[STATEMENT]
lemma basis_orthogonal:
  fixes B :: "'a::real_inner set"
  assumes fB: "finite B"
  shows "\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C"
  (is " \<exists>C. ?P B C")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C
[PROOF STEP]
using fB
[PROOF STATE]
proof (prove)
using this:
finite B

goal (1 subgoal):
 1. \<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C
[PROOF STEP]
proof (induct rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>C. finite C \<and> card C \<le> card {} \<and> span C = span {} \<and> pairwise orthogonal C
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<exists>C. finite C \<and> card C \<le> card {} \<and> span C = span {} \<and> pairwise orthogonal C
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>C. finite C \<and> card C \<le> card {} \<and> span C = span {} \<and> pairwise orthogonal C
[PROOF STEP]
apply (rule exI[where x="{}"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {} \<and> card {} \<le> card {} \<and> span {} = span {} \<and> pairwise orthogonal {}
[PROOF STEP]
apply (auto simp add: pairwise_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>C. finite C \<and> card C \<le> card {} \<and> span C = span {} \<and> pairwise orthogonal C

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
case (insert a B)
[PROOF STATE]
proof (state)
this:
finite B
a \<notin> B
\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
note fB = \<open>finite B\<close> and aB = \<open>a \<notin> B\<close>
[PROOF STATE]
proof (state)
this:
finite B
a \<notin> B

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
from \<open>\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C\<close>
[PROOF STATE]
proof (chain)
picking this:
\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C
[PROOF STEP]
obtain C where C: "finite C" "card C \<le> card B"
    "span C = span B" "pairwise orthogonal C"
[PROOF STATE]
proof (prove)
using this:
\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C

goal (1 subgoal):
 1. (\<And>C. \<lbrakk>finite C; card C \<le> card B; span C = span B; pairwise orthogonal C\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
let ?a = "a - sum (\<lambda>x. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) C"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
let ?C = "insert ?a C"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
from C(1)
[PROOF STATE]
proof (chain)
picking this:
finite C
[PROOF STEP]
have fC: "finite ?C"
[PROOF STATE]
proof (prove)
using this:
finite C

goal (1 subgoal):
 1. finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
from fB aB C(1,2)
[PROOF STATE]
proof (chain)
picking this:
finite B
a \<notin> B
finite C
card C \<le> card B
[PROOF STEP]
have cC: "card ?C \<le> card (insert a B)"
[PROOF STATE]
proof (prove)
using this:
finite B
a \<notin> B
finite C
card C \<le> card B

goal (1 subgoal):
 1. card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B)
[PROOF STEP]
by (simp add: card_insert_if)
[PROOF STATE]
proof (state)
this:
card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
fix x k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
have th0: "\<And>(a::'a) b c. a - (b - c) = c + (a - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b c. a - (b - c) = c + (a - b)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
?a - (?b - ?c) = ?c + (?a - ?b)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
have "x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C \<longleftrightarrow> x - k *\<^sub>R a \<in> span C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (x - k *\<^sub>R a \<in> span C)
[PROOF STEP]
apply (simp only: scaleR_right_diff_distrib th0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (k *\<^sub>R (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) + (x - k *\<^sub>R a) \<in> span C) = (x - k *\<^sub>R a \<in> span C)
[PROOF STEP]
apply (rule span_add_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k *\<^sub>R (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) \<in> span C
[PROOF STEP]
apply (rule span_scale)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) \<in> span C
[PROOF STEP]
apply (rule span_sum)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> C \<Longrightarrow> (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x \<in> span C
[PROOF STEP]
apply (rule span_scale)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> C \<Longrightarrow> x \<in> span C
[PROOF STEP]
apply (rule span_base)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> C \<Longrightarrow> x \<in> C
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (x - k *\<^sub>R a \<in> span C)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(?x2 - ?k2 *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (?x2 - ?k2 *\<^sub>R a \<in> span C)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(?x2 - ?k2 *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (?x2 - ?k2 *\<^sub>R a \<in> span C)
[PROOF STEP]
have SC: "span ?C = span (insert a B)"
[PROOF STATE]
proof (prove)
using this:
(?x2 - ?k2 *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (?x2 - ?k2 *\<^sub>R a \<in> span C)

goal (1 subgoal):
 1. span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B)
[PROOF STEP]
unfolding set_eq_iff span_breakdown_eq C(3)[symmetric]
[PROOF STATE]
proof (prove)
using this:
(?x2 - ?k2 *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (?x2 - ?k2 *\<^sub>R a \<in> span C)

goal (1 subgoal):
 1. \<forall>x. (\<exists>k. x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C) = (\<exists>k. x - k *\<^sub>R a \<in> span C)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
fix y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
assume yC: "y \<in> C"
[PROOF STATE]
proof (state)
this:
y \<in> C

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<in> C
[PROOF STEP]
have Cy: "C = insert y (C - {y})"
[PROOF STATE]
proof (prove)
using this:
y \<in> C

goal (1 subgoal):
 1. C = insert y (C - {y})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
C = insert y (C - {y})

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
have fth: "finite (C - {y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (C - {y})
[PROOF STEP]
using C
[PROOF STATE]
proof (prove)
using this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C

goal (1 subgoal):
 1. finite (C - {y})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (C - {y})

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
have "orthogonal ?a y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) y
[PROOF STEP]
unfolding orthogonal_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<bullet> y = 0
[PROOF STEP]
unfolding inner_diff inner_sum_left right_minus_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<bullet> y = (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x \<bullet> y)
[PROOF STEP]
unfolding sum.remove [OF \<open>finite C\<close> \<open>y \<in> C\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<bullet> y = (y \<bullet> a / (y \<bullet> y)) *\<^sub>R y \<bullet> y + (\<Sum>x\<in>C - {y}. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x \<bullet> y)
[PROOF STEP]
apply (clarsimp simp add: inner_commute[of y a])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<noteq> (0::'a) \<Longrightarrow> (\<Sum>x\<in>C - {y}. x \<bullet> a * (x \<bullet> y) / (x \<bullet> x)) = 0
[PROOF STEP]
apply (rule sum.neutral)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<noteq> (0::'a) \<Longrightarrow> \<forall>x\<in>C - {y}. x \<bullet> a * (x \<bullet> y) / (x \<bullet> x) = 0
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> x \<bullet> y = 0
[PROOF STEP]
apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> x \<in> C
 2. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> y \<in> C
 3. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> x \<noteq> y
[PROOF STEP]
using \<open>y \<in> C\<close>
[PROOF STATE]
proof (prove)
using this:
y \<in> C

goal (3 subgoals):
 1. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> x \<in> C
 2. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> y \<in> C
 3. \<And>x. \<lbrakk>y \<noteq> (0::'a); x \<in> C; x \<noteq> y; x \<bullet> a \<noteq> 0; x \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> x \<noteq> y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
orthogonal (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) y

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?y2 \<in> C \<Longrightarrow> orthogonal (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) ?y2

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
with \<open>pairwise orthogonal C\<close>
[PROOF STATE]
proof (chain)
picking this:
pairwise orthogonal C
?y2 \<in> C \<Longrightarrow> orthogonal (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) ?y2
[PROOF STEP]
have CPO: "pairwise orthogonal ?C"
[PROOF STATE]
proof (prove)
using this:
pairwise orthogonal C
?y2 \<in> C \<Longrightarrow> orthogonal (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) ?y2

goal (1 subgoal):
 1. pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
[PROOF STEP]
by (rule pairwise_orthogonal_insert)
[PROOF STATE]
proof (state)
this:
pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
from fC cC SC CPO
[PROOF STATE]
proof (chain)
picking this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B)
span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B)
pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
[PROOF STEP]
have "?P (insert a B) ?C"
[PROOF STATE]
proof (prove)
using this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B)
span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B)
pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)

goal (1 subgoal):
 1. finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<and> card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B) \<and> span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B) \<and> pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<and> card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B) \<and> span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B) \<and> pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>C. finite C \<and> card C \<le> card F \<and> span C = span F \<and> pairwise orthogonal C\<rbrakk> \<Longrightarrow> \<exists>C. finite C \<and> card C \<le> card (insert x F) \<and> span C = span (insert x F) \<and> pairwise orthogonal C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<and> card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B) \<and> span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B) \<and> pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<and> card (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) \<le> card (insert a B) \<and> span (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C) = span (insert a B) \<and> pairwise orthogonal (insert (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) C)

goal (1 subgoal):
 1. \<exists>C. finite C \<and> card C \<le> card (insert a B) \<and> span C = span (insert a B) \<and> pairwise orthogonal C
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>C. finite C \<and> card C \<le> card (insert a B) \<and> span C = span (insert a B) \<and> pairwise orthogonal C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in Module) monofun_0:"\<lbrakk>R module N; free_generator R M H;
      f \<in> H \<rightarrow> carrier N; h \<in> H\<rbrakk> \<Longrightarrow>  monofun R M N f H h  \<zero>  = \<zero>\<^bsub>N\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H\<rbrakk> \<Longrightarrow> monofun R M N f H h \<zero> = \<zero>\<^bsub>N\<^esub>
[PROOF STEP]
apply (cut_tac fgs_submodule[of "{h}"],
       frule submodule_inc_0[of "fgs R M {h}"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H; submodule R M (fgs R M {h}); \<zero> \<in> fgs R M {h}\<rbrakk> \<Longrightarrow> monofun R M N f H h \<zero> = \<zero>\<^bsub>N\<^esub>
 2. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H\<rbrakk> \<Longrightarrow> {h} \<subseteq> carrier M
[PROOF STEP]
apply (cut_tac sc_Ring, frule Ring.ring_zero,
       frule monofun_sprod[of N H f h \<zero> "\<zero>\<^bsub>R\<^esub>"], assumption+,
       cut_tac ag_inc_zero)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H; submodule R M (fgs R M {h}); \<zero> \<in> fgs R M {h}; Ring R; \<zero>\<^bsub>R\<^esub> \<in> carrier R; monofun R M N f H h (\<zero>\<^bsub>R\<^esub> \<cdot>\<^sub>s \<zero>) = \<zero>\<^bsub>R\<^esub> \<cdot>\<^sub>s\<^bsub>N\<^esub> monofun R M N f H h \<zero>; \<zero> \<in> carrier M\<rbrakk> \<Longrightarrow> monofun R M N f H h \<zero> = \<zero>\<^bsub>N\<^esub>
 2. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H\<rbrakk> \<Longrightarrow> {h} \<subseteq> carrier M
[PROOF STEP]
apply (simp add:sc_0_m,
       frule monofun_mem[of N h H \<zero> f], assumption+,
       simp add:Module.sc_0_m)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module N; free_generator R M H; f \<in> H \<rightarrow> carrier N; h \<in> H\<rbrakk> \<Longrightarrow> {h} \<subseteq> carrier M
[PROOF STEP]
apply (frule free_generator_sub, rule subsetI, simp add:subsetD)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma cc_restr_intersect: "ccField G \<inter> ((S - S') \<union> (S' - S)) = {} \<Longrightarrow> cc_restr S G = cc_restr S' G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccField G \<inter> (S - S' \<union> (S' - S)) = {} \<Longrightarrow> G G|` S = G G|` S'
[PROOF STEP]
by (rule CoCalls_eqI) (auto dest: elem_to_ccField)


[STATEMENT]
lemma smooth_on_sum:
  "n-smooth_on S (\<lambda>x. \<Sum>i\<in>F. f i x)"
  if "\<And>i. i \<in> F \<Longrightarrow> finite F \<Longrightarrow> n-smooth_on S (f i)" "open S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n-smooth_on S (\<lambda>x. \<Sum>i\<in>F. f i x)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i \<in> F; finite F\<rbrakk> \<Longrightarrow> n-smooth_on S (f ?i)
open S

goal (1 subgoal):
 1. n-smooth_on S (\<lambda>x. \<Sum>i\<in>F. f i x)
[PROOF STEP]
by (auto simp: smooth_on_def higher_differentiable_on_sum)


[STATEMENT]
lemma cblinfun_compose_zero_right[simp]: "U o\<^sub>C\<^sub>L 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U o\<^sub>C\<^sub>L 0 = 0
[PROOF STEP]
using bounded_cbilinear.zero_right bounded_cbilinear_cblinfun_compose
[PROOF STATE]
proof (prove)
using this:
bounded_cbilinear ?prod \<Longrightarrow> ?prod ?a (0::?'b) = (0::?'c)
bounded_cbilinear (o\<^sub>C\<^sub>L)

goal (1 subgoal):
 1. U o\<^sub>C\<^sub>L 0 = 0
[PROOF STEP]
by blast


[STATEMENT]
lemma mask_nat_positive_iff [simp]:
  \<open>(0::nat) < mask n \<longleftrightarrow> 0 < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < mask n) = (0 < n)
[PROOF STEP]
proof (cases \<open>n = 0\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (0 < mask n) = (0 < n)
 2. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

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

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

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
[PROOF STEP]
have \<open>0 < n\<close>
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

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

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have \<open>(0::nat) < mask n\<close>
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. 0 < mask n
[PROOF STEP]
using less_eq_mask [of n]
[PROOF STATE]
proof (prove)
using this:
0 < n
n \<le> mask n

goal (1 subgoal):
 1. 0 < mask n
[PROOF STEP]
by (rule order_less_le_trans)
[PROOF STATE]
proof (state)
this:
0 < mask n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (0 < mask n) = (0 < n)
[PROOF STEP]
with \<open>0 < n\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
0 < mask n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < n
0 < mask n

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nonzero_gen: assumes "bs \<subseteq> as"
  shows "(\<Prod> (a, i) \<in> bs. a) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>(a, i)\<in>bs. a) \<noteq> 0
[PROOF STEP]
using monic_gen[OF assms]
[PROOF STATE]
proof (prove)
using this:
monic (\<Prod>(a, i)\<in>bs. a)

goal (1 subgoal):
 1. (\<Prod>(a, i)\<in>bs. a) \<noteq> 0
[PROOF STEP]
by auto


[STATEMENT]
lemma faceCountMax_bound:
 "\<lbrakk> tame g; v \<in> \<V> g \<rbrakk> \<Longrightarrow> tri g v + quad g v \<le> 7"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>tame g; v \<in> \<V> g\<rbrakk> \<Longrightarrow> tri g v + quad g v \<le> 7
[PROOF STEP]
using tri_quad_le_degree[of g v]
[PROOF STATE]
proof (prove)
using this:
tri g v + quad g v \<le> degree g v

goal (1 subgoal):
 1. \<lbrakk>tame g; v \<in> \<V> g\<rbrakk> \<Longrightarrow> tri g v + quad g v \<le> 7
[PROOF STEP]
by(auto simp:tame_def tame11b_def split:if_split_asm)


[STATEMENT]
lemma distincts_distinct_set:
  assumes "distincts xss" shows "distinct (map set xss)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map set xss)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distincts xss

goal (1 subgoal):
 1. distinct (map set xss)
[PROOF STEP]
by (auto simp: distinct_map distincts_distinct distincts_inj_on_set)


[STATEMENT]
lemma lfp_le_gfp': "mono f \<Longrightarrow> lfp f x \<le> gfp f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mono f \<Longrightarrow> lfp f x \<le> gfp f x
[PROOF STEP]
by (rule le_funD[OF lfp_le_gfp])


[STATEMENT]
lemma interior_of_subtopology_open:
  assumes "openin X U"
  shows "(subtopology X U) interior_of S = U \<inter> X interior_of S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subtopology X U interior_of S = U \<inter> X interior_of S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. subtopology X U interior_of S = U \<inter> X interior_of S
[PROOF STEP]
have "\<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A
[PROOF STEP]
using assms openin_Int_closure_of_eq
[PROOF STATE]
proof (prove)
using this:
openin X U
openin ?X ?S \<Longrightarrow> ?S \<inter> ?X closure_of ?T = ?S \<inter> ?X closure_of (?S \<inter> ?T)

goal (1 subgoal):
 1. \<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A

goal (1 subgoal):
 1. subtopology X U interior_of S = U \<inter> X interior_of S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A
[PROOF STEP]
have "topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))"
[PROOF STATE]
proof (prove)
using this:
\<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A

goal (1 subgoal):
 1. topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))
[PROOF STEP]
by (metis (no_types) Diff_Int_distrib Int_Diff inf_commute)
[PROOF STATE]
proof (state)
this:
topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))

goal (1 subgoal):
 1. subtopology X U interior_of S = U \<inter> X interior_of S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))

goal (1 subgoal):
 1. subtopology X U interior_of S = U \<inter> X interior_of S
[PROOF STEP]
unfolding interior_of_closure_of closure_of_subtopology_open topspace_subtopology
[PROOF STATE]
proof (prove)
using this:
topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))

goal (1 subgoal):
 1. topspace X \<inter> U - subtopology X U closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))
[PROOF STEP]
using openin_Int_closure_of_eq [OF assms]
[PROOF STATE]
proof (prove)
using this:
topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))
U \<inter> X closure_of ?T = U \<inter> X closure_of (U \<inter> ?T)

goal (1 subgoal):
 1. topspace X \<inter> U - subtopology X U closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))
[PROOF STEP]
by (metis assms closure_of_subtopology_open)
[PROOF STATE]
proof (state)
this:
subtopology X U interior_of S = U \<inter> X interior_of S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_smult0: "vec_smult 0 as = vec0 (length as)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_smult (0::'a) as = vec0 (length as)
[PROOF STEP]
by (induction as; auto simp add:vec0_def vec_smult_def)


[STATEMENT]
lemma image_mset_filter_swap: "image_mset f {# x \<in># M. P (f x)#} = {# x \<in># image_mset f M. P x#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset f {#x \<in># M. P (f x)#} = filter_mset P (image_mset f M)
[PROOF STEP]
by (induction M) auto


[STATEMENT]
lemma asymp_equiv_at_top_imp_at_left:
  "(\<lambda>x. f (a - inverse x)) \<sim>[at_top] (\<lambda>x. g (a - inverse x)) \<Longrightarrow> f \<sim>[at_left a] g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f (a - inverse x)) \<sim>[at_top] (\<lambda>x. g (a - inverse x)) \<Longrightarrow> f \<sim>[at_left a] g
[PROOF STEP]
by (simp add: at_left_to_top' asymp_equiv_filtermap_iff)


[STATEMENT]
lemma Osum_Preorder:
"\<lbrakk>Field r Int Field r' = {}; Preorder r; Preorder r'\<rbrakk> \<Longrightarrow> Preorder (r Osum r')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Preorder r; Preorder r'\<rbrakk> \<Longrightarrow> Preorder (r \<union>o r')
[PROOF STEP]
unfolding preorder_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Refl r \<and> trans r; Refl r' \<and> trans r'\<rbrakk> \<Longrightarrow> Refl (r \<union>o r') \<and> trans (r \<union>o r')
[PROOF STEP]
using Osum_Refl Osum_trans
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Field ?r \<inter> Field ?r' = {}; Refl ?r; Refl ?r'\<rbrakk> \<Longrightarrow> Refl (?r \<union>o ?r')
\<lbrakk>Field ?r \<inter> Field ?r' = {}; trans ?r; trans ?r'\<rbrakk> \<Longrightarrow> trans (?r \<union>o ?r')

goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Refl r \<and> trans r; Refl r' \<and> trans r'\<rbrakk> \<Longrightarrow> Refl (r \<union>o r') \<and> trans (r \<union>o r')
[PROOF STEP]
by blast


[STATEMENT]
lemma range_subset_lower:
  fixes c :: "'a ::linorder"
  shows "\<lbrakk> {a..b} \<subseteq> {c..d}; x \<in> {a..b} \<rbrakk> \<Longrightarrow> c \<le> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{a..b} \<subseteq> {c..d}; x \<in> {a..b}\<rbrakk> \<Longrightarrow> c \<le> a
[PROOF STEP]
apply (frule (1) subsetD)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{a..b} \<subseteq> {c..d}; x \<in> {a..b}; x \<in> {c..d}\<rbrakk> \<Longrightarrow> c \<le> a
[PROOF STEP]
apply (rule classical)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{a..b} \<subseteq> {c..d}; x \<in> {a..b}; x \<in> {c..d}; \<not> c \<le> a\<rbrakk> \<Longrightarrow> c \<le> a
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mask_out_eq_0:
  "\<lbrakk> idx < 2 ^ sz; sz < LENGTH('a) \<rbrakk> \<Longrightarrow> (of_nat idx :: 'a :: len word) AND NOT(mask sz) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>idx < 2 ^ sz; sz < LENGTH('a)\<rbrakk> \<Longrightarrow> word_of_nat idx AND NOT (mask sz) = 0
[PROOF STEP]
by (simp add: of_nat_power less_mask_eq mask_eq_0_eq_x)


[STATEMENT]
lemma gauss_poly_monic:
  assumes "n > 1"
  shows "monic_poly R (gauss_poly R n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
have "monic_poly R (X [^]\<^bsub>P\<^esub> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic_poly R (X [^]\<^bsub>P\<^esub> n)
[PROOF STEP]
by (intro monic_poly_pow monic_poly_var)
[PROOF STATE]
proof (state)
this:
monic_poly R (X [^]\<^bsub>P\<^esub> n)

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
monic_poly R (X [^]\<^bsub>P\<^esub> n)

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
have "\<ominus>\<^bsub>P\<^esub> X \<in> carrier P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<ominus>\<^bsub>P\<^esub> X \<in> carrier P
[PROOF STEP]
using var_closed
[PROOF STATE]
proof (prove)
using this:
X \<in> carrier P
polynomial (carrier R) X

goal (1 subgoal):
 1. \<ominus>\<^bsub>P\<^esub> X \<in> carrier P
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<ominus>\<^bsub>P\<^esub> X \<in> carrier P

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<ominus>\<^bsub>P\<^esub> X \<in> carrier P

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
have "degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)
[PROOF STEP]
using assms univ_poly_a_inv_degree var_closed
[PROOF STATE]
proof (prove)
using this:
1 < n
?p \<in> carrier P \<Longrightarrow> degree (\<ominus>\<^bsub>P\<^esub> ?p) = degree ?p
X \<in> carrier P
polynomial (carrier R) X

goal (1 subgoal):
 1. degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)
[PROOF STEP]
using degree_var
[PROOF STATE]
proof (prove)
using this:
1 < n
?p \<in> carrier P \<Longrightarrow> degree (\<ominus>\<^bsub>P\<^esub> ?p) = degree ?p
X \<in> carrier P
polynomial (carrier R) X
degree X = 1

goal (1 subgoal):
 1. degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)
[PROOF STEP]
unfolding var_pow_degree
[PROOF STATE]
proof (prove)
using this:
1 < n
?p \<in> carrier P \<Longrightarrow> degree (\<ominus>\<^bsub>P\<^esub> ?p) = degree ?p
X \<in> carrier P
polynomial (carrier R) X
degree X = 1

goal (1 subgoal):
 1. degree (\<ominus>\<^bsub>P\<^esub> X) < n
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
monic_poly R (X [^]\<^bsub>P\<^esub> n)
\<ominus>\<^bsub>P\<^esub> X \<in> carrier P
degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
monic_poly R (X [^]\<^bsub>P\<^esub> n)
\<ominus>\<^bsub>P\<^esub> X \<in> carrier P
degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)

goal (1 subgoal):
 1. monic_poly R (gauss_poly R n)
[PROOF STEP]
unfolding gauss_poly_def a_minus_def
[PROOF STATE]
proof (prove)
using this:
monic_poly R (X [^]\<^bsub>P\<^esub> n)
\<ominus>\<^bsub>P\<^esub> X \<in> carrier P
degree (\<ominus>\<^bsub>P\<^esub> X) < degree (X [^]\<^bsub>P\<^esub> n)

goal (1 subgoal):
 1. monic_poly R (X [^]\<^bsub>P\<^esub> n \<oplus>\<^bsub>P\<^esub> \<ominus>\<^bsub>P\<^esub> X)
[PROOF STEP]
by (intro monic_poly_add_distinct, auto)
[PROOF STATE]
proof (state)
this:
monic_poly R (gauss_poly R n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pair_o_assoc'[simp]:
  assumes [simp]: \<open>compatible F G\<close> \<open>compatible G H\<close> \<open>compatible F H\<close>
  shows \<open>((F; G); H) \<circ> assoc' = (F; (G; H))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((F;G);H) \<circ> assoc' = (F;(G;H))
[PROOF STEP]
proof (rule tensor_extensionality3)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. register (((F;G);H) \<circ> assoc')
 2. register (F;(G;H))
 3. \<And>f g h. (((F;G);H) \<circ> assoc') (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h) = (F;(G;H)) (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h)
[PROOF STEP]
show \<open>register (((F; G); H) \<circ> assoc')\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. register (((F;G);H) \<circ> assoc')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
register (((F;G);H) \<circ> assoc')

goal (2 subgoals):
 1. register (F;(G;H))
 2. \<And>f g h. (((F;G);H) \<circ> assoc') (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h) = (F;(G;H)) (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h)
[PROOF STEP]
show \<open>register (F; (G; H))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. register (F;(G;H))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
register (F;(G;H))

goal (1 subgoal):
 1. \<And>f g h. (((F;G);H) \<circ> assoc') (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h) = (F;(G;H)) (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h)
[PROOF STEP]
show \<open>(((F; G); H) \<circ> assoc') (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h) = (F; (G; H)) (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h)\<close> for f g h
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (((F;G);H) \<circ> assoc') (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h) = (F;(G;H)) (f \<otimes>\<^sub>u g \<otimes>\<^sub>u h)
[PROOF STEP]
by (simp add: register_pair_apply assoc'_apply comp_update_assoc)
[PROOF STATE]
proof (state)
this:
(((F;G);H) \<circ> assoc') (?f \<otimes>\<^sub>u ?g \<otimes>\<^sub>u ?h) = (F;(G;H)) (?f \<otimes>\<^sub>u ?g \<otimes>\<^sub>u ?h)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma connex_union:
  assumes "connex X (\<sqsubseteq>)" and "connex Y (\<sqsubseteq>)" and "\<forall>x \<in> X. \<forall>y \<in> Y. x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
  shows "connex (X\<union>Y) (\<sqsubseteq>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connex (X \<union> Y) (\<sqsubseteq>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
connex X (\<sqsubseteq>)
connex Y (\<sqsubseteq>)
\<forall>x\<in>X. \<forall>y\<in>Y. x \<sqsubseteq> y \<or> y \<sqsubseteq> x

goal (1 subgoal):
 1. connex (X \<union> Y) (\<sqsubseteq>)
[PROOF STEP]
by (auto simp: connex_def)


[STATEMENT]
lemma div_diff_mult_self1: "
  (n - k * m) div m = n div m - (k::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n - k * m) div m = n div m - k
[PROOF STEP]
apply (case_tac "m = 0", simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<noteq> 0 \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply (case_tac "n < k * m")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m \<noteq> 0; n < k * m\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
 2. \<lbrakk>m \<noteq> 0; \<not> n < k * m\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n < k * m\<rbrakk> \<Longrightarrow> n div m \<le> k
 2. \<lbrakk>m \<noteq> 0; \<not> n < k * m\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply (drule div_le_mono[OF less_imp_le, of n _ m])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n div m \<le> k * m div m\<rbrakk> \<Longrightarrow> n div m \<le> k
 2. \<lbrakk>m \<noteq> 0; \<not> n < k * m\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m \<noteq> 0; \<not> n < k * m\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply (simp add: linorder_not_less)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> (n - k * m) div m = n div m - k
[PROOF STEP]
apply (rule iffD1[OF mult_cancel1_gr0[where k=m]], assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> m * ((n - k * m) div m) = m * (n div m - k)
[PROOF STEP]
apply (subst diff_mult_distrib2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> m * ((n - k * m) div m) = m * (n div m) - m * k
[PROOF STEP]
apply (simp only: minus_mod_eq_mult_div [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> n - k * m - (n - k * m) mod m = n - n mod m - m * k
[PROOF STEP]
apply (simp only: diff_commute[of _ "k*m"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> n - (n - k * m) mod m - k * m = n - n mod m - m * k
[PROOF STEP]
apply (simp only: mult.commute[of m])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k * m \<le> n\<rbrakk> \<Longrightarrow> n - (n - k * m) mod m - k * m = n - n mod m - k * m
[PROOF STEP]
apply (simp only: mod_diff_mult_self1)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma finite_conj2:
  "\<lbrakk> finite A; finite B \<rbrakk> \<Longrightarrow> finite ({(S,S'). S: A \<and> S' : B})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> finite {(S, S'). S \<in> A \<and> S' \<in> B}
[PROOF STEP]
by auto


[STATEMENT]
lemma (in Group) l_mult_eqn1:"\<lbrakk>a \<in> carrier G; x \<in> carrier G;  y \<in> carrier G;
        (\<rho> a) \<cdot> x = (\<rho> a) \<cdot> y\<rbrakk>  \<Longrightarrow> x = y "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier G; x \<in> carrier G; y \<in> carrier G; \<rho> a \<cdot> x = \<rho> a \<cdot> y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
by (frule i_closed[of "a"], rule l_div_eqn[of "\<rho> a" "x" "y"], assumption+)


[STATEMENT]
lemma set_spmf_spmf_of_pmf [simp]: "set_spmf (spmf_of_pmf p) = set_pmf p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_spmf (spmf_of_pmf p) = set_pmf p
[PROOF STEP]
by(auto simp add: spmf_of_pmf_def set_spmf_def bind_image o_def)


[STATEMENT]
lemma Lambert_W_eq_minus_exp_minus1 [simp]: "Lambert_W (-exp (-1)) = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Lambert_W (- exp (- 1)) = - 1
[PROOF STEP]
by (rule Lambert_W_eqI) auto


[STATEMENT]
lemma (in heapstruct) change_key_op_invar:
      "\<lbrakk>heap_invar h; valid h i\<rbrakk> \<Longrightarrow> change_key_op i v h \<le> SPEC heap_invar"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>heap_invar h; valid h i\<rbrakk> \<Longrightarrow> change_key_op i v h \<le> SPEC heap_invar
[PROOF STEP]
unfolding change_key_op_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>heap_invar h; valid h i\<rbrakk> \<Longrightarrow> ASSERT (valid h i) \<bind> (\<lambda>_. update_op h i v \<bind> (\<lambda>h. repair_op h i)) \<le> SPEC heap_invar
[PROOF STEP]
apply (refine_vcg)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>heap_invar h; valid h i; valid h i; x = update h i v\<rbrakk> \<Longrightarrow> repair_op x i \<le> SPEC heap_invar
[PROOF STEP]
apply hypsubst
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>heap_invar h; valid h i; valid h i\<rbrakk> \<Longrightarrow> repair_op (update h i v) i \<le> SPEC heap_invar
[PROOF STEP]
apply refine_vcg
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. \<lbrakk>heap_invar h; valid h i; valid h i; heap_invar xa \<and> \<alpha> xa = \<alpha> (update h i v) \<and> length xa = length h\<rbrakk> \<Longrightarrow> heap_invar xa
[PROOF STEP]
by (auto simp: sink_invar_incr)


[STATEMENT]
lemma continuous_Lambert_W [continuous_intros]:
  assumes "continuous F f" "f (Lim F (\<lambda>x. x)) > -exp (-1) \<or> eventually (\<lambda>x. f x \<ge> -exp (-1)) F"
  shows   "continuous F (\<lambda>x. Lambert_W (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous F (\<lambda>x. Lambert_W (f x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous F f
- exp (- 1) < f (Lim F (\<lambda>x. x)) \<or> (\<forall>\<^sub>F x in F. - exp (- 1) \<le> f x)

goal (1 subgoal):
 1. continuous F (\<lambda>x. Lambert_W (f x))
[PROOF STEP]
unfolding continuous_def
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> f (Lim F (\<lambda>x. x))) F
- exp (- 1) < f (Lim F (\<lambda>x. x)) \<or> (\<forall>\<^sub>F x in F. - exp (- 1) \<le> f x)

goal (1 subgoal):
 1. ((\<lambda>x. Lambert_W (f x)) \<longlongrightarrow> Lambert_W (f (Lim F (\<lambda>x. x)))) F
[PROOF STEP]
by (intro tendsto_Lambert_W) auto


[STATEMENT]
lemma orbit_perm_swap: "orbit (perm_swap a b f) x = (a \<rightleftharpoons>\<^sub>F b) ` orbit f ((a \<rightleftharpoons>\<^sub>F b) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orbit (perm_swap a b f) x = (a \<rightleftharpoons>\<^sub>F b) ` orbit f ((a \<rightleftharpoons>\<^sub>F b) x)
[PROOF STEP]
by (auto simp: orbit_altdef funpow_perm_swap) (auto simp: perm_swap_def)


[STATEMENT]
lemma "x + (y + (y + (y + (-y + -x)))) = y + (0::int) + y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + (y + (y + (y + (- y + - x)))) = y + 0 + y
[PROOF STEP]
by simp


[STATEMENT]
lemma strict_order_letter_less:
  assumes "strict_order r"
  shows "strict_order (letter_less r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_order (letter_less r)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
strict_order r

goal (1 subgoal):
 1. strict_order (letter_less r)
[PROOF STEP]
unfolding irrefl_def trans_def letter_less_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>a. (a, a) \<notin> r) \<and> (\<forall>x y z. (x, y) \<in> r \<longrightarrow> (y, z) \<in> r \<longrightarrow> (x, z) \<in> r)

goal (1 subgoal):
 1. (\<forall>a. (a, a) \<notin> {(a, b). (snd a, snd b) \<in> r}) \<and> (\<forall>x y z. (x, y) \<in> {(a, b). (snd a, snd b) \<in> r} \<longrightarrow> (y, z) \<in> {(a, b). (snd a, snd b) \<in> r} \<longrightarrow> (x, z) \<in> {(a, b). (snd a, snd b) \<in> r})
[PROOF STEP]
by fast


[STATEMENT]
lemma strict_mono_o: "strict_mono r \<Longrightarrow> strict_mono s \<Longrightarrow> strict_mono (r \<circ> s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>strict_mono r; strict_mono s\<rbrakk> \<Longrightarrow> strict_mono (r \<circ> s)
[PROOF STEP]
unfolding strict_mono_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x y. x < y \<longrightarrow> r x < r y; \<forall>x y. x < y \<longrightarrow> s x < s y\<rbrakk> \<Longrightarrow> \<forall>x y. x < y \<longrightarrow> (r \<circ> s) x < (r \<circ> s) y
[PROOF STEP]
by simp


[STATEMENT]
lemma vec_to_iarray_exists:
shows "(\<exists>b. A $ b \<noteq> 0) = IArray.exists (\<lambda>b. (vec_to_iarray A) !! b \<noteq> 0) (IArray[0..<IArray.length (vec_to_iarray A)])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>b. A $ b \<noteq> (0::'b)) = IArray.exists (\<lambda>b. vec_to_iarray A !! b \<noteq> (0::'b)) (IArray [0..<IArray.length (vec_to_iarray A)])
[PROOF STEP]
proof (unfold IArray.exists_def length_vec_to_iarray, auto simp del: IArray.sub_def)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>b. A $ b \<noteq> (0::'b) \<Longrightarrow> \<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> (0::'b)
 2. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
fix b
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>b. A $ b \<noteq> (0::'b) \<Longrightarrow> \<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> (0::'b)
 2. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
assume Ab: "A $ b \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $ b \<noteq> (0::'b)

goal (2 subgoals):
 1. \<And>b. A $ b \<noteq> (0::'b) \<Longrightarrow> \<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> (0::'b)
 2. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
show "\<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> (0::'b)
[PROOF STEP]
by (rule bexI[of _ "to_nat b"], unfold vec_to_iarray_nth', auto simp add: Ab to_nat_less_card[of b])
[PROOF STATE]
proof (state)
this:
\<exists>b\<in>{0..<CARD('a)}. vec_to_iarray A !! b \<noteq> (0::'b)

goal (1 subgoal):
 1. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
fix b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
assume b: "b < CARD('a)" and Ab_vec: "vec_to_iarray A !! b \<noteq> 0"
[PROOF STATE]
proof (state)
this:
b < CARD('a)
vec_to_iarray A !! b \<noteq> (0::'b)

goal (1 subgoal):
 1. \<And>b. \<lbrakk>b < CARD('a); vec_to_iarray A !! b \<noteq> (0::'b)\<rbrakk> \<Longrightarrow> \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
show "\<exists>b. A $ b \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. A $ b \<noteq> (0::'b)
[PROOF STEP]
by (rule exI[of _ "from_nat b"], metis Ab_vec vec_to_iarray_nth[OF b])
[PROOF STATE]
proof (state)
this:
\<exists>b. A $ b \<noteq> (0::'b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma stable_rank_unique:
  assumes "stable_rank x i"
  assumes "stable_rank x j"
  shows "i = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
stable_rank x i
stable_rank x j
[PROOF STEP]
obtain n m where "\<And>n'. n' \<ge> n \<Longrightarrow> rank x n' = Some i"
    and "\<And>m'. m' \<ge> m \<Longrightarrow> rank x m' = Some j"
[PROOF STATE]
proof (prove)
using this:
stable_rank x i
stable_rank x j

goal (1 subgoal):
 1. (\<And>n m. \<lbrakk>\<And>n'. n \<le> n' \<Longrightarrow> rank x n' = Some i; \<And>m'. m \<le> m' \<Longrightarrow> rank x m' = Some j\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding stable_rank_def MOST_nat_le
[PROOF STATE]
proof (prove)
using this:
\<exists>m. \<forall>n\<ge>m. rank x n = Some i
\<exists>m. \<forall>n\<ge>m. rank x n = Some j

goal (1 subgoal):
 1. (\<And>n m. \<lbrakk>\<And>n'. n \<le> n' \<Longrightarrow> rank x n' = Some i; \<And>m'. m \<le> m' \<Longrightarrow> rank x m' = Some j\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n \<le> ?n' \<Longrightarrow> rank x ?n' = Some i
m \<le> ?m' \<Longrightarrow> rank x ?m' = Some j

goal (1 subgoal):
 1. i = j
[PROOF STEP]
hence "rank x (n + m) = Some i" and "rank x (n + m) = Some j"
[PROOF STATE]
proof (prove)
using this:
n \<le> ?n' \<Longrightarrow> rank x ?n' = Some i
m \<le> ?m' \<Longrightarrow> rank x ?m' = Some j

goal (1 subgoal):
 1. rank x (n + m) = Some i &&& rank x (n + m) = Some j
[PROOF STEP]
by (metis add.commute le_add1)+
[PROOF STATE]
proof (state)
this:
rank x (n + m) = Some i
rank x (n + m) = Some j

goal (1 subgoal):
 1. i = j
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
rank x (n + m) = Some i
rank x (n + m) = Some j

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Suc_i_mod_s_0_1:"\<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s = s - Suc 0\<rbrakk>
        \<Longrightarrow> Suc i mod s = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s = s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = 0
[PROOF STEP]
apply (insert div_mult_mod_eq [of "i" "s", THEN sym])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s = s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i mod s = 0
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s = s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = 0
[PROOF STEP]
apply (thin_tac "i mod s = s - Suc 0")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = 0
[PROOF STEP]
apply (subgoal_tac "Suc i mod s = Suc (i div s * s + s - Suc 0) mod s")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0; Suc i mod s = Suc (i div s * s + s - Suc 0) mod s\<rbrakk> \<Longrightarrow> Suc i mod s = 0
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i div s * s + s - Suc 0) mod s
[PROOF STEP]
apply (thin_tac "i = i div s * s + s - Suc 0", simp del: add_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i div s * s + s - Suc 0) mod s
[PROOF STEP]
apply (subgoal_tac "Suc (i div s * s + s - Suc 0) mod s = (i div s * s + s) mod s")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0; Suc (i div s * s + s - Suc 0) mod s = (i div s * s + s) mod s\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i div s * s + s - Suc 0) mod s
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc (i div s * s + s - Suc 0) mod s = (i div s * s + s) mod s
[PROOF STEP]
apply (simp del: add_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc (i div s * s + s - Suc 0) mod s = (i div s * s + s) mod s
[PROOF STEP]
apply (subgoal_tac "Suc (i div s * s + s - Suc 0) = i div s * s + s")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0; Suc (i div s * s + s - Suc 0) = i div s * s + s\<rbrakk> \<Longrightarrow> Suc (i div s * s + s - Suc 0) mod s = (i div s * s + s) mod s
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc (i div s * s + s - Suc 0) = i div s * s + s
[PROOF STEP]
apply (simp del: add_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i = i div s * s + s - Suc 0\<rbrakk> \<Longrightarrow> Suc (i div s * s + s - Suc 0) = i div s * s + s
[PROOF STEP]
apply (rule Suc_pred [of "i div s * s + s"], simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done