[STATEMENT]
theorem mono_step [simp]:
  "dmono D \<Longrightarrow> mono (step D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dmono D \<Longrightarrow> mono (step D)
[PROOF STEP]
apply (simp add: dmono_def mono_def le_fun_def step_def Inf_fun_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y \<Longrightarrow> \<forall>x y. (\<forall>xa. x xa \<sqsubseteq> y xa) \<longrightarrow> (\<forall>xa. (INF j. D (xa, j) (x j)) \<sqsubseteq> (INF j. D (xa, j) (y j)))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y xa. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> (INF j. D (xa, j) (x j)) \<sqsubseteq> (INF j. D (xa, j) (y j))
[PROOF STEP]
apply (rule INF_greatest)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa; j \<in> UNIV\<rbrakk> \<Longrightarrow> (INF j. D (xa, j) (x j)) \<sqsubseteq> D (xa, j) (y j)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> (INF j. D (xa, j) (x j)) \<sqsubseteq> D (xa, j) (y j)
[PROOF STEP]
apply (rule_tac y = "D(xa, j) (x j)" in order_trans)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> (INF j. D (xa, j) (x j)) \<sqsubseteq> D (xa, j) (x j)
 2. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> D (xa, j) (x j) \<sqsubseteq> D (xa, j) (y j)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> (INF j. D (xa, j) (x j)) \<sqsubseteq> D (xa, j) (x j)
[PROOF STEP]
apply (rule INF_lower)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y xa j. \<lbrakk>\<forall>a b x y. x \<sqsubseteq> y \<longrightarrow> D (a, b) x \<sqsubseteq> D (a, b) y; \<forall>xa. x xa \<sqsubseteq> y xa\<rbrakk> \<Longrightarrow> j \<in> UNIV
[PROOF STEP]
by auto


[STATEMENT]
lemma monotone_directed_complete:
  assumes comp: "directed_complete A r"
  assumes fI: "f ` I \<subseteq> A" and dir: "directed I ri" and I0: "I \<noteq> {}" and mono: "monotone_on I ri r f"
  shows "\<exists>s. extreme_bound A r (f ` I) s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ex (extreme_bound A r (f ` I))
[PROOF STEP]
apply (rule completeD[OF comp[unfolded directed_complete_def], OF fI])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` I \<in> {X. directed X r \<and> X \<noteq> {}}
[PROOF STEP]
using monotone_directed_image[OF mono dir] I0
[PROOF STATE]
proof (prove)
using this:
directed (f ` I) r
I \<noteq> {}

goal (1 subgoal):
 1. f ` I \<in> {X. directed X r \<and> X \<noteq> {}}
[PROOF STEP]
by auto


[STATEMENT]
lemma rbt_lookup_rbt_insertwk:
  assumes "rbt_sorted t"
  shows "rbt_lookup (rbt_insert_with_key f k v t) x = ((rbt_lookup t)(k |-> case rbt_lookup t k of None \<Rightarrow> v
                                                       | Some w \<Rightarrow> f k w v)) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rbt_lookup (rbt_insert_with_key f k v t) x = (rbt_lookup t(k \<mapsto> case rbt_lookup t k of None \<Rightarrow> v | Some w \<Rightarrow> f k w v)) x
[PROOF STEP]
unfolding rbt_insert_with_key_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rbt_lookup (paint B (rbt_ins f k v t)) x = (rbt_lookup t(k \<mapsto> case rbt_lookup t k of None \<Rightarrow> v | Some w \<Rightarrow> f k w v)) x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
rbt_sorted t

goal (1 subgoal):
 1. rbt_lookup (paint B (rbt_ins f k v t)) x = (rbt_lookup t(k \<mapsto> case rbt_lookup t k of None \<Rightarrow> v | Some w \<Rightarrow> f k w v)) x
[PROOF STEP]
by (simp add:rbt_lookup_ins)


[STATEMENT]
lemma last_message_conv_if: "
  (last_message xs = m) =
  (if m = \<NoMsg> then \<forall>i<length xs. xs ! i = \<NoMsg>
   else \<exists>i<length xs. xs ! i = m \<and> (\<forall>j<length xs. i < j \<longrightarrow> xs ! j = \<NoMsg>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (last_message xs = m) = (if m = NoMsg then \<forall>i<length xs. xs ! i = NoMsg else \<exists>i<length xs. xs ! i = m \<and> (\<forall>j<length xs. i < j \<longrightarrow> xs ! j = NoMsg))
[PROOF STEP]
by (simp add: last_message_NoMsg_conv last_message_conv)


[STATEMENT]
lemma surj_on_add_mult:
  assumes coprime: "coprime x (q::nat)"
    and inj: "inj_on (\<lambda> b. (y + x*b) mod q) {..<q}"
  shows "(\<lambda> b. (y + x*b) mod q) ` {..< q} = {..< q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>b. (y + x * b) mod q) ` {..<q} = {..<q}
[PROOF STEP]
apply(rule endo_inj_surj)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite {..<q}
 2. (\<lambda>b. (y + x * b) mod q) ` {..<q} \<subseteq> {..<q}
 3. inj_on (\<lambda>b. (y + x * b) mod q) {..<q}
[PROOF STEP]
using coprime inj
[PROOF STATE]
proof (prove)
using this:
coprime x q
inj_on (\<lambda>b. (y + x * b) mod q) {..<q}

goal (3 subgoals):
 1. finite {..<q}
 2. (\<lambda>b. (y + x * b) mod q) ` {..<q} \<subseteq> {..<q}
 3. inj_on (\<lambda>b. (y + x * b) mod q) {..<q}
[PROOF STEP]
by auto


[STATEMENT]
lemma listrel1I:
  "\<lbrakk> (x, y) \<in> r;  xs = us @ x # vs;  ys = us @ y # vs \<rbrakk> \<Longrightarrow>
  (xs, ys) \<in> listrel1 r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> r; xs = us @ x # vs; ys = us @ y # vs\<rbrakk> \<Longrightarrow> (xs, ys) \<in> listrel1 r
[PROOF STEP]
unfolding listrel1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> r; xs = us @ x # vs; ys = us @ y # vs\<rbrakk> \<Longrightarrow> (xs, ys) \<in> {(xs, ys). \<exists>us z z' vs. xs = us @ z # vs \<and> (z, z') \<in> r \<and> ys = us @ z' # vs}
[PROOF STEP]
by auto


[STATEMENT]
lemma primorial'_Suc: "primorial' (Suc n) = nth_prime n * primorial' n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primorial' (Suc n) = nth_prime n * primorial' n
[PROOF STEP]
by (simp add: primorial'_def)


[STATEMENT]
lemma mulex1_add: "mulex1 P N (M0 + {#a#}) \<Longrightarrow>
  (\<exists>M. mulex1 P M M0 \<and> N = M + {#a#}) \<or>
  (\<exists>K. (\<forall>b. b \<in># K \<longrightarrow> P b a) \<and> N = M0 + K)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mulex1 P N (M0 + {#a#}) \<Longrightarrow> (\<exists>M. mulex1 P M M0 \<and> N = M + {#a#}) \<or> (\<exists>K. (\<forall>b. b \<in># K \<longrightarrow> P b a) \<and> N = M0 + K)
[PROOF STEP]
using less_add [of N a M0 "{(x, y). P x y}"]
[PROOF STATE]
proof (prove)
using this:
(N, add_mset a M0) \<in> mult1 {(x, y). P x y} \<Longrightarrow> (\<exists>M. (M, M0) \<in> mult1 {(x, y). P x y} \<and> N = add_mset a M) \<or> (\<exists>K. (\<forall>b. b \<in># K \<longrightarrow> (b, a) \<in> {(x, y). P x y}) \<and> N = M0 + K)

goal (1 subgoal):
 1. mulex1 P N (M0 + {#a#}) \<Longrightarrow> (\<exists>M. mulex1 P M M0 \<and> N = M + {#a#}) \<or> (\<exists>K. (\<forall>b. b \<in># K \<longrightarrow> P b a) \<and> N = M0 + K)
[PROOF STEP]
by (auto simp: mulex1_def)


[STATEMENT]
lemma euclidean_size_gcd_less1:
  assumes "a \<noteq> 0" and "\<not> a dvd b"
  shows "euclidean_size (gcd a b) < euclidean_size a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. euclidean_size (gcd a b) < euclidean_size a
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> euclidean_size (gcd a b) < euclidean_size a \<Longrightarrow> False
[PROOF STEP]
assume "\<not>euclidean_size (gcd a b) < euclidean_size a"
[PROOF STATE]
proof (state)
this:
\<not> euclidean_size (gcd a b) < euclidean_size a

goal (1 subgoal):
 1. \<not> euclidean_size (gcd a b) < euclidean_size a \<Longrightarrow> False
[PROOF STEP]
with \<open>a \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> (0::'a)
\<not> euclidean_size (gcd a b) < euclidean_size a
[PROOF STEP]
have A: "euclidean_size (gcd a b) = euclidean_size a"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (0::'a)
\<not> euclidean_size (gcd a b) < euclidean_size a

goal (1 subgoal):
 1. euclidean_size (gcd a b) = euclidean_size a
[PROOF STEP]
by (intro le_antisym, simp_all)
[PROOF STATE]
proof (state)
this:
euclidean_size (gcd a b) = euclidean_size a

goal (1 subgoal):
 1. \<not> euclidean_size (gcd a b) < euclidean_size a \<Longrightarrow> False
[PROOF STEP]
have "a dvd gcd a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a dvd gcd a b
[PROOF STEP]
by (rule dvd_euclidean_size_eq_imp_dvd) (simp_all add: assms A)
[PROOF STATE]
proof (state)
this:
a dvd gcd a b

goal (1 subgoal):
 1. \<not> euclidean_size (gcd a b) < euclidean_size a \<Longrightarrow> False
[PROOF STEP]
hence "a dvd b"
[PROOF STATE]
proof (prove)
using this:
a dvd gcd a b

goal (1 subgoal):
 1. a dvd b
[PROOF STEP]
using dvd_gcdD2
[PROOF STATE]
proof (prove)
using this:
a dvd gcd a b
?a dvd gcd ?b ?c \<Longrightarrow> ?a dvd ?c

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

goal (1 subgoal):
 1. \<not> euclidean_size (gcd a b) < euclidean_size a \<Longrightarrow> False
[PROOF STEP]
with \<open>\<not> a dvd b\<close>
[PROOF STATE]
proof (chain)
picking this:
\<not> a dvd b
a dvd b
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<not> a dvd b
a dvd b

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in vectorspace) vsum_comm:
  fixes W1 W2
  assumes h1: "subspace K W1 V" and h2: "subspace K W2 V"
  shows "(subspace_sum W1 W2) = (subspace_sum W2 W1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subspace_sum W1 W2 = subspace_sum W2 W1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. subspace_sum W1 W2 = subspace_sum W2 W1
[PROOF STEP]
from h1 h2
[PROOF STATE]
proof (chain)
picking this:
subspace K W1 V
subspace K W2 V
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
subspace K W1 V
subspace K W2 V

goal (1 subgoal):
 1. subspace_sum W1 W2 = subspace_sum W2 W1
[PROOF STEP]
by (intro msum_comm, unfold subspace_def, auto)
[PROOF STATE]
proof (state)
this:
subspace_sum W1 W2 = subspace_sum W2 W1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma  cross_orthogonal_transformation:
  assumes "orthogonal_transformation f"
  shows   "(f x) \<times> (f y) = det(matrix f) *\<^sub>R f(x \<times> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)
[PROOF STEP]
have orth: "orthogonal_matrix (matrix f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_matrix (matrix f)
[PROOF STEP]
using assms orthogonal_transformation_matrix
[PROOF STATE]
proof (prove)
using this:
orthogonal_transformation f
orthogonal_transformation ?f = (linear ?f \<and> orthogonal_matrix (matrix ?f))

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

goal (1 subgoal):
 1. f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)
[PROOF STEP]
have "matrix f *v z = f z" for z
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix f *v z = f z
[PROOF STEP]
using assms orthogonal_transformation_matrix
[PROOF STATE]
proof (prove)
using this:
orthogonal_transformation f
orthogonal_transformation ?f = (linear ?f \<and> orthogonal_matrix (matrix ?f))

goal (1 subgoal):
 1. matrix f *v z = f z
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
matrix f *v ?z = f ?z

goal (1 subgoal):
 1. f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)
[PROOF STEP]
with cross_orthogonal_matrix [OF orth]
[PROOF STATE]
proof (chain)
picking this:
(matrix f *v ?x) \<times> (matrix f *v ?y) = det (matrix f) *\<^sub>R (matrix f *v ?x \<times> ?y)
matrix f *v ?z = f ?z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(matrix f *v ?x) \<times> (matrix f *v ?y) = det (matrix f) *\<^sub>R (matrix f *v ?x \<times> ?y)
matrix f *v ?z = f ?z

goal (1 subgoal):
 1. f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f x \<times> f y = det (matrix f) *\<^sub>R f (x \<times> y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Sup_pres_Sup:
  fixes F :: "('a::complete_lattice \<Rightarrow> 'b::complete_lattice) set"
  shows "\<forall>f \<in> F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion>F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f\<in>F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion> F)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>f\<in>F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion> F)
[PROOF STEP]
assume h: "\<forall>f \<in> F. f \<circ> Sup = Sup \<circ> image f"
[PROOF STATE]
proof (state)
this:
\<forall>f\<in>F. Sup_pres f

goal (1 subgoal):
 1. \<forall>f\<in>F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion> F)
[PROOF STEP]
hence "\<forall>f \<in> F. f \<circ> Sup \<le> Sup \<circ> image (\<Squnion>F)"
[PROOF STATE]
proof (prove)
using this:
\<forall>f\<in>F. Sup_pres f

goal (1 subgoal):
 1. \<forall>f\<in>F. f \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)
[PROOF STEP]
by (simp add: SUP_subset_mono Sup_upper le_fun_def)
[PROOF STATE]
proof (state)
this:
\<forall>f\<in>F. f \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)

goal (1 subgoal):
 1. \<forall>f\<in>F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion> F)
[PROOF STEP]
hence "(\<Squnion>F) \<circ> Sup \<le> Sup \<circ> image (\<Squnion>F)"
[PROOF STATE]
proof (prove)
using this:
\<forall>f\<in>F. f \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)

goal (1 subgoal):
 1. \<Squnion> F \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)
[PROOF STEP]
by (simp add: SUP_le_iff le_fun_def)
[PROOF STATE]
proof (state)
this:
\<Squnion> F \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)

goal (1 subgoal):
 1. \<forall>f\<in>F. Sup_pres f \<Longrightarrow> Sup_pres (\<Squnion> F)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Squnion> F \<circ> Sup \<le> Sup \<circ> (`) (\<Squnion> F)

goal (1 subgoal):
 1. Sup_pres (\<Squnion> F)
[PROOF STEP]
by (simp add: Sup_pres_iso h antisym iso_Sup_supdistl iso_fSup)
[PROOF STATE]
proof (state)
this:
Sup_pres (\<Squnion> F)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neg_prod_lt:
  fixes c :: "'a::linordered_field"
  assumes "c < 0"
  shows "c * x < 0 \<equiv> x > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * x < (0::'a) \<equiv> (0::'a) < x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c * x < (0::'a) \<equiv> (0::'a) < x
[PROOF STEP]
have "c * x < 0 \<longleftrightarrow> 0 / c < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c * x < (0::'a)) = ((0::'a) / c < x)
[PROOF STEP]
by (simp only: neg_divide_less_eq[OF \<open>c < 0\<close>] algebra_simps)
[PROOF STATE]
proof (state)
this:
(c * x < (0::'a)) = ((0::'a) / c < x)

goal (1 subgoal):
 1. c * x < (0::'a) \<equiv> (0::'a) < x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(c * x < (0::'a)) = ((0::'a) / c < x)

goal (1 subgoal):
 1. c * x < (0::'a) \<equiv> (0::'a) < x
[PROOF STEP]
have "\<dots> \<longleftrightarrow> 0 < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((0::'a) / c < x) = ((0::'a) < x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((0::'a) / c < x) = ((0::'a) < x)

goal (1 subgoal):
 1. c * x < (0::'a) \<equiv> (0::'a) < x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(c * x < (0::'a)) = ((0::'a) < x)
[PROOF STEP]
show "PROP ?thesis"
[PROOF STATE]
proof (prove)
using this:
(c * x < (0::'a)) = ((0::'a) < x)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gbinomial_int_n_n [simp]: "(int n) gchoose n = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int n gchoose n = 1
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. int 0 gchoose 0 = 1
 2. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. int 0 gchoose 0 = 1
 2. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int 0 gchoose 0 = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int 0 gchoose 0 = 1

goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
int n gchoose n = 1

goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
have "int (Suc n) gchoose Suc n = (int n + 1) gchoose Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (Suc n) gchoose Suc n = int n + 1 gchoose Suc n
[PROOF STEP]
by (simp add: add.commute)
[PROOF STATE]
proof (state)
this:
int (Suc n) gchoose Suc n = int n + 1 gchoose Suc n

goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (Suc n) gchoose Suc n = int n + 1 gchoose Suc n

goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
have "\<dots> = (int n gchoose n) + (int n gchoose (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int n + 1 gchoose Suc n = int n gchoose n + (int n gchoose Suc n)
[PROOF STEP]
by (fact gbinomial_int_Suc_Suc)
[PROOF STATE]
proof (state)
this:
int n + 1 gchoose Suc n = int n gchoose n + (int n gchoose Suc n)

goal (1 subgoal):
 1. \<And>n. int n gchoose n = 1 \<Longrightarrow> int (Suc n) gchoose Suc n = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
int (Suc n) gchoose Suc n = int n gchoose n + (int n gchoose Suc n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
int (Suc n) gchoose Suc n = int n gchoose n + (int n gchoose Suc n)

goal (1 subgoal):
 1. int (Suc n) gchoose Suc n = 1
[PROOF STEP]
by (simp add: Suc gbinomial_eq_0)
[PROOF STATE]
proof (state)
this:
int (Suc n) gchoose Suc n = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma concat_leaf_nodes_leaves_list: "(concat (map leaves (leaf_nodes_list ts))) = leaves_list ts"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map leaves (leaf_nodes_list ts)) = leaves_list ts
[PROOF STEP]
apply(induction ts)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. concat (map leaves (leaf_nodes_list [])) = leaves_list []
 2. \<And>a ts. concat (map leaves (leaf_nodes_list ts)) = leaves_list ts \<Longrightarrow> concat (map leaves (leaf_nodes_list (a # ts))) = leaves_list (a # ts)
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map leaves (leaf_nodes_list [])) = leaves_list []
[PROOF STEP]
by auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a ts. concat (map leaves (leaf_nodes_list ts)) = leaves_list ts \<Longrightarrow> concat (map leaves (leaf_nodes_list (a # ts))) = leaves_list (a # ts)
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map leaves (leaf_nodes_list ts_)) = leaves_list ts_ \<Longrightarrow> concat (map leaves (leaf_nodes_list (a_ # ts_))) = leaves_list (a_ # ts_)
[PROOF STEP]
using concat_leaf_nodes_leaves
[PROOF STATE]
proof (prove)
using this:
concat (map leaves (leaf_nodes ?t)) = leaves ?t

goal (1 subgoal):
 1. concat (map leaves (leaf_nodes_list ts_)) = leaves_list ts_ \<Longrightarrow> concat (map leaves (leaf_nodes_list (a_ # ts_))) = leaves_list (a_ # ts_)
[PROOF STEP]
by auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma subspace_image: assumes S: "m1.subspace S" shows "m2.subspace (f ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2.subspace (f ` S)
[PROOF STEP]
unfolding m2.subspace_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'c) \<in> f ` S \<and> (\<forall>x\<in>f ` S. \<forall>y\<in>f ` S. x + y \<in> f ` S) \<and> (\<forall>c. \<forall>x\<in>f ` S. c *b x \<in> f ` S)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. (0::'c) \<in> f ` S
 2. \<And>x xa y xb. \<lbrakk>xa \<in> S; xb \<in> S\<rbrakk> \<Longrightarrow> f xa + f xb \<in> f ` S
 3. \<And>c x xa. xa \<in> S \<Longrightarrow> c *b f xa \<in> f ` S
[PROOF STEP]
show "0 \<in> f ` S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'c) \<in> f ` S
[PROOF STEP]
by (rule image_eqI[of _ _ 0]) (auto simp: S m1.subspace_0)
[PROOF STATE]
proof (state)
this:
(0::'c) \<in> f ` S

goal (2 subgoals):
 1. \<And>x xa y xb. \<lbrakk>xa \<in> S; xb \<in> S\<rbrakk> \<Longrightarrow> f xa + f xb \<in> f ` S
 2. \<And>c x xa. xa \<in> S \<Longrightarrow> c *b f xa \<in> f ` S
[PROOF STEP]
show "x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> f x + f y \<in> f ` S" for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> f x + f y \<in> f ` S
[PROOF STEP]
by (rule image_eqI[of _ _ "x + y"]) (auto simp: S m1.subspace_add add)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<in> S; ?y \<in> S\<rbrakk> \<Longrightarrow> f ?x + f ?y \<in> f ` S

goal (1 subgoal):
 1. \<And>c x xa. xa \<in> S \<Longrightarrow> c *b f xa \<in> f ` S
[PROOF STEP]
show "x \<in> S \<Longrightarrow> r *b f x \<in> f ` S" for r x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> S \<Longrightarrow> r *b f x \<in> f ` S
[PROOF STEP]
by (rule image_eqI[of _ _ "r *a x"]) (auto simp: S m1.subspace_scale scale)
[PROOF STATE]
proof (state)
this:
?x \<in> S \<Longrightarrow> ?r *b f ?x \<in> f ` S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma XpZ_inv:
  "XpZ * XpZ = 1\<^sub>m 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. XpZ * XpZ = 1\<^sub>m 2
[PROOF STEP]
unfolding XpZ_def X_def Z_def times_mat_def one_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row (complex_of_real (- 1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)))) (dim_col (complex_of_real (- 1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)))) (\<lambda>(i, j). Matrix.row (complex_of_real (- 1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1))) i \<bullet> Matrix.col (complex_of_real (- 1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1))) j) = Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 1 else 0)
[PROOF STEP]
apply (rule cong_mat, simp+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < 2; j < 2\<rbrakk> \<Longrightarrow> (i = 0 \<longrightarrow> (j = 0 \<longrightarrow> (Matrix.vec 2 (\<lambda>j. if j = 0 then 0 else 1) + Matrix.vec 2 (\<lambda>j. if 0 < j then 0 else 1)) \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)) 0 = complex_of_real (sqrt 2) * complex_of_real (sqrt 2)) \<and> (0 < j \<longrightarrow> (Matrix.vec 2 (\<lambda>j. if j = 0 then 0 else 1) + Matrix.vec 2 (\<lambda>j. if 0 < j then 0 else 1)) \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)) j = 0)) \<and> (0 < i \<longrightarrow> (i = j \<longrightarrow> (Matrix.vec 2 (\<lambda>ja. if j = ja then 0 else 1) + Matrix.vec 2 (\<lambda>ja. if j \<noteq> ja then 0 else - 1)) \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)) j = complex_of_real (sqrt 2) * complex_of_real (sqrt 2)) \<and> (i \<noteq> j \<longrightarrow> (Matrix.vec 2 (\<lambda>j. if i = j then 0 else 1) + Matrix.vec 2 (\<lambda>j. if i \<noteq> j then 0 else - 1)) \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1) + Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1)) j = 0))
[PROOF STEP]
apply (auto simp add: Matrix.scalar_prod_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. complex_of_real (sqrt 2) * complex_of_real (sqrt 2) = 2
 2. \<And>j. \<lbrakk>j < 2; 0 < j\<rbrakk> \<Longrightarrow> complex_of_real (sqrt 2) * complex_of_real (sqrt 2) = 2
[PROOF STEP]
apply (auto simp add: Gates.csqrt_2_sq)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "nat (i + j) <= nat i + nat j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat (i + j) \<le> nat i + nat j
[PROOF STEP]
by linarith


[STATEMENT]
lemma "ai = e/(e-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ai = e / (e - 1)
[PROOF STEP]
unfolding ai_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f2 / (f2 - f2 / e) = e / (e - 1)
[PROOF STEP]
by(simp add: field_simps)


[STATEMENT]
lemma split_01: "{0..1::real} = {0..1/2} \<union> {1/2..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0..1} = {0..1 / 2} \<union> {1 / 2..1}
[PROOF STEP]
by force


[STATEMENT]
lemma tllist_all2_conv_all_tnth:
  "tllist_all2 P Q xs ys \<longleftrightarrow>
  tlength xs = tlength ys \<and>
  (\<forall>n. enat n < tlength xs \<longrightarrow> P (tnth xs n) (tnth ys n)) \<and>
  (tfinite xs \<longrightarrow> Q (terminal xs) (terminal ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tllist_all2 P Q xs ys = (tlength xs = tlength ys \<and> (\<forall>n. enat n < tlength xs \<longrightarrow> P (tnth xs n) (tnth ys n)) \<and> (tfinite xs \<longrightarrow> Q (terminal xs) (terminal ys)))
[PROOF STEP]
by transfer(auto 4 4 simp add: llist_all2_conv_all_lnth split: if_split_asm dest: lfinite_llength_enat not_lfinite_llength)


[STATEMENT]
lemma prime_factors_gt_0_nat:
  "p \<in> prime_factors x \<Longrightarrow> p > (0::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<in># prime_factorization x \<Longrightarrow> 0 < p
[PROOF STEP]
by (simp add: in_prime_factors_imp_prime prime_gt_0_nat)


[STATEMENT]
lemma INF_pair:
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> _ :: complete_lattice"
  shows "(INF i \<in> A. INF j \<in> B. f i j) = (INF p \<in> A \<times> B. f (fst p) (snd p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (INF i\<in>A. Inf (f i ` B)) = (INF p\<in>A \<times> B. f (fst p) (snd p))
[PROOF STEP]
by (rule antisym) (auto intro!: INF_greatest INF_lower2)


[STATEMENT]
lemma prod_upto_nat_unfold:
  "prod f {m..(n::nat)} = (if n < m then 1 else (if n = 0 then f 0 else f n * prod f {m..(n - 1)}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod f {m..n} = (if n < m then 1::'a else if n = 0 then f 0 else f n * prod f {m..n - 1})
[PROOF STEP]
by auto (auto simp add: gr0_conv_Suc atLeastAtMostSuc_conv)


[STATEMENT]
lemma dtree_out_arcs:
  "snd ` {(x,e). (if e \<in> out_arcs T r then x = to_dtree_aux (head T e) else False)} = out_arcs T r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd ` {(x, e). if e \<in> out_arcs T r then x = to_dtree_aux (head T e) else False} = out_arcs T r
[PROOF STEP]
using dtree_children_img_alt
[PROOF STATE]
proof (prove)
using this:
(\<lambda>e. (to_dtree_aux (head T e), e)) ` out_arcs T ?r = {(x, e). if e \<in> out_arcs T ?r then x = to_dtree_aux (head T e) else False}

goal (1 subgoal):
 1. snd ` {(x, e). if e \<in> out_arcs T r then x = to_dtree_aux (head T e) else False} = out_arcs T r
[PROOF STEP]
by (metis image_add_snd_snd_id)


[STATEMENT]
lemma comm_groupI:
  fixes G (structure)
  assumes m_closed:
      "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"
    and one_closed: "\<one> \<in> carrier G"
    and m_assoc:
      "!!x y z. [| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
      (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"
    and m_comm:
      "!!x y. [| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"
    and l_one: "!!x. x \<in> carrier G ==> \<one> \<otimes> x = x"
    and l_inv_ex: "!!x. x \<in> carrier G ==> \<exists>y \<in> carrier G. y \<otimes> x = \<one>"
  shows "comm_group G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comm_group G
[PROOF STEP]
by (fast intro: group.group_comm_groupI groupI assms)


[STATEMENT]
theorem H1:
  assumes h1: "\<turnstile> \<box>[P]_v" and h2: "\<turnstile> \<box>[P \<longrightarrow> Q]_v"
  shows "\<turnstile> \<box>[Q]_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<turnstile> \<box>[Q]_v
[PROOF STEP]
using assms ax4[unlifted]
[PROOF STATE]
proof (prove)
using this:
\<turnstile> \<box>[P]_v
\<turnstile> \<box>[P \<longrightarrow> Q]_v
(\<box>[?P1 \<longrightarrow> ?Q1]_?v1) ?w \<longrightarrow> (\<box>[?P1]_?v1) ?w \<longrightarrow> (\<box>[?Q1]_?v1) ?w

goal (1 subgoal):
 1. \<turnstile> \<box>[Q]_v
[PROOF STEP]
by force


[STATEMENT]
lemma comp_char:
    shows "g \<cdot> f = (if C1.arr (C1 (fst g) (fst f)) \<and> C2.arr (C2 (snd g) (snd f)) then
                       (C1 (fst g) (fst f), C2 (snd g) (snd f))
                    else Null)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<cdot> f = (if C1.seq (fst g) (fst f) \<and> C2.seq (snd g) (snd f) then (fst g \<cdot>\<^sub>1 fst f, snd g \<cdot>\<^sub>2 snd f) else (C1.null, C2.null))
[PROOF STEP]
using comp_def
[PROOF STATE]
proof (prove)
using this:
?g \<cdot> ?f = (if (C1.arr (fst ?f) \<and> C2.arr (snd ?f)) \<and> (C1.arr (fst ?g) \<and> C2.arr (snd ?g)) \<and> (if C1.arr (fst ?f) \<and> C2.arr (snd ?f) then (C1.cod (fst ?f), C2.cod (snd ?f)) else (C1.null, C2.null)) = (if C1.arr (fst ?g) \<and> C2.arr (snd ?g) then (C1.dom (fst ?g), C2.dom (snd ?g)) else (C1.null, C2.null)) then (fst ?g \<cdot>\<^sub>1 fst ?f, snd ?g \<cdot>\<^sub>2 snd ?f) else (C1.null, C2.null))

goal (1 subgoal):
 1. g \<cdot> f = (if C1.seq (fst g) (fst f) \<and> C2.seq (snd g) (snd f) then (fst g \<cdot>\<^sub>1 fst f, snd g \<cdot>\<^sub>2 snd f) else (C1.null, C2.null))
[PROOF STEP]
by auto


[STATEMENT]
lemma index_mat_multcol[simp]:
  "i < dim_row A \<Longrightarrow> j < dim_col A \<Longrightarrow> multcol k a A $$ (i,j) = (if k = j then a * A $$ (i,j) else A $$ (i,j))"
  "i < dim_row A \<Longrightarrow> j < dim_col A \<Longrightarrow> multcol j a A $$ (i,j) = a * A $$ (i,j)"
  "i < dim_row A \<Longrightarrow> j < dim_col A \<Longrightarrow> k \<noteq> j \<Longrightarrow> multcol k a A $$ (i,j) = A $$ (i,j)"
  "dim_row (multcol k a A) = dim_row A" "dim_col (multcol k a A) = dim_col A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> multcol k a A $$ (i, j) = (if k = j then a * A $$ (i, j) else A $$ (i, j))) &&& (\<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> multcol j a A $$ (i, j) = a * A $$ (i, j))) &&& (\<lbrakk>i < dim_row A; j < dim_col A; k \<noteq> j\<rbrakk> \<Longrightarrow> multcol k a A $$ (i, j) = A $$ (i, j)) &&& dim_row (multcol k a A) = dim_row A &&& dim_col (multcol k a A) = dim_col A
[PROOF STEP]
unfolding mat_multcol_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> mat (dim_row A) (dim_col A) (\<lambda>(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = (if k = j then a * A $$ (i, j) else A $$ (i, j))) &&& (\<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> mat (dim_row A) (dim_col A) (\<lambda>(i, ja). if j = ja then a * A $$ (i, ja) else A $$ (i, ja)) $$ (i, j) = a * A $$ (i, j))) &&& (\<lbrakk>i < dim_row A; j < dim_col A; k \<noteq> j\<rbrakk> \<Longrightarrow> mat (dim_row A) (dim_col A) (\<lambda>(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = A $$ (i, j)) &&& dim_row (mat (dim_row A) (dim_col A) (\<lambda>(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_row A &&& dim_col (mat (dim_row A) (dim_col A) (\<lambda>(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_col A
[PROOF STEP]
by auto


[STATEMENT]
lemma sets_in_Pi[measurable (raw)]:
  "finite I \<Longrightarrow> f \<in> measurable N (PiM I M) \<Longrightarrow>
  (\<And>j. j \<in> I \<Longrightarrow> {x\<in>space (M j). x \<in> F j} \<in> sets (M j)) \<Longrightarrow>
  Measurable.pred N (\<lambda>x. f x \<in> Pi I F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; f \<in> N \<rightarrow>\<^sub>M Pi\<^sub>M I M; \<And>j. j \<in> I \<Longrightarrow> {x \<in> space (M j). x \<in> F j} \<in> sets (M j)\<rbrakk> \<Longrightarrow> Measurable.pred N (\<lambda>x. f x \<in> Pi I F)
[PROOF STEP]
unfolding pred_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; f \<in> N \<rightarrow>\<^sub>M Pi\<^sub>M I M; \<And>j. j \<in> I \<Longrightarrow> {x \<in> space (M j). x \<in> F j} \<in> sets (M j)\<rbrakk> \<Longrightarrow> {x \<in> space N. f x \<in> Pi I F} \<in> sets N
[PROOF STEP]
by (rule measurable_sets_Collect[of f N "PiM I M", OF _ sets_in_Pi_aux]) auto


[STATEMENT]
lemma isometry_inverse:
  assumes "isometry f"
  shows "isometry (inv f)"
        "bij f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isometry (inv f) &&& bij f
[PROOF STEP]
using isometry_on_inverse[OF isometryD(1)[OF assms]] isometryD(3)[OF assms]
[PROOF STATE]
proof (prove)
using this:
isometry_on (range f) (inv f)
?x \<in> UNIV \<Longrightarrow> inv f (f ?x) = ?x
?y \<in> range f \<Longrightarrow> f (inv f ?y) = ?y
bij_betw f UNIV (range f)
surj f

goal (1 subgoal):
 1. isometry (inv f) &&& bij f
[PROOF STEP]
unfolding isometry_def
[PROOF STATE]
proof (prove)
using this:
isometry_on (range f) (inv f)
?x \<in> UNIV \<Longrightarrow> inv f (f ?x) = ?x
?y \<in> range f \<Longrightarrow> f (inv f ?y) = ?y
bij_betw f UNIV (range f)
surj f

goal (1 subgoal):
 1. isometry_on UNIV (inv f) \<and> surj (inv f) &&& bij f
[PROOF STEP]
by (auto simp add: bij_imp_bij_inv bij_is_surj)


[STATEMENT]
lemma "\<Gamma>\<turnstile>\<^sub>t \<lbrace>\<acute>M=0 \<and> \<acute>N=0\<rbrace>
      WHILE (\<acute>M < i)
      INV \<lbrace>\<acute>M \<le> i \<and> (\<acute>M \<noteq> 0 \<longrightarrow> \<acute>N = j) \<and> \<acute>N \<le> j\<rbrace>
      VAR MEASURE (i - \<acute>M)
      DO
         \<acute>N :== 0;;
         WHILE (\<acute>N < j)
         FIX m.
         INV \<lbrace>\<acute>M=m \<and> \<acute>N \<le> j\<rbrace>
         VAR MEASURE (j - \<acute>N)
         DO
           \<acute>N :== \<acute>N + 1
         OD;;
       \<acute>M :== \<acute>M + 1
       OD
       \<lbrace>\<acute>M=i \<and> (\<acute>M\<noteq>0 \<longrightarrow> \<acute>N=j)\<rbrace>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Gamma>\<turnstile>\<^sub>t \<lbrace>\<acute>M = 0 \<and> \<acute>N = 0\<rbrace> WHILE \<acute>M < i INV \<lbrace>\<acute>M \<le> i \<and> (\<acute>M \<noteq> 0 \<longrightarrow> \<acute>N = j) \<and> \<acute>N \<le> j\<rbrace> VAR MEASURE i - \<acute>M DO \<acute>N :== 0;; WHILE \<lbrace>\<acute>N < j\<rbrace> FIX m. INV \<lbrace>\<acute>M = m \<and> \<acute>N \<le> j\<rbrace> VAR MEASURE j - \<acute>N (\<acute>N :== \<acute>N + 1);; \<acute>M :== \<acute>M + 1 OD \<lbrace>\<acute>M = i \<and> (\<acute>M \<noteq> 0 \<longrightarrow> \<acute>N = j)\<rbrace>
[PROOF STEP]
apply vcg
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>M N. \<lbrakk>M = 0; N = 0\<rbrakk> \<Longrightarrow> M \<le> i \<and> (M \<noteq> 0 \<longrightarrow> N = j) \<and> N \<le> j
 2. \<And>M N. \<lbrakk>M \<le> i; M \<noteq> 0 \<longrightarrow> N = j; N \<le> j; M < i\<rbrakk> \<Longrightarrow> 0 \<le> j \<and> (\<forall>Ma N. Ma = M \<and> N \<le> j \<and> \<not> N < j \<longrightarrow> i - (M + 1) < i - M \<and> M + 1 \<le> i \<and> (M + 1 \<noteq> 0 \<longrightarrow> N = j))
 3. \<And>M N. \<lbrakk>N \<le> j; N < j\<rbrakk> \<Longrightarrow> j - (N + 1) < j - N \<and> M = M \<and> N + 1 \<le> j
 4. \<And>M N. \<lbrakk>M \<le> i; M \<noteq> 0 \<longrightarrow> N = j; N \<le> j; \<not> M < i\<rbrakk> \<Longrightarrow> M = i \<and> (M \<noteq> 0 \<longrightarrow> N = j)
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>M N. \<lbrakk>0 < M \<longrightarrow> N = j; N \<le> j; M < i\<rbrakk> \<Longrightarrow> (\<exists>N\<le>j. \<not> N < j) \<longrightarrow> i - Suc M < i - M
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sum_list_split: "sum_list (l @ (a::'a::monoid_add) # r) = (sum_list l) + a + (sum_list r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (l @ a # r) = sum_list l + a + sum_list r
[PROOF STEP]
by (induct l) (auto simp add: add.assoc)


[STATEMENT]
lemma (in strategic_space_2p) M_correct:
  assumes "\<phi>\<^sub>A = pi/2 \<and> \<theta>\<^sub>A = pi/2"
  shows "U\<^sub>A = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
 2. dim_row (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
 3. dim_col (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
show "dim_row U\<^sub>A = dim_row M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
using mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_row (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_row (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
 2. dim_col (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
show "dim_col U\<^sub>A = dim_col M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
using mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_col (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_col (Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]]) = dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
assume a0:"i < dim_row M" and a1:"j < dim_col M"
[PROOF STATE]
proof (state)
this:
i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
[PROOF STEP]
show "U\<^sub>A $$ (i,j) = M $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])

goal (1 subgoal):
 1. Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
have "i\<in>{0,1} \<and> j\<in>{0,1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<in> {0, 1} \<and> j \<in> {0, 1}
[PROOF STEP]
using a0 a1 mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. i \<in> {0, 1} \<and> j \<in> {0, 1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<in> {0, 1} \<and> j \<in> {0, 1}

goal (1 subgoal):
 1. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]]); j < dim_col (Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]])\<rbrakk> \<Longrightarrow> Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i \<in> {0, 1} \<and> j \<in> {0, 1}

goal (1 subgoal):
 1. Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
using mat_of_cols_list_def exp_of_half_pi[of "pi/2"] exp_of_minus_half_pi[of "pi/2"]
[PROOF STATE]
proof (prove)
using this:
i \<in> {0, 1} \<and> j \<in> {0, 1}
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)
pi / 2 = pi / 2 \<Longrightarrow> exp (\<i> * complex_of_real (pi / 2)) = \<i>
pi / 2 = pi / 2 \<Longrightarrow> exp (- (\<i> * complex_of_real (pi / 2))) = - \<i>

goal (1 subgoal):
 1. Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)
[PROOF STEP]
by (auto simp add: assms sin_45 cos_45)
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list 2 [exp (\<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2)) # map complex_of_real [- sin (\<theta>\<^sub>A / 2)], [complex_of_real (sin (\<theta>\<^sub>A / 2)), exp (- \<i> * complex_of_real \<phi>\<^sub>A) * complex_of_real (cos (\<theta>\<^sub>A / 2))]] $$ (i, j) = Tensor.mat_of_cols_list 2 [\<i> * complex_of_real (sqrt 2) / 2 # map complex_of_real [- 1 * sqrt 2 / 2], [complex_of_real (1 * sqrt 2 / 2), - \<i> * complex_of_real (sqrt 2) / 2]] $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem updVal_preserves_sWls[simp]:
assumes "sWls SEM (asSort xs) sX" and "sWlsVal SEM val"
shows "sWlsVal SEM (val (x := sX)_xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sWlsVal SEM (val (x := sX)_xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sWls SEM (asSort xs) sX
sWlsVal SEM val

goal (1 subgoal):
 1. sWlsVal SEM (val (x := sX)_xs)
[PROOF STEP]
unfolding sWlsVal_def
[PROOF STATE]
proof (prove)
using this:
sWls SEM (asSort xs) sX
\<forall>ys y. sWls SEM (asSort ys) (val ys y)

goal (1 subgoal):
 1. \<forall>ys y. sWls SEM (asSort ys) ((val (x := sX)_xs) ys y)
[PROOF STEP]
by auto


[STATEMENT]
lemma finite_fv_fo_terms_set: "finite (fv_fo_terms_set ts)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (fv_fo_terms_set ts)
[PROOF STEP]
by (auto simp: fv_fo_terms_set_def finite_fv_fo_term_set)


[STATEMENT]
lemma homotopic_loops:
   "homotopic_loops s p q \<longleftrightarrow>
      (\<exists>h. continuous_on ({0..1::real} \<times> {0..1}) h \<and>
          image h ({0..1} \<times> {0..1}) \<subseteq> s \<and>
          (\<forall>x \<in> {0..1}. h(0,x) = p x) \<and>
          (\<forall>x \<in> {0..1}. h(1,x) = q x) \<and>
          (\<forall>t \<in> {0..1}. pathfinish(h \<circ> Pair t) = pathstart(h \<circ> Pair t)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_loops s p q = (\<exists>h. continuous_on ({0..1} \<times> {0..1}) h \<and> h ` ({0..1} \<times> {0..1}) \<subseteq> s \<and> (\<forall>x\<in>{0..1}. h (0, x) = p x) \<and> (\<forall>x\<in>{0..1}. h (1, x) = q x) \<and> (\<forall>t\<in>{0..1}. pathfinish (h \<circ> Pair t) = pathstart (h \<circ> Pair t)))
[PROOF STEP]
by (simp add: homotopic_loops_def pathstart_def pathfinish_def homotopic_with)


[STATEMENT]
lemma ceiling_divide_eq_div: "\<lceil>of_int a / of_int b\<rceil> = - (- a div b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>of_int a / of_int b\<rceil> = - (- a div b)
[PROOF STEP]
by (metis ceiling_def floor_divide_of_int_eq minus_divide_left of_int_minus)


[STATEMENT]
lemma singleton2:" (\<exists>n. Rep_nat_int i = {n}) \<longrightarrow> |i| = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>n. Rep_nat_int i = {n}) \<longrightarrow> |i| = 1
[PROOF STEP]
using card_1_singletonE card'.rep_eq
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card ?A = 1; \<And>x. ?A = {x} \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
|?x| = card (Rep_nat_int ?x)

goal (1 subgoal):
 1. (\<exists>n. Rep_nat_int i = {n}) \<longrightarrow> |i| = 1
[PROOF STEP]
by fastforce


[STATEMENT]
lemma convergent_mult:
  fixes X Y :: "nat \<Rightarrow> 'a::topological_semigroup_mult"
  assumes "convergent (\<lambda>n. X n)"
    and "convergent (\<lambda>n. Y n)"
  shows "convergent (\<lambda>n. X n * Y n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent (\<lambda>n. X n * Y n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
convergent X
convergent Y

goal (1 subgoal):
 1. convergent (\<lambda>n. X n * Y n)
[PROOF STEP]
unfolding convergent_def
[PROOF STATE]
proof (prove)
using this:
\<exists>L. X \<longlonglongrightarrow> L
\<exists>L. Y \<longlonglongrightarrow> L

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. X n * Y n) \<longlonglongrightarrow> L
[PROOF STEP]
by (blast intro: tendsto_mult)


[STATEMENT]
lemma kauff_mat_tensor_distrib:
"\<forall>xs.\<forall>ys.(kauff_mat (basic xs \<otimes> basic ys)
 = kauff_mat (basic xs) \<otimes> kauff_mat (basic ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>xs ys. kauff_mat (basic xs \<otimes> basic ys) = kauff_mat (basic xs) \<otimes> kauff_mat (basic ys)
[PROOF STEP]
apply(rule allI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs. \<forall>ys. kauff_mat (basic xs \<otimes> basic ys) = kauff_mat (basic xs) \<otimes> kauff_mat (basic ys)
[PROOF STEP]
apply (rule allI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs ys. kauff_mat (basic xs \<otimes> basic ys) = kauff_mat (basic xs) \<otimes> kauff_mat (basic ys)
[PROOF STEP]
apply (induct_tac xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xs ys. kauff_mat (basic [] \<otimes> basic ys) = kauff_mat (basic []) \<otimes> kauff_mat (basic ys)
 2. \<And>xs ys a list. kauff_mat (basic list \<otimes> basic ys) = kauff_mat (basic list) \<otimes> kauff_mat (basic ys) \<Longrightarrow> kauff_mat (basic (a # list) \<otimes> basic ys) = kauff_mat (basic (a # list)) \<otimes> kauff_mat (basic ys)
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>ys. blockmat ys = rat_poly.vec_mat_Tensor [1] (blockmat ys)
 2. \<And>ys a list. blockmat (list \<otimes> ys) = blockmat list \<otimes> blockmat ys \<Longrightarrow> brickmat a \<otimes> (blockmat list \<otimes> blockmat ys) = brickmat a \<otimes> blockmat list \<otimes> blockmat ys
[PROOF STEP]
apply (metis rat_poly.vec_mat_Tensor_vector_id)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ys a list. blockmat (list \<otimes> ys) = blockmat list \<otimes> blockmat ys \<Longrightarrow> brickmat a \<otimes> (blockmat list \<otimes> blockmat ys) = brickmat a \<otimes> blockmat list \<otimes> blockmat ys
[PROOF STEP]
apply (simp add:tens_assoc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma content_free_unit:
  assumes "content (p::'a::{idom,semiring_gcd} poly) = 1"
  shows "p dvd 1 \<longleftrightarrow> degree p = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p dvd 1) = (degree p = 0)
[PROOF STEP]
by (insert assms, auto dest!:degree0_coeffs simp: normalize_1_iff poly_dvd_1)


[STATEMENT]
lemma length_zero_iff_borders_eq:"\<parallel>r\<parallel> = 0 \<longleftrightarrow> left r = right r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<parallel>r\<parallel> = 0) = (left r = right r)
[PROOF STEP]
using length_def
[PROOF STATE]
proof (prove)
using this:
\<parallel>?r\<parallel> \<equiv> right ?r - left ?r

goal (1 subgoal):
 1. (\<parallel>r\<parallel> = 0) = (left r = right r)
[PROOF STEP]
by auto


[STATEMENT]
lemma unit_vecs_distinct: "distinct (unit_vecs n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (unit_vecs n)
[PROOF STEP]
unfolding distinct_conv_nth unit_vecs_length
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<n. \<forall>j<n. i \<noteq> j \<longrightarrow> unit_vecs n ! i \<noteq> unit_vecs n ! j
[PROOF STEP]
proof (intro allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> unit_vecs n ! i \<noteq> unit_vecs n ! j
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> unit_vecs n ! i \<noteq> unit_vecs n ! j
[PROOF STEP]
assume *: "i < n" "j < n" "i \<noteq> j"
[PROOF STATE]
proof (state)
this:
i < n
j < n
i \<noteq> j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> unit_vecs n ! i \<noteq> unit_vecs n ! j
[PROOF STEP]
show "unit_vecs n ! i \<noteq> unit_vecs n ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vecs n ! i \<noteq> unit_vecs n ! j
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. unit_vecs n ! i = unit_vecs n ! j \<Longrightarrow> False
[PROOF STEP]
assume "unit_vecs n ! i = unit_vecs n ! j"
[PROOF STATE]
proof (state)
this:
unit_vecs n ! i = unit_vecs n ! j

goal (1 subgoal):
 1. unit_vecs n ! i = unit_vecs n ! j \<Longrightarrow> False
[PROOF STEP]
from arg_cong[OF this, of "\<lambda> v. v $ i"]
[PROOF STATE]
proof (chain)
picking this:
unit_vecs n ! i $ i = unit_vecs n ! j $ i
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
unit_vecs n ! i $ i = unit_vecs n ! j $ i

goal (1 subgoal):
 1. False
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
unit_vecs n ! i $ i = unit_vecs n ! j $ i
i < n
j < n
i \<noteq> j

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding unit_vecs_def
[PROOF STATE]
proof (prove)
using this:
map (unit_vec n) [0..<n] ! i $ i = map (unit_vec n) [0..<n] ! j $ i
i < n
j < n
i \<noteq> j

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:
unit_vecs n ! i \<noteq> unit_vecs n ! j

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma wf_hd_neq_all:
  assumes wf_ss_w: "wf_dom ss w "
      and w_n_nil: "w \<noteq> [] "
    shows " ss!(hd w) \<noteq> rev [0..<n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ss ! hd w \<noteq> rev [0..<n]
[PROOF STEP]
proof(rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
assume "\<not> ss ! hd w \<noteq>  (rev [0..<n])"
[PROOF STATE]
proof (state)
this:
\<not> ss ! hd w \<noteq> rev [0..<n]

goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
note x = this
[PROOF STATE]
proof (state)
this:
\<not> ss ! hd w \<noteq> rev [0..<n]

goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
from wf_ss_w
[PROOF STATE]
proof (chain)
picking this:
wf_dom ss w
[PROOF STEP]
have "\<forall>x\<in> set w. x < n" and "sorted w"
[PROOF STATE]
proof (prove)
using this:
wf_dom ss w

goal (1 subgoal):
 1. \<forall>x\<in>set w. x < n &&& Sorted_Less.sorted w
[PROOF STEP]
by (auto simp add:wf_dom_def)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>set w. x < n
Sorted_Less.sorted w

goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>set w. x < n
Sorted_Less.sorted w
[PROOF STEP]
have "hd w < n" and y:"\<forall>x \<in> set w. x \<ge> hd w"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>set w. x < n
Sorted_Less.sorted w

goal (1 subgoal):
 1. hd w < n &&& \<forall>x\<in>set w. hd w \<le> x
[PROOF STEP]
using w_n_nil
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>set w. x < n
Sorted_Less.sorted w
w \<noteq> []

goal (1 subgoal):
 1. hd w < n &&& \<forall>x\<in>set w. hd w \<le> x
[PROOF STEP]
by (induct w) (auto simp add:sorted_wrt_append)
[PROOF STATE]
proof (state)
this:
hd w < n
\<forall>x\<in>set w. hd w \<le> x

goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
with wf_ss_w x
[PROOF STATE]
proof (chain)
picking this:
wf_dom ss w
\<not> ss ! hd w \<noteq> rev [0..<n]
hd w < n
\<forall>x\<in>set w. hd w \<le> x
[PROOF STEP]
have  "(\<exists>x\<in> set w. (x,hd w)\<in> g_E G \<and> x < hd w)"
[PROOF STATE]
proof (prove)
using this:
wf_dom ss w
\<not> ss ! hd w \<noteq> rev [0..<n]
hd w < n
\<forall>x\<in>set w. hd w \<le> x

goal (1 subgoal):
 1. \<exists>x\<in>set w. (x, hd w) \<in> g_E G \<and> x < hd w
[PROOF STEP]
by (auto simp add:wf_dom_def)
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>set w. (x, hd w) \<in> g_E G \<and> x < hd w

goal (1 subgoal):
 1. \<not> ss ! hd w \<noteq> rev [0..<n] \<Longrightarrow> False
[PROOF STEP]
with y
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>set w. hd w \<le> x
\<exists>x\<in>set w. (x, hd w) \<in> g_E G \<and> x < hd w
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>set w. hd w \<le> x
\<exists>x\<in>set w. (x, hd w) \<in> g_E G \<and> x < hd w

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma quasi_isometry_betweenD:
  assumes "lambda C-quasi_isometry_between X Y f"
  shows "lambda C-quasi_isometry_on X f"
        "f`X \<subseteq> Y"
        "\<And>y. y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) y \<le> C"
        "\<And>x y. x \<in> X \<Longrightarrow> y \<in> X \<Longrightarrow> dist (f x) (f y) \<le> lambda * dist x y + C"
        "\<And>x y. x \<in> X \<Longrightarrow> y \<in> X \<Longrightarrow> dist (f x) (f y) \<ge> (1/lambda) * dist x y - C"
        "lambda \<ge> 1" "C \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (lambda C -quasi_isometry_on X f &&& f ` X \<subseteq> Y &&& (\<And>y. y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) y \<le> C)) &&& ((\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> dist (f x) (f y) \<le> lambda * dist x y + C) &&& (\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> 1 / lambda * dist x y - C \<le> dist (f x) (f y))) &&& 1 \<le> lambda &&& 0 \<le> C
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry_between X Y f

goal (1 subgoal):
 1. (lambda C -quasi_isometry_on X f &&& f ` X \<subseteq> Y &&& (\<And>y. y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) y \<le> C)) &&& ((\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> dist (f x) (f y) \<le> lambda * dist x y + C) &&& (\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> 1 / lambda * dist x y - C \<le> dist (f x) (f y))) &&& 1 \<le> lambda &&& 0 \<le> C
[PROOF STEP]
unfolding quasi_isometry_between_def quasi_isometry_on_def
[PROOF STATE]
proof (prove)
using this:
(1 \<le> lambda \<and> 0 \<le> C \<and> (\<forall>x\<in>X. \<forall>y\<in>X. dist (f x) (f y) \<le> lambda * dist x y + C \<and> 1 / lambda * dist x y - C \<le> dist (f x) (f y))) \<and> f ` X \<subseteq> Y \<and> (\<forall>y\<in>Y. \<exists>x\<in>X. dist (f x) y \<le> C)

goal (1 subgoal):
 1. (1 \<le> lambda \<and> 0 \<le> C \<and> (\<forall>x\<in>X. \<forall>y\<in>X. dist (f x) (f y) \<le> lambda * dist x y + C \<and> 1 / lambda * dist x y - C \<le> dist (f x) (f y)) &&& f ` X \<subseteq> Y &&& (\<And>y. y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) y \<le> C)) &&& ((\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> dist (f x) (f y) \<le> lambda * dist x y + C) &&& (\<And>x y. \<lbrakk>x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> 1 / lambda * dist x y - C \<le> dist (f x) (f y))) &&& 1 \<le> lambda &&& 0 \<le> C
[PROOF STEP]
by auto


[STATEMENT]
lemma bitstrings_finite: "finite {xs::bool list. length xs = m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {xs. length xs = m}
[PROOF STEP]
using finite_lists_length_eq[where A="UNIV"]
[PROOF STATE]
proof (prove)
using this:
finite UNIV \<Longrightarrow> finite {xs. set xs \<subseteq> UNIV \<and> length xs = ?n}

goal (1 subgoal):
 1. finite {xs. length xs = m}
[PROOF STEP]
by force


[STATEMENT]
lemma emeasure_uniform_count_measure:
  "finite A \<Longrightarrow> X \<subseteq> A \<Longrightarrow> emeasure (uniform_count_measure A) X = card X / card A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; X \<subseteq> A\<rbrakk> \<Longrightarrow> emeasure (uniform_count_measure A) X = ennreal (real (card X) / real (card A))
[PROOF STEP]
by (simp add: emeasure_point_measure_finite uniform_count_measure_def divide_inverse ennreal_mult
                ennreal_of_nat_eq_real_of_nat)


[STATEMENT]
lemma finite_union_of_Union:
   "\<lbrakk>finite \<U>; \<And>S. S \<in> \<U> \<Longrightarrow> (finite union_of P) S\<rbrakk> \<Longrightarrow> (finite union_of P) (\<Union>\<U>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite \<U>; \<And>S. S \<in> \<U> \<Longrightarrow> (finite union_of P) S\<rbrakk> \<Longrightarrow> (finite union_of P) (\<Union> \<U>)
[PROOF STEP]
using finite_union_of_idempot [of P]
[PROOF STATE]
proof (prove)
using this:
finite union_of finite union_of P = finite union_of P

goal (1 subgoal):
 1. \<lbrakk>finite \<U>; \<And>S. S \<in> \<U> \<Longrightarrow> (finite union_of P) S\<rbrakk> \<Longrightarrow> (finite union_of P) (\<Union> \<U>)
[PROOF STEP]
by (metis mem_Collect_eq subsetI union_of_def)


[STATEMENT]
lemma rank_eq_suc_to_nat_greatest:
assumes A_not_0: "A \<noteq> 0"
shows "rank A = to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have rref: "reduced_row_echelon_form_upt_k (Gauss_Jordan A) (ncols (Gauss_Jordan A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_row_echelon_form_upt_k (Gauss_Jordan A) (ncols (Gauss_Jordan A))
[PROOF STEP]
using rref_Gauss_Jordan
[PROOF STATE]
proof (prove)
using this:
reduced_row_echelon_form (Gauss_Jordan ?A)

goal (1 subgoal):
 1. reduced_row_echelon_form_upt_k (Gauss_Jordan A) (ncols (Gauss_Jordan A))
[PROOF STEP]
unfolding reduced_row_echelon_form_def
[PROOF STATE]
proof (prove)
using this:
reduced_row_echelon_form_upt_k (Gauss_Jordan ?A) (ncols (Gauss_Jordan ?A))

goal (1 subgoal):
 1. reduced_row_echelon_form_upt_k (Gauss_Jordan A) (ncols (Gauss_Jordan A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
reduced_row_echelon_form_upt_k (Gauss_Jordan A) (ncols (Gauss_Jordan A))

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have not_all_zero: "\<not> (\<forall>a. is_zero_row_upt_k a (ncols (Gauss_Jordan A)) (Gauss_Jordan A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (\<forall>a. is_zero_row_upt_k a (ncols (Gauss_Jordan A)) (Gauss_Jordan A))
[PROOF STEP]
unfolding is_zero_row_def[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (\<forall>a. is_zero_row a (Gauss_Jordan A))
[PROOF STEP]
using Gauss_Jordan_not_0[OF A_not_0]
[PROOF STATE]
proof (prove)
using this:
Gauss_Jordan A \<noteq> 0

goal (1 subgoal):
 1. \<not> (\<forall>a. is_zero_row a (Gauss_Jordan A))
[PROOF STEP]
unfolding is_zero_row_def'
[PROOF STATE]
proof (prove)
using this:
Gauss_Jordan A \<noteq> 0

goal (1 subgoal):
 1. \<not> (\<forall>a j. Gauss_Jordan A $ a $ j = (0::'a))
[PROOF STEP]
by (metis vec_eq_iff zero_index)
[PROOF STATE]
proof (state)
this:
\<not> (\<forall>a. is_zero_row_upt_k a (ncols (Gauss_Jordan A)) (Gauss_Jordan A))

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have "rank A = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
unfolding rank_Gauss_Jordan[of A]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank (Gauss_Jordan A) = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
unfolding rref_rank[OF rref_Gauss_Jordan]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0} = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
rank A = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rank A = card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have "... = card {i. i\<le>(GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0} = card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
proof (rule bij_betw_same_card[symmetric, of "\<lambda>i. row i (Gauss_Jordan A)"], unfold bij_betw_def, rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on (\<lambda>i. row i (Gauss_Jordan A)) {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
 2. (\<lambda>i. row i (Gauss_Jordan A)) ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
show "inj_on (\<lambda>i. row i (Gauss_Jordan A)) {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>i. row i (Gauss_Jordan A)) {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
proof (unfold inj_on_def, auto, rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); y \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); row x (Gauss_Jordan A) = row y (Gauss_Jordan A); x \<noteq> y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); y \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); row x (Gauss_Jordan A) = row y (Gauss_Jordan A); x \<noteq> y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume x: "x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))" and y: "y \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))"
         and xy_eq_row: "row x (Gauss_Jordan A) = row y (Gauss_Jordan A)" and x_not_y: "x \<noteq> y"
[PROOF STATE]
proof (state)
this:
x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
y \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
row x (Gauss_Jordan A) = row y (Gauss_Jordan A)
x \<noteq> y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); y \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)); row x (Gauss_Jordan A) = row y (Gauss_Jordan A); x \<noteq> y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof (cases "x<y")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < y \<Longrightarrow> False
 2. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x < y

goal (2 subgoals):
 1. x < y \<Longrightarrow> False
 2. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
have "(LEAST n. (Gauss_Jordan A) $ x $ n \<noteq> 0) < (LEAST n. (Gauss_Jordan A) $ y $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a))
[PROOF STEP]
proof (rule rref_condition3_equiv[OF rref_Gauss_Jordan True])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<not> is_zero_row x (Gauss_Jordan A)
 2. \<not> is_zero_row y (Gauss_Jordan A)
[PROOF STEP]
show "\<not> is_zero_row x (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row x (Gauss_Jordan A)
[PROOF STEP]
by (unfold is_zero_row_def,
                    rule greatest_ge_nonzero_row'[OF rref x[unfolded is_zero_row_def] not_all_zero])
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row x (Gauss_Jordan A)

goal (1 subgoal):
 1. \<not> is_zero_row y (Gauss_Jordan A)
[PROOF STEP]
show "\<not> is_zero_row y (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row y (Gauss_Jordan A)
[PROOF STEP]
by (unfold is_zero_row_def, rule greatest_ge_nonzero_row'[OF rref y[unfolded is_zero_row_def] not_all_zero])
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row y (Gauss_Jordan A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a))

goal (2 subgoals):
 1. x < y \<Longrightarrow> False
 2. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. False
[PROOF STEP]
by (metis less_irrefl row_def vec_nth_inverse xy_eq_row)
[PROOF STATE]
proof (state)
this:
False

goal (1 subgoal):
 1. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x < y

goal (1 subgoal):
 1. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
hence x_ge_y: "x>y"
[PROOF STATE]
proof (prove)
using this:
\<not> x < y

goal (1 subgoal):
 1. y < x
[PROOF STEP]
using x_not_y
[PROOF STATE]
proof (prove)
using this:
\<not> x < y
x \<noteq> y

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

goal (1 subgoal):
 1. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
have "(LEAST n. (Gauss_Jordan A) $ y $ n \<noteq> 0) < (LEAST n. (Gauss_Jordan A) $ x $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a))
[PROOF STEP]
proof (rule rref_condition3_equiv[OF rref_Gauss_Jordan x_ge_y])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<not> is_zero_row y (Gauss_Jordan A)
 2. \<not> is_zero_row x (Gauss_Jordan A)
[PROOF STEP]
show "\<not> is_zero_row x (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row x (Gauss_Jordan A)
[PROOF STEP]
by (unfold is_zero_row_def, rule greatest_ge_nonzero_row'[OF rref x[unfolded is_zero_row_def] not_all_zero])
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row x (Gauss_Jordan A)

goal (1 subgoal):
 1. \<not> is_zero_row y (Gauss_Jordan A)
[PROOF STEP]
show "\<not> is_zero_row y (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row y (Gauss_Jordan A)
[PROOF STEP]
by (unfold is_zero_row_def, rule greatest_ge_nonzero_row'[OF rref y[unfolded is_zero_row_def] not_all_zero])
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row y (Gauss_Jordan A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. \<not> x < y \<Longrightarrow> False
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(LEAST n. Gauss_Jordan A $ y $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan A $ x $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. False
[PROOF STEP]
by (metis less_irrefl row_def vec_nth_inverse xy_eq_row)
[PROOF STATE]
proof (state)
this:
False

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>i. row i (Gauss_Jordan A)) {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. (\<lambda>i. row i (Gauss_Jordan A)) ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
show "(\<lambda>i. row i (Gauss_Jordan A)) ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>i. row i (Gauss_Jordan A)) ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}
[PROOF STEP]
proof (unfold image_def, auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa. xa \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0
 2. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
fix xa
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa. xa \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0
 2. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
assume  xa: "xa \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))"
[PROOF STATE]
proof (state)
this:
xa \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (2 subgoals):
 1. \<And>xa. xa \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0
 2. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
show "\<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0
[PROOF STEP]
proof (rule exI[of _ xa], simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. row xa (Gauss_Jordan A) \<noteq> 0
[PROOF STEP]
have "\<not> is_zero_row xa (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_zero_row xa (Gauss_Jordan A)
[PROOF STEP]
by (unfold is_zero_row_def, rule greatest_ge_nonzero_row'[OF rref xa[unfolded is_zero_row_def] not_all_zero])
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row xa (Gauss_Jordan A)

goal (1 subgoal):
 1. row xa (Gauss_Jordan A) \<noteq> 0
[PROOF STEP]
thus "row xa (Gauss_Jordan A) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row xa (Gauss_Jordan A)

goal (1 subgoal):
 1. row xa (Gauss_Jordan A) \<noteq> 0
[PROOF STEP]
unfolding row_def is_zero_row_def'
[PROOF STATE]
proof (prove)
using this:
\<not> (\<forall>j. Gauss_Jordan A $ xa $ j = (0::'a))

goal (1 subgoal):
 1. vec_lambda (($) (Gauss_Jordan A $ xa)) \<noteq> 0
[PROOF STEP]
by (metis vec_nth_inverse zero_index)
[PROOF STATE]
proof (state)
this:
row xa (Gauss_Jordan A) \<noteq> 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>i. row xa (Gauss_Jordan A) = row i (Gauss_Jordan A) \<and> row i (Gauss_Jordan A) \<noteq> 0

goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
assume  "row i (Gauss_Jordan A) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
row i (Gauss_Jordan A) \<noteq> 0

goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
hence "\<not> is_zero_row i (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
using this:
row i (Gauss_Jordan A) \<noteq> 0

goal (1 subgoal):
 1. \<not> is_zero_row i (Gauss_Jordan A)
[PROOF STEP]
unfolding row_def is_zero_row_def'
[PROOF STATE]
proof (prove)
using this:
vec_lambda (($) (Gauss_Jordan A $ i)) \<noteq> 0

goal (1 subgoal):
 1. \<not> (\<forall>j. Gauss_Jordan A $ i $ j = (0::'a))
[PROOF STEP]
by (metis vec_eq_iff vec_nth_inverse zero_index)
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row i (Gauss_Jordan A)

goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
hence "i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))"
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i (Gauss_Jordan A)

goal (1 subgoal):
 1. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
[PROOF STEP]
using Greatest_ge
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i (Gauss_Jordan A)
?P ?k \<Longrightarrow> ?k \<le> (GREATEST x. ?P x)

goal (1 subgoal):
 1. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. \<And>i. row i (Gauss_Jordan A) \<noteq> 0 \<Longrightarrow> \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
thus "\<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)"
[PROOF STATE]
proof (prove)
using this:
i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. \<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>x\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). row i (Gauss_Jordan A) = row x (Gauss_Jordan A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>i. row i (Gauss_Jordan A)) ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0} = card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {row i (Gauss_Jordan A) |i. row i (Gauss_Jordan A) \<noteq> 0} = card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have "... = card {i. i \<le> to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = card {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
proof (rule bij_betw_same_card[of "\<lambda>i. to_nat i"], unfold bij_betw_def, rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on mod_type_class.to_nat {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
 2. mod_type_class.to_nat ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
show "inj_on to_nat {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on mod_type_class.to_nat {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
using bij_to_nat
[PROOF STATE]
proof (prove)
using this:
bij_betw mod_type_class.to_nat UNIV {0..<CARD(?'a)}

goal (1 subgoal):
 1. inj_on mod_type_class.to_nat {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
by (metis bij_betw_imp_inj_on subset_inj_on top_greatest)
[PROOF STATE]
proof (state)
this:
inj_on mod_type_class.to_nat {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. mod_type_class.to_nat ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
show "to_nat ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {i. i \<le> to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}
[PROOF STEP]
proof (unfold image_def, auto simp add: to_nat_mono')
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
assume x: "x \<le> to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))"
[PROOF STATE]
proof (state)
this:
x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
hence "from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))"
[PROOF STATE]
proof (prove)
using this:
x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
[PROOF STEP]
by (metis (full_types) leD not_le_imp_less to_nat_le)
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))

goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
have "x < CARD('c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < CARD('c)
[PROOF STEP]
using x bij_to_nat[where ?'a='b]
[PROOF STATE]
proof (prove)
using this:
x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
bij_betw mod_type_class.to_nat UNIV {0..<CARD('b)}

goal (1 subgoal):
 1. x < CARD('c)
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
inj mod_type_class.to_nat \<and> range mod_type_class.to_nat = {0..<CARD('b)}

goal (1 subgoal):
 1. x < CARD('c)
[PROOF STEP]
by (metis less_le_trans not_le to_nat_less_card)
[PROOF STATE]
proof (state)
this:
x < CARD('c)

goal (1 subgoal):
 1. \<And>x. x \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) \<Longrightarrow> \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
x < CARD('c)
[PROOF STEP]
show "\<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = to_nat xa"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
x < CARD('c)

goal (1 subgoal):
 1. \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
using to_nat_from_nat_id
[PROOF STATE]
proof (prove)
using this:
mod_type_class.from_nat x \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))
x < CARD('c)
?x < CARD(?'a) \<Longrightarrow> mod_type_class.to_nat (mod_type_class.from_nat ?x) = ?x

goal (1 subgoal):
 1. \<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>xa\<le>GREATEST a. \<not> is_zero_row a (Gauss_Jordan A). x = mod_type_class.to_nat xa

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat ` {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = card {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {i. i \<le> (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = card {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))}

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
have "... = to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
unfolding card_Collect_le_nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))) = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {i. i \<le> mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A))} = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1

goal (1 subgoal):
 1. rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
rank A = mod_type_class.to_nat (GREATEST a. \<not> is_zero_row a (Gauss_Jordan A)) + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem r_phi:
  assumes "i = encode f" and "recfn 1 f"
  shows "eval r_phi [i, x] = eval f [x]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval r_phi [i, x] = eval f [x]
[PROOF STEP]
unfolding r_phi_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval (r_universal 1) [i, x] = eval f [x]
[PROOF STEP]
using r_universal assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>recfn ?n ?f; length ?xs = ?n\<rbrakk> \<Longrightarrow> eval (r_universal ?n) (encode ?f # ?xs) = eval ?f ?xs
i = encode f
recfn 1 f

goal (1 subgoal):
 1. eval (r_universal 1) [i, x] = eval f [x]
[PROOF STEP]
by force