[STATEMENT]
lemma renaming_preserves_cardinality :
  "card (rename_clause A C) = card C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
have im: "rename_clause A C = (rename_literal A) ` C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rename_clause A C = rename_literal A ` C
[PROOF STEP]
unfolding rename_clause_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {L. \<exists>LL. LL \<in> C \<and> L = rename_literal A LL} = rename_literal A ` C
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rename_clause A C = rename_literal A ` C

goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
have "inj_on (rename_literal A) C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (rename_literal A) C
[PROOF STEP]
by (metis inj_onI inverse_renaming)
[PROOF STATE]
proof (state)
this:
inj_on (rename_literal A) C

goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
from this and im
[PROOF STATE]
proof (chain)
picking this:
inj_on (rename_literal A) C
rename_clause A C = rename_literal A ` C
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inj_on (rename_literal A) C
rename_clause A C = rename_literal A ` C

goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
using card_image
[PROOF STATE]
proof (prove)
using this:
inj_on (rename_literal A) C
rename_clause A C = rename_literal A ` C
inj_on ?f ?A \<Longrightarrow> card (?f ` ?A) = card ?A

goal (1 subgoal):
 1. card (rename_clause A C) = card C
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (rename_clause A C) = card C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_ennrealD:
  assumes lim: "((\<lambda>x. ennreal (f x)) \<longlongrightarrow> ennreal x) F"
  assumes *: "\<forall>\<^sub>F x in F. 0 \<le> f x" and x: "0 \<le> x"
  shows "(f \<longlongrightarrow> x) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<longlongrightarrow> x) F
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (f \<longlongrightarrow> x) F
[PROOF STEP]
have "((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F
    \<longleftrightarrow> (f \<longlongrightarrow> enn2ereal (ennreal x)) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F
[PROOF STEP]
using "*" eventually_mono
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. 0 \<le> f x
\<lbrakk>eventually ?P ?F; \<And>x. ?P x \<Longrightarrow> ?Q x\<rbrakk> \<Longrightarrow> eventually ?Q ?F

goal (1 subgoal):
 1. ((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F
[PROOF STEP]
by (intro tendsto_cong) fastforce
[PROOF STATE]
proof (state)
this:
((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F

goal (1 subgoal):
 1. (f \<longlongrightarrow> x) F
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F

goal (1 subgoal):
 1. (f \<longlongrightarrow> x) F
[PROOF STEP]
using assms(1) continuous_at_enn2ereal isCont_tendsto_compose x
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. enn2ereal (ennreal (f x))) \<longlongrightarrow> enn2ereal (ennreal x)) F = ((\<lambda>x. ereal (f x)) \<longlongrightarrow> enn2ereal (ennreal x)) F
((\<lambda>x. ennreal (f x)) \<longlongrightarrow> ennreal x) F
continuous (at ?x within ?A) enn2ereal
\<lbrakk>isCont ?g ?l; (?f \<longlongrightarrow> ?l) ?F\<rbrakk> \<Longrightarrow> ((\<lambda>x. ?g (?f x)) \<longlongrightarrow> ?g ?l) ?F
0 \<le> x

goal (1 subgoal):
 1. (f \<longlongrightarrow> x) F
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(f \<longlongrightarrow> x) F

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in pdigraph) dghm_proj_ObjMap_vrange:
  assumes "i \<in>\<^sub>\<circ> I"
  shows "\<R>\<^sub>\<circ> (\<pi>\<^sub>D\<^sub>G I \<AA> i\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<AA> i\<lparr>Obj\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<R>\<^sub>\<circ> (\<pi>\<^sub>D\<^sub>G I \<AA> i\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<AA> i\<lparr>Obj\<rparr>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i \<in>\<^sub>\<circ> I

goal (1 subgoal):
 1. \<R>\<^sub>\<circ> (\<pi>\<^sub>D\<^sub>G I \<AA> i\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<AA> i\<lparr>Obj\<rparr>
[PROOF STEP]
unfolding dghm_proj_components
[PROOF STATE]
proof (prove)
using this:
i \<in>\<^sub>\<circ> I

goal (1 subgoal):
 1. \<R>\<^sub>\<circ> (\<lambda>a\<in>\<^sub>\<circ>dg_prod I \<AA>\<lparr>Obj\<rparr>. a\<lparr>i\<rparr>) \<subseteq>\<^sub>\<circ> \<AA> i\<lparr>Obj\<rparr>
[PROOF STEP]
by (intro vrange_VLambda_vsubset) (clarsimp simp: dg_prod_components)


[STATEMENT]
lemma atMost_atLeastAtMost_0_conv: "{..i::nat} = {0..i}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {..i} = {0..i}
[PROOF STEP]
by (simp add: set_interval_defs)


[STATEMENT]
lemma image_nonempty:"\<lbrakk>f \<in> A \<rightarrow> B; A1 \<subseteq> A; A1 \<noteq> {} \<rbrakk> \<Longrightarrow> f ` A1 \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; A1 \<subseteq> A; A1 \<noteq> {}\<rbrakk> \<Longrightarrow> f ` A1 \<noteq> {}
[PROOF STEP]
by (frule nonempty_some[of "A1"],
       frule elem_in_image2[of "f" "A" "B" "A1" "SOME x. x \<in> A1"],
        assumption+, simp add:nonempty)


[STATEMENT]
lemma uints_unats: "uints n = int ` unats n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uints n = int ` unats n
[PROOF STEP]
apply (unfold unats_def uints_num)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {i. 0 \<le> i \<and> i < 2 ^ n} = int ` {i. i < 2 ^ n}
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>0 \<le> x; x < 2 ^ n\<rbrakk> \<Longrightarrow> x \<in> int ` {i. i < 2 ^ n}
 2. \<And>x xa. xa < 2 ^ n \<Longrightarrow> 0 \<le> int xa
 3. \<And>x xa. xa < 2 ^ n \<Longrightarrow> int xa < 2 ^ n
[PROOF STEP]
apply (rule_tac image_eqI)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>x. \<lbrakk>0 \<le> x; x < 2 ^ n\<rbrakk> \<Longrightarrow> x = int (?x10 x)
 2. \<And>x. \<lbrakk>0 \<le> x; x < 2 ^ n\<rbrakk> \<Longrightarrow> ?x10 x \<in> {i. i < 2 ^ n}
 3. \<And>x xa. xa < 2 ^ n \<Longrightarrow> 0 \<le> int xa
 4. \<And>x xa. xa < 2 ^ n \<Longrightarrow> int xa < 2 ^ n
[PROOF STEP]
apply (erule_tac nat_0_le [symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>0 \<le> x; x < 2 ^ n\<rbrakk> \<Longrightarrow> nat x \<in> {i. i < 2 ^ n}
 2. \<And>x xa. xa < 2 ^ n \<Longrightarrow> 0 \<le> int xa
 3. \<And>x xa. xa < 2 ^ n \<Longrightarrow> int xa < 2 ^ n
[PROOF STEP]
by auto


[STATEMENT]
lemma pdevs_apply_update_slist: "pdevs_apply (Pdevs (update_slist n x xs)) i =
  (if i = n then x else pdevs_apply (Pdevs xs) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pdevs_apply (Pdevs (update_slist n x xs)) i = (if i = n then x else pdevs_apply (Pdevs xs) i)
[PROOF STEP]
by transfer (auto simp: Pdevs_raw_def)


[STATEMENT]
lemma guard_match_commute: "guardMatch t1 t2 = guardMatch t2 t1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. guardMatch t1 t2 = guardMatch t2 t1
[PROOF STEP]
apply (simp add: guardMatch_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<exists>n. Guards t1 = [Eq (V (I 0)) (L (Num n))]) \<and> (\<exists>n'. Guards t2 = [Eq (V (I 0)) (L (Num n'))])) = ((\<exists>n. Guards t2 = [Eq (V (I 0)) (L (Num n))]) \<and> (\<exists>n'. Guards t1 = [Eq (V (I 0)) (L (Num n'))]))
[PROOF STEP]
by auto


[STATEMENT]
lemma dim_extract_matrix:
shows "dim_row (extract_matrix as m n) = m"
and "dim_col (extract_matrix as m n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (extract_matrix as m n) = m &&& dim_col (extract_matrix as m n) = n
[PROOF STEP]
unfolding extract_matrix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (mat m n (\<lambda>(i, j). as (i * n + j))) = m &&& dim_col (mat m n (\<lambda>(i, j). as (i * n + j))) = n
[PROOF STEP]
by simp_all


[STATEMENT]
lemma rev_map_pow:  "(rev_map f) (w\<^sup>@n) = rev ((f (rev w))\<^sup>@n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev_map f (w \<^sup>@ n) = rev (f (rev w) \<^sup>@ n)
[PROOF STEP]
by (simp add: pow_morph rev_map_arg rev_pow)


[STATEMENT]
lemma (in cpx_sq_mat) make_pm_projectors:
  assumes "A\<in> fc_mats"
  and "hermitian A"
and "i < proj_meas_size (make_pm A)"
shows "projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))
[PROOF STEP]
have "proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))
[PROOF STEP]
using assms make_pm_proj_measurement'
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
i < proj_meas_size (make_pm A)
\<lbrakk>?A \<in> fc_mats; hermitian ?A\<rbrakk> \<Longrightarrow> proj_measurement (proj_meas_size (make_pm ?A)) (proj_meas_outcomes (make_pm ?A))

goal (1 subgoal):
 1. proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))

goal (1 subgoal):
 1. projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))

goal (1 subgoal):
 1. projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))
[PROOF STEP]
using proj_measurement_proj assms
[PROOF STATE]
proof (prove)
using this:
proj_measurement (proj_meas_size (make_pm A)) (proj_meas_outcomes (make_pm A))
\<lbrakk>proj_measurement ?p ?M; ?i < ?p\<rbrakk> \<Longrightarrow> projector (meas_outcome_prj (?M ?i))
A \<in> fc_mats
hermitian A
i < proj_meas_size (make_pm A)

goal (1 subgoal):
 1. projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
projector (meas_outcome_prj (proj_meas_outcomes (make_pm A) i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) iso_group_mul_gen:
  assumes "A \<lhd> G" "B \<lhd> G"
  shows "(\<lambda>(x,y). x \<otimes> y) \<in> iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G
     \<longleftrightarrow> A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G)
[PROOF STEP]
interpret group_disjoint_sum G A B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. group_disjoint_sum G A B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<lhd> G
B \<lhd> G

goal (1 subgoal):
 1. group_disjoint_sum G A B
[PROOF STEP]
by (auto simp: group_disjoint_sum_def normal_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G)
[PROOF STEP]
by (simp add: subset_one iso_group_mul_eq assms)
[PROOF STATE]
proof (state)
this:
((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B \<subseteq> {\<one>} \<and> A <#> B = carrier G)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma reconstruct_poly_monic_defines_mset:
  assumes "(\<Prod>a\<leftarrow>as. [:- a, 1:]) = (\<Prod>a\<leftarrow>bs. [:- a, 1::'a::field:])"
  shows "mset as = mset bs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
let ?as = "mset (map (\<lambda> a. [:- a, 1:]) as)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
let ?bs = "mset (map (\<lambda> a. [:- a, 1:]) bs)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
have eq_smult:"prod_mset ?as = prod_mset ?bs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) as)) = \<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) bs))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(\<Prod>a\<leftarrow>as. [:- a, 1::'a:]) = (\<Prod>a\<leftarrow>bs. [:- a, 1::'a:])

goal (1 subgoal):
 1. \<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) as)) = \<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) bs))
[PROOF STEP]
by (metis prod_mset_prod_list)
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) as)) = \<Prod>\<^sub># (mset (map (\<lambda>a. [:- a, 1::'a:]) bs))

goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
have irr:"\<And> as::'a list. set_mset (mset (map (\<lambda> a. [:- a, 1:]) as)) \<subseteq> {q. irreducible q \<and> monic q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>as. set_mset (mset (map (\<lambda>a. [:- a, 1::'a:]) as)) \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
by (auto intro!: linear_term_irreducible\<^sub>d[of "-_::'a", simplified])
[PROOF STATE]
proof (state)
this:
set_mset (mset (map (\<lambda>a. [:- a, 1::'a:]) ?as)) \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
from monic_factorization_unique_mset[OF eq_smult irr irr]
[PROOF STATE]
proof (chain)
picking this:
mset (map (\<lambda>a. [:- a, 1::'a:]) as) = mset (map (\<lambda>a. [:- a, 1::'a:]) bs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mset (map (\<lambda>a. [:- a, 1::'a:]) as) = mset (map (\<lambda>a. [:- a, 1::'a:]) bs)

goal (1 subgoal):
 1. mset as = mset bs
[PROOF STEP]
apply (subst inj_eq[OF multiset.inj_map,symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. mset (map (\<lambda>a. [:- a, 1::'a:]) as) = mset (map (\<lambda>a. [:- a, 1::'a:]) bs) \<Longrightarrow> inj ?f4
 2. mset (map (\<lambda>a. [:- a, 1::'a:]) as) = mset (map (\<lambda>a. [:- a, 1::'a:]) bs) \<Longrightarrow> image_mset ?f4 (mset as) = image_mset ?f4 (mset bs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mset as = mset bs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mset_set_set_mset':
  assumes "\<forall>x. count M x \<le> 1"
  shows "mset_set (set_mset M) = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. count M x \<le> 1
[PROOF STEP]
have "count M x = 0 \<or> count M x = 1"
[PROOF STATE]
proof (prove)
using this:
\<forall>x. count M x \<le> 1

goal (1 subgoal):
 1. count M x = 0 \<or> count M x = 1
[PROOF STEP]
by (auto elim: le_SucE)
[PROOF STATE]
proof (state)
this:
count M x = 0 \<or> count M x = 1

goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
count M x = 0 \<or> count M x = 1
[PROOF STEP]
have "count (mset_set (set_mset M)) x = count M x"
[PROOF STATE]
proof (prove)
using this:
count M x = 0 \<or> count M x = 1

goal (1 subgoal):
 1. count (mset_set (set_mset M)) x = count M x
[PROOF STEP]
by (metis count_eq_zero_iff count_mset_set(1,3) finite_set_mset)
[PROOF STATE]
proof (state)
this:
count (mset_set (set_mset M)) x = count M x

goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
count (mset_set (set_mset M)) ?x2 = count M ?x2

goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
count (mset_set (set_mset M)) ?x2 = count M ?x2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
count (mset_set (set_mset M)) ?x2 = count M ?x2

goal (1 subgoal):
 1. mset_set (set_mset M) = M
[PROOF STEP]
by (simp add: multiset_eq_iff)
[PROOF STATE]
proof (state)
this:
mset_set (set_mset M) = M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma polyneg0: "isnpolyh p n \<Longrightarrow> (~\<^sub>p p) = 0\<^sub>p \<longleftrightarrow> p = 0\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isnpolyh p n \<Longrightarrow> (~\<^sub>p p = 0\<^sub>p) = (p = 0\<^sub>p)
[PROOF STEP]
by (induct p arbitrary: n rule: polyneg.induct) (auto simp add: Nneg_def)


[STATEMENT]
lemma (in finite_measure) ennreal_integral_real:
  assumes [measurable]: "f \<in> borel_measurable M"
  assumes ae: "AE x in M. f x \<le> ennreal B" "0 \<le> B"
  shows "ennreal (\<integral>x. enn2real (f x) \<partial>M) = (\<integral>\<^sup>+x. f x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (LINT x|M. enn2real (f x)) = integral\<^sup>N M f
[PROOF STEP]
proof (subst nn_integral_eq_integral[symmetric])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. integrable M (\<lambda>x. enn2real (f x))
 2. AE x in M. 0 \<le> enn2real (f x)
 3. \<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M = integral\<^sup>N M f
[PROOF STEP]
show "integrable M (\<lambda>x. enn2real (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M (\<lambda>x. enn2real (f x))
[PROOF STEP]
using ae
[PROOF STATE]
proof (prove)
using this:
AE x in M. f x \<le> ennreal B
0 \<le> B

goal (1 subgoal):
 1. integrable M (\<lambda>x. enn2real (f x))
[PROOF STEP]
by (intro integrable_const_bound[where B=B]) (auto simp: enn2real_leI)
[PROOF STATE]
proof (state)
this:
integrable M (\<lambda>x. enn2real (f x))

goal (2 subgoals):
 1. AE x in M. 0 \<le> enn2real (f x)
 2. \<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M = integral\<^sup>N M f
[PROOF STEP]
show "(\<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M) = integral\<^sup>N M f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M = integral\<^sup>N M f
[PROOF STEP]
using ae
[PROOF STATE]
proof (prove)
using this:
AE x in M. f x \<le> ennreal B
0 \<le> B

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M = integral\<^sup>N M f
[PROOF STEP]
by (intro nn_integral_cong_AE) (auto simp: le_less_trans[OF _ ennreal_less_top])
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (enn2real (f x)) \<partial>M = integral\<^sup>N M f

goal (1 subgoal):
 1. AE x in M. 0 \<le> enn2real (f x)
[PROOF STEP]
qed auto


[STATEMENT]
lemma eqvt_fresh_cong1: "(\<And>p x. p \<bullet> (f x) = f (p \<bullet> x)) \<Longrightarrow> a \<sharp> x \<Longrightarrow> a \<sharp> f x "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> f x
[PROOF STEP]
apply (rule fresh_fun_eqvt_app[of f])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> eqvt f
 2. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> x
[PROOF STEP]
apply (rule eqvtI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>p. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> p \<bullet> f \<equiv> f
 2. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> x
[PROOF STEP]
apply (rule eq_reflection)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>p. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> p \<bullet> f = f
 2. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> x
[PROOF STEP]
apply (rule ext)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>p xa. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> (p \<bullet> f) xa = f xa
 2. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> x
[PROOF STEP]
apply (metis permute_fun_def permute_minus_cancel(1))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>p x. p \<bullet> f x = f (p \<bullet> x); a \<sharp> x\<rbrakk> \<Longrightarrow> a \<sharp> x
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma [code abstract]:
shows "vec_nth (Gauss_Jordan_in_ij A i j) = (let n = (LEAST n. A $ n $ j \<noteq> 0 \<and> i \<le> n);
  interchange_A = (interchange_rows A i n);
  A' = mult_row interchange_A i (1/interchange_A$i$j) in
  (% s. if s=i then A' $ s else (row_add A' s i (-(interchange_A$s$j))) $ s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (Gauss_Jordan_in_ij A i j) = (let n = LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n; interchange_A = interchange_rows A i n; A' = mult_row interchange_A i ((1::'b) / interchange_A $ i $ j) in (\<lambda>s. if s = i then A' $ s else row_add A' s i (- interchange_A $ s $ j) $ s))
[PROOF STEP]
unfolding Gauss_Jordan_in_ij_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>s. if s = i then mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n)) i ((1::'b) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ i $ j) $ s else row_add (mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n)) i ((1::'b) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ i $ j)) s i (- interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ s $ j) $ s) = (\<lambda>s. if s = i then mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n)) i ((1::'b) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ i $ j) $ s else row_add (mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n)) i ((1::'b) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ i $ j)) s i (- interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'b) \<and> i \<le> n) $ s $ j) $ s)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma not_and_lt:
  "\<not> (A B Lt C D \<and> C D Lt A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (A B Lt C D \<and> C D Lt A B)
[PROOF STEP]
by (simp add: Lt_def le_anti_symmetry)


[STATEMENT]
lemma bounded_linear_sum:
  fixes f :: "'i \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
  shows "(\<And>i. i \<in> I \<Longrightarrow> bounded_linear (f i)) \<Longrightarrow> bounded_linear (\<lambda>x. \<Sum>i\<in>I. f i x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> bounded_linear (f i)) \<Longrightarrow> bounded_linear (\<lambda>x. \<Sum>i\<in>I. f i x)
[PROOF STEP]
by (induct I rule: infinite_finite_induct) (auto intro!: bounded_linear_add)


[STATEMENT]
lemma rank_Gauss_Jordan_eq:
  fixes A::"'a::{field}^'n::{mod_type}^'m::{mod_type}"
  shows "rank A = (let A'=(Gauss_Jordan A) in card {row i A' |i. row i A' \<noteq> 0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = (let A' = Gauss_Jordan A in card {row i A' |i. row i A' \<noteq> 0})
[PROOF STEP]
by (metis (mono_tags) rank_Gauss_Jordan rref_Gauss_Jordan rref_rank)


[STATEMENT]
lemma cone_decomp_map_times:
  assumes "cone_decomp T ps"
  shows "cone_decomp ((*) s ` T) (map (apfst ((*) (s::_ \<Rightarrow>\<^sub>0 _::{comm_ring_1,ring_no_zero_divisors}))) ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cone_decomp ((*) s ` T) (map (apfst ((*) s)) ps)
[PROOF STEP]
proof (rule cone_decompI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
cone_decomp T ps
[PROOF STEP]
have "direct_decomp T (map cone ps)"
[PROOF STATE]
proof (prove)
using this:
cone_decomp T ps

goal (1 subgoal):
 1. direct_decomp T (map cone ps)
[PROOF STEP]
by (rule cone_decompD)
[PROOF STATE]
proof (state)
this:
direct_decomp T (map cone ps)

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
hence "direct_decomp ((*) s ` T) (map ((`) ((*) s)) (map cone ps))"
[PROOF STATE]
proof (prove)
using this:
direct_decomp T (map cone ps)

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map ((`) ((*) s)) (map cone ps))
[PROOF STEP]
by (rule direct_decomp_image_times) (rule times_canc_left)
[PROOF STATE]
proof (state)
this:
direct_decomp ((*) s ` T) (map ((`) ((*) s)) (map cone ps))

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
direct_decomp ((*) s ` T) (map ((`) ((*) s)) (map cone ps))

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
have "map ((`) ((*) s)) (map cone ps) = map cone (map (apfst ((*) s)) ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ((`) ((*) s)) (map cone ps) = map cone (map (apfst ((*) s)) ps)
[PROOF STEP]
by (simp add: cone_image_times')
[PROOF STATE]
proof (state)
this:
map ((`) ((*) s)) (map cone ps) = map cone (map (apfst ((*) s)) ps)

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
show "direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))"
[PROOF STATE]
proof (prove)
using this:
direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))

goal (1 subgoal):
 1. direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
direct_decomp ((*) s ` T) (map cone (map (apfst ((*) s)) ps))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vint_plus_transfer[transfer_rule]:
  includes lifting_syntax
  shows "(cr_vint ===> cr_vint ===> cr_vint) (+\<^sub>\<int>) (+)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cr_vint ===> cr_vint ===> cr_vint) (+\<^sub>\<int>) (+)
[PROOF STEP]
using vint_fpair_in_fproduct_vint
[PROOF STATE]
proof (prove)
using this:
[?a\<^sub>\<int>, ?b\<^sub>\<int>]\<^sub>\<circ> \<in>\<^sub>\<circ> \<int>\<^sub>\<circ> ^\<^sub>\<times> 2\<^sub>\<nat>

goal (1 subgoal):
 1. (cr_vint ===> cr_vint ===> cr_vint) (+\<^sub>\<int>) (+)
[PROOF STEP]
by (intro rel_funI, unfold vint_plus_def cr_vint_def cr_scalar_def)
    (simp add: nat_omega_simps)


[STATEMENT]
lemma desargues_config_not_col_12:
  assumes "desargues_config A B C A' B' C' M N P R"
  shows "\<not> col C B B'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> col C B B'
[PROOF STEP]
using assms desargues_config_not_col_8 desargues_config_rot_CW
[PROOF STATE]
proof (prove)
using this:
desargues_config A B C A' B' C' M N P R
desargues_config ?A ?B ?C ?A' ?B' ?C' ?M ?N ?P ?R \<Longrightarrow> \<not> col ?A ?C ?C'
desargues_config ?A ?B ?C ?A' ?B' ?C' ?M ?N ?P ?R \<Longrightarrow> desargues_config ?C ?A ?B ?C' ?A' ?B' ?P ?M ?N ?R

goal (1 subgoal):
 1. \<not> col C B B'
[PROOF STEP]
by blast


[STATEMENT]
lemma interval_bij_bij:
  "\<forall>(i::'a::euclidean_space)\<in>Basis. a\<bullet>i < b\<bullet>i \<and> u\<bullet>i < v\<bullet>i \<Longrightarrow>
    interval_bij (a, b) (u, v) (interval_bij (u, v) (a, b) x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>Basis. a \<bullet> i < b \<bullet> i \<and> u \<bullet> i < v \<bullet> i \<Longrightarrow> interval_bij (a, b) (u, v) (interval_bij (u, v) (a, b) x) = x
[PROOF STEP]
by (auto simp: interval_bij_def euclidean_eq_iff[where 'a='a])


[STATEMENT]
lemma mod_ring_is_field:
  assumes"Factorial_Ring.prime p"
  shows "field (mod_ring p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
have p_ge_0: "p > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p
[PROOF STEP]
using assms prime_gt_0_nat
[PROOF STATE]
proof (prove)
using this:
normalization_semidom_class.prime p
normalization_semidom_class.prime ?p \<Longrightarrow> 0 < ?p

goal (1 subgoal):
 1. 0 < p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
0 < p

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
have p_ge_1: "p > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < p
[PROOF STEP]
using assms prime_gt_1_nat
[PROOF STATE]
proof (prove)
using this:
normalization_semidom_class.prime p
normalization_semidom_class.prime ?p \<Longrightarrow> 1 < ?p

goal (1 subgoal):
 1. 1 < p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 < p

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
interpret field "ZFact (int p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. field (ZFact (int p))
[PROOF STEP]
using zfact_prime_is_field[OF assms]
[PROOF STATE]
proof (prove)
using this:
field (ZFact (int p))

goal (1 subgoal):
 1. field (ZFact (int p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
have "field ((mod_ring p) \<lparr> zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub> \<rparr>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. field (mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr>)
[PROOF STEP]
by (rule ring_iso_imp_img_field[OF zfact_iso_inv_is_ring_iso[OF p_ge_1]])
[PROOF STATE]
proof (state)
this:
field (mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr>)

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
field (mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr>)

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
have
    "(mod_ring p) \<lparr> zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub> \<rparr> = mod_ring p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr> = mod_ring p
[PROOF STEP]
using zfact_iso_inv_0[OF p_ge_0]
[PROOF STATE]
proof (prove)
using this:
zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub> = 0

goal (1 subgoal):
 1. mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr> = mod_ring p
[PROOF STEP]
by (simp add:mod_ring_def)
[PROOF STATE]
proof (state)
this:
mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr> = mod_ring p

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
field (mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr>)
mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr> = mod_ring p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
field (mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr>)
mod_ring p\<lparr>zero := zfact_iso_inv p \<zero>\<^bsub>ZFact (int p)\<^esub>\<rparr> = mod_ring p

goal (1 subgoal):
 1. field (mod_ring p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
field (mod_ring p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sq_mtx_inv_idempotent[simp]: "mtx_invertible A \<Longrightarrow> A\<^sup>-\<^sup>1\<^sup>-\<^sup>1 = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mtx_invertible A \<Longrightarrow> A\<^sup>-\<^sup>1\<^sup>-\<^sup>1 = A
[PROOF STEP]
using mtx_invertibleD sq_mtx_inv_unique
[PROOF STATE]
proof (prove)
using this:
mtx_invertible ?A \<Longrightarrow> ?A\<^sup>-\<^sup>1 * ?A = 1
mtx_invertible ?A \<Longrightarrow> ?A * ?A\<^sup>-\<^sup>1 = 1
\<lbrakk>?A * ?B = 1; ?B * ?A = 1\<rbrakk> \<Longrightarrow> ?A\<^sup>-\<^sup>1 = ?B

goal (1 subgoal):
 1. mtx_invertible A \<Longrightarrow> A\<^sup>-\<^sup>1\<^sup>-\<^sup>1 = A
[PROOF STEP]
by blast


[STATEMENT]
lemma majoritiesE:
  assumes crd: "card (UNIV::('a::finite) set) < card (S::'a set) + card (T::'a set)"
  obtains p where "p \<in> S" and "p \<in> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p. \<lbrakk>p \<in> S; p \<in> T\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using crd majorities_intersect
[PROOF STATE]
proof (prove)
using this:
card UNIV < card S + card T
card UNIV < card ?S + card ?T \<Longrightarrow> ?S \<inter> ?T \<noteq> {}

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>p \<in> S; p \<in> T\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast


[STATEMENT]
lemma gcd_0:
  "gcd a 0 = normalize a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. normalization_euclidean_semiring_class.gcd a (0::'a) = normalize a
[PROOF STEP]
by (simp add: gcd.simps [of a 0])


[STATEMENT]
lemma denominator_nonzero: "f (2 - t) + f (t - 1) = 0 \<longleftrightarrow> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f (2 - t) + f (t - 1) = 0) = False
[PROOF STEP]
using denominator_pos[of t]
[PROOF STATE]
proof (prove)
using this:
0 < f (2 - t) + f (t - 1)

goal (1 subgoal):
 1. (f (2 - t) + f (t - 1) = 0) = False
[PROOF STEP]
by auto


[STATEMENT]
lemma from_hma\<^sub>v_add: "from_hma\<^sub>v v + from_hma\<^sub>v w = from_hma\<^sub>v (v + w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_hma\<^sub>v v + from_hma\<^sub>v w = from_hma\<^sub>v (v + w)
[PROOF STEP]
unfolding from_hma\<^sub>v_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.vec CARD('b) (\<lambda>i. v $h Bij_Nat.from_nat i) + Matrix.vec CARD('b) (\<lambda>i. w $h Bij_Nat.from_nat i) = Matrix.vec CARD('b) (\<lambda>i. (v + w) $h Bij_Nat.from_nat i)
[PROOF STEP]
by auto


[STATEMENT]
lemma lm04_06_one_step_relation_register_old:
  fixes l::register
    and ic::configuration
    and p::program

  defines "s \<equiv> fst ic"
      and "tape \<equiv> snd ic"

  defines "m \<equiv> length p"
      and "tape' \<equiv> snd (step ic p)"

  assumes is_val: "is_valid ic p"
      and l: \<open>l < length tape\<close>

  shows "(tape'!l) = (tape!l) + (if isadd (p!s) \<and> l = modifies (p!s) then 1 else 0)
                              - Z ic p l 0 * (if issub (p!s) \<and> l = modifies (p!s) then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
[PROOF STEP]
using l
[PROOF STATE]
proof (prove)
using this:
l < length tape

goal (1 subgoal):
 1. tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
[PROOF STEP]
apply (cases \<open>p!s\<close>)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x11 x12. \<lbrakk>l < length tape; p ! s = Add x11 x12\<rbrakk> \<Longrightarrow> tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
 2. \<And>x21 x22 x23. \<lbrakk>l < length tape; p ! s = Sub x21 x22 x23\<rbrakk> \<Longrightarrow> tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
 3. \<lbrakk>l < length tape; p ! s = Halt\<rbrakk> \<Longrightarrow> tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)
[PROOF STEP]
apply (auto simp: assms(1-4) step_def update_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x22 x23. \<lbrakk>l < length (snd ic); p ! fst ic = Sub l x22 x23; 0 < snd ic ! l\<rbrakk> \<Longrightarrow> snd ic ! l - Suc 0 = snd ic ! l - Z ic p l 0
[PROOF STEP]
using nth_digit_0
[PROOF STATE]
proof (prove)
using this:
?x \<le> 1 \<Longrightarrow> ?x \<exclamdown> 0 = ?x

goal (1 subgoal):
 1. \<And>x22 x23. \<lbrakk>l < length (snd ic); p ! fst ic = Sub l x22 x23; 0 < snd ic ! l\<rbrakk> \<Longrightarrow> snd ic ! l - Suc 0 = snd ic ! l - Z ic p l 0
[PROOF STEP]
by (auto simp add: Z_def R_def)
[PROOF STATE]
proof (state)
this:
tape' ! l = tape ! l + (if isadd (p ! s) \<and> l = modifies (p ! s) then 1 else 0) - Z ic p l 0 * (if issub (p ! s) \<and> l = modifies (p ! s) then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in residues_prime) prime_totient_eq: "totient p = p - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totient p = p - 1
[PROOF STEP]
using totient_eq
[PROOF STATE]
proof (prove)
using this:
totient (nat (int p)) = card (Units R)

goal (1 subgoal):
 1. totient p = p - 1
[PROOF STEP]
by (simp add: res_prime_units_eq)


[STATEMENT]
lemma prime_elem_imp_coprime:
  assumes "prime_elem p" "\<not>p dvd n"
  shows   "coprime p n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime p n
[PROOF STEP]
proof (rule coprimeI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd p; c dvd n\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
fix d
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd p; c dvd n\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
assume "d dvd p" "d dvd n"
[PROOF STATE]
proof (state)
this:
d dvd p
d dvd n

goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd p; c dvd n\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
show "is_unit d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_unit d
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> is_unit d \<Longrightarrow> False
[PROOF STEP]
assume "\<not>is_unit d"
[PROOF STATE]
proof (state)
this:
\<not> is_unit d

goal (1 subgoal):
 1. \<not> is_unit d \<Longrightarrow> False
[PROOF STEP]
from \<open>prime_elem p\<close> and \<open>d dvd p\<close> and this
[PROOF STATE]
proof (chain)
picking this:
prime_elem p
d dvd p
\<not> is_unit d
[PROOF STEP]
have "p dvd d"
[PROOF STATE]
proof (prove)
using this:
prime_elem p
d dvd p
\<not> is_unit d

goal (1 subgoal):
 1. p dvd d
[PROOF STEP]
by (rule prime_elemD2)
[PROOF STATE]
proof (state)
this:
p dvd d

goal (1 subgoal):
 1. \<not> is_unit d \<Longrightarrow> False
[PROOF STEP]
from this and \<open>d dvd n\<close>
[PROOF STATE]
proof (chain)
picking this:
p dvd d
d dvd n
[PROOF STEP]
have "p dvd n"
[PROOF STATE]
proof (prove)
using this:
p dvd d
d dvd n

goal (1 subgoal):
 1. p dvd n
[PROOF STEP]
by (rule dvd_trans)
[PROOF STATE]
proof (state)
this:
p dvd n

goal (1 subgoal):
 1. \<not> is_unit d \<Longrightarrow> False
[PROOF STEP]
with \<open>\<not>p dvd n\<close>
[PROOF STATE]
proof (chain)
picking this:
\<not> p dvd n
p dvd n
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<not> p dvd n
p dvd n

goal (1 subgoal):
 1. False
[PROOF STEP]
by contradiction
[PROOF STATE]
proof (state)
this:
False

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem t_sortB:
  "t_heap_of_B xs + t_list_of_B (heap_of_B xs)
    \<le> 3 * length xs * (nlog2 (length xs + 1) + 3) + 1"
  (is "?lhs \<le> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
have "?lhs \<le> ?lhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> t_heap_of_B xs + t_list_of_B (heap_of_B xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> t_heap_of_B xs + t_list_of_B (heap_of_B xs)

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> t_heap_of_B xs + t_list_of_B (heap_of_B xs)

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
note t_heap_of_B_bound[of xs]
[PROOF STATE]
proof (state)
this:
t_heap_of_B xs \<le> 6 * length xs + 1

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
t_heap_of_B xs \<le> 6 * length xs + 1

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
note t_list_of_B_log_bound[of "heap_of_B xs"]
[PROOF STATE]
proof (state)
this:
braun (heap_of_B xs) \<Longrightarrow> t_list_of_B (heap_of_B xs) \<le> 3 * (nat \<lceil>log 2 (real (size (heap_of_B xs) + 1))\<rceil> + 1) * size (heap_of_B xs)

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> x + t_list_of_B (heap_of_B xs) \<le> y + t_list_of_B (heap_of_B xs); braun (heap_of_B xs); \<And>x y. x \<le> y \<Longrightarrow> 6 * length xs + 1 + x \<le> 6 * length xs + 1 + y\<rbrakk> \<Longrightarrow> t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 6 * length xs + 1 + 3 * (nat \<lceil>log 2 (real (size (heap_of_B xs) + 1))\<rceil> + 1) * size (heap_of_B xs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> x + t_list_of_B (heap_of_B xs) \<le> y + t_list_of_B (heap_of_B xs); braun (heap_of_B xs); \<And>x y. x \<le> y \<Longrightarrow> 6 * length xs + 1 + x \<le> 6 * length xs + 1 + y\<rbrakk> \<Longrightarrow> t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 6 * length xs + 1 + 3 * (nat \<lceil>log 2 (real (size (heap_of_B xs) + 1))\<rceil> + 1) * size (heap_of_B xs)

goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1
[PROOF STEP]
apply (simp add: size_heapify braun_heapify heap_of_B_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t_heap_of_B xs + t_list_of_B (fst (heapify (length xs) xs)) \<le> Suc (6 * length xs + (3 + 3 * nat \<lceil>log 2 (1 + real (length xs))\<rceil>) * length xs) \<Longrightarrow> t_heap_of_B xs + t_list_of_B (fst (heapify (length xs) xs)) \<le> Suc (3 * length xs * (nat \<lceil>log 2 (1 + real (length xs))\<rceil> + 3))
[PROOF STEP]
apply (simp add: field_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
t_heap_of_B xs + t_list_of_B (heap_of_B xs) \<le> 3 * length xs * (nat \<lceil>log 2 (real (length xs + 1))\<rceil> + 3) + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma valid_Tree\<^sub>\<alpha>_Conj\<^sub>\<alpha> [simp]: "valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) \<longleftrightarrow> (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) = (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) = (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)
[PROOF STEP]
have "valid_Tree P (rep_Tree\<^sub>\<alpha> (abs_Tree\<^sub>\<alpha> (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>)))) \<longleftrightarrow> valid_Tree P (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_Tree P (rep_Tree\<^sub>\<alpha> (abs_Tree\<^sub>\<alpha> (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>)))) = valid_Tree P (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>))
[PROOF STEP]
by (metis Tree\<^sub>\<alpha>_rep_abs alpha_Tree_valid_Tree)
[PROOF STATE]
proof (state)
this:
valid_Tree P (rep_Tree\<^sub>\<alpha> (abs_Tree\<^sub>\<alpha> (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>)))) = valid_Tree P (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>))

goal (1 subgoal):
 1. valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) = (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
valid_Tree P (rep_Tree\<^sub>\<alpha> (abs_Tree\<^sub>\<alpha> (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>)))) = valid_Tree P (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
valid_Tree P (rep_Tree\<^sub>\<alpha> (abs_Tree\<^sub>\<alpha> (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>)))) = valid_Tree P (tConj (map_bset rep_Tree\<^sub>\<alpha> tset\<^sub>\<alpha>))

goal (1 subgoal):
 1. valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) = (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)
[PROOF STEP]
by (simp add: valid_Tree\<^sub>\<alpha>_def Conj\<^sub>\<alpha>_def map_bset.rep_eq)
[PROOF STATE]
proof (state)
this:
valid_Tree\<^sub>\<alpha> P (Conj\<^sub>\<alpha> tset\<^sub>\<alpha>) = (\<forall>t\<^sub>\<alpha>\<in>set_bset tset\<^sub>\<alpha>. valid_Tree\<^sub>\<alpha> P t\<^sub>\<alpha>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma SN_on_subset1:
  assumes "SN_on r A" and "s \<subseteq> r"
  shows "SN_on s A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. SN_on s A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
SN_on r A
s \<subseteq> r

goal (1 subgoal):
 1. SN_on s A
[PROOF STEP]
unfolding SN_defs
[PROOF STATE]
proof (prove)
using this:
\<nexists>f. f 0 \<in> A \<and> (\<forall>i. (f i, f (Suc i)) \<in> r)
s \<subseteq> r

goal (1 subgoal):
 1. \<nexists>f. f 0 \<in> A \<and> (\<forall>i. (f i, f (Suc i)) \<in> s)
[PROOF STEP]
by blast


[STATEMENT]
lemma aux1_digit_lt_linear:
  assumes "b < 2^r" and "k \<ge> r"
  shows "(a*2^r + b) \<exclamdown> k = (a*2^r) \<exclamdown> k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
have "b div 2 ^ k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b div 2 ^ k = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
b < 2 ^ r
r \<le> k

goal (1 subgoal):
 1. b div 2 ^ k = 0
[PROOF STEP]
by (simp add: order.strict_trans2)
[PROOF STATE]
proof (state)
this:
b div 2 ^ k = 0

goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b div 2 ^ k = 0

goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
have "(a * 2 ^ r mod 2 ^ k +  b mod 2 ^ k) div 2 ^ k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
b < 2 ^ r
r \<le> k

goal (1 subgoal):
 1. (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>b < 2 ^ r; r \<le> k\<rbrakk> \<Longrightarrow> (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
have "bin_carry (a*2^r) b k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bin_carry (a * 2 ^ r) b k = 0
[PROOF STEP]
using assms aux1_1_digit_lt_linear
[PROOF STATE]
proof (prove)
using this:
b < 2 ^ r
r \<le> k
\<lbrakk>?b < 2 ^ ?r; ?r \<le> ?k\<rbrakk> \<Longrightarrow> bin_carry (?a * 2 ^ ?r) ?b ?k = 0

goal (1 subgoal):
 1. bin_carry (a * 2 ^ r) b k = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bin_carry (a * 2 ^ r) b k = 0

goal (1 subgoal):
 1. \<lbrakk>b < 2 ^ r; r \<le> k\<rbrakk> \<Longrightarrow> (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bin_carry (a * 2 ^ r) b k = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bin_carry (a * 2 ^ r) b k = 0

goal (1 subgoal):
 1. (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bin_carry (a * 2 ^ r) b k = 0
b < 2 ^ r
r \<le> k

goal (1 subgoal):
 1. (a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
by (auto simp add: bin_carry_def)
[PROOF STATE]
proof (state)
this:
(a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0

goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
b div 2 ^ k = 0
(a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
b div 2 ^ k = 0
(a * 2 ^ r mod 2 ^ k + b mod 2 ^ k) div 2 ^ k = 0

goal (1 subgoal):
 1. (a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k
[PROOF STEP]
by (auto simp add: nth_bit_def div_add1_eq[of "a*2^r" "b" "2^k"])
[PROOF STATE]
proof (state)
this:
(a * 2 ^ r + b) \<exclamdown> k = (a * 2 ^ r) \<exclamdown> k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem per_lemma: assumes "period w p" and "period w q" and len: "p + q - gcd p q \<le> \<^bold>|w\<^bold>|"
  shows  "period w (gcd p q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have takep: "w \<le>p (take p w) \<cdot> w" and takeq: "w \<le>p (take q w) \<cdot> w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<le>p take p w \<cdot> w &&& w \<le>p take q w \<cdot> w
[PROOF STEP]
using \<open>period w p\<close> \<open>period w q\<close> period_D3
[PROOF STATE]
proof (prove)
using this:
period w p
period w q
period ?w ?n \<Longrightarrow> ?w \<le>p take ?n ?w \<cdot> ?w

goal (1 subgoal):
 1. w \<le>p take p w \<cdot> w &&& w \<le>p take q w \<cdot> w
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
w \<le>p take p w \<cdot> w
w \<le>p take q w \<cdot> w

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have lenp: "\<^bold>|take p w\<^bold>| = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<^bold>|take p w\<^bold>| = p
[PROOF STEP]
using gcd_le2_nat[OF per_positive[OF \<open>period w q\<close>], of p] len take_len
[PROOF STATE]
proof (prove)
using this:
gcd p q \<le> q
p + q - gcd p q \<le> \<^bold>|w\<^bold>|
?p \<le> \<^bold>|?w\<^bold>| \<Longrightarrow> \<^bold>|take ?p ?w\<^bold>| = ?p

goal (1 subgoal):
 1. \<^bold>|take p w\<^bold>| = p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<^bold>|take p w\<^bold>| = p

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have lenq: "\<^bold>|take q w\<^bold>| = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<^bold>|take q w\<^bold>| = q
[PROOF STEP]
using gcd_le1_nat[OF per_positive[OF \<open>period w p\<close>], of q] len take_len
[PROOF STATE]
proof (prove)
using this:
gcd p q \<le> p
p + q - gcd p q \<le> \<^bold>|w\<^bold>|
?p \<le> \<^bold>|?w\<^bold>| \<Longrightarrow> \<^bold>|take ?p ?w\<^bold>| = ?p

goal (1 subgoal):
 1. \<^bold>|take q w\<^bold>| = q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<^bold>|take q w\<^bold>| = q

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
obtain t where "take p w \<in> t*" and "take q w \<in> t*"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t. \<lbrakk>take p w \<in> t*; take q w \<in> t*\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using comm_rootE[OF per_lemma_comm[OF takeq takep, unfolded lenp lenq, OF len], of thesis]
[PROOF STATE]
proof (prove)
using this:
(\<And>t. \<lbrakk>take p w \<in> t*; take q w \<in> t*\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>take p w \<in> t*; take q w \<in> t*\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
take p w \<in> t*
take q w \<in> t*

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
hence "w \<le>p t\<^sup>\<omega>"
[PROOF STATE]
proof (prove)
using this:
take p w \<in> t*
take q w \<in> t*

goal (1 subgoal):
 1. w \<le>p t\<^sup>\<omega>
[PROOF STEP]
using \<open>period w p\<close> period_def per_root_trans
[PROOF STATE]
proof (prove)
using this:
take p w \<in> t*
take q w \<in> t*
period w p
period ?w ?n = ?w \<le>p take ?n ?w\<^sup>\<omega>
\<lbrakk>?w \<le>p ?u\<^sup>\<omega>; ?u \<in> ?t*\<rbrakk> \<Longrightarrow> ?w \<le>p ?t\<^sup>\<omega>

goal (1 subgoal):
 1. w \<le>p t\<^sup>\<omega>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w \<le>p t\<^sup>\<omega>

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have "period w \<^bold>|t\<^bold>|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. period w \<^bold>|t\<^bold>|
[PROOF STEP]
using  root_period[OF  per_nemp[OF \<open>period w p\<close>] \<open>w \<le>p t\<^sup>\<omega>\<close>]
[PROOF STATE]
proof (prove)
using this:
period w \<^bold>|t\<^bold>|

goal (1 subgoal):
 1. period w \<^bold>|t\<^bold>|
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
period w \<^bold>|t\<^bold>|

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have "\<^bold>|t\<^bold>| dvd (gcd p q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<^bold>|t\<^bold>| dvd gcd p q
[PROOF STEP]
using  common_root_len_gcd[OF \<open>take p w \<in> t*\<close> \<open>take q w \<in> t*\<close>]
[PROOF STATE]
proof (prove)
using this:
\<^bold>|t\<^bold>| dvd gcd \<^bold>|take p w\<^bold>| \<^bold>|take q w\<^bold>|

goal (1 subgoal):
 1. \<^bold>|t\<^bold>| dvd gcd p q
[PROOF STEP]
unfolding  lenp lenq
[PROOF STATE]
proof (prove)
using this:
\<^bold>|t\<^bold>| dvd gcd p q

goal (1 subgoal):
 1. \<^bold>|t\<^bold>| dvd gcd p q
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<^bold>|t\<^bold>| dvd gcd p q

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
from dvd_div_mult_self[OF this]
[PROOF STATE]
proof (chain)
picking this:
gcd p q div \<^bold>|t\<^bold>| * \<^bold>|t\<^bold>| = gcd p q
[PROOF STEP]
have "gcd p q div \<^bold>|t\<^bold>| * \<^bold>|t\<^bold>| = gcd p q"
[PROOF STATE]
proof (prove)
using this:
gcd p q div \<^bold>|t\<^bold>| * \<^bold>|t\<^bold>| = gcd p q

goal (1 subgoal):
 1. gcd p q div \<^bold>|t\<^bold>| * \<^bold>|t\<^bold>| = gcd p q
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
gcd p q div \<^bold>|t\<^bold>| * \<^bold>|t\<^bold>| = gcd p q

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
have "gcd p q \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd p q \<noteq> 0
[PROOF STEP]
using \<open>period w p\<close>
[PROOF STATE]
proof (prove)
using this:
period w p

goal (1 subgoal):
 1. gcd p q \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd p q \<noteq> 0

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
from this[folded dvd_div_eq_0_iff[OF \<open>\<^bold>|t\<^bold>| dvd (gcd p q)\<close>]]
[PROOF STATE]
proof (chain)
picking this:
gcd p q div \<^bold>|t\<^bold>| \<noteq> 0
[PROOF STEP]
show "period w (gcd p q)"
[PROOF STATE]
proof (prove)
using this:
gcd p q div \<^bold>|t\<^bold>| \<noteq> 0

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
using  per_mult[OF \<open>period w \<^bold>|t\<^bold>|\<close>, of "gcd p q div \<^bold>|t\<^bold>|", unfolded dvd_div_mult_self[OF \<open>\<^bold>|t\<^bold>| dvd (gcd p q)\<close>]]
[PROOF STATE]
proof (prove)
using this:
gcd p q div \<^bold>|t\<^bold>| \<noteq> 0
gcd p q div \<^bold>|t\<^bold>| \<noteq> 0 \<Longrightarrow> period w (gcd p q)

goal (1 subgoal):
 1. period w (gcd p q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
period w (gcd p q)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lm5: "\<lbrakk> c_assoc_have_key (pr_gr x) key = 0; x \<le> y \<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
assume A1: "c_assoc_have_key (pr_gr x) key = 0"
[PROOF STATE]
proof (state)
this:
c_assoc_have_key (pr_gr x) key = 0

goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
assume A2: "x \<le> y"
[PROOF STATE]
proof (state)
this:
x \<le> y

goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
let ?z = "y-x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
from A2
[PROOF STATE]
proof (chain)
picking this:
x \<le> y
[PROOF STEP]
have S1: "0 \<le> ?z"
[PROOF STATE]
proof (prove)
using this:
x \<le> y

goal (1 subgoal):
 1. 0 \<le> y - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> y - x

goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
from A2
[PROOF STATE]
proof (chain)
picking this:
x \<le> y
[PROOF STEP]
have S2: "y = x + ?z"
[PROOF STATE]
proof (prove)
using this:
x \<le> y

goal (1 subgoal):
 1. y = x + (y - x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y = x + (y - x)

goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
from A1 S1
[PROOF STATE]
proof (chain)
picking this:
c_assoc_have_key (pr_gr x) key = 0
0 \<le> y - x
[PROOF STEP]
have S3: "c_assoc_have_key (pr_gr (x+?z)) key = 0"
[PROOF STATE]
proof (prove)
using this:
c_assoc_have_key (pr_gr x) key = 0
0 \<le> y - x

goal (1 subgoal):
 1. c_assoc_have_key (pr_gr (x + (y - x))) key = 0
[PROOF STEP]
by (rule lm4)
[PROOF STATE]
proof (state)
this:
c_assoc_have_key (pr_gr (x + (y - x))) key = 0

goal (1 subgoal):
 1. \<lbrakk>c_assoc_have_key (pr_gr x) key = 0; x \<le> y\<rbrakk> \<Longrightarrow> c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
from S2 S3
[PROOF STATE]
proof (chain)
picking this:
y = x + (y - x)
c_assoc_have_key (pr_gr (x + (y - x))) key = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
y = x + (y - x)
c_assoc_have_key (pr_gr (x + (y - x))) key = 0

goal (1 subgoal):
 1. c_assoc_have_key (pr_gr y) key = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c_assoc_have_key (pr_gr y) key = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma multiplicative_dirichlet_prod:
  assumes "multiplicative_function f"
  assumes "multiplicative_function g"
  shows   "multiplicative_function (dirichlet_prod f g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicative_function (dirichlet_prod f g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. multiplicative_function (dirichlet_prod f g)
[PROOF STEP]
interpret f: multiplicative_function f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicative_function f
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. multiplicative_function (dirichlet_prod f g)
[PROOF STEP]
interpret g: multiplicative_function g
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicative_function g
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. multiplicative_function (dirichlet_prod f g)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicative_function (dirichlet_prod f g)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
fix a b :: nat
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
assume "a > 1" "b > 1" and coprime: "coprime a b"
[PROOF STATE]
proof (state)
this:
1 < a
1 < b
coprime a b

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
hence "dirichlet_prod f g (a * b) =
             (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s)))"
[PROOF STATE]
proof (prove)
using this:
1 < a
1 < b
coprime a b

goal (1 subgoal):
 1. dirichlet_prod f g (a * b) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s)))
[PROOF STEP]
by (simp add: dirichlet_prod_def sum_divisors_coprime_mult)
[PROOF STATE]
proof (state)
this:
dirichlet_prod f g (a * b) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s)))

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dirichlet_prod f g (a * b) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s)))

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
have "\<dots> = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s))) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s))
[PROOF STEP]
using \<open>coprime a b\<close>
[PROOF STATE]
proof (prove)
using this:
coprime a b

goal (1 subgoal):
 1. (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s))) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s))
[PROOF STEP]
proof (rule sum_coprime_dvd_cong)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
fix r s
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
assume "coprime r s" and "r dvd a" and "s dvd b"
[PROOF STATE]
proof (state)
this:
coprime r s
r dvd a
s dvd b

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
with \<open>a > 1\<close> \<open>b > 1\<close>
[PROOF STATE]
proof (chain)
picking this:
1 < a
1 < b
coprime r s
r dvd a
s dvd b
[PROOF STEP]
have "r > 0" "s > 0"
[PROOF STATE]
proof (prove)
using this:
1 < a
1 < b
coprime r s
r dvd a
s dvd b

goal (1 subgoal):
 1. 0 < r &&& 0 < s
[PROOF STEP]
by (auto intro: ccontr)
[PROOF STATE]
proof (state)
this:
0 < r
0 < s

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
from \<open>coprime r s\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime r s
[PROOF STEP]
have "f (r * s) = f r * f s"
[PROOF STATE]
proof (prove)
using this:
coprime r s

goal (1 subgoal):
 1. f (r * s) = f r * f s
[PROOF STEP]
by (rule f.mult_coprime)
[PROOF STATE]
proof (state)
this:
f (r * s) = f r * f s

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f (r * s) = f r * f s

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
from \<open>coprime a b\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime a b
[PROOF STEP]
have \<open>coprime (a div r) (b div s)\<close>
[PROOF STATE]
proof (prove)
using this:
coprime a b

goal (1 subgoal):
 1. coprime (a div r) (b div s)
[PROOF STEP]
using \<open>r > 0\<close> \<open>s > 0\<close> \<open>r dvd a\<close> \<open>s dvd b\<close> dvd_div_iff_mult [of r a] dvd_div_iff_mult [of s b]
[PROOF STATE]
proof (prove)
using this:
coprime a b
0 < r
0 < s
r dvd a
s dvd b
\<lbrakk>r \<noteq> 0; r dvd a\<rbrakk> \<Longrightarrow> (?a dvd a div r) = (?a * r dvd a)
\<lbrakk>s \<noteq> 0; s dvd b\<rbrakk> \<Longrightarrow> (?a dvd b div s) = (?a * s dvd b)

goal (1 subgoal):
 1. coprime (a div r) (b div s)
[PROOF STEP]
by (auto dest: coprime_imp_coprime dvd_mult_left)
[PROOF STATE]
proof (state)
this:
coprime (a div r) (b div s)

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
coprime (a div r) (b div s)
[PROOF STEP]
have "g (a div r * (b div s)) = g (a div r) * g (b div s)"
[PROOF STATE]
proof (prove)
using this:
coprime (a div r) (b div s)

goal (1 subgoal):
 1. g (a div r * (b div s)) = g (a div r) * g (b div s)
[PROOF STEP]
by (rule g.mult_coprime)
[PROOF STATE]
proof (state)
this:
g (a div r * (b div s)) = g (a div r) * g (b div s)

goal (1 subgoal):
 1. \<And>r s. \<lbrakk>coprime r s; r dvd a; s dvd b\<rbrakk> \<Longrightarrow> f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f (r * s) = f r * f s
g (a div r * (b div s)) = g (a div r) * g (b div s)
[PROOF STEP]
show "f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)"
[PROOF STATE]
proof (prove)
using this:
f (r * s) = f r * f s
g (a div r * (b div s)) = g (a div r) * g (b div s)

goal (1 subgoal):
 1. f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
using \<open>r dvd a\<close> \<open>s dvd b\<close>
[PROOF STATE]
proof (prove)
using this:
f (r * s) = f r * f s
g (a div r * (b div s)) = g (a div r) * g (b div s)
r dvd a
s dvd b

goal (1 subgoal):
 1. f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)
[PROOF STEP]
by (simp add: div_mult_div_if_dvd ac_simps)
[PROOF STATE]
proof (state)
this:
f (r * s) * g (a * b div (r * s)) = f r * f s * g (a div r) * g (b div s)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s))) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s))

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s) * g (a * b div (r * s))) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s))

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
have "\<dots> = dirichlet_prod f g a * dirichlet_prod f g b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s)) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
unfolding dirichlet_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s)) = (\<Sum>d | d dvd a. f d * g (a div d)) * (\<Sum>d | d dvd b. f d * g (b div d))
[PROOF STEP]
by (simp add: sum_product mult_ac)
[PROOF STATE]
proof (state)
this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f r * f s * g (a div r) * g (b div s)) = dirichlet_prod f g a * dirichlet_prod f g b

goal (3 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b; coprime a b\<rbrakk> \<Longrightarrow> dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
show "dirichlet_prod f g (a * b) = \<dots>"
[PROOF STATE]
proof (prove)
using this:
dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b

goal (1 subgoal):
 1. dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dirichlet_prod f g (a * b) = dirichlet_prod f g a * dirichlet_prod f g b

goal (2 subgoals):
 1. dirichlet_prod f g 0 = (0::'a)
 2. dirichlet_prod f g 1 = (1::'a)
[PROOF STEP]
qed simp_all
[PROOF STATE]
proof (state)
this:
multiplicative_function (dirichlet_prod f g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cong_add_rcancel_0:
  "[x + a = a] (mod n) \<longleftrightarrow> [x = 0] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x + a = a] (mod n) = [x = 0::'a] (mod n)
[PROOF STEP]
using cong_add_rcancel [of x a 0 n]
[PROOF STATE]
proof (prove)
using this:
[x + a = (0::'a) + a] (mod n) = [x = 0::'a] (mod n)

goal (1 subgoal):
 1. [x + a = a] (mod n) = [x = 0::'a] (mod n)
[PROOF STEP]
by simp


[STATEMENT]
lemma eventually_at_left_at_right_imp_at:
  "eventually P (at_left a) \<Longrightarrow> eventually P (at_right a) \<Longrightarrow> eventually P (at (a::real))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>eventually P (at_left a); eventually P (at_right a)\<rbrakk> \<Longrightarrow> eventually P (at a)
[PROOF STEP]
by (simp add: eventually_at_split)


[STATEMENT]
lemma char_poly_similar: assumes "similar_mat A (B :: 'a :: comm_ring_1 mat)"
  shows "char_poly A = char_poly B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
from similar_matD[OF assms]
[PROOF STATE]
proof (chain)
picking this:
\<exists>n P Q. {A, B, P, Q} \<subseteq> carrier_mat n n \<and> P * Q = 1\<^sub>m n \<and> Q * P = 1\<^sub>m n \<and> A = P * B * Q
[PROOF STEP]
obtain n P Q where
  carr: "{A, B, P, Q} \<subseteq> carrier_mat n n" (is "_ \<subseteq> ?C")
  and PQ: "P * Q = 1\<^sub>m n"
  and AB: "A = P * B * Q"
[PROOF STATE]
proof (prove)
using this:
\<exists>n P Q. {A, B, P, Q} \<subseteq> carrier_mat n n \<and> P * Q = 1\<^sub>m n \<and> Q * P = 1\<^sub>m n \<and> A = P * B * Q

goal (1 subgoal):
 1. (\<And>P Q n. \<lbrakk>{A, B, P, Q} \<subseteq> carrier_mat n n; P * Q = 1\<^sub>m n; A = P * B * Q\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{A, B, P, Q} \<subseteq> carrier_mat n n
P * Q = 1\<^sub>m n
A = P * B * Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
hence A: "A \<in> ?C" and B: "B \<in> ?C" and P: "P \<in> ?C" and Q: "Q \<in> ?C"
[PROOF STATE]
proof (prove)
using this:
{A, B, P, Q} \<subseteq> carrier_mat n n
P * Q = 1\<^sub>m n
A = P * B * Q

goal (1 subgoal):
 1. (A \<in> carrier_mat n n &&& B \<in> carrier_mat n n) &&& P \<in> carrier_mat n n &&& Q \<in> carrier_mat n n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
P \<in> carrier_mat n n
Q \<in> carrier_mat n n

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?m = "\<lambda> a. [: -a :]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?P = "map_mat (\<lambda> a. [: a :]) P"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?Q = "map_mat (\<lambda> a. [: a :]) Q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?B = "map_mat ?m B"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?I = "map_mat (\<lambda> a. [: a :]) (1\<^sub>m n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
let ?XI = "[:0, 1:] \<cdot>\<^sub>m 1\<^sub>m n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
from A B
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
[PROOF STEP]
have dim: "dim_row A = n" "dim_row B = n"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n

goal (1 subgoal):
 1. dim_row A = n &&& dim_row B = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row A = n
dim_row B = n

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have cong: "\<And> x y z. x = y \<Longrightarrow> x * z = y * z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y z. x = y \<Longrightarrow> x * z = y * z
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?x3 = ?y3 \<Longrightarrow> ?x3 * ?z3 = ?y3 * ?z3

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have id: "?m = (\<lambda> a :: 'a. [: a :] * [: -1 :])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>a. [:- a:]) = (\<lambda>a. [:a:] * [:- (1::'a):])
[PROOF STEP]
by (intro ext, auto)
[PROOF STATE]
proof (state)
this:
(\<lambda>a. [:- a:]) = (\<lambda>a. [:a:] * [:- (1::'a):])

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "char_poly A = det (?XI + map_mat (\<lambda>a. [:- a:]) (P * B * Q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. char_poly A = det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) (P * B * Q))
[PROOF STEP]
unfolding
    char_poly_defs dim
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) A) = det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) (P * B * Q))
[PROOF STEP]
by (simp add: AB)
[PROOF STATE]
proof (state)
this:
char_poly A = det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) (P * B * Q))

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
char_poly A = det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) (P * B * Q))

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "?XI = ?P * ?XI * ?Q" (is "_ = ?left")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
have "?P * ?XI = [:0, 1:] \<cdot>\<^sub>m (?P * 1\<^sub>m n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n)
[PROOF STEP]
by (rule mult_smult_distrib[of _ n n _ n], insert P, auto)
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
have "?P * 1\<^sub>m n = ?P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P
[PROOF STEP]
using P
[PROOF STATE]
proof (prove)
using this:
P \<in> carrier_mat n n

goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
have "([: 0, 1:] \<cdot>\<^sub>m ?P) * ?Q = [: 0, 1:] \<cdot>\<^sub>m (?P * ?Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)
[PROOF STEP]
by (rule mult_smult_assoc_mat, insert P Q, auto)
[PROOF STATE]
proof (state)
this:
[:0::'a, 1::'a:] \<cdot>\<^sub>m map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[:0::'a, 1::'a:] \<cdot>\<^sub>m map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = [:0::'a, 1::'a:] \<cdot>\<^sub>m (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
have "?P * ?Q = ?I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)
[PROOF STEP]
unfolding PQ[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (P * Q)
[PROOF STEP]
by (rule map_poly_mult[symmetric, OF P Q])
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
have "[: 0, 1:] \<cdot>\<^sub>m ?I = ?XI"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:0::'b, 1::'b:] \<cdot>\<^sub>m map_mat (\<lambda>a. [:a:]) (1\<^sub>m n) = [:0::'b, 1::'b:] \<cdot>\<^sub>m 1\<^sub>m n
[PROOF STEP]
by rule auto
[PROOF STATE]
proof (state)
this:
[:0::?'b5, 1::?'b5:] \<cdot>\<^sub>m map_mat (\<lambda>a. [:a:]) (1\<^sub>m n) = [:0::?'b5, 1::?'b5:] \<cdot>\<^sub>m 1\<^sub>m n

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q = [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q = [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n

goal (1 subgoal):
 1. [:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
[:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "map_mat ?m (P * B * Q) = ?P * ?B * ?Q" (is "_ = ?right")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:- a:]) (P * B * Q) = map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:] * [:- (1::'a):]) (P * B * Q) = map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:] * [:- (1::'a):]) B * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
by (subst map_poly_mult[OF mult_carrier_mat[OF P B] Q],
      subst map_poly_mult(3)[OF P B], simp)
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:- a:]) (P * B * Q) = map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:- a:]) (P * B * Q) = map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "?left + ?right = (?P * ?XI + ?P * ?B) * ?Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q = (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q
[PROOF STEP]
by (rule add_mult_distrib_mat[symmetric, of _ n n], insert B P Q, auto)
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q = (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) * map_mat (\<lambda>a. [:a:]) Q + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B * map_mat (\<lambda>a. [:a:]) Q = (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "?P * ?XI + ?P * ?B = ?P * (?XI + ?B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)
[PROOF STEP]
by (rule mult_add_distrib_mat[symmetric, of _ n n], insert B P Q, auto)
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n) + map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:- a:]) B = map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "det (?P * (?XI + ?B) * ?Q) = det ?P * det (?XI + ?B) * det ?Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q)
[PROOF STEP]
by (rule trans[OF det_mult[of _ n] cong[OF det_mult]], insert P Q B, auto)
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P * ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "\<dots> = (det ?P * det ?Q) * det (?XI + ?B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) * det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "det (?XI + ?B) = char_poly B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) = char_poly B
[PROOF STEP]
unfolding char_poly_defs dim
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) = det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) = char_poly B

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det ([:0::'a, 1::'a:] \<cdot>\<^sub>m 1\<^sub>m n + map_mat (\<lambda>a. [:- a:]) B) = char_poly B

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "det ?P * det ?Q = det (?P * ?Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)
[PROOF STEP]
by (rule det_mult[symmetric], insert P Q, auto)
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) P) * det (map_mat (\<lambda>a. [:a:]) Q) = det (map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "?P * ?Q = ?I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)
[PROOF STEP]
unfolding PQ[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (P * Q)
[PROOF STEP]
by (rule map_poly_mult[symmetric, OF P Q])
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_mat (\<lambda>a. [:a:]) P * map_mat (\<lambda>a. [:a:]) Q = map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "det \<dots> = prod_list (diag_mat ?I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)) = prod_list (diag_mat (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)))
[PROOF STEP]
by (rule det_upper_triangular[of _ n], auto)
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)) = prod_list (diag_mat (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)))

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)) = prod_list (diag_mat (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)))

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
have "\<dots> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (diag_mat (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n))) = 1
[PROOF STEP]
unfolding prod_list_diag_prod
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..<dim_row (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n)). map_mat (\<lambda>a. [:a:]) (1\<^sub>m n) $$ (i, i)) = 1
[PROOF STEP]
by (rule prod.neutral) simp
[PROOF STATE]
proof (state)
this:
prod_list (diag_mat (map_mat (\<lambda>a. [:a:]) (1\<^sub>m n))) = 1

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
char_poly A = 1 * char_poly B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
char_poly A = 1 * char_poly B

goal (1 subgoal):
 1. char_poly A = char_poly B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
char_poly A = char_poly B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma graph_domD: "x \<in> graph m \<Longrightarrow> fst x \<in> dom m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> graph m \<Longrightarrow> fst x \<in> dom m
[PROOF STEP]
using fst_graph_eq_dom
[PROOF STATE]
proof (prove)
using this:
fst ` graph ?m = dom ?m

goal (1 subgoal):
 1. x \<in> graph m \<Longrightarrow> fst x \<in> dom m
[PROOF STEP]
by (metis imageI)


[STATEMENT]
lemma root_powreal_inverse:
  assumes "0 < n" and "0 \<le> x"
  shows "root n x = x pow\<^sub>\<real> (1/n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> (1 / real n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> (1 / real n)
[PROOF STEP]
have "root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))
[PROOF STEP]
using assms real_root_eq_powrat_inverse realpow_powrat_eq [symmetric] powreal_def
[PROOF STATE]
proof (prove)
using this:
0 < n
0 \<le> x
0 < ?n \<Longrightarrow> root ?n ?x = ?x pow\<^sub>\<rat> inverse (rat_of_nat ?n)
0 < ?a \<Longrightarrow> ?a pow\<^sub>\<rat> ?q = ?a pow\<^sub>\<real> real_of_rat ?q
?a pow\<^sub>\<real> ?x = (if 0 < ?a \<and> ?a < 1 then inverse ?a powa - ?x else if 1 \<le> ?a then ?a powa ?x else 0)

goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))

goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> (1 / real n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
root n x = x pow\<^sub>\<real> real_of_rat (inverse (rat_of_nat n))

goal (1 subgoal):
 1. root n x = x pow\<^sub>\<real> (1 / real n)
[PROOF STEP]
by (metis inverse_eq_divide of_rat_inverse of_rat_of_nat_eq)
[PROOF STATE]
proof (state)
this:
root n x = x pow\<^sub>\<real> (1 / real n)

goal:
No subgoals!
[PROOF STEP]
qed