[STATEMENT]
lemma (in domain) finite_domain_units:
  assumes "finite (carrier R)"
  shows "Units R = carrier R - {\<zero>}" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Units R = carrier R - {\<zero>}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Units R \<subseteq> carrier R - {\<zero>}
 2. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
have "Units R \<subseteq> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Units R \<subseteq> carrier R
[PROOF STEP]
by (simp add:Units_def)
[PROOF STATE]
proof (state)
this:
Units R \<subseteq> carrier R

goal (2 subgoals):
 1. Units R \<subseteq> carrier R - {\<zero>}
 2. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Units R \<subseteq> carrier R

goal (2 subgoals):
 1. Units R \<subseteq> carrier R - {\<zero>}
 2. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
have "\<zero> \<notin> Units R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<zero> \<notin> Units R
[PROOF STEP]
by (meson zero_is_prime(1) primeE)
[PROOF STATE]
proof (state)
this:
\<zero> \<notin> Units R

goal (2 subgoals):
 1. Units R \<subseteq> carrier R - {\<zero>}
 2. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Units R \<subseteq> carrier R
\<zero> \<notin> Units R
[PROOF STEP]
show "Units R \<subseteq> carrier R - {\<zero>}"
[PROOF STATE]
proof (prove)
using this:
Units R \<subseteq> carrier R
\<zero> \<notin> Units R

goal (1 subgoal):
 1. Units R \<subseteq> carrier R - {\<zero>}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Units R \<subseteq> carrier R - {\<zero>}

goal (1 subgoal):
 1. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
have "x \<in> Units R" if a: "x \<in> carrier R - {\<zero>}" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
have x_carr: "x \<in> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> carrier R
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier R - {\<zero>}

goal (1 subgoal):
 1. x \<in> carrier R
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> carrier R

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
define f where "f = (\<lambda>y. y \<otimes>\<^bsub>R\<^esub> x)"
[PROOF STATE]
proof (state)
this:
f = (\<lambda>y. y \<otimes> x)

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
have "inj_on f (carrier R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f (carrier R)
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>y. y \<otimes> x) (carrier R)
[PROOF STEP]
by (rule inj_onI, metis DiffD1 DiffD2 a m_rcancel insertI1)
[PROOF STATE]
proof (state)
this:
inj_on f (carrier R)

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
hence "card (carrier R) = card (f ` carrier R)"
[PROOF STATE]
proof (prove)
using this:
inj_on f (carrier R)

goal (1 subgoal):
 1. card (carrier R) = card (f ` carrier R)
[PROOF STEP]
by (metis card_image)
[PROOF STATE]
proof (state)
this:
card (carrier R) = card (f ` carrier R)

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card (carrier R) = card (f ` carrier R)

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
have "f ` carrier R \<subseteq> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` carrier R \<subseteq> carrier R
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>y. y \<otimes> x) ` carrier R \<subseteq> carrier R
[PROOF STEP]
by (rule image_subsetI, simp add: ring.ring_simprules x_carr)
[PROOF STATE]
proof (state)
this:
f ` carrier R \<subseteq> carrier R

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card (carrier R) = card (f ` carrier R)
f ` carrier R \<subseteq> carrier R
[PROOF STEP]
have "f ` carrier R = carrier R"
[PROOF STATE]
proof (prove)
using this:
card (carrier R) = card (f ` carrier R)
f ` carrier R \<subseteq> carrier R

goal (1 subgoal):
 1. f ` carrier R = carrier R
[PROOF STEP]
using card_subset_eq assms
[PROOF STATE]
proof (prove)
using this:
card (carrier R) = card (f ` carrier R)
f ` carrier R \<subseteq> carrier R
\<lbrakk>finite ?B; ?A \<subseteq> ?B; card ?A = card ?B\<rbrakk> \<Longrightarrow> ?A = ?B
finite (carrier R)

goal (1 subgoal):
 1. f ` carrier R = carrier R
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
f ` carrier R = carrier R

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f ` carrier R = carrier R

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
have "\<one>\<^bsub>R\<^esub> \<in> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one> \<in> carrier R
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<one> \<in> carrier R

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f ` carrier R = carrier R
\<one> \<in> carrier R
[PROOF STEP]
have "\<exists>y \<in> carrier R. f y = \<one>\<^bsub>R\<^esub>"
[PROOF STATE]
proof (prove)
using this:
f ` carrier R = carrier R
\<one> \<in> carrier R

goal (1 subgoal):
 1. \<exists>y\<in>carrier R. f y = \<one>
[PROOF STEP]
by (metis image_iff)
[PROOF STATE]
proof (state)
this:
\<exists>y\<in>carrier R. f y = \<one>

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>y\<in>carrier R. f y = \<one>
[PROOF STEP]
obtain y
      where y_carrier: "y \<in> carrier R"
        and y_left_inv: "y \<otimes>\<^bsub>R\<^esub> x = \<one>\<^bsub>R\<^esub>"
[PROOF STATE]
proof (prove)
using this:
\<exists>y\<in>carrier R. f y = \<one>

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>y \<in> carrier R; y \<otimes> x = \<one>\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using f_def
[PROOF STATE]
proof (prove)
using this:
\<exists>y\<in>carrier R. f y = \<one>
f = (\<lambda>y. y \<otimes> x)

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>y \<in> carrier R; y \<otimes> x = \<one>\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
y \<in> carrier R
y \<otimes> x = \<one>

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
hence  y_right_inv: "x \<otimes>\<^bsub>R\<^esub> y = \<one>\<^bsub>R\<^esub>"
[PROOF STATE]
proof (prove)
using this:
y \<in> carrier R
y \<otimes> x = \<one>

goal (1 subgoal):
 1. x \<otimes> y = \<one>
[PROOF STEP]
by (metis DiffD1 a cring_simprules(14))
[PROOF STATE]
proof (state)
this:
x \<otimes> y = \<one>

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
show "x \<in> Units R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
using y_carrier y_left_inv y_right_inv
[PROOF STATE]
proof (prove)
using this:
y \<in> carrier R
y \<otimes> x = \<one>
x \<otimes> y = \<one>

goal (1 subgoal):
 1. x \<in> Units R
[PROOF STEP]
by (metis DiffD1 a divides_one factor_def)
[PROOF STATE]
proof (state)
this:
x \<in> Units R

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> carrier R - {\<zero>} \<Longrightarrow> ?x \<in> Units R

goal (1 subgoal):
 1. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
thus "?rhs \<subseteq> ?lhs"
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier R - {\<zero>} \<Longrightarrow> ?x \<in> Units R

goal (1 subgoal):
 1. carrier R - {\<zero>} \<subseteq> Units R
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
carrier R - {\<zero>} \<subseteq> Units R

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma min_max_var_value_simps [simp, intro!]:
  "min_var_value < max_var_value"
  "min_var_value < 0"
  "min_var_value \<le> 0"
  "max_var_value > 0"
  "max_var_value \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (min_var_value < max_var_value &&& min_var_value < 0) &&& min_var_value \<le> 0 &&& 0 < max_var_value &&& 0 \<le> max_var_value
[PROOF STEP]
by (simp_all add: min_var_value_def max_var_value_def)


[STATEMENT]
lemma Monotonic_inf [closure]:
  assumes "Monotonic P" "Monotonic Q"
  shows "Monotonic (\<lambda> X. P(X) \<sqinter> Q(X))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Monotonic (\<lambda>X. P X \<sqinter> Q X)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Monotonic P
Monotonic Q

goal (1 subgoal):
 1. Monotonic (\<lambda>X. P X \<sqinter> Q X)
[PROOF STEP]
by (simp add: mono_def, rel_auto)


[STATEMENT]
lemma stabilizer_right_differenceset_invariant:
  assumes "b \<in> G" and "A \<subseteq> G"
  shows "stabilizer (differenceset A {b}) = stabilizer A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stabilizer (differenceset A {b}) = stabilizer A
[PROOF STEP]
using assms minusset_eq stabilizer_right_sumset_invariant
[PROOF STATE]
proof (prove)
using this:
b \<in> G
A \<subseteq> G
minusset ?A = local.inverse ` (?A \<inter> G)
\<lbrakk>?a \<in> G; ?A \<subseteq> G\<rbrakk> \<Longrightarrow> stabilizer (sumset ?A {?a}) = stabilizer ?A

goal (1 subgoal):
 1. stabilizer (differenceset A {b}) = stabilizer A
[PROOF STEP]
by auto


[STATEMENT]
lemma preal_trans_lemma:
  assumes "x + y1 = x1 + y" and "x + y2 = x2 + y"
  shows "x1 + y2 = x2 + (y1::preal)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x1 + y2 = x2 + y1
[PROOF STEP]
by (metis add.left_commute assms preal_add_left_cancel)


[STATEMENT]
lemma sum_minus[simp]:
fixes a :: nat
shows "sum f {a ..< a + b} = sum (%x. f (a + x)) {..< b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {a..<a + b} = (\<Sum>x<b. f (a + x))
[PROOF STEP]
using sum.reindex[of "(+) a" "{..< b}" f]
[PROOF STATE]
proof (prove)
using this:
inj_on ((+) a) {..<b} \<Longrightarrow> sum f ((+) a ` {..<b}) = sum (f \<circ> (+) a) {..<b}

goal (1 subgoal):
 1. sum f {a..<a + b} = (\<Sum>x<b. f (a + x))
[PROOF STEP]
by auto


[STATEMENT]
lemma bf_xor_alt: "bf_xor a b = (bf_ite a (bf_not b) b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bf_xor a b = bf_ite a (bf_not b) b
[PROOF STEP]
(* two application version *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bf_xor a b = bf_ite a (bf_not b) b
[PROOF STEP]
unfolding bf_xor_def bf_biimp_def bf_not_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bf_ite (bf_ite a b (bf_ite b bf_False bf_True)) bf_False bf_True = bf_ite a (bf_ite b bf_False bf_True) b
[PROOF STEP]
unfolding bf_ite_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>l. if if a l then b l else if b l then False else True then False else True) = (\<lambda>l. if a l then if b l then False else True else b l)
[PROOF STEP]
by simp


[STATEMENT]
lemma finite_SSuffixes:
  shows "finite (SSuffixes s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (SSuffixes s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (SSuffixes s)
[PROOF STEP]
have "SSuffixes s \<subseteq> Suffixes s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. SSuffixes s \<subseteq> Suffixes s
[PROOF STEP]
unfolding strict_suffix_def suffix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {s'. (\<exists>zs. s = zs @ s') \<and> s' \<noteq> s} \<subseteq> {s'. \<exists>zs. s = zs @ s'}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
SSuffixes s \<subseteq> Suffixes s

goal (1 subgoal):
 1. finite (SSuffixes s)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
SSuffixes s \<subseteq> Suffixes s
[PROOF STEP]
show "finite (SSuffixes s)"
[PROOF STATE]
proof (prove)
using this:
SSuffixes s \<subseteq> Suffixes s

goal (1 subgoal):
 1. finite (SSuffixes s)
[PROOF STEP]
using finite_Suffixes finite_subset
[PROOF STATE]
proof (prove)
using this:
SSuffixes s \<subseteq> Suffixes s
finite (Suffixes ?s)
\<lbrakk>?A \<subseteq> ?B; finite ?B\<rbrakk> \<Longrightarrow> finite ?A

goal (1 subgoal):
 1. finite (SSuffixes s)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (SSuffixes s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma representation_extend:
  assumes basis: "independent basis" and v: "v \<in> span basis'" and basis': "basis' \<subseteq> basis"
  shows "representation basis v = representation basis' v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. representation basis v = representation basis' v
[PROOF STEP]
proof (rule representation_eqI[OF basis])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. v \<in> span basis
 2. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 3. finite {b. representation basis' v b \<noteq> (0::'a)}
 4. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show v': "v \<in> span basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> span basis
[PROOF STEP]
using span_mono[OF basis'] v
[PROOF STATE]
proof (prove)
using this:
span basis' \<subseteq> span basis
v \<in> span basis'

goal (1 subgoal):
 1. v \<in> span basis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> span basis

goal (3 subgoals):
 1. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis' v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
have *: "independent basis'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. independent basis'
[PROOF STEP]
using basis' basis
[PROOF STATE]
proof (prove)
using this:
basis' \<subseteq> basis
independent basis

goal (1 subgoal):
 1. independent basis'
[PROOF STEP]
by (auto intro: dependent_mono)
[PROOF STATE]
proof (state)
this:
independent basis'

goal (3 subgoals):
 1. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis' v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "representation basis' v b \<noteq> 0 \<Longrightarrow> b \<in> basis" for b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
[PROOF STEP]
using representation_ne_zero basis'
[PROOF STATE]
proof (prove)
using this:
representation ?basis ?v ?b \<noteq> (0::'a) \<Longrightarrow> ?b \<in> ?basis
basis' \<subseteq> basis

goal (1 subgoal):
 1. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
representation basis' v ?b \<noteq> (0::'a) \<Longrightarrow> ?b \<in> basis

goal (2 subgoals):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
 2. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "finite {b. representation basis' v b \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
[PROOF STEP]
using finite_representation
[PROOF STATE]
proof (prove)
using this:
finite {b. representation ?basis ?v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
finite {b. representation basis' v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "(\<Sum>b | representation basis' v b \<noteq> 0. representation basis' v b *s b) = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
using sum_nonzero_representation_eq[OF * v]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v

goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closed_Un [continuous_intros, intro]: "closed S \<Longrightarrow> closed T \<Longrightarrow> closed (S \<union> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed S; closed T\<rbrakk> \<Longrightarrow> closed (S \<union> T)
[PROOF STEP]
unfolding closed_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>open (- S); open (- T)\<rbrakk> \<Longrightarrow> open (- (S \<union> T))
[PROOF STEP]
by auto


[STATEMENT]
lemma wf_SN:
  shows "(wfP r^--1) = (SN relset)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wfP (\<rightarrow>)\<inverse>\<inverse> = SN {(x, y). x \<rightarrow> y}
[PROOF STEP]
unfolding wf_converse wf_iff_no_infinite_down_chain SN_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<nexists>f. \<forall>i. (f (Suc i), f i) \<in> {(x, y). x \<rightarrow> y}\<inverse>) = (\<nexists>f. f 0 \<in> UNIV \<and> (\<forall>i. (f i, f (Suc i)) \<in> {(x, y). x \<rightarrow> y}))
[PROOF STEP]
by auto


[STATEMENT]
lemma left_unique_Grp [iff]:
  "left_unique (BNF_Def.Grp A f) \<longleftrightarrow> inj_on f A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. left_unique (BNF_Def.Grp A f) = inj_on f A
[PROOF STEP]
unfolding Grp_def left_unique_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x y z. z = f x \<and> x \<in> A \<longrightarrow> z = f y \<and> y \<in> A \<longrightarrow> x = y) = inj_on f A
[PROOF STEP]
by(auto simp add: inj_on_def)


[STATEMENT]
lemma pred_sum_conj [simp]:
  shows pred_sum_conj1: "\<And>P Q R. pred_sum (\<lambda>x. P x \<and> Q x) R = (\<lambda>x. pred_sum P R x \<and> pred_sum Q R x)"
  and pred_sum_conj2: "\<And>P Q R. pred_sum P (\<lambda>x. Q x \<and> R x) = (\<lambda>x. pred_sum P Q x \<and> pred_sum P R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>P Q R. pred_sum (\<lambda>x. P x \<and> Q x) R = (\<lambda>x. pred_sum P R x \<and> pred_sum Q R x)) &&& (\<And>P Q R. pred_sum P (\<lambda>x. Q x \<and> R x) = (\<lambda>x. pred_sum P Q x \<and> pred_sum P R x))
[PROOF STEP]
by(auto simp add: pred_sum.simps fun_eq_iff)


[STATEMENT]
lemma poly_y_minus_x_0[simp]: "poly_y_minus_x 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_y_minus_x 0 = 0
[PROOF STEP]
by (simp add: poly_y_minus_x_def)


[STATEMENT]
lemma mk_or_atoms:
  "atoms_ltln (mk_or \<phi> \<psi>) \<subseteq> atoms_ltln \<phi> \<union> atoms_ltln \<psi>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. atoms_ltln (mk_or \<phi> \<psi>) \<subseteq> atoms_ltln \<phi> \<union> atoms_ltln \<psi>
[PROOF STEP]
by (auto simp: mk_or_def split: ltln.splits)


[STATEMENT]
lemma card_eq_length_impl_distinct:
  "\<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk>
    \<Longrightarrow> distinct_relations t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
proof(induction n arbitrary: t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. \<lbrakk>finite (relations t); height t \<le> 0; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
finite (relations t)
height t \<le> 0
Finite_Set.card (relations t) = length (inorder t)

goal (2 subgoals):
 1. \<And>t. \<lbrakk>finite (relations t); height t \<le> 0; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite (relations t)
height t \<le> 0
Finite_Set.card (relations t) = length (inorder t)
[PROOF STEP]
obtain r where "Relation r = t"
[PROOF STATE]
proof (prove)
using this:
finite (relations t)
height t \<le> 0
Finite_Set.card (relations t) = length (inorder t)

goal (1 subgoal):
 1. (\<And>r. Relation r = t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using height_0_rel
[PROOF STATE]
proof (prove)
using this:
finite (relations t)
height t \<le> 0
Finite_Set.card (relations t) = length (inorder t)
height ?t = 0 \<Longrightarrow> \<exists>r. ?t = Relation r

goal (1 subgoal):
 1. (\<And>r. Relation r = t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Relation r = t

goal (2 subgoals):
 1. \<And>t. \<lbrakk>finite (relations t); height t \<le> 0; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Relation r = t
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Relation r = t

goal (1 subgoal):
 1. distinct_relations t
[PROOF STEP]
using distinct_relations_def
[PROOF STATE]
proof (prove)
using this:
Relation r = t
distinct_relations ?t = distinct (inorder ?t)

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

goal (1 subgoal):
 1. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations t)
height t \<le> Suc n
Finite_Set.card (relations t) = length (inorder t)

goal (1 subgoal):
 1. \<And>n t. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations t)
height t \<le> Suc n
Finite_Set.card (relations t) = length (inorder t)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations t)
height t \<le> Suc n
Finite_Set.card (relations t) = length (inorder t)

goal (1 subgoal):
 1. distinct_relations t
[PROOF STEP]
proof(cases "height t = Suc n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
height t = Suc n

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
height t = Suc n
[PROOF STEP]
have "0 < height t"
[PROOF STATE]
proof (prove)
using this:
height t = Suc n

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

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < height t
[PROOF STEP]
obtain l r where join[simp]: "Join l r = t"
[PROOF STATE]
proof (prove)
using this:
0 < height t

goal (1 subgoal):
 1. (\<And>l r. Join l r = t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using height_gt_0_join
[PROOF STATE]
proof (prove)
using this:
0 < height t
0 < height ?t \<Longrightarrow> \<exists>l r. ?t = Join l r

goal (1 subgoal):
 1. (\<And>l r. Join l r = t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Join l r = t

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Join l r = t
[PROOF STEP]
have 0: "finite (relations l) \<and> finite (relations r)"
[PROOF STATE]
proof (prove)
using this:
Join l r = t

goal (1 subgoal):
 1. finite (relations l) \<and> finite (relations r)
[PROOF STEP]
using Suc.prems(1) finite_trans
[PROOF STATE]
proof (prove)
using this:
Join l r = t
finite (relations t)
finite (relations (Join ?l ?r)) \<Longrightarrow> finite (relations ?l) \<and> finite (relations ?r)

goal (1 subgoal):
 1. finite (relations l) \<and> finite (relations r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (relations l) \<and> finite (relations r)

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have 1: "height l \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height l \<le> n
[PROOF STEP]
using True join
[PROOF STATE]
proof (prove)
using this:
height t = Suc n
Join l r = t

goal (1 subgoal):
 1. height l \<le> n
[PROOF STEP]
by (metis height_decr_l less_Suc_eq_le)
[PROOF STATE]
proof (state)
this:
height l \<le> n

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have 2: "height r \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height r \<le> n
[PROOF STEP]
using True join
[PROOF STATE]
proof (prove)
using this:
height t = Suc n
Join l r = t

goal (1 subgoal):
 1. height r \<le> n
[PROOF STEP]
by (metis height_decr_r less_Suc_eq_le)
[PROOF STATE]
proof (state)
this:
height r \<le> n

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have "Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r)
              = Finite_Set.card (relations l) + Finite_Set.card (relations r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
[PROOF STEP]
using card_Un_Int join 0
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; finite ?B\<rbrakk> \<Longrightarrow> Finite_Set.card ?A + Finite_Set.card ?B = Finite_Set.card (?A \<union> ?B) + Finite_Set.card (?A \<inter> ?B)
Join l r = t
finite (relations l) \<and> finite (relations r)

goal (1 subgoal):
 1. Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
[PROOF STEP]
by (metis JoinTree.joinTree.simps(16))
[PROOF STATE]
proof (state)
this:
Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
[PROOF STEP]
have "Finite_Set.card (relations t)
              = Finite_Set.card (relations l) + Finite_Set.card (relations r)"
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)

goal (1 subgoal):
 1. Finite_Set.card (relations t) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
[PROOF STEP]
using Suc.prems(1,3)
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations t) + Finite_Set.card (relations l \<inter> relations r) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
finite (relations t)
Finite_Set.card (relations t) = length (inorder t)

goal (1 subgoal):
 1. Finite_Set.card (relations t) = Finite_Set.card (relations l) + Finite_Set.card (relations r)
[PROOF STEP]
by (simp add: card_eq_length_impl_disjunct)
[PROOF STATE]
proof (state)
this:
Finite_Set.card (relations t) = Finite_Set.card (relations l) + Finite_Set.card (relations r)

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have "Finite_Set.card (relations l) = length (inorder l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Finite_Set.card (relations l) = length (inorder l)
[PROOF STEP]
using Suc.prems(1,3) card_eq_length_trans_l join
[PROOF STATE]
proof (prove)
using this:
finite (relations t)
Finite_Set.card (relations t) = length (inorder t)
\<lbrakk>finite (relations (Join ?l ?r)); Finite_Set.card (relations (Join ?l ?r)) = length (inorder (Join ?l ?r))\<rbrakk> \<Longrightarrow> Finite_Set.card (relations ?l) = length (inorder ?l)
Join l r = t

goal (1 subgoal):
 1. Finite_Set.card (relations l) = length (inorder l)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Finite_Set.card (relations l) = length (inorder l)

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Finite_Set.card (relations l) = length (inorder l)
[PROOF STEP]
have 3: "distinct_relations l"
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations l) = length (inorder l)

goal (1 subgoal):
 1. distinct_relations l
[PROOF STEP]
using Suc.IH 0 1
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations l) = length (inorder l)
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations l) \<and> finite (relations r)
height l \<le> n

goal (1 subgoal):
 1. distinct_relations l
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
distinct_relations l

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have "Finite_Set.card (relations r) = length (inorder r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Finite_Set.card (relations r) = length (inorder r)
[PROOF STEP]
using Suc.IH Suc.prems(1,3) card_eq_length_trans_r join
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations t)
Finite_Set.card (relations t) = length (inorder t)
\<lbrakk>finite (relations (Join ?l ?r)); Finite_Set.card (relations (Join ?l ?r)) = length (inorder (Join ?l ?r))\<rbrakk> \<Longrightarrow> Finite_Set.card (relations ?r) = length (inorder ?r)
Join l r = t

goal (1 subgoal):
 1. Finite_Set.card (relations r) = length (inorder r)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Finite_Set.card (relations r) = length (inorder r)

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Finite_Set.card (relations r) = length (inorder r)
[PROOF STEP]
have 4: "distinct_relations r"
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations r) = length (inorder r)

goal (1 subgoal):
 1. distinct_relations r
[PROOF STEP]
using Suc.IH 0 2
[PROOF STATE]
proof (prove)
using this:
Finite_Set.card (relations r) = length (inorder r)
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations l) \<and> finite (relations r)
height r \<le> n

goal (1 subgoal):
 1. distinct_relations r
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
distinct_relations r

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
have "relations l \<inter> relations r = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. relations l \<inter> relations r = {}
[PROOF STEP]
using card_eq_length_impl_disjunct join Suc.prems(1,3)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (relations (Join ?l ?r)); Finite_Set.card (relations (Join ?l ?r)) = length (inorder (Join ?l ?r))\<rbrakk> \<Longrightarrow> relations ?l \<inter> relations ?r = {}
Join l r = t
finite (relations t)
Finite_Set.card (relations t) = length (inorder t)

goal (1 subgoal):
 1. relations l \<inter> relations r = {}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
relations l \<inter> relations r = {}

goal (2 subgoals):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t = Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
 2. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
relations l \<inter> relations r = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
relations l \<inter> relations r = {}

goal (1 subgoal):
 1. distinct_relations t
[PROOF STEP]
using 3 4 distinct_and_disjoint_impl_distinct
[PROOF STATE]
proof (prove)
using this:
relations l \<inter> relations r = {}
distinct_relations l
distinct_relations r
\<lbrakk>distinct_relations ?l; distinct_relations ?r; relations ?l \<inter> relations ?r = {}\<rbrakk> \<Longrightarrow> distinct_relations (Join ?l ?r)

goal (1 subgoal):
 1. distinct_relations t
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
distinct_relations t

goal (1 subgoal):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
height t \<noteq> Suc n

goal (1 subgoal):
 1. \<lbrakk>\<And>t. \<lbrakk>finite (relations t); height t \<le> n; Finite_Set.card (relations t) = length (inorder t)\<rbrakk> \<Longrightarrow> distinct_relations t; finite (relations t); height t \<le> Suc n; Finite_Set.card (relations t) = length (inorder t); height t \<noteq> Suc n\<rbrakk> \<Longrightarrow> distinct_relations t
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
height t \<noteq> Suc n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
height t \<noteq> Suc n

goal (1 subgoal):
 1. distinct_relations t
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
height t \<noteq> Suc n
\<lbrakk>finite (relations ?t); height ?t \<le> n; Finite_Set.card (relations ?t) = length (inorder ?t)\<rbrakk> \<Longrightarrow> distinct_relations ?t
finite (relations t)
height t \<le> Suc n
Finite_Set.card (relations t) = length (inorder t)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct_relations t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem Quadratic_Reciprocity_int:
  assumes "prime (nat p)" "2 < p" "prime (nat q)" "2 < q" "p \<noteq> q"
  shows "Legendre p q * Legendre q p = (-1::int) ^ (nat ((p - 1) div 2 * ((q - 1) div 2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime (nat p)
2 < p
prime (nat q)
2 < q
p \<noteq> q
[PROOF STEP]
have "0 \<le> (p - 1) div 2"
[PROOF STATE]
proof (prove)
using this:
prime (nat p)
2 < p
prime (nat q)
2 < q
p \<noteq> q

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

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 \<le> (p - 1) div 2

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
have "(nat p - 1) div 2 = nat ((p - 1) div 2)" "(nat q - 1) div 2 = nat ((q - 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (nat p - 1) div 2 = nat ((p - 1) div 2) &&& (nat q - 1) div 2 = nat ((q - 1) div 2)
[PROOF STEP]
by fastforce+
[PROOF STATE]
proof (state)
this:
(nat p - 1) div 2 = nat ((p - 1) div 2)
(nat q - 1) div 2 = nat ((q - 1) div 2)

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 \<le> (p - 1) div 2
(nat p - 1) div 2 = nat ((p - 1) div 2)
(nat q - 1) div 2 = nat ((q - 1) div 2)
[PROOF STEP]
have "(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))"
[PROOF STATE]
proof (prove)
using this:
0 \<le> (p - 1) div 2
(nat p - 1) div 2 = nat ((p - 1) div 2)
(nat q - 1) div 2 = nat ((q - 1) div 2)

goal (1 subgoal):
 1. (nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
using nat_mult_distrib
[PROOF STATE]
proof (prove)
using this:
0 \<le> (p - 1) div 2
(nat p - 1) div 2 = nat ((p - 1) div 2)
(nat q - 1) div 2 = nat ((q - 1) div 2)
0 \<le> ?z \<Longrightarrow> nat (?z * ?z') = nat ?z * nat ?z'

goal (1 subgoal):
 1. (nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
have "2 < nat p" "2 < nat q" "nat p \<noteq> nat q" "int (nat p) = p" "int (nat q) = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 < nat p &&& 2 < nat q) &&& nat p \<noteq> nat q &&& int (nat p) = p &&& int (nat q) = q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prime (nat p)
2 < p
prime (nat q)
2 < q
p \<noteq> q

goal (1 subgoal):
 1. (2 < nat p &&& 2 < nat q) &&& nat p \<noteq> nat q &&& int (nat p) = p &&& int (nat q) = q
[PROOF STEP]
by linarith+
[PROOF STATE]
proof (state)
this:
2 < nat p
2 < nat q
nat p \<noteq> nat q
int (nat p) = p
int (nat q) = q

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))
2 < nat p
2 < nat q
nat p \<noteq> nat q
int (nat p) = p
int (nat q) = q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))
2 < nat p
2 < nat q
nat p \<noteq> nat q
int (nat p) = p
int (nat q) = q

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
using Quadratic_Reciprocity[of "nat p" "nat q"] assms
[PROOF STATE]
proof (prove)
using this:
(nat p - 1) div 2 * ((nat q - 1) div 2) = nat ((p - 1) div 2 * ((q - 1) div 2))
2 < nat p
2 < nat q
nat p \<noteq> nat q
int (nat p) = p
int (nat q) = q
\<lbrakk>prime (nat p); 2 < nat p; prime (nat q); 2 < nat q; nat p \<noteq> nat q\<rbrakk> \<Longrightarrow> Legendre (int (nat p)) (int (nat q)) * Legendre (int (nat q)) (int (nat p)) = (- 1) ^ ((nat p - 1) div 2 * ((nat q - 1) div 2))
prime (nat p)
2 < p
prime (nat q)
2 < q
p \<noteq> q

goal (1 subgoal):
 1. Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
Legendre p q * Legendre q p = (- 1) ^ nat ((p - 1) div 2 * ((q - 1) div 2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem limit_inj [simp]:
  assumes inj: "inj f"
  shows "limit (f \<circ> w) = f ` (limit w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit (f \<circ> w) = f ` limit w
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. limit (f \<circ> w) \<subseteq> f ` limit w
 2. f ` limit w \<subseteq> limit (f \<circ> w)
[PROOF STEP]
show "f ` limit w \<subseteq> limit (f \<circ> w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` limit w \<subseteq> limit (f \<circ> w)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f ` limit w \<subseteq> limit (f \<circ> w)

goal (1 subgoal):
 1. limit (f \<circ> w) \<subseteq> f ` limit w
[PROOF STEP]
show "limit (f \<circ> w) \<subseteq> f ` limit w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit (f \<circ> w) \<subseteq> f ` limit w
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> limit (f \<circ> w) \<Longrightarrow> x \<in> f ` limit w
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> limit (f \<circ> w) \<Longrightarrow> x \<in> f ` limit w
[PROOF STEP]
assume x: "x \<in> limit (f \<circ> w)"
[PROOF STATE]
proof (state)
this:
x \<in> limit (f \<circ> w)

goal (1 subgoal):
 1. \<And>x. x \<in> limit (f \<circ> w) \<Longrightarrow> x \<in> f ` limit w
[PROOF STEP]
from inj
[PROOF STATE]
proof (chain)
picking this:
inj f
[PROOF STEP]
have "finite (f -` {x})"
[PROOF STATE]
proof (prove)
using this:
inj f

goal (1 subgoal):
 1. finite (f -` {x})
[PROOF STEP]
by (blast intro: finite_vimageI)
[PROOF STATE]
proof (state)
this:
finite (f -` {x})

goal (1 subgoal):
 1. \<And>x. x \<in> limit (f \<circ> w) \<Longrightarrow> x \<in> f ` limit w
[PROOF STEP]
with x
[PROOF STATE]
proof (chain)
picking this:
x \<in> limit (f \<circ> w)
finite (f -` {x})
[PROOF STEP]
obtain a where a: "a \<in> (f -` {x}) \<and> a \<in> limit w"
[PROOF STATE]
proof (prove)
using this:
x \<in> limit (f \<circ> w)
finite (f -` {x})

goal (1 subgoal):
 1. (\<And>a. a \<in> f -` {x} \<and> a \<in> limit w \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (blast dest: limit_o_inv)
[PROOF STATE]
proof (state)
this:
a \<in> f -` {x} \<and> a \<in> limit w

goal (1 subgoal):
 1. \<And>x. x \<in> limit (f \<circ> w) \<Longrightarrow> x \<in> f ` limit w
[PROOF STEP]
thus "x \<in> f ` (limit w)"
[PROOF STATE]
proof (prove)
using this:
a \<in> f -` {x} \<and> a \<in> limit w

goal (1 subgoal):
 1. x \<in> f ` limit w
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> f ` limit w

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
limit (f \<circ> w) \<subseteq> f ` limit w

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma get_norm_value:
  fixes a::"'a::{floor_ceiling}"
  assumes "pp>0"
  obtains k::int and a1 where "a=(of_int k)*pp+a1" "a0\<le>a1" "a1<a0+pp"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define k where "k=floor ((a-a0)/pp)"
[PROOF STATE]
proof (state)
this:
k = \<lfloor>(a - a0) / pp\<rfloor>

goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define a1 where "a1=a-(of_int k)*pp"
[PROOF STATE]
proof (state)
this:
a1 = a - of_int k * pp

goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a- a0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(0::'a) < pp

goal (1 subgoal):
 1. of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0
[PROOF STEP]
by (meson le_divide_eq of_int_floor_le)
[PROOF STATE]
proof (state)
this:
of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0

goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0

goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "a-a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor>+1) * pp"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(0::'a) < pp

goal (1 subgoal):
 1. a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp
[PROOF STEP]
by (meson divide_less_eq floor_correct)
[PROOF STATE]
proof (state)
this:
a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp

goal (1 subgoal):
 1. (\<And>k a1. \<lbrakk>a = of_int k * pp + a1; a0 \<le> a1; a1 < a0 + pp\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0
a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0
a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp

goal (1 subgoal):
 1. thesis
[PROOF STEP]
apply (intro that[of k a1])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a = of_int k * pp + a1
 2. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a0 \<le> a1
 3. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a1 < a0 + pp
[PROOF STEP]
unfolding k_def a1_def
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a = of_int \<lfloor>(a - a0) / pp\<rfloor> * pp + (a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp)
 2. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a0 \<le> a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp
 3. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp < a0 + pp
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(0::'a) < pp

goal (3 subgoals):
 1. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a = of_int \<lfloor>(a - a0) / pp\<rfloor> * pp + (a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp)
 2. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a0 \<le> a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp
 3. \<lbrakk>of_int \<lfloor>(a - a0) / pp\<rfloor> * pp \<le> a - a0; a - a0 < of_int (\<lfloor>(a - a0) / pp\<rfloor> + 1) * pp\<rbrakk> \<Longrightarrow> a - of_int \<lfloor>(a - a0) / pp\<rfloor> * pp < a0 + pp
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lemDirectionCollinear:
    shows "collinear u v (v \<leadsto> d) \<longleftrightarrow> (\<exists>\<beta>.(from u to v = (-\<beta>)**d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have basic1: "\<forall>u v.(positionVector (u \<leadsto> v)) = (positionVector u) \<oplus> v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>u v. positionVector (u \<leadsto> v) = positionVector u \<oplus> v
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>u v. positionVector (u \<leadsto> v) = positionVector u \<oplus> v

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have basic2: "\<forall>u v w.(u = v \<oplus> w \<longrightarrow> v \<ominus> u = vecNegate w )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>u v w. u = v \<oplus> w \<longrightarrow> v \<ominus> u = ~ w
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>v w. tdir v - (tdir v + tdir w) = - tdir w
 2. \<And>v w. xdir v - (xdir v + xdir w) = - xdir w
 3. \<And>v w. ydir v - (ydir v + ydir w) = - ydir w
 4. \<And>v w. zdir v - (zdir v + zdir w) = - zdir w
[PROOF STEP]
by    (metis add_uminus_conv_diff diff_add_cancel minus_add
              semiring_normalization_rules(24)) +
[PROOF STATE]
proof (state)
this:
\<forall>u v w. u = v \<oplus> w \<longrightarrow> v \<ominus> u = ~ w

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have basic3: "\<forall>u v.(from u to v = positionVector v \<ominus> positionVector u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>u v. from u to v = positionVector v \<ominus> positionVector u
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>u v. from u to v = positionVector v \<ominus> positionVector u

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have basic4: "\<forall>u v w.(v \<ominus> u = vecNegate w \<longrightarrow> u = v \<oplus> w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>u v w. v \<ominus> u = ~ w \<longrightarrow> u = v \<oplus> w
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>u v w. \<lbrakk>tdir v - tdir u = - tdir w; xdir v - xdir u = - xdir w; ydir v - ydir u = - ydir w; zdir v - zdir u = - zdir w\<rbrakk> \<Longrightarrow> u = \<lparr>tdir = tdir v + tdir w, xdir = xdir v + xdir w, ydir = ydir v + ydir w, zdir = zdir v + zdir w\<rparr>
[PROOF STEP]
by (metis add_uminus_conv_diff diff_add_cancel lemScale1 mult.left_neutral
          semiring_normalization_rules(24) vecScale.simps)
[PROOF STATE]
proof (state)
this:
\<forall>u v w. v \<ominus> u = ~ w \<longrightarrow> u = v \<oplus> w

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<forall>u v w. v \<ominus> u = ~ w \<longrightarrow> u = v \<oplus> w

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
assume assm: "collinear u v (v \<leadsto> d)"
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have "\<exists>\<alpha> \<beta>. ( (\<alpha> + \<beta> = 1)  \<and>
         positionVector u = \<alpha>**(positionVector v) \<oplus> \<beta>**(positionVector (v \<leadsto> d)) )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>\<alpha> \<beta>. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)
[PROOF STEP]
by (metis assm collinear.simps)
[PROOF STATE]
proof (state)
this:
\<exists>\<alpha> \<beta>. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>\<alpha> \<beta>. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)
[PROOF STEP]
obtain \<alpha> \<beta> where props: "(\<alpha> + \<beta> = 1)  \<and>
              positionVector u = \<alpha>**(positionVector v) \<oplus> \<beta>**(positionVector (v \<leadsto> d))"
[PROOF STATE]
proof (prove)
using this:
\<exists>\<alpha> \<beta>. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. (\<And>\<alpha> \<beta>. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector u = 1**(positionVector v) \<oplus> \<beta>**d"
[PROOF STATE]
proof (prove)
using this:
\<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d
[PROOF STEP]
by (metis basic1 lemScaleOverAdd lemVecPlusAssoc lemAddOverScale props)
[PROOF STATE]
proof (state)
this:
positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector u = positionVector v \<oplus> \<beta>**d"
[PROOF STATE]
proof (prove)
using this:
positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. positionVector u = positionVector v \<oplus> \<beta> ** d
[PROOF STEP]
by (metis lemScale1)
[PROOF STATE]
proof (state)
this:
positionVector u = positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector v \<ominus> positionVector u = (-\<beta>)**d"
[PROOF STATE]
proof (prove)
using this:
positionVector u = positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. positionVector v \<ominus> positionVector u = (- \<beta>) ** d
[PROOF STEP]
by (metis basic2 lemScaleNeg)
[PROOF STATE]
proof (state)
this:
positionVector v \<ominus> positionVector u = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "\<exists>\<beta>.(from u to v = (-\<beta>)**d)"
[PROOF STATE]
proof (prove)
using this:
positionVector v \<ominus> positionVector u = (- \<beta>) ** d

goal (1 subgoal):
 1. \<exists>\<beta>. from u to v = (- \<beta>) ** d
[PROOF STEP]
by (metis basic3)
[PROOF STATE]
proof (state)
this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d) \<Longrightarrow> \<exists>\<beta>. from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
collinear u v (v \<leadsto> d) \<Longrightarrow> \<exists>\<beta>. from u to v = (- \<beta>) ** d
[PROOF STEP]
have fwd: "collinear u v (v \<leadsto> d) \<longrightarrow> (\<exists>\<beta>.(from u to v = (-\<beta>)**d))"
[PROOF STATE]
proof (prove)
using this:
collinear u v (v \<leadsto> d) \<Longrightarrow> \<exists>\<beta>. from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) \<longrightarrow> (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d) \<longrightarrow> (\<exists>\<beta>. from u to v = (- \<beta>) ** d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d) \<longrightarrow> (\<exists>\<beta>. from u to v = (- \<beta>) ** d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
assume "\<exists>\<beta>.(from u to v = (-\<beta>)**d)"
[PROOF STATE]
proof (state)
this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d
[PROOF STEP]
obtain \<beta> where assm: "from u to v = (-\<beta>)**d"
[PROOF STATE]
proof (prove)
using this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. (\<And>\<beta>. from u to v = (- \<beta>) ** d \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
from u to v = (- \<beta>) ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
define \<alpha> where "\<alpha> = 1 - \<beta>"
[PROOF STATE]
proof (state)
this:
\<alpha> = (1::'a) - \<beta>

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have \<alpha>\<beta>_sum: "\<alpha> + \<beta> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<alpha> + \<beta> = (1::'a)
[PROOF STEP]
by (simp add: \<alpha>_def)
[PROOF STATE]
proof (state)
this:
\<alpha> + \<beta> = (1::'a)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
have "from u to v = vecNegate (\<beta>**d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from u to v = ~ \<beta> ** d
[PROOF STEP]
by (metis assm lemScaleNeg)
[PROOF STATE]
proof (state)
this:
from u to v = ~ \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector v \<ominus> positionVector u = vecNegate (\<beta>**d)"
[PROOF STATE]
proof (prove)
using this:
from u to v = ~ \<beta> ** d

goal (1 subgoal):
 1. positionVector v \<ominus> positionVector u = ~ \<beta> ** d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
positionVector v \<ominus> positionVector u = ~ \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector u = positionVector v \<oplus> \<beta>**d"
[PROOF STATE]
proof (prove)
using this:
positionVector v \<ominus> positionVector u = ~ \<beta> ** d

goal (1 subgoal):
 1. positionVector u = positionVector v \<oplus> \<beta> ** d
[PROOF STEP]
by (metis basic4)
[PROOF STATE]
proof (state)
this:
positionVector u = positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "positionVector u = 1**(positionVector v) \<oplus> \<beta>**d"
[PROOF STATE]
proof (prove)
using this:
positionVector u = positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d
[PROOF STEP]
by (metis lemScale1)
[PROOF STATE]
proof (state)
this:
positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "(\<alpha> + \<beta> = 1)  \<and>
            positionVector u = \<alpha>**(positionVector v) \<oplus> \<beta>**(positionVector (v \<leadsto> d))"
[PROOF STATE]
proof (prove)
using this:
positionVector u = (1::'a) ** positionVector v \<oplus> \<beta> ** d

goal (1 subgoal):
 1. \<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)
[PROOF STEP]
by (metis \<alpha>\<beta>_sum basic1 lemScaleOverAdd lemVecPlusAssoc lemAddOverScale)
[PROOF STATE]
proof (state)
this:
\<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
hence "collinear u v (v \<leadsto> d)"
[PROOF STATE]
proof (prove)
using this:
\<alpha> + \<beta> = (1::'a) \<and> positionVector u = \<alpha> ** positionVector v \<oplus> \<beta> ** positionVector (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d \<Longrightarrow> collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d \<Longrightarrow> collinear u v (v \<leadsto> d)
[PROOF STEP]
have "(\<exists>\<beta>.(from u to v = (-\<beta>)**d)) \<longrightarrow> collinear u v (v \<leadsto> d)"
[PROOF STATE]
proof (prove)
using this:
\<exists>\<beta>. from u to v = (- \<beta>) ** d \<Longrightarrow> collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. (\<exists>\<beta>. from u to v = (- \<beta>) ** d) \<longrightarrow> collinear u v (v \<leadsto> d)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<exists>\<beta>. from u to v = (- \<beta>) ** d) \<longrightarrow> collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<exists>\<beta>. from u to v = (- \<beta>) ** d) \<longrightarrow> collinear u v (v \<leadsto> d)

goal (1 subgoal):
 1. collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)
[PROOF STEP]
by (metis fwd)
[PROOF STATE]
proof (state)
this:
collinear u v (v \<leadsto> d) = (\<exists>\<beta>. from u to v = (- \<beta>) ** d)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma list_Singl[simp]: "list {b} = [b]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list {b} = [b]
[PROOF STEP]
unfolding list_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME al. distinct al \<and> set al = {b}) = [b]
[PROOF STEP]
apply(rule some_equality)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct [b] \<and> set [b] = {b}
 2. \<And>al. distinct al \<and> set al = {b} \<Longrightarrow> al = [b]
[PROOF STEP]
by auto


[STATEMENT]
lemma acomplete_bal:
  assumes "n \<le> length xs" "bal n xs = (t,ys)" shows "acomplete t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. acomplete t
[PROOF STEP]
unfolding acomplete_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height t - min_height t \<le> 1
[PROOF STEP]
using height_bal[OF assms] min_height_bal[OF assms]
[PROOF STATE]
proof (prove)
using this:
height t = nat \<lceil>log 2 (real (n + 1))\<rceil>
min_height t = nat \<lfloor>log 2 (real (n + 1))\<rfloor>

goal (1 subgoal):
 1. height t - min_height t \<le> 1
[PROOF STEP]
by linarith


[STATEMENT]
lemma mUnionM_add_mset [simp]: "mUnionM (add_mset x M) = munionM x (mUnionM M)" for x M
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mUnionM (add_mset x M) = munionM x (mUnionM M)
[PROOF STEP]
by(simp add: mUnionM_def)


[STATEMENT]
lemma lsorted_llist_of[simp]: "lsorted (llist_of xs) \<longleftrightarrow> sorted xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lsorted (llist_of xs) = sorted xs
[PROOF STEP]
by(induct xs)(auto simp: lsorted_LCons)


[STATEMENT]
lemma induced_modulus_altdef2_lemma:
  fixes n a d q :: nat
  defines "q \<equiv> (\<Prod> p | prime p \<and> p dvd n \<and> \<not> (p dvd a). p)"
  defines "m \<equiv> a + q * d"
  assumes "n > 0" "coprime a d"
  shows "[m = a] (mod d)" and "coprime m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [m = a] (mod d) &&& coprime m n
[PROOF STEP]
proof (simp add: assms(2) cong_add_lcancel_0_nat cong_mult_self_right)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
have fin: "finite {p. prime p \<and> p dvd n \<and> \<not> (p dvd a)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
by (simp add: assms)
[PROOF STATE]
proof (state)
this:
finite {p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
finite {p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
assume 4: "prime p" "p dvd m" "p dvd n"
[PROOF STATE]
proof (state)
this:
prime p
p dvd m
p dvd n

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
have "p = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = 1
[PROOF STEP]
proof (cases "p dvd a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
p dvd a

goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
from this assms 4(2)
[PROOF STATE]
proof (chain)
picking this:
p dvd a
q \<equiv> \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
m \<equiv> a + q * d
0 < n
coprime a d
p dvd m
[PROOF STEP]
have "p dvd q*d"
[PROOF STATE]
proof (prove)
using this:
p dvd a
q \<equiv> \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
m \<equiv> a + q * d
0 < n
coprime a d
p dvd m

goal (1 subgoal):
 1. p dvd q * d
[PROOF STEP]
by (simp add: dvd_add_right_iff)
[PROOF STATE]
proof (state)
this:
p dvd q * d

goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd q * d
[PROOF STEP]
have a1: "p dvd q \<or> p dvd d"
[PROOF STATE]
proof (prove)
using this:
p dvd q * d

goal (1 subgoal):
 1. p dvd q \<or> p dvd d
[PROOF STEP]
using 4(1) prime_dvd_mult_iff
[PROOF STATE]
proof (prove)
using this:
p dvd q * d
prime p
prime ?p \<Longrightarrow> (?p dvd ?a * ?b) = (?p dvd ?a \<or> ?p dvd ?b)

goal (1 subgoal):
 1. p dvd q \<or> p dvd d
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p dvd q \<or> p dvd d

goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
have a2: "\<not> (p dvd q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> p dvd q
[PROOF STEP]
proof (rule ccontr,simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
assume "p dvd q"
[PROOF STATE]
proof (state)
this:
p dvd q

goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd q
[PROOF STEP]
have "p dvd (\<Prod> p | prime p \<and> p dvd n \<and> \<not> (p dvd a). p)"
[PROOF STATE]
proof (prove)
using this:
p dvd q

goal (1 subgoal):
 1. p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
unfolding assms
[PROOF STATE]
proof (prove)
using this:
p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
have "\<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x"
[PROOF STATE]
proof (prove)
using this:
p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. \<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x
[PROOF STEP]
using prime_dvd_prod_iff[OF fin 4(1)]
[PROOF STATE]
proof (prove)
using this:
p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
(p dvd prod ?f {p. prime p \<and> p dvd n \<and> \<not> p dvd a}) = (\<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd ?f x)

goal (1 subgoal):
 1. \<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x

goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x
[PROOF STEP]
obtain x where c: "p dvd x \<and> prime x \<and> \<not> x dvd a"
[PROOF STATE]
proof (prove)
using this:
\<exists>x\<in>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}. p dvd x

goal (1 subgoal):
 1. (\<And>x. p dvd x \<and> prime x \<and> \<not> x dvd a \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p dvd x \<and> prime x \<and> \<not> x dvd a

goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd x \<and> prime x \<and> \<not> x dvd a
[PROOF STEP]
have "p = x"
[PROOF STATE]
proof (prove)
using this:
p dvd x \<and> prime x \<and> \<not> x dvd a

goal (1 subgoal):
 1. p = x
[PROOF STEP]
using 4(1)
[PROOF STATE]
proof (prove)
using this:
p dvd x \<and> prime x \<and> \<not> x dvd a
prime p

goal (1 subgoal):
 1. p = x
[PROOF STEP]
by (simp add: primes_dvd_imp_eq)
[PROOF STATE]
proof (state)
this:
p = x

goal (1 subgoal):
 1. p dvd q \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p = x
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
p = x

goal (1 subgoal):
 1. False
[PROOF STEP]
using True c
[PROOF STATE]
proof (prove)
using this:
p = x
p dvd a
p dvd x \<and> prime x \<and> \<not> x dvd a

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> p dvd q

goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
have a3: "\<not> (p dvd d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> p dvd d
[PROOF STEP]
using True assms "4"(1) coprime_def not_prime_unit
[PROOF STATE]
proof (prove)
using this:
p dvd a
q \<equiv> \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
m \<equiv> a + q * d
0 < n
coprime a d
prime p
coprime ?a ?b = (\<forall>c. c dvd ?a \<longrightarrow> c dvd ?b \<longrightarrow> is_unit c)
is_unit ?x \<Longrightarrow> \<not> prime ?x

goal (1 subgoal):
 1. \<not> p dvd d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> p dvd d

goal (2 subgoals):
 1. p dvd a \<Longrightarrow> p = 1
 2. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
from a1 a2 a3
[PROOF STATE]
proof (chain)
picking this:
p dvd q \<or> p dvd d
\<not> p dvd q
\<not> p dvd d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p dvd q \<or> p dvd d
\<not> p dvd q
\<not> p dvd d

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

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> p dvd a

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> p dvd a
[PROOF STEP]
have "p dvd q"
[PROOF STATE]
proof (prove)
using this:
\<not> p dvd a

goal (1 subgoal):
 1. p dvd q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p dvd q
[PROOF STEP]
have in_s: "p \<in> {p. prime p \<and> p dvd n \<and> \<not> p dvd a}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<in> {p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
using False 4(3) 4(1)
[PROOF STATE]
proof (prove)
using this:
\<not> p dvd a
p dvd n
prime p

goal (1 subgoal):
 1. p \<in> {p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p \<in> {p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p dvd q
[PROOF STEP]
show "p dvd q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd q
[PROOF STEP]
unfolding assms
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
using dvd_prodI[OF fin in_s ]
[PROOF STATE]
proof (prove)
using this:
?f p dvd prod ?f {p. prime p \<and> p dvd n \<and> \<not> p dvd a}

goal (1 subgoal):
 1. p dvd \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
p dvd q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
p dvd q

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd q
[PROOF STEP]
have "p dvd q*d"
[PROOF STATE]
proof (prove)
using this:
p dvd q

goal (1 subgoal):
 1. p dvd q * d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p dvd q * d

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd q * d
[PROOF STEP]
have "p dvd a"
[PROOF STATE]
proof (prove)
using this:
p dvd q * d

goal (1 subgoal):
 1. p dvd a
[PROOF STEP]
using 4(2) assms
[PROOF STATE]
proof (prove)
using this:
p dvd q * d
p dvd m
q \<equiv> \<Prod>{p. prime p \<and> p dvd n \<and> \<not> p dvd a}
m \<equiv> a + q * d
0 < n
coprime a d

goal (1 subgoal):
 1. p dvd a
[PROOF STEP]
by (simp add: dvd_add_left_iff)
[PROOF STATE]
proof (state)
this:
p dvd a

goal (1 subgoal):
 1. \<not> p dvd a \<Longrightarrow> p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p dvd a

goal (1 subgoal):
 1. p = 1
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
p dvd a
\<not> p dvd a

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
p = 1

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
note lem = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1

goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
show "coprime m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime m n
[PROOF STEP]
proof (subst coprime_iff_gcd_eq_1)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
assume "a dvd m" "a dvd n" "a \<noteq> 1"
[PROOF STATE]
proof (state)
this:
a dvd m
a dvd n
a \<noteq> 1

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
a dvd m
a dvd n
a \<noteq> 1

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
assume "prime p" "p dvd a"
[PROOF STATE]
proof (state)
this:
prime p
p dvd a

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime p
p dvd a
[PROOF STEP]
have "p dvd m" "p dvd n"
[PROOF STATE]
proof (prove)
using this:
prime p
p dvd a

goal (1 subgoal):
 1. p dvd m &&& p dvd n
[PROOF STEP]
using \<open>a dvd m\<close> \<open>a dvd n\<close>
[PROOF STATE]
proof (prove)
using this:
prime p
p dvd a
a dvd m
a dvd n

goal (1 subgoal):
 1. p dvd m &&& p dvd n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p dvd m
p dvd n

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
from lem
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1
[PROOF STEP]
have "p = a"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1

goal (1 subgoal):
 1. p = a
[PROOF STEP]
using not_prime_1 \<open>prime p\<close> \<open>p dvd m\<close> \<open>p dvd n\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1
\<not> prime (1::?'a)
prime p
p dvd m
p dvd n

goal (1 subgoal):
 1. p = a
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p = a

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>prime ?p2; ?p2 dvd a\<rbrakk> \<Longrightarrow> ?p2 = a

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>prime ?p2; ?p2 dvd a\<rbrakk> \<Longrightarrow> ?p2 = a
[PROOF STEP]
have "prime a"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime ?p2; ?p2 dvd a\<rbrakk> \<Longrightarrow> ?p2 = a

goal (1 subgoal):
 1. prime a
[PROOF STEP]
using prime_prime_factor[of a] \<open>a \<noteq> 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime ?p2; ?p2 dvd a\<rbrakk> \<Longrightarrow> ?p2 = a
prime a = (a \<noteq> 1 \<and> (\<forall>p. prime p \<and> p dvd a \<longrightarrow> p = a))
a \<noteq> 1

goal (1 subgoal):
 1. prime a
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
prime a

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime a
[PROOF STEP]
have "a = 1"
[PROOF STATE]
proof (prove)
using this:
prime a

goal (1 subgoal):
 1. a = 1
[PROOF STEP]
using lem \<open>a dvd m\<close> \<open>a dvd n\<close>
[PROOF STATE]
proof (prove)
using this:
prime a
\<lbrakk>prime ?p2; ?p2 dvd m; ?p2 dvd n\<rbrakk> \<Longrightarrow> ?p2 = 1
a dvd m
a dvd n

goal (1 subgoal):
 1. a = 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a = 1

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a = 1
[PROOF STEP]
have "False"
[PROOF STATE]
proof (prove)
using this:
a = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>a = 1\<close> \<open>a \<noteq> 1\<close>
[PROOF STATE]
proof (prove)
using this:
a = 1
a = 1
a \<noteq> 1

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

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?aa2 dvd m; ?aa2 dvd n; ?aa2 \<noteq> 1\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?aa2 dvd m; ?aa2 dvd n; ?aa2 \<noteq> 1\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
show "gcd m n = 1"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?aa2 dvd m; ?aa2 dvd n; ?aa2 \<noteq> 1\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. gcd m n = 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
gcd m n = 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime m n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma representation_extend:
  assumes basis: "independent basis" and v: "v \<in> span basis'" and basis': "basis' \<subseteq> basis"
  shows "representation basis v = representation basis' v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. representation basis v = representation basis' v
[PROOF STEP]
proof (rule representation_eqI[OF basis])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. v \<in> span basis
 2. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 3. finite {b. representation basis' v b \<noteq> (0::'a)}
 4. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show v': "v \<in> span basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> span basis
[PROOF STEP]
using span_mono[OF basis'] v
[PROOF STATE]
proof (prove)
using this:
span basis' \<subseteq> span basis
v \<in> span basis'

goal (1 subgoal):
 1. v \<in> span basis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> span basis

goal (3 subgoals):
 1. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis' v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
have *: "independent basis'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. independent basis'
[PROOF STEP]
using basis' basis
[PROOF STATE]
proof (prove)
using this:
basis' \<subseteq> basis
independent basis

goal (1 subgoal):
 1. independent basis'
[PROOF STEP]
by (auto intro: dependent_mono)
[PROOF STATE]
proof (state)
this:
independent basis'

goal (3 subgoals):
 1. \<And>b. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis' v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "representation basis' v b \<noteq> 0 \<Longrightarrow> b \<in> basis" for b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
[PROOF STEP]
using representation_ne_zero basis'
[PROOF STATE]
proof (prove)
using this:
representation ?basis ?v ?b \<noteq> (0::'a) \<Longrightarrow> ?b \<in> ?basis
basis' \<subseteq> basis

goal (1 subgoal):
 1. representation basis' v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
representation basis' v ?b \<noteq> (0::'a) \<Longrightarrow> ?b \<in> basis

goal (2 subgoals):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
 2. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "finite {b. representation basis' v b \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
[PROOF STEP]
using finite_representation
[PROOF STATE]
proof (prove)
using this:
finite {b. representation ?basis ?v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. finite {b. representation basis' v b \<noteq> (0::'a)}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
finite {b. representation basis' v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
show "(\<Sum>b | representation basis' v b \<noteq> 0. representation basis' v b *s b) = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
using sum_nonzero_representation_eq[OF * v]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v

goal (1 subgoal):
 1. (\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>b | representation basis' v b \<noteq> (0::'a). representation basis' v b *s b) = v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma path_image_subpath_gen:
  fixes g :: "_ \<Rightarrow> 'a::real_normed_vector"
  shows "path_image(subpath u v g) = g ` (closed_segment u v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image (subpath u v g) = g ` closed_segment u v
[PROOF STEP]
by (auto simp add: closed_segment_real_eq path_image_def subpath_def)


[STATEMENT]
lemma fps_lr_inverse_nth_0:
  "(fps_left_inverse f x) $ 0 = x" "(fps_right_inverse f x) $ 0 = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_left_inverse f x $ 0 = x &&& fps_right_inverse f x $ 0 = x
[PROOF STEP]
by auto


[STATEMENT]
lemma finite_cl_states: "(UNIV :: cl_states set) = {cl_state, tr_state, fin_state, fin_clstate}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = {cl_state, tr_state, fin_state, fin_clstate}
[PROOF STEP]
using cl_states.exhaust
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?y = cl_state \<Longrightarrow> ?P; ?y = tr_state \<Longrightarrow> ?P; ?y = fin_state \<Longrightarrow> ?P; ?y = fin_clstate \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P

goal (1 subgoal):
 1. UNIV = {cl_state, tr_state, fin_state, fin_clstate}
[PROOF STEP]
by auto


[STATEMENT]
lemma fls_prpart_of_nat [simp]: "fls_prpart (of_nat n) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_prpart (of_nat n) = 0
[PROOF STEP]
by (simp add: fls_prpart_eq0_iff)


[STATEMENT]
lemma wf_tuple_tabulate_Some: "wf_tuple n A (Table.tabulate f 0 n) \<Longrightarrow> x \<in> A \<Longrightarrow> x < n \<Longrightarrow> \<exists>y. f x = Some y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>wf_tuple n A (tabulate f 0 n); x \<in> A; x < n\<rbrakk> \<Longrightarrow> \<exists>y. f x = Some y
[PROOF STEP]
unfolding wf_tuple_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>length (tabulate f 0 n) = n \<and> (\<forall>i<n. (tabulate f 0 n ! i = None) = (i \<notin> A)); x \<in> A; x < n\<rbrakk> \<Longrightarrow> \<exists>y. f x = Some y
[PROOF STEP]
by auto