[STATEMENT]
lemma OneHAInitState_SAStates:
   "\<lbrakk> S \<in> HAInitStates A; T \<in> HAInitStates A;
      S \<in> States SA; T \<in> States SA; SA \<in> SAs A \<rbrakk> \<Longrightarrow>
      S = T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>S \<in> HAInitStates A; T \<in> HAInitStates A; S \<in> States SA; T \<in> States SA; SA \<in> SAs A\<rbrakk> \<Longrightarrow> S = T
[PROOF STEP]
apply (unfold HAInitStates_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>S \<in> (\<Union>A\<in>SAs A. {InitState A}); T \<in> (\<Union>A\<in>SAs A. {InitState A}); S \<in> States SA; T \<in> States SA; SA \<in> SAs A\<rbrakk> \<Longrightarrow> S = T
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. \<lbrakk>InitState x \<in> States SA; InitState xa \<in> States SA; SA \<in> SAs A; x \<in> SAs A; S = InitState x; xa \<in> SAs A; T = InitState xa\<rbrakk> \<Longrightarrow> InitState x = InitState xa
[PROOF STEP]
apply (rename_tac AA AAA)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>AA AAA. \<lbrakk>InitState AA \<in> States SA; InitState AAA \<in> States SA; SA \<in> SAs A; AA \<in> SAs A; S = InitState AA; AAA \<in> SAs A; T = InitState AAA\<rbrakk> \<Longrightarrow> InitState AA = InitState AAA
[PROOF STEP]
apply (case_tac "AA = SA")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>AA AAA. \<lbrakk>InitState AA \<in> States SA; InitState AAA \<in> States SA; SA \<in> SAs A; AA \<in> SAs A; S = InitState AA; AAA \<in> SAs A; T = InitState AAA; AA = SA\<rbrakk> \<Longrightarrow> InitState AA = InitState AAA
 2. \<And>AA AAA. \<lbrakk>InitState AA \<in> States SA; InitState AAA \<in> States SA; SA \<in> SAs A; AA \<in> SAs A; S = InitState AA; AAA \<in> SAs A; T = InitState AAA; AA \<noteq> SA\<rbrakk> \<Longrightarrow> InitState AA = InitState AAA
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>AAA. \<lbrakk>InitState AAA \<in> States SA; SA \<in> SAs A; S = InitState SA; AAA \<in> SAs A; T = InitState AAA\<rbrakk> \<Longrightarrow> InitState SA = InitState AAA
[PROOF STEP]
apply (case_tac "AAA = SA")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>AAA. \<lbrakk>InitState AAA \<in> States SA; SA \<in> SAs A; S = InitState SA; AAA \<in> SAs A; T = InitState AAA; AAA = SA\<rbrakk> \<Longrightarrow> InitState SA = InitState AAA
 2. \<And>AAA. \<lbrakk>InitState AAA \<in> States SA; SA \<in> SAs A; S = InitState SA; AAA \<in> SAs A; T = InitState AAA; AAA \<noteq> SA\<rbrakk> \<Longrightarrow> InitState SA = InitState AAA
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma step_size_ok_2: "\<lbrakk>
  invar (States dir big small);
  step (States dir big small) = States dir' big' small';
  size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big
\<rbrakk> \<Longrightarrow> size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); step (States dir big small) = States dir' big' small'; size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big\<rbrakk> \<Longrightarrow> size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
using remaining_steps_decline step_size_new_small step_size_new_big
[PROOF STATE]
proof (prove)
using this:
invar ?states \<Longrightarrow> remaining_steps (step ?states) \<le> remaining_steps ?states
\<lbrakk>invar (States ?dir ?big ?small); step (States ?dir ?big ?small) = States ?dir' ?big' ?small'\<rbrakk> \<Longrightarrow> size_new ?small' = size_new ?small
\<lbrakk>invar (States ?dir ?big ?small); step (States ?dir ?big ?small) = States ?dir' ?big' ?small'\<rbrakk> \<Longrightarrow> size_new ?big' = size_new ?big

goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); step (States dir big small) = States dir' big' small'; size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big\<rbrakk> \<Longrightarrow> size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
by (smt (verit, best) add_le_mono le_refl le_trans)


[STATEMENT]
lemma hom_induced1:
  "\<exists>hom_relmap.
    (\<forall>p X S Y T f.
        continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T
        \<longrightarrow> (hom_relmap p X S Y T f) \<in> hom (relative_homology_group (int p) X S)
                               (relative_homology_group (int p) Y T)) \<and>
    (\<forall>p X S Y T f c.
        continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and>
        singular_relcycle p X S c
        \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) =
            homologous_rel_set p Y T (chain_map p f c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>hom_relmap. (\<forall>p X S Y T f. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>p X S Y T f c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>hom_relmap. (\<forall>p X S Y T f. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>p X S Y T f c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
have "\<exists>y. (y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and>
           (\<forall>c. singular_relcycle p X S c \<longrightarrow>
                y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))"
    if contf: "continuous_map X Y f" and fim: "f ` (topspace X \<inter> S) \<subseteq> T"
    for p X S Y T and f :: "'a \<Rightarrow> 'b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
let ?f = "(#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
let ?F = "\<lambda>x. singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
have 1: "?f \<in> hom (relcycle_group p X S) (relative_homology_group (int p) Y T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f \<in> hom (relcycle_group p X S) (relative_homology_group (int p) Y T)
[PROOF STEP]
apply (rule hom_compose [where H = "relcycle_group p Y T"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. chain_map p f \<in> hom (relcycle_group p X S) (relcycle_group p Y T)
 2. (#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<in> hom (relcycle_group p Y T) (relative_homology_group (int p) Y T)
[PROOF STEP]
apply (metis contf fim hom_chain_map relcycle_group_restrict)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<in> hom (relcycle_group p Y T) (relative_homology_group (int p) Y T)
[PROOF STEP]
by (simp add: nontrivial_relative_homology_group normal.r_coset_hom_Mod normal_subgroup_singular_relboundary_relcycle)
[PROOF STATE]
proof (state)
this:
(#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f \<in> hom (relcycle_group p X S) (relative_homology_group (int p) Y T)

goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
have 2: "singular_relboundary_set p X S \<lhd> relcycle_group p X S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_relboundary_set p X S \<lhd> relcycle_group p X S
[PROOF STEP]
using normal_subgroup_singular_relboundary_relcycle
[PROOF STATE]
proof (prove)
using this:
singular_relboundary_set ?p ?X ?S \<lhd> relcycle_group ?p ?X ?S

goal (1 subgoal):
 1. singular_relboundary_set p X S \<lhd> relcycle_group p X S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
singular_relboundary_set p X S \<lhd> relcycle_group p X S

goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
have 3: "?f x = ?f y"
      if "singular_relcycle p X S x" "singular_relcycle p X S y" "?F x = ?F y" for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y
[PROOF STEP]
have "singular_relboundary p Y T (chain_map p f (x - y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_relboundary p Y T (chain_map p f (x - y))
[PROOF STEP]
apply (rule singular_relboundary_chain_map [OF _ contf fim])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. singular_relboundary p X (topspace X \<inter> S) (x - y)
[PROOF STEP]
by (metis homologous_rel_def homologous_rel_eq mem_Collect_eq right_coset_singular_relboundary singular_relboundary_restrict that(3))
[PROOF STATE]
proof (state)
this:
singular_relboundary p Y T (chain_map p f (x - y))

goal (1 subgoal):
 1. ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
singular_relboundary p Y T (chain_map p f (x - y))
[PROOF STEP]
have "singular_relboundary p Y T (chain_map p f x - chain_map p f y)"
[PROOF STATE]
proof (prove)
using this:
singular_relboundary p Y T (chain_map p f (x - y))

goal (1 subgoal):
 1. singular_relboundary p Y T (chain_map p f x - chain_map p f y)
[PROOF STEP]
by (simp add: chain_map_diff)
[PROOF STATE]
proof (state)
this:
singular_relboundary p Y T (chain_map p f x - chain_map p f y)

goal (1 subgoal):
 1. ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y
[PROOF STEP]
with that
[PROOF STATE]
proof (chain)
picking this:
singular_relcycle p X S x
singular_relcycle p X S y
singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y
singular_relboundary p Y T (chain_map p f x - chain_map p f y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
singular_relcycle p X S x
singular_relcycle p X S y
singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y
singular_relboundary p Y T (chain_map p f x - chain_map p f y)

goal (1 subgoal):
 1. ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y
[PROOF STEP]
apply (simp add: right_coset_singular_relboundary homologous_rel_set_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>singular_relcycle p X S x; singular_relcycle p X S y; homologous_rel p X S x y; singular_relboundary p Y T (chain_map p f x - chain_map p f y)\<rbrakk> \<Longrightarrow> homologous_rel p Y T (chain_map p f x) (chain_map p f y)
[PROOF STEP]
apply (simp add: homologous_rel_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>singular_relcycle p X S ?x; singular_relcycle p X S ?y; singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> ?x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> ?y\<rbrakk> \<Longrightarrow> ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) ?x = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) ?y

goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
obtain g where "g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S)
                            (relative_homology_group (int p) Y T)"
                   "\<And>x. x \<in> singular_relcycle_set p X S \<Longrightarrow> g (?F x) = ?f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<lbrakk>g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T); \<And>x. x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using FactGroup_universal [OF 1 2 3, unfolded carrier_relcycle_group]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x y. \<lbrakk>x \<in> singular_relcycle_set p X S; y \<in> singular_relcycle_set p X S; singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y\<rbrakk> \<Longrightarrow> singular_relcycle p X S x; \<And>x y. \<lbrakk>x \<in> singular_relcycle_set p X S; y \<in> singular_relcycle_set p X S; singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y\<rbrakk> \<Longrightarrow> singular_relcycle p X S y; \<And>x y. \<lbrakk>x \<in> singular_relcycle_set p X S; y \<in> singular_relcycle_set p X S; singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y\<rbrakk> \<Longrightarrow> singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x = singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> y; \<And>g. \<lbrakk>g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T); \<And>x. x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>g. \<lbrakk>g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T); \<And>x. x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T)
?x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> ?x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) ?x

goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T)
?x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> ?x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) ?x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
g \<in> hom (relcycle_group p X S Mod singular_relboundary_set p X S) (relative_homology_group (int p) Y T)
?x \<in> singular_relcycle_set p X S \<Longrightarrow> g (singular_relboundary_set p X S #>\<^bsub>relcycle_group p X S\<^esub> ?x) = ((#>\<^bsub>relcycle_group p Y T\<^esub>) (singular_relboundary_set p Y T) \<circ> chain_map p f) ?x

goal (1 subgoal):
 1. \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
by (force simp: right_coset_singular_relboundary nontrivial_relative_homology_group)
[PROOF STATE]
proof (state)
this:
\<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>continuous_map ?X ?Y ?f; ?f ` (topspace ?X \<inter> ?S) \<subseteq> ?T\<rbrakk> \<Longrightarrow> \<exists>y. y \<in> hom (relative_homology_group (int ?p) ?X ?S) (relative_homology_group (int ?p) ?Y ?T) \<and> (\<forall>c. singular_relcycle ?p ?X ?S c \<longrightarrow> y (homologous_rel_set ?p ?X ?S c) = homologous_rel_set ?p ?Y ?T (chain_map ?p ?f c))

goal (1 subgoal):
 1. \<exists>hom_relmap. (\<forall>p X S Y T f. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>p X S Y T f c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>continuous_map ?X ?Y ?f; ?f ` (topspace ?X \<inter> ?S) \<subseteq> ?T\<rbrakk> \<Longrightarrow> \<exists>y. y \<in> hom (relative_homology_group (int ?p) ?X ?S) (relative_homology_group (int ?p) ?Y ?T) \<and> (\<forall>c. singular_relcycle ?p ?X ?S c \<longrightarrow> y (homologous_rel_set ?p ?X ?S c) = homologous_rel_set ?p ?Y ?T (chain_map ?p ?f c))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>continuous_map ?X ?Y ?f; ?f ` (topspace ?X \<inter> ?S) \<subseteq> ?T\<rbrakk> \<Longrightarrow> \<exists>y. y \<in> hom (relative_homology_group (int ?p) ?X ?S) (relative_homology_group (int ?p) ?Y ?T) \<and> (\<forall>c. singular_relcycle ?p ?X ?S c \<longrightarrow> y (homologous_rel_set ?p ?X ?S c) = homologous_rel_set ?p ?Y ?T (chain_map ?p ?f c))

goal (1 subgoal):
 1. \<exists>hom_relmap. (\<forall>p X S Y T f. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>p X S Y T f c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
apply (simp flip: all_conj_distrib)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>X Y f S T p. \<lbrakk>continuous_map X Y f; f ` (topspace X \<inter> S) \<subseteq> T\<rbrakk> \<Longrightarrow> \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))) \<Longrightarrow> \<exists>hom_relmap. \<forall>p X S Y T f. (continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))
[PROOF STEP]
apply ((subst choice_iff [symmetric])+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>X Y f S T p. \<lbrakk>continuous_map X Y f; f ` (topspace X \<inter> S) \<subseteq> T\<rbrakk> \<Longrightarrow> \<exists>y. y \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T) \<and> (\<forall>c. singular_relcycle p X S c \<longrightarrow> y (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))) \<Longrightarrow> \<forall>x xa xb xc xd xe. \<exists>y. (continuous_map xa xc xe \<and> xe ` (topspace xa \<inter> xb) \<subseteq> xd \<longrightarrow> y \<in> hom (relative_homology_group (int x) xa xb) (relative_homology_group (int x) xc xd)) \<and> (\<forall>c. continuous_map xa xc xe \<and> xe ` (topspace xa \<inter> xb) \<subseteq> xd \<and> singular_relcycle x xa xb c \<longrightarrow> y (homologous_rel_set x xa xb c) = homologous_rel_set x xc xd (chain_map x xe c))
[PROOF STEP]
apply metis
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>hom_relmap. (\<forall>p X S Y T f. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<longrightarrow> hom_relmap p X S Y T f \<in> hom (relative_homology_group (int p) X S) (relative_homology_group (int p) Y T)) \<and> (\<forall>p X S Y T f c. continuous_map X Y f \<and> f ` (topspace X \<inter> S) \<subseteq> T \<and> singular_relcycle p X S c \<longrightarrow> hom_relmap p X S Y T f (homologous_rel_set p X S c) = homologous_rel_set p Y T (chain_map p f c))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Int_stable_Icc: "Int_stable (range (\<lambda>(a, b). {a .. b::real}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Int_stable (range (\<lambda>(a, b). {a..b}))
[PROOF STEP]
by (auto simp: Int_stable_def)


[STATEMENT]
lemma him_diff [simp]: "HIm(p - q) = HIm p - HIm q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. HIm (p - q) = HIm p - HIm q
[PROOF STEP]
by (simp add: HIm_def vec_eq_iff vector_def)


[STATEMENT]
lemma isomorphic_group_cyclicity:
   "\<lbrakk>G \<cong> H; group G; group H\<rbrakk> \<Longrightarrow> cyclic_group G \<longleftrightarrow> cyclic_group H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>G \<cong> H; Group.group G; Group.group H\<rbrakk> \<Longrightarrow> cyclic_group G = cyclic_group H
[PROOF STEP]
by (meson ex_in_conv group.cyclic_group_epimorphic_image group.iso_sym is_iso_def iso_iff_mon_epi)


[STATEMENT]
theorem Plus_idem: "Plus r r = r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Plus r r = r
[PROOF STEP]
by (coinduction arbitrary: r) auto


[STATEMENT]
theorem assumes fin: "finite (UNIV :: 'a set)"
  and xs: "sorted xs" "distinct xs"
  and ys: "sorted ys" "distinct ys"
  shows set_less_aux_Compl2_conv_set_less_aux_Compl:
  "set xs \<sqsubset>' - set ys \<longleftrightarrow> set_less_aux_Compl None xs ys" (is ?Compl2)
  and Compl1_set_less_aux_conv_Compl_set_less_aux:
  "- set xs \<sqsubset>' set ys \<longleftrightarrow> Compl_set_less_aux None xs ys" (is ?Compl1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set xs \<sqsubset>' - set ys) = set_less_aux_Compl None xs ys &&& (- set xs \<sqsubset>' set ys) = Compl_set_less_aux None xs ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite UNIV
sorted xs
distinct xs
sorted ys
distinct ys

goal (1 subgoal):
 1. (set xs \<sqsubset>' - set ys) = set_less_aux_Compl None xs ys &&& (- set xs \<sqsubset>' set ys) = Compl_set_less_aux None xs ys
[PROOF STEP]
by(simp_all only: set_less_aux_conv_set_less_eq_aux set_less_aux_Compl_iff Compl_set_less_aux_Compl_iff set_less_eq_aux_Compl2_conv_set_less_eq_aux_Compl Compl1_set_less_eq_aux_conv_Compl_set_less_eq_aux)


[STATEMENT]
lemma (in is_functor) op_cf_obj_comma_is_iso_functor'[cat_comma_cs_intros]:
  assumes "b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>"
    and "\<AA>' = op_cat (\<FF> \<^sub>C\<^sub>F\<down> b)"
    and "\<BB>' = b \<down>\<^sub>C\<^sub>F (op_cf \<FF>)"
  shows "op_cf_obj_comma \<FF> b : \<AA>' \<mapsto>\<mapsto>\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<BB>'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. op_cf_obj_comma \<FF> b : \<AA>' \<mapsto>\<mapsto>\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<BB>'
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. op_cf_obj_comma \<FF> b : \<AA>' \<mapsto>\<mapsto>\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<BB>'
[PROOF STEP]
unfolding assms(2,3)
[PROOF STATE]
proof (prove)
using this:
b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. op_cf_obj_comma \<FF> b : op_cat (\<FF> \<^sub>C\<^sub>F\<down> b) \<mapsto>\<mapsto>\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> b \<down>\<^sub>C\<^sub>F (op_cf \<FF>)
[PROOF STEP]
by (rule op_cf_obj_comma_is_iso_functor)


[STATEMENT]
lemma iso_homology_contractible_space_subtopology2:
  "\<lbrakk>contractible_space X; S \<subseteq> topspace X; p \<noteq> 0; S \<noteq> {}\<rbrakk>
    \<Longrightarrow> homology_group p (subtopology X S) \<cong> relative_homology_group (p + 1) X S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>contractible_space X; S \<subseteq> topspace X; p \<noteq> 0; S \<noteq> {}\<rbrakk> \<Longrightarrow> homology_group p (subtopology X S) \<cong> relative_homology_group (p + 1) X S
[PROOF STEP]
by (metis (no_types, opaque_lifting) add.commute isomorphic_group_reduced_homology_of_contractible topspace_subtopology topspace_subtopology_subset un_reduced_homology_group)


[STATEMENT]
lemma dim_with: "dim = (\<lambda>X. dim_on_with UNIV (+) 0 scale X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.dim = dim_on_with UNIV (+) (0::'b) (*s)
[PROOF STEP]
unfolding dim_def dim_on_with_def dependent_with span_with
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>V. if \<exists>b. \<not> dependent_with (+) (0::'b) (*s) b \<and> span_with (+) (0::'b) (*s) b = span_with (+) (0::'b) (*s) V then card (SOME b. \<not> dependent_with (+) (0::'b) (*s) b \<and> span_with (+) (0::'b) (*s) b = span_with (+) (0::'b) (*s) V) else 0) = (\<lambda>X. if \<exists>b\<subseteq>UNIV. \<not> dependent_with (+) (0::'b) (*s) b \<and> span_with (+) (0::'b) (*s) b = span_with (+) (0::'b) (*s) X then card (SOME b. b \<subseteq> UNIV \<and> \<not> dependent_with (+) (0::'b) (*s) b \<and> span_with (+) (0::'b) (*s) b = span_with (+) (0::'b) (*s) X) else 0)
[PROOF STEP]
by force


[STATEMENT]
lemma measure_differentiable_image_eq:
  fixes f :: "real^'n::{finite,wellorder} \<Rightarrow> real^'n::_"
  assumes S: "S \<in> sets lebesgue"
    and der_f: "\<And>x. x \<in> S \<Longrightarrow> (f has_derivative f' x) (at x within S)"
    and inj: "inj_on f S"
    and intS: "(\<lambda>x. \<bar>det (matrix (f' x))\<bar>) integrable_on S"
  shows "measure lebesgue (f ` S) = integral S (\<lambda>x. \<bar>det (matrix (f' x))\<bar>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure lebesgue (f ` S) = integral S (\<lambda>x. \<bar>det (matrix (f' x))\<bar>)
[PROOF STEP]
using measurable_differentiable_image_eq [OF S der_f inj]
        assms has_measure_differentiable_image
[PROOF STATE]
proof (prove)
using this:
(\<And>x. x \<in> S \<Longrightarrow> x \<in> S) \<Longrightarrow> (f ` S \<in> lmeasurable) = ((\<lambda>x. \<bar>det (matrix (f' x))\<bar>) integrable_on S)
S \<in> sets lebesgue
?x \<in> S \<Longrightarrow> (f has_derivative f' ?x) (at ?x within S)
inj_on f S
(\<lambda>x. \<bar>det (matrix (f' x))\<bar>) integrable_on S
\<lbrakk>?S \<in> sets lebesgue; \<And>x. x \<in> ?S \<Longrightarrow> (?f has_derivative ?f' x) (at x within ?S); inj_on ?f ?S\<rbrakk> \<Longrightarrow> (?f ` ?S \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue (?f ` ?S) = ?m) = ((\<lambda>x. \<bar>det (matrix (?f' x))\<bar>) has_integral ?m) ?S

goal (1 subgoal):
 1. Sigma_Algebra.measure lebesgue (f ` S) = integral S (\<lambda>x. \<bar>det (matrix (f' x))\<bar>)
[PROOF STEP]
by blast


[STATEMENT]
lemma iT_Plus_finite_iff: "finite (I \<oplus> k) = finite I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (I \<oplus> k) = finite I
[PROOF STEP]
by (simp add: iT_Plus_def inj_on_finite_image_iff)


[STATEMENT]
lemma solve_consistent_rref_code[code abstract]:
  shows "vec_nth (solve_consistent_rref A b) = (% j. if (\<exists>i. A $ i $ j = 1 \<and> j=(LEAST n. A $ i $ n \<noteq> 0)) then b $ (THE i. A $ i $ j = 1) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (solve_consistent_rref A b) = (\<lambda>j. if \<exists>i. A $ i $ j = (1::'b) \<and> j = (LEAST n. A $ i $ n \<noteq> (0::'b)) then b $ (THE i. A $ i $ j = (1::'b)) else (0::'b))
[PROOF STEP]
unfolding solve_consistent_rref_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>j. if \<exists>i. A $ i $ j = (1::'b) \<and> j = (LEAST n. A $ i $ n \<noteq> (0::'b)) then b $ (THE i. A $ i $ j = (1::'b)) else (0::'b)) = (\<lambda>j. if \<exists>i. A $ i $ j = (1::'b) \<and> j = (LEAST n. A $ i $ n \<noteq> (0::'b)) then b $ (THE i. A $ i $ j = (1::'b)) else (0::'b))
[PROOF STEP]
by auto


[STATEMENT]
theorem pell_solutions:
 fixes D :: nat
 assumes "\<nexists>k. D = k\<^sup>2"
 obtains x\<^sub>0 y\<^sub>0 :: nat
 where   "\<forall>(x::int) (y::int).
            x\<^sup>2 - D * y\<^sup>2 = 1 \<longleftrightarrow>
            (\<exists>n::nat. nat \<bar>x\<bar> + sqrt D * nat \<bar>y\<bar> = (x\<^sub>0 + sqrt D * y\<^sub>0) ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x\<^sub>0 y\<^sub>0. \<forall>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real x\<^sub>0 + sqrt (real D) * real y\<^sub>0) ^ n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>x\<^sub>0 y\<^sub>0. \<forall>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real x\<^sub>0 + sqrt (real D) * real y\<^sub>0) ^ n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
\<nexists>k. D = k\<^sup>2
[PROOF STEP]
interpret pell
[PROOF STATE]
proof (prove)
using this:
\<nexists>k. D = k\<^sup>2

goal (1 subgoal):
 1. pell D
[PROOF STEP]
by unfold_locales (auto simp: is_nth_power_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>x\<^sub>0 y\<^sub>0. \<forall>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real x\<^sub>0 + sqrt (real D) * real y\<^sub>0) ^ n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof (rule that[of "fst fund_sol" "snd fund_sol"], intro allI, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
case (1 x y)
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
have "(x\<^sup>2 - int D * y\<^sup>2 = 1) \<longleftrightarrow> solution (x, y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x\<^sup>2 - int D * y\<^sup>2 = 1) = solution (x, y)
[PROOF STEP]
by (auto simp: solution_def)
[PROOF STATE]
proof (state)
this:
(x\<^sup>2 - int D * y\<^sup>2 = 1) = solution (x, y)

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x\<^sup>2 - int D * y\<^sup>2 = 1) = solution (x, y)

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
have "\<dots> \<longleftrightarrow> (\<exists>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. solution (x, y) = (\<exists>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n)
[PROOF STEP]
by (subst solution_iff_nth_solution') blast
[PROOF STATE]
proof (state)
this:
solution (x, y) = (\<exists>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n)

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
solution (x, y) = (\<exists>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n)

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
have "(\<lambda>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n) =
                 (\<lambda>n. pell_valuation (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = pell_valuation (nth_solution n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n) = (\<lambda>n. pell_valuation (case (nat \<bar>x\<bar>, nat \<bar>y\<bar>) of (x, y) \<Rightarrow> (int x, int y)) = pell_valuation (case nth_solution n of (x, y) \<Rightarrow> (int x, int y)))
[PROOF STEP]
by (subst pell_valuation_eq_iff) (auto simp add: case_prod_unfold prod_eq_iff fun_eq_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n) = (\<lambda>n. pell_valuation (case (nat \<bar>x\<bar>, nat \<bar>y\<bar>) of (x, y) \<Rightarrow> (int x, int y)) = pell_valuation (case nth_solution n of (x, y) \<Rightarrow> (int x, int y)))

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (nat \<bar>x\<bar>, nat \<bar>y\<bar>) = nth_solution n) = (\<lambda>n. pell_valuation (case (nat \<bar>x\<bar>, nat \<bar>y\<bar>) of (x, y) \<Rightarrow> (int x, int y)) = pell_valuation (case nth_solution n of (x, y) \<Rightarrow> (int x, int y)))

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
have "\<dots> = (\<lambda>n. nat \<bar>x\<bar> + sqrt D * nat \<bar>y\<bar> = (fst fund_sol + sqrt D * snd fund_sol) ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. pell_valuation (case (nat \<bar>x\<bar>, nat \<bar>y\<bar>) of (x, y) \<Rightarrow> (int x, int y)) = pell_valuation (case nth_solution n of (x, y) \<Rightarrow> (int x, int y))) = (\<lambda>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
by (subst pell_valuation_nth_solution)
         (simp add: pell_valuation_def case_prod_unfold mult_ac)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. pell_valuation (case (nat \<bar>x\<bar>, nat \<bar>y\<bar>) of (x, y) \<Rightarrow> (int x, int y)) = pell_valuation (case nth_solution n of (x, y) \<Rightarrow> (int x, int y))) = (\<lambda>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)

goal (1 subgoal):
 1. \<And>x y. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)

goal (1 subgoal):
 1. (x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(x\<^sup>2 - int D * y\<^sup>2 = 1) = (\<exists>n. real (nat \<bar>x\<bar>) + sqrt (real D) * real (nat \<bar>y\<bar>) = (real (fst fund_sol) + sqrt (real D) * real (snd fund_sol)) ^ n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma interval_of_plus: "interval_of (a + b) = interval_of a + interval_of b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interval_of (a + b) = interval_of a + interval_of b
[PROOF STEP]
by (simp add: interval_eqI)


[STATEMENT]
lemma (in \<Z>) vsnd_arrow_is_cat_Rel_iso_arr'[cat_Rel_par_set_cs_intros]:
  assumes "a \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>"
    and "B \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>"
    and "AB = set {a} \<times>\<^sub>\<circ> B"
    and "A' = A"
    and "\<CC>' = cat_Rel \<alpha>"
  shows "vsnd_arrow (set {a}) B : AB \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>'\<^esub> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vsnd_arrow (ZFC_in_HOL.set {a}) B : AB \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>'\<^esub> B
[PROOF STEP]
using assms(1-2)
[PROOF STATE]
proof (prove)
using this:
a \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>
B \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. vsnd_arrow (ZFC_in_HOL.set {a}) B : AB \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>'\<^esub> B
[PROOF STEP]
unfolding assms(3-5)
[PROOF STATE]
proof (prove)
using this:
a \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>
B \<in>\<^sub>\<circ> cat_Rel \<alpha>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. vsnd_arrow (ZFC_in_HOL.set {a}) B : ZFC_in_HOL.set {a} \<times>\<^sub>\<circ> B \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>cat_Rel \<alpha>\<^esub> B
[PROOF STEP]
by (rule vsnd_arrow_is_cat_Rel_iso_arr)


[STATEMENT]
lemma pos_pow2: "(0::nat) < 2^(n::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 2 ^ n
[PROOF STEP]
by simp


[STATEMENT]
lemma "0 + Suc n = Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 + Suc n = Suc n
[PROOF STEP]
by normalization


[STATEMENT]
lemma scalar_prod_lincomb_orthogonal: assumes ortho: "orthogonal gs" and gs: "set gs \<subseteq> carrier_vec n"
  shows "k \<le> length gs \<Longrightarrow> sumlist (map (\<lambda> i. g i \<cdot>\<^sub>v gs ! i) [0 ..< k]) \<bullet> sumlist (map (\<lambda> i. h i \<cdot>\<^sub>v gs ! i) [0 ..< k])
  = sum_list (map (\<lambda> i. g i * h i * (gs ! i \<bullet> gs ! i)) [0 ..< k])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
proof (induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
Suc k \<le> length gs

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
note ortho = orthogonalD[OF ortho]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < length gs; ?j < length gs\<rbrakk> \<Longrightarrow> (gs ! ?i \<bullet> gs ! ?j = (0::'a)) = (?i \<noteq> ?j)

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
let ?m = "length gs"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
from gs Suc(2)
[PROOF STATE]
proof (chain)
picking this:
set gs \<subseteq> carrier_vec n
Suc k \<le> length gs
[PROOF STEP]
have gsi[simp]: "\<And> i. i \<le> k \<Longrightarrow> gs ! i \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
set gs \<subseteq> carrier_vec n
Suc k \<le> length gs

goal (1 subgoal):
 1. \<And>i. i \<le> k \<Longrightarrow> gs ! i \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i1 \<le> k \<Longrightarrow> gs ! ?i1 \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
Suc k \<le> length gs
[PROOF STEP]
have kn: "k \<le> ?m" and k: "k < ?m"
[PROOF STATE]
proof (prove)
using this:
k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
Suc k \<le> length gs

goal (1 subgoal):
 1. k \<le> length gs &&& k < length gs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<le> length gs
k < length gs

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
let ?v1 = "sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k])"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
let ?v2 = "(g k \<cdot>\<^sub>v gs ! k)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
let ?w1 = "sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k])"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
let ?w2 = "(h k \<cdot>\<^sub>v gs ! k)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
Suc k \<le> length gs
[PROOF STEP]
have id: "[0 ..< Suc k] = [0 ..< k] @ [k]"
[PROOF STATE]
proof (prove)
using this:
k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i))
Suc k \<le> length gs

goal (1 subgoal):
 1. [0..<Suc k] = [0..<k] @ [k]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[0..<Suc k] = [0..<k] @ [k]

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have id: "sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = ?v1 + ?v2"
     "sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = ?w1 + ?w2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k &&& M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k
[PROOF STEP]
unfolding id map_append
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k] @ map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [k]) = M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k &&& M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k] @ map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [k]) = M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k
[PROOF STEP]
by (subst sumlist_append, insert Suc(2), auto)+
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k
M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have v1: "?v1 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n
[PROOF STEP]
by (rule sumlist_carrier, insert Suc(2), auto)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have v2: "?v2 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
by (insert Suc(2), auto)
[PROOF STATE]
proof (state)
this:
g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have w1: "?w1 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n
[PROOF STEP]
by (rule sumlist_carrier, insert Suc(2), auto)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have w2: "?w2 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
by (insert Suc(2), auto)
[PROOF STATE]
proof (state)
this:
h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have gsk: "gs ! k \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs ! k \<in> carrier_vec n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gs ! k \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have v12: "?v1 + ?v2 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
using v1 v2
[PROOF STATE]
proof (prove)
using this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n
g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have w12: "?w1 + ?w2 \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
using w1 w2
[PROOF STATE]
proof (prove)
using this:
M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) \<in> carrier_vec n
h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k \<in> carrier_vec n

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have 0: "\<And> g h. i < k \<Longrightarrow> (g \<cdot>\<^sub>v gs ! i) \<bullet> (h \<cdot>\<^sub>v gs ! k) = 0" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>g h. i < k \<Longrightarrow> (g \<cdot>\<^sub>v gs ! i) \<bullet> (h \<cdot>\<^sub>v gs ! k) = (0::'a)
[PROOF STEP]
by (subst scalar_prod_smult_distrib[OF _ gsk], (insert k, auto)[1],
    subst smult_scalar_prod_distrib[OF _ gsk], (insert k, auto)[1], insert ortho[of i k] k, auto)
[PROOF STATE]
proof (state)
this:
?i2 < k \<Longrightarrow> (?g1 \<cdot>\<^sub>v gs ! ?i2) \<bullet> (?h1 \<cdot>\<^sub>v gs ! k) = (0::'a)

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have 1: "?v1 \<bullet> ?w2 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> (h k \<cdot>\<^sub>v gs ! k) = (0::'a)
[PROOF STEP]
by (subst scalar_prod_left_sum_distrib[OF _ w2], (insert Suc(2), auto)[1], rule sum_list_neutral,
        insert 0, auto)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> (h k \<cdot>\<^sub>v gs ! k) = (0::'a)

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
have 2: "?v2 \<bullet> ?w1 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g k \<cdot>\<^sub>v gs ! k) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (0::'a)
[PROOF STEP]
unfolding comm_scalar_prod[OF v2 w1]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> (g k \<cdot>\<^sub>v gs ! k) = (0::'a)
[PROOF STEP]
apply (subst scalar_prod_left_sum_distrib[OF _ v2])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>v. v \<in> set (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) \<Longrightarrow> v \<in> carrier_vec n
 2. (\<Sum>v\<leftarrow>map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]. v \<bullet> (g k \<cdot>\<^sub>v gs ! k)) = (0::'a)
[PROOF STEP]
apply ((insert gs, force)[1])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>v\<leftarrow>map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]. v \<bullet> (g k \<cdot>\<^sub>v gs ! k)) = (0::'a)
[PROOF STEP]
apply (rule sum_list_neutral)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> set (map (\<lambda>v. v \<bullet> (g k \<cdot>\<^sub>v gs ! k)) (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k])) \<Longrightarrow> x = (0::'a)
[PROOF STEP]
by (insert 0, auto)
[PROOF STATE]
proof (state)
this:
(g k \<cdot>\<^sub>v gs ! k) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (0::'a)

goal (2 subgoals):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
 2. \<And>k. \<lbrakk>k \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) = (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)); Suc k \<le> length gs\<rbrakk> \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) + g k \<cdot>\<^sub>v gs ! k) \<bullet> (M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + h k \<cdot>\<^sub>v gs ! k) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
unfolding scalar_prod_add_distrib[OF v12 w1 w2]
      add_scalar_prod_distrib[OF v1 v2 w1]
      add_scalar_prod_distrib[OF v1 v2 w2]
      scalar_prod_smult_distrib[OF w2 gsk]
      smult_scalar_prod_distrib[OF gsk gsk]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + (g k \<cdot>\<^sub>v gs ! k) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + (M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> (h k \<cdot>\<^sub>v gs ! k) + (g k \<cdot>\<^sub>v gs ! k) \<bullet> (h k \<cdot>\<^sub>v gs ! k)) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
unfolding Suc(1)[OF kn]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<leftarrow>[0..<k]. g i * h i * (gs ! i \<bullet> gs ! i)) + (g k \<cdot>\<^sub>v gs ! k) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<k]) + (M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<k]) \<bullet> (h k \<cdot>\<^sub>v gs ! k) + (g k \<cdot>\<^sub>v gs ! k) \<bullet> (h k \<cdot>\<^sub>v gs ! k)) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
by (simp add: 1 2 comm_scalar_prod[OF v2 w1])
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<Suc k]) = (\<Sum>i\<leftarrow>[0..<Suc k]. g i * h i * (gs ! i \<bullet> gs ! i))

goal (1 subgoal):
 1. 0 \<le> length gs \<Longrightarrow> M.sumlist (map (\<lambda>i. g i \<cdot>\<^sub>v gs ! i) [0..<0]) \<bullet> M.sumlist (map (\<lambda>i. h i \<cdot>\<^sub>v gs ! i) [0..<0]) = (\<Sum>i\<leftarrow>[0..<0]. g i * h i * (gs ! i \<bullet> gs ! i))
[PROOF STEP]
qed auto


[STATEMENT]
lemma vec_of_ell2_scaleR[code]:
  \<comment> \<open>Code equation for multiplying a vector with a real scalar\<close>
  "vec_of_ell2 (scaleR a \<psi>) = smult_vec (complex_of_real a) (vec_of_ell2 \<psi>)"
  for \<psi> :: "'a::enum ell2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_ell2 (a *\<^sub>R \<psi>) = complex_of_real a \<cdot>\<^sub>v vec_of_ell2 \<psi>
[PROOF STEP]
by (simp add: vec_of_ell2_def vec_of_basis_enum_scaleR)


[STATEMENT]
lemma univ_for_pr_lm_5: "c_fst (c_fst key) mod 7 = 5 \<Longrightarrow> univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 5 \<Longrightarrow> univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 5 \<Longrightarrow> univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))
[PROOF STEP]
assume A: "c_fst (c_fst key) mod 7 = 5"
[PROOF STATE]
proof (state)
this:
c_fst (c_fst key) mod 7 = 5

goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 5 \<Longrightarrow> univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))
[PROOF STEP]
have S1: "univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)
[PROOF STEP]
by (simp add: univ_for_pr_def pr_conv_2_to_1_def)
[PROOF STATE]
proof (state)
this:
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)

goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 5 \<Longrightarrow> univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))
[PROOF STEP]
with A
[PROOF STATE]
proof (chain)
picking this:
c_fst (c_fst key) mod 7 = 5
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c_fst (c_fst key) mod 7 = 5
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)

goal (1 subgoal):
 1. univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))
[PROOF STEP]
by (simp add: nat_to_pr_lm_5 c_f_pair_def univ_for_pr_def pr_conv_2_to_1_def)
[PROOF STATE]
proof (state)
this:
univ_for_pr key = c_pair (univ_for_pr (c_pair (c_fst (c_snd (c_fst key))) (c_snd key))) (univ_for_pr (c_pair (c_snd (c_snd (c_fst key))) (c_snd key)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nn_integral_count_space_top_approx:
  fixes f :: "nat => ennreal" and b :: ennreal
  assumes "nn_integral (count_space UNIV) f = top"
  and "b < top"
  obtains n where "b < sum f {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. b < sum f {..<n} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
integral\<^sup>N (count_space UNIV) f = \<top>
b < \<top>

goal (1 subgoal):
 1. (\<And>n. b < sum f {..<n} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding nn_integral_count_space_nat suminf_eq_SUP SUP_eq_top_iff
[PROOF STATE]
proof (prove)
using this:
\<forall>x<\<top>. \<exists>i\<in>UNIV. x < sum f {..<i}
b < \<top>

goal (1 subgoal):
 1. (\<And>n. b < sum f {..<n} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by(auto)


[STATEMENT]
lemma (in Ring) prod_n_principal_ideal:"\<lbrakk>e \<in> {j. j\<le>n} \<rightarrow> {j. (0::nat)\<le>j};
f \<in> {j. j\<le>n} \<rightarrow> carrier R; \<forall>k\<le> n. J k = (Rxa R (f k))\<^bsup>\<diamondsuit>R (e k)\<^esup>\<rbrakk> \<Longrightarrow>
                 ideal_n_prod R n J = Rxa R (mprod_expR R e f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>e \<in> {j. j \<le> n} \<rightarrow> {j. 0 \<le> j}; f \<in> {j. j \<le> n} \<rightarrow> carrier R; \<forall>k\<le>n. J k = R \<diamondsuit>\<^sub>p f k \<^bsup>\<diamondsuit>R e k\<^esup>\<rbrakk> \<Longrightarrow> i\<Pi>\<^bsub>R,n\<^esub> J = R \<diamondsuit>\<^sub>p mprod_expR R e f n
[PROOF STEP]
apply (simp add:prod_n_principal_idealTr[of e n f J])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma list_assn_aux_append2[simp]:
  assumes "length l2=length l2'"
  shows "list_assn P (l1@l2) (l1'@l2')
    = list_assn P l1 l1' * list_assn P l2 l2'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (cases "length l1 = length l1'")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length l1 = length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
 2. length l1 \<noteq> length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (erule list_assn_aux_append)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length l1 \<noteq> length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (simp add: list_assn_aux_ineq_len assms)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma int_pos_mult_monor:"\<lbrakk> 0 < (n::int); 0 \<le> n * m \<rbrakk> \<Longrightarrow> 0 \<le> m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < n; 0 \<le> n * m\<rbrakk> \<Longrightarrow> 0 \<le> m
[PROOF STEP]
by (rule mult_pos_iff, assumption+)


[STATEMENT]
lemma degree_mult_not_eq:
  "degree (f * g) \<noteq> degree f + degree g \<Longrightarrow> lead_coeff f * lead_coeff g = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (f * g) \<noteq> degree f + degree g \<Longrightarrow> lead_coeff f * lead_coeff g = (0::'a)
[PROOF STEP]
by (rule ccontr, auto simp: coeff_mult_degree_sum degree_mult_le le_antisym le_degree)


[STATEMENT]
lemma order_gt_0 [simp]: "order \<G> > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < order \<G>
[PROOF STEP]
using prime_order prime_gt_0_nat
[PROOF STATE]
proof (prove)
using this:
prime (order \<G>)
prime ?p \<Longrightarrow> 0 < ?p

goal (1 subgoal):
 1. 0 < order \<G>
[PROOF STEP]
by blast


[STATEMENT]
lemma Suc_diff[simp]: "\<And>n m. n\<ge>m \<Longrightarrow> m\<ge>1 \<Longrightarrow> Suc (n - m) = n - (m - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n m. \<lbrakk>m \<le> n; 1 \<le> m\<rbrakk> \<Longrightarrow> Suc (n - m) = n - (m - 1)
[PROOF STEP]
by simp


[STATEMENT]
lemma div_power_helper:
  "\<lbrakk> x \<le> y; y < LENGTH('a) \<rbrakk> \<Longrightarrow> (2 ^ y - 1) div (2 ^ x :: 'a::len word) = 2 ^ (y - x) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y < LENGTH('a)\<rbrakk> \<Longrightarrow> (2 ^ y - 1) div 2 ^ x = 2 ^ (y - x) - 1
[PROOF STEP]
apply (simp flip: mask_eq_exp_minus_1 drop_bit_eq_div)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y < LENGTH('a)\<rbrakk> \<Longrightarrow> drop_bit x (mask y) = mask (y - x)
[PROOF STEP]
apply (rule bit_word_eqI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>x \<le> y; y < LENGTH('a); n < LENGTH('a)\<rbrakk> \<Longrightarrow> bit (drop_bit x (mask y)) n = bit (mask (y - x)) n
[PROOF STEP]
apply (auto simp add: bit_simps not_le)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma aless_natless:"(an n < an m) = (n < m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (an n < an m) = (n < m)
[PROOF STEP]
apply (simp add:an_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ant (int n) < ant (int m)) = (n < m)
[PROOF STEP]
apply (simp add:aless_zless)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sumset_is_empty_iff [simp]: "sumset A B = {} \<longleftrightarrow> A \<inter> G = {} \<or> B \<inter> G = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sumset A B = {}) = (A \<inter> G = {} \<or> B \<inter> G = {})
[PROOF STEP]
by (auto simp: sumset_eq)


[STATEMENT]
lemma flip_length[simp]: "length (flip i xs) = length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (flip i xs) = length xs
[PROOF STEP]
apply(induct xs arbitrary: i)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i. length (flip i []) = length []
 2. \<And>a xs i. (\<And>i. length (flip i xs) = length xs) \<Longrightarrow> length (flip i (a # xs)) = length (a # xs)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. length (flip i xs) = length xs) \<Longrightarrow> length (flip i (a # xs)) = length (a # xs)
[PROOF STEP]
apply(case_tac i)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a xs i. \<lbrakk>\<And>i. length (flip i xs) = length xs; i = 0\<rbrakk> \<Longrightarrow> length (flip i (a # xs)) = length (a # xs)
 2. \<And>a xs i nat. \<lbrakk>\<And>i. length (flip i xs) = length xs; i = Suc nat\<rbrakk> \<Longrightarrow> length (flip i (a # xs)) = length (a # xs)
[PROOF STEP]
by(simp_all)


[STATEMENT]
lemma takeWhile_eq_all_conv[simp]:
  "(takeWhile P xs = xs) = (\<forall>x \<in> set xs. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (takeWhile P xs = xs) = (\<forall>x\<in>set xs. P x)
[PROOF STEP]
by(induct xs, auto)


[STATEMENT]
lemma distributed_transform_integral:
  assumes Px: "distributed M N X Px" "\<And>x. x \<in> space N \<Longrightarrow> 0 \<le> Px x"
  assumes "distributed M P Y Py" "\<And>x. x \<in> space P \<Longrightarrow> 0 \<le> Py x"
  assumes Y: "Y = T \<circ> X" and T: "T \<in> measurable N P" and f: "f \<in> borel_measurable P"
  shows "(\<integral>x. Py x * f x \<partial>P) = (\<integral>x. Px x * f (T x) \<partial>N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
have "(\<integral>x. Py x * f x \<partial>P) = (\<integral>x. f (Y x) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|M. f (Y x)
[PROOF STEP]
by (rule distributed_integral) fact+
[PROOF STATE]
proof (state)
this:
LINT x|P. Py x * f x = LINT x|M. f (Y x)

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
LINT x|P. Py x * f x = LINT x|M. f (Y x)

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
have "\<dots> = (\<integral>x. f (T (X x)) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|M. f (Y x) = LINT x|M. f (T (X x))
[PROOF STEP]
using Y
[PROOF STATE]
proof (prove)
using this:
Y = T \<circ> X

goal (1 subgoal):
 1. LINT x|M. f (Y x) = LINT x|M. f (T (X x))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
LINT x|M. f (Y x) = LINT x|M. f (T (X x))

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
LINT x|M. f (Y x) = LINT x|M. f (T (X x))

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
have "\<dots> = (\<integral>x. Px x * f (T x) \<partial>N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|M. f (T (X x)) = LINT x|N. Px x * f (T x)
[PROOF STEP]
using measurable_comp[OF T f] Px
[PROOF STATE]
proof (prove)
using this:
f \<circ> T \<in> borel_measurable N
distributed M N X (\<lambda>x. ennreal (Px x))
?x \<in> space N \<Longrightarrow> 0 \<le> Px ?x

goal (1 subgoal):
 1. LINT x|M. f (T (X x)) = LINT x|N. Px x * f (T x)
[PROOF STEP]
by (intro distributed_integral[symmetric]) (auto simp: comp_def)
[PROOF STATE]
proof (state)
this:
LINT x|M. f (T (X x)) = LINT x|N. Px x * f (T x)

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)

goal (1 subgoal):
 1. LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
LINT x|P. Py x * f x = LINT x|N. Px x * f (T x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_integral_null [intro]: "content(cbox a b) = 0 \<Longrightarrow> (f has_integral 0) (cbox a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content (cbox a b) = 0 \<Longrightarrow> (f has_integral (0::'b)) (cbox a b)
[PROOF STEP]
unfolding has_integral_cbox
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content (cbox a b) = 0 \<Longrightarrow> (sum (\<lambda>(x, k). content k *\<^sub>R f x) \<longlongrightarrow> (0::'b)) (division_filter (cbox a b))
[PROOF STEP]
using eventually_division_filter_tagged_division[of "cbox a b"]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F p in division_filter (cbox a b). p tagged_division_of cbox a b

goal (1 subgoal):
 1. content (cbox a b) = 0 \<Longrightarrow> (sum (\<lambda>(x, k). content k *\<^sub>R f x) \<longlongrightarrow> (0::'b)) (division_filter (cbox a b))
[PROOF STEP]
by (subst tendsto_cong[where g="\<lambda>_. 0"]) (auto elim: eventually_mono intro: sum_content_null)


[STATEMENT]
lemma ipoly_0_0[simp]: "ipoly f (0::'a::{comm_ring_1,ring_char_0}) = 0 \<longleftrightarrow> poly f 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ipoly f (0::'a) = (0::'a)) = (poly f 0 = 0)
[PROOF STEP]
unfolding poly_0_coeff_0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (coeff (of_int_poly f) 0 = (0::'a)) = (coeff f 0 = 0)
[PROOF STEP]
by simp


[STATEMENT]
lemma lm044:
  "pseudoAllocation a = \<Union> {{(fst pair, {y})| y. y \<in> snd pair}| pair. pair \<in> a}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pseudoAllocation a = \<Union> {{(fst pair, {y}) |y. y \<in> snd pair} |pair. pair \<in> a}
[PROOF STEP]
unfolding pseudoAllocation_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (omega ` a) = \<Union> {{(fst pair, {y}) |y. y \<in> snd pair} |pair. pair \<in> a}
[PROOF STEP]
using lm043
[PROOF STATE]
proof (prove)
using this:
omega ?pair = {(fst ?pair, {y}) |y. y \<in> snd ?pair}

goal (1 subgoal):
 1. \<Union> (omega ` a) = \<Union> {{(fst pair, {y}) |y. y \<in> snd pair} |pair. pair \<in> a}
[PROOF STEP]
by blast


[STATEMENT]
lemma (in prob_space) AE_iff_emeasure_eq_1:
  assumes [measurable]: "Measurable.pred M P"
  shows "(AE x in M. P x) \<longleftrightarrow> emeasure M {x\<in>space M. P x} = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. almost_everywhere M P = (emeasure M {x \<in> space M. P x} = 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. almost_everywhere M P = (emeasure M {x \<in> space M. P x} = 1)
[PROOF STEP]
have *: "{x \<in> space M. \<not> P x} = space M - {x\<in>space M. P x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x \<in> space M. \<not> P x} = space M - {x \<in> space M. P x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x \<in> space M. \<not> P x} = space M - {x \<in> space M. P x}

goal (1 subgoal):
 1. almost_everywhere M P = (emeasure M {x \<in> space M. P x} = 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. almost_everywhere M P = (emeasure M {x \<in> space M. P x} = 1)
[PROOF STEP]
by (auto simp add: ennreal_minus_eq_0 * emeasure_compl emeasure_space_1 AE_iff_measurable[OF _ refl]
             intro: antisym emeasure_le_1)
[PROOF STATE]
proof (state)
this:
almost_everywhere M P = (emeasure M {x \<in> space M. P x} = 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma upper_triangular_imp_det_eq_0_iff:
  fixes A :: "'a :: idom mat"
  assumes "A \<in> carrier_mat n n" and "upper_triangular A"
  shows "det A = 0 \<longleftrightarrow> 0 \<in> set (diag_mat A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (det A = (0::'a)) = ((0::'a) \<in> set (diag_mat A))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
upper_triangular A

goal (1 subgoal):
 1. (det A = (0::'a)) = ((0::'a) \<in> set (diag_mat A))
[PROOF STEP]
by (auto simp: det_upper_triangular)


[STATEMENT]
lemma variance_prod_pmf_slice:
  fixes f :: "'a \<Rightarrow> real"
  assumes "i \<in> I" "finite I"
  assumes "integrable (measure_pmf (M i)) (\<lambda>\<omega>. f \<omega>^2)"
  shows "prob_space.variance (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)) = prob_space.variance (M i) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
have a:"integrable (measure_pmf (M i)) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable (measure_pmf (M i)) f
[PROOF STEP]
using assms(3) measure_pmf.square_integrable_imp_integrable
[PROOF STATE]
proof (prove)
using this:
integrable (measure_pmf (M i)) (\<lambda>\<omega>. (f \<omega>)\<^sup>2)
\<lbrakk>measure_pmf.random_variable ?M borel ?f; integrable (measure_pmf ?M) (\<lambda>x. (?f x)\<^sup>2)\<rbrakk> \<Longrightarrow> integrable (measure_pmf ?M) ?f

goal (1 subgoal):
 1. integrable (measure_pmf (M i)) f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
integrable (measure_pmf (M i)) f

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
have b:" integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i))\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i))\<^sup>2)
[PROOF STEP]
by (rule integrable_Pi_pmf_slice[OF assms(2) assms(1)], metis assms(3))
[PROOF STATE]
proof (state)
this:
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i))\<^sup>2)

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
have c:" integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. f (x i))
[PROOF STEP]
by (rule integrable_Pi_pmf_slice[OF assms(2) assms(1)], metis a)
[PROOF STATE]
proof (state)
this:
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. f (x i))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
have "measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 =
      measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 = measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2
[PROOF STEP]
using assms a b c
[PROOF STATE]
proof (prove)
using this:
i \<in> I
finite I
integrable (measure_pmf (M i)) (\<lambda>\<omega>. (f \<omega>)\<^sup>2)
integrable (measure_pmf (M i)) f
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i))\<^sup>2)
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. f (x i))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 = measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2
[PROOF STEP]
by ((subst expectation_Pi_pmf_slice[OF assms(2,1)])?, simp)+
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 = measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 = measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
using assms a b c
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i))\<^sup>2) - (measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f (x i)))\<^sup>2 = measure_pmf.expectation (M i) (\<lambda>x. (f x)\<^sup>2) - (measure_pmf.expectation (M i) f)\<^sup>2
i \<in> I
finite I
integrable (measure_pmf (M i)) (\<lambda>\<omega>. (f \<omega>)\<^sup>2)
integrable (measure_pmf (M i)) f
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. (f (x i))\<^sup>2)
integrable (measure_pmf (Pi_pmf I d M)) (\<lambda>x. f (x i))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)
[PROOF STEP]
by (simp add: measure_pmf.variance_eq)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. (f (x i) - measure_pmf.expectation (Pi_pmf I d M) (\<lambda>\<omega>. f (\<omega> i)))\<^sup>2) = measure_pmf.expectation (M i) (\<lambda>x. (f x - measure_pmf.expectation (M i) f)\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma trunc_degree:
  assumes "f \<in> carrier P"
  assumes "degree f > 0"
  shows "degree (trunc f) < degree f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deg R (Cring_Poly.truncate R f) < deg R f
[PROOF STEP]
unfolding truncate_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deg R (f \<ominus>\<^bsub>UP R\<^esub> leading_term R f) < deg R f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier P
0 < deg R f

goal (1 subgoal):
 1. deg R (f \<ominus>\<^bsub>UP R\<^esub> leading_term R f) < deg R f
[PROOF STEP]
by (metis ltrm_closed ltrm_decomp P.add.right_cancel Cring_Poly.truncate_def trunc_closed trunc_simps(1))


[STATEMENT]
lemma less_sets_weaken1: "\<lbrakk>A' \<lless> B; A \<subseteq> A'\<rbrakk> \<Longrightarrow> A \<lless> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A' \<lless> B; A \<subseteq> A'\<rbrakk> \<Longrightarrow> A \<lless> B
[PROOF STEP]
by (auto simp: less_sets_def)


[STATEMENT]
lemma cbox_2D:
  fixes x\<^sub>0 :: real and y\<^sub>0 :: real
  shows "cbox (x\<^sub>0, y\<^sub>0) (x\<^sub>1, y\<^sub>1) = { (x, y). x\<^sub>0 \<le> x \<and> x \<le> x\<^sub>1 \<and> y\<^sub>0 \<le> y \<and> y \<le> y\<^sub>1 }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cbox (x\<^sub>0, y\<^sub>0) (x\<^sub>1, y\<^sub>1) = {(x, y). x\<^sub>0 \<le> x \<and> x \<le> x\<^sub>1 \<and> y\<^sub>0 \<le> y \<and> y \<le> y\<^sub>1}
[PROOF STEP]
by fastforce


[STATEMENT]
lemma nth_map_zip:
assumes "i < length xs"
assumes "i < length ys"
shows "map f (zip xs ys) ! i = f (xs ! i, ys ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map f (zip xs ys) ! i = f (xs ! i, ys ! i)
[PROOF STEP]
using nth_zip nth_map length_zip
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < length ?xs; ?i < length ?ys\<rbrakk> \<Longrightarrow> zip ?xs ?ys ! ?i = (?xs ! ?i, ?ys ! ?i)
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)
length (zip ?xs ?ys) = min (length ?xs) (length ?ys)

goal (1 subgoal):
 1. map f (zip xs ys) ! i = f (xs ! i, ys ! i)
[PROOF STEP]
by (simp add: assms(1) assms(2))


[STATEMENT]
lemma eval_eterm_cong: "(\<And>n. n \<in> fv_fo_term_set t \<Longrightarrow> \<sigma> n = \<sigma>' n) \<Longrightarrow>
  eval_eterm \<sigma> t = eval_eterm \<sigma>' t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. n \<in> fv_fo_term_set t \<Longrightarrow> \<sigma> n = \<sigma>' n) \<Longrightarrow> \<sigma> \<cdot>e t = \<sigma>' \<cdot>e t
[PROOF STEP]
by (cases t) auto


[STATEMENT]
lemma closed_interval_left:
  fixes b :: "'a::euclidean_space"
  shows "closed {x::'a. \<forall>i\<in>Basis. x\<bullet>i \<le> b\<bullet>i}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed {x. \<forall>i\<in>Basis. x \<bullet> i \<le> b \<bullet> i}
[PROOF STEP]
by (simp add: Collect_ball_eq closed_INT closed_Collect_le continuous_on_inner)