[STATEMENT]
lemma Uswap_apply[simp]: \<open>Uswap *\<^sub>V s \<otimes>\<^sub>s t = t \<otimes>\<^sub>s s\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Uswap *\<^sub>V s \<otimes>\<^sub>s t = t \<otimes>\<^sub>s s
[PROOF STEP]
apply (rule clinear_equal_ket[where f=\<open>\<lambda>s. Uswap *\<^sub>V s \<otimes>\<^sub>s t\<close>, THEN fun_cong])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. clinear (\<lambda>s. Uswap *\<^sub>V s \<otimes>\<^sub>s t)
 2. clinear ((\<otimes>\<^sub>s) t)
 3. \<And>i. Uswap *\<^sub>V ket i \<otimes>\<^sub>s t = t \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (simp add: cblinfun.add_right clinearI tensor_ell2_add1 tensor_ell2_scaleC1)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. clinear ((\<otimes>\<^sub>s) t)
 2. \<And>i. Uswap *\<^sub>V ket i \<otimes>\<^sub>s t = t \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (simp add: clinear_tensor_ell21)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. Uswap *\<^sub>V ket i \<otimes>\<^sub>s t = t \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (rule clinear_equal_ket[where f=\<open>\<lambda>t. Uswap *\<^sub>V _ \<otimes>\<^sub>s t\<close>, THEN fun_cong])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>i. clinear (\<lambda>t. Uswap *\<^sub>V ket i \<otimes>\<^sub>s t)
 2. \<And>i. clinear (\<lambda>a. a \<otimes>\<^sub>s ket i)
 3. \<And>i ia. Uswap *\<^sub>V ket i \<otimes>\<^sub>s ket ia = ket ia \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (simp add: cblinfun.add_right clinearI tensor_ell2_add2 tensor_ell2_scaleC2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i. clinear (\<lambda>a. a \<otimes>\<^sub>s ket i)
 2. \<And>i ia. Uswap *\<^sub>V ket i \<otimes>\<^sub>s ket ia = ket ia \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (simp add: clinear_tensor_ell22)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i ia. Uswap *\<^sub>V ket i \<otimes>\<^sub>s ket ia = ket ia \<otimes>\<^sub>s ket i
[PROOF STEP]
apply (rule basis_enum_eq_vec_of_basis_enumI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i ia. vec_of_basis_enum (Uswap *\<^sub>V ket i \<otimes>\<^sub>s ket ia) = vec_of_basis_enum (ket ia \<otimes>\<^sub>s ket i)
[PROOF STEP]
apply (simp add: mat_of_cblinfun_cblinfun_apply vec_of_basis_enum_ket)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i ia. matrix_Uswap *\<^sub>v unit_vec 4 (enum_idx (i, ia)) = unit_vec 4 (enum_idx (ia, i))
[PROOF STEP]
by (case_tac i; case_tac ia; hypsubst_thin; normalization)


[STATEMENT]
lemma dim_image_invertible_mat:
  fixes P::"'a::{field}^'m^'m"
  assumes inv_P: "invertible P"
  and sub_W: "vec.subspace W"
  shows "vec.dim ((\<lambda>x. P *v x)` W) = vec.dim W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
obtain B where B_in_W: "B\<subseteq>W" and ind_B: "vec.independent B"
    and W_in_span_B: "W \<subseteq> vec.span B" and card_B_eq_dim_W: "card B = vec.dim W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. \<lbrakk>B \<subseteq> W; vec.independent B; W \<subseteq> vec.span B; card B = vec.dim W\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using vec.basis_exists
[PROOF STATE]
proof (prove)
using this:
(\<And>B. \<lbrakk>B \<subseteq> ?V; vec.independent B; ?V \<subseteq> vec.span B; card B = vec.dim ?V\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>B. \<lbrakk>B \<subseteq> W; vec.independent B; W \<subseteq> vec.span B; card B = vec.dim W\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
B \<subseteq> W
vec.independent B
W \<subseteq> vec.span B
card B = vec.dim W

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
define L where "L = (\<lambda>x. P *v x)"
[PROOF STATE]
proof (state)
this:
L = (*v) P

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
define C where "C = L`B"
[PROOF STATE]
proof (state)
this:
C = L ` B

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have finite_B: "finite B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite B
[PROOF STEP]
using vec.indep_card_eq_dim_span[OF ind_B]
[PROOF STATE]
proof (prove)
using this:
finite B \<and> card B = vec.dim (vec.span B)

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

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
interpret L: Vector_Spaces.linear "(*s)" "(*s)" L
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear (*s) (*s) L
[PROOF STEP]
using matrix_vector_mul_linear_gen
[PROOF STATE]
proof (prove)
using this:
linear (*s) (*s) ((*v) ?A)

goal (1 subgoal):
 1. linear (*s) (*s) L
[PROOF STEP]
unfolding L_def
[PROOF STATE]
proof (prove)
using this:
linear (*s) (*s) ((*v) ?A)

goal (1 subgoal):
 1. linear (*s) (*s) ((*v) P)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have finite_C: "finite C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite C
[PROOF STEP]
using vec.indep_card_eq_dim_span[OF ind_B]
[PROOF STATE]
proof (prove)
using this:
finite B \<and> card B = vec.dim (vec.span B)

goal (1 subgoal):
 1. finite C
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
using this:
finite B \<and> card B = vec.dim (vec.span B)

goal (1 subgoal):
 1. finite (L ` B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite C

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have inv_TP: "invertible_lf ((*s)) ((*s)) (\<lambda>x. P *v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible_lf (*s) (*s) ((*v) P)
[PROOF STEP]
using invertible_matrix_imp_invertible_lf[OF inv_P]
[PROOF STATE]
proof (prove)
using this:
invertible_lf (*s) (*s) ((*v) P)

goal (1 subgoal):
 1. invertible_lf (*s) (*s) ((*v) P)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
invertible_lf (*s) (*s) ((*v) P)

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have inj_on_LW: "inj_on L W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on L W
[PROOF STEP]
using invertible_imp_bijective[OF inv_TP]
[PROOF STATE]
proof (prove)
using this:
bij ((*v) P)

goal (1 subgoal):
 1. inj_on L W
[PROOF STEP]
unfolding bij_def L_def
[PROOF STATE]
proof (prove)
using this:
inj ((*v) P) \<and> surj ((*v) P)

goal (1 subgoal):
 1. inj_on ((*v) P) W
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. P *v x = P *v y \<longrightarrow> x = y) \<and> surj ((*v) P)

goal (1 subgoal):
 1. \<forall>x\<in>W. \<forall>y\<in>W. P *v x = P *v y \<longrightarrow> x = y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
inj_on L W

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
hence inj_on_LB: "inj_on L B"
[PROOF STATE]
proof (prove)
using this:
inj_on L W

goal (1 subgoal):
 1. inj_on L B
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>W. \<forall>y\<in>W. L x = L y \<longrightarrow> x = y

goal (1 subgoal):
 1. \<forall>x\<in>B. \<forall>y\<in>B. L x = L y \<longrightarrow> x = y
[PROOF STEP]
using B_in_W
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>W. \<forall>y\<in>W. L x = L y \<longrightarrow> x = y
B \<subseteq> W

goal (1 subgoal):
 1. \<forall>x\<in>B. \<forall>y\<in>B. L x = L y \<longrightarrow> x = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on L B

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have ind_D: "vec.independent C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.independent C
[PROOF STEP]
proof (rule vec.independent_if_scalars_zero[OF finite_C])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
fix f x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
assume sum: "(\<Sum>x\<in>C. f x *s x) = 0" and x: "x \<in> C"
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>C. f x *s x) = 0
x \<in> C

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
obtain y where Ly_eq_x: "L y = x" and y: "y \<in> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>y. \<lbrakk>L y = x; y \<in> B\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
x \<in> C

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>L y = x; y \<in> B\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding C_def L_def
[PROOF STATE]
proof (prove)
using this:
x \<in> (*v) P ` B

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>P *v y = x; y \<in> B\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
L y = x
y \<in> B

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
have "(\<Sum>x\<in>C. f x *s x) = sum ((\<lambda>x. f x *s x) \<circ> L) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>C. f x *s x) = sum ((\<lambda>x. f x *s x) \<circ> L) B
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>L ` B. f x *s x) = sum ((\<lambda>x. f x *s x) \<circ> L) B
[PROOF STEP]
by (rule sum.reindex[OF inj_on_LB])
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>C. f x *s x) = sum ((\<lambda>x. f x *s x) \<circ> L) B

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>C. f x *s x) = sum ((\<lambda>x. f x *s x) \<circ> L) B

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
have "... = sum (\<lambda>x. f (L x) *s L x) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((\<lambda>x. f x *s x) \<circ> L) B = (\<Sum>x\<in>B. f (L x) *s L x)
[PROOF STEP]
unfolding o_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>B. f (L x) *s L x) = (\<Sum>x\<in>B. f (L x) *s L x)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
sum ((\<lambda>x. f x *s x) \<circ> L) B = (\<Sum>x\<in>B. f (L x) *s L x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((\<lambda>x. f x *s x) \<circ> L) B = (\<Sum>x\<in>B. f (L x) *s L x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
have "... =  sum (\<lambda>x. ((f \<circ> L) x) *s L x) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>B. f (L x) *s L x) = (\<Sum>x\<in>B. (f \<circ> L) x *s L x)
[PROOF STEP]
using o_def
[PROOF STATE]
proof (prove)
using this:
?f \<circ> ?g = (\<lambda>x. ?f (?g x))

goal (1 subgoal):
 1. (\<Sum>x\<in>B. f (L x) *s L x) = (\<Sum>x\<in>B. (f \<circ> L) x *s L x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. f (L x) *s L x) = (\<Sum>x\<in>B. (f \<circ> L) x *s L x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. f (L x) *s L x) = (\<Sum>x\<in>B. (f \<circ> L) x *s L x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
have "... = L (sum (\<lambda>x. ((f \<circ> L) x) *s x) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s L x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)
[PROOF STEP]
by (simp add: L.sum L.scale)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. (f \<circ> L) x *s L x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)
[PROOF STEP]
have rw: " (\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)

goal (1 subgoal):
 1. (\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
have "(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W
[PROOF STEP]
by (rule vec.subspace_sum[OF sub_W])
        (simp add: B_in_W rev_subsetD sub_W vec.subspace_scale)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
hence "(\<Sum>x\<in>B. (f \<circ> L) x *s x)=0"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W

goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
[PROOF STEP]
using sum rw
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W
(\<Sum>x\<in>C. f x *s x) = 0
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)

goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
[PROOF STEP]
using vec.linear_inj_on_iff_eq_0[OF L.linear_axioms sub_W]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W
(\<Sum>x\<in>C. f x *s x) = 0
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)
inj_on L W = (\<forall>x\<in>W. L x = 0 \<longrightarrow> x = 0)

goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
[PROOF STEP]
using inj_on_LW
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) \<in> W
(\<Sum>x\<in>C. f x *s x) = 0
(\<Sum>x\<in>C. f x *s x) = L (\<Sum>x\<in>B. (f \<circ> L) x *s x)
inj_on L W = (\<forall>x\<in>W. L x = 0 \<longrightarrow> x = 0)
inj_on L W

goal (1 subgoal):
 1. (\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
[PROOF STEP]
by (auto simp: L_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
hence "(f \<circ> L) y = 0"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0

goal (1 subgoal):
 1. (f \<circ> L) y = (0::'a)
[PROOF STEP]
using vec.scalars_zero_if_independent[OF finite_B ind_B, of "(f \<circ> L)"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0 \<Longrightarrow> \<forall>x\<in>B. (f \<circ> L) x = (0::'a)

goal (1 subgoal):
 1. (f \<circ> L) y = (0::'a)
[PROOF STEP]
using y
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0
(\<Sum>x\<in>B. (f \<circ> L) x *s x) = 0 \<Longrightarrow> \<forall>x\<in>B. (f \<circ> L) x = (0::'a)
y \<in> B

goal (1 subgoal):
 1. (f \<circ> L) y = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(f \<circ> L) y = (0::'a)

goal (1 subgoal):
 1. \<And>f x. \<lbrakk>(\<Sum>x\<in>C. f x *s x) = 0; x \<in> C\<rbrakk> \<Longrightarrow> f x = (0::'a)
[PROOF STEP]
thus "f x = 0"
[PROOF STATE]
proof (prove)
using this:
(f \<circ> L) y = (0::'a)

goal (1 subgoal):
 1. f x = (0::'a)
[PROOF STEP]
unfolding o_def Ly_eq_x
[PROOF STATE]
proof (prove)
using this:
f x = (0::'a)

goal (1 subgoal):
 1. f x = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
f x = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
vec.independent C

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have "L` W \<subseteq> vec.span C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L ` W \<subseteq> vec.span C
[PROOF STEP]
proof (unfold vec.span_finite[OF finite_C], clarify)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xa. xa \<in> W \<Longrightarrow> L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)
[PROOF STEP]
fix xa
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xa. xa \<in> W \<Longrightarrow> L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)
[PROOF STEP]
assume xa_in_W: "xa \<in> W"
[PROOF STATE]
proof (state)
this:
xa \<in> W

goal (1 subgoal):
 1. \<And>x xa. xa \<in> W \<Longrightarrow> L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)
[PROOF STEP]
obtain g where sum_g: "sum (\<lambda>x. g x *s x) B = xa"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. (\<Sum>x\<in>B. g x *s x) = xa \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using vec.span_finite[OF finite_B] W_in_span_B xa_in_W
[PROOF STATE]
proof (prove)
using this:
vec.span B = range (\<lambda>u. \<Sum>v\<in>B. u v *s v)
W \<subseteq> vec.span B
xa \<in> W

goal (1 subgoal):
 1. (\<And>g. (\<Sum>x\<in>B. g x *s x) = xa \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. g x *s x) = xa

goal (1 subgoal):
 1. \<And>x xa. xa \<in> W \<Longrightarrow> L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)
[PROOF STEP]
show "L xa \<in> range (\<lambda>u. (\<Sum>v\<in>C. u v *s v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)
[PROOF STEP]
proof (rule image_eqI[where x="\<lambda>x. g (THE y. y \<in> B \<and> x=L y)"])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
have "L xa = L (sum (\<lambda>x. g x *s x) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L xa = L (\<Sum>x\<in>B. g x *s x)
[PROOF STEP]
using sum_g
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>B. g x *s x) = xa

goal (1 subgoal):
 1. L xa = L (\<Sum>x\<in>B. g x *s x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
L xa = L (\<Sum>x\<in>B. g x *s x)

goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
L xa = L (\<Sum>x\<in>B. g x *s x)

goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
have "... = sum (\<lambda>x. g x *s L x) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L (\<Sum>x\<in>B. g x *s x) = (\<Sum>x\<in>B. g x *s L x)
[PROOF STEP]
by (simp add: L.sum L.scale)
[PROOF STATE]
proof (state)
this:
L (\<Sum>x\<in>B. g x *s x) = (\<Sum>x\<in>B. g x *s L x)

goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
L (\<Sum>x\<in>B. g x *s x) = (\<Sum>x\<in>B. g x *s L x)

goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
have "... = sum (\<lambda>x. g (THE y. y \<in> B \<and> x=L y) *s x) (L`B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>B. g x *s L x) = (\<Sum>x\<in>L ` B. g (THE y. y \<in> B \<and> x = L y) *s x)
[PROOF STEP]
proof (unfold sum.reindex[OF inj_on_LB], unfold o_def, rule sum.cong)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. B = B
 2. \<And>x. x \<in> B \<Longrightarrow> g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. B = B
 2. \<And>x. x \<in> B \<Longrightarrow> g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
assume x_in_B: "x\<in>B"
[PROOF STATE]
proof (state)
this:
x \<in> B

goal (2 subgoals):
 1. B = B
 2. \<And>x. x \<in> B \<Longrightarrow> g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
have x_eq_the:"x = (THE y. y \<in> B \<and> L x = L y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = (THE y. y \<in> B \<and> L x = L y)
[PROOF STEP]
proof (rule the_equality[symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x \<in> B \<and> L x = L x
 2. \<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x
[PROOF STEP]
show "x \<in> B \<and> L x = L x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> B \<and> L x = L x
[PROOF STEP]
using x_in_B
[PROOF STATE]
proof (prove)
using this:
x \<in> B

goal (1 subgoal):
 1. x \<in> B \<and> L x = L x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> B \<and> L x = L x

goal (1 subgoal):
 1. \<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x
[PROOF STEP]
show "\<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x
[PROOF STEP]
using inj_on_LB x_in_B
[PROOF STATE]
proof (prove)
using this:
inj_on L B
x \<in> B

goal (1 subgoal):
 1. \<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>B. \<forall>y\<in>B. L x = L y \<longrightarrow> x = y
x \<in> B

goal (1 subgoal):
 1. \<And>y. y \<in> B \<and> L x = L y \<Longrightarrow> y = x
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
?y \<in> B \<and> L x = L ?y \<Longrightarrow> ?y = x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x = (THE y. y \<in> B \<and> L x = L y)

goal (2 subgoals):
 1. B = B
 2. \<And>x. x \<in> B \<Longrightarrow> g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
show "g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
using x_eq_the
[PROOF STATE]
proof (prove)
using this:
x = (THE y. y \<in> B \<and> L x = L y)

goal (1 subgoal):
 1. g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
g x *s L x = g (THE y. y \<in> B \<and> L x = L y) *s L x

goal (1 subgoal):
 1. B = B
[PROOF STEP]
qed rule
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>B. g x *s L x) = (\<Sum>x\<in>L ` B. g (THE y. y \<in> B \<and> x = L y) *s x)

goal (2 subgoals):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
 2. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
L xa = (\<Sum>x\<in>L ` B. g (THE y. y \<in> B \<and> x = L y) *s x)
[PROOF STEP]
show "L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)"
[PROOF STATE]
proof (prove)
using this:
L xa = (\<Sum>x\<in>L ` B. g (THE y. y \<in> B \<and> x = L y) *s x)

goal (1 subgoal):
 1. L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
using this:
L xa = (\<Sum>x\<in>L ` B. g (THE y. y \<in> B \<and> x = L y) *s x)

goal (1 subgoal):
 1. L xa = (\<Sum>v\<in>L ` B. g (THE y. y \<in> B \<and> v = L y) *s v)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
L xa = (\<Sum>v\<in>C. g (THE y. y \<in> B \<and> v = L y) *s v)

goal (1 subgoal):
 1. (\<lambda>x. g (THE y. y \<in> B \<and> x = L y)) \<in> UNIV
[PROOF STEP]
qed rule
[PROOF STATE]
proof (state)
this:
L xa \<in> range (\<lambda>u. \<Sum>v\<in>C. u v *s v)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
L ` W \<subseteq> vec.span C

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
have "card C = card B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card C = card B
[PROOF STEP]
using card_image[OF inj_on_LB]
[PROOF STATE]
proof (prove)
using this:
card (L ` B) = card B

goal (1 subgoal):
 1. card C = card B
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
using this:
card (L ` B) = card B

goal (1 subgoal):
 1. card (L ` B) = card B
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card C = card B

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card C = card B

goal (1 subgoal):
 1. vec.dim ((*v) P ` W) = vec.dim W
[PROOF STEP]
by (metis B_in_W C_def L.span_image W_in_span_B \<open>L \<equiv> (*v) P\<close> card_B_eq_dim_W ind_D sub_W
        vec.indep_card_eq_dim_span vec.span_subspace)
[PROOF STATE]
proof (state)
this:
vec.dim ((*v) P ` W) = vec.dim W

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal_row_of_unitary [simp]:
  fixes U::"complex mat"
  assumes "unitary U" and "dim_row U = n" and "i < n" and "j < n" and "i \<noteq> j"
  shows "\<langle>row U i|row U j\<rangle> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>row U i|row U j\<rangle> = 0
[PROOF STEP]
using assms orthogonal_col_of_unitary transpose_of_unitary_is_unitary col_transpose
[PROOF STATE]
proof (prove)
using this:
unitary U
dim_row U = n
i < n
j < n
i \<noteq> j
\<lbrakk>unitary ?U; dim_col ?U = ?n; ?i < ?n; ?j < ?n; ?i \<noteq> ?j\<rbrakk> \<Longrightarrow> \<langle>col ?U ?i|col ?U ?j\<rangle> = 0
unitary ?U \<Longrightarrow> unitary ?U\<^sup>t
?i < dim_row ?A \<Longrightarrow> col ?A\<^sup>t ?i = row ?A ?i

goal (1 subgoal):
 1. \<langle>row U i|row U j\<rangle> = 0
[PROOF STEP]
by (metis index_transpose_mat(3))


[STATEMENT]
theorem sturm_R:
  shows "card {x. poly p x=0} =  changes_R_smods p (pderiv p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card {x. poly p x = 0}) = changes_R_smods p (pderiv p)
[PROOF STEP]
using sturm_tarski_R[of _ 1,unfolded taq_def]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x | poly ?p x = 0. sign (poly 1 x)) = changes_R_smods ?p (pderiv ?p * 1)

goal (1 subgoal):
 1. int (card {x. poly p x = 0}) = changes_R_smods p (pderiv p)
[PROOF STEP]
by force


[STATEMENT]
lemma Cons_lenlex_iff:
  "((m # ms, n # ns) \<in> lenlex r) \<longleftrightarrow>
    length ms < length ns
  \<or> length ms = length ns \<and> (m,n) \<in> r
  \<or> (m = n \<and> (ms,ns) \<in> lenlex r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((m # ms, n # ns) \<in> lenlex r) = (length ms < length ns \<or> length ms = length ns \<and> (m, n) \<in> r \<or> m = n \<and> (ms, ns) \<in> lenlex r)
[PROOF STEP]
by (auto simp: lenlex_def)


[STATEMENT]
lemma abs_dist_diff_le: "\<bar>dist a b - dist b c\<bar> \<le> dist a c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>dist a b - dist b c\<bar> \<le> dist a c
[PROOF STEP]
using dist_triangle3[of b c a] dist_triangle2[of a b c]
[PROOF STATE]
proof (prove)
using this:
dist b c \<le> dist a b + dist a c
dist a b \<le> dist a c + dist b c

goal (1 subgoal):
 1. \<bar>dist a b - dist b c\<bar> \<le> dist a c
[PROOF STEP]
by simp


[STATEMENT]
lemma decompress_1:
  assumes "a\<in>{0,1}"
  shows "decompress 1 a = round(real_of_int q/2) * a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. decompress 1 a = round (real_of_int q / 2) * a
[PROOF STEP]
unfolding decompress_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int q * real_of_int a / real_of_int 2 ^ 1) = round (real_of_int q / 2) * a
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a \<in> {0, 1}

goal (1 subgoal):
 1. round (real_of_int q * real_of_int a / real_of_int 2 ^ 1) = round (real_of_int q / 2) * a
[PROOF STEP]
by auto


[STATEMENT]
lemma card_cartesian_prod_square: "finite X \<Longrightarrow> card (X \<times> X) = (card X)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite X \<Longrightarrow> card (X \<times> X) = (card X)\<^sup>2
[PROOF STEP]
using card_cartesian_product
[PROOF STATE]
proof (prove)
using this:
card (?A \<times> ?B) = card ?A * card ?B

goal (1 subgoal):
 1. finite X \<Longrightarrow> card (X \<times> X) = (card X)\<^sup>2
[PROOF STEP]
by (simp add: power2_eq_square)


[STATEMENT]
lemma relImage_proj:
  assumes "equiv A R"
  shows "relImage R (proj R) \<subseteq> Id_on (A//R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. relImage R (proj R) \<subseteq> Id_on (A // R)
[PROOF STEP]
unfolding relImage_def Id_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(proj R a1, proj R a2) |a1 a2. (a1, a2) \<in> R} \<subseteq> (\<Union>x\<in>A // R. {(x, x)})
[PROOF STEP]
using proj_iff[OF assms] equiv_class_eq_iff[OF assms]
[PROOF STATE]
proof (prove)
using this:
{?x, ?y} \<subseteq> A \<Longrightarrow> (proj R ?x = proj R ?y) = ((?x, ?y) \<in> R)
((?x, ?y) \<in> R) = (R `` {?x} = R `` {?y} \<and> ?x \<in> A \<and> ?y \<in> A)

goal (1 subgoal):
 1. {(proj R a1, proj R a2) |a1 a2. (a1, a2) \<in> R} \<subseteq> (\<Union>x\<in>A // R. {(x, x)})
[PROOF STEP]
by (auto simp: proj_preserves)


[STATEMENT]
lemma size_nat_multiset_eq:
  fixes N :: "nat multiset"
  assumes "number_partition n N"
  shows "size N = sum (count N) {..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
have "set_mset N \<subseteq> {..sum_mset N}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_mset N \<subseteq> {..\<Sum>\<^sub># N}
[PROOF STEP]
by (auto dest: multi_member_split)
[PROOF STATE]
proof (state)
this:
set_mset N \<subseteq> {..\<Sum>\<^sub># N}

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
have "size N = sum (count N) (set_mset N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size N = sum (count N) (set_mset N)
[PROOF STEP]
by (rule size_multiset_overloaded_eq)
[PROOF STATE]
proof (state)
this:
size N = sum (count N) (set_mset N)

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size N = sum (count N) (set_mset N)

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
have "\<dots> = sum (count N) {..sum_mset N}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (count N) (set_mset N) = sum (count N) {..\<Sum>\<^sub># N}
[PROOF STEP]
using \<open>set_mset N \<subseteq> {..sum_mset N}\<close>
[PROOF STATE]
proof (prove)
using this:
set_mset N \<subseteq> {..\<Sum>\<^sub># N}

goal (1 subgoal):
 1. sum (count N) (set_mset N) = sum (count N) {..\<Sum>\<^sub># N}
[PROOF STEP]
by (auto intro: sum.mono_neutral_cong_left count_inI)
[PROOF STATE]
proof (state)
this:
sum (count N) (set_mset N) = sum (count N) {..\<Sum>\<^sub># N}

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
size N = sum (count N) {..\<Sum>\<^sub># N}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
size N = sum (count N) {..\<Sum>\<^sub># N}

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
using \<open>number_partition n N\<close>
[PROOF STATE]
proof (prove)
using this:
size N = sum (count N) {..\<Sum>\<^sub># N}
number_partition n N

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
unfolding number_partition_def
[PROOF STATE]
proof (prove)
using this:
size N = sum (count N) {..\<Sum>\<^sub># N}
\<Sum>\<^sub># N = n \<and> 0 \<notin># N

goal (1 subgoal):
 1. size N = sum (count N) {..n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
size N = sum (count N) {..n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma smult_smult_assoc:
  "a \<cdot>\<^sub>v (b \<cdot>\<^sub>v v) = (a * b::'a::ring) \<cdot>\<^sub>v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<cdot>\<^sub>v (b \<cdot>\<^sub>v v) = a * b \<cdot>\<^sub>v v
[PROOF STEP]
apply (rule sym, rule eq_vecI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i. i < dim_vec (a \<cdot>\<^sub>v (b \<cdot>\<^sub>v v)) \<Longrightarrow> (a * b \<cdot>\<^sub>v v) $ i = (a \<cdot>\<^sub>v (b \<cdot>\<^sub>v v)) $ i
 2. dim_vec (a * b \<cdot>\<^sub>v v) = dim_vec (a \<cdot>\<^sub>v (b \<cdot>\<^sub>v v))
[PROOF STEP]
unfolding smult_vec_def plus_vec_def
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i. i < dim_vec (vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i)) \<Longrightarrow> vec (dim_vec v) (\<lambda>i. a * b * v $ i) $ i = vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i) $ i
 2. dim_vec (vec (dim_vec v) (\<lambda>i. a * b * v $ i)) = dim_vec (vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i))
[PROOF STEP]
using mult.assoc
[PROOF STATE]
proof (prove)
using this:
?a * ?b * ?c = ?a * (?b * ?c)

goal (2 subgoals):
 1. \<And>i. i < dim_vec (vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i)) \<Longrightarrow> vec (dim_vec v) (\<lambda>i. a * b * v $ i) $ i = vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i) $ i
 2. dim_vec (vec (dim_vec v) (\<lambda>i. a * b * v $ i)) = dim_vec (vec (dim_vec (vec (dim_vec v) (\<lambda>i. b * v $ i))) (\<lambda>i. a * vec (dim_vec v) (\<lambda>i. b * v $ i) $ i))
[PROOF STEP]
by auto


[STATEMENT]
lemma algebraic_int_plus [intro]:
  fixes x y :: "'a :: field_char_0"
  assumes "algebraic_int x" "algebraic_int y"
  shows   "algebraic_int (x + y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
from assms(1)
[PROOF STATE]
proof (chain)
picking this:
algebraic_int x
[PROOF STEP]
obtain p where p: "lead_coeff p = 1" "ipoly p x = 0"
[PROOF STATE]
proof (prove)
using this:
algebraic_int x

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>monic p; ipoly p x = (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: algebraic_int_altdef_ipoly)
[PROOF STATE]
proof (state)
this:
monic p
ipoly p x = (0::'a)

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
from assms(2)
[PROOF STATE]
proof (chain)
picking this:
algebraic_int y
[PROOF STEP]
obtain q where q: "lead_coeff q = 1" "ipoly q y = 0"
[PROOF STATE]
proof (prove)
using this:
algebraic_int y

goal (1 subgoal):
 1. (\<And>q. \<lbrakk>monic q; ipoly q y = (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: algebraic_int_altdef_ipoly)
[PROOF STATE]
proof (state)
this:
monic q
ipoly q y = (0::'a)

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
have deg_pos: "degree p > 0" "degree q > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < degree p &&& 0 < degree q
[PROOF STEP]
using p q
[PROOF STATE]
proof (prove)
using this:
monic p
ipoly p x = (0::'a)
monic q
ipoly q y = (0::'a)

goal (1 subgoal):
 1. 0 < degree p &&& 0 < degree q
[PROOF STEP]
by (auto intro!: Nat.gr0I elim!: degree_eq_zeroE)
[PROOF STATE]
proof (state)
this:
0 < degree p
0 < degree q

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
define r where "r = poly_add_sign (degree p) (degree q) * poly_add p q"
[PROOF STATE]
proof (state)
this:
r = poly_add_sign (degree p) (degree q) * poly_add p q

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
have "lead_coeff r = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic r
[PROOF STEP]
using p q deg_pos
[PROOF STATE]
proof (prove)
using this:
monic p
ipoly p x = (0::'a)
monic q
ipoly q y = (0::'a)
0 < degree p
0 < degree q

goal (1 subgoal):
 1. monic r
[PROOF STEP]
by (simp add: r_def lead_coeff_mult poly_add_sign_def sign_def lead_coeff_poly_add)
[PROOF STATE]
proof (state)
this:
monic r

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
monic r

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
have "ipoly r (x + y) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ipoly r (x + y) = (0::'a)
[PROOF STEP]
using p q
[PROOF STATE]
proof (prove)
using this:
monic p
ipoly p x = (0::'a)
monic q
ipoly q y = (0::'a)

goal (1 subgoal):
 1. ipoly r (x + y) = (0::'a)
[PROOF STEP]
by (simp add: ipoly_poly_add r_def of_int_poly_hom.hom_mult)
[PROOF STATE]
proof (state)
this:
ipoly r (x + y) = (0::'a)

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
monic r
ipoly r (x + y) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
monic r
ipoly r (x + y) = (0::'a)

goal (1 subgoal):
 1. algebraic_int (x + y)
[PROOF STEP]
by (auto simp: algebraic_int_altdef_ipoly)
[PROOF STATE]
proof (state)
this:
algebraic_int (x + y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mod_neq_imp_diff_mod_neq0:"
  \<lbrakk> (a::nat) mod m \<noteq> b mod m; a \<le> b \<rbrakk> \<Longrightarrow> 0 < (b - a) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a mod m \<noteq> b mod m; a \<le> b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply (case_tac "m = 0", simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a mod m \<noteq> b mod m; a \<le> b; m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply (drule le_imp_less_or_eq, erule disjE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>a mod m \<noteq> b mod m; m \<noteq> 0; a < b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
 2. \<lbrakk>a mod m \<noteq> b mod m; m \<noteq> 0; a = b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
prefer 2
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>a mod m \<noteq> b mod m; m \<noteq> 0; a = b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
 2. \<lbrakk>a mod m \<noteq> b mod m; m \<noteq> 0; a < b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a mod m \<noteq> b mod m; m \<noteq> 0; a < b\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply (drule neq_iff[THEN iffD1], erule disjE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m \<noteq> 0; a < b; a mod m < b mod m\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
 2. \<lbrakk>m \<noteq> 0; a < b; b mod m < a mod m\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply (simp add: mod_diff1_eq1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m \<noteq> 0; a < b; b mod m < a mod m\<rbrakk> \<Longrightarrow> 0 < (b - a) mod m
[PROOF STEP]
apply (simp add: mod_diff1_eq2[OF less_imp_le] trans_less_add1[OF mod_less_divisor])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma rel_list_all2_antisym:
  "\<lbrakk> (\<And>x y. \<lbrakk>(x,y) \<in> S; (y,x) \<in> T\<rbrakk> \<Longrightarrow> x = y);
     list_all2 (fun_of S) xs ys; list_all2 (fun_of T) ys xs \<rbrakk> \<Longrightarrow> xs = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x y. \<lbrakk>(x, y) \<in> S; (y, x) \<in> T\<rbrakk> \<Longrightarrow> x = y; list_all2 (fun_of S) xs ys; list_all2 (fun_of T) ys xs\<rbrakk> \<Longrightarrow> xs = ys
[PROOF STEP]
by (rule list_all2_antisym) auto


[STATEMENT]
lemma mono_on_subset: "\<lbrakk> mono_on f A ; B \<subseteq> A \<rbrakk> \<Longrightarrow> mono_on f B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>SetInterval2.mono_on f A; B \<subseteq> A\<rbrakk> \<Longrightarrow> SetInterval2.mono_on f B
[PROOF STEP]
unfolding mono_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>a\<in>A. \<forall>b\<in>A. a \<le> b \<longrightarrow> f a \<le> f b; B \<subseteq> A\<rbrakk> \<Longrightarrow> \<forall>a\<in>B. \<forall>b\<in>B. a \<le> b \<longrightarrow> f a \<le> f b
[PROOF STEP]
by blast


[STATEMENT]
lemma measure_spmf_scale_spmf: "measure_spmf (scale_spmf r p) = scale_measure (min (inverse (weight_spmf p)) r) (measure_spmf p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_spmf (scale_spmf r p) = scale_measure (ennreal (min (inverse (weight_spmf p)) r)) (measure_spmf p)
[PROOF STEP]
apply(rule measure_eqI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. sets (measure_spmf (scale_spmf r p)) = sets (scale_measure (ennreal (min (inverse (weight_spmf p)) r)) (measure_spmf p))
 2. \<And>A. A \<in> sets (measure_spmf (scale_spmf r p)) \<Longrightarrow> emeasure (measure_spmf (scale_spmf r p)) A = emeasure (scale_measure (ennreal (min (inverse (weight_spmf p)) r)) (measure_spmf p)) A
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A. A \<in> sets (measure_spmf (scale_spmf r p)) \<Longrightarrow> emeasure (measure_spmf (scale_spmf r p)) A = emeasure (scale_measure (ennreal (min (inverse (weight_spmf p)) r)) (measure_spmf p)) A
[PROOF STEP]
apply(simp add: nn_integral_spmf[symmetric] spmf_scale_spmf)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A. \<integral>\<^sup>+ x. ennreal (max 0 (min (inverse (weight_spmf p)) r) * spmf p x) \<partial>count_space A = ennreal (min (inverse (weight_spmf p)) r) * \<integral>\<^sup>+ x. ennreal (spmf p x) \<partial>count_space A
[PROOF STEP]
apply(subst nn_integral_cmult[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>A. (\<lambda>x. ennreal (spmf p x)) \<in> borel_measurable (count_space A)
 2. \<And>A. \<integral>\<^sup>+ x. ennreal (max 0 (min (inverse (weight_spmf p)) r) * spmf p x) \<partial>count_space A = \<integral>\<^sup>+ x. ennreal (min (inverse (weight_spmf p)) r) * ennreal (spmf p x) \<partial>count_space A
[PROOF STEP]
apply(auto simp add: max_def min_def ennreal_mult[symmetric] not_le ennreal_lt_0)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Euclid_GCD_time: "VARS a b t
 {0<A & 0<B & t=0}
 a := A; t := t+1; b := B; t := t+1;
 WHILE  a \<noteq> b
 INV {0<a & 0<b & gcd A B = gcd a b & a\<le>A & b\<le>B & t \<le> max A B - max a b + 2}
 DO IF a<b THEN b := b-a; t := t+1 ELSE a := a-b; t := t+1 FI OD
 {a = gcd A B & t \<le> max A B + 2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0 < A \<and> 0 < B \<and> t = 0}
a := A; t := t + 1; b := B; t := t + 1; WHILE a \<noteq> b INV {0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> a \<le> A \<and> b \<le> B \<and> t \<le> max A B - max a b + 2}  VAR {0}
DO IF a < b THEN b := b - a; t := t + 1  ELSE a := a - b; t := t + 1 FI OD
{a = Arith2.gcd A B \<and> t \<le> max A B + 2}
[PROOF STEP]
apply vcg
  \<comment> \<open>Now prove the verification conditions\<close>
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b t. 0 < A \<and> 0 < B \<and> t = 0 \<Longrightarrow> 0 < A \<and> 0 < B \<and> Arith2.gcd A B = Arith2.gcd A B \<and> A \<le> A \<and> B \<le> B \<and> t + 1 + 1 \<le> max A B - max A B + 2
 2. \<And>a b t. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> a \<le> A \<and> b \<le> B \<and> t \<le> max A B - max a b + 2) \<and> a \<noteq> b \<Longrightarrow> (a < b \<longrightarrow> 0 < a \<and> 0 < b - a \<and> Arith2.gcd A B = Arith2.gcd a (b - a) \<and> a \<le> A \<and> b - a \<le> B \<and> t + 1 \<le> max A B - max a (b - a) + 2) \<and> (\<not> a < b \<longrightarrow> 0 < a - b \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd (a - b) b \<and> a - b \<le> A \<and> b \<le> B \<and> t + 1 \<le> max A B - max (a - b) b + 2)
 3. \<And>a b t. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b \<and> a \<le> A \<and> b \<le> B \<and> t \<le> max A B - max a b + 2) \<and> \<not> a \<noteq> b \<Longrightarrow> a = Arith2.gcd A B \<and> t \<le> max A B + 2
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b t. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a b; a \<le> A; b \<le> B; t \<le> Suc (Suc (max A B - b)); a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd a (b - a)
 2. \<And>a b t. \<lbrakk>0 < b; Arith2.gcd A B = Arith2.gcd a b; a \<le> A; b \<le> B; t \<le> Suc (Suc (max A B - a)); a \<noteq> b; \<not> a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd (a - b) b
 3. \<And>a t. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a; a \<le> A; a \<le> B; t \<le> Suc (Suc (max A B - a))\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(simp add: gcd_diff_r less_imp_le)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a b t. \<lbrakk>0 < b; Arith2.gcd A B = Arith2.gcd a b; a \<le> A; b \<le> B; t \<le> Suc (Suc (max A B - a)); a \<noteq> b; \<not> a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd (a - b) b
 2. \<And>a t. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a; a \<le> A; a \<le> B; t \<le> Suc (Suc (max A B - a))\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(simp add: linorder_not_less gcd_diff_l)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a t. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a; a \<le> A; a \<le> B; t \<le> Suc (Suc (max A B - a))\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(erule gcd_nnn)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma strict_mono_sets_imp_disjoint:
  fixes A :: "'a::linorder set"
  assumes "strict_mono_sets A f"
  shows "pairwise (\<lambda>x y. disjnt (f x) (f y)) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pairwise (\<lambda>x y. disjnt (f x) (f y)) A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
strict_mono_sets A f

goal (1 subgoal):
 1. pairwise (\<lambda>x y. disjnt (f x) (f y)) A
[PROOF STEP]
unfolding strict_mono_sets_def pairwise_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>A. \<forall>y\<in>A. x < y \<longrightarrow> f x \<lless> f y

goal (1 subgoal):
 1. \<forall>x\<in>A. \<forall>y\<in>A. x \<noteq> y \<longrightarrow> disjnt (f x) (f y)
[PROOF STEP]
by (meson antisym_conv3 disjnt_sym less_sets_imp_disjnt)


[STATEMENT]
lemma matrix_left_invertible_injective:
  fixes A :: "'a::field^'n^'m"
  shows "(\<exists>B. B ** A = mat 1) \<longleftrightarrow> inj ((*v) A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>B. B ** A = mat (1::'a)) = inj ((*v) A)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>B. B ** A = mat (1::'a) \<Longrightarrow> inj ((*v) A)
 2. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
fix B
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>B. B ** A = mat (1::'a) \<Longrightarrow> inj ((*v) A)
 2. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
assume B: "B ** A = mat 1"
[PROOF STATE]
proof (state)
this:
B ** A = mat (1::'a)

goal (2 subgoals):
 1. \<And>B. B ** A = mat (1::'a) \<Longrightarrow> inj ((*v) A)
 2. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
show "inj ((*v) A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj ((*v) A)
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>UNIV. \<forall>y\<in>UNIV. A *v x = A *v y \<longrightarrow> x = y
[PROOF STEP]
by (metis B matrix_vector_mul_assoc matrix_vector_mul_lid)
[PROOF STATE]
proof (state)
this:
inj ((*v) A)

goal (1 subgoal):
 1. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
assume "inj ((*v) A)"
[PROOF STATE]
proof (state)
this:
inj ((*v) A)

goal (1 subgoal):
 1. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
from vec.linear_injective_left_inverse[OF matrix_vector_mul_linear_gen this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> g \<circ> (*v) A = id
[PROOF STEP]
obtain g where "Vector_Spaces.linear (*s) (*s) g" and g: "g \<circ> (*v) A = id"
[PROOF STATE]
proof (prove)
using this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> g \<circ> (*v) A = id

goal (1 subgoal):
 1. (\<And>g. \<lbrakk>Vector_Spaces.linear (*s) (*s) g; g \<circ> (*v) A = id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Vector_Spaces.linear (*s) (*s) g
g \<circ> (*v) A = id

goal (1 subgoal):
 1. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
have "matrix g ** A = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix g ** A = mat (1::'a)
[PROOF STEP]
by (metis matrix_vector_mul_linear_gen \<open>Vector_Spaces.linear (*s) (*s) g\<close> g matrix_compose_gen
        matrix_eq matrix_id_mat_1 matrix_vector_mul(1))
[PROOF STATE]
proof (state)
this:
matrix g ** A = mat (1::'a)

goal (1 subgoal):
 1. inj ((*v) A) \<Longrightarrow> \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
matrix g ** A = mat (1::'a)
[PROOF STEP]
show "\<exists>B. B ** A = mat 1"
[PROOF STATE]
proof (prove)
using this:
matrix g ** A = mat (1::'a)

goal (1 subgoal):
 1. \<exists>B. B ** A = mat (1::'a)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>B. B ** A = mat (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prodinf_divide: "convergent_prod f \<Longrightarrow> convergent_prod g \<Longrightarrow> prodinf f / prodinf g = (\<Prod>n. f n / g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>convergent_prod f; convergent_prod g\<rbrakk> \<Longrightarrow> prodinf f / prodinf g = (\<Prod>n. f n / g n)
[PROOF STEP]
by (intro has_prod_unique has_prod_divide convergent_prod_has_prod)


[STATEMENT]
lemma multiset_diff_union_assoc:
  fixes A B C D :: "'a multiset"
  shows "C \<subseteq># B \<Longrightarrow> A + B - C = A + (B - C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C \<subseteq># B \<Longrightarrow> A + B - C = A + (B - C)
[PROOF STEP]
by (fact subset_mset.diff_add_assoc)


[STATEMENT]
lemma summable_finite: "finite N \<Longrightarrow> (\<And>n. n \<notin> N \<Longrightarrow> f n = 0) \<Longrightarrow> summable f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite N; \<And>n. n \<notin> N \<Longrightarrow> f n = (0::'a)\<rbrakk> \<Longrightarrow> summable f
[PROOF STEP]
by (rule sums_summable) (rule sums_finite)


[STATEMENT]
lemma llist_all2_lnthD2:
  "\<lbrakk> llist_all2 P xs ys; enat n < llength ys \<rbrakk> \<Longrightarrow> P (lnth xs n) (lnth ys n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>llist_all2 P xs ys; enat n < llength ys\<rbrakk> \<Longrightarrow> P (lnth xs n) (lnth ys n)
[PROOF STEP]
by(fastforce simp add: llist_all2_conv_lzip lset_lzip)


[STATEMENT]
lemma distrib_subset1:
  "Rep_preal (w * (x + y)) \<subseteq> Rep_preal (w * x + w * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Rep_preal (w * (x + y)) \<subseteq> Rep_preal (w * x + w * y)
[PROOF STEP]
by (force simp: Bex_def mem_Rep_preal_add_iff mem_Rep_preal_mult_iff distrib_left)


[STATEMENT]
lemma frontier_outside_subset:
  fixes S :: "'a::real_normed_vector set"
  assumes "closed S"
  shows "frontier(outside S) \<subseteq> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frontier (outside S) \<subseteq> S
[PROOF STEP]
unfolding frontier_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure (outside S) - interior (outside S) \<subseteq> S
[PROOF STEP]
by (metis Diff_subset_conv assms closure_outside_subset interior_eq open_outside sup_aci(1))


[STATEMENT]
theorem ln_upper_11: "0<x \<Longrightarrow> ln(x) \<le> ln_upper_11 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> ln x \<le> ln_upper_11 x
[PROOF STEP]
by (metis le_less_linear less_eq_real_def ln_upper_11_neg ln_upper_11_pos)


[STATEMENT]
lemma negligible_imp_measure0: "negligible S \<Longrightarrow> measure lebesgue S = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negligible S \<Longrightarrow> Sigma_Algebra.measure lebesgue S = 0
[PROOF STEP]
by (simp add: measure_eq_0_null_sets negligible_iff_null_sets)


[STATEMENT]
lemma pderiv_power: "pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pderiv (p ^ n) = Polynomial.smult (of_nat n) (p ^ (n - 1)) * pderiv p
[PROOF STEP]
by (cases n) (simp_all add: pderiv_power_Suc del: power_Suc)


[STATEMENT]
lemma powr_mono_both:
  fixes x :: real
  assumes "0 \<le> a" "a \<le> b" "1 \<le> x" "x \<le> y"
    shows "x powr a \<le> y powr b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x powr a \<le> y powr b
[PROOF STEP]
by (meson assms order.trans powr_mono powr_mono2 zero_le_one)


[STATEMENT]
lemma set_plus_image: "S + T = (\<lambda>(x, y). x + y) ` (S \<times> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S + T = (\<lambda>(x, y). x + y) ` (S \<times> T)
[PROOF STEP]
by (fastforce simp: set_plus_def image_iff)


[STATEMENT]
lemma mset_replicate_replicate_mset: "mset (replicate n L) = replicate_mset n L"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (replicate n L) = replicate_mset n L
[PROOF STEP]
by (induction n) auto


[STATEMENT]
lemma mult_left_bounds:
  fixes f g :: "real \<Rightarrow> real"
  shows "\<forall>x. g x \<in> {l x..u x} \<longrightarrow> f x \<ge> 0 \<longrightarrow> f x * g x \<in> {f x * l x..f x * u x}"
    and "\<forall>x. g x \<in> {l x..u x} \<longrightarrow> f x \<le> 0 \<longrightarrow> f x * g x \<in> {f x * u x..f x * l x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. g x \<in> {l x..u x} \<longrightarrow> 0 \<le> f x \<longrightarrow> f x * g x \<in> {f x * l x..f x * u x} &&& \<forall>x. g x \<in> {l x..u x} \<longrightarrow> f x \<le> 0 \<longrightarrow> f x * g x \<in> {f x * u x..f x * l x}
[PROOF STEP]
by (auto intro: mult_left_mono mult_left_mono_neg)


[STATEMENT]
lemma le_lfp: "mono f \<Longrightarrow> x \<le> lfp f \<Longrightarrow> f x \<le> lfp f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>mono f; x \<le> lfp f\<rbrakk> \<Longrightarrow> f x \<le> lfp f
[PROOF STEP]
by (subst lfp_unfold) (auto dest: monoD)


[STATEMENT]
lemma conjugate_square_eq_0_vec[simp]:
  fixes v :: "'a :: {conjugatable_ordered_ring,semiring_no_zero_divisors} vec"
  assumes "v \<in> carrier_vec n"
  shows "v \<bullet>c v = 0 \<longleftrightarrow> v = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)
[PROOF STEP]
proof (insert assms, induct rule: carrier_vec_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (vNil \<bullet>c vNil = (0::'a)) = (vNil = 0\<^sub>v 0)
 2. \<And>n a v. \<lbrakk>v \<in> carrier_vec n; (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)\<rbrakk> \<Longrightarrow> (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (vNil \<bullet>c vNil = (0::'a)) = (vNil = 0\<^sub>v 0)
 2. \<And>n a v. \<lbrakk>v \<in> carrier_vec n; (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)\<rbrakk> \<Longrightarrow> (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vNil \<bullet>c vNil = (0::'a)) = (vNil = 0\<^sub>v 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(vNil \<bullet>c vNil = (0::'a)) = (vNil = 0\<^sub>v 0)

goal (1 subgoal):
 1. \<And>n a v. \<lbrakk>v \<in> carrier_vec n; (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)\<rbrakk> \<Longrightarrow> (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n a v. \<lbrakk>v \<in> carrier_vec n; (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)\<rbrakk> \<Longrightarrow> (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
case (Suc n a v)
[PROOF STATE]
proof (state)
this:
v \<in> carrier_vec n
(v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)

goal (1 subgoal):
 1. \<And>n a v. \<lbrakk>v \<in> carrier_vec n; (v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)\<rbrakk> \<Longrightarrow> (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
v \<in> carrier_vec n
(v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n
(v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)

goal (1 subgoal):
 1. (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
using conjugate_square_positive[of a] conjugate_square_ge_0_vec[of v]
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n
(v \<bullet>c v = (0::'a)) = (v = 0\<^sub>v n)
(0::'a) \<le> a * conjugate a
(0::'a) \<le> v \<bullet>c v

goal (1 subgoal):
 1. (vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))
[PROOF STEP]
by (auto simp: le_less add_nonneg_eq_0_iff zero_vec_Suc)
[PROOF STATE]
proof (state)
this:
(vCons a v \<bullet>c vCons a v = (0::'a)) = (vCons a v = 0\<^sub>v (Suc n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma left_mult_zero_mat'[simp]: "dim_row A = n \<Longrightarrow> 0\<^sub>m nr n * A = 0\<^sub>m nr (dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row A = n \<Longrightarrow> 0\<^sub>m nr n * A = 0\<^sub>m nr (dim_col A)
[PROOF STEP]
by (rule left_mult_zero_mat, unfold carrier_mat_def, simp)


[STATEMENT]
lemma prod_prime_factors:
  assumes "x \<noteq> 0"
  shows   "(\<Prod>p \<in> prime_factors x. p ^ multiplicity p x) = normalize x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
have "normalize x = prod_mset (prime_factorization x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. normalize x = \<Prod>\<^sub># (prime_factorization x)
[PROOF STEP]
by (simp add: prod_mset_prime_factorization assms)
[PROOF STATE]
proof (state)
this:
normalize x = \<Prod>\<^sub># (prime_factorization x)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
normalize x = \<Prod>\<^sub># (prime_factorization x)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
have "\<dots> = (\<Prod>p \<in> prime_factors x. p ^ count (prime_factorization x) p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (prime_factorization x) = (\<Prod>p\<in>prime_factors x. p ^ count (prime_factorization x) p)
[PROOF STEP]
by (subst prod_mset_multiplicity) simp_all
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (prime_factorization x) = (\<Prod>p\<in>prime_factors x. p ^ count (prime_factorization x) p)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (prime_factorization x) = (\<Prod>p\<in>prime_factors x. p ^ count (prime_factorization x) p)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
have "\<dots> = (\<Prod>p \<in> prime_factors x. p ^ multiplicity p x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ count (prime_factorization x) p) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)
[PROOF STEP]
by (intro prod.cong)
      (simp_all add: assms count_prime_factorization_prime in_prime_factors_imp_prime)
[PROOF STATE]
proof (state)
this:
(\<Prod>p\<in>prime_factors x. p ^ count (prime_factorization x) p) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
normalize x = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
normalize x = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = normalize x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma LeadsETo_UN:
     "(\<And>i. i \<in> I \<Longrightarrow> F \<in> (A i) LeadsTo[CC] B)
      \<Longrightarrow> F \<in> (UN i:I. A i) LeadsTo[CC] B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> F \<in> A i LeadsTo[CC] B) \<Longrightarrow> F \<in> \<Union> (A ` I) LeadsTo[CC] B
[PROOF STEP]
apply (blast intro: LeadsETo_Union)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prime_power_eq_imp_eq:
  fixes p q :: "'a :: factorial_semiring"
  assumes "prime p" "prime q" "m > 0"
  assumes "p ^ m = q ^ n"
  shows   "p = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = q
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
assume pq: "p \<noteq> q"
[PROOF STATE]
proof (state)
this:
p \<noteq> q

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
prime q
0 < m
p ^ m = q ^ n
[PROOF STEP]
have "m = multiplicity p (p ^ m)"
[PROOF STATE]
proof (prove)
using this:
prime p
prime q
0 < m
p ^ m = q ^ n

goal (1 subgoal):
 1. m = multiplicity p (p ^ m)
[PROOF STEP]
by (subst multiplicity_prime_power) auto
[PROOF STATE]
proof (state)
this:
m = multiplicity p (p ^ m)

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m = multiplicity p (p ^ m)

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
note \<open>p ^ m = q ^ n\<close>
[PROOF STATE]
proof (state)
this:
p ^ m = q ^ n

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p ^ m = q ^ n

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
from assms pq
[PROOF STATE]
proof (chain)
picking this:
prime p
prime q
0 < m
p ^ m = q ^ n
p \<noteq> q
[PROOF STEP]
have "multiplicity p (q ^ n) = 0"
[PROOF STATE]
proof (prove)
using this:
prime p
prime q
0 < m
p ^ m = q ^ n
p \<noteq> q

goal (1 subgoal):
 1. multiplicity p (q ^ n) = 0
[PROOF STEP]
by (subst multiplicity_distinct_prime_power) auto
[PROOF STATE]
proof (state)
this:
multiplicity p (q ^ n) = 0

goal (1 subgoal):
 1. p \<noteq> q \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
m = 0
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
m = 0

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_suminf_le:
  assumes "\<And>n. norm (f n :: 'a :: banach) \<le> g n" "summable g"
  shows   "norm (suminf f) \<le> suminf g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
have *: "summable (\<lambda>n. norm (f n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. norm (f n))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
norm (f ?n) \<le> g ?n
summable g

goal (1 subgoal):
 1. summable (\<lambda>n. norm (f n))
[PROOF STEP]
by (intro summable_norm summable_comparison_test[OF _ assms(2)] exI[of _ 0]) auto
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. norm (f n))

goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
hence "norm (suminf f) \<le> (\<Sum>n. norm (f n))"
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. norm (f n))

goal (1 subgoal):
 1. norm (suminf f) \<le> (\<Sum>n. norm (f n))
[PROOF STEP]
by (intro summable_norm) auto
[PROOF STATE]
proof (state)
this:
norm (suminf f) \<le> (\<Sum>n. norm (f n))

goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (suminf f) \<le> (\<Sum>n. norm (f n))

goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
have "\<dots> \<le> suminf g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. norm (f n)) \<le> suminf g
[PROOF STEP]
by (intro suminf_le * assms allI)
[PROOF STATE]
proof (state)
this:
(\<Sum>n. norm (f n)) \<le> suminf g

goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (suminf f) \<le> suminf g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (suminf f) \<le> suminf g

goal (1 subgoal):
 1. norm (suminf f) \<le> suminf g
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (suminf f) \<le> suminf g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_at_sequentially:
  fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
  shows "continuous (at a) f \<longleftrightarrow>
    (\<forall>x. (x \<longlongrightarrow> a) sequentially --> ((f \<circ> x) \<longlongrightarrow> f a) sequentially)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isCont f a = (\<forall>x. x \<longlonglongrightarrow> a \<longrightarrow> (f \<circ> x) \<longlonglongrightarrow> f a)
[PROOF STEP]
using continuous_within_sequentially[of a UNIV f]
[PROOF STATE]
proof (prove)
using this:
isCont f a = (\<forall>x. (\<forall>n. x n \<in> UNIV) \<and> x \<longlonglongrightarrow> a \<longrightarrow> (f \<circ> x) \<longlonglongrightarrow> f a)

goal (1 subgoal):
 1. isCont f a = (\<forall>x. x \<longlonglongrightarrow> a \<longrightarrow> (f \<circ> x) \<longlonglongrightarrow> f a)
[PROOF STEP]
by simp


[STATEMENT]
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. analz G \<union> analz H \<subseteq> analz (G \<union> H)
[PROOF STEP]
by (intro Un_least analz_mono Un_upper1 Un_upper2)


[STATEMENT]
lemma inter_mset_empty_distrib_right: "A \<inter># (B + C) = {#} \<longleftrightarrow> A \<inter># B = {#} \<and> A \<inter># C = {#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<inter># (B + C) = {#}) = (A \<inter># B = {#} \<and> A \<inter># C = {#})
[PROOF STEP]
by (meson disjunct_not_in union_iff)


[STATEMENT]
lemma emeasure_eq:
  "emeasure P A = (if A \<subseteq> Pow S_edges then (\<Sum>edges\<in>A. p^card edges * (1 - p)^card (S_edges - edges)) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure P A = ennreal (if A \<subseteq> Pow S_edges then \<Sum>edges\<in>A. p ^ card edges * (1 - p) ^ card (S_edges - edges) else 0)
[PROOF STEP]
using finite_edges p_prob
[PROOF STATE]
proof (prove)
using this:
finite S_edges
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. emeasure P A = ennreal (if A \<subseteq> Pow S_edges then \<Sum>edges\<in>A. p ^ card edges * (1 - p) ^ card (S_edges - edges) else 0)
[PROOF STEP]
by (simp add: P_def space_point_measure emeasure_point_measure_finite
    sets_point_measure emeasure_notin_sets)


[STATEMENT]
lemma DFT_upper:
  assumes mbound: "0 < m" and ibound: "m <= i"
  shows "DFT (2 * m) a i =
    DFT m (%i. a (2 * i)) (i - m) -
    root (2 * m) ^ (i - m) * DFT m (%i. a (2 * i + 1)) (i - m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DFT (2 * m) a i = DFT m (\<lambda>i. a (2 * i)) (i - m) - FFT.root (2 * m) ^ (i - m) * DFT m (\<lambda>i. a (2 * i + 1)) (i - m)
[PROOF STEP]
proof (unfold DFT_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
have "(\<Sum>j = 0..<2 * m. root (2 * m) ^ (i * j) * a j) =
    (\<Sum>j = 0..<m. root (2 * m) ^ (i * (2 * j)) * a (2 * j)) +
    (\<Sum>j = 0..<m. root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1))"
    (is "?s = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1))
[PROOF STEP]
by (simp add: sum_splice)
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1))

goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1))

goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
have "... =
    (\<Sum>j = 0..<m. root m ^ ((i - m) * j) * a (2 * j)) -
    root (2 * m) ^ (i - m) *
    (\<Sum>j = 0..<m. root m ^ ((i - m) * j) * a (2 * j + 1))"
    (is "_ = ?t")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1)) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
txt \<open>First pair of sums\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1)) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
apply (simp add: root_cancel1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root m ^ (i * j) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i + i * (2 * j)) * a (Suc (2 * j))) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (Suc (2 * j)))
[PROOF STEP]
apply (simp add: root_unity ibound root_nonzero power_diff power_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i + i * (2 * j)) * a (Suc (2 * j))) = - (FFT.root (2 * m) ^ i * (\<Sum>j = 0..<m. (FFT.root m ^ i) ^ j * a (Suc (2 * j))) / FFT.root (2 * m) ^ m)
[PROOF STEP]
txt \<open>Second pair of sums\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i + i * (2 * j)) * a (Suc (2 * j))) = - (FFT.root (2 * m) ^ i * (\<Sum>j = 0..<m. (FFT.root m ^ i) ^ j * a (Suc (2 * j))) / FFT.root (2 * m) ^ m)
[PROOF STEP]
apply (simp add: mbound root_cancel2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i + i * (2 * j)) * a (Suc (2 * j))) = FFT.root (2 * m) ^ i * (\<Sum>j = 0..<m. (FFT.root m ^ i) ^ j * a (Suc (2 * j)))
[PROOF STEP]
apply (simp add: sum_distrib_left)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i + i * (2 * j)) * a (Suc (2 * j))) = (\<Sum>n = 0..<m. FFT.root (2 * m) ^ i * ((FFT.root m ^ i) ^ n * a (Suc (2 * n))))
[PROOF STEP]
apply (simp add: power_add)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ i * FFT.root (2 * m) ^ (i * (2 * j)) * a (Suc (2 * j))) = (\<Sum>n = 0..<m. FFT.root (2 * m) ^ i * ((FFT.root m ^ i) ^ n * a (Suc (2 * n))))
[PROOF STEP]
apply (simp add: root_cancel1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ i * FFT.root m ^ (i * j) * a (Suc (2 * j))) = (\<Sum>n = 0..<m. FFT.root (2 * m) ^ i * ((FFT.root m ^ i) ^ n * a (Suc (2 * n))))
[PROOF STEP]
apply (simp add: power_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<m. FFT.root (2 * m) ^ i * (FFT.root m ^ i) ^ j * a (Suc (2 * j))) = (\<Sum>n = 0..<m. FFT.root (2 * m) ^ i * ((FFT.root m ^ i) ^ n * a (Suc (2 * n))))
[PROOF STEP]
apply (simp add: ac_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j)) * a (2 * j)) + (\<Sum>j = 0..<m. FFT.root (2 * m) ^ (i * (2 * j + 1)) * a (2 * j + 1)) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))

goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
show "?s = ?t"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))

goal (1 subgoal):
 1. (\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<2 * m. FFT.root (2 * m) ^ (i * j) * a j) = (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j)) - FFT.root (2 * m) ^ (i - m) * (\<Sum>j = 0..<m. FFT.root m ^ ((i - m) * j) * a (2 * j + 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem gen_mutil_not_tiling:
  "t \<in> tiling domino ==>
  (i + j) mod 2 = 0 ==> (m + n) mod 2 = 0 ==>
  {(i, j), (m, n)} \<subseteq> t
  ==> (t - {(i,j)} - {(m,n)}) \<notin> tiling domino"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; {(i, j), (m, n)} \<subseteq> t\<rbrakk> \<Longrightarrow> t - {(i, j)} - {(m, n)} \<notin> tiling domino
[PROOF STEP]
apply (rule notI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; {(i, j), (m, n)} \<subseteq> t; t - {(i, j)} - {(m, n)} \<in> tiling domino\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (subgoal_tac
  "card (whites \<inter> (t - {(i,j)} - {(m,n)})) <
   card (blacks \<inter> (t - {(i,j)} - {(m,n)}))")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; {(i, j), (m, n)} \<subseteq> t; t - {(i, j)} - {(m, n)} \<in> tiling domino; card (whites \<inter> (t - {(i, j)} - {(m, n)})) < card (blacks \<inter> (t - {(i, j)} - {(m, n)}))\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; {(i, j), (m, n)} \<subseteq> t; t - {(i, j)} - {(m, n)} \<in> tiling domino\<rbrakk> \<Longrightarrow> card (whites \<inter> (t - {(i, j)} - {(m, n)})) < card (blacks \<inter> (t - {(i, j)} - {(m, n)}))
[PROOF STEP]
apply (force simp only: tiling_domino_0_1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; {(i, j), (m, n)} \<subseteq> t; t - {(i, j)} - {(m, n)} \<in> tiling domino\<rbrakk> \<Longrightarrow> card (whites \<inter> (t - {(i, j)} - {(m, n)})) < card (blacks \<inter> (t - {(i, j)} - {(m, n)}))
[PROOF STEP]
apply (simp add: tiling_domino_0_1 [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<in> tiling domino; (i + j) mod 2 = 0; (m + n) mod 2 = 0; (i, j) \<in> t \<and> (m, n) \<in> t; t - {(i, j)} - {(m, n)} \<in> tiling domino\<rbrakk> \<Longrightarrow> card (whites \<inter> t - {(i, j)} - {(m, n)}) < card (whites \<inter> t)
[PROOF STEP]
apply (simp add: coloured_def card_Diff2_less)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Gmult_add_add:
  assumes "a \<in> G"
  shows "Gmult a (m+n) = Gmult a m \<oplus> Gmult a n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Gmult a (m + n) = Gmult a m \<oplus> Gmult a n
[PROOF STEP]
by (induction m) (use assms local.associative in fastforce)+


[STATEMENT]
lemma inv_stereographic_stereographic [simp]:
  shows "inv_stereographic (stereographic x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_stereographic (stereographic x) = x
[PROOF STEP]
using stereographic_inv_stereographic[of "stereographic x"]
[PROOF STATE]
proof (prove)
using this:
stereographic (inv_stereographic (stereographic x)) = stereographic x

goal (1 subgoal):
 1. inv_stereographic (stereographic x) = x
[PROOF STEP]
using bij_stereographic
[PROOF STATE]
proof (prove)
using this:
stereographic (inv_stereographic (stereographic x)) = stereographic x
bij stereographic

goal (1 subgoal):
 1. inv_stereographic (stereographic x) = x
[PROOF STEP]
unfolding bij_def inj_on_def
[PROOF STATE]
proof (prove)
using this:
stereographic (inv_stereographic (stereographic x)) = stereographic x
(\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. stereographic x = stereographic y \<longrightarrow> x = y) \<and> surj stereographic

goal (1 subgoal):
 1. inv_stereographic (stereographic x) = x
[PROOF STEP]
by simp


[STATEMENT]
lemma filtermap_at_right_shift: "filtermap (\<lambda>x. x - d) (at_right a) = at_right (a - d)"
  for a d :: "real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filtermap (\<lambda>x. x - d) (at_right a) = at_right (a - d)
[PROOF STEP]
by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_shift[symmetric])