[STATEMENT]
lemma complex_div_gt_0: "(Re (a / b) > 0 \<longleftrightarrow> Re (a * cnj b) > 0) \<and> (Im (a / b) > 0 \<longleftrightarrow> Im (a * cnj b) > 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
proof (cases "b = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. b = 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
 2. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
b = 0

goal (2 subgoals):
 1. b = 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
 2. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
b = 0

goal (1 subgoal):
 1. (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b \<noteq> 0
[PROOF STEP]
have "0 < (Re b)\<^sup>2 + (Im b)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0

goal (1 subgoal):
 1. 0 < (Re b)\<^sup>2 + (Im b)\<^sup>2
[PROOF STEP]
by (simp add: complex_eq_iff sum_power2_gt_zero_iff)
[PROOF STATE]
proof (state)
this:
0 < (Re b)\<^sup>2 + (Im b)\<^sup>2

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < (Re b)\<^sup>2 + (Im b)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < (Re b)\<^sup>2 + (Im b)\<^sup>2

goal (1 subgoal):
 1. (0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))
[PROOF STEP]
by (simp add: Re_divide Im_divide zero_less_divide_iff)
[PROOF STATE]
proof (state)
this:
(0 < Re (a / b)) = (0 < Re (a * cnj b)) \<and> (0 < Im (a / b)) = (0 < Im (a * cnj b))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma suminf_half_series_ereal: "(\<Sum>n. (1/2 :: ereal) ^ Suc n) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. (1 / 2) ^ Suc n) = 1
[PROOF STEP]
using sums_ereal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x. ereal ((1 / 2) ^ Suc x)) = ereal 1

goal (1 subgoal):
 1. (\<Sum>n. (1 / 2) ^ Suc n) = 1
[PROOF STEP]
by (simp add: one_ereal_def)


[STATEMENT]
lemma odd_half_floor:
assumes "odd x"
shows "\<lfloor>real_of_int x / 2\<rfloor> = (x-1) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>real_of_int x / 2\<rfloor> = (x - 1) div 2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. \<lfloor>real_of_int x / 2\<rfloor> = (x - 1) div 2
[PROOF STEP]
by (metis add.commute diff_add_cancel even_add
 even_succ_div_2 floor_divide_of_int_eq odd_one of_int_numeral)


[STATEMENT]
lemma erf_remainder_conv_Suc:
  assumes "x > 0"
  shows   "erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) *
                    exp (- x\<^sup>2) / (x ^ (2 * n + 1)) + erf_remainder (Suc n) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
have "erf_remainder n x =
          (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) *
             exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + -(
          (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) *
            real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)" (is "_ = ?A + ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)
[PROOF STEP]
unfolding erf_remainder_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * erf_remainder_integral n x = (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x

goal (1 subgoal):
 1. (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * erf_remainder_integral n x = (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)
[PROOF STEP]
by (subst erf_remainder_integral_conv_Suc)
       (auto simp: assms algebra_simps simp del: power_Suc)
[PROOF STATE]
proof (state)
this:
erf_remainder n x = (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
erf_remainder n x = (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) + - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x)

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
have "?B = erf_remainder (Suc n) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x) = erf_remainder (Suc n) x
[PROOF STEP]
by (simp add: divide_simps erf_remainder_def)
[PROOF STATE]
proof (state)
this:
- ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x) = erf_remainder (Suc n) x

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- ((- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * real (2 * n + 1) / 2 * erf_remainder_integral (Suc n) x) = erf_remainder (Suc n) x

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
have "?A = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) *
                    exp (- x\<^sup>2) / (x ^ (2 * n + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1)
[PROOF STEP]
by (simp add: divide_simps)
[PROOF STATE]
proof (state)
this:
(- 1) ^ n * 2 * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / (2 * x ^ (2 * n + 1)) = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1)

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x

goal (1 subgoal):
 1. erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
erf_remainder n x = (- 1) ^ n * fact (2 * n) / (sqrt pi * 4 ^ n * fact n) * exp (- x\<^sup>2) / x ^ (2 * n + 1) + erf_remainder (Suc n) x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_less_power_trans2:
  fixes n :: nat
  shows "\<lbrakk>n < 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> n * 2 ^ k  < 2 ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> n * 2 ^ k < 2 ^ m
[PROOF STEP]
by (subst mult.commute, erule (1) nat_less_power_trans)


[STATEMENT]
lemma tendsto_powr:
  fixes a b :: real
  assumes f: "(f \<longlongrightarrow> a) F"
    and g: "(g \<longlongrightarrow> b) F"
    and a: "a \<noteq> 0"
  shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F
[PROOF STEP]
unfolding powr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. if f x = 0 then 0 else exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) F
[PROOF STEP]
proof (rule filterlim_If)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))
 2. ((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x \<noteq> 0}))
[PROOF STEP]
from f
[PROOF STATE]
proof (chain)
picking this:
(f \<longlongrightarrow> a) F
[PROOF STEP]
show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> a) F

goal (1 subgoal):
 1. ((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))
[PROOF STEP]
by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))

goal (1 subgoal):
 1. ((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x \<noteq> 0}))
[PROOF STEP]
from f g a
[PROOF STATE]
proof (chain)
picking this:
(f \<longlongrightarrow> a) F
(g \<longlongrightarrow> b) F
a \<noteq> 0
[PROOF STEP]
show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a)))
      (inf F (principal {x. f x \<noteq> 0}))"
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> a) F
(g \<longlongrightarrow> b) F
a \<noteq> 0

goal (1 subgoal):
 1. ((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x \<noteq> 0}))
[PROOF STEP]
by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x \<noteq> 0}))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma filtermap_times_pos_at_right:
  fixes c::"'a::{linordered_field, linorder_topology}"
  assumes "c > 0"
  shows "filtermap (times c) (at_right p) = at_right (c * p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filtermap ((*) c) (at_right p) = at_right (c * p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(0::'a) < c

goal (1 subgoal):
 1. filtermap ((*) c) (at_right p) = at_right (c * p)
[PROOF STEP]
by (intro filtermap_fun_inverse[where g="\<lambda>x. inverse c * x"])
    (auto intro!: filterlim_ident filterlim_times_pos)


[STATEMENT]
lemma set_card_diff_ge_zero: "finite A \<Longrightarrow> finite B \<Longrightarrow> A \<noteq> B \<Longrightarrow> card A = card B \<Longrightarrow>
    card (A - B) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B; A \<noteq> B; card A = card B\<rbrakk> \<Longrightarrow> 0 < card (A - B)
[PROOF STEP]
by (meson Diff_eq_empty_iff card_0_eq card_subset_eq finite_Diff neq0_conv)


[STATEMENT]
lemma aux_sum_formula: "(\<Sum>i<n. 10 + 5 * i) \<le> 3 * n^2 + 7 * (n :: nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
have "(\<Sum>i<n. 10 + 5 * i) = 10 * n + 5 * (\<Sum>i<n. i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) = 10 * n + 5 * \<Sum> {..<n}
[PROOF STEP]
by (subst sum.distrib, auto simp: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. 10 + 5 * i) = 10 * n + 5 * \<Sum> {..<n}

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. 10 + 5 * i) = 10 * n + 5 * \<Sum> {..<n}

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
have "\<dots> \<le> 10 * n + 3 * ((n - 1) * n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 10 * n + 5 * \<Sum> {..<n} \<le> 10 * n + 3 * ((n - 1) * n)
[PROOF STEP]
by (unfold gauss_sum_nat2, rule add_left_mono, cases n, auto)
[PROOF STATE]
proof (state)
this:
10 * n + 5 * \<Sum> {..<n} \<le> 10 * n + 3 * ((n - 1) * n)

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
10 * n + 5 * \<Sum> {..<n} \<le> 10 * n + 3 * ((n - 1) * n)

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
have "\<dots> = 3 * n^2 + 7 * n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 10 * n + 3 * ((n - 1) * n) = 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
unfolding power2_eq_square
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 10 * n + 3 * ((n - 1) * n) = 3 * (n * n) + 7 * n
[PROOF STEP]
by (cases n, auto)
[PROOF STATE]
proof (state)
this:
10 * n + 3 * ((n - 1) * n) = 3 * n\<^sup>2 + 7 * n

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n

goal (1 subgoal):
 1. (\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. 10 + 5 * i) \<le> 3 * n\<^sup>2 + 7 * n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lucas_lehmer_mult_assoc:
  assumes m: "m > 0"
  shows   "lucas_lehmer_mult m x (lucas_lehmer_mult m y z) =
           lucas_lehmer_mult m (lucas_lehmer_mult m x y) z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lucas_lehmer_mult m x (lucas_lehmer_mult m y z) = lucas_lehmer_mult m (lucas_lehmer_mult m x y) z
[PROOF STEP]
proof (rule prod_eqI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
let ?mul = "lucas_lehmer_mult m"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "[fst (?mul x (?mul y z)) = fst x * (fst y * fst z + 3 * snd y * snd z) +
           3 * snd x * (fst y * snd z + snd y * fst z)] (mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z)] (mod m)
[PROOF STEP]
by (rule lucas_lehmer_mult_cong[THEN cong_trans] cong_add cong_mult cong_refl)+
[PROOF STATE]
proof (state)
this:
[fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z)] (mod m)

goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z)] (mod m)

goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "fst x * (fst y * fst z + 3 * snd y * snd z) +
               3 * snd x * (fst y * snd z + snd y * fst z) =
             (fst x * fst y + 3 * snd x * snd y) * fst z +
               3 * (fst x * snd y + snd x * fst y) * snd z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z) = (fst x * fst y + 3 * snd x * snd y) * fst z + 3 * (fst x * snd y + snd x * fst y) * snd z
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z) = (fst x * fst y + 3 * snd x * snd y) * fst z + 3 * (fst x * snd y + snd x * fst y) * snd z

goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fst x * (fst y * fst z + 3 * snd y * snd z) + 3 * snd x * (fst y * snd z + snd y * fst z) = (fst x * fst y + 3 * snd x * snd y) * fst z + 3 * (fst x * snd y + snd x * fst y) * snd z

goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "[\<dots> = fst (?mul (?mul x y) z)] (mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(fst x * fst y + 3 * snd x * snd y) * fst z + 3 * (fst x * snd y + snd x * fst y) * snd z = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)
[PROOF STEP]
by (rule cong_sym, (rule lucas_lehmer_mult_cong[THEN cong_trans] cong_add cong_mult cong_refl)+)
[PROOF STATE]
proof (state)
this:
[(fst x * fst y + 3 * snd x * snd y) * fst z + 3 * (fst x * snd y + snd x * fst y) * snd z = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)

goal (2 subgoals):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
 2. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)
[PROOF STEP]
show "fst (?mul x (?mul y z)) = fst (?mul (?mul x y) z)"
[PROOF STATE]
proof (prove)
using this:
[fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)

goal (1 subgoal):
 1. fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
by (rule cong_less_modulus_unique_nat)
       (use m in \<open>auto simp: lucas_lehmer_mult_def case_prod_unfold\<close>)
[PROOF STATE]
proof (state)
this:
fst (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "[snd (?mul x (?mul y z)) = fst x * (fst y * snd z + snd y * fst z) +
     snd x * (fst y * fst z + 3 * snd y * snd z)] (mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z)] (mod m)
[PROOF STEP]
by (rule lucas_lehmer_mult_cong[THEN cong_trans] cong_add cong_mult cong_refl)+
[PROOF STATE]
proof (state)
this:
[snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z)] (mod m)

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z)] (mod m)

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z) =
             (fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z) = (fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z) = (fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fst x * (fst y * snd z + snd y * fst z) + snd x * (fst y * fst z + 3 * snd y * snd z) = (fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
have "[\<dots> = snd (?mul (?mul x y) z)] (mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)
[PROOF STEP]
by (rule cong_sym, (rule lucas_lehmer_mult_cong[THEN cong_trans] cong_add cong_mult cong_refl)+)
[PROOF STATE]
proof (state)
this:
[(fst x * fst y + 3 * snd x * snd y) * snd z + (fst x * snd y + snd x * fst y) * fst z = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)
[PROOF STEP]
show "snd (?mul x (?mul y z)) = snd (?mul (?mul x y) z)"
[PROOF STATE]
proof (prove)
using this:
[snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)] (mod m)

goal (1 subgoal):
 1. snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)
[PROOF STEP]
by (rule cong_less_modulus_unique_nat)
       (use m in \<open>auto simp: lucas_lehmer_mult_def case_prod_unfold\<close>)
[PROOF STATE]
proof (state)
this:
snd (lucas_lehmer_mult m x (lucas_lehmer_mult m y z)) = snd (lucas_lehmer_mult m (lucas_lehmer_mult m x y) z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_z_over_z_series:
  fixes z :: "'a :: {real_normed_field,banach}"
  assumes "z \<noteq> 0"
  shows   "(\<lambda>n. (-1)^n / fact (2*n+1) * z^(2*n)) sums (sin z / z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. (- (1::'a)) ^ n / fact (2 * n + 1) * z ^ (2 * n)) sums (sin z / z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. (- (1::'a)) ^ n / fact (2 * n + 1) * z ^ (2 * n)) sums (sin z / z)
[PROOF STEP]
from sin_series[of z]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. ((- 1) ^ n / fact (2 * n + 1)) *\<^sub>R z ^ (2 * n + 1)) sums sin z
[PROOF STEP]
have "(\<lambda>n. z * ((-1)^n / fact (2*n+1)) * z^(2*n)) sums sin z"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ((- 1) ^ n / fact (2 * n + 1)) *\<^sub>R z ^ (2 * n + 1)) sums sin z

goal (1 subgoal):
 1. (\<lambda>n. z * ((- (1::'a)) ^ n / fact (2 * n + 1)) * z ^ (2 * n)) sums sin z
[PROOF STEP]
by (simp add: field_simps scaleR_conv_of_real)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. z * ((- (1::'a)) ^ n / fact (2 * n + 1)) * z ^ (2 * n)) sums sin z

goal (1 subgoal):
 1. (\<lambda>n. (- (1::'a)) ^ n / fact (2 * n + 1) * z ^ (2 * n)) sums (sin z / z)
[PROOF STEP]
from sums_mult[OF this, of "inverse z"] and assms
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. inverse z * (z * ((- (1::'a)) ^ n / fact (2 * n + 1)) * z ^ (2 * n))) sums (inverse z * sin z)
z \<noteq> (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse z * (z * ((- (1::'a)) ^ n / fact (2 * n + 1)) * z ^ (2 * n))) sums (inverse z * sin z)
z \<noteq> (0::'a)

goal (1 subgoal):
 1. (\<lambda>n. (- (1::'a)) ^ n / fact (2 * n + 1) * z ^ (2 * n)) sums (sin z / z)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (- (1::'a)) ^ n / fact (2 * n + 1) * z ^ (2 * n)) sums (sin z / z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma expands_to_sqrt:
  assumes "trimmed_pos F" "basis_wf basis" "(f expands_to F) basis"
  shows   "((\<lambda>x. sqrt (f x)) expands_to powr_expansion False F (1/2)) basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. sqrt (f x)) expands_to powr_expansion False F (1 / 2)) basis
[PROOF STEP]
using expands_to_root[of 2 F basis f] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 2; trimmed_pos F; basis_wf basis; (f expands_to F) basis\<rbrakk> \<Longrightarrow> ((\<lambda>x. root 2 (f x)) expands_to powr_expansion False F (inverse (real 2))) basis
trimmed_pos F
basis_wf basis
(f expands_to F) basis

goal (1 subgoal):
 1. ((\<lambda>x. sqrt (f x)) expands_to powr_expansion False F (1 / 2)) basis
[PROOF STEP]
by (simp add: sqrt_def)


[STATEMENT]
lemma "add2 (add2 (S n) (S m)) (S k) = S(S(S(add2 n (add2 m k))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add2 (add2 (S n) (S m)) (S k) = S (S (S (add2 n (add2 m k))))
[PROOF STEP]
by normalization


[STATEMENT]
lemma foldl_prod_prod:
  "foldl (\<lambda>(r::'b::comm_ring_1) (x::'a::comm_ring_1). r * f x) v as * foldl (\<lambda>r x. r * g x) w as =
    foldl (\<lambda>r x. r * f x * g x) (v * w) as"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>r x. r * f x) v as * foldl (\<lambda>r x. r * g x) w as = foldl (\<lambda>r x. r * f x * g x) (v * w) as
[PROOF STEP]
by (induct as arbitrary: v w) (simp_all add: algebra_simps)


[STATEMENT]
lemma suminf_geometric: "norm c < 1 \<Longrightarrow> suminf (\<lambda>n. c^n) = 1 / (1 - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm c < 1 \<Longrightarrow> (\<Sum>n. c ^ n) = (1::'a) / ((1::'a) - c)
[PROOF STEP]
by (rule sums_unique[symmetric]) (rule geometric_sums)


[STATEMENT]
lemma simple_integral_add[simp]:
  assumes f: "simple_function M f" and "\<And>x. 0 \<le> f x" and g: "simple_function M g" and "\<And>x. 0 \<le> g x"
  shows "(\<integral>\<^sup>Sx. f x + g x \<partial>M) = integral\<^sup>S M f + integral\<^sup>S M g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
have "(\<integral>\<^sup>Sx. f x + g x \<partial>M) =
    (\<Sum>y\<in>(\<lambda>x. (f x, g x))`space M. (fst y + snd y) * emeasure M {x\<in>space M. (f x, g x) = y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y})
[PROOF STEP]
by (intro simple_function_partition) (auto intro: f g)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>S x. f x + g x \<partial>M = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y})

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>S x. f x + g x \<partial>M = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y})

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
have "\<dots> = (\<Sum>y\<in>(\<lambda>x. (f x, g x))`space M. fst y * emeasure M {x\<in>space M. (f x, g x) = y}) +
    (\<Sum>y\<in>(\<lambda>x. (f x, g x))`space M. snd y * emeasure M {x\<in>space M. (f x, g x) = y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y}) = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) + (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y})
[PROOF STEP]
using assms(2,4)
[PROOF STATE]
proof (prove)
using this:
0 \<le> f ?x
0 \<le> g ?x

goal (1 subgoal):
 1. (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y}) = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) + (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y})
[PROOF STEP]
by (auto intro!: sum.cong distrib_right simp: sum.distrib[symmetric])
[PROOF STATE]
proof (state)
this:
(\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y}) = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) + (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y})

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. (fst y + snd y) * emeasure M {x \<in> space M. (f x, g x) = y}) = (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) + (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y})

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
have "(\<Sum>y\<in>(\<lambda>x. (f x, g x))`space M. fst y * emeasure M {x\<in>space M. (f x, g x) = y}) = (\<integral>\<^sup>Sx. f x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) = integral\<^sup>S M f
[PROOF STEP]
by (intro simple_function_partition[symmetric]) (auto intro: f g)
[PROOF STATE]
proof (state)
this:
(\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) = integral\<^sup>S M f

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. fst y * emeasure M {x \<in> space M. (f x, g x) = y}) = integral\<^sup>S M f

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
have "(\<Sum>y\<in>(\<lambda>x. (f x, g x))`space M. snd y * emeasure M {x\<in>space M. (f x, g x) = y}) = (\<integral>\<^sup>Sx. g x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y}) = integral\<^sup>S M g
[PROOF STEP]
by (intro simple_function_partition[symmetric]) (auto intro: f g)
[PROOF STATE]
proof (state)
this:
(\<Sum>y\<in>(\<lambda>x. (f x, g x)) ` space M. snd y * emeasure M {x \<in> space M. (f x, g x) = y}) = integral\<^sup>S M g

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g

goal (1 subgoal):
 1. \<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>S x. f x + g x \<partial>M = integral\<^sup>S M f + integral\<^sup>S M g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem card_equiv_k_classes_eq_card_partitions_k_parts:
  "card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}
[PROOF STEP]
have "bij_betw (\<lambda>R. A // R) {R. equiv A R \<and> card (A // R) = k} {P. partition_on A P \<and> card P = k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw ((//) A) {R. equiv A R \<and> card (A // R) = k} {P. partition_on A P \<and> card P = k}
[PROOF STEP]
by (rule bij_betw_partition_of_equiv_with_k_classes)
[PROOF STATE]
proof (state)
this:
bij_betw ((//) A) {R. equiv A R \<and> card (A // R) = k} {P. partition_on A P \<and> card P = k}

goal (1 subgoal):
 1. card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
bij_betw ((//) A) {R. equiv A R \<and> card (A // R) = k} {P. partition_on A P \<and> card P = k}
[PROOF STEP]
show "card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}"
[PROOF STATE]
proof (prove)
using this:
bij_betw ((//) A) {R. equiv A R \<and> card (A // R) = k} {P. partition_on A P \<and> card P = k}

goal (1 subgoal):
 1. card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card {R. equiv A R \<and> card (A // R) = k} = card {P. partition_on A P \<and> card P = k}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma proj2_set_Col_coeff:
  assumes "proj2_set_Col S" and "{p,q,r} \<subseteq> S" and "p \<noteq> q" and "r \<noteq> p"
  shows "r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)"
  (is "r = proj2_abs (?i *\<^sub>R ?u + ?v)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)
[PROOF STEP]
from \<open>{p,q,r} \<subseteq> S\<close> and \<open>proj2_set_Col S\<close>
[PROOF STATE]
proof (chain)
picking this:
{p, q, r} \<subseteq> S
proj2_set_Col S
[PROOF STEP]
have "proj2_set_Col {p,q,r}"
[PROOF STATE]
proof (prove)
using this:
{p, q, r} \<subseteq> S
proj2_set_Col S

goal (1 subgoal):
 1. proj2_set_Col {p, q, r}
[PROOF STEP]
by (rule proj2_subset_Col)
[PROOF STATE]
proof (state)
this:
proj2_set_Col {p, q, r}

goal (1 subgoal):
 1. r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)
[PROOF STEP]
hence "proj2_Col p q r"
[PROOF STATE]
proof (prove)
using this:
proj2_set_Col {p, q, r}

goal (1 subgoal):
 1. proj2_Col p q r
[PROOF STEP]
by (subst proj2_Col_iff_set_Col)
[PROOF STATE]
proof (state)
this:
proj2_Col p q r

goal (1 subgoal):
 1. r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)
[PROOF STEP]
with \<open>p \<noteq> q\<close> and \<open>r \<noteq> p\<close> and proj2_Col_coeff
[PROOF STATE]
proof (chain)
picking this:
p \<noteq> q
r \<noteq> p
\<lbrakk>proj2_Col ?a ?r ?t; ?a \<noteq> ?r; ?t \<noteq> ?a\<rbrakk> \<Longrightarrow> ?t = proj2_abs (proj2_Col_coeff ?a ?r ?t *\<^sub>R proj2_rep ?a + proj2_rep ?r)
proj2_Col p q r
[PROOF STEP]
show "r = proj2_abs (?i *\<^sub>R ?u + ?v)"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> q
r \<noteq> p
\<lbrakk>proj2_Col ?a ?r ?t; ?a \<noteq> ?r; ?t \<noteq> ?a\<rbrakk> \<Longrightarrow> ?t = proj2_abs (proj2_Col_coeff ?a ?r ?t *\<^sub>R proj2_rep ?a + proj2_rep ?r)
proj2_Col p q r

goal (1 subgoal):
 1. r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r = proj2_abs (proj2_Col_coeff p q r *\<^sub>R proj2_rep p + proj2_rep q)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neg_prod_sum_le:
  fixes c :: "'a::linordered_field"
  assumes "c < 0"
  shows "c * x + t \<le> 0 \<equiv> x \<ge> (- 1 / c) * t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * x + t \<le> (0::'a) \<equiv> - (1::'a) / c * t \<le> x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c * x + t \<le> (0::'a) \<equiv> - (1::'a) / c * t \<le> x
[PROOF STEP]
have "c * x + t \<le> 0 \<longleftrightarrow> c * x \<le> -t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c * x + t \<le> (0::'a)) = (c * x \<le> - t)
[PROOF STEP]
by (subst le_iff_diff_le_0 [of "c*x" "-t"]) simp
[PROOF STATE]
proof (state)
this:
(c * x + t \<le> (0::'a)) = (c * x \<le> - t)

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

goal (1 subgoal):
 1. c * x + t \<le> (0::'a) \<equiv> - (1::'a) / c * t \<le> x
[PROOF STEP]
have "\<dots> \<longleftrightarrow> - t / c \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c * x \<le> - t) = (- t / c \<le> x)
[PROOF STEP]
by (simp only: neg_divide_le_eq[OF \<open>c < 0\<close>] algebra_simps)
[PROOF STATE]
proof (state)
this:
(c * x \<le> - t) = (- t / c \<le> x)

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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma invertible_mat_first_column_not0:
  fixes A::"'a :: comm_ring_1 mat"
  assumes A: "A \<in> carrier_mat n n" and inv_A: "invertible_mat A" and n0: "0<n"
  shows "col A 0 \<noteq> (0\<^sub>v n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col A 0 \<noteq> 0\<^sub>v n
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
assume " \<not> col A 0 \<noteq> 0\<^sub>v n"
[PROOF STATE]
proof (state)
this:
\<not> col A 0 \<noteq> 0\<^sub>v n

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
hence col_A0: "col A 0 = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
using this:
\<not> col A 0 \<noteq> 0\<^sub>v n

goal (1 subgoal):
 1. col A 0 = 0\<^sub>v n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
col A 0 = 0\<^sub>v n

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
have "(det A dvd 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A dvd (1::'a)
[PROOF STEP]
using inv_A invertible_iff_is_unit_JNF[OF A]
[PROOF STATE]
proof (prove)
using this:
invertible_mat A
invertible_mat A = (det A dvd (1::'a))

goal (1 subgoal):
 1. det A dvd (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
det A dvd (1::'a)

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
hence 1: "det A \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
det A dvd (1::'a)

goal (1 subgoal):
 1. det A \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
det A \<noteq> (0::'a)

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
have "det A = (\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0)
[PROOF STEP]
by (rule laplace_expansion_column[OF A n0])
[PROOF STATE]
proof (state)
this:
det A = (\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0)

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det A = (\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0)

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
have "... = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0) = (0::'a)
[PROOF STEP]
by (rule sum.neutral, insert col_A0 n0 A, auto simp add: col_def,
        metis Matrix.zero_vec_def index_vec mult_zero_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. A $$ (i, 0) * Determinant.cofactor A i 0) = (0::'a)

goal (1 subgoal):
 1. \<not> col A 0 \<noteq> 0\<^sub>v n \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
det A = (0::'a)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
det A = (0::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
det A = (0::'a)
det A \<noteq> (0::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma jordan_nf_root_char_poly: fixes A :: "'a :: {semiring_no_zero_divisors, idom} mat"
  assumes "jordan_nf A n_as"
  and "(m, lam) \<in> set n_as"
shows "poly (char_poly A) lam = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
jordan_nf A n_as
(m, lam) \<in> set n_as
[PROOF STEP]
have m0: "m \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
jordan_nf A n_as
(m, lam) \<in> set n_as

goal (1 subgoal):
 1. m \<noteq> 0
[PROOF STEP]
unfolding jordan_nf_def
[PROOF STATE]
proof (prove)
using this:
0 \<notin> fst ` set n_as \<and> similar_mat A (jordan_matrix n_as)
(m, lam) \<in> set n_as

goal (1 subgoal):
 1. m \<noteq> 0
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
m \<noteq> 0

goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
from split_list[OF assms(2)]
[PROOF STATE]
proof (chain)
picking this:
\<exists>ys zs. n_as = ys @ (m, lam) # zs
[PROOF STEP]
obtain as bs where nas: "n_as = as @ (m, lam) # bs"
[PROOF STATE]
proof (prove)
using this:
\<exists>ys zs. n_as = ys @ (m, lam) # zs

goal (1 subgoal):
 1. (\<And>as bs. n_as = as @ (m, lam) # bs \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n_as = as @ (m, lam) # bs

goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
using m0
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. poly (char_poly A) lam = (0::'a)
[PROOF STEP]
unfolding jordan_nf_char_poly[OF assms(1)] nas poly_prod_list prod_list_zero_iff
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. (0::'a) \<in> set (map (\<lambda>p. poly p lam) (map (\<lambda>(n, a). [:- a, 1::'a:] ^ n) (as @ (m, lam) # bs)))
[PROOF STEP]
by (auto simp: o_def)
[PROOF STATE]
proof (state)
this:
poly (char_poly A) lam = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iter_tensor_of_H_on_zero_tensor:
  assumes "n \<ge> 1"
  shows "(H \<otimes>\<^bsup>n\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>n\<^esup>) = \<psi>\<^sub>1\<^sub>0 n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> n

goal (1 subgoal):
 1. H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
proof(rule nat_induct_at_least)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. H \<otimes>\<^bsup>1\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>1\<^esup> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))
 2. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
show "(H \<otimes>\<^bsup>1\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>1\<^esup>) = \<psi>\<^sub>1\<^sub>0 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H \<otimes>\<^bsup>1\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>1\<^esup> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))
[PROOF STEP]
using H_on_ket_zero
[PROOF STATE]
proof (prove)
using this:
H * |Deutsch.zero\<rangle> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))

goal (1 subgoal):
 1. H \<otimes>\<^bsup>1\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>1\<^esup> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
H \<otimes>\<^bsup>1\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>1\<^esup> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
fix n:: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
assume a0: "n \<ge> 1" and IH: "(H \<otimes>\<^bsup>n\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>n\<^esup>) = \<psi>\<^sub>1\<^sub>0 n"
[PROOF STATE]
proof (state)
this:
1 \<le> n
H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 \<le> n
H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
have "(H \<otimes>\<^bsup>(Suc n)\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>(Suc n)\<^esup>) = (H * |zero\<rangle>) \<Otimes> ((H \<otimes>\<^bsup>n\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>n\<^esup>))"
[PROOF STATE]
proof (prove)
using this:
1 \<le> n
H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
using iter_tensor_mult_distr[of "n" "H" "|zero\<rangle>"] a0 ket_vec_def H_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> n
H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
\<lbrakk>1 \<le> n; dim_col H = dim_row |Deutsch.zero\<rangle>; 0 < dim_col H; 0 < dim_col |Deutsch.zero\<rangle>\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup>
1 \<le> n
|?v\<rangle> \<equiv> Matrix.mat (dim_vec ?v) 1 (\<lambda>(i, j). ?v $ i)
H \<equiv> complex_of_real (1 / sqrt 2) \<cdot>\<^sub>m Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 1 else if i = 0 then 1 else - 1)

goal (1 subgoal):
 1. H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
by(simp add: H_def)
[PROOF STATE]
proof (state)
this:
H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup>

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup>

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
have  "... = (H * |zero\<rangle>) \<Otimes> (\<psi>\<^sub>1\<^sub>0 n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
using IH
[PROOF STATE]
proof (prove)
using this:
H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
H * |Deutsch.zero\<rangle> \<Otimes> H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
have "... = (\<psi>\<^sub>1\<^sub>0 1) \<Otimes> (\<psi>\<^sub>1\<^sub>0 n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
using H_on_ket_zero
[PROOF STATE]
proof (prove)
using this:
H * |Deutsch.zero\<rangle> = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1))

goal (1 subgoal):
 1. H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
H * |Deutsch.zero\<rangle> \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
have "... = (\<psi>\<^sub>1\<^sub>0 (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
using \<psi>\<^sub>1\<^sub>0_tensor a0
[PROOF STATE]
proof (prove)
using this:
1 \<le> ?n \<Longrightarrow> Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ ?n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ ?n)) = Matrix.mat (2 ^ Suc ?n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc ?n))
1 \<le> n

goal (1 subgoal):
 1. Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix.mat (2 ^ 1) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ 1)) \<Otimes> Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n)) = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; H \<otimes>\<^bsup>n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>n\<^esup> = Matrix.mat (2 ^ n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ n))\<rbrakk> \<Longrightarrow> H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
show "(H \<otimes>\<^bsup>(Suc n)\<^esup>) * ( |zero\<rangle> \<otimes>\<^bsup>(Suc n)\<^esup>) = (\<psi>\<^sub>1\<^sub>0 (Suc n))"
[PROOF STATE]
proof (prove)
using this:
H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))

goal (1 subgoal):
 1. H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
H \<otimes>\<^bsup>Suc n\<^esup> * |Deutsch.zero\<rangle> \<otimes>\<^bsup>Suc n\<^esup> = Matrix.mat (2 ^ Suc n) 1 (\<lambda>x. complex_of_real (case x of (i, j) \<Rightarrow> 1 / sqrt 2 ^ Suc n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_plus_assoc: assumes vec: "vec nr u" "vec nr v" "vec nr w"
 shows "vec_plus u (vec_plus v w) = vec_plus (vec_plus u v) w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_plus u (vec_plus v w) = vec_plus (vec_plus u v) w
[PROOF STEP]
proof (rule vec_eqI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. vec ?n (vec_plus u (vec_plus v w))
 2. vec ?n (vec_plus (vec_plus u v) w)
 3. \<And>i. i < ?n \<Longrightarrow> vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. vec ?n (vec_plus u (vec_plus v w))
 2. vec ?n (vec_plus (vec_plus u v) w)
 3. \<And>i. i < ?n \<Longrightarrow> vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i
[PROOF STEP]
assume i: "i < nr"
[PROOF STATE]
proof (state)
this:
i < nr

goal (3 subgoals):
 1. vec ?n (vec_plus u (vec_plus v w))
 2. vec ?n (vec_plus (vec_plus u v) w)
 3. \<And>i. i < ?n \<Longrightarrow> vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i
[PROOF STEP]
note [simp] = vec_plus_index[OF _ _ i]
[PROOF STATE]
proof (state)
this:
\<lbrakk>vec nr ?v1.0; vec nr ?v2.0\<rbrakk> \<Longrightarrow> vec_plusI ?pl ?v1.0 ?v2.0 ! i = ?pl (?v1.0 ! i) (?v2.0 ! i)

goal (3 subgoals):
 1. vec ?n (vec_plus u (vec_plus v w))
 2. vec ?n (vec_plus (vec_plus u v) w)
 3. \<And>i. i < ?n \<Longrightarrow> vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i
[PROOF STEP]
from vec
[PROOF STATE]
proof (chain)
picking this:
vec nr u
vec nr v
vec nr w
[PROOF STEP]
show "vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i"
[PROOF STATE]
proof (prove)
using this:
vec nr u
vec nr v
vec nr w

goal (1 subgoal):
 1. vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i
[PROOF STEP]
by (auto simp: add.assoc)
[PROOF STATE]
proof (state)
this:
vec_plus u (vec_plus v w) ! i = vec_plus (vec_plus u v) w ! i

goal (2 subgoals):
 1. vec nr (vec_plus u (vec_plus v w))
 2. vec nr (vec_plus (vec_plus u v) w)
[PROOF STEP]
qed (auto intro: vec)


[STATEMENT]
lemma mersenne_mod_less':
  assumes "k \<le> 5 * 2 ^ n"
  shows   "mersenne_mod k n < 2 ^ n + 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
have "mersenne_mod k n = k mod 2 ^ n + k div 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mersenne_mod k n = k mod 2 ^ n + k div 2 ^ n
[PROOF STEP]
by (simp add: mersenne_mod_def)
[PROOF STATE]
proof (state)
this:
mersenne_mod k n = k mod 2 ^ n + k div 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mersenne_mod k n = k mod 2 ^ n + k div 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
have "k mod 2 ^ n < 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k mod 2 ^ n < 2 ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k mod 2 ^ n < 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k mod 2 ^ n < 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
k mod 2 ^ n < 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
have "k div 2 ^ n * 2 ^ n + 0 \<le> k div 2 ^ n * 2 ^ n + k mod (2 ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k div 2 ^ n * 2 ^ n + 0 \<le> k div 2 ^ n * 2 ^ n + k mod 2 ^ n
[PROOF STEP]
by (intro add_mono) auto
[PROOF STATE]
proof (state)
this:
k div 2 ^ n * 2 ^ n + 0 \<le> k div 2 ^ n * 2 ^ n + k mod 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k div 2 ^ n * 2 ^ n + 0 \<le> k div 2 ^ n * 2 ^ n + k mod 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
have "\<dots> = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k div 2 ^ n * 2 ^ n + k mod 2 ^ n = k
[PROOF STEP]
by (subst mult.commute) auto
[PROOF STATE]
proof (state)
this:
k div 2 ^ n * 2 ^ n + k mod 2 ^ n = k

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k div 2 ^ n * 2 ^ n + k mod 2 ^ n = k

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
have "\<dots> \<le> 5 * 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> 5 * 2 ^ n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
k \<le> 5 * 2 ^ n

goal (1 subgoal):
 1. k \<le> 5 * 2 ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k \<le> 5 * 2 ^ n

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>k div 2 ^ n * 2 ^ n + 0 \<in> UNIV; k \<in> UNIV; 5 * 2 ^ n \<in> UNIV\<rbrakk> \<Longrightarrow> k div 2 ^ n * 2 ^ n + 0 \<le> 5 * 2 ^ n
[PROOF STEP]
have "k div 2 ^ n \<le> 5"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>k div 2 ^ n * 2 ^ n + 0 \<in> UNIV; k \<in> UNIV; 5 * 2 ^ n \<in> UNIV\<rbrakk> \<Longrightarrow> k div 2 ^ n * 2 ^ n + 0 \<le> 5 * 2 ^ n

goal (1 subgoal):
 1. k div 2 ^ n \<le> 5
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k div 2 ^ n \<le> 5

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
k div 2 ^ n \<le> 5

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>x y. x < y \<Longrightarrow> x + k div 2 ^ n < y + k div 2 ^ n; \<And>x y. x \<le> y \<Longrightarrow> 2 ^ n + x \<le> 2 ^ n + y\<rbrakk> \<Longrightarrow> mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x y. x < y \<Longrightarrow> x + k div 2 ^ n < y + k div 2 ^ n; \<And>x y. x \<le> y \<Longrightarrow> 2 ^ n + x \<le> 2 ^ n + y\<rbrakk> \<Longrightarrow> mersenne_mod k n < 2 ^ n + 5

goal (1 subgoal):
 1. mersenne_mod k n < 2 ^ n + 5
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mersenne_mod k n < 2 ^ n + 5

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma minus_add_minus_mat: fixes u :: "'a :: ab_group_add mat"
  assumes "u \<in> carrier_mat nr nc" "v \<in> carrier_mat nr nc" "w \<in> carrier_mat nr nc"
  shows "u - (v + w) = u - v - w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u - (v + w) = u - v - w
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_mat nr nc
v \<in> carrier_mat nr nc
w \<in> carrier_mat nr nc

goal (1 subgoal):
 1. u - (v + w) = u - v - w
[PROOF STEP]
by auto


[STATEMENT]
lemma echelon_form_def':
"echelon_form A = (
    (\<forall>i. is_zero_row i A \<longrightarrow> \<not> (\<exists>j. j>i \<and> \<not> is_zero_row j A))
    \<and>
    (\<forall>i j. i<j \<and> \<not> (is_zero_row i A) \<and> \<not> (is_zero_row j A)
          \<longrightarrow> ((LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ j $ n \<noteq> 0))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. echelon_form A = ((\<forall>i. is_zero_row i A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row j A)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row j A \<longrightarrow> (LEAST n. A $h i $h n \<noteq> (0::'a)) < (LEAST n. A $h j $h n \<noteq> (0::'a))))
[PROOF STEP]
unfolding echelon_form_def echelon_form_upt_k_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>i. is_zero_row_upt_k i (ncols A) A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j (ncols A) A)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row_upt_k i (ncols A) A \<and> \<not> is_zero_row_upt_k j (ncols A) A \<longrightarrow> (LEAST n. A $h i $h n \<noteq> (0::'a)) < (LEAST n. A $h j $h n \<noteq> (0::'a)))) = ((\<forall>i. is_zero_row i A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row j A)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row j A \<longrightarrow> (LEAST n. A $h i $h n \<noteq> (0::'a)) < (LEAST n. A $h j $h n \<noteq> (0::'a))))
[PROOF STEP]
unfolding is_zero_row_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>i. is_zero_row_upt_k i (ncols A) A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j (ncols A) A)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row_upt_k i (ncols A) A \<and> \<not> is_zero_row_upt_k j (ncols A) A \<longrightarrow> (LEAST n. A $h i $h n \<noteq> (0::'a)) < (LEAST n. A $h j $h n \<noteq> (0::'a)))) = ((\<forall>i. is_zero_row_upt_k i (ncols A) A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j (ncols A) A)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row_upt_k i (ncols A) A \<and> \<not> is_zero_row_upt_k j (ncols A) A \<longrightarrow> (LEAST n. A $h i $h n \<noteq> (0::'a)) < (LEAST n. A $h j $h n \<noteq> (0::'a))))
[PROOF STEP]
by auto


[STATEMENT]
lemma poly_add_in_carrier:
  "\<lbrakk> set p1 \<subseteq> carrier R; set p2 \<subseteq> carrier R \<rbrakk> \<Longrightarrow> set (poly_add p1 p2) \<subseteq> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>set p1 \<subseteq> carrier R; set p2 \<subseteq> carrier R\<rbrakk> \<Longrightarrow> set (poly_add p1 p2) \<subseteq> carrier R
[PROOF STEP]
using polynomial_incl[OF poly_add_is_polynomial[OF carrier_is_subring]]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set ?p1.1 \<subseteq> carrier R; set ?p2.1 \<subseteq> carrier R\<rbrakk> \<Longrightarrow> set (poly_add ?p1.1 ?p2.1) \<subseteq> carrier R

goal (1 subgoal):
 1. \<lbrakk>set p1 \<subseteq> carrier R; set p2 \<subseteq> carrier R\<rbrakk> \<Longrightarrow> set (poly_add p1 p2) \<subseteq> carrier R
[PROOF STEP]
by simp


[STATEMENT]
lemma arccos_arcsin_sqrt_neg: "-1 \<le> x \<Longrightarrow> x \<le> 0 \<Longrightarrow> arccos x = pi - arcsin(sqrt(1 - x\<^sup>2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>- 1 \<le> x; x \<le> 0\<rbrakk> \<Longrightarrow> arccos x = pi - arcsin (sqrt (1 - x\<^sup>2))
[PROOF STEP]
using arccos_arcsin_sqrt_pos [of "-x"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> - x; - x \<le> 1\<rbrakk> \<Longrightarrow> arccos (- x) = arcsin (sqrt (1 - (- x)\<^sup>2))

goal (1 subgoal):
 1. \<lbrakk>- 1 \<le> x; x \<le> 0\<rbrakk> \<Longrightarrow> arccos x = pi - arcsin (sqrt (1 - x\<^sup>2))
[PROOF STEP]
by (simp add: arccos_minus)


[STATEMENT]
lemma exp_1_lt_3: "exp (1::real) < 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
from Taylor_up[of 3 "\<lambda>_. exp" exp 0 1 0]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < 3; exp = exp; \<forall>m t. m < 3 \<and> 0 \<le> t \<and> t \<le> 1 \<longrightarrow> (exp has_real_derivative exp t) (at t); 0 \<le> 0; 0 < 1\<rbrakk> \<Longrightarrow> \<exists>t>0. t < 1 \<and> exp 1 = (\<Sum>m<3. exp 0 / fact m * (1 - 0) ^ m) + exp t / fact 3 * (1 - 0) ^ 3
[PROOF STEP]
obtain t :: real where "t > 0" "t < 1" "exp 1 = 5/2 + exp t / 6"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 3; exp = exp; \<forall>m t. m < 3 \<and> 0 \<le> t \<and> t \<le> 1 \<longrightarrow> (exp has_real_derivative exp t) (at t); 0 \<le> 0; 0 < 1\<rbrakk> \<Longrightarrow> \<exists>t>0. t < 1 \<and> exp 1 = (\<Sum>m<3. exp 0 / fact m * (1 - 0) ^ m) + exp t / fact 3 * (1 - 0) ^ 3

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>0 < t; t < 1; exp 1 = 5 / 2 + exp t / 6\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: eval_nat_numeral)
[PROOF STATE]
proof (state)
this:
0 < t
t < 1
exp 1 = 5 / 2 + exp t / 6

goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
note this(3)
[PROOF STATE]
proof (state)
this:
exp 1 = 5 / 2 + exp t / 6

goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp 1 = 5 / 2 + exp t / 6

goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
from \<open>t < 1\<close>
[PROOF STATE]
proof (chain)
picking this:
t < 1
[PROOF STEP]
have "exp t < exp 1"
[PROOF STATE]
proof (prove)
using this:
t < 1

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

goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>x y. x < y \<Longrightarrow> 5 / 2 + x / 6 < 5 / 2 + y / 6) \<Longrightarrow> exp 1 < 5 / 2 + exp 1 / 6
[PROOF STEP]
show "exp (1::real) < 3"
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x < y \<Longrightarrow> 5 / 2 + x / 6 < 5 / 2 + y / 6) \<Longrightarrow> exp 1 < 5 / 2 + exp 1 / 6

goal (1 subgoal):
 1. exp 1 < 3
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
exp 1 < 3

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ordLeq_Func:
assumes "{b1,b2} \<subseteq> B" "b1 \<noteq> b2"
shows "|A| \<le>o |Func A B|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |A| \<le>o |Func A B|
[PROOF STEP]
unfolding card_of_ordLeq[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. inj_on f A \<and> f ` A \<subseteq> Func A B
[PROOF STEP]
proof(intro exI conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on ?f A
 2. ?f ` A \<subseteq> Func A B
[PROOF STEP]
let ?F = "\<lambda> aa a. if a \<in> A then (if a = aa then b1 else b2) else undefined"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on ?f A
 2. ?f ` A \<subseteq> Func A B
[PROOF STEP]
show "inj_on ?F A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{b1, b2} \<subseteq> B
b1 \<noteq> b2

goal (1 subgoal):
 1. inj_on (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) A
[PROOF STEP]
unfolding inj_on_def fun_eq_iff
[PROOF STATE]
proof (prove)
using this:
{b1, b2} \<subseteq> B
b1 \<noteq> b2

goal (1 subgoal):
 1. \<forall>x\<in>A. \<forall>y\<in>A. (\<forall>xa. (if xa \<in> A then if xa = x then b1 else b2 else undefined) = (if xa \<in> A then if xa = y then b1 else b2 else undefined)) \<longrightarrow> x = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) A

goal (1 subgoal):
 1. (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) ` A \<subseteq> Func A B
[PROOF STEP]
show "?F ` A \<subseteq> Func A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) ` A \<subseteq> Func A B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{b1, b2} \<subseteq> B
b1 \<noteq> b2

goal (1 subgoal):
 1. (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) ` A \<subseteq> Func A B
[PROOF STEP]
unfolding Func_def
[PROOF STATE]
proof (prove)
using this:
{b1, b2} \<subseteq> B
b1 \<noteq> b2

goal (1 subgoal):
 1. (\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) ` A \<subseteq> {f. (\<forall>a\<in>A. f a \<in> B) \<and> (\<forall>a. a \<notin> A \<longrightarrow> f a = undefined)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>aa a. if a \<in> A then if a = aa then b1 else b2 else undefined) ` A \<subseteq> Func A B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma triangle_num_eq_iff: "triangle_num m = triangle_num n \<longleftrightarrow> m = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (triangle_num m = triangle_num n) = (m = n)
[PROOF STEP]
using strict_mono_eq[OF strict_mono_triangle_num]
[PROOF STATE]
proof (prove)
using this:
(triangle_num ?x = triangle_num ?y) = (?x = ?y)

goal (1 subgoal):
 1. (triangle_num m = triangle_num n) = (m = n)
[PROOF STEP]
.


[STATEMENT]
lemma double_csin_square:
  "2 * csin (a::real) * csin a = 1 - ccos (2 * a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
have eq: "ccos (2 * a) = ccos a * ccos a - csin a * csin a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (cos (2 * a)) = complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
using cos_add[of a a]
[PROOF STATE]
proof (prove)
using this:
cos (a + a) = cos a * cos a - sin a * sin a

goal (1 subgoal):
 1. complex_of_real (cos (2 * a)) = complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
complex_of_real (cos (2 * a)) = complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a)

goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
have "ccos a * ccos a = 1 - csin a * csin a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (cos a) * complex_of_real (cos a) = 1 - complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
using csin_ccos_squared_add[of a]
[PROOF STATE]
proof (prove)
using this:
complex_of_real (cos a) * complex_of_real (cos a) + complex_of_real (sin a) * complex_of_real (sin a) = 1

goal (1 subgoal):
 1. complex_of_real (cos a) * complex_of_real (cos a) = 1 - complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
by (auto intro: add_implies_diff)
[PROOF STATE]
proof (state)
this:
complex_of_real (cos a) * complex_of_real (cos a) = 1 - complex_of_real (sin a) * complex_of_real (sin a)

goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
complex_of_real (cos a) * complex_of_real (cos a) = 1 - complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
have "ccos a * ccos a - csin a * csin a = 1 - 2 * csin (a::real) * csin a"
[PROOF STATE]
proof (prove)
using this:
complex_of_real (cos a) * complex_of_real (cos a) = 1 - complex_of_real (sin a) * complex_of_real (sin a)

goal (1 subgoal):
 1. complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a) = 1 - 2 * complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a) = 1 - 2 * complex_of_real (sin a) * complex_of_real (sin a)

goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
with eq
[PROOF STATE]
proof (chain)
picking this:
complex_of_real (cos (2 * a)) = complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a)
complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a) = 1 - 2 * complex_of_real (sin a) * complex_of_real (sin a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
complex_of_real (cos (2 * a)) = complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a)
complex_of_real (cos a) * complex_of_real (cos a) - complex_of_real (sin a) * complex_of_real (sin a) = 1 - 2 * complex_of_real (sin a) * complex_of_real (sin a)

goal (1 subgoal):
 1. 2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * complex_of_real (sin a) * complex_of_real (sin a) = 1 - complex_of_real (cos (2 * a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem integral_Markov_inequality_measure:
  assumes [measurable]: "integrable M u" and "A \<in> sets M" and "AE x in M. 0 \<le> u x" "0 < (c::real)"
  shows "measure M {x\<in>space M. u x \<ge> c} \<le> (\<integral>x. u x \<partial>M) / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
have le: "emeasure M {x\<in>space M. u x \<ge> c} \<le> ennreal ((1/c) * (\<integral>x. u x \<partial>M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure M {x \<in> space M. c \<le> u x} \<le> ennreal (1 / c * integral\<^sup>L M u)
[PROOF STEP]
by (rule integral_Markov_inequality) (use assms in auto)
[PROOF STATE]
proof (state)
this:
emeasure M {x \<in> space M. c \<le> u x} \<le> ennreal (1 / c * integral\<^sup>L M u)

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure M {x \<in> space M. c \<le> u x} \<le> ennreal (1 / c * integral\<^sup>L M u)

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
have "\<dots> < top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (1 / c * integral\<^sup>L M u) < top
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ennreal (1 / c * integral\<^sup>L M u) < top

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
emeasure M {x \<in> space M. c \<le> u x} < top
[PROOF STEP]
have "ennreal (measure M {x\<in>space M. u x \<ge> c}) = emeasure M {x\<in>space M. u x \<ge> c}"
[PROOF STATE]
proof (prove)
using this:
emeasure M {x \<in> space M. c \<le> u x} < top

goal (1 subgoal):
 1. ennreal (Sigma_Algebra.measure M {x \<in> space M. c \<le> u x}) = emeasure M {x \<in> space M. c \<le> u x}
[PROOF STEP]
by (intro emeasure_eq_ennreal_measure [symmetric]) auto
[PROOF STATE]
proof (state)
this:
ennreal (Sigma_Algebra.measure M {x \<in> space M. c \<le> u x}) = emeasure M {x \<in> space M. c \<le> u x}

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ennreal (Sigma_Algebra.measure M {x \<in> space M. c \<le> u x}) = emeasure M {x \<in> space M. c \<le> u x}

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
note le
[PROOF STATE]
proof (state)
this:
emeasure M {x \<in> space M. c \<le> u x} \<le> ennreal (1 / c * integral\<^sup>L M u)

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ennreal (Sigma_Algebra.measure M {x \<in> space M. c \<le> u x}) \<le> ennreal (1 / c * integral\<^sup>L M u)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ennreal (Sigma_Algebra.measure M {x \<in> space M. c \<le> u x}) \<le> ennreal (1 / c * integral\<^sup>L M u)

goal (1 subgoal):
 1. Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c
[PROOF STEP]
by (subst (asm) ennreal_le_iff)
       (auto intro!: divide_nonneg_pos Bochner_Integration.integral_nonneg_AE assms)
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M {x \<in> space M. c \<le> u x} \<le> integral\<^sup>L M u / c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integral_exp_times:
  "integral {t0 .. t} (\<lambda>t. exp (c * t)) = (if c = 0 then t - t0 else exp (c * t) / c - exp (c * t0) / c)"
  if "t0 \<le> t"
  for c t::real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {t0..t} (\<lambda>t. exp (c * t)) = (if c = 0 then t - t0 else exp (c * t) / c - exp (c * t0) / c)
[PROOF STEP]
using exp_times_has_integral[OF that, of c] that
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. exp (c * t)) has_integral (if c = 0 then t else exp (c * t) / c) - (if c = 0 then t0 else exp (c * t0) / c)) {t0..t}
t0 \<le> t

goal (1 subgoal):
 1. integral {t0..t} (\<lambda>t. exp (c * t)) = (if c = 0 then t - t0 else exp (c * t) / c - exp (c * t0) / c)
[PROOF STEP]
by (auto split: if_splits)


[STATEMENT]
lemma EVEN_intersect_ODD:
  shows "EVEN \<inter> ODD = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. EVEN \<inter> ODD = {}
[PROOF STEP]
using even_or_odd
[PROOF STATE]
proof (prove)
using this:
\<exists>i. ?n = 2 * i \<or> ?n = 2 * i + 1

goal (1 subgoal):
 1. EVEN \<inter> ODD = {}
[PROOF STEP]
by (auto) (presburger)


[STATEMENT]
lemma real_sqrt_le_iff [simp]: "sqrt x \<le> sqrt y \<longleftrightarrow> x \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sqrt x \<le> sqrt y) = (x \<le> y)
[PROOF STEP]
unfolding sqrt_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (root 2 x \<le> root 2 y) = (x \<le> y)
[PROOF STEP]
by (rule real_root_le_iff [OF pos2])


[STATEMENT]
lemma card_sequences:
  assumes "finite A" "finite B" "card A \<le> card B"
  shows "card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
obtain enum where "bij_betw enum {0..<card A} A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>enum. bij_betw enum {0..<card A} A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>finite A\<close> ex_bij_betw_nat_finite
[PROOF STATE]
proof (prove)
using this:
finite A
finite ?M \<Longrightarrow> \<exists>h. bij_betw h {0..<card ?M} ?M

goal (1 subgoal):
 1. (\<And>enum. bij_betw enum {0..<card A} A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bij_betw enum {0..<card A} A

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
have "bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}
[PROOF STEP]
using \<open>bij_betw enum {0..<card A} A\<close>
[PROOF STATE]
proof (prove)
using this:
bij_betw enum {0..<card A} A

goal (1 subgoal):
 1. bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}
[PROOF STEP]
by (rule bij_betw_function_of)
[PROOF STATE]
proof (state)
this:
bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}
[PROOF STEP]
have "card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}"
[PROOF STATE]
proof (prove)
using this:
bij_betw (function_of A enum) {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
have "card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} = fact (card B) div fact (card B - card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} = fact (card B) div fact (card B - card A)
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close> \<open>card A \<le> card B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card A \<le> card B

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} = fact (card B) div fact (card B - card A)
[PROOF STEP]
by (rule card_extensional_funcset_inj_on)
[PROOF STATE]
proof (state)
this:
card {f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} = fact (card B) div fact (card B - card A)

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> B \<and> length xs = card A \<and> distinct xs} = fact (card B) div fact (card B - card A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) ord_pow:
  assumes "x \<in> carrier G" "k dvd ord x" "k \<noteq> 0"
  shows "ord (pow G x k) = ord x div k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
have "(x [^] k) [^] (ord x div k) = \<one>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x [^] k) [^] (ord x div k) = \<one>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier G
k dvd ord x
k \<noteq> 0

goal (1 subgoal):
 1. (x [^] k) [^] (ord x div k) = \<one>
[PROOF STEP]
by (simp add: nat_pow_pow)
[PROOF STATE]
proof (state)
this:
(x [^] k) [^] (ord x div k) = \<one>

goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(x [^] k) [^] (ord x div k) = \<one>

goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
have "ord x dvd k * ord (x [^] k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord x dvd k * ord (x [^] k)
[PROOF STEP]
by (metis assms(1) pow_ord_eq_1 pow_eq_id nat_pow_closed nat_pow_pow)
[PROOF STATE]
proof (state)
this:
ord x dvd k * ord (x [^] k)

goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(x [^] k) [^] (ord x div k) = \<one>
ord x dvd k * ord (x [^] k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x [^] k) [^] (ord x div k) = \<one>
ord x dvd k * ord (x [^] k)

goal (1 subgoal):
 1. ord (x [^] k) = ord x div k
[PROOF STEP]
by (metis assms div_dvd_div dvd_antisym dvd_triv_left pow_eq_id nat_pow_closed nonzero_mult_div_cancel_left)
[PROOF STATE]
proof (state)
this:
ord (x [^] k) = ord x div k

goal:
No subgoals!
[PROOF STEP]
qed