[STATEMENT]
lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + inf b c = inf (a + b) (a + c)
[PROOF STEP]
apply (rule order.antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. a + inf b c \<le> inf (a + b) (a + c)
 2. inf (a + b) (a + c) \<le> a + inf b c
[PROOF STEP]
apply (simp_all add: le_infI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inf (a + b) (a + c) \<le> a + inf b c
[PROOF STEP]
apply (rule add_le_imp_le_left [of "uminus a"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - a + inf (a + b) (a + c) \<le> - a + (a + inf b c)
[PROOF STEP]
apply (simp only: add.assoc [symmetric], simp add: diff_le_eq add.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma absolutely_integrable_min:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  assumes "f absolutely_integrable_on S" "g absolutely_integrable_on S"
   shows "(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i)
            absolutely_integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
have "(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) =
        (\<lambda>x. (1/2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))
[PROOF STEP]
proof (rule ext)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
have "(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i)
[PROOF STEP]
by (force intro: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i)

goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i)

goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
have "... = (1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i) = (1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i)
[PROOF STEP]
by (simp add: scaleR_right.sum)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i) = (1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i)

goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>Basis. ((f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) / 2) *\<^sub>R i) = (1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i)

goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
have "... = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
by (simp add: sum.distrib sum_subtractf algebra_simps euclidean_representation)
[PROOF STATE]
proof (state)
this:
(1 / 2) *\<^sub>R (\<Sum>i\<in>Basis. (f x \<bullet> i + g x \<bullet> i - \<bar>f x \<bullet> i - g x \<bullet> i\<bar>) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))

goal (1 subgoal):
 1. \<And>x. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
show "(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) =
         (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))

goal (1 subgoal):
 1. (\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
have "(\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))
                 absolutely_integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))) absolutely_integrable_on S
[PROOF STEP]
using absolutely_integrable_abs [OF set_integral_diff(1) [OF assms]]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. \<Sum>i\<in>Basis. \<bar>(f x - g x) \<bullet> i\<bar> *\<^sub>R i) absolutely_integrable_on S

goal (1 subgoal):
 1. (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))) absolutely_integrable_on S
[PROOF STEP]
by (intro set_integral_add set_integral_diff absolutely_integrable_scaleR_left assms)
       (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))) absolutely_integrable_on S

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))
(\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))) absolutely_integrable_on S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) = (\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i)))
(\<lambda>x. (1 / 2) *\<^sub>R (f x + g x - (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i - g x \<bullet> i\<bar> *\<^sub>R i))) absolutely_integrable_on S

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>i\<in>Basis. min (f x \<bullet> i) (g x \<bullet> i) *\<^sub>R i) absolutely_integrable_on S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in vectorspace) sum_map_linear:
  fixes V1 V2
  assumes h1: "subspace K V1 V" and h2: "subspace K V2 V"
  shows "linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda> v. (fst v) \<oplus>\<^bsub>V\<^esub> (snd v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
[PROOF STEP]
from h1 h2
[PROOF STATE]
proof (chain)
picking this:
subspace K V1 V
subspace K V2 V
[PROOF STEP]
have mod: "mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda> v. (fst v) \<oplus>\<^bsub>V\<^esub> (snd v))"
[PROOF STATE]
proof (prove)
using this:
subspace K V1 V
subspace K V2 V

goal (1 subgoal):
 1. mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
[PROOF STEP]
by ( intro sum_map_hom, unfold subspace_def, auto)
[PROOF STATE]
proof (state)
this:
mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)

goal (1 subgoal):
 1. linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
[PROOF STEP]
from mod h1 h2
[PROOF STATE]
proof (chain)
picking this:
mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
subspace K V1 V
subspace K V2 V
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
subspace K V1 V
subspace K V2 V

goal (1 subgoal):
 1. linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)
[PROOF STEP]
apply (unfold linear_map_def, auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v); subspace K V1 V; subspace K V2 V\<rbrakk> \<Longrightarrow> vectorspace K (direct_sum (vs V1) (vs V2))
 2. \<lbrakk>mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v); subspace K V1 V; subspace K V2 V\<rbrakk> \<Longrightarrow> vectorspace K V
[PROOF STEP]
apply (intro direct_sum_is_vs subspace_is_vs, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>mod_hom K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v); subspace K V1 V; subspace K V2 V\<rbrakk> \<Longrightarrow> vectorspace K V
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
linear_map K (direct_sum (vs V1) (vs V2)) V (\<lambda>v. fst v \<oplus>\<^bsub>V\<^esub> snd v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ker_to_rimg:"\<lbrakk>Ring A; Ring R; f \<in> rHom A R \<rbrakk> \<Longrightarrow>
                         ker\<^bsub>A,R\<^esub> f = ker\<^bsub>A,(rimg A R f)\<^esub> f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ring A; Ring R; f \<in> rHom A R\<rbrakk> \<Longrightarrow> ker\<^bsub>A,R\<^esub> f = ker\<^bsub>A,rimg A R f\<^esub> f
[PROOF STEP]
apply (frule rhom_to_rimg [of "A" "R" "f"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ring A; Ring R; f \<in> rHom A R; f \<in> rHom A (rimg A R f)\<rbrakk> \<Longrightarrow> ker\<^bsub>A,R\<^esub> f = ker\<^bsub>A,rimg A R f\<^esub> f
[PROOF STEP]
apply (simp add:ker_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ring A; Ring R; f \<in> rHom A R; f \<in> rHom A (rimg A R f)\<rbrakk> \<Longrightarrow> {a \<in> carrier A. f a = \<zero>\<^bsub>R\<^esub>} = {a \<in> carrier A. f a = \<zero>\<^bsub>rimg A R f\<^esub>}
[PROOF STEP]
apply (simp add:rimg_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma list_all2_iff:
  "list_all2 P xs ys \<longleftrightarrow> length xs = length ys \<and> (\<forall>(x, y) \<in> set (zip xs ys). P x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_all2 P xs ys = (length xs = length ys \<and> (\<forall>(x, y)\<in>set (zip xs ys). P x y))
[PROOF STEP]
by (induct xs ys rule: list_induct2') auto


[STATEMENT]
lemma imirror_cut_greater: "\<lbrakk> finite I; t \<le> iMin I + Max I \<rbrakk> \<Longrightarrow>
  imirror I \<down>> (mirror_elem t I) =
  imirror_bounds (I \<down>< t) (iMin I) (Max I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (case_tac "t = 0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I; t = 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
 2. \<lbrakk>finite I; t \<le> iMin I + Max I; t \<noteq> 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (simp add: cut_less_0_empty imirror_bounds_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; t = 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem 0 I = {}
 2. \<lbrakk>finite I; t \<le> iMin I + Max I; t \<noteq> 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (rule cut_greater_Max_empty)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>finite I; t = 0\<rbrakk> \<Longrightarrow> finite (imirror I)
 2. \<lbrakk>finite I; t = 0\<rbrakk> \<Longrightarrow> Max (imirror I) \<le> mirror_elem 0 I
 3. \<lbrakk>finite I; t \<le> iMin I + Max I; t \<noteq> 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (rule imirror_finite, assumption)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; t = 0\<rbrakk> \<Longrightarrow> Max (imirror I) \<le> mirror_elem 0 I
 2. \<lbrakk>finite I; t \<le> iMin I + Max I; t \<noteq> 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (simp add: imirror_Max mirror_elem_def nat_mirror_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I; t \<noteq> 0\<rbrakk> \<Longrightarrow> imirror I \<down>> mirror_elem t I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (simp add: nat_cut_ge_greater_conv[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I; 0 < t\<rbrakk> \<Longrightarrow> imirror I \<down>\<ge> Suc (mirror_elem t I) = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (rule subst[of "mirror_elem (t - Suc 0) I" "Suc (mirror_elem t I)"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I; 0 < t\<rbrakk> \<Longrightarrow> mirror_elem (t - Suc 0) I = Suc (mirror_elem t I)
 2. \<lbrakk>finite I; t \<le> iMin I + Max I; 0 < t\<rbrakk> \<Longrightarrow> imirror I \<down>\<ge> mirror_elem (t - Suc 0) I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (simp add: mirror_elem_def nat_mirror_diff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; t \<le> iMin I + Max I; 0 < t\<rbrakk> \<Longrightarrow> imirror I \<down>\<ge> mirror_elem (t - Suc 0) I = imirror_bounds (I \<down>< t) (iMin I) (Max I)
[PROOF STEP]
apply (simp add: imirror_cut_ge nat_cut_less_le_conv)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma bernoulli_odd_numeral_eq_0 [simp]: "bernoulli (numeral (Num.Bit1 n)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli (numeral (num.Bit1 n)) = 0
[PROOF STEP]
by (rule bernoulli_odd_eq_0[OF _ odd_numeral]) auto


[STATEMENT]
lemma add_zero_example : "((Var 0)^2 - (Const 1)) + Const 0 = ((Var 0)^2 - (Const 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Var 0)\<^sup>2 - Const (1::'a) + Const (0::'a) = (Var 0)\<^sup>2 - Const (1::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (Var 0)\<^sup>2 - Const (1::'a) + Const (0::'a) = (Var 0)\<^sup>2 - Const (1::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Var 0)\<^sup>2 - Const (1::'a) + Const (0::'a) = (Var 0)\<^sup>2 - Const (1::'a)
[PROOF STEP]
by (simp add : add_zero)
[PROOF STATE]
proof (state)
this:
(Var 0)\<^sup>2 - Const (1::'a) + Const (0::'a) = (Var 0)\<^sup>2 - Const (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nth_le_takeWhile_ord: "\<lbrakk> sorted xs; i \<ge> length (takeWhile (\<lambda> x. x \<le> n) xs); i < length xs \<rbrakk> \<Longrightarrow> n \<le> xs ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sorted xs; length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i
[PROOF STEP]
apply (induct xs arbitrary: i, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs i. \<lbrakk>\<And>i. \<lbrakk>length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i; length (if a \<le> n then a # takeWhile (\<lambda>x. x \<le> n) xs else []) \<le> i; i < Suc (length xs); \<forall>x\<in>set xs. a \<le> x; sorted xs\<rbrakk> \<Longrightarrow> n \<le> (a # xs) ! i
[PROOF STEP]
apply (rename_tac x xs i)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs i. \<lbrakk>\<And>i. \<lbrakk>length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i; length (if x \<le> n then x # takeWhile (\<lambda>x. x \<le> n) xs else []) \<le> i; i < Suc (length xs); \<forall>xa\<in>set xs. x \<le> xa; sorted xs\<rbrakk> \<Longrightarrow> n \<le> (x # xs) ! i
[PROOF STEP]
apply (case_tac "x \<le> n")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x xs i. \<lbrakk>\<And>i. \<lbrakk>length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i; length (if x \<le> n then x # takeWhile (\<lambda>x. x \<le> n) xs else []) \<le> i; i < Suc (length xs); \<forall>xa\<in>set xs. x \<le> xa; sorted xs; x \<le> n\<rbrakk> \<Longrightarrow> n \<le> (x # xs) ! i
 2. \<And>x xs i. \<lbrakk>\<And>i. \<lbrakk>length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i; length (if x \<le> n then x # takeWhile (\<lambda>x. x \<le> n) xs else []) \<le> i; i < Suc (length xs); \<forall>xa\<in>set xs. x \<le> xa; sorted xs; \<not> x \<le> n\<rbrakk> \<Longrightarrow> n \<le> (x # xs) ! i
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs i. \<lbrakk>\<And>i. \<lbrakk>length (takeWhile (\<lambda>x. x \<le> n) xs) \<le> i; i < length xs\<rbrakk> \<Longrightarrow> n \<le> xs ! i; i < Suc (length xs); \<forall>xa\<in>set xs. x \<le> xa; sorted xs; \<not> x \<le> n\<rbrakk> \<Longrightarrow> n \<le> (x # xs) ! i
[PROOF STEP]
apply (metis One_nat_def Suc_eq_plus1 le_less_linear le_less_trans less_imp_le list.size(4) nth_mem set_ConsD)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma real_in_int_intervals:
  assumes xb: "real_of_int m \<le> x \<and> x < real_of_int ((n::int) + 1)"
  shows "\<exists> j\<in> {m.. n}. real_of_int j \<le> x \<and> x < real_of_int (j+1)" (is "\<exists> j\<in> ?N. ?P j")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j\<in>{m..n}. real_of_int j \<le> x \<and> x < real_of_int (j + 1)
[PROOF STEP]
by (rule bexI[where P="?P" and x="\<lfloor>x\<rfloor>" and A="?N"])
(auto simp add: floor_less_iff[where x="x" and z="n+1", simplified]
  xb[simplified] floor_mono[where x="real_of_int m" and y="x", OF conjunct1[OF xb], simplified floor_of_int[where z="m"]])


[STATEMENT]
theorem equivalence_of_partition:
  "Equivalence = E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Equivalence = E
[PROOF STEP]
unfolding Equivalence_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(a, b). \<exists>A\<in>Partition. a \<in> A \<and> b \<in> A} = E
[PROOF STEP]
unfolding Partition_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(a, b). \<exists>A\<in>Class ` S. a \<in> A \<and> b \<in> A} = E
[PROOF STEP]
by auto (metis ClassD Class_closed Class_eq)


[STATEMENT]
lemma sparse_row_vector_map: "(\<forall>x y. f (x+y) = (f x) + (f y)) \<Longrightarrow> (f::'a\<Rightarrow>('a::lattice_ring)) 0 = 0 \<Longrightarrow>
  sparse_row_vector (map (% x. (fst x, f (snd x))) a) = apply_matrix f (sparse_row_vector a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x y. f (x + y) = f x + f y; f (0::'a) = (0::'a)\<rbrakk> \<Longrightarrow> sparse_row_vector (map (\<lambda>x. (fst x, f (snd x))) a) = apply_matrix f (sparse_row_vector a)
[PROOF STEP]
apply (induct a)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>x y. f (x + y) = f x + f y; f (0::'a) = (0::'a)\<rbrakk> \<Longrightarrow> sparse_row_vector (map (\<lambda>x. (fst x, f (snd x))) []) = apply_matrix f (sparse_row_vector [])
 2. \<And>a1 a2. \<lbrakk>\<lbrakk>\<forall>x y. f (x + y) = f x + f y; f (0::'a) = (0::'a)\<rbrakk> \<Longrightarrow> sparse_row_vector (map (\<lambda>x. (fst x, f (snd x))) a2) = apply_matrix f (sparse_row_vector a2); \<forall>x y. f (x + y) = f x + f y; f (0::'a) = (0::'a)\<rbrakk> \<Longrightarrow> sparse_row_vector (map (\<lambda>x. (fst x, f (snd x))) (a1 # a2)) = apply_matrix f (sparse_row_vector (a1 # a2))
[PROOF STEP]
apply (simp_all add: apply_matrix_add)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma irreducible\<^sub>d_dvd_eq:
  fixes a b :: "'a::{comm_semiring_1,semiring_no_zero_divisors} poly"
  assumes "irreducible\<^sub>d a" and "irreducible\<^sub>d b"
    and "a dvd b"
    and "monic a" and "monic b"
  shows "a = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
irreducible\<^sub>d a
irreducible\<^sub>d b
a dvd b
monic a
monic b

goal (1 subgoal):
 1. a = b
[PROOF STEP]
by (metis (no_types, lifting) coeff_smult degree_smult_eq irreducible\<^sub>dD(1) irreducible\<^sub>d_dvd_smult
    mult.right_neutral smult_1_left)


[STATEMENT]
lemma transpose_one[simp]: "transpose 1 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Square_Matrix.transpose 1 = 1
[PROOF STEP]
by transfer (simp add: fun_eq_iff)


[STATEMENT]
lemma finprod_cong:
  "\<lbrakk>A = B; f \<in> B \<rightarrow> carrier G = True;
      \<And>i. i \<in> B =simp=> f i = g i\<rbrakk> \<Longrightarrow> finprod G f A = finprod G g B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A = B; (f \<in> B \<rightarrow> carrier G) = True; \<And>i. i \<in> B =simp=> f i = g i\<rbrakk> \<Longrightarrow> finprod G f A = finprod G g B
[PROOF STEP]
by (rule finprod_cong') (auto simp add: simp_implies_def)


[STATEMENT]
lemma path_component_trans:
  assumes "path_component S x y" and "path_component S y z"
  shows "path_component S x z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_component S x z
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
path_component S x y
path_component S y z

goal (1 subgoal):
 1. path_component S x z
[PROOF STEP]
unfolding path_component_def
[PROOF STATE]
proof (prove)
using this:
\<exists>g. path g \<and> path_image g \<subseteq> S \<and> pathstart g = x \<and> pathfinish g = y
\<exists>g. path g \<and> path_image g \<subseteq> S \<and> pathstart g = y \<and> pathfinish g = z

goal (1 subgoal):
 1. \<exists>g. path g \<and> path_image g \<subseteq> S \<and> pathstart g = x \<and> pathfinish g = z
[PROOF STEP]
by (metis path_join pathfinish_join pathstart_join subset_path_image_join)


[STATEMENT]
lemma mult_cancel_right:
  assumes "f2 \<in> \<Theta>[F](g2)" and "eventually (\<lambda>x. g2 x \<noteq> 0) F"
  shows   "(\<lambda>x. f1 x * f2 x) \<in> L F (\<lambda>x. g1 x * g2 x) \<longleftrightarrow> f1 \<in> L F (g1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f1 x * f2 x) \<in> L F (\<lambda>x. g1 x * g2 x)) = (f1 \<in> L F g1)
[PROOF STEP]
by (subst (1 2) mult.commute) (rule mult_cancel_left[OF assms])


[STATEMENT]
lemma det_code[simp]: assumes sel_fun: "det_selection_fun sel_fun"
  and mf: "mute_fun mf"
  shows "det_code A = det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.det_code A = det A
[PROOF STEP]
using det_code_def[simp]
[PROOF STATE]
proof (prove)
using this:
local.det_code ?A = (if dim_row ?A = dim_col ?A then case local.triangulize ?A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a))

goal (1 subgoal):
 1. local.det_code A = det A
[PROOF STEP]
proof (cases "dim_row A = dim_col A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
dim_row A = dim_col A

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
dim_row A = dim_col A
[PROOF STEP]
have A: "A \<in> carrier_mat (dim_row A) (dim_row A)"
[PROOF STATE]
proof (prove)
using this:
dim_row A = dim_col A

goal (1 subgoal):
 1. A \<in> carrier_mat (dim_row A) (dim_row A)
[PROOF STEP]
unfolding carrier_mat_def
[PROOF STATE]
proof (prove)
using this:
dim_row A = dim_col A

goal (1 subgoal):
 1. A \<in> {m. dim_row m = dim_row A \<and> dim_col m = dim_row A}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat (dim_row A) (dim_row A)

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
obtain r' A' where rA': "triangulize A = (r',A')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>r' A'. local.triangulize A = (r', A') \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
local.triangulize A = (r', A')

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
from triangulize_divisor[OF mf sel_fun A] rA'
[PROOF STATE]
proof (chain)
picking this:
local.triangulize A = (?r', ?A') \<Longrightarrow> ?r' \<noteq> (0::'a)
local.triangulize A = (r', A')
[PROOF STEP]
have r'0: "r' \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
local.triangulize A = (?r', ?A') \<Longrightarrow> ?r' \<noteq> (0::'a)
local.triangulize A = (r', A')

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

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
from triangulize_det[OF mf sel_fun A rA']
[PROOF STATE]
proof (chain)
picking this:
det A * r' = det A'
[PROOF STEP]
have det': "det A * r' = det A'"
[PROOF STATE]
proof (prove)
using this:
det A * r' = det A'

goal (1 subgoal):
 1. det A * r' = det A'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
det A * r' = det A'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
from triangulized[OF mf sel_fun A, unfolded rA']
[PROOF STATE]
proof (chain)
picking this:
(r', A') = (?r', ?A') \<Longrightarrow> upper_triangular ?A'
[PROOF STEP]
have tri': "upper_triangular A'"
[PROOF STATE]
proof (prove)
using this:
(r', A') = (?r', ?A') \<Longrightarrow> upper_triangular ?A'

goal (1 subgoal):
 1. upper_triangular A'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
upper_triangular A'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
have A': "A' \<in> carrier_mat (dim_row A') (dim_row A')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A' \<in> carrier_mat (dim_row A') (dim_row A')
[PROOF STEP]
using triangulize_closed[OF rA' A]
[PROOF STATE]
proof (prove)
using this:
A' \<in> carrier_mat (dim_row A) (dim_row A)

goal (1 subgoal):
 1. A' \<in> carrier_mat (dim_row A') (dim_row A')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A' \<in> carrier_mat (dim_row A') (dim_row A')

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
from tri'
[PROOF STATE]
proof (chain)
picking this:
upper_triangular A'
[PROOF STEP]
have tr: "triangular_to (dim_row A') A'"
[PROOF STATE]
proof (prove)
using this:
upper_triangular A'

goal (1 subgoal):
 1. local.triangular_to (dim_row A') A'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.triangular_to (dim_row A') A'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
have "det_code A = prod_list (diag_mat A') div r'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.det_code A = prod_list (diag_mat A') div r'
[PROOF STEP]
using rA' True
[PROOF STATE]
proof (prove)
using this:
local.triangulize A = (r', A')
dim_row A = dim_col A

goal (1 subgoal):
 1. local.det_code A = prod_list (diag_mat A') div r'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.det_code A = prod_list (diag_mat A') div r'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.det_code A = prod_list (diag_mat A') div r'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
have "prod_list (diag_mat A') = det A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (diag_mat A') = det A'
[PROOF STEP]
unfolding det_upper_triangular[OF tri' A']
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (diag_mat A') = prod_list (diag_mat A')
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
prod_list (diag_mat A') = det A'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prod_list (diag_mat A') = det A'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
have "\<dots> = det A * r'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A' = det A * r'
[PROOF STEP]
by (simp add: det')
[PROOF STATE]
proof (state)
this:
det A' = det A * r'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det A' = det A * r'

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
have "\<dots> div r' = det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A * r' div r' = det A
[PROOF STEP]
using r'0
[PROOF STATE]
proof (prove)
using this:
r' \<noteq> (0::'a)

goal (1 subgoal):
 1. det A * r' div r' = det A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
det A * r' div r' = det A

goal (2 subgoals):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A = dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
 2. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
local.det_code A = det A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
local.det_code A = det A

goal (1 subgoal):
 1. local.det_code A = det A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
local.det_code A = det A

goal (1 subgoal):
 1. \<lbrakk>\<And>A. local.det_code A = (if dim_row A = dim_col A then case local.triangulize A of (m, A') \<Rightarrow> prod_list (diag_mat A') div m else (0::'a)); dim_row A \<noteq> dim_col A\<rbrakk> \<Longrightarrow> local.det_code A = det A
[PROOF STEP]
qed (simp add: det_def)


[STATEMENT]
lemma prime_elem_multiplicity_power_distrib:
  assumes "prime_elem p" "x \<noteq> 0"
  shows   "multiplicity p (x ^ n) = n * multiplicity p x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicity p (x ^ n) = n * multiplicity p x
[PROOF STEP]
using assms prime_elem_multiplicity_prod_mset_distrib [of p "replicate_mset n x"]
[PROOF STATE]
proof (prove)
using this:
prime_elem p
x \<noteq> (0::'a)
\<lbrakk>prime_elem p; (0::'a) \<notin># replicate_mset n x\<rbrakk> \<Longrightarrow> multiplicity p (\<Prod>\<^sub># (replicate_mset n x)) = \<Sum>\<^sub># (image_mset (multiplicity p) (replicate_mset n x))

goal (1 subgoal):
 1. multiplicity p (x ^ n) = n * multiplicity p x
[PROOF STEP]
by simp


[STATEMENT]
theorem MN_imp_dfa:
  assumes "MyhillNerode L R"
  obtains M where "dfa M" "dfa.language M = L" "card (states M) = card (UNIV//R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
MyhillNerode L R
[PROOF STEP]
obtain A
    where eqR: "equiv UNIV R"
      and riR: "right_invariant R"
      and finix: "finite (UNIV//R)"
      and L: "L = R``A"
[PROOF STATE]
proof (prove)
using this:
MyhillNerode L R

goal (1 subgoal):
 1. (\<And>A. \<lbrakk>equiv UNIV R; right_invariant R; finite (UNIV // R); L = R `` A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: MyhillNerode_def)
[PROOF STATE]
proof (state)
this:
equiv UNIV R
right_invariant R
finite (UNIV // R)
L = R `` A

goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
let ?n = "card (UNIV//R)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from ex_bij_betw_finite_nat [OF finix]
[PROOF STATE]
proof (chain)
picking this:
\<exists>h. bij_betw h (UNIV // R) {0..<card (UNIV // R)}
[PROOF STEP]
obtain h where h: "bij_betw h (UNIV//R) (hfset (ord_of ?n))"
[PROOF STATE]
proof (prove)
using this:
\<exists>h. bij_betw h (UNIV // R) {0..<card (UNIV // R)}

goal (1 subgoal):
 1. (\<And>h. bij_betw h (UNIV // R) (hfset (ord_of (card (UNIV // R)))) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using bij_betw_ord_ofI
[PROOF STATE]
proof (prove)
using this:
\<exists>h. bij_betw h (UNIV // R) {0..<card (UNIV // R)}
bij_betw ?h ?A {0..<?n} \<Longrightarrow> bij_betw (ord_of \<circ> ?h) ?A (hfset (ord_of ?n))

goal (1 subgoal):
 1. (\<And>h. bij_betw h (UNIV // R) (hfset (ord_of (card (UNIV // R)))) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bij_betw h (UNIV // R) (hfset (ord_of (card (UNIV // R))))

goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
interpret MN: MyhillNerode_dfa L R A "?n" h
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MyhillNerode_dfa L R A (card (UNIV // R)) h
[PROOF STEP]
by (simp add: MyhillNerode_dfa_def eqR riR L h)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>M. \<lbrakk>dfa M; dfa.language M = L; card (states M) = card (UNIV // R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (auto simp: MN.language intro: that MN.dfa MN.language MN.card_states)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_mset_mono:
  "sum_mset (image_mset f K) \<le> sum_mset (image_mset g K)"
  if "\<And>i. i \<in># K \<Longrightarrow> f i \<le> g i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset f K) \<le> \<Sum>\<^sub># (image_mset g K)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
?i1 \<in># K \<Longrightarrow> f ?i1 \<le> g ?i1

goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset f K) \<le> \<Sum>\<^sub># (image_mset g K)
[PROOF STEP]
by (induction K) (simp_all add: add_mono)


[STATEMENT]
theorem Beta_plus1_right:
  assumes "y \<notin> \<int>\<^sub>\<le>\<^sub>0"
  shows   "(x + y) * Beta x (y + 1) = y * Beta x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y) * Beta x (y + (1::'a)) = y * Beta x y
[PROOF STEP]
using Beta_plus1_left[of y x] assms
[PROOF STATE]
proof (prove)
using this:
y \<notin> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> (y + x) * Beta (y + (1::'a)) x = y * Beta y x
y \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. (x + y) * Beta x (y + (1::'a)) = y * Beta x y
[PROOF STEP]
by (simp_all add: Beta_commute add.commute)


[STATEMENT]
lemma card_lists_length_eq':
  fixes A :: "'a set"
  shows "card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
proof (cases "finite A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
finite A

goal (2 subgoals):
 1. finite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
using card_lists_length_eq
[PROOF STATE]
proof (prove)
using this:
finite A
finite ?A \<Longrightarrow> card {xs. set xs \<subseteq> ?A \<and> length xs = ?n} = card ?A ^ ?n

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n

goal (1 subgoal):
 1. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
infinite A

goal (1 subgoal):
 1. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence inf_A: "infinite A"
[PROOF STATE]
proof (prove)
using this:
infinite A

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

goal (1 subgoal):
 1. infinite A \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence "card {xs. set xs \<subseteq> A \<and> length xs = n} = card {([] :: 'a list)}"
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card {[]}
[PROOF STEP]
by (intro arg_cong[where f="card"], auto simp add:set_eq_iff)
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card {[]}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card {[]}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
have "... = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {[]} = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {[]} = 1

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {[]} = 1

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
have "... = card A^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = card A ^ n
[PROOF STEP]
using True inf_A
[PROOF STATE]
proof (prove)
using this:
n = 0
infinite A

goal (1 subgoal):
 1. 1 = card A ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 = card A ^ n

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
 2. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence "inj (replicate n)"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. inj (replicate n)
[PROOF STEP]
by (meson inj_onI replicate_eq_replicate)
[PROOF STATE]
proof (state)
this:
inj (replicate n)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence "inj_on (replicate n) A"
[PROOF STATE]
proof (prove)
using this:
inj (replicate n)

goal (1 subgoal):
 1. inj_on (replicate n) A
[PROOF STEP]
using inj_on_subset
[PROOF STATE]
proof (prove)
using this:
inj (replicate n)
\<lbrakk>inj_on ?f ?A; ?B \<subseteq> ?A\<rbrakk> \<Longrightarrow> inj_on ?f ?B

goal (1 subgoal):
 1. inj_on (replicate n) A
[PROOF STEP]
by (metis subset_UNIV)
[PROOF STATE]
proof (state)
this:
inj_on (replicate n) A

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence "infinite (replicate n ` A)"
[PROOF STATE]
proof (prove)
using this:
inj_on (replicate n) A

goal (1 subgoal):
 1. infinite (replicate n ` A)
[PROOF STEP]
using inf_A finite_image_iff
[PROOF STATE]
proof (prove)
using this:
inj_on (replicate n) A
infinite A
inj_on ?f ?A \<Longrightarrow> finite (?f ` ?A) = finite ?A

goal (1 subgoal):
 1. infinite (replicate n ` A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
infinite (replicate n ` A)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
infinite (replicate n ` A)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
have
      "replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs  = n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs = n}
[PROOF STEP]
by (intro image_subsetI, auto)
[PROOF STATE]
proof (state)
this:
replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs = n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
infinite (replicate n ` A)
replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs = n}
[PROOF STEP]
have "infinite {xs. set xs \<subseteq> A \<and> length xs  = n}"
[PROOF STATE]
proof (prove)
using this:
infinite (replicate n ` A)
replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs = n}

goal (1 subgoal):
 1. infinite {xs. set xs \<subseteq> A \<and> length xs = n}
[PROOF STEP]
using infinite_super
[PROOF STATE]
proof (prove)
using this:
infinite (replicate n ` A)
replicate n ` A \<subseteq> {xs. set xs \<subseteq> A \<and> length xs = n}
\<lbrakk>?S \<subseteq> ?T; infinite ?S\<rbrakk> \<Longrightarrow> infinite ?T

goal (1 subgoal):
 1. infinite {xs. set xs \<subseteq> A \<and> length xs = n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
infinite {xs. set xs \<subseteq> A \<and> length xs = n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
hence "card {xs. set xs \<subseteq> A \<and> length xs  = n} = 0"
[PROOF STATE]
proof (prove)
using this:
infinite {xs. set xs \<subseteq> A \<and> length xs = n}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = 0

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
using inf_A False
[PROOF STATE]
proof (prove)
using this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = 0
infinite A
n \<noteq> 0

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs = n} = card A ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_expansion_lemma: "cos (x + real (Suc m) * pi / 2) = - sin (x + real m * pi / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (x + real (Suc m) * pi / 2) = - sin (x + real m * pi / 2)
[PROOF STEP]
by (auto simp: cos_add sin_add distrib_right add_divide_distrib)


[STATEMENT]
lemma pm_of_poly_prod: "pm_of_poly x (prod f I) = (\<Prod>i\<in>I. pm_of_poly x (f i :: _::ring_1 poly))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pm_of_poly x (prod f I) = (\<Prod>i\<in>I. pm_of_poly x (f i))
[PROOF STEP]
by (induct I rule: infinite_finite_induct) (simp_all add: pm_of_poly_times)


[STATEMENT]
lemma T_cruel:
  "s \<noteq> [] \<Longrightarrow> distinct s \<Longrightarrow>
  T s (cruel A (s,is) n) (off2 A (s,is) (cruel A (s,is) n)) \<ge> n*(length s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> n * length s \<le> T s (cruel A (s, is) n) (off2 A (s, is) (cruel A (s, is) n))
[PROOF STEP]
apply(induction n arbitrary: s "is")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>s is. \<lbrakk>s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> 0 * length s \<le> T s (cruel A (s, is) 0) (off2 A (s, is) (cruel A (s, is) 0))
 2. \<And>n s is. \<lbrakk>\<And>s is. \<lbrakk>s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> n * length s \<le> T s (cruel A (s, is) n) (off2 A (s, is) (cruel A (s, is) n)); s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> Suc n * length s \<le> T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n s is. \<lbrakk>\<And>s is. \<lbrakk>s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> n * length s \<le> T s (cruel A (s, is) n) (off2 A (s, is) (cruel A (s, is) n)); s \<noteq> []; distinct s\<rbrakk> \<Longrightarrow> Suc n * length s \<le> T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))
[PROOF STEP]
apply(erule_tac x = "fst(Step A (s, is) (last s))" in meta_allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n s is. \<lbrakk>s \<noteq> []; distinct s; \<And>isa. \<lbrakk>fst (Step A (s, is) (last s)) \<noteq> []; distinct (fst (Step A (s, is) (last s)))\<rbrakk> \<Longrightarrow> n * length (fst (Step A (s, is) (last s))) \<le> T (fst (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), isa) n) (off2 A (fst (Step A (s, is) (last s)), isa) (cruel A (fst (Step A (s, is) (last s)), isa) n))\<rbrakk> \<Longrightarrow> Suc n * length s \<le> T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))
[PROOF STEP]
apply(erule_tac x = "snd(Step A (s, is) (last s))" in meta_allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n s is. \<lbrakk>s \<noteq> []; distinct s; \<lbrakk>fst (Step A (s, is) (last s)) \<noteq> []; distinct (fst (Step A (s, is) (last s)))\<rbrakk> \<Longrightarrow> n * length (fst (Step A (s, is) (last s))) \<le> T (fst (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n) (off2 A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n))\<rbrakk> \<Longrightarrow> Suc n * length s \<le> T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))
[PROOF STEP]
apply(frule_tac sws = "snd(fst(snd A (s,is) (last s)))" in index_swaps_last_size)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n s is. \<lbrakk>s \<noteq> []; distinct s; \<lbrakk>fst (Step A (s, is) (last s)) \<noteq> []; distinct (fst (Step A (s, is) (last s)))\<rbrakk> \<Longrightarrow> n * length (fst (Step A (s, is) (last s))) \<le> T (fst (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n) (off2 A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) (cruel A (fst (Step A (s, is) (last s)), snd (Step A (s, is) (last s))) n)); length s \<le> index (swaps (snd (fst (snd A (s, is) (last s)))) s) (last s) + length (snd (fst (snd A (s, is) (last s)))) + 1\<rbrakk> \<Longrightarrow> Suc n * length s \<le> T s (cruel A (s, is) (Suc n)) (off2 A (s, is) (cruel A (s, is) (Suc n)))
[PROOF STEP]
apply(simp add: distinct_step t_def split_def Step_def
        length_greater_0_conv[symmetric] del: length_greater_0_conv)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma filter_length_weakening :
  assumes "\<And> q . f1 q \<Longrightarrow> f2 q"
  shows "length (filter f1 p) \<le> length (filter f2 p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter f1 p) \<le> length (filter f2 p)
[PROOF STEP]
proof (induction p)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (filter f1 []) \<le> length (filter f2 [])
 2. \<And>a p. length (filter f1 p) \<le> length (filter f2 p) \<Longrightarrow> length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. length (filter f1 []) \<le> length (filter f2 [])
 2. \<And>a p. length (filter f1 p) \<le> length (filter f2 p) \<Longrightarrow> length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter f1 []) \<le> length (filter f2 [])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (filter f1 []) \<le> length (filter f2 [])

goal (1 subgoal):
 1. \<And>a p. length (filter f1 p) \<le> length (filter f2 p) \<Longrightarrow> length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a p. length (filter f1 p) \<le> length (filter f2 p) \<Longrightarrow> length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
case (Cons a p)
[PROOF STATE]
proof (state)
this:
length (filter f1 p) \<le> length (filter f2 p)

goal (1 subgoal):
 1. \<And>a p. length (filter f1 p) \<le> length (filter f2 p) \<Longrightarrow> length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (filter f1 p) \<le> length (filter f2 p)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
length (filter f1 p) \<le> length (filter f2 p)

goal (1 subgoal):
 1. length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length (filter f1 p) \<le> length (filter f2 p)
f1 ?q \<Longrightarrow> f2 ?q

goal (1 subgoal):
 1. length (filter f1 (a # p)) \<le> length (filter f2 (a # p))
[PROOF STEP]
by (cases "f1 a"; auto)
[PROOF STATE]
proof (state)
this:
length (filter f1 (a # p)) \<le> length (filter f2 (a # p))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_mul_rid [simp]:
  fixes A :: "'a::semiring_1 ^ 'm ^ 'n"
  shows "A ** mat 1 = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ** mat (1::'a) = A
[PROOF STEP]
unfolding matrix_matrix_mult_def mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. \<Sum>k\<in>UNIV. A $ i $ k * (\<chi>i j. if i = j then 1::'a else (0::'a)) $ k $ j) = A
[PROOF STEP]
by (auto simp: if_distrib if_distribR sum.delta'[OF finite] cong: if_cong)


[STATEMENT]
lemma finite_basis: "\<exists>basis::'a::cfinite_dim set. finite basis \<and> cindependent basis \<and> cspan basis = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
from cfinitely_spanned
[PROOF STATE]
proof (chain)
picking this:
\<exists>S. finite S \<and> cspan S = UNIV
[PROOF STEP]
obtain S :: \<open>'a set\<close> where \<open>finite S\<close> and \<open>cspan S = UNIV\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>S. finite S \<and> cspan S = UNIV

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>finite S; cspan S = UNIV\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite S
cspan S = UNIV

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
from complex_vector.maximal_independent_subset
[PROOF STATE]
proof (chain)
picking this:
(\<And>B. \<lbrakk>B \<subseteq> ?V; cindependent B; ?V \<subseteq> cspan B\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
[PROOF STEP]
obtain B :: \<open>'a set\<close> where \<open>B \<subseteq> S\<close> and \<open>cindependent B\<close> and \<open>S \<subseteq> cspan B\<close>
[PROOF STATE]
proof (prove)
using this:
(\<And>B. \<lbrakk>B \<subseteq> ?V; cindependent B; ?V \<subseteq> cspan B\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>B. \<lbrakk>B \<subseteq> S; cindependent B; S \<subseteq> cspan B\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
B \<subseteq> S
cindependent B
S \<subseteq> cspan B

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
B \<subseteq> S
cindependent B
S \<subseteq> cspan B

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
have \<open>finite B\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite B
[PROOF STEP]
using \<open>B \<subseteq> S\<close> \<open>finite S\<close>
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> S
finite S

goal (1 subgoal):
 1. finite B
[PROOF STEP]
by (meson finite_subset)
[PROOF STATE]
proof (state)
this:
finite B

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite B

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
have \<open>cspan B = UNIV\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cspan B = UNIV
[PROOF STEP]
using \<open>cspan S = UNIV\<close> \<open>S \<subseteq> cspan B\<close>
[PROOF STATE]
proof (prove)
using this:
cspan S = UNIV
S \<subseteq> cspan B

goal (1 subgoal):
 1. cspan B = UNIV
[PROOF STEP]
by (metis complex_vector.span_eq top_greatest)
[PROOF STATE]
proof (state)
this:
cspan B = UNIV

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> S
cindependent B
S \<subseteq> cspan B
finite B
cspan B = UNIV
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> S
cindependent B
S \<subseteq> cspan B
finite B
cspan B = UNIV

goal (1 subgoal):
 1. \<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>basis. finite basis \<and> cindependent basis \<and> cspan basis = UNIV

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma compress_2d:
  assumes "x\<in>{\<lceil>q-(q/(2*2^d))\<rceil>..q-1}"
          "of_nat d < \<lceil>(log 2 q)::real\<rceil>"
  shows "round (real_of_int (2^d * x) / real_of_int q) = 2^d "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}
int d < \<lceil>log 2 (real_of_int q)\<rceil>

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}; int d < \<lceil>log 2 (real_of_int q)\<rceil>\<rbrakk> \<Longrightarrow> round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
have "(2::int)^d \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ d \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ d \<noteq> 0

goal (1 subgoal):
 1. \<lbrakk>x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}; int d < \<lceil>log 2 (real_of_int q)\<rceil>\<rbrakk> \<Longrightarrow> round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
have "round (real_of_int (2^d * x) / real_of_int q) \<ge> 2^d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
have "real_of_int x \<ge> real_of_int q - real_of_int q / (2 * 2^d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x
[PROOF STEP]
using assms(1) ceiling_le_iff
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}
(\<lceil>?x\<rceil> \<le> ?z) = (?x \<le> of_int ?z)

goal (1 subgoal):
 1. real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x
[PROOF STEP]
have "2^d * real_of_int x / real_of_int q \<ge>
      2^d * (real_of_int q - real_of_int q / (2 * 2^d)) /
      real_of_int q"
[PROOF STATE]
proof (prove)
using this:
real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x

goal (1 subgoal):
 1. 2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q \<le> 2 ^ d * real_of_int x / real_of_int q
[PROOF STEP]
using q_gt_zero
[PROOF STATE]
proof (prove)
using this:
real_of_int q - real_of_int q / (2 * 2 ^ d) \<le> real_of_int x
0 < q

goal (1 subgoal):
 1. 2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q \<le> 2 ^ d * real_of_int x / real_of_int q
[PROOF STEP]
by (simp add: divide_right_mono)
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
have "2^d * (real_of_int q - real_of_int q /
      (2 * 2^d)) / real_of_int q
      = 2^d * ((real_of_int q / real_of_int q) -
      (real_of_int q / real_of_int q) / (2 * 2^d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q = 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d))
[PROOF STEP]
by (simp add:algebra_simps diff_divide_distrib)
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q = 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d))

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q = 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d))

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
have "\<dots> = 2^d * (1 - 1/(2*2^d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d)) = 2 ^ d * (1 - 1 / (2 * 2 ^ d))
[PROOF STEP]
using q_nonzero
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0

goal (1 subgoal):
 1. 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d)) = 2 ^ d * (1 - 1 / (2 * 2 ^ d))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d)) = 2 ^ d * (1 - 1 / (2 * 2 ^ d))

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d)) = 2 ^ d * (1 - 1 / (2 * 2 ^ d))

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
have "\<dots> = 2^d - 1/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ d * (1 - 1 / (2 * 2 ^ d)) = 2 ^ d - 1 / 2
[PROOF STEP]
using \<open>2^d \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
2 ^ d \<noteq> 0

goal (1 subgoal):
 1. 2 ^ d * (1 - 1 / (2 * 2 ^ d)) = 2 ^ d - 1 / 2
[PROOF STEP]
by (simp add: right_diff_distrib')
[PROOF STATE]
proof (state)
this:
2 ^ d * (1 - 1 / (2 * 2 ^ d)) = 2 ^ d - 1 / 2

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q
[PROOF STEP]
have "2^d * real_of_int x / real_of_int q \<ge>
      2^d - (1::real)/(2::real)"
[PROOF STATE]
proof (prove)
using this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
[PROOF STEP]
unfolding round_def
[PROOF STATE]
proof (prove)
using this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q

goal (1 subgoal):
 1. 2 ^ d \<le> \<lfloor>real_of_int (2 ^ d * x) / real_of_int q + 1 / 2\<rfloor>
[PROOF STEP]
using le_floor_iff
[PROOF STATE]
proof (prove)
using this:
2 ^ d - 1 / 2 \<le> 2 ^ d * real_of_int x / real_of_int q
(?z \<le> \<lfloor>?x\<rfloor>) = (of_int ?z \<le> ?x)

goal (1 subgoal):
 1. 2 ^ d \<le> \<lfloor>real_of_int (2 ^ d * x) / real_of_int q + 1 / 2\<rfloor>
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)

goal (1 subgoal):
 1. \<lbrakk>x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}; int d < \<lceil>log 2 (real_of_int q)\<rceil>\<rbrakk> \<Longrightarrow> round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)

goal (1 subgoal):
 1. \<lbrakk>x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}; int d < \<lceil>log 2 (real_of_int q)\<rceil>\<rbrakk> \<Longrightarrow> round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
have "round (real_of_int (2^d * x) / real_of_int q) \<le> 2^d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
have "d < log 2 q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real d < log 2 (real_of_int q)
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
int d < \<lceil>log 2 (real_of_int q)\<rceil>

goal (1 subgoal):
 1. real d < log 2 (real_of_int q)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
real d < log 2 (real_of_int q)

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real d < log 2 (real_of_int q)
[PROOF STEP]
have "2 powr (real d) < of_int q"
[PROOF STATE]
proof (prove)
using this:
real d < log 2 (real_of_int q)

goal (1 subgoal):
 1. 2 powr real d < real_of_int q
[PROOF STEP]
using less_log_iff[of 2 q d] q_gt_zero
[PROOF STATE]
proof (prove)
using this:
real d < log 2 (real_of_int q)
\<lbrakk>1 < 2; 0 < real_of_int q\<rbrakk> \<Longrightarrow> (real d < log 2 (real_of_int q)) = (2 powr real d < real_of_int q)
0 < q

goal (1 subgoal):
 1. 2 powr real d < real_of_int q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 powr real d < real_of_int q

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
have "x < q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < q
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}

goal (1 subgoal):
 1. x < q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < q

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x < q
[PROOF STEP]
have "real_of_int x/ real_of_int q < 1"
[PROOF STATE]
proof (prove)
using this:
x < q

goal (1 subgoal):
 1. real_of_int x / real_of_int q < 1
[PROOF STEP]
by (simp add: q_gt_zero)
[PROOF STATE]
proof (state)
this:
real_of_int x / real_of_int q < 1

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of_int x / real_of_int q < 1
[PROOF STEP]
have "real_of_int (2^d * x) / real_of_int q <
      real_of_int (2^d)"
[PROOF STATE]
proof (prove)
using this:
real_of_int x / real_of_int q < 1

goal (1 subgoal):
 1. real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)
[PROOF STEP]
by (auto) (smt (verit, best) divide_less_eq_1_pos
        nonzero_mult_div_cancel_left times_divide_eq_right
        zero_less_power)
[PROOF STATE]
proof (state)
this:
real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
unfolding round_def
[PROOF STATE]
proof (prove)
using this:
real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)

goal (1 subgoal):
 1. \<lfloor>real_of_int (2 ^ d * x) / real_of_int q + 1 / 2\<rfloor> \<le> 2 ^ d
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d

goal (1 subgoal):
 1. \<lbrakk>x \<in> {\<lceil>real_of_int q - real_of_int q / (2 * 2 ^ d)\<rceil>..q - 1}; int d < \<lceil>log 2 (real_of_int q)\<rceil>\<rbrakk> \<Longrightarrow> round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 ^ d \<le> round (real_of_int (2 ^ d * x) / real_of_int q)
round (real_of_int (2 ^ d * x) / real_of_int q) \<le> 2 ^ d

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma total_degree_ineq:
  assumes "m \<in> monomials_of R P"
  assumes "finite (monomials_of R P)"
  shows "total_degree R P \<ge> size m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size m \<le> total_degree R P
[PROOF STEP]
unfolding total_degree_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size m \<le> (if monomials_of R P = {} then 0 else Max (size ` monomials_of R P))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m \<in> monomials_of R P
finite (monomials_of R P)

goal (1 subgoal):
 1. size m \<le> (if monomials_of R P = {} then 0 else Max (size ` monomials_of R P))
[PROOF STEP]
by force


[STATEMENT]
lemma RSpan_closed : "set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M
[PROOF STEP]
proof (induct ms)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> M \<Longrightarrow> RSpan [] \<subseteq> M
 2. \<And>a ms. \<lbrakk>set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M; set (a # ms) \<subseteq> M\<rbrakk> \<Longrightarrow> RSpan (a # ms) \<subseteq> M
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
set [] \<subseteq> M

goal (2 subgoals):
 1. set [] \<subseteq> M \<Longrightarrow> RSpan [] \<subseteq> M
 2. \<And>a ms. \<lbrakk>set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M; set (a # ms) \<subseteq> M\<rbrakk> \<Longrightarrow> RSpan (a # ms) \<subseteq> M
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. RSpan [] \<subseteq> M
[PROOF STEP]
using zero_closed
[PROOF STATE]
proof (prove)
using this:
(0::'m) \<in> M

goal (1 subgoal):
 1. RSpan [] \<subseteq> M
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
RSpan [] \<subseteq> M

goal (1 subgoal):
 1. \<And>a ms. \<lbrakk>set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M; set (a # ms) \<subseteq> M\<rbrakk> \<Longrightarrow> RSpan (a # ms) \<subseteq> M
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a ms. \<lbrakk>set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M; set (a # ms) \<subseteq> M\<rbrakk> \<Longrightarrow> RSpan (a # ms) \<subseteq> M
[PROOF STEP]
case (Cons m ms)
[PROOF STATE]
proof (state)
this:
set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M
set (m # ms) \<subseteq> M

goal (1 subgoal):
 1. \<And>a ms. \<lbrakk>set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M; set (a # ms) \<subseteq> M\<rbrakk> \<Longrightarrow> RSpan (a # ms) \<subseteq> M
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M
set (m # ms) \<subseteq> M

goal (1 subgoal):
 1. RSpan (m # ms) \<subseteq> M
[PROOF STEP]
using RSpan_single_closed RSpan_Cons Group Group.set_plus_closed[of M]
[PROOF STATE]
proof (prove)
using this:
set ms \<subseteq> M \<Longrightarrow> RSpan ms \<subseteq> M
set (m # ms) \<subseteq> M
?m \<in> M \<Longrightarrow> RSpan [?m] \<subseteq> M
RSpan (?m # ?ms) = RSpan [?m] + RSpan ?ms
Group M
\<lbrakk>Group M; ?A \<subseteq> M; ?B \<subseteq> M\<rbrakk> \<Longrightarrow> ?A + ?B \<subseteq> M

goal (1 subgoal):
 1. RSpan (m # ms) \<subseteq> M
[PROOF STEP]
by    simp
[PROOF STATE]
proof (state)
this:
RSpan (m # ms) \<subseteq> M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_prpart_base_factor: "fls_prpart (fls_base_factor f) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_prpart (fls_base_factor f) = 0
[PROOF STEP]
using fls_base_factor_subdegree[of f]
[PROOF STATE]
proof (prove)
using this:
fls_subdegree (fls_base_factor f) = 0

goal (1 subgoal):
 1. fls_prpart (fls_base_factor f) = 0
[PROOF STEP]
by (simp add: fls_prpart_eq0_iff)


[STATEMENT]
lemma snoc_sublist_snoc:
  "sublist (xs @ [x]) (ys @ [y]) \<longleftrightarrow>
     (x = y \<and> suffix xs ys \<or> sublist (xs @ [x]) ys) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sublist (xs @ [x]) (ys @ [y]) = (x = y \<and> suffix xs ys \<or> sublist (xs @ [x]) ys)
[PROOF STEP]
by (subst (1 2) sublist_rev [symmetric])
     (simp del: sublist_rev add: sublist_Cons_right suffix_to_prefix)