[STATEMENT]
lemma one_time_pad:
  assumes inj_on: "inj_on f {..<q}"
    and sur: "f ` {..<q} = {..<q}"
  shows "map_spmf f (sample_uniform q) = (sample_uniform q)"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
have rhs: "?rhs = spmf_of_set ({..< q})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sample_uniform q = spmf_of_set {..<q}
[PROOF STEP]
by(auto simp add: sample_uniform_def)
[PROOF STATE]
proof (state)
this:
sample_uniform q = spmf_of_set {..<q}

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sample_uniform q = spmf_of_set {..<q}

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
have "map_spmf(\<lambda>s. f s) (spmf_of_set {..<q}) = spmf_of_set ((\<lambda>s. f s) ` {..<q})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf f (spmf_of_set {..<q}) = spmf_of_set (f ` {..<q})
[PROOF STEP]
by(simp add: inj_on)
[PROOF STATE]
proof (state)
this:
map_spmf f (spmf_of_set {..<q}) = spmf_of_set (f ` {..<q})

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_spmf f (spmf_of_set {..<q}) = spmf_of_set (f ` {..<q})

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
have "f ` {..<q} = {..<q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` {..<q} = {..<q}
[PROOF STEP]
apply(rule endo_inj_surj)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite {..<q}
 2. f ` {..<q} \<subseteq> {..<q}
 3. inj_on f {..<q}
[PROOF STEP]
by(simp, simp add: sur, simp add: inj_on)
[PROOF STATE]
proof (state)
this:
f ` {..<q} = {..<q}

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
map_spmf f (sample_uniform q) = spmf_of_set (f ` {..<q})
f ` {..<q} = {..<q}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
map_spmf f (sample_uniform q) = spmf_of_set (f ` {..<q})
f ` {..<q} = {..<q}

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
using rhs
[PROOF STATE]
proof (prove)
using this:
map_spmf f (sample_uniform q) = spmf_of_set (f ` {..<q})
f ` {..<q} = {..<q}
sample_uniform q = spmf_of_set {..<q}

goal (1 subgoal):
 1. map_spmf f (sample_uniform q) = sample_uniform q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map_spmf f (sample_uniform q) = sample_uniform q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcd_code_int [code]: "gcd k l = \<bar>if l = 0 then k else gcd l (\<bar>k\<bar> mod \<bar>l\<bar>)\<bar>"
  for k l :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd k l = \<bar>if l = 0 then k else gcd l (\<bar>k\<bar> mod \<bar>l\<bar>)\<bar>
[PROOF STEP]
using gcd_red_int [of "\<bar>k\<bar>" "\<bar>l\<bar>"]
[PROOF STATE]
proof (prove)
using this:
gcd \<bar>k\<bar> \<bar>l\<bar> = gcd \<bar>l\<bar> (\<bar>k\<bar> mod \<bar>l\<bar>)

goal (1 subgoal):
 1. gcd k l = \<bar>if l = 0 then k else gcd l (\<bar>k\<bar> mod \<bar>l\<bar>)\<bar>
[PROOF STEP]
by simp


[STATEMENT]
lemma min_coin_set_sym: "fst`(\<CC>\<^sub>m g h) = snd `(\<CC>\<^sub>m h g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst ` \<CC>\<^sub>m g h = snd ` \<CC>\<^sub>m h g
[PROOF STEP]
unfolding min_coincidence_set_def image_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst ` {(r, s). g r =\<^sub>m h s} = snd ` {(r, s). h r =\<^sub>m g s}
[PROOF STEP]
by (rule, rule, simp add: image_iff min_coin_sym_iff)
     (rule, simp add: image_iff min_coin_sym_iff)


[STATEMENT]
lemma hash_prob:
  assumes "K \<subseteq> carrier R"
  assumes "card K \<le> k"
  assumes "y ` K \<subseteq> carrier R"
  shows
    "prob {\<omega>. (\<forall>x \<in> K. hash x \<omega> = y x)} = 1/(real field_size)^card K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
have "\<zero> \<in> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<zero> \<in> carrier R
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<zero> \<in> carrier R

goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
hence a:"field_size > 0"
[PROOF STATE]
proof (prove)
using this:
\<zero> \<in> carrier R

goal (1 subgoal):
 1. 0 < field_size
[PROOF STEP]
using finite_carrier card_gt_0_iff
[PROOF STATE]
proof (prove)
using this:
\<zero> \<in> carrier R
finite (carrier R)
(0 < card ?A) = (?A \<noteq> {} \<and> finite ?A)

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

goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
have b:"real (card {\<omega> \<in> space. \<forall>x\<in>K. eval \<omega> x = y x}) / real (card space) =
    1 / real field_size ^ card K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card {\<omega> \<in> local.space. \<forall>x\<in>K. local.eval \<omega> x = y x}) / real (card local.space) = 1 / real field_size ^ card K
[PROOF STEP]
using a assms(2)
[PROOF STATE]
proof (prove)
using this:
0 < field_size
card K \<le> k

goal (1 subgoal):
 1. real (card {\<omega> \<in> local.space. \<forall>x\<in>K. local.eval \<omega> x = y x}) / real (card local.space) = 1 / real field_size ^ card K
[PROOF STEP]
apply (simp add: frac_eq_eq poly_cards[OF assms(1,2,3)] power_add[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < field_size; card K \<le> k\<rbrakk> \<Longrightarrow> field_size ^ k = card local.space
[PROOF STEP]
by (simp add:space_def bounded_degree_polynomials_card)
[PROOF STATE]
proof (state)
this:
real (card {\<omega> \<in> local.space. \<forall>x\<in>K. local.eval \<omega> x = y x}) / real (card local.space) = 1 / real field_size ^ card K

goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.prob (pmf_of_set local.space) {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K
[PROOF STEP]
by (simp add:hash_def measure_pmf_of_set Int_def b)
[PROOF STATE]
proof (state)
this:
prob {\<omega>. \<forall>x\<in>K. hash x \<omega> = y x} = 1 / real field_size ^ card K

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma add_inv_exists_vec:
  "(v :: 'a :: group_add vec) \<in> carrier_vec n \<Longrightarrow> \<exists> w \<in> carrier_vec n. w + v = 0\<^sub>v n \<and> v + w = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> carrier_vec n \<Longrightarrow> \<exists>w\<in>carrier_vec n. w + v = 0\<^sub>v n \<and> v + w = 0\<^sub>v n
[PROOF STEP]
by (intro bexI[of _ "- v"], auto)


[STATEMENT]
lemma has_field_derivative_Arccos:
  assumes "(Im z = 0 \<Longrightarrow> \<bar>Re z\<bar> < 1)"
    shows "(Arccos has_field_derivative - inverse(sin(Arccos z))) (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
have "x\<^sup>2 \<noteq> -1" for x::real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 \<noteq> - 1
[PROOF STEP]
by (sos "((R<1 + (([~1] * A=0) + (R<1 * (R<1 * [x__]^2)))))")
[PROOF STATE]
proof (state)
this:
?x\<^sup>2 \<noteq> - 1

goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
Im z = 0 \<Longrightarrow> \<bar>Re z\<bar> < 1
?x\<^sup>2 \<noteq> - 1
[PROOF STEP]
have "(cos (Arccos z))\<^sup>2 \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
Im z = 0 \<Longrightarrow> \<bar>Re z\<bar> < 1
?x\<^sup>2 \<noteq> - 1

goal (1 subgoal):
 1. (cos (Arccos z))\<^sup>2 \<noteq> 1
[PROOF STEP]
by (auto simp: complex_eq_iff Re_power2 Im_power2 abs_square_eq_1)
[PROOF STATE]
proof (state)
this:
(cos (Arccos z))\<^sup>2 \<noteq> 1

goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(cos (Arccos z))\<^sup>2 \<noteq> 1
[PROOF STEP]
have "- sin (Arccos z) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(cos (Arccos z))\<^sup>2 \<noteq> 1

goal (1 subgoal):
 1. - sin (Arccos z) \<noteq> 0
[PROOF STEP]
by (metis cos_squared_eq diff_0_right mult_zero_left neg_0_equal_iff_equal power2_eq_square)
[PROOF STATE]
proof (state)
this:
- sin (Arccos z) \<noteq> 0

goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
- sin (Arccos z) \<noteq> 0
[PROOF STEP]
have "(Arccos has_field_derivative inverse(- sin(Arccos z))) (at z)"
[PROOF STATE]
proof (prove)
using this:
- sin (Arccos z) \<noteq> 0

goal (1 subgoal):
 1. (Arccos has_field_derivative inverse (- sin (Arccos z))) (at z)
[PROOF STEP]
by (rule has_field_derivative_inverse_basic [OF DERIV_cos _ _ open_ball [of z 1]])
       (auto intro: isCont_Arccos assms)
[PROOF STATE]
proof (state)
this:
(Arccos has_field_derivative inverse (- sin (Arccos z))) (at z)

goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(Arccos has_field_derivative inverse (- sin (Arccos z))) (at z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(Arccos has_field_derivative inverse (- sin (Arccos z))) (at z)

goal (1 subgoal):
 1. (Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(Arccos has_field_derivative - inverse (sin (Arccos z))) (at z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_to_iarray_bezout_iterate:
  assumes n: "n<nrows A"
  shows "matrix_to_iarray (bezout_iterate A n i j bezout)
  = bezout_iterate_iarrays (matrix_to_iarray A) n (to_nat i) (to_nat j) bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
n < nrows A

goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
proof (induct n arbitrary: A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>A. 0 < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A 0 i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
 2. \<And>n A. \<lbrakk>\<And>A. n < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout; Suc n < nrows A\<rbrakk> \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 < nrows A

goal (2 subgoals):
 1. \<And>A. 0 < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A 0 i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
 2. \<And>n A. \<lbrakk>\<And>A. n < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout; Suc n < nrows A\<rbrakk> \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
0 < nrows A

goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A 0 i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding bezout_iterate_iarrays.simps bezout_iterate.simps
[PROOF STATE]
proof (prove)
using this:
0 < nrows A

goal (1 subgoal):
 1. matrix_to_iarray A = matrix_to_iarray A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A 0 i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. n < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout; Suc n < nrows A\<rbrakk> \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. n < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout; Suc n < nrows A\<rbrakk> \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
n < nrows ?A \<Longrightarrow> matrix_to_iarray (bezout_iterate ?A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray ?A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
Suc n < nrows A

goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. n < nrows A \<Longrightarrow> matrix_to_iarray (bezout_iterate A n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout; Suc n < nrows A\<rbrakk> \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
proof (cases "Suc n \<le> to_nat i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
 2. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc n \<le> mod_type_class.to_nat i

goal (2 subgoals):
 1. Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
 2. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding bezout_iterate.simps bezout_iterate_iarrays.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = (if Suc n \<le> mod_type_class.to_nat i then matrix_to_iarray A else bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
Suc n \<le> mod_type_class.to_nat i

goal (1 subgoal):
 1. matrix_to_iarray (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = (if Suc n \<le> mod_type_class.to_nat i then matrix_to_iarray A else bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> Suc n \<le> mod_type_class.to_nat i

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
let ?B="(bezout_matrix_iarrays (matrix_to_iarray A) (to_nat i) (Suc n) (to_nat j) bezout
      **i matrix_to_iarray A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
let ?B2="matrix_to_iarray (bezout_matrix A i (from_nat (Suc n)) j bezout ** A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
have "matrix_to_iarray (bezout_iterate A (Suc n) i j bezout)
      = matrix_to_iarray (bezout_iterate (bezout_matrix A i (from_nat (Suc n)) j bezout ** A) n i j bezout)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)
[PROOF STEP]
unfolding bezout_iterate.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> Suc n \<le> mod_type_class.to_nat i

goal (1 subgoal):
 1. matrix_to_iarray (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
have "... = bezout_iterate_iarrays ?B2 n (to_nat i) (to_nat j) bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
proof (rule Suc.hyps)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)
[PROOF STEP]
show "n < nrows (bezout_matrix A i (from_nat (Suc n)) j bezout ** A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)
[PROOF STEP]
using Suc.prems
[PROOF STATE]
proof (prove)
using this:
Suc n < nrows A

goal (1 subgoal):
 1. n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)
[PROOF STEP]
unfolding nrows_def
[PROOF STATE]
proof (prove)
using this:
Suc n < CARD('c)

goal (1 subgoal):
 1. n < CARD('c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
have "... = bezout_iterate_iarrays ?B n (to_nat i) (to_nat j) bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding matrix_to_iarray_matrix_matrix_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding matrix_to_iarray_bezout_matrix[of A i "from_nat (Suc n)" j bezout]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (mod_type_class.to_nat (mod_type_class.from_nat (Suc n))) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding to_nat_from_nat_id[OF Suc.prems[unfolded nrows_def]]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bezout_iterate_iarrays (matrix_to_iarray (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
have "... = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (to_nat i) (to_nat j) bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
unfolding bezout_iterate_iarrays.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = (if Suc n \<le> mod_type_class.to_nat i then matrix_to_iarray A else bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> Suc n \<le> mod_type_class.to_nat i

goal (1 subgoal):
 1. bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = (if Suc n \<le> mod_type_class.to_nat i then matrix_to_iarray A else bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_iterate_iarrays (bezout_matrix_iarrays (matrix_to_iarray A) (mod_type_class.to_nat i) (Suc n) (mod_type_class.to_nat j) bezout **i matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. \<not> Suc n \<le> mod_type_class.to_nat i \<Longrightarrow> matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal (1 subgoal):
 1. matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
matrix_to_iarray (bezout_iterate A (Suc n) i j bezout) = bezout_iterate_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) bezout

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma affine_dependent_imp_dependent: "affine_dependent s \<Longrightarrow> dependent s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine_dependent s \<Longrightarrow> dependent s
[PROOF STEP]
unfolding affine_dependent_def dependent_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>s. x \<in> affine hull (s - {x}) \<Longrightarrow> \<exists>a\<in>s. a \<in> span (s - {a})
[PROOF STEP]
using affine_hull_subset_span
[PROOF STATE]
proof (prove)
using this:
affine hull ?s \<subseteq> span ?s

goal (1 subgoal):
 1. \<exists>x\<in>s. x \<in> affine hull (s - {x}) \<Longrightarrow> \<exists>a\<in>s. a \<in> span (s - {a})
[PROOF STEP]
by auto


[STATEMENT]
lemma indicator_union_arith:
  "indicator (A \<union> B) x = indicator A x + indicator B x - indicator A x * (indicator B x :: 'a::ring_1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. indicator (A \<union> B) x = indicator A x + indicator B x - indicator A x * indicator B x
[PROOF STEP]
unfolding indicator_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_bool (x \<in> A \<union> B) = of_bool (x \<in> A) + of_bool (x \<in> B) - of_bool (x \<in> A) * of_bool (x \<in> B)
[PROOF STEP]
by (auto simp: min_def max_def)


[STATEMENT]
lemma copy_first_matrix_dim: "dim_row (copy_first_matrix nr nc) = nr" "dim_col (copy_first_matrix nr nc) = nc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (copy_first_matrix nr nc) = nr &&& dim_col (copy_first_matrix nr nc) = nc
[PROOF STEP]
by (simp_all add: copy_first_matrix_def)


[STATEMENT]
lemma has_derivative_zero_connected_constant:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  assumes "connected S"
      and "open S"
      and "finite k"
      and "continuous_on S f"
      and "\<forall>x\<in>(S - k). (f has_derivative (\<lambda>h. 0)) (at x within S)"
    obtains c where "\<And>x. x \<in> S \<Longrightarrow> f(x) = c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof (cases "S = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S = {}\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
S = {}

goal (2 subgoals):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S = {}\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S = {}

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (metis empty_iff that)
[PROOF STATE]
proof (state)
this:
thesis

goal (1 subgoal):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
S \<noteq> {}

goal (1 subgoal):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S \<noteq> {}
[PROOF STEP]
obtain c where "c \<in> S"
[PROOF STATE]
proof (prove)
using this:
S \<noteq> {}

goal (1 subgoal):
 1. (\<And>c. c \<in> S \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis equals0I)
[PROOF STATE]
proof (state)
this:
c \<in> S

goal (1 subgoal):
 1. \<lbrakk>\<And>c. (\<And>x. x \<in> S \<Longrightarrow> f x = c) \<Longrightarrow> thesis; S \<noteq> {}\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c \<in> S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c \<in> S

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (metis has_derivative_zero_unique_strong_connected assms that)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sqrt_sum_squares_half_less:
  "x < u/2 \<Longrightarrow> y < u/2 \<Longrightarrow> 0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> sqrt (x\<^sup>2 + y\<^sup>2) < u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < u / 2; y < u / 2; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> sqrt (x\<^sup>2 + y\<^sup>2) < u
[PROOF STEP]
apply (rule real_sqrt_sum_squares_less)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x < u / 2; y < u / 2; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> \<bar>x\<bar> < u / sqrt 2
 2. \<lbrakk>x < u / 2; y < u / 2; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> \<bar>y\<bar> < u / sqrt 2
[PROOF STEP]
apply (auto simp add: abs_if field_simps)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * sqrt 2 < u
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 < u
[PROOF STEP]
apply (rule le_less_trans [where y = "x*2"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * sqrt 2 \<le> x * 2
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * 2 < u
 3. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 < u
[PROOF STEP]
using less_eq_real_def sqrt2_less_2
[PROOF STATE]
proof (prove)
using this:
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
sqrt 2 < 2

goal (3 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * sqrt 2 \<le> x * 2
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * 2 < u
 3. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 < u
[PROOF STEP]
apply force
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x * 2 < u
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 < u
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 < u
[PROOF STEP]
apply (rule le_less_trans [where y = "y*2"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 \<le> y * 2
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * 2 < u
[PROOF STEP]
using less_eq_real_def sqrt2_less_2 mult_le_cancel_left
[PROOF STATE]
proof (prove)
using this:
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
sqrt 2 < 2
(?c * ?a \<le> ?c * ?b) = (((0::?'a) < ?c \<longrightarrow> ?a \<le> ?b) \<and> (?c < (0::?'a) \<longrightarrow> ?b \<le> ?a))

goal (2 subgoals):
 1. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * sqrt 2 \<le> y * 2
 2. \<lbrakk>x * 2 < u; y * 2 < u; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> y * 2 < u
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma summable_fps:
  fixes f :: "'a :: {banach, real_normed_div_algebra} fps"
  shows "norm z < fps_conv_radius f \<Longrightarrow> summable (\<lambda>n. fps_nth f n * z ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (norm z) < fps_conv_radius f \<Longrightarrow> summable (\<lambda>n. fps_nth f n * z ^ n)
[PROOF STEP]
by (rule summable_in_conv_radius) (simp_all add: fps_conv_radius_def)


[STATEMENT]
lemma hom_int_pow:
  "\<lbrakk>h \<in> hom G H; x \<in> carrier G; group G; group H\<rbrakk> \<Longrightarrow> h (x [^]\<^bsub>G\<^esub> (n :: int)) = (h x) [^]\<^bsub>H\<^esub> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>h \<in> hom G H; x \<in> carrier G; Group.group G; Group.group H\<rbrakk> \<Longrightarrow> h (x [^]\<^bsub>G\<^esub> n) = h x [^]\<^bsub>H\<^esub> n
[PROOF STEP]
by (simp add: group_hom.hom_int_pow group_hom_axioms.intro group_hom_def)


[STATEMENT]
theorem cycle_of_permutation:
  assumes "permutation p" shows "cycle (support p a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
have "(least_power p a) dvd (j - i)" if "i \<le> j" "j < least_power p a" and "(p ^^ i) a = (p ^^ j) a" for i j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. least_power p a dvd j - i
[PROOF STEP]
using funpow_diff[OF bij_is_inj that(1,3)] assms
[PROOF STATE]
proof (prove)
using this:
bij p \<Longrightarrow> (p ^^ (j - i)) a = a
permutation p

goal (1 subgoal):
 1. least_power p a dvd j - i
[PROOF STEP]
by (simp add: permutation least_power_dvd)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; (p ^^ ?i) a = (p ^^ ?j) a\<rbrakk> \<Longrightarrow> least_power p a dvd ?j - ?i

goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; (p ^^ ?i) a = (p ^^ ?j) a\<rbrakk> \<Longrightarrow> least_power p a dvd ?j - ?i

goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
have "i = j" if "i \<le> j" "j < least_power p a" and "(least_power p a) dvd (j - i)" for i j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
using that le_eq_less_or_eq nat_dvd_not_less
[PROOF STATE]
proof (prove)
using this:
i \<le> j
j < least_power p a
least_power p a dvd j - i
(?m \<le> ?n) = (?m < ?n \<or> ?m = ?n)
\<lbrakk>0 < ?m; ?m < ?n\<rbrakk> \<Longrightarrow> \<not> ?n dvd ?m

goal (1 subgoal):
 1. i = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; least_power p a dvd ?j - ?i\<rbrakk> \<Longrightarrow> ?i = ?j

goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; (p ^^ ?i) a = (p ^^ ?j) a\<rbrakk> \<Longrightarrow> least_power p a dvd ?j - ?i
\<lbrakk>?i \<le> ?j; ?j < least_power p a; least_power p a dvd ?j - ?i\<rbrakk> \<Longrightarrow> ?i = ?j
[PROOF STEP]
have "inj_on (\<lambda>i. (p ^^ i) a) {..< (least_power p a)}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; (p ^^ ?i) a = (p ^^ ?j) a\<rbrakk> \<Longrightarrow> least_power p a dvd ?j - ?i
\<lbrakk>?i \<le> ?j; ?j < least_power p a; least_power p a dvd ?j - ?i\<rbrakk> \<Longrightarrow> ?i = ?j

goal (1 subgoal):
 1. inj_on (\<lambda>i. (p ^^ i) a) {..<least_power p a}
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i \<le> ?j; ?j < least_power p a; (p ^^ ?i) a = (p ^^ ?j) a\<rbrakk> \<Longrightarrow> least_power p a dvd ?j - ?i
\<lbrakk>?i \<le> ?j; ?j < least_power p a; least_power p a dvd ?j - ?i\<rbrakk> \<Longrightarrow> ?i = ?j

goal (1 subgoal):
 1. \<forall>x\<in>{..<least_power p a}. \<forall>y\<in>{..<least_power p a}. (p ^^ x) a = (p ^^ y) a \<longrightarrow> x = y
[PROOF STEP]
by (metis le_cases lessThan_iff)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>i. (p ^^ i) a) {..<least_power p a}

goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
inj_on (\<lambda>i. (p ^^ i) a) {..<least_power p a}

goal (1 subgoal):
 1. cycle (support p a)
[PROOF STEP]
by (simp add: atLeast_upt distinct_map)
[PROOF STATE]
proof (state)
this:
cycle (support p a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closed_nonneg_Reals_complex [simp]: "closed (\<real>\<^sub>\<ge>\<^sub>0 :: complex set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed \<real>\<^sub>\<ge>\<^sub>0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closed \<real>\<^sub>\<ge>\<^sub>0
[PROOF STEP]
have "\<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. Re(z) \<ge> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. 0 \<le> Re z}
[PROOF STEP]
using complex_nonneg_Reals_iff complex_is_Real_iff
[PROOF STATE]
proof (prove)
using this:
(?z \<in> \<real>\<^sub>\<ge>\<^sub>0) = (0 \<le> Re ?z \<and> Im ?z = 0)
(?z \<in> \<real>) = (Im ?z = 0)

goal (1 subgoal):
 1. \<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. 0 \<le> Re z}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. 0 \<le> Re z}

goal (1 subgoal):
 1. closed \<real>\<^sub>\<ge>\<^sub>0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. 0 \<le> Re z}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<real>\<^sub>\<ge>\<^sub>0 = \<real> \<inter> {z. 0 \<le> Re z}

goal (1 subgoal):
 1. closed \<real>\<^sub>\<ge>\<^sub>0
[PROOF STEP]
by (metis closed_Real_halfspace_Re_ge)
[PROOF STATE]
proof (state)
this:
closed \<real>\<^sub>\<ge>\<^sub>0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma strict_mono_less_sets_Min:
  assumes "strict_mono_sets I f" "finite I" "I \<noteq> {}"
  shows "less_sets (f (Min I)) (\<Union> (f ` (I - {Min I})))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (Min I) \<lless> \<Union> (f ` (I - {Min I}))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
strict_mono_sets I f
finite I
I \<noteq> {}

goal (1 subgoal):
 1. f (Min I) \<lless> \<Union> (f ` (I - {Min I}))
[PROOF STEP]
by (simp add: strict_mono_sets_def less_sets_UN2 dual_order.strict_iff_order)


[STATEMENT]
lemma rev_star [simp]: "rev ` star A = star (rev ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev ` star A = star (rev ` A)
[PROOF STEP]
by (simp add: star_def image_UN)


[STATEMENT]
lemma M_not_zero_simp: "j < dim_col M \<Longrightarrow> i < dim_row M \<Longrightarrow> M $$ (i, j) \<noteq> 0 \<Longrightarrow> M $$ (i, j) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>j < dim_col M; i < dim_row M; M $$ (i, j) \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> M $$ (i, j) = (1::'b)
[PROOF STEP]
using elems01
[PROOF STATE]
proof (prove)
using this:
elements_mat M \<subseteq> {0::'b, 1::'b}

goal (1 subgoal):
 1. \<lbrakk>j < dim_col M; i < dim_row M; M $$ (i, j) \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> M $$ (i, j) = (1::'b)
[PROOF STEP]
by auto


[STATEMENT]
lemma pm_of_poly_sum: "pm_of_poly x (sum f I) = (\<Sum>i\<in>I. pm_of_poly x (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pm_of_poly x (sum f I) = (\<Sum>i\<in>I. pm_of_poly x (f i))
[PROOF STEP]
by (induct I rule: infinite_finite_induct) (simp_all add: pm_of_poly_plus)


[STATEMENT]
lemma minus_zero_does_nothing: "minus_poly_rev_list x (map ((*) 0) y) = x"
  for x :: "'a::ring list"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. minus_poly_rev_list x (map ((*) (0::'a)) y) = x
[PROOF STEP]
by (induct x y rule: minus_poly_rev_list.induct) auto


[STATEMENT]
lemma minus_real_alg: "(real_of x) - (real_of y) = real_of (x - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of x - real_of y = real_of (x - y)
[PROOF STEP]
unfolding minus_real_alg_def minus_real_def uminus_real_alg plus_real_alg
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of (x + - y) = real_of (x + - y)
[PROOF STEP]
..


[STATEMENT]
lemma vsingleton_Un_iff:
  "set {x} = A \<union>\<^sub>\<circ> B \<longleftrightarrow>
    A = 0 \<and> B = set {x} \<or> A = set {x} \<and> B = 0 \<or> A = set {x} \<and> B = set {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set {x} = A \<union>\<^sub>\<circ> B) = (A = 0 \<and> B = set {x} \<or> A = set {x} \<and> B = 0 \<or> A = set {x} \<and> B = set {x})
[PROOF STEP]
by (metis vunion_vsingleton_iff sup_V_0_left sup_V_0_right sup_idem)


[STATEMENT]
lemma vcard_veqpoll: "vcard A = vcard B \<longleftrightarrow> A \<approx>\<^sub>\<circ> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vcard A = vcard B) = (A \<approx>\<^sub>\<circ> B)
[PROOF STEP]
by (metis cardinal_cong cardinal_eqpoll eqpoll_sym eqpoll_trans)


[STATEMENT]
lemma contour_integral_split_linepath:
  assumes f: "continuous_on (closed_segment a b) f"
      and c: "c \<in> closed_segment a b"
    shows "contour_integral(linepath a b) f = contour_integral(linepath a c) f + contour_integral(linepath c b) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral (linepath a b) f = contour_integral (linepath a c) f + contour_integral (linepath c b) f
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
c \<in> closed_segment a b

goal (1 subgoal):
 1. contour_integral (linepath a b) f = contour_integral (linepath a c) f + contour_integral (linepath c b) f
[PROOF STEP]
by (auto simp: closed_segment_def algebra_simps intro!: contour_integral_split [OF f])


[STATEMENT]
lemma nabla_noether_iff: "Noetherian x \<longleftrightarrow> \<nabla> x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Noetherian x = (\<nabla>x = (zero_class.zero::'a))
[PROOF STEP]
using nabla_noether noether_nabla
[PROOF STATE]
proof (prove)
using this:
\<nabla>?x = (zero_class.zero::'a) \<Longrightarrow> Noetherian ?x
Noetherian ?x \<Longrightarrow> \<nabla>?x = (zero_class.zero::'a)

goal (1 subgoal):
 1. Noetherian x = (\<nabla>x = (zero_class.zero::'a))
[PROOF STEP]
by blast


[STATEMENT]
lemma complex_norm_eq_1_exp_eq: "norm z = 1 \<longleftrightarrow> exp(\<i> * (Arg z)) = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod z = 1) = (exp (\<i> * complex_of_real (Arg z)) = z)
[PROOF STEP]
by (metis Arg_eq exp_not_eq_zero exp_zero mult.left_neutral norm_zero of_real_1 norm_exp_i_times)


[STATEMENT]
theorem is_ord_insrt:
 "is_ord t \<Longrightarrow> is_ord (insrt\<^sub>0 (x::'a::linorder) t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_ord t \<Longrightarrow> is_ord (insrt\<^sub>0 x t)
[PROOF STEP]
by (induct t) (simp_all add:is_ord_l_bal is_ord_r_bal set_of_insrt
    linorder_not_less order_neq_le_trans Let_def)


[STATEMENT]
lemma Least_nat_ex:
  \<open>(n::nat) \<in> S \<Longrightarrow> \<exists>x \<in> S. (\<forall>y \<in> S. x \<le> y)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<in> S \<Longrightarrow> \<exists>x\<in>S. \<forall>y\<in>S. x \<le> y
[PROOF STEP]
by (induction n rule: nat_less_induct, insert not_le_imp_less, blast)


[STATEMENT]
lemma [code]:
  "rtrancl (Rel X R) = Rel UNIV (R\<^sup>+)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rtrancl (Rel X R) = Rel UNIV (R\<^sup>+)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>X R. (Id_on X \<union> R)\<^sup>* = Id_on UNIV \<union> R\<^sup>+
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>X R a b. \<lbrakk>(a, b) \<in> (Id_on X \<union> R)\<^sup>*; (a, b) \<notin> R\<^sup>+\<rbrakk> \<Longrightarrow> (a, b) \<in> Id_on UNIV
 2. \<And>X R a b. (a, b) \<in> R\<^sup>+ \<Longrightarrow> (a, b) \<in> (Id_on X \<union> R)\<^sup>*
[PROOF STEP]
apply (metis Id_on_iff Un_commute UNIV_I rtrancl_Un_separatorE rtrancl_eq_or_trancl)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>X R a b. (a, b) \<in> R\<^sup>+ \<Longrightarrow> (a, b) \<in> (Id_on X \<union> R)\<^sup>*
[PROOF STEP]
by (metis in_rtrancl_UnI trancl_into_rtrancl)


[STATEMENT]
lemma INFM_imp_distrib: "(INFM x. P x \<longrightarrow> Q x) \<longleftrightarrow> ((MOST x. P x) \<longrightarrow> (INFM x. Q x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>\<^sub>\<infinity>x. P x \<longrightarrow> Q x) = ((\<forall>\<^sub>\<infinity>x. P x) \<longrightarrow> (\<exists>\<^sub>\<infinity>x. Q x))
[PROOF STEP]
by (rule frequently_imp_iff)


[STATEMENT]
lemma det_snd_Gauss_Jordan_det_P[code_unfold]:
fixes A::"'a::{field}^'n::{mod_type}^'n::{mod_type}"
shows "det (snd (Gauss_Jordan_det_P A)) = prod (\<lambda>i. (snd (Gauss_Jordan_det_P A))$i$i) (UNIV:: 'n set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (snd (Gauss_Jordan_det_P A)) = (\<Prod>i\<in>UNIV. snd (Gauss_Jordan_det_P A) $ i $ i)
[PROOF STEP]
unfolding snd_Gauss_Jordan_det_P_is_Gauss_Jordan det_Gauss_Jordan
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>UNIV. Gauss_Jordan A $ i $ i) = (\<Prod>i\<in>UNIV. Gauss_Jordan A $ i $ i)
[PROOF STEP]
..


[STATEMENT]
lemma (in finite_boolean_algebra) UNIV_card:
  "card (UNIV::'a set) = card (Pow \<J>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card UNIV = card (Pow \<J>)
[PROOF STEP]
using
    bij_betw_same_card [where f="\<lambda>x. \<lbrace> x \<rbrace>"]
    birkhoffs_theorem
[PROOF STATE]
proof (prove)
using this:
bij_betw join_irreducibles_embedding ?A ?B \<Longrightarrow> card ?A = card ?B
bij_betw join_irreducibles_embedding UNIV \<O>\<J>

goal (1 subgoal):
 1. card UNIV = card (Pow \<J>)
[PROOF STEP]
unfolding
    \<O>\<J>_is_Pow_\<J>
[PROOF STATE]
proof (prove)
using this:
bij_betw join_irreducibles_embedding ?A ?B \<Longrightarrow> card ?A = card ?B
bij_betw join_irreducibles_embedding UNIV (Pow \<J>)

goal (1 subgoal):
 1. card UNIV = card (Pow \<J>)
[PROOF STEP]
by blast


[STATEMENT]
lemma set_rel_csv[relator_props]:
  "\<lbrakk> single_valued (R\<inverse>) \<rbrakk>
  \<Longrightarrow> single_valued ((\<langle>R\<rangle>set_rel)\<inverse>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. single_valued (R\<inverse>) \<Longrightarrow> single_valued ((\<langle>R\<rangle>set_rel)\<inverse>)
[PROOF STEP]
unfolding single_valued_def set_rel_def converse_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. (y, x) \<in> R \<longrightarrow> (\<forall>z. (z, x) \<in> R \<longrightarrow> y = z) \<Longrightarrow> \<forall>x y. (y, x) \<in> {(A, B). (\<forall>x\<in>A. \<exists>y\<in>B. (x, y) \<in> R) \<and> (\<forall>y\<in>B. \<exists>x\<in>A. (x, y) \<in> R)} \<longrightarrow> (\<forall>z. (z, x) \<in> {(A, B). (\<forall>x\<in>A. \<exists>y\<in>B. (x, y) \<in> R) \<and> (\<forall>y\<in>B. \<exists>x\<in>A. (x, y) \<in> R)} \<longrightarrow> y = z)
[PROOF STEP]
by fast


[STATEMENT]
lemma infsum_superconst_infinite_enat:
  fixes f :: \<open>'a \<Rightarrow> enat\<close>
  assumes geqb: \<open>\<And>x. x \<in> S \<Longrightarrow> f x \<ge> b\<close>
  assumes b: \<open>b > 0\<close>
  assumes \<open>infinite S\<close>
  shows "infsum f S = \<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
have \<open>ennreal_of_enat (infsum f S) = infsum (ennreal_of_enat o f) S\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal_of_enat (infsum f S) = infsum (ennreal_of_enat \<circ> f) S
[PROOF STEP]
apply (rule infsum_comm_additive_general[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>F. \<lbrakk>finite F; F \<subseteq> S\<rbrakk> \<Longrightarrow> sum (ennreal_of_enat \<circ> f) F = ennreal_of_enat (sum f F)
 2. isCont ennreal_of_enat (infsum f S)
 3. f summable_on S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ennreal_of_enat (infsum f S) = infsum (ennreal_of_enat \<circ> f) S

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ennreal_of_enat (infsum f S) = infsum (ennreal_of_enat \<circ> f) S

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
have \<open>\<dots> = \<infinity>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum (ennreal_of_enat \<circ> f) S = \<infinity>
[PROOF STEP]
by (metis assms(3) b comp_apply ennreal_of_enat_0 ennreal_of_enat_inj ennreal_of_enat_le_iff geqb infsum_superconst_infinite_ennreal not_gr_zero)
[PROOF STATE]
proof (state)
this:
infsum (ennreal_of_enat \<circ> f) S = \<infinity>

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
infsum (ennreal_of_enat \<circ> f) S = \<infinity>

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
have \<open>\<dots> = ennreal_of_enat \<infinity>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<infinity> = ennreal_of_enat \<infinity>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<infinity> = ennreal_of_enat \<infinity>

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ennreal_of_enat (infsum f S) = ennreal_of_enat \<infinity>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ennreal_of_enat (infsum f S) = ennreal_of_enat \<infinity>

goal (1 subgoal):
 1. infsum f S = \<infinity>
[PROOF STEP]
by (rule ennreal_of_enat_inj[THEN iffD1])
[PROOF STATE]
proof (state)
this:
infsum f S = \<infinity>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma relcomp_on_triple[simp]:
  shows "on_triple (R O S) = on_triple R O on_triple S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. on_triple (R O S) = on_triple R O on_triple S
[PROOF STEP]
unfolding on_triple_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {((l, s, t), l', s', t'). l = l' \<and> (s, s') \<in> R O S \<and> (t, t') \<in> R O S} = {((l, s, t), l', s', t'). l = l' \<and> (s, s') \<in> R \<and> (t, t') \<in> R} O {((l, s, t), l', s', t'). l = l' \<and> (s, s') \<in> S \<and> (t, t') \<in> S}
[PROOF STEP]
by fast


[STATEMENT]
lemma matrix_to_iarray_snd_QR_decomposition[code_unfold]:
  shows "matrix_to_iarray (snd (QR_decomposition A)) = snd (QR_decomposition_iarrays (matrix_to_iarray A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (QR_decomposition A)) = snd (QR_decomposition_iarrays (matrix_to_iarray A))
[PROOF STEP]
proof (unfold iarray_exhaust2 list_eq_iff_nth_eq, rule conjI, auto, unfold IArray.sub_def[symmetric] IArray.length_def[symmetric])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. IArray.length (matrix_to_iarray (snd (QR_decomposition A))) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)))
 2. \<And>i. i < IArray.length (matrix_to_iarray (snd (QR_decomposition A))) \<Longrightarrow> IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i)
 3. \<And>i ia. \<lbrakk>i < IArray.length (matrix_to_iarray (snd (QR_decomposition A))); ia < IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i)\<rbrakk> \<Longrightarrow> matrix_to_iarray (snd (QR_decomposition A)) !! i !! ia = snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i !! ia
[PROOF STEP]
fix i ia
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. IArray.length (matrix_to_iarray (snd (QR_decomposition A))) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)))
 2. \<And>i. i < IArray.length (matrix_to_iarray (snd (QR_decomposition A))) \<Longrightarrow> IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i)
 3. \<And>i ia. \<lbrakk>i < IArray.length (matrix_to_iarray (snd (QR_decomposition A))); ia < IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i)\<rbrakk> \<Longrightarrow> matrix_to_iarray (snd (QR_decomposition A)) !! i !! ia = snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i !! ia
[PROOF STEP]
show "IArray.length (matrix_to_iarray (snd (QR_decomposition A)))
    = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)))"
    and "IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i)
    = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i)"
    and "matrix_to_iarray (snd (QR_decomposition A)) !! i !! ia
    = snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i !! ia"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (matrix_to_iarray (snd (QR_decomposition A))) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A))) &&& IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i) &&& matrix_to_iarray (snd (QR_decomposition A)) !! i !! ia = snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i !! ia
[PROOF STEP]
unfolding QR_decomposition_iarrays_def QR_decomposition_def Let_def snd_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A)) ** A)) = IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) &&& IArray.length (matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A)) ** A) !! i) = IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) &&& matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A)) ** A) !! i !! ia = (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia
[PROOF STEP]
unfolding matrix_to_iarray_matrix_matrix_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) = IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) &&& IArray.length ((matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i) = IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) &&& (matrix_to_iarray (Finite_Cartesian_Product.transpose (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i !! ia = (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia
[PROOF STEP]
unfolding matrix_to_iarray_transpose
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (transpose_iarray (matrix_to_iarray (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) = IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) &&& IArray.length ((transpose_iarray (matrix_to_iarray (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i) = IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) &&& (transpose_iarray (matrix_to_iarray (divide_by_norm (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i !! ia = (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia
[PROOF STEP]
unfolding matrix_to_iarray_divide_by_norm
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (transpose_iarray (divide_by_norm_iarray (matrix_to_iarray (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) = IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) &&& IArray.length ((transpose_iarray (divide_by_norm_iarray (matrix_to_iarray (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i) = IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) &&& (transpose_iarray (divide_by_norm_iarray (matrix_to_iarray (Gram_Schmidt_matrix A))) **i matrix_to_iarray A) !! i !! ia = (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia
[PROOF STEP]
unfolding matrix_to_iarray_Gram_Schmidt_matrix
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) = IArray.length (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) &&& IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) = IArray.length ((transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i) &&& (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia = (transpose_iarray (divide_by_norm_iarray (Gram_Schmidt_matrix_iarrays (matrix_to_iarray A))) **i matrix_to_iarray A) !! i !! ia
[PROOF STEP]
by rule+
[PROOF STATE]
proof (state)
this:
IArray.length (matrix_to_iarray (snd (QR_decomposition A))) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)))
IArray.length (matrix_to_iarray (snd (QR_decomposition A)) !! i) = IArray.length (snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i)
matrix_to_iarray (snd (QR_decomposition A)) !! i !! ia = snd (QR_decomposition_iarrays (matrix_to_iarray A)) !! i !! ia

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma product_composition_lemma:
  assumes c0: "c$0 = (0::'a::idom)"
    and d0: "d$0 = 0"
  shows "((a oo c) * (b oo d))$n =
    sum (\<lambda>(k,m). a$k * b$m * (c^k * d^m) $ n) {(k,m). k + m \<le> n}"  (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
let ?S = "{(k::nat, m::nat). k + m \<le> n}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have s: "?S \<subseteq> {0..n} \<times> {0..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(k, m). k + m \<le> n} \<subseteq> {0..n} \<times> {0..n}
[PROOF STEP]
by (simp add: subset_eq)
[PROOF STATE]
proof (state)
this:
{(k, m). k + m \<le> n} \<subseteq> {0..n} \<times> {0..n}

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have f: "finite {(k::nat, m::nat). k + m \<le> n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {(k, m). k + m \<le> n}
[PROOF STEP]
by (auto intro: finite_subset[OF s])
[PROOF STATE]
proof (state)
this:
finite {(k, m). k + m \<le> n}

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have "?r = (\<Sum>(k, m) \<in> {(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n) = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j)))
[PROOF STEP]
by (simp add: fps_mult_nth sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n) = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j)))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n) = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j)))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have "\<dots> = (\<Sum>i = 0..n. \<Sum>(k,m)\<in>{(k,m). k+m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n-i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j))) = (\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i))
[PROOF STEP]
unfolding sum.swap [where A = "{0..n}"]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j))) = (\<Sum>j\<in>{(k, m). k + m \<le> n}. \<Sum>i = 0..n. case j of (k, m) \<Rightarrow> a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i))
[PROOF STEP]
by (auto simp add: field_simps intro: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j))) = (\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. \<Sum>j = 0..n. a $ k * b $ m * (c ^ k $ j * d ^ m $ (n - j))) = (\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have "... = (\<Sum>i = 0..n.
                    \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i)) = (\<Sum>i = 0..n. \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i)))
[PROOF STEP]
apply (rule sum.cong [OF refl])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..n} \<Longrightarrow> (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ x * b $ m * d ^ m $ (n - x)) = (\<Sum>q = 0..x. \<Sum>j = 0..n - x. a $ q * c ^ q $ x * (b $ j * d ^ j $ (n - x)))
[PROOF STEP]
apply (simp add: sum.cartesian_product mult.assoc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<le> n \<Longrightarrow> (\<Sum>xa\<in>{(k, m). k + m \<le> n}. case xa of (k, m) \<Rightarrow> a $ k * (c ^ k $ x * (b $ m * d ^ m $ (n - x)))) = (\<Sum>xa\<in>{0..x} \<times> {0..n - x}. case xa of (q, j) \<Rightarrow> a $ q * (c ^ q $ x * (b $ j * d ^ j $ (n - x))))
[PROOF STEP]
apply (rule sum.mono_neutral_right[OF f], force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<le> n \<Longrightarrow> \<forall>i\<in>{(k, m). k + m \<le> n} - {0..x} \<times> {0..n - x}. (case i of (k, m) \<Rightarrow> a $ k * (c ^ k $ x * (b $ m * d ^ m $ (n - x)))) = (0::'a)
[PROOF STEP]
by clarsimp (meson c0 d0 leI startsby_zero_power_prefix)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i)) = (\<Sum>i = 0..n. \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i)))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. \<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * c ^ k $ i * b $ m * d ^ m $ (n - i)) = (\<Sum>i = 0..n. \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i)))

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
have "\<dots> = ?l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i))) = ((a oo c) * (b oo d)) $ n
[PROOF STEP]
by (simp add: fps_mult_nth fps_compose_nth sum_product)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. \<Sum>q = 0..i. \<Sum>j = 0..n - i. a $ q * c ^ q $ i * (b $ j * d ^ j $ (n - i))) = ((a oo c) * (b oo d)) $ n

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n) = ((a oo c) * (b oo d)) $ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n) = ((a oo c) * (b oo d)) $ n

goal (1 subgoal):
 1. ((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((a oo c) * (b oo d)) $ n = (\<Sum>(k, m)\<in>{(k, m). k + m \<le> n}. a $ k * b $ m * (c ^ k * d ^ m) $ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma samp_uni_plus_one_time_pad:
  shows "map_spmf (\<lambda>b. (y + b) mod q) (sample_uniform q) = (sample_uniform q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>b. (y + b) mod q) (sample_uniform q) = sample_uniform q
[PROOF STEP]
using inj_uni_samp_add surj_uni_samp one_time_pad
[PROOF STATE]
proof (prove)
using this:
inj_on (\<lambda>b. (?y + b) mod ?q) {..<?q}
inj_on (\<lambda>b. (?y + b) mod ?q) {..<?q} \<Longrightarrow> (\<lambda>b. (?y + b) mod ?q) ` {..<?q} = {..<?q}
\<lbrakk>inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}\<rbrakk> \<Longrightarrow> map_spmf ?f (sample_uniform ?q) = sample_uniform ?q

goal (1 subgoal):
 1. map_spmf (\<lambda>b. (y + b) mod q) (sample_uniform q) = sample_uniform q
[PROOF STEP]
by simp


[STATEMENT]
lemma homeomorphic_contractible:
  fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set"
  shows "\<lbrakk>contractible S; S homeomorphic T\<rbrakk> \<Longrightarrow> contractible T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>contractible S; S homeomorphic T\<rbrakk> \<Longrightarrow> contractible T
[PROOF STEP]
by (metis homeomorphic_contractible_eq)


[STATEMENT]
lemma Gauss_Jordan_in_ij_det_P_code[code]:
shows "Gauss_Jordan_in_ij_det_P 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 (if i = n then 1/(A $ i $ j) else - 1/(A $ n $ j), Gauss_Jordan_wrapper i j A' interchange_A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Gauss_Jordan_in_ij_det_P A i j = (let n = LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n; interchange_A = interchange_rows A i n; A' = mult_row interchange_A i ((1::'a) / interchange_A $ i $ j) in (if i = n then (1::'a) / A $ i $ j else - (1::'a) / A $ n $ j, Gauss_Jordan_wrapper i j A' interchange_A))
[PROOF STEP]
unfolding Gauss_Jordan_in_ij_det_P_def Gauss_Jordan_in_ij_def Gauss_Jordan_wrapper_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) then (1::'a) / A $ i $ j else - (1::'a) / A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j, \<chi>s. if s = i then mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n)) i ((1::'a) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ i $ j) $ s else row_add (mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n)) i ((1::'a) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ i $ j)) s i (- interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ s $ j) $ s) = (if i = (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) then (1::'a) / A $ i $ j else - (1::'a) / A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j, \<chi>s. if s = i then mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n)) i ((1::'a) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ i $ j) $ s else row_add (mult_row (interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n)) i ((1::'a) / interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ i $ j)) s i (- interchange_rows A i (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ s $ j) $ s)
[PROOF STEP]
by auto


[STATEMENT]
lemma polytope_linear_image: "\<lbrakk>linear f; polytope p\<rbrakk> \<Longrightarrow> polytope(image f p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>linear f; polytope p\<rbrakk> \<Longrightarrow> polytope (f ` p)
[PROOF STEP]
unfolding polytope_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>linear f; \<exists>v. finite v \<and> p = convex hull v\<rbrakk> \<Longrightarrow> \<exists>v. finite v \<and> f ` p = convex hull v
[PROOF STEP]
using convex_hull_linear_image
[PROOF STATE]
proof (prove)
using this:
linear ?f \<Longrightarrow> ?f ` (convex hull ?s) = convex hull ?f ` ?s

goal (1 subgoal):
 1. \<lbrakk>linear f; \<exists>v. finite v \<and> p = convex hull v\<rbrakk> \<Longrightarrow> \<exists>v. finite v \<and> f ` p = convex hull v
[PROOF STEP]
by blast


[STATEMENT]
lemma "\<forall>(x::'a::linordered_field) < 0. \<exists>(y::'a::linordered_field) > 0. 7 * x + y > 0 \<and> x - y \<le> 9"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x<0::'a. \<exists>y>0::'a. (0::'a) < (7::'a) * x + y \<and> x - y \<le> (9::'a)
[PROOF STEP]
by ferrack


[STATEMENT]
lemma monoseq_Suc: "monoseq X \<longleftrightarrow> (\<forall>n. X n \<le> X (Suc n)) \<or> (\<forall>n. X (Suc n) \<le> X n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monoseq X = ((\<forall>n. X n \<le> X (Suc n)) \<or> (\<forall>n. X (Suc n) \<le> X n))
[PROOF STEP]
unfolding monoseq_iff incseq_Suc_iff decseq_Suc_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>n. X n \<le> X (Suc n)) \<or> (\<forall>n. X (Suc n) \<le> X n)) = ((\<forall>n. X n \<le> X (Suc n)) \<or> (\<forall>n. X (Suc n) \<le> X n))
[PROOF STEP]
..


[STATEMENT]
theorem wls_vsubstAbs_compose2:
assumes  "wlsAbs (us,s) A"
and "ys \<noteq> zs \<or> y \<notin> {z,z1}"
shows "((A $[y1 // y]_ys) $[z1 // z]_zs) = ((A $[z1 // z]_zs) $[(y1 @ys[z1 / z]_zs) // y]_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $[y1 // y]_ys $[z1 // z]_zs = A $[z1 // z]_zs $[y1 @ys[z1 / z]_zs // y]_ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wlsAbs (us, s) A
ys \<noteq> zs \<or> y \<notin> {z, z1}

goal (1 subgoal):
 1. A $[y1 // y]_ys $[z1 // z]_zs = A $[z1 // z]_zs $[y1 @ys[z1 / z]_zs // y]_ys
[PROOF STEP]
by(simp add: vsubstAbs_compose2)


[STATEMENT]
lemma minimise_states_subset :
  assumes "observable M"
  and     "q \<in> states (minimise M)"
shows "q \<subseteq> states M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<subseteq> FSM.states M
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
q \<in> FSM.states (minimise M)

goal (1 subgoal):
 1. q \<subseteq> FSM.states M
[PROOF STEP]
unfolding minimise_props[OF assms(1)]
[PROOF STATE]
proof (prove)
using this:
q \<in> (\<lambda>q. {q' \<in> FSM.states M. LS M q = LS M q'}) ` FSM.states M

goal (1 subgoal):
 1. q \<subseteq> FSM.states M
[PROOF STEP]
by auto


[STATEMENT]
lemma trans_finite_has_maximal_elt:
  assumes "trans r"
  assumes "finite (Field r)"
  assumes "Field r \<noteq> {}"
  shows "\<exists>x\<in>Field r. (\<forall>y\<in>Field r. (x, y) \<in> r \<longrightarrow> (y, x) \<in> r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>Field r. \<forall>y\<in>Field r. (x, y) \<in> r \<longrightarrow> (y, x) \<in> r
[PROOF STEP]
using assms(2,1,3)
[PROOF STATE]
proof (prove)
using this:
finite (Field r)
trans r
Field r \<noteq> {}

goal (1 subgoal):
 1. \<exists>x\<in>Field r. \<forall>y\<in>Field r. (x, y) \<in> r \<longrightarrow> (y, x) \<in> r
[PROOF STEP]
by induct (auto elim: transE)


[STATEMENT]
lemma has_field_derivative_powr_right [derivative_intros]:
    "w \<noteq> 0 \<Longrightarrow> ((\<lambda>z. w powr z) has_field_derivative Ln w * w powr z) (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<noteq> 0 \<Longrightarrow> ((powr) w has_field_derivative Ln w * w powr z) (at z)
[PROOF STEP]
unfolding powr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<noteq> 0 \<Longrightarrow> ((\<lambda>z. if w = 0 then 0 else exp (z * Ln w)) has_field_derivative Ln w * (if w = 0 then 0 else exp (z * Ln w))) (at z)
[PROOF STEP]
by (intro derivative_eq_intros | simp)+


[STATEMENT]
lemma dim_empty [simp]: "dim {} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim {} = 0
[PROOF STEP]
by (rule dim_unique[OF order_refl]) (auto simp: dependent_def)


[STATEMENT]
lemma piecewise_continuous_on_integrable:
  fixes a b::real and f::"real \<Rightarrow> 'a::euclidean_space"
  assumes "piecewise_continuous_on a b I f"
  shows "f integrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f integrable_on {a..b}
[PROOF STEP]
using piecewise_continuous_on_imp_absolutely_integrable[OF assms]
[PROOF STATE]
proof (prove)
using this:
f absolutely_integrable_on {a..b}

goal (1 subgoal):
 1. f integrable_on {a..b}
[PROOF STEP]
unfolding absolutely_integrable_on_def
[PROOF STATE]
proof (prove)
using this:
f integrable_on {a..b} \<and> (\<lambda>x. norm (f x)) integrable_on {a..b}

goal (1 subgoal):
 1. f integrable_on {a..b}
[PROOF STEP]
by auto


[STATEMENT]
lemma n_min1_2: "n = 2  \<Longrightarrow> \<omega>  = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 \<Longrightarrow> \<omega> = - 1
[PROOF STEP]
using omega_properties(1) omega_properties(2) power2_eq_1_iff
[PROOF STATE]
proof (prove)
using this:
\<omega> ^ n = 1
\<omega> \<noteq> 1
(?a\<^sup>2 = (1::?'a)) = (?a = (1::?'a) \<or> ?a = - (1::?'a))

goal (1 subgoal):
 1. n = 2 \<Longrightarrow> \<omega> = - 1
[PROOF STEP]
by blast


[STATEMENT]
lemma integrable_on_cmult_right_iff [simp]:
  fixes f :: "_ \<Rightarrow> 'b :: {comm_ring,real_algebra_1,real_normed_vector}"
  assumes "c \<noteq> 0"
  shows "(\<lambda>x. f x * of_real c) integrable_on s \<longleftrightarrow> f integrable_on s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f x * of_real c) integrable_on s) = (f integrable_on s)
[PROOF STEP]
using integrable_on_cmult_left_iff [OF assms]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. of_real c * ?f x) integrable_on ?s) = (?f integrable_on ?s)

goal (1 subgoal):
 1. ((\<lambda>x. f x * of_real c) integrable_on s) = (f integrable_on s)
[PROOF STEP]
by (simp add: mult.commute)


[STATEMENT]
lemma multiplicity_same_power': "multiplicity p (p ^ n) = (if p = 0 \<or> is_unit p then 0 else n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
consider "p = 0" | "is_unit p" |"p \<noteq> 0" "\<not>is_unit p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p = (0::'a) \<Longrightarrow> thesis; is_unit p \<Longrightarrow> thesis; \<lbrakk>p \<noteq> (0::'a); \<not> is_unit p\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>p = (0::'a) \<Longrightarrow> ?thesis1; is_unit p \<Longrightarrow> ?thesis1; \<lbrakk>p \<noteq> (0::'a); \<not> is_unit p\<rbrakk> \<Longrightarrow> ?thesis1\<rbrakk> \<Longrightarrow> ?thesis1

goal (1 subgoal):
 1. multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>p = (0::'a) \<Longrightarrow> ?thesis1; is_unit p \<Longrightarrow> ?thesis1; \<lbrakk>p \<noteq> (0::'a); \<not> is_unit p\<rbrakk> \<Longrightarrow> ?thesis1\<rbrakk> \<Longrightarrow> ?thesis1

goal (1 subgoal):
 1. multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. p = (0::'a) \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
 2. is_unit p \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
 3. \<lbrakk>p \<noteq> (0::'a); \<not> is_unit p\<rbrakk> \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
assume "p \<noteq> 0" "\<not>is_unit p"
[PROOF STATE]
proof (state)
this:
p \<noteq> (0::'a)
\<not> is_unit p

goal (3 subgoals):
 1. p = (0::'a) \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
 2. is_unit p \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
 3. \<lbrakk>p \<noteq> (0::'a); \<not> is_unit p\<rbrakk> \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p \<noteq> (0::'a)
\<not> is_unit p

goal (1 subgoal):
 1. multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
by (induction n) (simp_all add: multiplicity_times_same)
[PROOF STATE]
proof (state)
this:
multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)

goal (2 subgoals):
 1. p = (0::'a) \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
 2. is_unit p \<Longrightarrow> multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)
[PROOF STEP]
qed (simp_all add: power_0_left multiplicity_unit_left)
[PROOF STATE]
proof (state)
this:
multiplicity p (p ^ n) = (if p = (0::'a) \<or> is_unit p then 0 else n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infsetsum_mono:
  fixes f g :: "'a \<Rightarrow> real"
  assumes "f abs_summable_on A" and "g abs_summable_on A"
  assumes "\<And>x. x \<in> A \<Longrightarrow> f x \<le> g x"
  shows   "infsetsum f A \<le> infsetsum g A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsetsum f A \<le> infsetsum g A
[PROOF STEP]
by (intro infsetsum_mono_neutral assms) auto


[STATEMENT]
lemma soundness_diagonalize_JNF':
  fixes A::"'a mat"
  assumes "is_bezout_ext bezout" and "A \<in> carrier_mat m n"
  and "diagonalize_JNF A bezout = (P,S,Q)"
  shows "P \<in> carrier_mat m m \<and> Q \<in> carrier_mat n n \<and> S \<in> carrier_mat m n
      \<and> invertible_mat P \<and> invertible_mat Q \<and> isDiagonal_mat S \<and> S = P*A*Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P \<in> carrier_mat m m \<and> Q \<in> carrier_mat n n \<and> S \<in> carrier_mat m n \<and> invertible_mat P \<and> invertible_mat Q \<and> isDiagonal_mat S \<and> S = P * A * Q
[PROOF STEP]
using soundness_diagonalize_JNF assms
[PROOF STATE]
proof (prove)
using this:
\<forall>A bezout. A \<in> carrier_mat ?m ?n \<and> is_bezout_ext bezout \<longrightarrow> (case diagonalize_JNF A bezout of (P, S, Q) \<Rightarrow> P \<in> carrier_mat ?m ?m \<and> Q \<in> carrier_mat ?n ?n \<and> S \<in> carrier_mat ?m ?n \<and> invertible_mat P \<and> invertible_mat Q \<and> isDiagonal_mat S \<and> S = P * A * Q)
is_bezout_ext bezout
A \<in> carrier_mat m n
diagonalize_JNF A bezout = (P, S, Q)

goal (1 subgoal):
 1. P \<in> carrier_mat m m \<and> Q \<in> carrier_mat n n \<and> S \<in> carrier_mat m n \<and> invertible_mat P \<and> invertible_mat Q \<and> isDiagonal_mat S \<and> S = P * A * Q
[PROOF STEP]
unfolding case_prod_beta
[PROOF STATE]
proof (prove)
using this:
\<forall>A bezout. A \<in> carrier_mat ?m ?n \<and> is_bezout_ext bezout \<longrightarrow> fst (diagonalize_JNF A bezout) \<in> carrier_mat ?m ?m \<and> snd (snd (diagonalize_JNF A bezout)) \<in> carrier_mat ?n ?n \<and> fst (snd (diagonalize_JNF A bezout)) \<in> carrier_mat ?m ?n \<and> invertible_mat (fst (diagonalize_JNF A bezout)) \<and> invertible_mat (snd (snd (diagonalize_JNF A bezout))) \<and> isDiagonal_mat (fst (snd (diagonalize_JNF A bezout))) \<and> fst (snd (diagonalize_JNF A bezout)) = fst (diagonalize_JNF A bezout) * A * snd (snd (diagonalize_JNF A bezout))
is_bezout_ext bezout
A \<in> carrier_mat m n
diagonalize_JNF A bezout = (P, S, Q)

goal (1 subgoal):
 1. P \<in> carrier_mat m m \<and> Q \<in> carrier_mat n n \<and> S \<in> carrier_mat m n \<and> invertible_mat P \<and> invertible_mat Q \<and> isDiagonal_mat S \<and> S = P * A * Q
[PROOF STEP]
by (metis fst_conv snd_conv)


[STATEMENT]
lemma contour_integral_local_primitive_lemma:
  fixes f :: "complex\<Rightarrow>complex"
  assumes gpd: "g piecewise_differentiable_on {a..b}"
      and dh: "\<And>x. x \<in> S \<Longrightarrow> (f has_field_derivative f' x) (at x within S)"
      and gs: "\<And>x. x \<in> {a..b} \<Longrightarrow> g x \<in> S"
  shows
    "(\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
[PROOF STEP]
proof (cases "cbox a b = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. cbox a b = {} \<Longrightarrow> (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
 2. cbox a b \<noteq> {} \<Longrightarrow> (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
cbox a b \<noteq> {}

goal (2 subgoals):
 1. cbox a b = {} \<Longrightarrow> (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
 2. cbox a b \<noteq> {} \<Longrightarrow> (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cbox a b \<noteq> {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cbox a b \<noteq> {}

goal (1 subgoal):
 1. (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
[PROOF STEP]
unfolding integrable_on_def
[PROOF STATE]
proof (prove)
using this:
cbox a b \<noteq> {}

goal (1 subgoal):
 1. \<exists>y. ((\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) has_integral y) {a..b}
[PROOF STEP]
by (auto intro: assms contour_integral_primitive_lemma)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}

goal (1 subgoal):
 1. cbox a b = {} \<Longrightarrow> (\<lambda>x. f' (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b}
[PROOF STEP]
qed auto


[STATEMENT]
lemma uwellformed_alt_snd:
  assumes "uwellformed G" "{x, y} \<in> uedges G"
  shows "y \<in> uverts G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<in> uverts G
[PROOF STEP]
using uwellformed_def assms
[PROOF STATE]
proof (prove)
using this:
uwellformed ?G \<equiv> \<forall>e\<in>uedges ?G. card e = 2 \<and> (\<forall>u\<in>e. u \<in> uverts ?G)
uwellformed G
{x, y} \<in> uedges G

goal (1 subgoal):
 1. y \<in> uverts G
[PROOF STEP]
by simp


[STATEMENT]
lemma conj_wo_inv:
  assumes QG:"subgroup Q G"
  assumes PG:"subgroup P G"
  assumes g:"g \<in> carrier G"
  assumes conj:"inv g <# (Q #> g) = P"
  shows "Q #> g = g <# P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
from g
[PROOF STATE]
proof (chain)
picking this:
g \<in> carrier G
[PROOF STEP]
have invg:"inv g \<in> carrier G"
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier G

goal (1 subgoal):
 1. inv g \<in> carrier G
[PROOF STEP]
by (metis inv_closed)
[PROOF STATE]
proof (state)
this:
inv g \<in> carrier G

goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
from conj
[PROOF STATE]
proof (chain)
picking this:
inv g <# (Q #> g) = P
[PROOF STEP]
have "g <# (inv g <# (Q #> g)) = g <# P"
[PROOF STATE]
proof (prove)
using this:
inv g <# (Q #> g) = P

goal (1 subgoal):
 1. g <# (inv g <# (Q #> g)) = g <# P
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
g <# (inv g <# (Q #> g)) = g <# P

goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
with QG g invg
[PROOF STATE]
proof (chain)
picking this:
subgroup Q G
g \<in> carrier G
inv g \<in> carrier G
g <# (inv g <# (Q #> g)) = g <# P
[PROOF STEP]
have "(g \<otimes> inv g) <# (Q #> g) = g <# P"
[PROOF STATE]
proof (prove)
using this:
subgroup Q G
g \<in> carrier G
inv g \<in> carrier G
g <# (inv g <# (Q #> g)) = g <# P

goal (1 subgoal):
 1. g \<otimes> inv g <# (Q #> g) = g <# P
[PROOF STEP]
by (metis lcos_m_assoc r_coset_subset_G subgroup.subset)
[PROOF STATE]
proof (state)
this:
g \<otimes> inv g <# (Q #> g) = g <# P

goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
with g invg
[PROOF STATE]
proof (chain)
picking this:
g \<in> carrier G
inv g \<in> carrier G
g \<otimes> inv g <# (Q #> g) = g <# P
[PROOF STEP]
have "\<one> <# (Q #> g) = g <# P"
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier G
inv g \<in> carrier G
g \<otimes> inv g <# (Q #> g) = g <# P

goal (1 subgoal):
 1. \<one> <# (Q #> g) = g <# P
[PROOF STEP]
by (metis r_inv)
[PROOF STATE]
proof (state)
this:
\<one> <# (Q #> g) = g <# P

goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
with QG g
[PROOF STATE]
proof (chain)
picking this:
subgroup Q G
g \<in> carrier G
\<one> <# (Q #> g) = g <# P
[PROOF STEP]
show "Q #> g = g <# P"
[PROOF STATE]
proof (prove)
using this:
subgroup Q G
g \<in> carrier G
\<one> <# (Q #> g) = g <# P

goal (1 subgoal):
 1. Q #> g = g <# P
[PROOF STEP]
by (metis lcos_mult_one r_coset_subset_G subgroup.subset)
[PROOF STATE]
proof (state)
this:
Q #> g = g <# P

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linear_orderable_2_3:
  "linear_orderable_2 x \<longleftrightarrow> linear_orderable_3 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_orderable_2 x = linear_orderable_3 x
[PROOF STEP]
using linear_strict_order_split
[PROOF STATE]
proof (prove)
using this:
linear_orderable_2 ?x = linear_orderable_3 ?x

goal (1 subgoal):
 1. linear_orderable_2 x = linear_orderable_3 x
[PROOF STEP]
by auto


[STATEMENT]
lemma permutation_of_poly_list_is_poly_list:
  assumes "is_poly_tuple k fs"
  assumes "\<sigma> permutes {..< length fs}"
  shows "is_poly_tuple k (permute_list \<sigma> fs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_poly_tuple k (permute_list \<sigma> fs)
[PROOF STEP]
unfolding is_poly_tuple_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (permute_list \<sigma> fs) \<subseteq> carrier (R [\<X>\<^bsub>k\<^esub>])
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (permute_list \<sigma> fs) \<subseteq> carrier (R [\<X>\<^bsub>k\<^esub>])
[PROOF STEP]
show "set (permute_list \<sigma> fs) \<subseteq> carrier (coord_ring R k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (permute_list \<sigma> fs) \<subseteq> carrier (R [\<X>\<^bsub>k\<^esub>])
[PROOF STEP]
using assms is_poly_tuple_def set_permute_list
[PROOF STATE]
proof (prove)
using this:
is_poly_tuple k fs
\<sigma> permutes {..<length fs}
is_poly_tuple ?n ?fs = (set ?fs \<subseteq> carrier (R [\<X>\<^bsub>?n\<^esub>]))
?f permutes {..<length ?xs} \<Longrightarrow> set (permute_list ?f ?xs) = set ?xs

goal (1 subgoal):
 1. set (permute_list \<sigma> fs) \<subseteq> carrier (R [\<X>\<^bsub>k\<^esub>])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set (permute_list \<sigma> fs) \<subseteq> carrier (R [\<X>\<^bsub>k\<^esub>])

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_prpart_plus [simp] : "fls_prpart (f + g) = fls_prpart f + fls_prpart g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_prpart (f + g) = fls_prpart f + fls_prpart g
[PROOF STEP]
by (intro poly_eqI) simp


[STATEMENT]
lemma tensor_prod_of_cnot_id_1:
  shows "(CNOT \<Otimes> Id 1) = M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CNOT \<Otimes> Quantum.Id 1 = M1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
 2. dim_row (CNOT \<Otimes> Quantum.Id 1) = dim_row M1
 3. dim_col (CNOT \<Otimes> Quantum.Id 1) = dim_col M1
[PROOF STEP]
show "dim_col (CNOT \<Otimes> Id 1) = dim_col M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (CNOT \<Otimes> Quantum.Id 1) = dim_col M1
[PROOF STEP]
by(simp add: CNOT_def Id_def mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
dim_col (CNOT \<Otimes> Quantum.Id 1) = dim_col M1

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
 2. dim_row (CNOT \<Otimes> Quantum.Id 1) = dim_row M1
[PROOF STEP]
show "dim_row (CNOT \<Otimes> Id 1) = dim_row M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (CNOT \<Otimes> Quantum.Id 1) = dim_row M1
[PROOF STEP]
by(simp add: CNOT_def Id_def  mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
dim_row (CNOT \<Otimes> Quantum.Id 1) = dim_row M1

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
[PROOF STEP]
fix i j::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
[PROOF STEP]
assume "i < dim_row M1" and "j < dim_col M1"
[PROOF STATE]
proof (state)
this:
i < dim_row M1
j < dim_col M1

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row M1
j < dim_col M1
[PROOF STEP]
have "i \<in> {0..<8} \<and> j \<in> {0..<8}"
[PROOF STATE]
proof (prove)
using this:
i < dim_row M1
j < dim_col M1

goal (1 subgoal):
 1. i \<in> {0..<8} \<and> j \<in> {0..<8}
[PROOF STEP]
by (auto simp add:  mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
i \<in> {0..<8} \<and> j \<in> {0..<8}

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row M1; j < dim_col M1\<rbrakk> \<Longrightarrow> (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<in> {0..<8} \<and> j \<in> {0..<8}
[PROOF STEP]
show "(CNOT \<Otimes> Id 1) $$ (i, j) = M1 $$ (i, j)"
[PROOF STATE]
proof (prove)
using this:
i \<in> {0..<8} \<and> j \<in> {0..<8}

goal (1 subgoal):
 1. (CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)
[PROOF STEP]
by (auto simp add: Id_def CNOT_def mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
(CNOT \<Otimes> Quantum.Id 1) $$ (i, j) = M1 $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_to_iarray_rows: "vec_to_iarray` (rows A) = rows_iarray (matrix_to_iarray A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray ` rows A = rows_iarray (matrix_to_iarray A)
[PROOF STEP]
unfolding rows_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray ` {row i A |i. i \<in> UNIV} = rows_iarray (matrix_to_iarray A)
[PROOF STEP]
unfolding rows_iarray_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray ` {row i A |i. i \<in> UNIV} = {row_iarray i (matrix_to_iarray A) |i. i \<in> {..<nrows_iarray (matrix_to_iarray A)}}
[PROOF STEP]
apply (auto simp add: vec_to_iarray_row to_nat_less_card nrows_eq_card_rows)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < CARD('c) \<Longrightarrow> row_iarray i (matrix_to_iarray A) \<in> vec_to_iarray ` {uu_. \<exists>i. uu_ = row i A}
[PROOF STEP]
by (unfold image_def, auto, metis from_nat_not_eq vec_to_iarray_row)


[STATEMENT]
lemma left_diff_repeat_zmset_distrib':
  \<open>i \<ge> j \<Longrightarrow> repeat_zmset (i - j) u = repeat_zmset i u - repeat_zmset j u\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j \<le> i \<Longrightarrow> repeat_zmset (i - j) u = repeat_zmset i u - repeat_zmset j u
[PROOF STEP]
by (auto simp: zmultiset_eq_iff int_distrib(3) of_nat_diff)