[STATEMENT]
lemma inner_mult_diag_real':
  fixes B::"complex Matrix.mat"
  assumes "diagonal_mat B"
  and "B \<in> carrier_mat n n"
  and "\<forall>i < n. B$$(i, i) \<in> Reals"
  and "v \<in> carrier_vec n"
shows "inner_prod v (B *\<^sub>v v)  \<in> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
have  "inner_prod v (B *\<^sub>v v)  =
    (\<Sum> i \<in> {0 ..< n}. B $$ (i,i) * (vec_index v i *
    (conjugate (vec_index v i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) = (\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i)))
[PROOF STEP]
using inner_mult_diag_expand' assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>diagonal_mat ?B; ?B \<in> carrier_mat ?n ?n; ?v \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> Complex_Matrix.inner_prod ?v (?B *\<^sub>v ?v) = (\<Sum>i = 0..<?n. ?B $$ (i, i) * (?v $ i * conjugate (?v $ i)))
diagonal_mat B
B \<in> carrier_mat n n
\<forall>i<n. B $$ (i, i) \<in> \<real>
v \<in> carrier_vec n

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) = (\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod v (B *\<^sub>v v) = (\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i)))

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod v (B *\<^sub>v v) = (\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i)))

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
have "... \<in> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i))) \<in> \<real>
[PROOF STEP]
proof (rule real_sum_real)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> B $$ (i, i) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow>
      B $$ (i, i) * ((vec_index v i) * conjugate (vec_index v i)) \<in> \<real>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> B $$ (i, i) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
using assms mult_conj_real
[PROOF STATE]
proof (prove)
using this:
diagonal_mat B
B \<in> carrier_mat n n
\<forall>i<n. B $$ (i, i) \<in> \<real>
v \<in> carrier_vec n
?v * conjugate ?v \<in> \<real>

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> B $$ (i, i) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> B $$ (?i, ?i) * (v $ ?i * conjugate (v $ ?i)) \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. B $$ (i, i) * (v $ i * conjugate (v $ i))) \<in> \<real>

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod v (B *\<^sub>v v) \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma length_around_zero:
  assumes "i >= 0"
  shows "length (around_zero i) = 2 * nat i + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (around_zero i) = 2 * nat i + 1
[PROOF STEP]
proof (induct rule: int_ge_induct [OF assms])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (around_zero 0) = 2 * nat 0 + 1
 2. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. length (around_zero 0) = 2 * nat 0 + 1
 2. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
from 1
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (around_zero 0) = 2 * nat 0 + 1
[PROOF STEP]
by (simp add: around_zero.simps)
[PROOF STATE]
proof (state)
this:
length (around_zero 0) = 2 * nat 0 + 1

goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
case (2 i)
[PROOF STATE]
proof (state)
this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1

goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
from 2
[PROOF STATE]
proof (chain)
picking this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1

goal (1 subgoal):
 1. length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
by (simp add: around_zero.simps [of "i + 1"])
[PROOF STATE]
proof (state)
this:
length (around_zero (i + 1)) = 2 * nat (i + 1) + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tensor_mat_id:
  assumes "0 < d1"
  and "0 < d2"
shows "tensor_mat (1\<^sub>m d1) (1\<^sub>m d2) = 1\<^sub>m (d1 * d2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1\<^sub>m d1 \<Otimes> 1\<^sub>m d2 = 1\<^sub>m (d1 * d2)
[PROOF STEP]
proof (rule eq_matI, auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>j. j < d1 * d2 \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (j, j) = 1
 2. \<And>i j. \<lbrakk>i < d1 * d2; j < d1 * d2; i \<noteq> j\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 0
[PROOF STEP]
show "tensor_mat (1\<^sub>m d1) (1\<^sub>m d2) $$ (i, i) = 1" if "i < (d1 * d2)" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, i) = 1
[PROOF STEP]
using that index_tensor_mat'[of "1\<^sub>m d1" "1\<^sub>m d2"]
[PROOF STATE]
proof (prove)
using this:
i < d1 * d2
\<lbrakk>0 < dim_col (1\<^sub>m d1); 0 < dim_col (1\<^sub>m d2); ?i < dim_row (1\<^sub>m d1) * dim_row (1\<^sub>m d2); ?j < dim_col (1\<^sub>m d1) * dim_col (1\<^sub>m d2)\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (?i, ?j) = 1\<^sub>m d1 $$ (?i div dim_row (1\<^sub>m d2), ?j div dim_col (1\<^sub>m d2)) * 1\<^sub>m d2 $$ (?i mod dim_row (1\<^sub>m d2), ?j mod dim_col (1\<^sub>m d2))

goal (1 subgoal):
 1. (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, i) = 1
[PROOF STEP]
by (simp add: assms less_mult_imp_div_less)
[PROOF STATE]
proof (state)
this:
?i < d1 * d2 \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (?i, ?i) = 1

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < d1 * d2; j < d1 * d2; i \<noteq> j\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < d1 * d2; j < d1 * d2; i \<noteq> j\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 0
[PROOF STEP]
show "tensor_mat (1\<^sub>m d1) (1\<^sub>m d2) $$ (i, j) = 0" if "i < d1 * d2" "j < d1 * d2" "i \<noteq> j" for i j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 0
[PROOF STEP]
using that index_tensor_mat[of "1\<^sub>m d1" d1 d1 "1\<^sub>m d2" d2 d2 i j]
[PROOF STATE]
proof (prove)
using this:
i < d1 * d2
j < d1 * d2
i \<noteq> j
\<lbrakk>dim_row (1\<^sub>m d1) = d1; dim_col (1\<^sub>m d1) = d1; dim_row (1\<^sub>m d2) = d2; dim_col (1\<^sub>m d2) = d2; i < d1 * d2; j < d1 * d2; 0 < d1; 0 < d2\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 1\<^sub>m d1 $$ (i div d2, j div d2) * 1\<^sub>m d2 $$ (i mod d2, j mod d2)

goal (1 subgoal):
 1. (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (i, j) = 0
[PROOF STEP]
by (metis assms(1) assms(2) index_one_mat(1) index_one_mat(2) index_one_mat(3)
        less_mult_imp_div_less mod_less_divisor mult_div_mod_eq mult_not_zero)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < d1 * d2; ?j < d1 * d2; ?i \<noteq> ?j\<rbrakk> \<Longrightarrow> (1\<^sub>m d1 \<Otimes> 1\<^sub>m d2) $$ (?i, ?j) = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem euler_maclaurin_strong_nat':
  assumes "a \<le> b"
  shows   "(\<Sum>k=a..b. f (real k)) =
             F (real b) + C + (1 / 2) *\<^sub>R f (real b) +
             (\<Sum>i=1..N. (bernoulli (2*i) / fact (2*i)) *\<^sub>R fs (2*i-1) (real b)) -
             EM_remainder (2*N+1) (fs (2*N+1)) b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = a..b. f (real k)) = F (real b) + C + (1 / 2) *\<^sub>R f (real b) + (\<Sum>i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *\<^sub>R fs (2 * i - 1) (real b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int b)
[PROOF STEP]
using euler_maclaurin_strong_int'[of b]
[PROOF STATE]
proof (prove)
using this:
int a \<le> int b \<Longrightarrow> (\<Sum>k = int a..int b. f (real_of_int k)) = F (real_of_int (int b)) + C + (1 / 2) *\<^sub>R f (real_of_int (int b)) + (\<Sum>i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *\<^sub>R fs (2 * i - 1) (real_of_int (int b))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int b)

goal (1 subgoal):
 1. (\<Sum>k = a..b. f (real k)) = F (real b) + C + (1 / 2) *\<^sub>R f (real b) + (\<Sum>i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *\<^sub>R fs (2 * i - 1) (real b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int b)
[PROOF STEP]
by (simp add: assms sum_atLeastAtMost_of_int_nat_transfer)


[STATEMENT]
lemma sum_incr2: "sum f (incr2 ` A) = sum (\<lambda>xy. f(fst xy,snd xy+1)) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
have "sum f (incr2 ` A) = sum (f o incr2) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f (incr2 ` A) = sum (f \<circ> incr2) A
[PROOF STEP]
by(subst sum.reindex)(auto simp: inj_on_def)
[PROOF STATE]
proof (state)
this:
sum f (incr2 ` A) = sum (f \<circ> incr2) A

goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f (incr2 ` A) = sum (f \<circ> incr2) A

goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
have "f o incr2 = (\<lambda>xy. f(fst xy,snd xy+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<circ> incr2 = (\<lambda>xy. f (fst xy, snd xy + 1))
[PROOF STEP]
by(auto simp: fun_eq_iff)
[PROOF STATE]
proof (state)
this:
f \<circ> incr2 = (\<lambda>xy. f (fst xy, snd xy + 1))

goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum f (incr2 ` A) = (\<Sum>a\<in>A. f (fst a, snd a + 1))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum f (incr2 ` A) = (\<Sum>a\<in>A. f (fst a, snd a + 1))

goal (1 subgoal):
 1. sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum f (incr2 ` A) = (\<Sum>xy\<in>A. f (fst xy, snd xy + 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma exp_not_zero_imp_exp_diff_not_zero:
  \<open>2 ^ (n - m) \<noteq> 0\<close> if \<open>2 ^ n \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
proof (cases \<open>m \<le> n\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
 2. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
m \<le> n

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
 2. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
m \<le> n

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
 2. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
define q where \<open>q = n - m\<close>
[PROOF STATE]
proof (state)
this:
q = n - m

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
 2. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
m \<le> n
q = n - m
[PROOF STEP]
have \<open>n = m + q\<close>
[PROOF STATE]
proof (prove)
using this:
m \<le> n
q = n - m

goal (1 subgoal):
 1. n = m + q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n = m + q

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
 2. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
with that
[PROOF STATE]
proof (chain)
picking this:
(2::'a) ^ n \<noteq> (0::'a)
n = m + q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(2::'a) ^ n \<noteq> (0::'a)
n = m + q

goal (1 subgoal):
 1. (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
by (simp add: exp_add_not_zero_imp_right)
[PROOF STATE]
proof (state)
this:
(2::'a) ^ (n - m) \<noteq> (0::'a)

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> m \<le> n

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
with that
[PROOF STATE]
proof (chain)
picking this:
(2::'a) ^ n \<noteq> (0::'a)
\<not> m \<le> n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(2::'a) ^ n \<noteq> (0::'a)
\<not> m \<le> n

goal (1 subgoal):
 1. (2::'a) ^ (n - m) \<noteq> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(2::'a) ^ (n - m) \<noteq> (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma invfun_surj:"\<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk>
                      \<Longrightarrow>  surj_to (invfun A B f) B A "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> surj_to (f\<inverse>\<^bsub>B,A\<^esub>) B A
[PROOF STEP]
apply (simp add:surj_to_def [of "invfun A B f" "B" "A"] image_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x} = A
[PROOF STEP]
apply (rule equalityI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x} \<subseteq> A
 2. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> A \<subseteq> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x}
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; x \<in> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x}\<rbrakk> \<Longrightarrow> x \<in> A
 2. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> A \<subseteq> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x}
[PROOF STEP]
apply (simp add:CollectI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; \<exists>xa\<in>B. x = (f\<inverse>\<^bsub>B,A\<^esub>) xa\<rbrakk> \<Longrightarrow> x \<in> A
 2. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B\<rbrakk> \<Longrightarrow> A \<subseteq> {y. \<exists>x\<in>B. y = (f\<inverse>\<^bsub>B,A\<^esub>) x}
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xa. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; xa \<in> B\<rbrakk> \<Longrightarrow> (f\<inverse>\<^bsub>B,A\<^esub>) xa \<in> A
 2. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; x \<in> A\<rbrakk> \<Longrightarrow> \<exists>xa\<in>B. x = (f\<inverse>\<^bsub>B,A\<^esub>) xa
[PROOF STEP]
apply (simp add:invfun_mem)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; x \<in> A\<rbrakk> \<Longrightarrow> \<exists>xa\<in>B. x = (f\<inverse>\<^bsub>B,A\<^esub>) xa
[PROOF STEP]
apply (frule funcset_mem [of "f" "A" "B"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; x \<in> A; f x \<in> B\<rbrakk> \<Longrightarrow> \<exists>xa\<in>B. x = (f\<inverse>\<^bsub>B,A\<^esub>) xa
[PROOF STEP]
apply (frule_tac t = x in invfun_l [of "f" "A" "B", THEN sym], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; x \<in> A; f x \<in> B; x = (f\<inverse>\<^bsub>B,A\<^esub>) (f x)\<rbrakk> \<Longrightarrow> \<exists>xa\<in>B. x = (f\<inverse>\<^bsub>B,A\<^esub>) xa
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem integer_composition_enum_correct:
  "set (integer_composition_enum n) = integer_compositions n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (integer_composition_enum n) = integer_compositions n
[PROOF STEP]
proof standard
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set (integer_composition_enum n) \<subseteq> integer_compositions n
 2. integer_compositions n \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
show "set (integer_composition_enum n) \<subseteq> integer_compositions n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (integer_composition_enum n) \<subseteq> integer_compositions n
[PROOF STEP]
unfolding integer_compositions_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (integer_composition_enum n) \<subseteq> {xs. sum_list xs = n \<and> 0 \<notin> set xs}
[PROOF STEP]
using integer_composition_enum_not_null integer_composition_enum_sum
[PROOF STATE]
proof (prove)
using this:
?xs \<in> set (integer_composition_enum ?n) \<Longrightarrow> 0 \<notin> set ?xs
?xs \<in> set (integer_composition_enum ?n) \<Longrightarrow> sum_list ?xs = ?n

goal (1 subgoal):
 1. set (integer_composition_enum n) \<subseteq> {xs. sum_list xs = n \<and> 0 \<notin> set xs}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (integer_composition_enum n) \<subseteq> integer_compositions n

goal (1 subgoal):
 1. integer_compositions n \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integer_compositions n \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
show "integer_compositions n \<subseteq> set (integer_composition_enum n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integer_compositions n \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
unfolding integer_compositions_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xs. sum_list xs = n \<and> 0 \<notin> set xs} \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
using integer_composition_enum_correct_aux
[PROOF STATE]
proof (prove)
using this:
0 \<notin> set ?xs \<Longrightarrow> ?xs \<in> set (integer_composition_enum (sum_list ?xs))

goal (1 subgoal):
 1. {xs. sum_list xs = n \<and> 0 \<notin> set xs} \<subseteq> set (integer_composition_enum n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
integer_compositions n \<subseteq> set (integer_composition_enum n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma add_eq_inf_sup: "a + b = sup a b + inf a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
have "0 = - inf 0 (a - b) + inf (a - b) 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) = - inf (0::'a) (a - b) + inf (a - b) (0::'a)
[PROOF STEP]
by (simp add: inf_commute)
[PROOF STATE]
proof (state)
this:
(0::'a) = - inf (0::'a) (a - b) + inf (a - b) (0::'a)

goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) = - inf (0::'a) (a - b) + inf (a - b) (0::'a)
[PROOF STEP]
have "0 = sup 0 (b - a) + inf (a - b) 0"
[PROOF STATE]
proof (prove)
using this:
(0::'a) = - inf (0::'a) (a - b) + inf (a - b) (0::'a)

goal (1 subgoal):
 1. (0::'a) = sup (0::'a) (b - a) + inf (a - b) (0::'a)
[PROOF STEP]
by (simp add: inf_eq_neg_sup)
[PROOF STATE]
proof (state)
this:
(0::'a) = sup (0::'a) (b - a) + inf (a - b) (0::'a)

goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) = sup (0::'a) (b - a) + inf (a - b) (0::'a)
[PROOF STEP]
have "0 = (- a + sup a b) + (inf a b + (- b))"
[PROOF STATE]
proof (prove)
using this:
(0::'a) = sup (0::'a) (b - a) + inf (a - b) (0::'a)

goal (1 subgoal):
 1. (0::'a) = - a + sup a b + (inf a b + - b)
[PROOF STEP]
by (simp only: add_sup_distrib_left add_inf_distrib_right) simp
[PROOF STATE]
proof (state)
this:
(0::'a) = - a + sup a b + (inf a b + - b)

goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) = - a + sup a b + (inf a b + - b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(0::'a) = - a + sup a b + (inf a b + - b)

goal (1 subgoal):
 1. a + b = sup a b + inf a b
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
a + b = sup a b + inf a b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_path_connected_space_imp:
     "\<lbrakk>path_connected_space X; X homeomorphic_space Y\<rbrakk> \<Longrightarrow> path_connected_space Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>path_connected_space X; X homeomorphic_space Y\<rbrakk> \<Longrightarrow> path_connected_space Y
[PROOF STEP]
unfolding homeomorphic_space_def homeomorphic_maps_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>path_connected_space X; \<exists>f g. continuous_map X Y f \<and> continuous_map Y X g \<and> (\<forall>x\<in>topspace X. g (f x) = x) \<and> (\<forall>y\<in>topspace Y. f (g y) = y)\<rbrakk> \<Longrightarrow> path_connected_space Y
[PROOF STEP]
by (metis (no_types, opaque_lifting) continuous_map_closedin continuous_map_image_subset_topspace imageI order_class.order.antisym path_connectedin_continuous_map_image path_connectedin_topspace subsetI)


[STATEMENT]
lemma (in prob_space) exponential_distributed_expectation:
  "0 < l \<Longrightarrow> distributed M lborel X (exponential_density l) \<Longrightarrow> expectation X = 1 / l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; distributed M lborel X (\<lambda>x. ennreal (exponential_density l x))\<rbrakk> \<Longrightarrow> expectation X = 1 / l
[PROOF STEP]
using erlang_ith_moment[of l X 0 1]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < l; distributed M lborel X (\<lambda>x. ennreal (exponential_density l x))\<rbrakk> \<Longrightarrow> expectation (\<lambda>x. X x ^ 1) = fact (0 + 1) / (fact 0 * l ^ 1)

goal (1 subgoal):
 1. \<lbrakk>0 < l; distributed M lborel X (\<lambda>x. ennreal (exponential_density l x))\<rbrakk> \<Longrightarrow> expectation X = 1 / l
[PROOF STEP]
by simp


[STATEMENT]
lemma min_plus_max:
  shows "(min a b) + (max a b) = a + b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. min a b + max a b = a + b
[PROOF STEP]
proof (cases "a \<le> b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<le> b \<Longrightarrow> min a b + max a b = a + b
 2. \<not> a \<le> b \<Longrightarrow> min a b + max a b = a + b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a \<le> b

goal (2 subgoals):
 1. a \<le> b \<Longrightarrow> min a b + max a b = a + b
 2. \<not> a \<le> b \<Longrightarrow> min a b + max a b = a + b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<le> b

goal (1 subgoal):
 1. min a b + max a b = a + b
[PROOF STEP]
unfolding min_def max_def
[PROOF STATE]
proof (prove)
using this:
a \<le> b

goal (1 subgoal):
 1. (if a \<le> b then a else b) + (if a \<le> b then b else a) = a + b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
min a b + max a b = a + b

goal (1 subgoal):
 1. \<not> a \<le> b \<Longrightarrow> min a b + max a b = a + b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a \<le> b \<Longrightarrow> min a b + max a b = a + b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> a \<le> b

goal (1 subgoal):
 1. \<not> a \<le> b \<Longrightarrow> min a b + max a b = a + b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> a \<le> b

goal (1 subgoal):
 1. min a b + max a b = a + b
[PROOF STEP]
unfolding min_def max_def
[PROOF STATE]
proof (prove)
using this:
\<not> a \<le> b

goal (1 subgoal):
 1. (if a \<le> b then a else b) + (if a \<le> b then b else a) = a + b
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
min a b + max a b = a + b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma even_square_cong_4_int:
  fixes x :: int
  assumes "even x"
  shows   "[x ^ 2 = 0] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
even x
[PROOF STEP]
have "even \<bar>x\<bar>"
[PROOF STATE]
proof (prove)
using this:
even x

goal (1 subgoal):
 1. even \<bar>x\<bar>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
even \<bar>x\<bar>

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
hence [simp]: "\<bar>x\<bar> mod 2 = 0"
[PROOF STATE]
proof (prove)
using this:
even \<bar>x\<bar>

goal (1 subgoal):
 1. \<bar>x\<bar> mod 2 = 0
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar> mod 2 = 0

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
have "(\<bar>x\<bar> ^ 2) mod 4 = ((\<bar>x\<bar> mod 4) ^ 2) mod 4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4
[PROOF STEP]
by (simp add: power_mod)
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
even x
[PROOF STEP]
have "\<bar>x\<bar> mod 4 = 0 \<or> \<bar>x\<bar> mod 4 = 2"
[PROOF STATE]
proof (prove)
using this:
even x

goal (1 subgoal):
 1. \<bar>x\<bar> mod 4 = 0 \<or> \<bar>x\<bar> mod 4 = 2
[PROOF STEP]
using mod_double_modulus[of 2 "\<bar>x\<bar>"]
[PROOF STATE]
proof (prove)
using this:
even x
\<lbrakk>0 < 2; 0 \<le> \<bar>x\<bar>\<rbrakk> \<Longrightarrow> \<bar>x\<bar> mod (2 * 2) = \<bar>x\<bar> mod 2 \<or> \<bar>x\<bar> mod (2 * 2) = \<bar>x\<bar> mod 2 + 2

goal (1 subgoal):
 1. \<bar>x\<bar> mod 4 = 0 \<or> \<bar>x\<bar> mod 4 = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar> mod 4 = 0 \<or> \<bar>x\<bar> mod 4 = 2

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
hence "((\<bar>x\<bar> mod 4) ^ 2) mod 4 = 0"
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar> mod 4 = 0 \<or> \<bar>x\<bar> mod 4 = 2

goal (1 subgoal):
 1. (\<bar>x\<bar> mod 4)\<^sup>2 mod 4 = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<bar>x\<bar> mod 4)\<^sup>2 mod 4 = 0

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>x\<bar>\<^sup>2 mod 4 = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar>\<^sup>2 mod 4 = 0

goal (1 subgoal):
 1. [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = 0] (mod 4)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_inv_matrix_change_of_basis:
  fixes X::"'a::{field}^'n^'n" and Y::"'a^'n^'n"
  assumes basis_X: "is_basis (set_of_vector X)" and basis_Y: "is_basis (set_of_vector Y)"
  shows"matrix_change_of_basis Y X = matrix_inv (matrix_change_of_basis X Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis Y X = matrix_inv (matrix_change_of_basis X Y)
[PROOF STEP]
proof (rule matrix_inv_unique[symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
have linear_id: "linear ((*s)) ((*s)) id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear (*s) (*s) id
[PROOF STEP]
by (metis vec.linear_id)
[PROOF STATE]
proof (state)
this:
linear (*s) (*s) id

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
have "(matrix_change_of_basis Y X) ** (matrix_change_of_basis X Y) = (matrix' Y X id) ** (matrix' X Y id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = matrix' Y X id ** matrix' X Y id
[PROOF STEP]
unfolding matrix'_id_eq_matrix_change_of_basis[OF basis_X basis_Y]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = matrix' Y X id ** matrix_change_of_basis X Y
[PROOF STEP]
unfolding matrix'_id_eq_matrix_change_of_basis[OF basis_Y basis_X]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = matrix_change_of_basis Y X ** matrix_change_of_basis X Y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis Y X ** matrix_change_of_basis X Y = matrix' Y X id ** matrix' X Y id

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis Y X ** matrix_change_of_basis X Y = matrix' Y X id ** matrix' X Y id

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
have "... = matrix' X X (id \<circ> id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix' Y X id ** matrix' X Y id = matrix' X X (id \<circ> id)
[PROOF STEP]
using matrix'_compose[OF basis_X basis_Y basis_X linear_id linear_id]
[PROOF STATE]
proof (prove)
using this:
matrix' X X (id \<circ> id) = matrix' Y X id ** matrix' X Y id

goal (1 subgoal):
 1. matrix' Y X id ** matrix' X Y id = matrix' X X (id \<circ> id)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
matrix' Y X id ** matrix' X Y id = matrix' X X (id \<circ> id)

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix' Y X id ** matrix' X Y id = matrix' X X (id \<circ> id)

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
have "... = matrix_change_of_basis X X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix' X X (id \<circ> id) = matrix_change_of_basis X X
[PROOF STEP]
using  matrix'_id_eq_matrix_change_of_basis[OF basis_X basis_X]
[PROOF STATE]
proof (prove)
using this:
matrix' X X id = matrix_change_of_basis X X

goal (1 subgoal):
 1. matrix' X X (id \<circ> id) = matrix_change_of_basis X X
[PROOF STEP]
unfolding o_def id_def
[PROOF STATE]
proof (prove)
using this:
matrix' X X (\<lambda>x. x) = matrix_change_of_basis X X

goal (1 subgoal):
 1. matrix' X X (\<lambda>x. x) = matrix_change_of_basis X X
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix' X X (id \<circ> id) = matrix_change_of_basis X X

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix' X X (id \<circ> id) = matrix_change_of_basis X X

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
have "... = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis X X = mat (1::'a)
[PROOF STEP]
using matrix_change_of_basis_mat_1[OF basis_X]
[PROOF STATE]
proof (prove)
using this:
matrix_change_of_basis X X = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis X X = mat (1::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis X X = mat (1::'a)

goal (2 subgoals):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
 2. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
show "matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat 1"
[PROOF STATE]
proof (prove)
using this:
matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis Y X ** matrix_change_of_basis X Y = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
have "(matrix_change_of_basis X Y) ** (matrix_change_of_basis Y X) = (matrix' X Y id) ** (matrix' Y X id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = matrix' X Y id ** matrix' Y X id
[PROOF STEP]
unfolding matrix'_id_eq_matrix_change_of_basis[OF basis_X basis_Y]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = matrix_change_of_basis X Y ** matrix' Y X id
[PROOF STEP]
unfolding matrix'_id_eq_matrix_change_of_basis[OF basis_Y basis_X]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = matrix_change_of_basis X Y ** matrix_change_of_basis Y X
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis X Y ** matrix_change_of_basis Y X = matrix' X Y id ** matrix' Y X id

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis X Y ** matrix_change_of_basis Y X = matrix' X Y id ** matrix' Y X id

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
have "... = matrix' Y Y (id \<circ> id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix' X Y id ** matrix' Y X id = matrix' Y Y (id \<circ> id)
[PROOF STEP]
using matrix'_compose[OF basis_Y basis_X basis_Y linear_id linear_id]
[PROOF STATE]
proof (prove)
using this:
matrix' Y Y (id \<circ> id) = matrix' X Y id ** matrix' Y X id

goal (1 subgoal):
 1. matrix' X Y id ** matrix' Y X id = matrix' Y Y (id \<circ> id)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
matrix' X Y id ** matrix' Y X id = matrix' Y Y (id \<circ> id)

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix' X Y id ** matrix' Y X id = matrix' Y Y (id \<circ> id)

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
have "... = matrix_change_of_basis Y Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix' Y Y (id \<circ> id) = matrix_change_of_basis Y Y
[PROOF STEP]
using  matrix'_id_eq_matrix_change_of_basis[OF basis_Y basis_Y]
[PROOF STATE]
proof (prove)
using this:
matrix' Y Y id = matrix_change_of_basis Y Y

goal (1 subgoal):
 1. matrix' Y Y (id \<circ> id) = matrix_change_of_basis Y Y
[PROOF STEP]
unfolding o_def id_def
[PROOF STATE]
proof (prove)
using this:
matrix' Y Y (\<lambda>x. x) = matrix_change_of_basis Y Y

goal (1 subgoal):
 1. matrix' Y Y (\<lambda>x. x) = matrix_change_of_basis Y Y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix' Y Y (id \<circ> id) = matrix_change_of_basis Y Y

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix' Y Y (id \<circ> id) = matrix_change_of_basis Y Y

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
have "... = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_change_of_basis Y Y = mat (1::'a)
[PROOF STEP]
using matrix_change_of_basis_mat_1[OF basis_Y]
[PROOF STATE]
proof (prove)
using this:
matrix_change_of_basis Y Y = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis Y Y = mat (1::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis Y Y = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
show "matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat 1"
[PROOF STATE]
proof (prove)
using this:
matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)

goal (1 subgoal):
 1. matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_change_of_basis X Y ** matrix_change_of_basis Y X = mat (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma least_powerI:
  assumes "(f ^^ n) x = x" and "n > 0"
  shows "(f ^^ (least_power f x)) x = x" and "least_power f x > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f ^^ least_power f x) x = x &&& 0 < least_power f x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f ^^ n) x = x
0 < n

goal (1 subgoal):
 1. (f ^^ least_power f x) x = x &&& 0 < least_power f x
[PROOF STEP]
unfolding least_power_def
[PROOF STATE]
proof (prove)
using this:
(f ^^ n) x = x
0 < n

goal (1 subgoal):
 1. (f ^^ (LEAST n. (f ^^ n) x = x \<and> 0 < n)) x = x &&& 0 < (LEAST n. (f ^^ n) x = x \<and> 0 < n)
[PROOF STEP]
by (metis (mono_tags, lifting) LeastI)+


[STATEMENT]
lemma rank_1_proj_trace_inner:
  fixes A :: "'a::conjugatable_field Matrix.mat" and v :: "'a Matrix.vec"
  assumes A: "A \<in> carrier_mat n n"
    and v: "v \<in> carrier_vec n"
  shows "Complex_Matrix.trace (A * (rank_1_proj v)) = Complex_Matrix.inner_prod v (A *\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.trace (A * rank_1_proj v) = Complex_Matrix.inner_prod v (A *\<^sub>v v)
[PROOF STEP]
using assms trace_outer_prod_right[of A]
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
v \<in> carrier_vec n
\<lbrakk>A \<in> carrier_mat ?n ?n; ?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> Complex_Matrix.trace (A * outer_prod ?v ?w) = Complex_Matrix.inner_prod ?w (A *\<^sub>v ?v)

goal (1 subgoal):
 1. Complex_Matrix.trace (A * rank_1_proj v) = Complex_Matrix.inner_prod v (A *\<^sub>v v)
[PROOF STEP]
unfolding rank_1_proj_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
v \<in> carrier_vec n
\<lbrakk>A \<in> carrier_mat ?n ?n; ?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> Complex_Matrix.trace (A * outer_prod ?v ?w) = Complex_Matrix.inner_prod ?w (A *\<^sub>v ?v)

goal (1 subgoal):
 1. Complex_Matrix.trace (A * outer_prod v v) = Complex_Matrix.inner_prod v (A *\<^sub>v v)
[PROOF STEP]
by simp