[STATEMENT]
lemma from_mregex_to_mregex: "safe_regex m g r \<Longrightarrow> case_prod from_mregex (to_mregex r) = r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. safe_regex m g r \<Longrightarrow> (case to_mregex r of (x, xa) \<Rightarrow> from_mregex x xa) = r
[PROOF STEP]
by (induct r rule: safe_regex.induct)
    (auto dest: to_mregex_ok intro!: from_mregex_cong simp: nth_append from_mregex_shift cases_Neg_iff
      split: prod.splits modality.splits)


[STATEMENT]
lemma main_step:
  fixes qs:: "rat poly list"
  shows "set (find_consistent_signs qs) =  consistent_sign_vectors qs UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (find_consistent_signs qs) = consistent_sign_vectors qs UNIV
[PROOF STEP]
using main_step_aux1 main_step_aux2
[PROOF STATE]
proof (prove)
using this:
fst (factorize_polys ?qs) = [] \<Longrightarrow> set (find_consistent_signs ?qs) = consistent_sign_vectors ?qs UNIV
0 < length (fst (factorize_polys ?qs)) \<Longrightarrow> set (find_consistent_signs ?qs) = consistent_sign_vectors ?qs UNIV

goal (1 subgoal):
 1. set (find_consistent_signs qs) = consistent_sign_vectors qs UNIV
[PROOF STEP]
by auto


[STATEMENT]
lemma permChainEqvt[eqvt]:
  fixes p    :: "name prm"
  and   xvec :: "name list"
  and   yvec :: "name list"
  and   x    :: "'a::pt_name"

  shows "(p \<bullet> ([xvec yvec] \<bullet>\<^sub>v x)) = [(p \<bullet> xvec) (p \<bullet> yvec)] \<bullet>\<^sub>v (p \<bullet> x)"
  and   "(p \<bullet> ([xvec yvec]\<^sup>- \<bullet>\<^sub>v x)) = [(p \<bullet> xvec) (p \<bullet> yvec)]\<^sup>- \<bullet>\<^sub>v (p \<bullet> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<bullet> [xvec yvec] \<bullet>\<^sub>v x = [p \<bullet> xvec p \<bullet> yvec] \<bullet>\<^sub>v p \<bullet> x &&& p \<bullet> [xvec yvec]\<^sup>- \<bullet>\<^sub>v x = [p \<bullet> xvec p \<bullet> yvec]\<^sup>- \<bullet>\<^sub>v p \<bullet> x
[PROOF STEP]
by(subst pt_perm_compose[OF pt_name_inst, OF at_name_inst], simp add: eqvts rev_eqvt)+


[STATEMENT]
lemma nprv_scnjI:
"(\<And> \<psi>. \<psi> \<in> G \<Longrightarrow> nprv F \<psi>) \<Longrightarrow>
 F \<subseteq> fmla \<Longrightarrow> finite F \<Longrightarrow> G \<subseteq> fmla \<Longrightarrow> finite G \<Longrightarrow>
 nprv F (scnj G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>\<psi>. \<psi> \<in> G \<Longrightarrow> nprv F \<psi>; F \<subseteq> fmla; finite F; G \<subseteq> fmla; finite G\<rbrakk> \<Longrightarrow> nprv F (scnj G)
[PROOF STEP]
unfolding nprv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>\<psi>. \<psi> \<in> G \<Longrightarrow> prv (imp (scnj F) \<psi>); F \<subseteq> fmla; finite F; G \<subseteq> fmla; finite G\<rbrakk> \<Longrightarrow> prv (imp (scnj F) (scnj G))
[PROOF STEP]
by (simp add: prv_imp_scnj)


[STATEMENT]
lemma prefs_from_table_wfD:
  assumes "prefs_from_table_wf agents alts xss"
  shows "agents \<noteq> {}" "alts \<noteq> {}" "distinct (map fst xss)"
    and "set (map fst xss) = agents"
    and "\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> \<Union>(set xs) = alts"
    and "\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> is_finite_weak_ranking xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((agents \<noteq> {} &&& alts \<noteq> {} &&& distinct (map fst xss)) &&& set (map fst xss) = agents) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> \<Union> (set xs) = alts) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> is_finite_weak_ranking xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prefs_from_table_wf agents alts xss

goal (1 subgoal):
 1. ((agents \<noteq> {} &&& alts \<noteq> {} &&& distinct (map fst xss)) &&& set (map fst xss) = agents) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> \<Union> (set xs) = alts) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> is_finite_weak_ranking xs)
[PROOF STEP]
unfolding prefs_from_table_wf_def
[PROOF STATE]
proof (prove)
using this:
agents \<noteq> {} \<and> alts \<noteq> {} \<and> distinct (map fst xss) \<and> set (map fst xss) = agents \<and> (\<forall>xs\<in>set (map snd xss). \<Union> (set xs) = alts \<and> is_finite_weak_ranking xs)

goal (1 subgoal):
 1. ((agents \<noteq> {} &&& alts \<noteq> {} &&& distinct (map fst xss)) &&& set (map fst xss) = agents) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> \<Union> (set xs) = alts) &&& (\<And>xs. xs \<in> set (map snd xss) \<Longrightarrow> is_finite_weak_ranking xs)
[PROOF STEP]
by auto


[STATEMENT]
lemma (in prob_space) prob_indep_random_variable:
  assumes ind[simp]: "indep_var N X N Y"
  assumes [simp]: "A \<in> sets N" "B \<in> sets N"
  shows "\<P>(x in M. X x \<in> A \<and> Y x \<in> B) = \<P>(x in M. X x \<in> A) * \<P>(x in M. Y x \<in> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
have  " \<P>(x in M. (X x)\<in>A \<and>  (Y x)\<in> B ) = prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M)
[PROOF STEP]
by (auto intro!: arg_cong[where f= prob])
[PROOF STATE]
proof (state)
this:
prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M)

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M)

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
have "...=  prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M) = prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M)
[PROOF STEP]
by (auto intro!: indep_varD[where Ma=N and Mb=N])
[PROOF STATE]
proof (state)
this:
prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M) = prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M)

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob ((\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M) = prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M)

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
have "... = \<P>(x in M. X x \<in> A) * \<P>(x in M. Y x \<in> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M) = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
by (auto intro!: arg_cong2[where f= "(*)"] arg_cong[where f= prob])
[PROOF STATE]
proof (state)
this:
prob (X -` A \<inter> space M) * prob (Y -` B \<inter> space M) = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
prob {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = prob {x \<in> space M. X x \<in> A} * prob {x \<in> space M. Y x \<in> B}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma contour_integral_mirror:
  assumes "valid_path g"
  shows   "contour_integral (-g) f = contour_integral g (\<lambda>x. -f (- x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
proof (cases "f contour_integrable_on (-g)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
f contour_integrable_on - g

goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f contour_integrable_on - g
[PROOF STEP]
obtain I where I: "(f has_contour_integral I) (-g)"
[PROOF STATE]
proof (prove)
using this:
f contour_integrable_on - g

goal (1 subgoal):
 1. (\<And>I. (f has_contour_integral I) (- g) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: contour_integrable_on_def)
[PROOF STATE]
proof (state)
this:
(f has_contour_integral I) (- g)

goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(f has_contour_integral I) (- g)

goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
note has_contour_integral_mirror_iff[OF assms]
[PROOF STATE]
proof (state)
this:
(?f has_contour_integral ?I) (- g) = ((\<lambda>x. - ?f (- x)) has_contour_integral ?I) g

goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. - f (- x)) has_contour_integral I) g
[PROOF STEP]
have "((\<lambda>x. - f (- x)) has_contour_integral I) g"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. - f (- x)) has_contour_integral I) g

goal (1 subgoal):
 1. ((\<lambda>x. - f (- x)) has_contour_integral I) g
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
((\<lambda>x. - f (- x)) has_contour_integral I) g

goal (2 subgoals):
 1. f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
 2. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
with I
[PROOF STATE]
proof (chain)
picking this:
(f has_contour_integral I) (- g)
((\<lambda>x. - f (- x)) has_contour_integral I) g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral I) (- g)
((\<lambda>x. - f (- x)) has_contour_integral I) g

goal (1 subgoal):
 1. contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
using contour_integral_unique
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral I) (- g)
((\<lambda>x. - f (- x)) has_contour_integral I) g
(?f has_contour_integral ?i) ?g \<Longrightarrow> contour_integral ?g ?f = ?i

goal (1 subgoal):
 1. contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))

goal (1 subgoal):
 1. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> f contour_integrable_on - g

goal (1 subgoal):
 1. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
hence "\<not>(\<lambda>x. -f (-x)) contour_integrable_on g"
[PROOF STATE]
proof (prove)
using this:
\<not> f contour_integrable_on - g

goal (1 subgoal):
 1. \<not> (\<lambda>x. - f (- x)) contour_integrable_on g
[PROOF STEP]
by (auto simp: contour_integral_on_mirror_iff assms)
[PROOF STATE]
proof (state)
this:
\<not> (\<lambda>x. - f (- x)) contour_integrable_on g

goal (1 subgoal):
 1. \<not> f contour_integrable_on - g \<Longrightarrow> contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
from False and this
[PROOF STATE]
proof (chain)
picking this:
\<not> f contour_integrable_on - g
\<not> (\<lambda>x. - f (- x)) contour_integrable_on g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> f contour_integrable_on - g
\<not> (\<lambda>x. - f (- x)) contour_integrable_on g

goal (1 subgoal):
 1. contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))
[PROOF STEP]
by (simp add: not_integrable_contour_integral)
[PROOF STATE]
proof (state)
this:
contour_integral (- g) f = contour_integral g (\<lambda>x. - f (- x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sdiv_neg_pos: "a < 0 \<Longrightarrow> 0 \<le> b \<Longrightarrow> a sdiv b = - (- a div b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a < 0; 0 \<le> b\<rbrakk> \<Longrightarrow> a sdiv b = - (- a div b)
[PROOF STEP]
by (simp add: sdiv_def sgn_if)


[STATEMENT]
lemma maddux_3_11 [simp]:
  "(x \<sqinter> y) \<squnion> (x \<sqinter> -y) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqinter> y \<squnion> x \<sqinter> - y = x
[PROOF STEP]
using brouwer.maddux_3_12 sup.commute
[PROOF STATE]
proof (prove)
using this:
?x \<sqinter> - ?y \<squnion> ?x \<sqinter> ?y = ?x
?a \<squnion> ?b = ?b \<squnion> ?a

goal (1 subgoal):
 1. x \<sqinter> y \<squnion> x \<sqinter> - y = x
[PROOF STEP]
by auto


[STATEMENT]
lemma subterms\<^sub>s\<^sub>e\<^sub>t_mono: "M \<subseteq> N \<Longrightarrow> subterms\<^sub>s\<^sub>e\<^sub>t M \<subseteq> subterms\<^sub>s\<^sub>e\<^sub>t N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M \<subseteq> N \<Longrightarrow> subterms\<^sub>s\<^sub>e\<^sub>t M \<subseteq> subterms\<^sub>s\<^sub>e\<^sub>t N
[PROOF STEP]
by auto


[STATEMENT]
lemma sumhr_mult: "\<And>m n. hypreal_of_real r * sumhr (m, n, f) = sumhr (m, n, \<lambda>n. r * f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m n. hypreal_of_real r * sumhr (m, n, f) = sumhr (m, n, \<lambda>n. r * f n)
[PROOF STEP]
unfolding sumhr_app
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m n. hypreal_of_real r * (*f2* (\<lambda>m n. sum f {m..<n})) m n = (*f2* (\<lambda>m n. \<Sum>n = m..<n. r * f n)) m n
[PROOF STEP]
by transfer (rule sum_distrib_left)


[STATEMENT]
lemma completely_multiplicative_function_divide_nat_power:
  fixes f :: "nat \<Rightarrow> 'a :: {nat_power, field}"
  assumes "completely_multiplicative_function f"
  shows   "completely_multiplicative_function (\<lambda>n. f n / nat_power n s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. completely_multiplicative_function (\<lambda>n. f n / nat_power n s)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f 0 / nat_power 0 s = (0::'a)
 2. f (Suc 0) / nat_power (Suc 0) s = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
interpret f: completely_multiplicative_function f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. completely_multiplicative_function f
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f 0 / nat_power 0 s = (0::'a)
 2. f (Suc 0) / nat_power (Suc 0) s = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
show "f 0 / nat_power 0 s = 0" "f (Suc 0) / nat_power (Suc 0) s = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f 0 / nat_power 0 s = (0::'a) &&& f (Suc 0) / nat_power (Suc 0) s = (1::'a)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
f 0 / nat_power 0 s = (0::'a)
f (Suc 0) / nat_power (Suc 0) s = (1::'a)

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
fix a b :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
assume "a > 1" "b > 1"
[PROOF STATE]
proof (state)
this:
1 < a
1 < b

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
thus "f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)"
[PROOF STATE]
proof (prove)
using this:
1 < a
1 < b

goal (1 subgoal):
 1. f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)
[PROOF STEP]
by (simp_all add: f.mult nat_power_mult_distrib)
[PROOF STATE]
proof (state)
this:
f (a * b) / nat_power (a * b) s = f a / nat_power a s * (f b / nat_power b s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bezout_iterate_invertible:
  fixes A::"'a::{bezout_domain}^'cols^'rows::{mod_type}"
  assumes ib: "is_bezout_ext bezout"
  assumes "n<nrows A"
  and "to_nat i\<le>n"
  and "A $ i $ j \<noteq> 0"
  shows "\<exists>P. invertible P \<and> P**A = bezout_iterate A n i j bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_bezout_ext bezout
n < nrows A
mod_type_class.to_nat i \<le> n
A $ i $ j \<noteq> (0::'a)

goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout
[PROOF STEP]
proof (induct n arbitrary: A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>A. \<lbrakk>is_bezout_ext bezout; 0 < nrows A; mod_type_class.to_nat i \<le> 0; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A 0 i j bezout
 2. \<And>n A. \<lbrakk>\<And>A. \<lbrakk>is_bezout_ext bezout; n < nrows A; mod_type_class.to_nat i \<le> n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout; is_bezout_ext bezout; Suc n < nrows A; mod_type_class.to_nat i \<le> Suc n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
is_bezout_ext bezout
0 < nrows A
mod_type_class.to_nat i \<le> 0
A $ i $ j \<noteq> (0::'a)

goal (2 subgoals):
 1. \<And>A. \<lbrakk>is_bezout_ext bezout; 0 < nrows A; mod_type_class.to_nat i \<le> 0; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A 0 i j bezout
 2. \<And>n A. \<lbrakk>\<And>A. \<lbrakk>is_bezout_ext bezout; n < nrows A; mod_type_class.to_nat i \<le> n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout; is_bezout_ext bezout; Suc n < nrows A; mod_type_class.to_nat i \<le> Suc n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = bezout_iterate A 0 i j bezout
[PROOF STEP]
unfolding bezout_iterate.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = A
[PROOF STEP]
by (simp add: exI[of _ "mat 1"] matrix_mul_lid invertible_def)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible P \<and> P ** A = bezout_iterate A 0 i j bezout

goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. \<lbrakk>is_bezout_ext bezout; n < nrows A; mod_type_class.to_nat i \<le> n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout; is_bezout_ext bezout; Suc n < nrows A; mod_type_class.to_nat i \<le> Suc n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. \<lbrakk>is_bezout_ext bezout; n < nrows A; mod_type_class.to_nat i \<le> n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout; is_bezout_ext bezout; Suc n < nrows A; mod_type_class.to_nat i \<le> Suc n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>is_bezout_ext bezout; n < nrows ?A; mod_type_class.to_nat i \<le> n; ?A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** ?A = bezout_iterate ?A n i j bezout
is_bezout_ext bezout
Suc n < nrows A
mod_type_class.to_nat i \<le> Suc n
A $ i $ j \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>n A. \<lbrakk>\<And>A. \<lbrakk>is_bezout_ext bezout; n < nrows A; mod_type_class.to_nat i \<le> n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A n i j bezout; is_bezout_ext bezout; Suc n < nrows A; mod_type_class.to_nat i \<le> Suc n; A $ i $ j \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
proof (cases "Suc n = to_nat i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n = mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
 2. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc n = mod_type_class.to_nat i

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

goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout)
[PROOF STEP]
by (simp add: exI[of _ "mat 1"] matrix_mul_lid invertible_def)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Suc n \<noteq> mod_type_class.to_nat i

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
have i_le_n: "to_nat i < Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc n
[PROOF STEP]
using Suc.prems(3) False
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i \<le> Suc n
Suc n \<noteq> mod_type_class.to_nat i

goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i < Suc n

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
let ?B="(bezout_matrix A i (from_nat (Suc n)) j bezout ** A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
have b: "bezout_iterate A (Suc n) i j bezout = bezout_iterate ?B n i j bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_iterate A (Suc n) i j bezout = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout
[PROOF STEP]
unfolding bezout_iterate.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if Suc n \<le> mod_type_class.to_nat i then A else bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout
[PROOF STEP]
using i_le_n
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc n

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

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
have "\<exists>P. invertible P \<and> P**?B = bezout_iterate ?B n i j bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout
[PROOF STEP]
proof (rule Suc.hyps[OF ib _])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)
 2. mod_type_class.to_nat i \<le> n
 3. (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) $ i $ j \<noteq> (0::'a)
[PROOF STEP]
show "n < nrows ?B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < nrows (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A)
[PROOF STEP]
using Suc.prems (2)
[PROOF STATE]
proof (prove)
using this:
Suc n < nrows A

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

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

goal (2 subgoals):
 1. mod_type_class.to_nat i \<le> n
 2. (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) $ i $ j \<noteq> (0::'a)
[PROOF STEP]
show "to_nat i \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> n
[PROOF STEP]
using i_le_n
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc n

goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> n

goal (1 subgoal):
 1. (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) $ i $ j \<noteq> (0::'a)
[PROOF STEP]
show "?B $ i $ j \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) $ i $ j \<noteq> (0::'a)
[PROOF STEP]
by (metis False Suc.prems(2) Suc.prems(4) bezout_matrix_not_zero
          ib nrows_def to_nat_from_nat_id)
[PROOF STATE]
proof (state)
this:
(bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) $ i $ j \<noteq> (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible P \<and> P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<exists>P. invertible P \<and> P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout
[PROOF STEP]
obtain P where inv_P: "invertible P" and P: "P**?B = bezout_iterate ?B n i j bezout"
[PROOF STATE]
proof (prove)
using this:
\<exists>P. invertible P \<and> P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout

goal (1 subgoal):
 1. (\<And>P. \<lbrakk>invertible P; P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
invertible P
P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout

goal (1 subgoal):
 1. Suc n \<noteq> mod_type_class.to_nat i \<Longrightarrow> \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
proof (rule exI[of _ "P ** bezout_matrix A i (from_nat (Suc n)) j bezout"],
        rule conjI, rule invertible_mult)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. invertible P
 2. invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)
 3. P ** bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
show "P ** bezout_matrix A i (from_nat (Suc n)) j bezout ** A
        = bezout_iterate A (Suc n) i j bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P ** bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
using P
[PROOF STATE]
proof (prove)
using this:
P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout

goal (1 subgoal):
 1. P ** bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A = bezout_iterate A (Suc n) i j bezout
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
using this:
P ** (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout

goal (1 subgoal):
 1. P ** bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A = bezout_iterate (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A) n i j bezout
[PROOF STEP]
by (metis matrix_mul_assoc)
[PROOF STATE]
proof (state)
this:
P ** bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout ** A = bezout_iterate A (Suc n) i j bezout

goal (2 subgoals):
 1. invertible P
 2. invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)
[PROOF STEP]
have "det (bezout_matrix A i (from_nat (Suc n)) j bezout) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) = (1::'a)
[PROOF STEP]
proof (rule det_bezout_matrix[OF ib])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < mod_type_class.from_nat (Suc n)
 2. A $ i $ j \<noteq> (0::'a)
[PROOF STEP]
show "i < from_nat (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < mod_type_class.from_nat (Suc n)
[PROOF STEP]
using i_le_n from_nat_mono[of "to_nat i" "Suc n"] Suc.prems(2)
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc n
\<lbrakk>mod_type_class.to_nat i < Suc n; Suc n < CARD(?'a)\<rbrakk> \<Longrightarrow> mod_type_class.from_nat (mod_type_class.to_nat i) < mod_type_class.from_nat (Suc n)
Suc n < nrows A

goal (1 subgoal):
 1. i < mod_type_class.from_nat (Suc n)
[PROOF STEP]
unfolding nrows_def
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc n
\<lbrakk>mod_type_class.to_nat i < Suc n; Suc n < CARD(?'a)\<rbrakk> \<Longrightarrow> mod_type_class.from_nat (mod_type_class.to_nat i) < mod_type_class.from_nat (Suc n)
Suc n < CARD('rows)

goal (1 subgoal):
 1. i < mod_type_class.from_nat (Suc n)
[PROOF STEP]
by (metis from_nat_to_nat_id)
[PROOF STATE]
proof (state)
this:
i < mod_type_class.from_nat (Suc n)

goal (1 subgoal):
 1. A $ i $ j \<noteq> (0::'a)
[PROOF STEP]
show "A $ i $ j \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $ i $ j \<noteq> (0::'a)
[PROOF STEP]
by (rule Suc.prems(4))
[PROOF STATE]
proof (state)
this:
A $ i $ j \<noteq> (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
det (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) = (1::'a)

goal (2 subgoals):
 1. invertible P
 2. invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)
[PROOF STEP]
thus "invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)"
[PROOF STATE]
proof (prove)
using this:
det (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) = (1::'a)

goal (1 subgoal):
 1. invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)
[PROOF STEP]
unfolding invertible_iff_is_unit
[PROOF STATE]
proof (prove)
using this:
det (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) = (1::'a)

goal (1 subgoal):
 1. det (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout) dvd (1::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
invertible (bezout_matrix A i (mod_type_class.from_nat (Suc n)) j bezout)

goal (1 subgoal):
 1. invertible P
[PROOF STEP]
show "invertible P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible P
[PROOF STEP]
using inv_P
[PROOF STATE]
proof (prove)
using this:
invertible P

goal (1 subgoal):
 1. invertible P
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
invertible P

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible P \<and> P ** A = bezout_iterate A (Suc n) i j bezout

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ln_upper_15_neg:
  assumes "0 < x" and x1: "x \<le> 1" shows "ln(x) \<le> ln_upper_15 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln x \<le> ln_upper_15 x
[PROOF STEP]
apply (rule gen_upper_bound_decreasing [OF x1 d_delta_ln_upper_15])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>y. \<lbrakk>x \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 < y
 2. \<And>y. \<lbrakk>x \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> diff_delta_ln_upper_15 y \<le> 0
 3. ln_upper_15 1 = ln 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
x \<le> 1

goal (3 subgoals):
 1. \<And>y. \<lbrakk>x \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 < y
 2. \<And>y. \<lbrakk>x \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> diff_delta_ln_upper_15 y \<le> 0
 3. ln_upper_15 1 = ln 1
[PROOF STEP]
apply (auto simp: diff_delta_ln_upper_15_def divide_simps ln_upper_15_def mult_less_0_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma hom_max:
  assumes "a \<le> b \<longleftrightarrow> f a \<le> f b"
  shows "f (max a b) = max (f a) (f b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (max a b) = max (f a) (f b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(a \<le> b) = (f a \<le> f b)

goal (1 subgoal):
 1. f (max a b) = max (f a) (f b)
[PROOF STEP]
by (auto simp: max_def)


[STATEMENT]
lemma prefix_length_less_length: "(\<exists>x\<in>set xs. \<not>P x) \<Longrightarrow> prefix_length P xs < length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>set xs. \<not> P x \<Longrightarrow> prefix_length P xs < length xs
[PROOF STEP]
by (induction xs) (simp_all add: prefix_length_def)


[STATEMENT]
lemma face_of_translation_eq [simp]:
    "((+) a ` T face_of (+) a ` S) \<longleftrightarrow> T face_of S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((+) a ` T face_of (+) a ` S) = (T face_of S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((+) a ` T face_of (+) a ` S) = (T face_of S)
[PROOF STEP]
have *: "\<And>a T S. T face_of S \<Longrightarrow> ((+) a ` T face_of (+) a ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a T S. T face_of S \<Longrightarrow> (+) a ` T face_of (+) a ` S
[PROOF STEP]
by (simp add: face_of_def)
[PROOF STATE]
proof (state)
this:
?T face_of ?S \<Longrightarrow> (+) ?a ` ?T face_of (+) ?a ` ?S

goal (1 subgoal):
 1. ((+) a ` T face_of (+) a ` S) = (T face_of S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((+) a ` T face_of (+) a ` S) = (T face_of S)
[PROOF STEP]
by (force simp: image_comp o_def dest: * [where a = "-a"] intro: *)
[PROOF STATE]
proof (state)
this:
((+) a ` T face_of (+) a ` S) = (T face_of S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma assumes "bal_i (size t + dl) (height t)" "bal_d (size t) dl"
shows "height t \<le> ceiling(c * log 2 (size1 t) + b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have *: "0 < real (size t + 1) + cd * real (size t + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < real (size t + 1) + cd * real (size t + 1)
[PROOF STEP]
using cd0
[PROOF STATE]
proof (prove)
using this:
0 < cd

goal (1 subgoal):
 1. 0 < real (size t + 1) + cd * real (size t + 1)
[PROOF STEP]
by (simp add: add_pos_pos)
[PROOF STATE]
proof (state)
this:
0 < real (size t + 1) + cd * real (size t + 1)

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "0 < 2 powr (b / c) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 2 powr (b / c) - 1
[PROOF STEP]
using b0 c1
[PROOF STATE]
proof (prove)
using this:
0 < b
1 < c

goal (1 subgoal):
 1. 0 < 2 powr (b / c) - 1
[PROOF STEP]
by(auto simp: less_powr_iff)
[PROOF STATE]
proof (state)
this:
0 < 2 powr (b / c) - 1

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
hence **: "0 < real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1)"
[PROOF STATE]
proof (prove)
using this:
0 < 2 powr (b / c) - 1

goal (1 subgoal):
 1. 0 < real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1)
[PROOF STEP]
by (simp add: add_pos_pos)
[PROOF STATE]
proof (state)
this:
0 < real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1)

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "height t \<le> ceiling(c * log 2 (size t + 1 + dl))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil>
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
bal_i (size t + dl) (height t)

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil>
[PROOF STEP]
by(simp add: bal_i_def add_ac)
[PROOF STATE]
proof (state)
this:
int (height t) \<le> \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (height t) \<le> \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "\<dots> \<le> ceiling(c * log 2 (size t + 1 + cd * (size t + 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil>
[PROOF STEP]
using c1 cd0 assms(2)
[PROOF STATE]
proof (prove)
using this:
1 < c
0 < cd
bal_d (size t) dl

goal (1 subgoal):
 1. \<lceil>c * log 2 (real (size t + 1 + dl))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil>
[PROOF STEP]
by(simp add: ceiling_mono add_pos_nonneg bal_d_def add_ac)
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1 + dl))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1 + dl))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "\<dots> \<le> ceiling(c * log 2 (size t + 1 + (2 powr (b/c) - 1) * (size t + 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil>
[PROOF STEP]
using * ** cd_le_log c1
[PROOF STATE]
proof (prove)
using this:
0 < real (size t + 1) + cd * real (size t + 1)
0 < real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1)
cd \<le> 2 powr (b / c) - 1
1 < c

goal (1 subgoal):
 1. \<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil>
[PROOF STEP]
by(simp add: ceiling_mono mult_left_mono)
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1) + cd * real (size t + 1))\<rceil> \<le> \<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "\<dots> = ceiling(c * log 2 (2 powr (b/c) * (size1 t)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil> = \<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil>
[PROOF STEP]
by(simp add:algebra_simps size1_size)
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil> = \<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (real (size t + 1) + (2 powr (b / c) - 1) * real (size t + 1))\<rceil> = \<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "\<dots> = ceiling(c * (b/c + log 2 (size1 t)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil> = \<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil>
[PROOF STEP]
by(simp add: log_mult)
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil> = \<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<lceil>c * log 2 (2 powr (b / c) * real (size1 t))\<rceil> = \<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
have "\<dots> = ceiling(c * log 2 (size1 t) + b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil> = \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
using c1
[PROOF STATE]
proof (prove)
using this:
1 < c

goal (1 subgoal):
 1. \<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil> = \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
by(simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
\<lceil>c * (b / c + log 2 (real (size1 t)))\<rceil> = \<lceil>c * log 2 (real (size1 t)) + b\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>

goal (1 subgoal):
 1. int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
int (height t) \<le> \<lceil>c * log 2 (real (size1 t)) + b\<rceil>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prefixToLevelAppend:
  shows "prefixToLevel level (a @ b) =
  (if level < currentLevel a then
      prefixToLevel level a
  else
      a @ prefixToLevel_aux b level (currentLevel a)
  )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
proof (cases "level < currentLevel a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
 2. \<not> level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
level < currentLevel a

goal (2 subgoals):
 1. level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
 2. \<not> level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
level < currentLevel a

goal (1 subgoal):
 1. prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
unfolding prefixToLevel_def
[PROOF STATE]
proof (prove)
using this:
level < currentLevel a

goal (1 subgoal):
 1. prefixToLevel_aux (a @ b) level 0 = (if level < currentLevel a then prefixToLevel_aux a level 0 else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
using prefixToLevelAppend_aux1[of "0" "level" "a"]
[PROOF STATE]
proof (prove)
using this:
level < currentLevel a
\<lbrakk>0 \<le> level; level - 0 < currentLevel a\<rbrakk> \<Longrightarrow> prefixToLevel_aux (a @ ?b) level 0 = prefixToLevel_aux a level 0

goal (1 subgoal):
 1. prefixToLevel_aux (a @ b) level 0 = (if level < currentLevel a then prefixToLevel_aux a level 0 else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))

goal (1 subgoal):
 1. \<not> level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> level < currentLevel a

goal (1 subgoal):
 1. \<not> level < currentLevel a \<Longrightarrow> prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> level < currentLevel a

goal (1 subgoal):
 1. prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
unfolding prefixToLevel_def
[PROOF STATE]
proof (prove)
using this:
\<not> level < currentLevel a

goal (1 subgoal):
 1. prefixToLevel_aux (a @ b) level 0 = (if level < currentLevel a then prefixToLevel_aux a level 0 else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
using prefixToLevelAppend_aux2[of "0" "level" "a"]
[PROOF STATE]
proof (prove)
using this:
\<not> level < currentLevel a
\<lbrakk>0 \<le> level; currentLevel a + 0 \<le> level\<rbrakk> \<Longrightarrow> prefixToLevel_aux (a @ ?b) level 0 = a @ prefixToLevel_aux ?b level (0 + currentLevel a)

goal (1 subgoal):
 1. prefixToLevel_aux (a @ b) level 0 = (if level < currentLevel a then prefixToLevel_aux a level 0 else a @ prefixToLevel_aux b level (currentLevel a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prefixToLevel level (a @ b) = (if level < currentLevel a then prefixToLevel level a else a @ prefixToLevel_aux b level (currentLevel a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fps_of_poly_eq_iff: "fps_of_poly p = fps_of_poly q \<longleftrightarrow> p = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fps_of_poly p = fps_of_poly q) = (p = q)
[PROOF STEP]
by (simp add: fps_of_poly_def poly_eq_iff fps_eq_iff)


[STATEMENT]
theorem HInit_HInv5: "HInit s \<Longrightarrow> HInv5 s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. HInit s \<Longrightarrow> HInv5 s
[PROOF STEP]
using Disk_isMajority
[PROOF STATE]
proof (prove)
using this:
IsMajority UNIV

goal (1 subgoal):
 1. HInit s \<Longrightarrow> HInv5 s
[PROOF STEP]
by(auto simp add: HInit_def Init_def HInv5_def HInv5_inner_def)


[STATEMENT]
lemma comb_seq_Suc: "comb_seq (Suc n) \<omega> \<omega>' = comb_seq n \<omega> (case_nat (\<omega> n) \<omega>')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comb_seq (Suc n) \<omega> \<omega>' = comb_seq n \<omega> (case_nat (\<omega> n) \<omega>')
[PROOF STEP]
by (auto simp add: comb_seq_def not_less less_Suc_eq le_imp_diff_is_add intro!: ext split: nat.split)


[STATEMENT]
lemma vec_to_iarray_column':
assumes k: "k<ncols A"
shows "(vec_to_iarray (column (from_nat k) A)) = (column_iarray k (matrix_to_iarray A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray (column (mod_type_class.from_nat k) A) = column_iarray k (matrix_to_iarray A)
[PROOF STEP]
unfolding vec_to_iarray_column
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column_iarray (mod_type_class.to_nat (mod_type_class.from_nat k)) (matrix_to_iarray A) = column_iarray k (matrix_to_iarray A)
[PROOF STEP]
unfolding to_nat_from_nat_id[OF k[unfolded ncols_def]]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column_iarray k (matrix_to_iarray A) = column_iarray k (matrix_to_iarray A)
[PROOF STEP]
..


[STATEMENT]
lemma lesseq_a_b: "lesseq_b = lesseq_a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lesseq_b = lesseq_a
[PROOF STEP]
apply (simp add: fun_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x xa. lesseq_b x xa = lesseq_a x xa
[PROOF STEP]
apply clarify
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. lesseq_b x xa = lesseq_a x xa
[PROOF STEP]
apply (cut_tac x = x and y = xa in slattice_a.le_iff_sup)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. lesseq_a x xa = (sup_a x xa = xa) \<Longrightarrow> lesseq_b x xa = lesseq_a x xa
[PROOF STEP]
apply (cut_tac x = x and y = xa in slattice_b.le_iff_sup)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. \<lbrakk>lesseq_a x xa = (sup_a x xa = xa); lesseq_b x xa = (sup_a x xa = xa)\<rbrakk> \<Longrightarrow> lesseq_b x xa = lesseq_a x xa
[PROOF STEP]
by simp


[STATEMENT]
lemma iT_Minus_empty: "k \<ominus> {} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<ominus> {} = {}
[PROOF STEP]
by (simp add: iT_Minus_def)


[STATEMENT]
lemma lm04_15_register_masking:
  fixes c :: nat
    and l :: register
    and ic :: configuration
    and p :: program
    and q :: nat

defines "b == B c"
defines "d == D q c b"

assumes cells_bounded: "cells_bounded ic p c"
assumes l: "l < length (snd ic)"

defines "r == RLe ic p b q"

shows "r l \<preceq> d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
have "\<And>t. R ic p l t \<preceq> 2^c - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>t. R ic p l t \<preceq> 2 ^ c - 1
[PROOF STEP]
using cells_bounded l
[PROOF STATE]
proof (prove)
using this:
cells_bounded ic p c
l < length (snd ic)

goal (1 subgoal):
 1. \<And>t. R ic p l t \<preceq> 2 ^ c - 1
[PROOF STEP]
by (rule register_cells_masked)
[PROOF STATE]
proof (state)
this:
R ic p l ?t \<preceq> 2 ^ c - 1

goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
hence rmasked: "\<forall>t. R ic p l t \<preceq> 2^c - 1"
[PROOF STATE]
proof (prove)
using this:
R ic p l ?t \<preceq> 2 ^ c - 1

goal (1 subgoal):
 1. \<forall>t. R ic p l t \<preceq> 2 ^ c - 1
[PROOF STEP]
by (intro allI)
[PROOF STATE]
proof (state)
this:
\<forall>t. R ic p l t \<preceq> 2 ^ c - 1

goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
have rlt: "\<forall>t. R ic p l t \<le> 2^c - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>t. R ic p l t \<le> 2 ^ c - 1
[PROOF STEP]
using cells_bounded less_Suc_eq_le l
[PROOF STATE]
proof (prove)
using this:
cells_bounded ic p c
(?m < Suc ?n) = (?m \<le> ?n)
l < length (snd ic)

goal (1 subgoal):
 1. \<forall>t. R ic p l t \<le> 2 ^ c - 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>t. R ic p l t \<le> 2 ^ c - 1

goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
have rlmasked: "(\<Sum>t = 0..q. R ic p l t * b^t) \<preceq> (\<Sum>t = 0..q. (2^c - 1) * b^t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t = 0..q. R ic p l t * b ^ t) \<preceq> (\<Sum>t = 0..q. (2 ^ c - 1) * b ^ t)
[PROOF STEP]
using rmasked rlt b_def B_def mask_conserved_sum
[PROOF STATE]
proof (prove)
using this:
\<forall>t. R ic p l t \<preceq> 2 ^ c - 1
\<forall>t. R ic p l t \<le> 2 ^ c - 1
b \<equiv> B c
B ?c = 2 ^ Suc ?c
\<lbrakk>\<forall>t. ?x t \<preceq> ?y; \<forall>t. ?x t \<le> 2 ^ ?c - Suc 0; ?y \<le> 2 ^ ?c - Suc 0\<rbrakk> \<Longrightarrow> (\<Sum>t = 0..?q. ?x t * B ?c ^ t) \<preceq> (\<Sum>t = 0..?q. ?y * B ?c ^ t)

goal (1 subgoal):
 1. (\<Sum>t = 0..q. R ic p l t * b ^ t) \<preceq> (\<Sum>t = 0..q. (2 ^ c - 1) * b ^ t)
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>t = 0..q. R ic p l t * b ^ t) \<preceq> (\<Sum>t = 0..q. (2 ^ c - 1) * b ^ t)

goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t = 0..q. R ic p l t * b ^ t) \<preceq> (\<Sum>t = 0..q. (2 ^ c - 1) * b ^ t)

goal (1 subgoal):
 1. r l \<preceq> d
[PROOF STEP]
by (auto simp: r_def d_def D_def RLe_def mult.commute cong: sum.cong)
[PROOF STATE]
proof (state)
this:
r l \<preceq> d

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma row_space_alt: "row_space A = range (\<lambda>v. mult_vec_mat v A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_space A = range (\<lambda>v. v \<^sub>v* A)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. row_space A \<subseteq> range (\<lambda>v. v \<^sub>v* A)
 2. range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A
[PROOF STEP]
show "row_space A \<subseteq> range (\<lambda>v. v \<^sub>v* A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_space A \<subseteq> range (\<lambda>v. v \<^sub>v* A)
[PROOF STEP]
unfolding row_space_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>v. v \<^sub>v* A) ` carrier_vec (dim_row A) \<subseteq> range (\<lambda>v. v \<^sub>v* A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row_space A \<subseteq> range (\<lambda>v. v \<^sub>v* A)

goal (1 subgoal):
 1. range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A
[PROOF STEP]
show "range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> range (\<lambda>v. v \<^sub>v* A) \<Longrightarrow> x \<in> row_space A
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> range (\<lambda>v. v \<^sub>v* A) \<Longrightarrow> x \<in> row_space A
[PROOF STEP]
assume "x \<in> range (\<lambda>v. v \<^sub>v* A)"
[PROOF STATE]
proof (state)
this:
x \<in> range (\<lambda>v. v \<^sub>v* A)

goal (1 subgoal):
 1. \<And>x. x \<in> range (\<lambda>v. v \<^sub>v* A) \<Longrightarrow> x \<in> row_space A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> range (\<lambda>v. v \<^sub>v* A)
[PROOF STEP]
obtain v where "x = v \<^sub>v* A"
[PROOF STATE]
proof (prove)
using this:
x \<in> range (\<lambda>v. v \<^sub>v* A)

goal (1 subgoal):
 1. (\<And>v. x = v \<^sub>v* A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
x = v \<^sub>v* A

goal (1 subgoal):
 1. \<And>x. x \<in> range (\<lambda>v. v \<^sub>v* A) \<Longrightarrow> x \<in> row_space A
[PROOF STEP]
thus "x \<in> row_space A"
[PROOF STATE]
proof (prove)
using this:
x = v \<^sub>v* A

goal (1 subgoal):
 1. x \<in> row_space A
[PROOF STEP]
by (rule row_spaceI)
[PROOF STATE]
proof (state)
this:
x \<in> row_space A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
range (\<lambda>v. v \<^sub>v* A) \<subseteq> row_space A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma completely_multiplicative_function_mult:
  assumes "completely_multiplicative_function f" "completely_multiplicative_function g"
  shows   "completely_multiplicative_function (\<lambda>n. f n * g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. completely_multiplicative_function (\<lambda>n. f n * g n)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f 0 * g 0 = (0::'a)
 2. f (Suc 0) * g (Suc 0) = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
interpret f: completely_multiplicative_function f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. completely_multiplicative_function f
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f 0 * g 0 = (0::'a)
 2. f (Suc 0) * g (Suc 0) = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
interpret g: completely_multiplicative_function g
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. completely_multiplicative_function g
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f 0 * g 0 = (0::'a)
 2. f (Suc 0) * g (Suc 0) = (1::'a)
 3. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
show "f 0 * g 0 = 0" "f (Suc 0) * g (Suc 0) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f 0 * g 0 = (0::'a) &&& f (Suc 0) * g (Suc 0) = (1::'a)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
f 0 * g 0 = (0::'a)
f (Suc 0) * g (Suc 0) = (1::'a)

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
fix a b :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
assume "a > 1" "b > 1"
[PROOF STATE]
proof (state)
this:
1 < a
1 < b

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>1 < a; 1 < b\<rbrakk> \<Longrightarrow> f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
thus "f (a * b) * g (a * b) = (f a * g a) * (f b * g b)"
[PROOF STATE]
proof (prove)
using this:
1 < a
1 < b

goal (1 subgoal):
 1. f (a * b) * g (a * b) = f a * g a * (f b * g b)
[PROOF STEP]
by (simp_all add: f.mult g.mult mult_ac)
[PROOF STATE]
proof (state)
this:
f (a * b) * g (a * b) = f a * g a * (f b * g b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma times_canc_right:
  assumes "p * h = q * h" and "h \<noteq> (0::('x::linorder \<Rightarrow>\<^sub>0 nat) \<Rightarrow>\<^sub>0 'a::ring_no_zero_divisors)"
  shows "p = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = q
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
assume "p \<noteq> q"
[PROOF STATE]
proof (state)
this:
p \<noteq> q

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
hence "p - q \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> q

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

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
hence "(p - q) * h \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
p - q \<noteq> 0

goal (1 subgoal):
 1. (p - q) * h \<noteq> 0
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
p - q \<noteq> 0
h \<noteq> 0

goal (1 subgoal):
 1. (p - q) * h \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(p - q) * h \<noteq> 0

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
hence "p * h \<noteq> q * h"
[PROOF STATE]
proof (prove)
using this:
(p - q) * h \<noteq> 0

goal (1 subgoal):
 1. p * h \<noteq> q * h
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
p * h \<noteq> q * h

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
p * h \<noteq> q * h

goal (1 subgoal):
 1. False
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
p * h \<noteq> q * h
p * h = q * h

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma snd_echelon_form_of_upt_k_det_eq:
  shows "snd ((echelon_form_of_upt_k_det bezout) (n, A) k) = echelon_form_of_upt_k A k bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (echelon_form_of_upt_k_det bezout (n, A) k) = echelon_form_of_upt_k A k bezout
[PROOF STEP]
unfolding echelon_form_of_upt_k_det_def echelon_form_of_upt_k_def Let_def fst_conv snd_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (snd (foldl (echelon_form_of_column_k_det bezout) (1::'a, A, 0) [0..<Suc k])) = fst (foldl (echelon_form_of_column_k bezout) (A, 0) [0..<Suc k])
[PROOF STEP]
unfolding snd_foldl_ef_det_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (foldl (echelon_form_of_column_k bezout) (A, 0) [0..<Suc k]) = fst (foldl (echelon_form_of_column_k bezout) (A, 0) [0..<Suc k])
[PROOF STEP]
by auto


[STATEMENT]
lemma inverse_i [simp]: "inverse \<i> = - \<i>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse \<i> = - \<i>
[PROOF STEP]
by (rule inverse_unique) simp


[STATEMENT]
lemma linorder_lattice_sup_ge2: "sup (x::'a::linorder_lattice) y \<ge> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> sup x y
[PROOF STEP]
unfolding sup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> (if y \<le> x then x else y)
[PROOF STEP]
by (metis (full_types) linorder_linear)


[STATEMENT]
lemma lex_list_well_founded:
  assumes "well_founded order"
  shows "well_founded (lexp order)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. well_founded (lexp order)
[PROOF STEP]
using well_founded.intro assms(1)[THEN well_founded.wf, THEN lex_list_wfP]
[PROOF STATE]
proof (prove)
using this:
wfP ?R \<Longrightarrow> well_founded ?R
wfP (lexp order)

goal (1 subgoal):
 1. well_founded (lexp order)
[PROOF STEP]
by auto


[STATEMENT]
lemma isCont_add [simp]: "isCont f a \<Longrightarrow> isCont g a \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
  for f :: "'a::t2_space \<Rightarrow> 'b::topological_monoid_add"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a
[PROOF STEP]
by (fact continuous_add)


[STATEMENT]
lemma prod: "\<lbrakk>finite I; \<And>i. i \<in> I \<Longrightarrow> f i \<in> R\<rbrakk> \<Longrightarrow> (\<lambda>x. \<Prod>i \<in> I. f i x) \<in> R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; \<And>i. i \<in> I \<Longrightarrow> f i \<in> R\<rbrakk> \<Longrightarrow> (\<lambda>x. \<Prod>i\<in>I. f i x) \<in> R
[PROOF STEP]
by (induct I rule: finite_induct; simp add: const mult)


[STATEMENT]
lemma mat0_leastI:
  assumes A: "A \<in> carrier_mat nr nc"
  shows "mat_gt_arc A (0\<^sub>m nr nc)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_gt_arc A (0\<^sub>m nr nc)
[PROOF STEP]
proof (rule mat_comp_allI[OF A])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0\<^sub>m nr nc \<in> carrier_mat nr nc
 2. \<And>i j. \<lbrakk>i < nr; j < nc\<rbrakk> \<Longrightarrow> A $$ (i, j) \<succ> 0\<^sub>m nr nc $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0\<^sub>m nr nc \<in> carrier_mat nr nc
 2. \<And>i j. \<lbrakk>i < nr; j < nc\<rbrakk> \<Longrightarrow> A $$ (i, j) \<succ> 0\<^sub>m nr nc $$ (i, j)
[PROOF STEP]
assume i: "i < nr" and j: "j < nc"
[PROOF STATE]
proof (state)
this:
i < nr
j < nc

goal (2 subgoals):
 1. 0\<^sub>m nr nc \<in> carrier_mat nr nc
 2. \<And>i j. \<lbrakk>i < nr; j < nc\<rbrakk> \<Longrightarrow> A $$ (i, j) \<succ> 0\<^sub>m nr nc $$ (i, j)
[PROOF STEP]
thus "A $$ (i,j) \<succ> 0\<^sub>m nr nc $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
i < nr
j < nc

goal (1 subgoal):
 1. A $$ (i, j) \<succ> 0\<^sub>m nr nc $$ (i, j)
[PROOF STEP]
by (auto simp: zero_leastI)
[PROOF STATE]
proof (state)
this:
A $$ (i, j) \<succ> 0\<^sub>m nr nc $$ (i, j)

goal (1 subgoal):
 1. 0\<^sub>m nr nc \<in> carrier_mat nr nc
[PROOF STEP]
qed auto


[STATEMENT]
lemma ln_Gamma_bounds_aux:
  "x \<ge> 1 \<Longrightarrow> ln_Gamma x \<ge> c + (x - 1/2) * ln x - x"
  "x \<ge> 1 \<Longrightarrow> ln_Gamma x \<le> c + (x - 1/2) * ln x - x + 1/(12*x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 \<le> x \<Longrightarrow> c + (x - 1 / 2) * ln x - x \<le> ln_Gamma x) &&& (1 \<le> x \<Longrightarrow> ln_Gamma x \<le> c + (x - 1 / 2) * ln x - x + 1 / (12 * x))
[PROOF STEP]
using g_bounds[of x]
[PROOF STATE]
proof (prove)
using this:
1 \<le> x \<Longrightarrow> g x \<in> {c..c + 1 / (12 * x)}

goal (1 subgoal):
 1. (1 \<le> x \<Longrightarrow> c + (x - 1 / 2) * ln x - x \<le> ln_Gamma x) &&& (1 \<le> x \<Longrightarrow> ln_Gamma x \<le> c + (x - 1 / 2) * ln x - x + 1 / (12 * x))
[PROOF STEP]
by (simp_all add: g_def)


[STATEMENT]
lemma take_set: "set (take n l) = { l!i | i. i<n \<and> i<length l }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (take n l) = {l ! i |i. i < n \<and> i < length l}
[PROOF STEP]
apply (auto simp add: set_conv_nth)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < n; i < length l\<rbrakk> \<Longrightarrow> \<exists>ia. l ! i = take n l ! ia \<and> ia < length l \<and> ia < n
[PROOF STEP]
apply (rule_tac x=i in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i < n; i < length l\<rbrakk> \<Longrightarrow> l ! i = take n l ! i \<and> i < length l \<and> i < n
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma in_set_selsort_eq: "x \<in> set (selsort xs) \<longleftrightarrow> x \<in> (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> set (selsort xs)) = (x \<in> set xs)
[PROOF STEP]
by (induct rule: selsort.induct) (auto simp: Let_def intro!: fold_min_eqI1)


[STATEMENT]
lemma antisym_classes1:
  "c \<le> d \<Longrightarrow> d \<le> c \<Longrightarrow> c = d"
  for c d :: classes1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>c \<le> d; d \<le> c\<rbrakk> \<Longrightarrow> c = d
[PROOF STEP]
unfolding less_eq_classes1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>subclass1\<^sup>=\<^sup>= c d; subclass1\<^sup>=\<^sup>= d c\<rbrakk> \<Longrightarrow> c = d
[PROOF STEP]
using subclass1.simps
[PROOF STATE]
proof (prove)
using this:
subclass1 ?a1.0 ?a2.0 = ((\<exists>c. ?a1.0 = c \<and> ?a2.0 = Object \<and> c \<noteq> Object) \<or> ?a1.0 = Employee \<and> ?a2.0 = Person \<or> ?a1.0 = Customer \<and> ?a2.0 = Person)

goal (1 subgoal):
 1. \<lbrakk>subclass1\<^sup>=\<^sup>= c d; subclass1\<^sup>=\<^sup>= d c\<rbrakk> \<Longrightarrow> c = d
[PROOF STEP]
by auto


[STATEMENT]
lemma mset_insort1_key: "mset (insort1_key f x xs) = {#x#} + mset xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (insort1_key f x xs) = {#x#} + mset xs
[PROOF STEP]
by(induction xs) simp_all


[STATEMENT]
lemma delta_0_iff_i_0: "$\<delta> = 0 \<longleftrightarrow> i = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($\<delta> = 0) = (i = 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. $\<delta> = 0 \<Longrightarrow> i = 0
 2. i = 0 \<Longrightarrow> $\<delta> = 0
[PROOF STEP]
assume "$\<delta> = 0"
[PROOF STATE]
proof (state)
this:
$\<delta> = 0

goal (2 subgoals):
 1. $\<delta> = 0 \<Longrightarrow> i = 0
 2. i = 0 \<Longrightarrow> $\<delta> = 0
[PROOF STEP]
thus "i = 0"
[PROOF STATE]
proof (prove)
using this:
$\<delta> = 0

goal (1 subgoal):
 1. i = 0
[PROOF STEP]
using e_delta
[PROOF STATE]
proof (prove)
using this:
$\<delta> = 0
exp $\<delta> = 1 + i

goal (1 subgoal):
 1. i = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = 0

goal (1 subgoal):
 1. i = 0 \<Longrightarrow> $\<delta> = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = 0 \<Longrightarrow> $\<delta> = 0
[PROOF STEP]
assume "i = 0"
[PROOF STATE]
proof (state)
this:
i = 0

goal (1 subgoal):
 1. i = 0 \<Longrightarrow> $\<delta> = 0
[PROOF STEP]
thus "$\<delta> = 0"
[PROOF STATE]
proof (prove)
using this:
i = 0

goal (1 subgoal):
 1. $\<delta> = 0
[PROOF STEP]
unfolding i_force_def
[PROOF STATE]
proof (prove)
using this:
i = 0

goal (1 subgoal):
 1. ln (1 + i) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
$\<delta> = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scan_length[simp]: "length (scan f xs a) = length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (scan f xs a) = length xs
[PROOF STEP]
by (induct xs arbitrary: a) (auto)


[STATEMENT]
lemma inv_can [simp]:
    assumes "Ide t" and "Ide u" and "\<^bold>\<lfloor>t\<^bold>\<rfloor> = \<^bold>\<lfloor>u\<^bold>\<rfloor>"
    shows "inv (can u t) = can t u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.inv (can u t) = can t u
[PROOF STEP]
using assms inverse_arrows_can
[PROOF STATE]
proof (prove)
using this:
Ide t
Ide u
\<^bold>\<lfloor>t\<^bold>\<rfloor> = \<^bold>\<lfloor>u\<^bold>\<rfloor>
\<lbrakk>Ide ?t; Ide ?u; \<^bold>\<lfloor>?t\<^bold>\<rfloor> = \<^bold>\<lfloor>?u\<^bold>\<rfloor>\<rbrakk> \<Longrightarrow> local.iso (can ?u ?t)
\<lbrakk>Ide ?t; Ide ?u; \<^bold>\<lfloor>?t\<^bold>\<rfloor> = \<^bold>\<lfloor>?u\<^bold>\<rfloor>\<rbrakk> \<Longrightarrow> inverse_arrows (can ?u ?t) (can ?t ?u)

goal (1 subgoal):
 1. local.inv (can u t) = can t u
[PROOF STEP]
by (simp add: inverse_unique)


[STATEMENT]
lemma nth_mset_max:
  assumes "size A > k"
  assumes "\<And>x. x \<le> nth_mset k A \<Longrightarrow> count A x \<le> 1"
  shows "nth_mset k A = Max (least (k+1) (set_mset A))" and "card (least (k+1) (set_mset A)) = k+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A)) &&& card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
define xs where "xs = sorted_list_of_multiset A"
[PROOF STATE]
proof (state)
this:
xs = sorted_list_of_multiset A

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have k_bound: "k < length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < length xs
[PROOF STEP]
unfolding xs_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < length (sorted_list_of_multiset A)
[PROOF STEP]
by (metis size_mset mset_sorted_list_of_multiset assms(1))
[PROOF STATE]
proof (state)
this:
k < length xs

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have A_def: "A = mset xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = mset xs
[PROOF STEP]
by (simp add:xs_def)
[PROOF STATE]
proof (state)
this:
A = mset xs

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have s_xs: "sorted xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted xs
[PROOF STEP]
by (simp add:xs_def sorted_sorted_list_of_multiset)
[PROOF STATE]
proof (state)
this:
sorted xs

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "\<And>x. x \<le> xs ! k \<Longrightarrow> count A x \<le> Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<le> xs ! k \<Longrightarrow> count A x \<le> Suc 0
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
?x \<le> nth_mset k A \<Longrightarrow> count A ?x \<le> 1

goal (1 subgoal):
 1. \<And>x. x \<le> xs ! k \<Longrightarrow> count A x \<le> Suc 0
[PROOF STEP]
by (simp add:xs_def[symmetric] nth_mset_def)
[PROOF STATE]
proof (state)
this:
?x \<le> xs ! k \<Longrightarrow> count A ?x \<le> Suc 0

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
hence no_col: "\<And>x. x \<le> xs ! k \<Longrightarrow> count_list xs x \<le> 1"
[PROOF STATE]
proof (prove)
using this:
?x \<le> xs ! k \<Longrightarrow> count A ?x \<le> Suc 0

goal (1 subgoal):
 1. \<And>x. x \<le> xs ! k \<Longrightarrow> count_list xs x \<le> 1
[PROOF STEP]
by (simp add:A_def count_mset)
[PROOF STATE]
proof (state)
this:
?x \<le> xs ! k \<Longrightarrow> count_list xs ?x \<le> 1

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have inj_xs: "inj_on (\<lambda>k. xs ! k) {0..k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on ((!) xs) {0..k}
[PROOF STEP]
by (rule inj_onI, simp) (metis (full_types) count_list_ge_2_iff k_bound no_col
        le_neq_implies_less linorder_not_le order_le_less_trans s_xs sorted_iff_nth_mono)
[PROOF STATE]
proof (state)
this:
inj_on ((!) xs) {0..k}

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "\<And>y. y < length xs \<Longrightarrow> rank_of (xs ! y) (set xs) < k+1 \<Longrightarrow> y < k+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1\<rbrakk> \<Longrightarrow> y < k + 1
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
fix y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume b:"y < length xs"
[PROOF STATE]
proof (state)
this:
y < length xs

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "\<not>y < k +1"
[PROOF STATE]
proof (state)
this:
\<not> y < k + 1

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence a:"k + 1 \<le> y"
[PROOF STATE]
proof (prove)
using this:
\<not> y < k + 1

goal (1 subgoal):
 1. k + 1 \<le> y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k + 1 \<le> y

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have d:"Suc k < length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc k < length xs
[PROOF STEP]
using a b
[PROOF STATE]
proof (prove)
using this:
k + 1 \<le> y
y < length xs

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

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "k+1 = card ((!) xs ` {0..k})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k + 1 = card ((!) xs ` {0..k})
[PROOF STEP]
by (subst card_image[OF inj_xs], simp)
[PROOF STATE]
proof (state)
this:
k + 1 = card ((!) xs ` {0..k})

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k + 1 = card ((!) xs ` {0..k})

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "... \<le> rank_of (xs ! (k+1)) (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((!) xs ` {0..k}) \<le> rank_of (xs ! (k + 1)) (set xs)
[PROOF STEP]
unfolding rank_of_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((!) xs ` {0..k}) \<le> card {y \<in> set xs. y < xs ! (k + 1)}
[PROOF STEP]
using k_bound
[PROOF STATE]
proof (prove)
using this:
k < length xs

goal (1 subgoal):
 1. card ((!) xs ` {0..k}) \<le> card {y \<in> set xs. y < xs ! (k + 1)}
[PROOF STEP]
by (intro card_mono image_subsetI conjI, simp_all) (metis count_list_ge_2_iff no_col not_le le_imp_less_Suc s_xs
          sorted_iff_nth_mono d order_less_le)
[PROOF STATE]
proof (state)
this:
card ((!) xs ` {0..k}) \<le> rank_of (xs ! (k + 1)) (set xs)

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((!) xs ` {0..k}) \<le> rank_of (xs ! (k + 1)) (set xs)

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "... \<le> rank_of (xs ! y) (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank_of (xs ! (k + 1)) (set xs) \<le> rank_of (xs ! y) (set xs)
[PROOF STEP]
unfolding rank_of_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {y \<in> set xs. y < xs ! (k + 1)} \<le> card {ya \<in> set xs. ya < xs ! y}
[PROOF STEP]
by (intro card_mono subsetI, simp_all)
       (metis Suc_eq_plus1 a b s_xs order_less_le_trans sorted_iff_nth_mono)
[PROOF STATE]
proof (state)
this:
rank_of (xs ! (k + 1)) (set xs) \<le> rank_of (xs ! y) (set xs)

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rank_of (xs ! (k + 1)) (set xs) \<le> rank_of (xs ! y) (set xs)

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "... < k+1"
[PROOF STATE]
proof (state)
this:
rank_of (xs ! y) (set xs) < k + 1

goal (1 subgoal):
 1. \<And>y. \<lbrakk>y < length xs; rank_of (xs ! y) (set xs) < k + 1; \<not> y < k + 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k + 1 < k + 1
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
k + 1 < k + 1

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y < length xs; rank_of (xs ! ?y) (set xs) < k + 1\<rbrakk> \<Longrightarrow> ?y < k + 1

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y < length xs; rank_of (xs ! ?y) (set xs) < k + 1\<rbrakk> \<Longrightarrow> ?y < k + 1

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "rank_of (xs ! y) (set xs) < k+1" if a:"y < k + 1" for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
have "rank_of (xs ! y) (set xs) \<le> card ((\<lambda>k. xs ! k) ` {k. k < length xs \<and> xs ! k < xs ! y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) \<le> card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y})
[PROOF STEP]
unfolding rank_of_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {ya \<in> set xs. ya < xs ! y} \<le> card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y})
[PROOF STEP]
by (intro card_mono subsetI, simp)
       (metis (no_types, lifting) imageI in_set_conv_nth mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
rank_of (xs ! y) (set xs) \<le> card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y})

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rank_of (xs ! y) (set xs) \<le> card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y})

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
have "... \<le> card {k. k < length xs \<and> xs ! k < xs ! y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y}) \<le> card {k. k < length xs \<and> xs ! k < xs ! y}
[PROOF STEP]
by (rule card_image_le, simp)
[PROOF STATE]
proof (state)
this:
card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y}) \<le> card {k. k < length xs \<and> xs ! k < xs ! y}

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((!) xs ` {k. k < length xs \<and> xs ! k < xs ! y}) \<le> card {k. k < length xs \<and> xs ! k < xs ! y}

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
have "... \<le> card {k. k < y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {k. k < length xs \<and> xs ! k < xs ! y} \<le> card {k. k < y}
[PROOF STEP]
by (intro card_mono subsetI, simp_all add:not_less)
       (metis sorted_iff_nth_mono s_xs linorder_not_less)
[PROOF STATE]
proof (state)
this:
card {k. k < length xs \<and> xs ! k < xs ! y} \<le> card {k. k < y}

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {k. k < length xs \<and> xs ! k < xs ! y} \<le> card {k. k < y}

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
have "... = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {k. k < y} = y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {k. k < y} = y

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {k. k < y} = y

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
have "... < k + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y < k + 1
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
y < k + 1

goal (1 subgoal):
 1. y < k + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y < k + 1

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
show "rank_of (xs ! y) (set xs) < k+1"
[PROOF STATE]
proof (prove)
using this:
rank_of (xs ! y) (set xs) < k + 1

goal (1 subgoal):
 1. rank_of (xs ! y) (set xs) < k + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rank_of (xs ! y) (set xs) < k + 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?y < k + 1 \<Longrightarrow> rank_of (xs ! ?y) (set xs) < k + 1

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?y < length xs; rank_of (xs ! ?y) (set xs) < k + 1\<rbrakk> \<Longrightarrow> ?y < k + 1
?y < k + 1 \<Longrightarrow> rank_of (xs ! ?y) (set xs) < k + 1
[PROOF STEP]
have rank_conv: "\<And>y. y < length xs \<Longrightarrow> rank_of (xs ! y) (set xs) < k+1 \<longleftrightarrow> y < k+1"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?y < length xs; rank_of (xs ! ?y) (set xs) < k + 1\<rbrakk> \<Longrightarrow> ?y < k + 1
?y < k + 1 \<Longrightarrow> rank_of (xs ! ?y) (set xs) < k + 1

goal (1 subgoal):
 1. \<And>y. y < length xs \<Longrightarrow> (rank_of (xs ! y) (set xs) < k + 1) = (y < k + 1)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?y < length xs \<Longrightarrow> (rank_of (xs ! ?y) (set xs) < k + 1) = (?y < k + 1)

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "y \<le> xs ! k"  if a:"y \<in> least (k+1) (set xs)"  for y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
have "y \<in> set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<in> set xs
[PROOF STEP]
using a least_subset
[PROOF STATE]
proof (prove)
using this:
y \<in> K_Smallest.least (k + 1) (set xs)
K_Smallest.least ?k ?S \<subseteq> ?S

goal (1 subgoal):
 1. y \<in> set xs
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
y \<in> set xs

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<in> set xs
[PROOF STEP]
obtain i where i_bound: "i < length xs" and y_def: "y = xs ! i"
[PROOF STATE]
proof (prove)
using this:
y \<in> set xs

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < length xs; y = xs ! i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using in_set_conv_nth
[PROOF STATE]
proof (prove)
using this:
y \<in> set xs
(?x \<in> set ?xs) = (\<exists>i<length ?xs. ?xs ! i = ?x)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < length xs; y = xs ! i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
i < length xs
y = xs ! i

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
hence "rank_of (xs ! i) (set xs) < k+1"
[PROOF STATE]
proof (prove)
using this:
i < length xs
y = xs ! i

goal (1 subgoal):
 1. rank_of (xs ! i) (set xs) < k + 1
[PROOF STEP]
using a y_def i_bound
[PROOF STATE]
proof (prove)
using this:
i < length xs
y = xs ! i
y \<in> K_Smallest.least (k + 1) (set xs)
y = xs ! i
i < length xs

goal (1 subgoal):
 1. rank_of (xs ! i) (set xs) < k + 1
[PROOF STEP]
by (simp add: least_def)
[PROOF STATE]
proof (state)
this:
rank_of (xs ! i) (set xs) < k + 1

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
hence "i < k+1"
[PROOF STATE]
proof (prove)
using this:
rank_of (xs ! i) (set xs) < k + 1

goal (1 subgoal):
 1. i < k + 1
[PROOF STEP]
using rank_conv i_bound
[PROOF STATE]
proof (prove)
using this:
rank_of (xs ! i) (set xs) < k + 1
?y < length xs \<Longrightarrow> (rank_of (xs ! ?y) (set xs) < k + 1) = (?y < k + 1)
i < length xs

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

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
hence "i \<le> k"
[PROOF STATE]
proof (prove)
using this:
i < k + 1

goal (1 subgoal):
 1. i \<le> k
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
i \<le> k

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
hence "xs ! i \<le> xs ! k"
[PROOF STATE]
proof (prove)
using this:
i \<le> k

goal (1 subgoal):
 1. xs ! i \<le> xs ! k
[PROOF STEP]
using s_xs i_bound k_bound sorted_nth_mono
[PROOF STATE]
proof (prove)
using this:
i \<le> k
sorted xs
i < length xs
k < length xs
\<lbrakk>sorted ?xs; ?i \<le> ?j; ?j < length ?xs\<rbrakk> \<Longrightarrow> ?xs ! ?i \<le> ?xs ! ?j

goal (1 subgoal):
 1. xs ! i \<le> xs ! k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
xs ! i \<le> xs ! k

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
thus "y \<le> xs ! k"
[PROOF STATE]
proof (prove)
using this:
xs ! i \<le> xs ! k

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
using y_def
[PROOF STATE]
proof (prove)
using this:
xs ! i \<le> xs ! k
y = xs ! i

goal (1 subgoal):
 1. y \<le> xs ! k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y \<le> xs ! k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?y \<in> K_Smallest.least (k + 1) (set xs) \<Longrightarrow> ?y \<le> xs ! k

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?y \<in> K_Smallest.least (k + 1) (set xs) \<Longrightarrow> ?y \<le> xs ! k

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "xs ! k \<in> least (k+1) (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs ! k \<in> K_Smallest.least (k + 1) (set xs)
[PROOF STEP]
using k_bound rank_conv
[PROOF STATE]
proof (prove)
using this:
k < length xs
?y < length xs \<Longrightarrow> (rank_of (xs ! ?y) (set xs) < k + 1) = (?y < k + 1)

goal (1 subgoal):
 1. xs ! k \<in> K_Smallest.least (k + 1) (set xs)
[PROOF STEP]
by (simp add:least_def)
[PROOF STATE]
proof (state)
this:
xs ! k \<in> K_Smallest.least (k + 1) (set xs)

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?y \<in> K_Smallest.least (k + 1) (set xs) \<Longrightarrow> ?y \<le> xs ! k
xs ! k \<in> K_Smallest.least (k + 1) (set xs)
[PROOF STEP]
have "Max (least (k+1) (set xs)) = xs ! k"
[PROOF STATE]
proof (prove)
using this:
?y \<in> K_Smallest.least (k + 1) (set xs) \<Longrightarrow> ?y \<le> xs ! k
xs ! k \<in> K_Smallest.least (k + 1) (set xs)

goal (1 subgoal):
 1. Max (K_Smallest.least (k + 1) (set xs)) = xs ! k
[PROOF STEP]
by (intro Max_eqI finite_subset[OF least_subset], auto)
[PROOF STATE]
proof (state)
this:
Max (K_Smallest.least (k + 1) (set xs)) = xs ! k

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
hence "nth_mset k A = Max (K_Smallest.least (Suc k) (set xs))"
[PROOF STATE]
proof (prove)
using this:
Max (K_Smallest.least (k + 1) (set xs)) = xs ! k

goal (1 subgoal):
 1. nth_mset k A = Max (K_Smallest.least (Suc k) (set xs))
[PROOF STEP]
by (simp add:nth_mset_def xs_def[symmetric])
[PROOF STATE]
proof (state)
this:
nth_mset k A = Max (K_Smallest.least (Suc k) (set xs))

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nth_mset k A = Max (K_Smallest.least (Suc k) (set xs))

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "... = Max (least (k+1) (set_mset A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max (K_Smallest.least (Suc k) (set xs)) = Max (K_Smallest.least (k + 1) (set_mset A))
[PROOF STEP]
by (simp add:A_def)
[PROOF STATE]
proof (state)
this:
Max (K_Smallest.least (Suc k) (set xs)) = Max (K_Smallest.least (k + 1) (set_mset A))

goal (2 subgoals):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
 2. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
[PROOF STEP]
show "nth_mset k A = Max (least (k+1) (set_mset A))"
[PROOF STATE]
proof (prove)
using this:
nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))

goal (1 subgoal):
 1. nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_mset k A = Max (K_Smallest.least (k + 1) (set_mset A))

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "k + 1 = card ((\<lambda>i. xs ! i) ` {0..k})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k + 1 = card ((!) xs ` {0..k})
[PROOF STEP]
by (subst card_image[OF inj_xs], simp)
[PROOF STATE]
proof (state)
this:
k + 1 = card ((!) xs ` {0..k})

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k + 1 = card ((!) xs ` {0..k})

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "... \<le> card (least (k+1) (set xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((!) xs ` {0..k}) \<le> card (K_Smallest.least (k + 1) (set xs))
[PROOF STEP]
using rank_conv k_bound
[PROOF STATE]
proof (prove)
using this:
?y < length xs \<Longrightarrow> (rank_of (xs ! ?y) (set xs) < k + 1) = (?y < k + 1)
k < length xs

goal (1 subgoal):
 1. card ((!) xs ` {0..k}) \<le> card (K_Smallest.least (k + 1) (set xs))
[PROOF STEP]
by (intro card_mono image_subsetI finite_subset[OF least_subset], simp_all add:least_def)
[PROOF STATE]
proof (state)
this:
card ((!) xs ` {0..k}) \<le> card (K_Smallest.least (k + 1) (set xs))

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))
[PROOF STEP]
have "card (least (k+1) (set xs)) \<ge> k+1"
[PROOF STATE]
proof (prove)
using this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))

goal (1 subgoal):
 1. k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
have "card (least (k+1) (set xs)) \<le> k+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set xs)) \<le> k + 1
[PROOF STEP]
by (subst card_least, simp, simp)
[PROOF STATE]
proof (state)
this:
card (K_Smallest.least (k + 1) (set xs)) \<le> k + 1

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))
card (K_Smallest.least (k + 1) (set xs)) \<le> k + 1
[PROOF STEP]
have "card (least (k+1) (set xs)) = k+1"
[PROOF STATE]
proof (prove)
using this:
k + 1 \<le> card (K_Smallest.least (k + 1) (set xs))
card (K_Smallest.least (k + 1) (set xs)) \<le> k + 1

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set xs)) = k + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (K_Smallest.least (k + 1) (set xs)) = k + 1

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
thus "card (least (k+1) (set_mset A)) = k+1"
[PROOF STATE]
proof (prove)
using this:
card (K_Smallest.least (k + 1) (set xs)) = k + 1

goal (1 subgoal):
 1. card (K_Smallest.least (k + 1) (set_mset A)) = k + 1
[PROOF STEP]
by (simp add:A_def)
[PROOF STATE]
proof (state)
this:
card (K_Smallest.least (k + 1) (set_mset A)) = k + 1

goal:
No subgoals!
[PROOF STEP]
qed