[STATEMENT]
lemma mat_append_row_row:
  assumes "dim_col A = dim_vec c"
  shows "row (mat_append_row A c) (dim_row A) = c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (mat_append_row A c) (dim_row A) = c
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
 2. dim_vec (row (mat_append_row A c) (dim_row A)) = dim_vec c
[PROOF STEP]
let ?nA = "(mat_of_rows (dim_col A) (Matrix.rows A @ [c]))"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
 2. dim_vec (row (mat_append_row A c) (dim_row A)) = dim_vec c
[PROOF STEP]
show "dim_vec (Matrix.row (mat_append_row A c) (dim_row A)) = dim_vec c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (row (mat_append_row A c) (dim_row A)) = dim_vec c
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
dim_col A = dim_vec c

goal (1 subgoal):
 1. dim_vec (row (mat_append_row A c) (dim_row A)) = dim_vec c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec (row (mat_append_row A c) (dim_row A)) = dim_vec c

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
assume "i < dim_vec c"
[PROOF STATE]
proof (state)
this:
i < dim_vec c

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
from mat_append_row.simps[of A c]
[PROOF STATE]
proof (chain)
picking this:
mat_append_row A c = mat_of_rows (dim_col A) (rows A @ [c])
[PROOF STEP]
have "row (mat_append_row A c) (dim_row A) $ i = vec_index (row ?nA (dim_row A)) i"
[PROOF STATE]
proof (prove)
using this:
mat_append_row A c = mat_of_rows (dim_col A) (rows A @ [c])

goal (1 subgoal):
 1. row (mat_append_row A c) (dim_row A) $ i = row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (mat_append_row A c) (dim_row A) $ i = row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
row (mat_append_row A c) (dim_row A) $ i = row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
have "... = vec_index (vec (dim_col ?nA) (\<lambda> j. ?nA $$ (dim_row A,j))) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i = vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i
[PROOF STEP]
by (simp add: Matrix.row_def)
[PROOF STATE]
proof (state)
this:
row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i = vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
row (mat_of_rows (dim_col A) (rows A @ [c])) (dim_row A) $ i = vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
have "... =  vec_index ((rows A @ [c]) ! dim_row A) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i = (rows A @ [c]) ! dim_row A $ i
[PROOF STEP]
by (metis (mono_tags, lifting) \<open>mat_append_row A c = mat_of_rows (dim_col A) (Matrix.rows A @ [c])\<close>
        add_Suc_right append_Nil2 assms calculation carrier_matD(1) col_transpose cols_transpose
        index_transpose_mat(2) index_transpose_mat(3) length_append length_rows lessI list.size(3)
        mat_append_col.elims mat_append_col_col mat_append_row_dims nth_append_length
        transpose_mat_of_rows One_nat_def)
[PROOF STATE]
proof (state)
this:
vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i = (rows A @ [c]) ! dim_row A $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec (dim_col (mat_of_rows (dim_col A) (rows A @ [c]))) (\<lambda>j. mat_of_rows (dim_col A) (rows A @ [c]) $$ (dim_row A, j)) $ i = (rows A @ [c]) ! dim_row A $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
have "... = vec_index c i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (rows A @ [c]) ! dim_row A $ i = c $ i
[PROOF STEP]
by (metis length_rows nth_append_length)
[PROOF STATE]
proof (state)
this:
(rows A @ [c]) ! dim_row A $ i = c $ i

goal (1 subgoal):
 1. \<And>i. i < dim_vec c \<Longrightarrow> row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
show "Matrix.row (mat_append_row A c) (dim_row A) $ i = c $ i"
[PROOF STATE]
proof (prove)
using this:
row (mat_append_row A c) (dim_row A) $ i = c $ i

goal (1 subgoal):
 1. row (mat_append_row A c) (dim_row A) $ i = c $ i
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
row (mat_append_row A c) (dim_row A) $ i = c $ i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem budan_fourier_le:
  assumes "p\<noteq>0"
  shows "changes_le_der b p \<ge> proots_count p {x. x \<le>b} \<and>
          even (changes_le_der b p - proots_count p {x. x \<le>b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
define ps where "ps=pders p"
[PROOF STATE]
proof (state)
this:
ps = pders p

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
obtain lb where lb_root:"\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> x > lb"
    and lb_sgn:"\<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p"
    and "lb < b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>lb. \<lbrakk>\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> lb < x; \<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p; lb < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using root_list_lb[of ps b] set_pders_nzero[OF \<open>p\<noteq>0\<close>,folded ps_def]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<notin> set ps; \<And>lb. \<lbrakk>\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> lb < x; \<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p; lb < b\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
?q \<in> set ps \<Longrightarrow> ?q \<noteq> 0

goal (1 subgoal):
 1. (\<And>lb. \<lbrakk>\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> lb < x; \<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p; lb < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> lb < x
\<forall>x\<le>lb. \<forall>p\<in>set ps. sgn (poly p x) = sgn_neg_inf p
lb < b

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
have "proots_count p {x. x \<le>b} = proots_count p {x. lb< x \<and> x \<le> b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
have "p\<in>set ps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<in> set ps
[PROOF STEP]
unfolding ps_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<in> set (pders p)
[PROOF STEP]
by (simp add: assms pders.simps)
[PROOF STATE]
proof (state)
this:
p \<in> set ps

goal (1 subgoal):
 1. proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p \<in> set ps
[PROOF STEP]
have "proots_within p {x. x \<le>b} = proots_within p {x. lb< x \<and> x\<le>b}"
[PROOF STATE]
proof (prove)
using this:
p \<in> set ps

goal (1 subgoal):
 1. proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
using lb_root
[PROOF STATE]
proof (prove)
using this:
p \<in> set ps
\<forall>p\<in>set ps. \<forall>x. poly p x = 0 \<longrightarrow> lb < x

goal (1 subgoal):
 1. proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}

goal (1 subgoal):
 1. proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}

goal (1 subgoal):
 1. proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
[PROOF STEP]
unfolding proots_count_def
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. x \<le> b} = proots_within p {x. lb < x \<and> x \<le> b}

goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p {x. x \<le> b}. order r p) = (\<Sum>r\<in>proots_within p {x. lb < x \<and> x \<le> b}. order r p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
have "changes_le_der b p = changes_itv_der lb b p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
have "map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps
[PROOF STEP]
using lb_sgn[THEN spec,of lb,simplified]
[PROOF STATE]
proof (prove)
using this:
\<forall>p\<in>set ps. sgn (poly p lb) = sgn_neg_inf p

goal (1 subgoal):
 1. map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps
[PROOF STEP]
by (metis (mono_tags, lifting) comp_def list.map_cong0)
[PROOF STATE]
proof (state)
this:
map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps

goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
hence "changes_poly_at ps lb=changes_poly_neg_inf ps"
[PROOF STATE]
proof (prove)
using this:
map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps

goal (1 subgoal):
 1. changes_poly_at ps lb = changes_poly_neg_inf ps
[PROOF STEP]
unfolding changes_poly_neg_inf_def changes_poly_at_def
[PROOF STATE]
proof (prove)
using this:
map (sgn \<circ> (\<lambda>p. poly p lb)) ps = map sgn_neg_inf ps

goal (1 subgoal):
 1. changes (map (\<lambda>p. poly p lb) ps) = changes (map sgn_neg_inf ps)
[PROOF STEP]
by (subst changes_map_sgn_eq,metis map_map)
[PROOF STATE]
proof (state)
this:
changes_poly_at ps lb = changes_poly_neg_inf ps

goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
changes_poly_at ps lb = changes_poly_neg_inf ps
[PROOF STEP]
have "changes_poly_at ps lb=degree p"
[PROOF STATE]
proof (prove)
using this:
changes_poly_at ps lb = changes_poly_neg_inf ps

goal (1 subgoal):
 1. changes_poly_at ps lb = int (degree p)
[PROOF STEP]
unfolding ps_def
[PROOF STATE]
proof (prove)
using this:
changes_poly_at (pders p) lb = changes_poly_neg_inf (pders p)

goal (1 subgoal):
 1. changes_poly_at (pders p) lb = int (degree p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
changes_poly_at ps lb = int (degree p)

goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
changes_poly_at ps lb = int (degree p)

goal (1 subgoal):
 1. changes_le_der b p = changes_itv_der lb b p
[PROOF STEP]
unfolding changes_le_der_def changes_itv_der_def ps_def
[PROOF STATE]
proof (prove)
using this:
changes_poly_at (pders p) lb = int (degree p)

goal (1 subgoal):
 1. int (degree p) - changes_poly_at (pders p) b = (let ps = pders p in changes_poly_at ps lb - changes_poly_at ps b)
[PROOF STEP]
by (simp add:Let_def)
[PROOF STATE]
proof (state)
this:
changes_le_der b p = changes_itv_der lb b p

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
changes_le_der b p = changes_itv_der lb b p

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
changes_le_der b p = changes_itv_der lb b p

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
have "proots_count p {x. lb < x \<and> x \<le> b} \<le> changes_itv_der lb b p \<and>
      even (changes_itv_der lb b p - proots_count p {x. lb < x \<and> x \<le> b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))
[PROOF STEP]
using budan_fourier_interval[OF \<open>lb<b\<close> \<open>p\<noteq>0\<close>]
[PROOF STATE]
proof (prove)
using this:
int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))

goal (1 subgoal):
 1. int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
changes_le_der b p = changes_itv_der lb b p
int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. x \<le> b} = proots_count p {x. lb < x \<and> x \<le> b}
changes_le_der b p = changes_itv_der lb b p
int (proots_count p {x. lb < x \<and> x \<le> b}) \<le> changes_itv_der lb b p \<and> even (changes_itv_der lb b p - int (proots_count p {x. lb < x \<and> x \<le> b}))

goal (1 subgoal):
 1. int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. x \<le> b}) \<le> changes_le_der b p \<and> even (changes_le_der b p - int (proots_count p {x. x \<le> b}))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_gt_zero2: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < sin x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < x; x < pi / 2\<rbrakk> \<Longrightarrow> 0 < sin x
[PROOF STEP]
by (metis sin_gt_zero_02 order_less_trans pi_half_less_two)


[STATEMENT]
lemma length_coeffs_of_qr:
  "length (coeffs (of_qr (x ::'a qr))) < Suc (nat n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
proof (cases "x=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
 2. x \<noteq> 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> 0

goal (2 subgoals):
 1. x = 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
 2. x \<noteq> 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> 0
[PROOF STEP]
have "of_qr x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. of_qr x \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_qr x \<noteq> 0

goal (2 subgoals):
 1. x = 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
 2. x \<noteq> 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
of_qr x \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_qr x \<noteq> 0

goal (1 subgoal):
 1. length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
using length_coeffs_degree[of "of_qr x"] deg_of_qr[of x]
[PROOF STATE]
proof (prove)
using this:
of_qr x \<noteq> 0
of_qr x \<noteq> 0 \<Longrightarrow> length (coeffs (of_qr x)) = Suc (degree (of_qr x))
degree (of_qr x) < deg_qr TYPE('a)

goal (1 subgoal):
 1. length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
using deg_qr_n
[PROOF STATE]
proof (prove)
using this:
of_qr x \<noteq> 0
of_qr x \<noteq> 0 \<Longrightarrow> length (coeffs (of_qr x)) = Suc (degree (of_qr x))
degree (of_qr x) < deg_qr TYPE('a)
int (deg_qr TYPE('a)) = n

goal (1 subgoal):
 1. length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
length (coeffs (of_qr x)) < Suc (nat n)

goal (1 subgoal):
 1. x = 0 \<Longrightarrow> length (coeffs (of_qr x)) < Suc (nat n)
[PROOF STEP]
qed  (auto simp add: n_gt_zero)


[STATEMENT]
lemma pseudo_divmod_field:
  fixes g :: "'a::field poly"
  assumes g: "g \<noteq> 0"
    and *: "pseudo_divmod f g = (q,r)"
  defines "c \<equiv> coeff g (degree g) ^ (Suc (degree f) - degree g)"
  shows "f = g * smult (1/c) q + smult (1/c) r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
from leading_coeff_neq_0[OF g]
[PROOF STATE]
proof (chain)
picking this:
lead_coeff g \<noteq> (0::'a)
[PROOF STEP]
have c0: "c \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
lead_coeff g \<noteq> (0::'a)

goal (1 subgoal):
 1. c \<noteq> (0::'a)
[PROOF STEP]
by (auto simp: c_def)
[PROOF STATE]
proof (state)
this:
c \<noteq> (0::'a)

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
from pseudo_divmod(1)[OF g *, folded c_def]
[PROOF STATE]
proof (chain)
picking this:
smult c f = g * q + r
[PROOF STEP]
have "smult c f = g * q + r"
[PROOF STATE]
proof (prove)
using this:
smult c f = g * q + r

goal (1 subgoal):
 1. smult c f = g * q + r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
smult c f = g * q + r

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
smult c f = g * q + r

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
have "smult (1 / c) \<dots> = g * smult (1 / c) q + smult (1 / c) r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) (g * q + r) = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
by (simp add: smult_add_right)
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) (g * q + r) = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
smult ((1::'a) / c) (smult c f) = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
smult ((1::'a) / c) (smult c f) = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
using c0
[PROOF STATE]
proof (prove)
using this:
smult ((1::'a) / c) (smult c f) = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
c \<noteq> (0::'a)

goal (1 subgoal):
 1. f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f = g * smult ((1::'a) / c) q + smult ((1::'a) / c) r

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma normal_moment_nz_1: "has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
note normal_moment_even[OF \<sigma>_pos, of \<mu> 0]
[PROOF STATE]
proof (state)
this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0)) (fact (2 * 0) / ((2 / \<sigma>\<^sup>2) ^ 0 * fact 0))

goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
note normal_moment_odd[OF \<sigma>_pos, of \<mu> 0] has_bochner_integral_mult_left[of \<mu>, OF this]
[PROOF STATE]
proof (state)
this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0 + 1)) 0
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0) * \<mu>) (fact (2 * 0) / ((2 / \<sigma>\<^sup>2) ^ 0 * fact 0) * \<mu>)

goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
note has_bochner_integral_add[OF this]
[PROOF STATE]
proof (state)
this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0 + 1) + normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0) * \<mu>) (0 + fact (2 * 0) / ((2 / \<sigma>\<^sup>2) ^ 0 * fact 0) * \<mu>)

goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0 + 1) + normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0) * \<mu>) (0 + fact (2 * 0) / ((2 / \<sigma>\<^sup>2) ^ 0 * fact 0) * \<mu>)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0 + 1) + normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * 0) * \<mu>) (0 + fact (2 * 0) / ((2 / \<sigma>\<^sup>2) ^ 0 * fact 0) * \<mu>)

goal (1 subgoal):
 1. has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>
[PROOF STEP]
by (simp add: power2_eq_square field_simps)
[PROOF STATE]
proof (state)
this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * x) \<mu>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_pre:
  "(\<And>x y xs ys. zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y) \<Longrightarrow> sorted zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x y xs ys. zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y) \<Longrightarrow> sorted zs
[PROOF STEP]
apply (induction zs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (\<And>x y xs ys. [] = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y) \<Longrightarrow> sorted []
 2. \<And>a zs. \<lbrakk>(\<And>x y xs ys. zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y) \<Longrightarrow> sorted zs; \<And>x y xs ys. a # zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y\<rbrakk> \<Longrightarrow> sorted (a # zs)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a zs. \<lbrakk>(\<And>x y xs ys. zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y) \<Longrightarrow> sorted zs; \<And>x y xs ys. a # zs = xs @ [x, y] @ ys \<Longrightarrow> x \<le> y\<rbrakk> \<Longrightarrow> sorted (a # zs)
[PROOF STEP]
by (metis append_Nil append_Cons list.exhaust sorted1 sorted2)


[STATEMENT]
lemma less_4_cases:
  assumes n: "n < 4"
  shows "n = 0 \<or> n = 1 \<or> n = 2 \<or> n = (3::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 0 \<or> n = 1 \<or> n = 2 \<or> n = 3
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
n < 4

goal (1 subgoal):
 1. n = 0 \<or> n = 1 \<or> n = 2 \<or> n = 3
[PROOF STEP]
by linarith


[STATEMENT]
lemma circline_equation_quadratic_equation:
  assumes "circline_equation A B (cnj B) D z 1" and
          "Re z = x" and "Im z = y" and "Re B = bx" and "Im B = by"
  shows "A*x\<^sup>2 + A*y\<^sup>2 + 2*bx*x + 2*by*y + D = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
circline_equation A B (cnj B) D z 1
Re z = x
Im z = y
Re B = bx
Im B = by

goal (1 subgoal):
 1. A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>circline_equation A B (cnj B) D z 1; Re z = x; Im z = y; Re B = bx; Im B = by\<rbrakk> \<Longrightarrow> A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
have "z = x + \<i>*y" "B = bx + \<i>*by"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z = cor x + \<i> * cor y &&& B = cor bx + \<i> * cor by
[PROOF STEP]
using assms complex_eq
[PROOF STATE]
proof (prove)
using this:
circline_equation A B (cnj B) D z 1
Re z = x
Im z = y
Re B = bx
Im B = by
?a = cor (Re ?a) + \<i> * cor (Im ?a)

goal (1 subgoal):
 1. z = cor x + \<i> * cor y &&& B = cor bx + \<i> * cor by
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z = cor x + \<i> * cor y
B = cor bx + \<i> * cor by

goal (1 subgoal):
 1. \<lbrakk>circline_equation A B (cnj B) D z 1; Re z = x; Im z = y; Re B = bx; Im B = by\<rbrakk> \<Longrightarrow> A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
z = cor x + \<i> * cor y
B = cor bx + \<i> * cor by

goal (1 subgoal):
 1. A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
z = cor x + \<i> * cor y
B = cor bx + \<i> * cor by
circline_equation A B (cnj B) D z 1
Re z = x
Im z = y
Re B = bx
Im B = by

goal (1 subgoal):
 1. A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0
[PROOF STEP]
by (simp add: field_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
A * cor (x\<^sup>2) + A * cor (y\<^sup>2) + cor (2 * bx * x) + cor (2 * by * y) + D = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma csa_list_copr_rel:
  fixes p:: "real poly"
  fixes qs:: "real poly list"
  assumes nonzero: "p\<noteq>0"
  assumes pairwise_rel_prime: "\<forall>q. ((List.member qs q) \<longrightarrow> (coprime p q))"
  shows "characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
have "\<forall>q \<in> set(qs). \<forall> x \<in> set (characterize_root_list_p p).  poly q x \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0
[PROOF STEP]
using pairwise_rel_prime
[PROOF STATE]
proof (prove)
using this:
\<forall>q. List.member qs q \<longrightarrow> coprime p q

goal (1 subgoal):
 1. \<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0
[PROOF STEP]
using coprime_poly_0 in_set_member nonzero poly_roots_finite characterize_root_list_p_def
[PROOF STATE]
proof (prove)
using this:
\<forall>q. List.member qs q \<longrightarrow> coprime p q
coprime ?p ?q \<Longrightarrow> poly ?p ?x \<noteq> (0::?'a) \<or> poly ?q ?x \<noteq> (0::?'a)
(?x \<in> set ?xs) = List.member ?xs ?x
p \<noteq> 0
?p \<noteq> 0 \<Longrightarrow> finite {x. poly ?p x = (0::?'a)}
characterize_root_list_p ?p \<equiv> sorted_list_of_set {x. poly ?p x = 0}

goal (1 subgoal):
 1. \<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0

goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0
[PROOF STEP]
have h: "\<forall>q \<in> set(qs). \<forall> x \<in> set (characterize_root_list_p p). squash (poly q x) = (if (poly q x > 0) then (1::rat) else (-1::rat))"
[PROOF STATE]
proof (prove)
using this:
\<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). poly q x \<noteq> 0

goal (1 subgoal):
 1. \<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). squash (poly q x) = (if 0 < poly q x then 1 else - 1)
[PROOF STEP]
by (simp add: squash_def)
[PROOF STATE]
proof (state)
this:
\<forall>q\<in>set qs. \<forall>x\<in>set (characterize_root_list_p p). squash (poly q x) = (if 0 < poly q x then 1 else - 1)

goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
have "map (\<lambda>r. map (\<lambda>p. if 0 < poly p r then 1 else - 1) qs) (characterize_root_list_p p) = map (\<lambda>r. map (squash \<circ> (\<lambda>p. poly p r)) qs) (characterize_root_list_p p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>r. map (\<lambda>p. if 0 < poly p r then 1 else - 1) qs) (characterize_root_list_p p) = map (\<lambda>r. map (squash \<circ> (\<lambda>p. poly p r)) qs) (characterize_root_list_p p)
[PROOF STEP]
by (simp add: h)
[PROOF STATE]
proof (state)
this:
map (\<lambda>r. map (\<lambda>p. if 0 < poly p r then 1 else - 1) qs) (characterize_root_list_p p) = map (\<lambda>r. map (squash \<circ> (\<lambda>p. poly p r)) qs) (characterize_root_list_p p)

goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>r. map (\<lambda>p. if 0 < poly p r then 1 else - 1) qs) (characterize_root_list_p p) = map (\<lambda>r. map (squash \<circ> (\<lambda>p. poly p r)) qs) (characterize_root_list_p p)

goal (1 subgoal):
 1. characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs
[PROOF STEP]
unfolding characterize_consistent_signs_at_roots_def characterize_consistent_signs_at_roots_copr_def
      signs_at_def consistent_sign_vec_copr_def
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>r. map (\<lambda>p. if 0 < poly p r then 1 else - 1) qs) (characterize_root_list_p p) = map (\<lambda>r. map (squash \<circ> (\<lambda>p. poly p r)) qs) (characterize_root_list_p p)

goal (1 subgoal):
 1. remdups (map (\<lambda>x. map (squash \<circ> (\<lambda>q. poly q x)) qs) (characterize_root_list_p p)) = remdups (map (\<lambda>x. map (\<lambda>q. if 0 < poly q x then 1 else - 1) qs) (characterize_root_list_p p))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
characterize_consistent_signs_at_roots p qs = characterize_consistent_signs_at_roots_copr p qs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fds_shift_mult [simp]:
  fixes f g :: "'a :: {comm_semiring, nat_power} fds"
  shows "fds_shift c (f * g) = fds_shift c f * fds_shift c g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_shift c (f * g) = fds_shift c f * fds_shift c g
[PROOF STEP]
by (rule fds_eqI)
     (auto simp: algebra_simps fds_nth_mult dirichlet_prod_altdef2
        sum_distrib_left sum_distrib_right nat_power_mult_distrib intro!: sum.cong)


[STATEMENT]
lemma fps_left_inverse_eq_fps_right_inverse:
  fixes   f :: "'a::ring_1 fps"
  assumes f0: "x * f$0 = 1" "f $ 0 * y = 1"
  \<comment> \<open>These assumptions imply x equals y, but no need to assume that.\<close>
  shows   "fps_left_inverse f x = fps_right_inverse f y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
from f0(2)
[PROOF STATE]
proof (chain)
picking this:
f $ 0 * y = (1::'a)
[PROOF STEP]
have "f * fps_right_inverse f y = 1"
[PROOF STATE]
proof (prove)
using this:
f $ 0 * y = (1::'a)

goal (1 subgoal):
 1. f * fps_right_inverse f y = 1
[PROOF STEP]
by (simp add: fps_right_inverse)
[PROOF STATE]
proof (state)
this:
f * fps_right_inverse f y = 1

goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
hence "fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x"
[PROOF STATE]
proof (prove)
using this:
f * fps_right_inverse f y = 1

goal (1 subgoal):
 1. fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x
[PROOF STEP]
by (simp add: mult.assoc)
[PROOF STATE]
proof (state)
this:
fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x

goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x

goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
from f0(1)
[PROOF STATE]
proof (chain)
picking this:
x * f $ 0 = (1::'a)
[PROOF STEP]
have
    "fps_left_inverse f x * f * fps_right_inverse f y = fps_right_inverse f y"
[PROOF STATE]
proof (prove)
using this:
x * f $ 0 = (1::'a)

goal (1 subgoal):
 1. fps_left_inverse f x * f * fps_right_inverse f y = fps_right_inverse f y
[PROOF STEP]
by (simp add: fps_left_inverse)
[PROOF STATE]
proof (state)
this:
fps_left_inverse f x * f * fps_right_inverse f y = fps_right_inverse f y

goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x
fps_left_inverse f x * f * fps_right_inverse f y = fps_right_inverse f y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fps_left_inverse f x * f * fps_right_inverse f y = fps_left_inverse f x
fps_left_inverse f x * f * fps_right_inverse f y = fps_right_inverse f y

goal (1 subgoal):
 1. fps_left_inverse f x = fps_right_inverse f y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fps_left_inverse f x = fps_right_inverse f y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_matpower [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. matpow (f x) n) \<longlongrightarrow> matpow a n) F"
  for f :: "'a \<Rightarrow> 'b :: {semiring_1, real_normed_algebra} ^ 'n ^ 'n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. matpow (f x) n) \<longlongrightarrow> matpow a n) F
[PROOF STEP]
by (induct n, simp_all add: tendsto_mat_mult)


[STATEMENT]
lemma cong_mult_lcancel:
  "[k * a = k * b] (mod m) = [a = b] (mod m)"
  if "coprime k m" for a k m :: "'a::{unique_euclidean_ring, ring_gcd}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [k * a = k * b] (mod m) = [a = b] (mod m)
[PROOF STEP]
using that cong_mult_rcancel [of k m a b]
[PROOF STATE]
proof (prove)
using this:
coprime k m
coprime k m \<Longrightarrow> [a * k = b * k] (mod m) = [a = b] (mod m)

goal (1 subgoal):
 1. [k * a = k * b] (mod m) = [a = b] (mod m)
[PROOF STEP]
by (simp add: ac_simps)


[STATEMENT]
lemma nn_integral_densityR:
  assumes [measurable]: "f \<in> borel_measurable F" "g \<in> borel_measurable F"
  shows "(\<integral>\<^sup>+ x. f x * g x \<partial>F) = (\<integral>\<^sup>+ x. f x \<partial>(density F g))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
have "(\<integral>\<^sup>+ x. f x * g x \<partial>F) = (\<integral>\<^sup>+ x. g x * f x \<partial>F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = \<integral>\<^sup>+ x. g x * f x \<partial>F
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * g x \<partial>F = \<integral>\<^sup>+ x. g x * f x \<partial>F

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * g x \<partial>F = \<integral>\<^sup>+ x. g x * f x \<partial>F

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
have "... = (\<integral>\<^sup>+ x. f x \<partial>(density F g))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. g x * f x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
by (rule nn_integral_density[symmetric], simp_all add: assms)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. g x * f x \<partial>F = integral\<^sup>N (density F g) f

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * g x \<partial>F = integral\<^sup>N (density F g) f

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_solovay_strassen_liars_composite:
  fixes n :: nat
  assumes "\<not>prime n" "n > 2" "odd n"
  shows   "card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2"
    (is "card ?A < _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
interpret euler_witness_context n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. euler_witness_context n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> prime n
2 < n
odd n

goal (1 subgoal):
 1. euler_witness_context n
[PROOF STEP]
unfolding euler_witness_context_def
[PROOF STATE]
proof (prove)
using this:
\<not> prime n
2 < n
odd n

goal (1 subgoal):
 1. 1 < n \<and> odd n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
have "card H < (n - 1) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card H < (n - 1) div 2
[PROOF STEP]
by (intro card_euler_liars_cosets_limit(2) assms)
[PROOF STATE]
proof (state)
this:
card H < (n - 1) div 2

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card H < (n - 1) div 2

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
\<not> prime n
2 < n
odd n
[PROOF STEP]
have "H = insert 1 ?A"
[PROOF STATE]
proof (prove)
using this:
\<not> prime n
2 < n
odd n

goal (1 subgoal):
 1. H = insert 1 {a \<in> {2..<n}. solovay_strassen_witness n a}
[PROOF STEP]
by (auto simp: solovay_strassen_witness_def Let_def
                   euler_witness_def H_def Jacobi_eq_0_iff_not_coprime)
[PROOF STATE]
proof (state)
this:
H = insert 1 {a \<in> {2..<n}. solovay_strassen_witness n a}

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
H = insert 1 {a \<in> {2..<n}. solovay_strassen_witness n a}

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
have "card \<dots> = card ?A + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (insert 1 {a \<in> {2..<n}. solovay_strassen_witness n a}) = card {a \<in> {2..<n}. solovay_strassen_witness n a} + 1
[PROOF STEP]
by (subst card.insert) auto
[PROOF STATE]
proof (state)
this:
card (insert 1 {a \<in> {2..<n}. solovay_strassen_witness n a}) = card {a \<in> {2..<n}. solovay_strassen_witness n a} + 1

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {a \<in> {2..<n}. solovay_strassen_witness n a} + 1 < (n - 1) div 2
[PROOF STEP]
show "card ?A < (n - 2) div 2"
[PROOF STATE]
proof (prove)
using this:
card {a \<in> {2..<n}. solovay_strassen_witness n a} + 1 < (n - 1) div 2

goal (1 subgoal):
 1. card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
card {a \<in> {2..<n}. solovay_strassen_witness n a} < (n - 2) div 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma frontier_of_Union_subset:
   "finite \<F> \<Longrightarrow> X frontier_of (\<Union>\<F>) \<subseteq> (\<Union>T \<in> \<F>. X frontier_of T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite \<F> \<Longrightarrow> X frontier_of \<Union> \<F> \<subseteq> \<Union> ((frontier_of) X ` \<F>)
[PROOF STEP]
proof (induction \<F> rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. X frontier_of \<Union> {} \<subseteq> \<Union> ((frontier_of) X ` {})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; X frontier_of \<Union> F \<subseteq> \<Union> ((frontier_of) X ` F)\<rbrakk> \<Longrightarrow> X frontier_of \<Union> (insert x F) \<subseteq> \<Union> ((frontier_of) X ` insert x F)
[PROOF STEP]
case (insert A \<F>)
[PROOF STATE]
proof (state)
this:
finite \<F>
A \<notin> \<F>
X frontier_of \<Union> \<F> \<subseteq> \<Union> ((frontier_of) X ` \<F>)

goal (2 subgoals):
 1. X frontier_of \<Union> {} \<subseteq> \<Union> ((frontier_of) X ` {})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; X frontier_of \<Union> F \<subseteq> \<Union> ((frontier_of) X ` F)\<rbrakk> \<Longrightarrow> X frontier_of \<Union> (insert x F) \<subseteq> \<Union> ((frontier_of) X ` insert x F)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite \<F>
A \<notin> \<F>
X frontier_of \<Union> \<F> \<subseteq> \<Union> ((frontier_of) X ` \<F>)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite \<F>
A \<notin> \<F>
X frontier_of \<Union> \<F> \<subseteq> \<Union> ((frontier_of) X ` \<F>)

goal (1 subgoal):
 1. X frontier_of \<Union> (insert A \<F>) \<subseteq> \<Union> ((frontier_of) X ` insert A \<F>)
[PROOF STEP]
using frontier_of_Un_subset
[PROOF STATE]
proof (prove)
using this:
finite \<F>
A \<notin> \<F>
X frontier_of \<Union> \<F> \<subseteq> \<Union> ((frontier_of) X ` \<F>)
?X frontier_of (?S \<union> ?T) \<subseteq> ?X frontier_of ?S \<union> ?X frontier_of ?T

goal (1 subgoal):
 1. X frontier_of \<Union> (insert A \<F>) \<subseteq> \<Union> ((frontier_of) X ` insert A \<F>)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
X frontier_of \<Union> (insert A \<F>) \<subseteq> \<Union> ((frontier_of) X ` insert A \<F>)

goal (1 subgoal):
 1. X frontier_of \<Union> {} \<subseteq> \<Union> ((frontier_of) X ` {})
[PROOF STEP]
qed simp


[STATEMENT]
lemma Card_order_omax2:
assumes "finite I" and "I \<noteq> {}"
shows "Card_order (omax {|A i| | i. i \<in> I})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
let ?R = "{|A i| | i. i \<in> I}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
have "finite ?R" and "?R \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {|A i| |i. i \<in> I} &&& {|A i| |i. i \<in> I} \<noteq> {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite I
I \<noteq> {}

goal (1 subgoal):
 1. finite {|A i| |i. i \<in> I} &&& {|A i| |i. i \<in> I} \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {|A i| |i. i \<in> I}
{|A i| |i. i \<in> I} \<noteq> {}

goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {|A i| |i. i \<in> I}
{|A i| |i. i \<in> I} \<noteq> {}

goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
have "\<forall>r\<in>?R. Card_order r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>r\<in>{|A i| |i. i \<in> I}. Card_order r
[PROOF STEP]
using card_of_Card_order
[PROOF STATE]
proof (prove)
using this:
Card_order |?A|

goal (1 subgoal):
 1. \<forall>r\<in>{|A i| |i. i \<in> I}. Card_order r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>r\<in>{|A i| |i. i \<in> I}. Card_order r

goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {|A i| |i. i \<in> I}
{|A i| |i. i \<in> I} \<noteq> {}
\<forall>r\<in>{|A i| |i. i \<in> I}. Card_order r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {|A i| |i. i \<in> I}
{|A i| |i. i \<in> I} \<noteq> {}
\<forall>r\<in>{|A i| |i. i \<in> I}. Card_order r

goal (1 subgoal):
 1. Card_order (omax {|A i| |i. i \<in> I})
[PROOF STEP]
by(rule Card_order_omax)
[PROOF STATE]
proof (state)
this:
Card_order (omax {|A i| |i. i \<in> I})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lran_bwd_simp: "lran a l h = (if l<h then lran a l (h-1)@[a (h-1)] else [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lran a l h = (if l < h then lran a l (h - 1) @ [a (h - 1)] else [])
[PROOF STEP]
apply (induction a l h rule: lran.induct)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l h. (l < h \<Longrightarrow> lran a (l + 1) h = (if l + 1 < h then lran a (l + 1) (h - 1) @ [a (h - 1)] else [])) \<Longrightarrow> lran a l h = (if l < h then lran a l (h - 1) @ [a (h - 1)] else [])
[PROOF STEP]
apply (rewrite in "\<hole> = _" lran.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l h. (l < h \<Longrightarrow> lran a (l + 1) h = (if l + 1 < h then lran a (l + 1) (h - 1) @ [a (h - 1)] else [])) \<Longrightarrow> (if l < h then a l # lran a (l + 1) h else []) = (if l < h then lran a l (h - 1) @ [a (h - 1)] else [])
[PROOF STEP]
apply (rewrite in "_ = \<hole>" lran.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l h. (l < h \<Longrightarrow> lran a (l + 1) h = (if l + 1 < h then lran a (l + 1) (h - 1) @ [a (h - 1)] else [])) \<Longrightarrow> (if l < h then a l # lran a (l + 1) h else []) = (if l < h then (if l < h - 1 then a l # lran a (l + 1) (h - 1) else []) @ [a (h - 1)] else [])
[PROOF STEP]
by (auto simp: less_le)


[STATEMENT]
lemma from_nat_not_eq:
  assumes a_eq_to_nat: "a \<noteq> to_nat b"
  and a_less_card: "a<CARD('a)"
  shows "from_nat a \<noteq> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.from_nat a \<noteq> b
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<noteq> b \<Longrightarrow> False
[PROOF STEP]
assume "\<not> from_nat a \<noteq> b"
[PROOF STATE]
proof (state)
this:
\<not> mod_type_class.from_nat a \<noteq> b

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<noteq> b \<Longrightarrow> False
[PROOF STEP]
hence "from_nat a = b"
[PROOF STATE]
proof (prove)
using this:
\<not> mod_type_class.from_nat a \<noteq> b

goal (1 subgoal):
 1. mod_type_class.from_nat a = b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat a = b

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<noteq> b \<Longrightarrow> False
[PROOF STEP]
hence "to_nat ((from_nat a)::'a) = to_nat b"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.from_nat a = b

goal (1 subgoal):
 1. mod_type_class.to_nat (mod_type_class.from_nat a) = mod_type_class.to_nat b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (mod_type_class.from_nat a) = mod_type_class.to_nat b

goal (1 subgoal):
 1. \<not> mod_type_class.from_nat a \<noteq> b \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat (mod_type_class.from_nat a) = mod_type_class.to_nat b

goal (1 subgoal):
 1. False
[PROOF STEP]
by (metis a_eq_to_nat a_less_card to_nat_from_nat_id)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complex_Re_fact [simp]: "Re (fact n) = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
have "(fact n :: complex) = of_real (fact n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact n = complex_of_real (fact n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fact n = complex_of_real (fact n)

goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact n = complex_of_real (fact n)

goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
have "Re \<dots> = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (complex_of_real (fact n)) = fact n
[PROOF STEP]
by (subst Re_complex_of_real) simp_all
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (fact n)) = fact n

goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Re (fact n) = fact n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Re (fact n) = fact n

goal (1 subgoal):
 1. Re (fact n) = fact n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Re (fact n) = fact n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma weakly_reduced_imp_short_vector:
  assumes "weakly_reduced \<alpha> m"
    and in_L: "h \<in> lattice_of fs - {0\<^sub>v n}" and \<alpha>_pos:"\<alpha> \<ge> 1"
  shows "fs \<noteq> [] \<and> sq_norm (fs ! 0) \<le> \<alpha>^(m-1) * sq_norm h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
from gram_schmidt_short_vector assms
[PROOF STATE]
proof (chain)
picking this:
?h \<in> lattice_of fs - {0\<^sub>v n} \<Longrightarrow> \<exists>i<length fs. \<parallel>gso i\<parallel>\<^sup>2 \<le> \<parallel>?h\<parallel>\<^sup>2
weakly_reduced \<alpha> (length fs)
h \<in> lattice_of fs - {0\<^sub>v n}
(1::'a) \<le> \<alpha>
[PROOF STEP]
obtain i where
    i: "i < m" and le: "sq_norm (gso i) \<le> sq_norm h"
[PROOF STATE]
proof (prove)
using this:
?h \<in> lattice_of fs - {0\<^sub>v n} \<Longrightarrow> \<exists>i<length fs. \<parallel>gso i\<parallel>\<^sup>2 \<le> \<parallel>?h\<parallel>\<^sup>2
weakly_reduced \<alpha> (length fs)
h \<in> lattice_of fs - {0\<^sub>v n}
(1::'a) \<le> \<alpha>

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < length fs; \<parallel>gso i\<parallel>\<^sup>2 \<le> \<parallel>h\<parallel>\<^sup>2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < length fs
\<parallel>gso i\<parallel>\<^sup>2 \<le> \<parallel>h\<parallel>\<^sup>2

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
have small: "sq_norm (fs ! 0) \<le> \<alpha>^i * sq_norm (gso i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < length fs

goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2
[PROOF STEP]
proof (induct i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ 0 * \<parallel>gso 0\<parallel>\<^sup>2
 2. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 < length fs

goal (2 subgoals):
 1. 0 < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ 0 * \<parallel>gso 0\<parallel>\<^sup>2
 2. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ 0 * \<parallel>gso 0\<parallel>\<^sup>2
[PROOF STEP]
unfolding fs0_gso0[OF 0]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>gso 0\<parallel>\<^sup>2 \<le> \<alpha> ^ 0 * \<parallel>gso 0\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ 0 * \<parallel>gso 0\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
case (Suc i)
[PROOF STATE]
proof (state)
this:
i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2
Suc i < length fs

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
hence "sq_norm (fs ! 0) \<le> \<alpha>^i * sq_norm (gso i)"
[PROOF STATE]
proof (prove)
using this:
i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2
Suc i < length fs

goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
have "\<dots> \<le> \<alpha>^i * (\<alpha> * (sq_norm (gso (Suc i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)
[PROOF STEP]
using reduced_gso_E[OF assms(1) le_refl Suc(2)] \<alpha>_pos
[PROOF STATE]
proof (prove)
using this:
\<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2
(1::'a) \<le> \<alpha>

goal (1 subgoal):
 1. \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < length fs \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2; Suc i < length fs\<rbrakk> \<Longrightarrow> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)

goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
unfolding class_semiring.nat_pow_Suc[of \<alpha> i]
[PROOF STATE]
proof (prove)
using this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * (\<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2)

goal (1 subgoal):
 1. \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<alpha> * \<parallel>gso (Suc i)\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ Suc i * \<parallel>gso (Suc i)\<parallel>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
have "\<dots> \<le> \<alpha>^(m-1) * sq_norm h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
by (rule mult_mono[OF power_increasing le], insert i \<alpha>_pos, auto)
[PROOF STATE]
proof (state)
this:
\<alpha> ^ i * \<parallel>gso i\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
\<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
i < length fs

goal (1 subgoal):
 1. fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2
[PROOF STEP]
by (cases fs, auto)
[PROOF STATE]
proof (state)
this:
fs \<noteq> [] \<and> \<parallel>fs ! 0\<parallel>\<^sup>2 \<le> \<alpha> ^ (length fs - 1) * \<parallel>h\<parallel>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_add_offset_le:
  fixes x :: nat
  assumes yv: "y \<le> 2 ^ n"
  and     xv: "x < 2 ^ m"
  and     mn: "sz = m + n"
  shows   "x * 2 ^ n + y \<le> 2 ^ sz"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ sz
[PROOF STEP]
proof (subst mn)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
from yv
[PROOF STATE]
proof (chain)
picking this:
y \<le> 2 ^ n
[PROOF STEP]
obtain qy where "y + qy = 2 ^ n"
[PROOF STATE]
proof (prove)
using this:
y \<le> 2 ^ n

goal (1 subgoal):
 1. (\<And>qy. y + qy = 2 ^ n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: le_iff_add)
[PROOF STATE]
proof (state)
this:
y + qy = 2 ^ n

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
have "x * 2 ^ n + y \<le> x * 2 ^ n + 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * 2 ^ n + y \<le> x * 2 ^ n + 2 ^ n
[PROOF STEP]
using yv xv
[PROOF STATE]
proof (prove)
using this:
y \<le> 2 ^ n
x < 2 ^ m

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> x * 2 ^ n + 2 ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x * 2 ^ n + y \<le> x * 2 ^ n + 2 ^ n

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x * 2 ^ n + y \<le> x * 2 ^ n + 2 ^ n

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
have "\<dots> = (x + 1) * 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
have "\<dots> \<le> 2 ^ (m + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + 1) * 2 ^ n \<le> 2 ^ (m + n)
[PROOF STEP]
using xv
[PROOF STATE]
proof (prove)
using this:
x < 2 ^ m

goal (1 subgoal):
 1. (x + 1) * 2 ^ n \<le> 2 ^ (m + n)
[PROOF STEP]
by (subst power_add) (rule mult_le_mono1, simp)
[PROOF STATE]
proof (state)
this:
(x + 1) * 2 ^ n \<le> 2 ^ (m + n)

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
show "x * 2 ^ n + y \<le> 2 ^ (m + n)"
[PROOF STATE]
proof (prove)
using this:
x * 2 ^ n + y \<le> 2 ^ (m + n)

goal (1 subgoal):
 1. x * 2 ^ n + y \<le> 2 ^ (m + n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x * 2 ^ n + y \<le> 2 ^ (m + n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma odd_prime_gt_2_nat:
 "2 < p" if "odd p" "prime p" for p :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < p
[PROOF STEP]
using prime_ge_2_nat[OF \<open>prime p\<close>] \<open>odd p\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<le> p
odd p

goal (1 subgoal):
 1. 2 < p
[PROOF STEP]
by (cases "p = 2") auto


[STATEMENT]
lemma tendsto_mult_right: "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. (f x) * c) \<longlongrightarrow> l * c) F"
  for c :: "'a::topological_semigroup_mult"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. f x * c) \<longlongrightarrow> l * c) F
[PROOF STEP]
by (rule tendsto_mult [OF _ tendsto_const])


[STATEMENT]
lemma irreflexive_star:
  "(x \<sqinter> -1)\<^sup>\<star> = x\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
have 1: "x \<sqinter> 1 \<le> (x \<sqinter> -1)\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqinter> (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>
[PROOF STEP]
by (simp add: le_infI2 star.circ_reflexive)
[PROOF STATE]
proof (state)
this:
x \<sqinter> (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
have "x \<sqinter> -1 \<le> (x \<sqinter> -1)\<^sup>\<star>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqinter> - (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>
[PROOF STEP]
by (simp add: star.circ_increasing)
[PROOF STATE]
proof (state)
this:
x \<sqinter> - (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
hence "x \<le> (x \<sqinter> -1)\<^sup>\<star>"
[PROOF STATE]
proof (prove)
using this:
x \<sqinter> - (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. x \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
x \<sqinter> - (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>
x \<sqinter> (1::'a) \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. x \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>
[PROOF STEP]
by (smt maddux_3_11_pp regular_one_closed sup.absorb_iff1 sup_assoc)
[PROOF STATE]
proof (state)
this:
x \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<le> (x \<sqinter> - (1::'a))\<^sup>\<star>

goal (1 subgoal):
 1. (x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>
[PROOF STEP]
by (metis order.antisym inf.cobounded1 star_involutive star_isotone)
[PROOF STATE]
proof (state)
this:
(x \<sqinter> - (1::'a))\<^sup>\<star> = x\<^sup>\<star>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma aff_dim_basis_exists:
  fixes V :: "('n::euclidean_space) set"
  shows "\<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1
[PROOF STEP]
obtain B where "\<not> affine_dependent B \<and> affine hull B = affine hull V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. \<not> affine_dependent B \<and> affine hull B = affine hull V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using affine_basis_exists[of V]
[PROOF STATE]
proof (prove)
using this:
\<exists>B\<subseteq>V. \<not> affine_dependent B \<and> affine hull V = affine hull B

goal (1 subgoal):
 1. (\<And>B. \<not> affine_dependent B \<and> affine hull B = affine hull V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> affine_dependent B \<and> affine hull B = affine hull V

goal (1 subgoal):
 1. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> affine_dependent B \<and> affine hull B = affine hull V
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent B \<and> affine hull B = affine hull V

goal (1 subgoal):
 1. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1
[PROOF STEP]
unfolding aff_dim_def
      some_eq_ex[of "\<lambda>d. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1"]
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent B \<and> affine hull B = affine hull V

goal (1 subgoal):
 1. \<exists>d B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = d + 1
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<not> affine_dependent B; affine hull B = affine hull V\<rbrakk> \<Longrightarrow> \<exists>d B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = d + 1
[PROOF STEP]
apply (rule exI[of _ "int (card B) - (1 :: int)"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<not> affine_dependent B; affine hull B = affine hull V\<rbrakk> \<Longrightarrow> \<exists>Ba. affine hull Ba = affine hull V \<and> \<not> affine_dependent Ba \<and> int (card Ba) = int (card B) - 1 + 1
[PROOF STEP]
apply (rule exI[of _ "B"], auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_union_of_singletons :
  assumes "\<forall> S \<in> SS . (\<exists> t . S = {t})"
shows "card (\<Union> SS) = card SS"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
let ?f = "\<lambda> x . {x}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
have "bij_betw ?f (\<Union> SS) SS"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (\<lambda>x. {x}) (\<Union> SS) SS
[PROOF STEP]
unfolding bij_betw_def inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>\<Union> SS. \<forall>y\<in>\<Union> SS. {x} = {y} \<longrightarrow> x = y) \<and> (\<lambda>x. {x}) ` \<Union> SS = SS
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>S\<in>SS. \<exists>t. S = {t}

goal (1 subgoal):
 1. (\<forall>x\<in>\<Union> SS. \<forall>y\<in>\<Union> SS. {x} = {y} \<longrightarrow> x = y) \<and> (\<lambda>x. {x}) ` \<Union> SS = SS
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
bij_betw (\<lambda>x. {x}) (\<Union> SS) SS

goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bij_betw (\<lambda>x. {x}) (\<Union> SS) SS
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bij_betw (\<lambda>x. {x}) (\<Union> SS) SS

goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
using bij_betw_same_card
[PROOF STATE]
proof (prove)
using this:
bij_betw (\<lambda>x. {x}) (\<Union> SS) SS
bij_betw ?f ?A ?B \<Longrightarrow> card ?A = card ?B

goal (1 subgoal):
 1. card (\<Union> SS) = card SS
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (\<Union> SS) = card SS

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma index_add_vec[simp]:
  "i < dim_vec v\<^sub>2 \<Longrightarrow> (v\<^sub>1 + v\<^sub>2) $ i = v\<^sub>1 $ i + v\<^sub>2 $ i" "dim_vec (v\<^sub>1 + v\<^sub>2) = dim_vec v\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i < dim_vec v\<^sub>2 \<Longrightarrow> (v\<^sub>1 + v\<^sub>2) $ i = v\<^sub>1 $ i + v\<^sub>2 $ i) &&& dim_vec (v\<^sub>1 + v\<^sub>2) = dim_vec v\<^sub>2
[PROOF STEP]
unfolding plus_vec_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i < dim_vec v\<^sub>2 \<Longrightarrow> vec (dim_vec v\<^sub>2) (\<lambda>i. v\<^sub>1 $ i + v\<^sub>2 $ i) $ i = v\<^sub>1 $ i + v\<^sub>2 $ i) &&& dim_vec (vec (dim_vec v\<^sub>2) (\<lambda>i. v\<^sub>1 $ i + v\<^sub>2 $ i)) = dim_vec v\<^sub>2
[PROOF STEP]
by auto


[STATEMENT]
lemma nths_reencode_eq3:
  fixes A B C :: "nat set"
  assumes "C \<subseteq> B" "B \<subseteq> A"
  shows "nths (nths xs (ind_in_set A ` B)) (ind_in_set B ` C) = nths xs (ind_in_set A ` C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (nths xs (ind_in_set A ` B)) (ind_in_set B ` C) = nths xs (ind_in_set A ` C)
[PROOF STEP]
apply (subst ind_in_set_assoc[OF assms, symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths (nths xs (ind_in_set A ` B)) (ind_in_set (ind_in_set A ` B) ` ind_in_set A ` C) = nths xs (ind_in_set A ` C)
[PROOF STEP]
apply (rule nths_reencode_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ind_in_set A ` C \<subseteq> ind_in_set A ` B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
C \<subseteq> B
B \<subseteq> A

goal (1 subgoal):
 1. ind_in_set A ` C \<subseteq> ind_in_set A ` B
[PROOF STEP]
by blast


[STATEMENT]
lemma closed_vimage_vec_nth: "closed S \<Longrightarrow> closed ((\<lambda>x. x $ i) -` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed S \<Longrightarrow> closed ((\<lambda>x. x $ i) -` S)
[PROOF STEP]
unfolding closed_open vimage_Compl [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open (- S) \<Longrightarrow> open ((\<lambda>x. x $ i) -` (- S))
[PROOF STEP]
by (rule open_vimage_vec_nth)


[STATEMENT]
theorem existence:
  assumes "n > 0"
  assumes "Factorial_Ring.prime p"
  shows "\<exists>(F:: int set list set ring). finite_field F \<and> order F = p^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
interpret zf: finite_field "ZFact (int p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_field (ZFact (int p))
[PROOF STEP]
using zfact_prime_is_finite_field assms
[PROOF STATE]
proof (prove)
using this:
normalization_semidom_class.prime ?p \<Longrightarrow> finite_field (ZFact (int ?p))
0 < n
normalization_semidom_class.prime p

goal (1 subgoal):
 1. finite_field (ZFact (int p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
interpret zfp: polynomial_ring "ZFact p" "carrier (ZFact p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_ring (ZFact (int p)) (carrier (ZFact (int p)))
[PROOF STEP]
unfolding polynomial_ring_def polynomial_ring_axioms_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. field (ZFact (int p)) \<and> subfield (carrier (ZFact (int p))) (ZFact (int p))
[PROOF STEP]
using zf.field_axioms zf.carrier_is_subfield
[PROOF STATE]
proof (prove)
using this:
field (ZFact (int p))
subfield (carrier (ZFact (int p))) (ZFact (int p))

goal (1 subgoal):
 1. field (ZFact (int p)) \<and> subfield (carrier (ZFact (int p))) (ZFact (int p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
have p_gt_0: "p > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p
[PROOF STEP]
using prime_gt_0_nat assms(2)
[PROOF STATE]
proof (prove)
using this:
normalization_semidom_class.prime ?p \<Longrightarrow> 0 < ?p
normalization_semidom_class.prime p

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

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
obtain f where f_def:
    "monic_irreducible_poly (ZFact (int p)) f"
    "degree f = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>m_i_p (ZFact (int p)) f; Polynomials.degree f = n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using zf.exist_irred assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?n; \<And>f. \<lbrakk>m_i_p (ZFact (int p)) f; Polynomials.degree f = ?n\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
0 < n
normalization_semidom_class.prime p

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>m_i_p (ZFact (int p)) f; Polynomials.degree f = n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m_i_p (ZFact (int p)) f
Polynomials.degree f = n

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
let ?F  = "Rupt\<^bsub>(ZFact p)\<^esub> (carrier (ZFact p)) f"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
have "f \<in> carrier (poly_ring (ZFact (int p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> carrier zfp.P
[PROOF STEP]
using f_def(1) zf.monic_poly_carr
[PROOF STATE]
proof (prove)
using this:
m_i_p (ZFact (int p)) f
monic_poly (ZFact (int p)) ?f \<Longrightarrow> ?f \<in> carrier zfp.P

goal (1 subgoal):
 1. f \<in> carrier zfp.P
[PROOF STEP]
unfolding monic_irreducible_poly_def
[PROOF STATE]
proof (prove)
using this:
monic_poly (ZFact (int p)) f \<and> pirreducible\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f
monic_poly (ZFact (int p)) ?f \<Longrightarrow> ?f \<in> carrier zfp.P

goal (1 subgoal):
 1. f \<in> carrier zfp.P
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f \<in> carrier zfp.P

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f \<in> carrier zfp.P

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
have "degree f > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < Polynomials.degree f
[PROOF STEP]
using assms(1) f_def
[PROOF STATE]
proof (prove)
using this:
0 < n
m_i_p (ZFact (int p)) f
Polynomials.degree f = n

goal (1 subgoal):
 1. 0 < Polynomials.degree f
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < Polynomials.degree f

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f \<in> carrier zfp.P
0 < Polynomials.degree f
[PROOF STEP]
have "order ?F =  card (carrier (ZFact p))^degree f"
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier zfp.P
0 < Polynomials.degree f

goal (1 subgoal):
 1. order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = card (carrier (ZFact (int p))) ^ Polynomials.degree f
[PROOF STEP]
by (intro zf.rupture_order[OF zf.carrier_is_subfield]) auto
[PROOF STATE]
proof (state)
this:
order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = card (carrier (ZFact (int p))) ^ Polynomials.degree f

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
hence a:"order ?F = p^n"
[PROOF STATE]
proof (prove)
using this:
order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = card (carrier (ZFact (int p))) ^ Polynomials.degree f

goal (1 subgoal):
 1. order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = p ^ n
[PROOF STEP]
unfolding f_def(2) card_zfact_carr[OF p_gt_0]
[PROOF STATE]
proof (prove)
using this:
order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = p ^ n

goal (1 subgoal):
 1. order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = p ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = p ^ n

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
have "field ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
using f_def(1) zf.monic_poly_carr monic_irreducible_poly_def
[PROOF STATE]
proof (prove)
using this:
m_i_p (ZFact (int p)) f
monic_poly (ZFact (int p)) ?f \<Longrightarrow> ?f \<in> carrier zfp.P
m_i_p ?R ?f = (monic_poly ?R ?f \<and> pirreducible\<^bsub>?R\<^esub> (carrier ?R) ?f)

goal (1 subgoal):
 1. field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
by (subst zfp.rupture_is_field_iff_pirreducible) auto
[PROOF STATE]
proof (state)
this:
field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
have "order ?F > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
unfolding a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p ^ n
[PROOF STEP]
using assms(1,2) p_gt_0
[PROOF STATE]
proof (prove)
using this:
0 < n
normalization_semidom_class.prime p
0 < p

goal (1 subgoal):
 1. 0 < p ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
0 < order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
have b:"finite_field ?F"
[PROOF STATE]
proof (prove)
using this:
field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
0 < order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. finite_field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
using card_ge_0_finite
[PROOF STATE]
proof (prove)
using this:
field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
0 < order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
0 < card ?A \<Longrightarrow> finite ?A

goal (1 subgoal):
 1. finite_field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)
[PROOF STEP]
by (intro finite_fieldI, auto simp add:Coset.order_def)
[PROOF STATE]
proof (state)
this:
finite_field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
using a b
[PROOF STATE]
proof (prove)
using this:
order (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f) = p ^ n
finite_field (Rupt\<^bsub>ZFact (int p)\<^esub> (carrier (ZFact (int p))) f)

goal (1 subgoal):
 1. \<exists>F. finite_field F \<and> order F = p ^ n
[PROOF STEP]
by (intro exI[where x="?F"], simp)
[PROOF STATE]
proof (state)
this:
\<exists>F. finite_field F \<and> order F = p ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prefix_pairs_set_alt :
  "set (prefix_pairs xs) = {(xs1,xs1@xs2) | xs1 xs2 . xs2 \<noteq> [] \<and> (\<exists> xs3 . xs1@xs2@xs3 = xs)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (prefix_pairs xs) = {(xs1, xs1 @ xs2) |xs1 xs2. xs2 \<noteq> [] \<and> (\<exists>xs3. xs1 @ xs2 @ xs3 = xs)}
[PROOF STEP]
unfolding prefix_pairs_set
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(zs, ys) |zs ys. \<exists>xs1 xs2. zs @ xs1 = ys \<and> ys @ xs2 = xs \<and> xs1 \<noteq> []} = {(xs1, xs1 @ xs2) |xs1 xs2. xs2 \<noteq> [] \<and> (\<exists>xs3. xs1 @ xs2 @ xs3 = xs)}
[PROOF STEP]
by auto


[STATEMENT]
lemma degree_mult:
  fixes p q::"'a::{comm_semiring_0, ring_1_no_zero_divisors} mpoly"
  assumes "p \<noteq> 0"
  assumes "q \<noteq> 0"
  shows "MPoly_Type.degree (p * q) v = MPoly_Type.degree p v + MPoly_Type.degree q v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MPoly_Type.degree (p * q) v = MPoly_Type.degree p v + MPoly_Type.degree q v
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
q \<noteq> 0

goal (1 subgoal):
 1. MPoly_Type.degree (p * q) v = MPoly_Type.degree p v + MPoly_Type.degree q v
[PROOF STEP]
by (auto simp add: degree_eq_univariate_degree mpoly_to_nested_poly_mult Polynomial.degree_mult_eq)


[STATEMENT]
lemma plus_assoc:
assumes dimsA:"dims A = ds" and dimsB:"dims B = ds" and dimsC:"dims C = ds"
shows "(A + B) + C = A + (B + C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A + B + C = A + (B + C)
[PROOF STEP]
by (rule tensor_lookup_eqI; simp add: dimsA dimsB dimsC add.assoc)+


[STATEMENT]
lemma pmf_of_set_split_inter_diff:
  assumes "finite A" "finite B" "A \<noteq> {}" "B \<noteq> {}"
  assumes "p = card (A \<inter> B) / card B"
  shows   "do {b \<leftarrow> bernoulli_pmf p; if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)} =
             pmf_of_set B" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
have eq: "B = (A \<inter> B) \<union> (B - A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B = A \<inter> B \<union> (B - A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B = A \<inter> B \<union> (B - A)

goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
have card_eq: "card B = card (A \<inter> B) + card (B - A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card B = card (A \<inter> B) + card (B - A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
A \<noteq> {}
B \<noteq> {}
p = real (card (A \<inter> B)) / real (card B)

goal (1 subgoal):
 1. card B = card (A \<inter> B) + card (B - A)
[PROOF STEP]
by (subst eq, subst card_Un_disjoint) auto
[PROOF STATE]
proof (state)
this:
card B = card (A \<inter> B) + card (B - A)

goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
have "?lhs = pmf_of_set ((A \<inter> B) \<union> (B - A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set (A \<inter> B \<union> (B - A))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
A \<noteq> {}
B \<noteq> {}
p = real (card (A \<inter> B)) / real (card B)

goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set (A \<inter> B \<union> (B - A))
[PROOF STEP]
by (intro pmf_of_set_union_split) (auto simp: card_eq)
[PROOF STATE]
proof (state)
this:
bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set (A \<inter> B \<union> (B - A))

goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
with eq
[PROOF STATE]
proof (chain)
picking this:
B = A \<inter> B \<union> (B - A)
bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set (A \<inter> B \<union> (B - A))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
B = A \<inter> B \<union> (B - A)
bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set (A \<inter> B \<union> (B - A))

goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bernoulli_pmf p \<bind> (\<lambda>b. if b then pmf_of_set (A \<inter> B) else pmf_of_set (B - A)) = pmf_of_set B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ccFromList_append[simp]: "ccFromList (xs@ys) = ccFromList xs \<squnion> ccFromList ys \<squnion> ccProd (set xs) (set ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccFromList (xs @ ys) = ccFromList xs \<squnion> ccFromList ys \<squnion> set xs G\<times> set ys
[PROOF STEP]
by (induction xs) (auto simp add: ccProd_insert1[where S' = "set xs" for xs])


[STATEMENT]
lemma integral_eq_zero_null_sets:
  assumes "S \<in> null_sets lebesgue"
  shows "integral\<^sup>L (lebesgue_on S) f = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on S) f = (0::'b)
[PROOF STEP]
proof (rule integral_eq_zero_AE)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. AE x in lebesgue_on S. f x = (0::'b)
[PROOF STEP]
show "AE x in lebesgue_on S. f x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in lebesgue_on S. f x = (0::'b)
[PROOF STEP]
by (metis (no_types, lifting) assms AE_not_in lebesgue_on_mono null_setsD2 null_sets_restrict_space order_refl)
[PROOF STATE]
proof (state)
this:
AE x in lebesgue_on S. f x = (0::'b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma unit_ball_vol_even:
  "unit_ball_vol (real (2 * n)) = pi ^ n / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_ball_vol (real (2 * n)) = pi ^ n / fact n
[PROOF STEP]
by (simp add: unit_ball_vol_def add_ac powr_realpow Gamma_fact)