[STATEMENT]
lemma gen_akiyama_tanigawa_n_0:
  "gen_akiyama_tanigawa f n 0 =
     (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
note [simp del] = gen_akiyama_tanigawa.simps
[PROOF STATE]
proof (state)
this:
gen_akiyama_tanigawa ?f 0 ?m = ?f ?m
gen_akiyama_tanigawa ?f (Suc ?n) ?m = real (Suc ?m) * (gen_akiyama_tanigawa ?f ?n ?m - gen_akiyama_tanigawa ?f ?n (Suc ?m))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "gen_akiyama_tanigawa f n 0 = -(AT_fps f n $ 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gen_akiyama_tanigawa f n 0 = - (AT_fps f n $ 0)
[PROOF STEP]
by (simp add: AT_fps_def)
[PROOF STATE]
proof (state)
this:
gen_akiyama_tanigawa f n 0 = - (AT_fps f n $ 0)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gen_akiyama_tanigawa f n 0 = - (AT_fps f n $ 0)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "AT_fps f n $ 0 = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AT_fps f n $ 0 = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k))
[PROOF STEP]
by (subst AT_fps_altdef) (simp add: fps_sum_nth fps_nth_power_0 fps_0th_higher_deriv)
[PROOF STATE]
proof (state)
this:
AT_fps f n $ 0 = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
AT_fps f n $ 0 = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "\<dots> = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k)) = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k)))
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k)) = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k)))
[PROOF STEP]
by (intro sum.cong refl) (auto simp: Stirling_n_0 AT_fps_0_nth)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k)) = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k)))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * AT_fps f 0 $ k)) = (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k)))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "\<dots> = (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) -
                    (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k)"
     (is "_ = sum ?f _ - ?S2")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k))) = (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k)
[PROOF STEP]
by (simp add: sum_subtractf algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k))) = (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. real (Stirling n k) * (- 1) ^ k * (fact k * (f (k - 1) - f k))) = (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
[PROOF STEP]
have "sum ?f {..n} = sum ?f {0<..n}"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))
[PROOF STEP]
by (intro sum.mono_neutral_right) (auto simp: Stirling_n_0)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "\<dots> = sum ?f {0<..Suc n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..Suc n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))
[PROOF STEP]
by (intro sum.mono_neutral_left) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..Suc n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{0<..n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>k\<in>{0<..Suc n}. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "{0<..Suc n} = {Suc 0..Suc n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0<..Suc n} = {Suc 0..Suc n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0<..Suc n} = {Suc 0..Suc n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{0<..Suc n} = {Suc 0..Suc n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "sum ?f \<dots> = sum (\<lambda>n. ?f (Suc n)) {0..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = Suc 0..Suc n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>na = 0..n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1))
[PROOF STEP]
by (subst sum.atLeast_Suc_atMost_Suc_shift) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>k = Suc 0..Suc n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>na = 0..n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = Suc 0..Suc n. fact k * (real (Stirling n k) * (- 1) ^ k) * f (k - 1)) = (\<Sum>na = 0..n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "{0..n} = {..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0..n} = {..n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0..n} = {..n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{0..n} = {..n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "sum (\<lambda>n. ?f (Suc n)) \<dots> - ?S2 =
               (\<Sum>k\<le>n. -((-1)^k * fact k * real (Stirling (Suc n) (Suc k)) * f k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>na\<le>n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k) = (\<Sum>k\<le>n. - ((- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k))
[PROOF STEP]
by (subst sum_subtractf [symmetric], intro sum.cong) (simp_all add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>na\<le>n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k) = (\<Sum>k\<le>n. - ((- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>na\<le>n. fact (Suc na) * (real (Stirling n (Suc na)) * (- 1) ^ Suc na) * f (Suc na - 1)) - (\<Sum>k\<le>n. fact k * (real (Stirling n k) * (- 1) ^ k) * f k) = (\<Sum>k\<le>n. - ((- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
have "-\<dots> = (\<Sum>k\<le>n. ((-1)^k * fact k * real (Stirling (Suc n) (Suc k)) * f k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (\<Sum>k\<le>n. - ((- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)) = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
by (simp add: sum_negf)
[PROOF STATE]
proof (state)
this:
- (\<Sum>k\<le>n. - ((- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)) = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
 2. n \<noteq> 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)

goal (1 subgoal):
 1. gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> gen_akiyama_tanigawa f n 0 = (\<Sum>k\<le>n. (- 1) ^ k * fact k * real (Stirling (Suc n) (Suc k)) * f k)
[PROOF STEP]
qed simp_all


[STATEMENT]
lemma m1mod22k:
  \<open>- 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - (1::int)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - 1
[PROOF STEP]
by (simp add: zmod_minus1)


[STATEMENT]
theorem euler_maclaurin_strong_raw_nat:
  assumes "a \<le> b" "0 < N" "finite Y" "fs 0 = f"
    "(\<And>k. k \<le> N \<Longrightarrow> continuous_on {real a..real b} (fs k))"
    "(\<And>k x. k < N \<Longrightarrow> x \<in> {real a..real b} - Y \<Longrightarrow>
       (fs k has_vector_derivative fs (Suc k) x) (at x))"
  shows "(\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f =
           (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) +
           EM_remainder' N (fs N) (real a) (real b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
have "(\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) -
           integral {real_of_int (int a)..real_of_int (int b)} f =
           (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R
             (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) +
           EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a \<le> b
0 < N
finite Y
fs 0 = f
?k \<le> N \<Longrightarrow> continuous_on {real a..real b} (fs ?k)
\<lbrakk>?k < N; ?x \<in> {real a..real b} - Y\<rbrakk> \<Longrightarrow> (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)

goal (1 subgoal):
 1. (\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))
[PROOF STEP]
by (intro euler_maclaurin_raw_strong_int[where Y = Y] assms) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))

goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))

goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
have "(\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) = (\<Sum>i\<in>{a<..b}. f (real i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) = (\<Sum>i\<in>{a<..b}. f (real i))
[PROOF STEP]
by (intro sum.reindex_bij_witness[of _ int nat]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{int a<..int b}. f (real_of_int i)) = (\<Sum>i\<in>{a<..b}. f (real i))

goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>{a<..b}. f (real i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>{a<..b}. f (real i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))

goal (1 subgoal):
 1. (\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{a<..b}. f (real i)) - integral {real a..real b} f = (\<Sum>k<N. (bernoulli' (Suc k) / fact (Suc k)) *\<^sub>R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma less_disjoint_disjointed: "m < n \<Longrightarrow> disjointed A m \<inter> disjointed A n = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < n \<Longrightarrow> disjointed A m \<inter> disjointed A n = {}
[PROOF STEP]
by (auto simp add: disjointed_def)


[STATEMENT]
lemma unit_factor_Gcd: "unit_factor (Gcd A) = (if Gcd A = 0 then 0 else 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_factor (Gcd A) = (if Gcd A = (0::'a) then 0::'a else (1::'a))
[PROOF STEP]
by (simp add: Gcd_Lcm unit_factor_Lcm)


[STATEMENT]
theorem hta_prod'_correct:
  assumes TA: "hashedTa H1" "hashedTa H2"
  assumes HI: "hta_has_idx_s H1" "hta_has_idx_sf H2"
  shows
    "ta_lang (hta_\<alpha> (hta_prod' H1 H2))
     = ta_lang (hta_\<alpha> H1) \<inter> ta_lang (hta_\<alpha> H2)"

    "hashedTa (hta_prod' H1 H2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ta_lang (hta_\<alpha> (hta_prod' H1 H2)) = ta_lang (hta_\<alpha> H1) \<inter> ta_lang (hta_\<alpha> H2) &&& hashedTa (hta_prod' H1 H2)
[PROOF STEP]
by (simp_all add: hta_prod'_correct_aux[OF TA HI] ta_prod_correct_aux1)


[STATEMENT]
lemma mult_one_time_pad_units:
  assumes coprime: "coprime x q"
  shows "map_spmf (\<lambda> b. x*b mod q) (sample_uniform_units q) = sample_uniform_units q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>b. x * b mod q) (sample_uniform_units q) = sample_uniform_units q
[PROOF STEP]
using inj_on_mult_units surj_on_mult_units one_time_pad_units coprime
[PROOF STATE]
proof (prove)
using this:
coprime ?x ?q \<Longrightarrow> inj_on (\<lambda>b. ?x * b mod ?q) ({..<?q} - {0})
\<lbrakk>coprime ?x ?q; inj_on (\<lambda>b. ?x * b mod ?q) ({..<?q} - {0})\<rbrakk> \<Longrightarrow> (\<lambda>b. ?x * b mod ?q) ` ({..<?q} - {0}) = {..<?q} - {0}
\<lbrakk>inj_on ?f ({..<?q} - {0}); ?f ` ({..<?q} - {0}) = {..<?q} - {0}\<rbrakk> \<Longrightarrow> map_spmf ?f (sample_uniform_units ?q) = sample_uniform_units ?q
coprime x q

goal (1 subgoal):
 1. map_spmf (\<lambda>b. x * b mod q) (sample_uniform_units q) = sample_uniform_units q
[PROOF STEP]
by simp


[STATEMENT]
lemma bijective_closed_imp_open_map:
     "\<lbrakk>closed_map X X' f; f ` (topspace X) = topspace X'; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> open_map X X' f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed_map X X' f; f ` topspace X = topspace X'; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> open_map X X' f
[PROOF STEP]
unfolding closed_map_def open_map_def openin_closedin_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>U. closedin X U \<longrightarrow> closedin X' (f ` U); f ` topspace X = topspace X'; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> \<forall>U. U \<subseteq> topspace X \<and> closedin X (topspace X - U) \<longrightarrow> f ` U \<subseteq> topspace X' \<and> closedin X' (topspace X' - f ` U)
[PROOF STEP]
by auto (metis Diff_subset inj_on_image_set_diff)


[STATEMENT]
lemma gcollapse_alt:
    "gcollapse v APDPE = (
      let
        (a,p,D,pE)=APDPE;
        i=idx_of p v;
        s=collapse v (p,D,pE);
        us=\<Union>(set (drop i a));
        a = take i a @ [us]
      in (a,s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcollapse v APDPE = (let (a, p, D, pE) = APDPE; i = idx_of p v; s = collapse v (p, D, pE); us = \<Union> (set (drop i a)); a = take i a @ [us] in (a, s))
[PROOF STEP]
unfolding gcollapse_def gcollapse_aux_def collapse_def collapse_aux_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let (a, p, D, pE) = APDPE; i = idx_of p v; (a, p) = (take i a @ [\<Union> (set (drop i a))], take i p @ [\<Union> (set (drop i p))]) in (a, p, D, pE)) = (let (a, p, D, pE) = APDPE; i = idx_of p v; s = let (p, D, pE) = (p, D, pE); i = idx_of p v; p = take i p @ [\<Union> (set (drop i p))] in (p, D, pE); us = \<Union> (set (drop i a)); a = take i a @ [us] in (a, s))
[PROOF STEP]
by auto


[STATEMENT]
lemma all2_lemma [simp]:
  "rec_eval (rec_all2 f) [x, y1, y2] = (if (\<forall>z \<le> x. 0 < rec_eval f [z, y1, y2]) then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rec_eval (rec_all2 f) [x, y1, y2] = (if \<forall>z\<le>x. 0 < rec_eval f [z, y1, y2] then 1 else 0)
[PROOF STEP]
by (simp add: rec_all2_def)


[STATEMENT]
lemma count_buildup: "cnt (vebt_buildup n) \<le> 2 * 2^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnt (vebt_buildup n) \<le> 2 * 2 ^ n
[PROOF STEP]
by (smt (verit, ccfv_threshold) VEBT_internal.cnt_bound' add.right_neutral add_less_mono buildup_gives_valid cnt.simps(1) even_Suc lessI odd_pos one_le_power plus_1_eq_Suc vebt_buildup.elims)


[STATEMENT]
lemma pmf_of_set_permutations_of_multiset_nonempty:
  assumes "(A :: 'a multiset) \<noteq> {#}"
  shows "pmf_of_set (permutations_of_multiset A) =
           do {x \<leftarrow> pmf_of_multiset A;
               xs \<leftarrow> pmf_of_set (permutations_of_multiset (A - {#x#}));
               return_pmf (x#xs)
              }" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set (permutations_of_multiset A) = pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))
[PROOF STEP]
proof (rule pmf_eqI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. pmf (pmf_of_set (permutations_of_multiset A)) i = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) i
[PROOF STEP]
fix xs :: "'a list"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. pmf (pmf_of_set (permutations_of_multiset A)) i = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) i
[PROOF STEP]
show "pmf ?lhs xs = pmf ?rhs xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
proof (cases "xs \<in> permutations_of_multiset A")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
 2. xs \<notin> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
xs \<notin> permutations_of_multiset A

goal (2 subgoals):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
 2. xs \<notin> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {#}
xs \<notin> permutations_of_multiset A
[PROOF STEP]
have "xs \<notin> set_pmf ?lhs"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}
xs \<notin> permutations_of_multiset A

goal (1 subgoal):
 1. xs \<notin> set_pmf (pmf_of_set (permutations_of_multiset A))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
xs \<notin> set_pmf (pmf_of_set (permutations_of_multiset A))

goal (2 subgoals):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
 2. xs \<notin> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
xs \<notin> set_pmf (pmf_of_set (permutations_of_multiset A))

goal (2 subgoals):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
 2. xs \<notin> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
from assms False
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {#}
xs \<notin> permutations_of_multiset A
[PROOF STEP]
have "xs \<notin> set_pmf ?rhs"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}
xs \<notin> permutations_of_multiset A

goal (1 subgoal):
 1. xs \<notin> set_pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs))))
[PROOF STEP]
by (auto simp: permutations_of_multiset_Cons_iff)
[PROOF STATE]
proof (state)
this:
xs \<notin> set_pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs))))

goal (2 subgoals):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
 2. xs \<notin> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
xs \<notin> set_pmf (pmf_of_set (permutations_of_multiset A))
xs \<notin> set_pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
xs \<notin> set_pmf (pmf_of_set (permutations_of_multiset A))
xs \<notin> set_pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs))))

goal (1 subgoal):
 1. pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
by (simp add: set_pmf_eq)
[PROOF STATE]
proof (state)
this:
pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
xs \<in> permutations_of_multiset A

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {#}
xs \<in> permutations_of_multiset A
[PROOF STEP]
have nonempty: "xs \<noteq> []"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}
xs \<in> permutations_of_multiset A

goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
by (auto dest: permutations_of_multisetD)
[PROOF STATE]
proof (state)
this:
xs \<noteq> []

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
hence range_Cons: "xs \<in> range ((#) x) \<longleftrightarrow> hd xs = x" for x
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []

goal (1 subgoal):
 1. (xs \<in> range ((#) x)) = (hd xs = x)
[PROOF STEP]
by (cases xs) auto
[PROOF STATE]
proof (state)
this:
(xs \<in> range ((#) ?x)) = (hd xs = ?x)

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
from True nonempty
[PROOF STATE]
proof (chain)
picking this:
xs \<in> permutations_of_multiset A
xs \<noteq> []
[PROOF STEP]
have hd_tl: "hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})"
[PROOF STATE]
proof (prove)
using this:
xs \<in> permutations_of_multiset A
xs \<noteq> []

goal (1 subgoal):
 1. hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})
[PROOF STEP]
by (cases xs) (auto simp: permutations_of_multiset_Cons_iff)
[PROOF STATE]
proof (state)
this:
hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {#}
[PROOF STEP]
have "pmf ?rhs xs =
      (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x)
        (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) / real (size A)" (is "_ = ?S / _")
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}

goal (1 subgoal):
 1. pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs = (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) / real (size A)
[PROOF STEP]
unfolding map_pmf_def [symmetric]
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}

goal (1 subgoal):
 1. pmf (pmf_of_multiset A \<bind> (\<lambda>x. map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#}))))) xs = (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) / real (size A)
[PROOF STEP]
by (simp add: pmf_bind_pmf_of_multiset)
[PROOF STATE]
proof (state)
this:
pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs = (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) / real (size A)

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs = (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) / real (size A)

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
have "?S =
      (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) /
         real (card (permutations_of_multiset (A - {#hd xs#}))) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) = (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0)
[PROOF STEP]
using range_Cons hd_tl
[PROOF STATE]
proof (prove)
using this:
(xs \<in> range ((#) ?x)) = (hd xs = ?x)
hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})

goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) = (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0)
[PROOF STEP]
by (intro sum.cong refl, subst pmf_map_inj_inv[where f' = tl]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) = (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0)

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. real (count A x) * pmf (map_pmf ((#) x) (pmf_of_set (permutations_of_multiset (A - {#x#})))) xs) = (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0)

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
have "\<dots> = real (count A (hd xs)) /
                      real (card (permutations_of_multiset (A - {#hd xs#})))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0) = real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#})))
[PROOF STEP]
using hd_tl
[PROOF STATE]
proof (prove)
using this:
hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})

goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0) = real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#})))
[PROOF STEP]
by (simp add: sum.delta)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0) = real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#})))

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. if x = hd xs then real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) else 0) = real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#})))

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
from hd_tl
[PROOF STATE]
proof (chain)
picking this:
hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})
[PROOF STEP]
have "\<dots> = real (size A) / real (card (permutations_of_multiset A))"
[PROOF STATE]
proof (prove)
using this:
hd xs \<in># A \<and> tl xs \<in> permutations_of_multiset (A - {#hd xs#})

goal (1 subgoal):
 1. real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) = real (size A) / real (card (permutations_of_multiset A))
[PROOF STEP]
by (simp add: divide_simps real_card_permutations_of_multiset_remove[of "hd xs"])
[PROOF STATE]
proof (state)
this:
real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) = real (size A) / real (card (permutations_of_multiset A))

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (count A (hd xs)) / real (card (permutations_of_multiset (A - {#hd xs#}))) = real (size A) / real (card (permutations_of_multiset A))

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
have " \<dots> / real (size A) = pmf (pmf_of_set (permutations_of_multiset A)) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (size A) / real (card (permutations_of_multiset A)) / real (size A) = pmf (pmf_of_set (permutations_of_multiset A)) xs
[PROOF STEP]
using assms True
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}
xs \<in> permutations_of_multiset A

goal (1 subgoal):
 1. real (size A) / real (card (permutations_of_multiset A)) / real (size A) = pmf (pmf_of_set (permutations_of_multiset A)) xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (size A) / real (card (permutations_of_multiset A)) / real (size A) = pmf (pmf_of_set (permutations_of_multiset A)) xs

goal (1 subgoal):
 1. xs \<in> permutations_of_multiset A \<Longrightarrow> pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs = pmf (pmf_of_set (permutations_of_multiset A)) xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs = pmf (pmf_of_set (permutations_of_multiset A)) xs

goal (1 subgoal):
 1. pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
pmf (pmf_of_set (permutations_of_multiset A)) xs = pmf (pmf_of_multiset A \<bind> (\<lambda>x. pmf_of_set (permutations_of_multiset (A - {#x#})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closedin_Times:
  "closedin (top_of_set S) S' \<Longrightarrow> closedin (top_of_set T) T' \<Longrightarrow>
    closedin (top_of_set (S \<times> T)) (S' \<times> T')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closedin (top_of_set S) S'; closedin (top_of_set T) T'\<rbrakk> \<Longrightarrow> closedin (top_of_set (S \<times> T)) (S' \<times> T')
[PROOF STEP]
unfolding closedin_closed
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>T. closed T \<and> S' = S \<inter> T; \<exists>Ta. closed Ta \<and> T' = T \<inter> Ta\<rbrakk> \<Longrightarrow> \<exists>Ta. closed Ta \<and> S' \<times> T' = S \<times> T \<inter> Ta
[PROOF STEP]
using closed_Times
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>closed ?S; closed ?T\<rbrakk> \<Longrightarrow> closed (?S \<times> ?T)

goal (1 subgoal):
 1. \<lbrakk>\<exists>T. closed T \<and> S' = S \<inter> T; \<exists>Ta. closed Ta \<and> T' = T \<inter> Ta\<rbrakk> \<Longrightarrow> \<exists>Ta. closed Ta \<and> S' \<times> T' = S \<times> T \<inter> Ta
[PROOF STEP]
by blast


[STATEMENT]
theorem c_out_eq_c_list:
  fixes f cf t
  defines "xs \<equiv> revorder t"
  defines "h \<equiv> (\<lambda>a. ldeep_s f xs a * cf a)"
  assumes "distinct_relations t"
      and "reasonable_cards cf f t"
      and "left_deep t"
  shows "c_list (ldeep_s f xs) cf h (first_node t) xs = c_out cf f t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_list (ldeep_s f xs) cf h (first_node t) xs = c_out cf f t
[PROOF STEP]
using c_IKKBZ_eq_c_list_cout c_out_IKKBZ assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>distinct_relations ?t; reasonable_cards ?cf ?f ?t; left_deep ?t\<rbrakk> \<Longrightarrow> c_IKKBZ (\<lambda>a. (*) (ldeep_s ?f (revorder ?t) a)) ?cf ?f ?t = c_list (ldeep_s ?f (revorder ?t)) ?cf (\<lambda>a. ldeep_s ?f (revorder ?t) a * ?cf a) (first_node ?t) (revorder ?t)
\<lbrakk>distinct_relations ?t; reasonable_cards ?cf ?f ?t; left_deep ?t\<rbrakk> \<Longrightarrow> c_IKKBZ (\<lambda>a. (*) (ldeep_s ?f (revorder ?t) a)) ?cf ?f ?t = c_out ?cf ?f ?t
xs \<equiv> revorder t
h \<equiv> \<lambda>a. ldeep_s f xs a * cf a
distinct_relations t
reasonable_cards cf f t
left_deep t

goal (1 subgoal):
 1. c_list (ldeep_s f xs) cf h (first_node t) xs = c_out cf f t
[PROOF STEP]
by fastforce


[STATEMENT]
lemma Vset_mono: "\<lbrakk>Ord m; n \<le> m\<rbrakk> \<Longrightarrow> Vset n \<le> Vset m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ord m; n \<le> m\<rbrakk> \<Longrightarrow> Vset n \<le> Vset m
[PROOF STEP]
by (metis Ord_linear2 Vset_mono_strict Vset_non order.order_iff_strict
            order_class.order.antisym zero_le)


[STATEMENT]
lemma pow_sum: "(divide::nat \<Rightarrow> nat \<Rightarrow> nat) ((2::nat) ^((a::nat)+(b::nat))) (2^a) = 2^b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ (a + b) div 2 ^ a = 2 ^ b
[PROOF STEP]
by (induction a) simp+


[STATEMENT]
lemma F1set1_bd: "|F1set1 x| <o bd_F1 +c bd_F2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |F1set1 x| <o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLess_ordLeq_trans)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. |F1set1 x| <o ?r'
 2. ?r' \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule F1.set_bd(1))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bd_F1 \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLeq_csum1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Card_order bd_F1
[PROOF STEP]
apply (rule F1.bd_Card_order)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma suc_n_le_2_pow_n:
  fixes n :: nat
  shows "n + 1 \<le> 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n + 1 \<le> 2 ^ n
[PROOF STEP]
by (induction n, simp, simp)


[STATEMENT]
lemma vector_derivative_within_cbox:
  assumes ab: "a < b" "x \<in> cbox a b"
  assumes f: "(f has_vector_derivative f') (at x within cbox a b)"
  shows "vector_derivative f (at x within cbox a b) = f'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative f (at x within cbox a b) = f'
[PROOF STEP]
by (intro vector_derivative_unique_within_closed_interval[OF ab _ f]
            vector_derivative_works[THEN iffD1] differentiableI_vector)
     fact


[STATEMENT]
lemma UNIV_eq: \<open>(UNIV :: 'a word set) = word_of_int ` {0..<2 ^ LENGTH('a::len)}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = word_of_int ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
by (auto simp add: image_iff) (metis atLeastLessThan_iff linorder_not_le uint_split)


[STATEMENT]
lemma ordinal_times_div_le: "y * (x div y) \<le> (x::ordinal)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y * (x div y) \<le> x
[PROOF STEP]
apply (simp add: div_ordinal_def, safe)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < y \<Longrightarrow> y * oInv ((*) y) x \<le> x
[PROOF STEP]
apply (erule normal.oInv_bound1[OF normal_times])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y * 0 \<le> x
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sqrt_upper_bound_2_small:
  assumes "0 \<le> x"
    shows "sqrt x \<le> (1/32)*(65536*x^4 + 114688*x^3 + 17920*x^2 + 448*x + 1) / ((16*x + 1)*(256*x^2 + 96*x + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt x \<le> 1 / 32 * (65536 * x ^ 4 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) / ((16 * x + 1) * (256 * x\<^sup>2 + 96 * x + 1))
[PROOF STEP]
apply (rule order_trans [OF gen_sqrt_upper_scaled [of x 4 2] eq_refl])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. 0 \<le> x
 2. 0 < 4
 3. sqrtu (x * 4\<^sup>2) 2 / 4 = 1 / 32 * (65536 * x ^ 4 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) / ((16 * x + 1) * (256 * x\<^sup>2 + 96 * x + 1))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> x

goal (3 subgoals):
 1. 0 \<le> x
 2. 0 < 4
 3. sqrtu (x * 4\<^sup>2) 2 / 4 = 1 / 32 * (65536 * x ^ 4 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) / ((16 * x + 1) * (256 * x\<^sup>2 + 96 * x + 1))
[PROOF STEP]
apply (auto simp: sqrtu_2_eq )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> (x ^ 4 * 65536 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) / (32 * ((x * 16 + 1) * (x\<^sup>2 * 256 + 96 * x + 1))) = (65536 * x ^ 4 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) / (32 * ((16 * x + 1) * (256 * x\<^sup>2 + 96 * x + 1)))
[PROOF STEP]
apply (simp add: divide_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> 256 * x\<^sup>2 + 96 * x + 1 \<noteq> 0 \<longrightarrow> (x ^ 4 * 65536 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) * ((16 * x + 1) * (256 * x\<^sup>2 + 96 * x + 1)) = (65536 * x ^ 4 + 114688 * x ^ 3 + 17920 * x\<^sup>2 + 448 * x + 1) * ((x * 16 + 1) * (x\<^sup>2 * 256 + 96 * x + 1))
[PROOF STEP]
apply algebra
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma symmetry_lemma:
  assumes "\<And>a b c d. P a b c d \<Longrightarrow> P a b d c"
    and "\<And>a b c d. a \<noteq> b \<Longrightarrow> c \<noteq> d \<Longrightarrow>
      a = c \<and> b = d \<or> a = c \<and> b \<noteq> d \<or> a \<noteq> c \<and> b = d \<or> a \<noteq> c \<and> a \<noteq> d \<and> b \<noteq> c \<and> b \<noteq> d \<Longrightarrow>
      P a b c d"
  shows "\<And>a b c d. a \<noteq> b \<longrightarrow> c \<noteq> d \<longrightarrow>  P a b c d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b c d. a \<noteq> b \<longrightarrow> c \<noteq> d \<longrightarrow> P a b c d
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P ?a ?b ?c ?d \<Longrightarrow> P ?a ?b ?d ?c
\<lbrakk>?a \<noteq> ?b; ?c \<noteq> ?d; ?a = ?c \<and> ?b = ?d \<or> ?a = ?c \<and> ?b \<noteq> ?d \<or> ?a \<noteq> ?c \<and> ?b = ?d \<or> ?a \<noteq> ?c \<and> ?a \<noteq> ?d \<and> ?b \<noteq> ?c \<and> ?b \<noteq> ?d\<rbrakk> \<Longrightarrow> P ?a ?b ?c ?d

goal (1 subgoal):
 1. \<And>a b c d. a \<noteq> b \<longrightarrow> c \<noteq> d \<longrightarrow> P a b c d
[PROOF STEP]
by metis


[STATEMENT]
lemma AllowedActs_project [simp]:
     "AllowedActs(project h C F) =
        {act. Restrict (project_set h C) act
               \<in> project_act h ` Restrict C ` AllowedActs F}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AllowedActs (project h C F) = {act. Restrict (project_set h C) act \<in> project_act h ` Restrict C ` AllowedActs F}
[PROOF STEP]
apply (simp (no_asm) add: project_def image_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insert Id {act. \<exists>x\<in>AllowedActs F. Restrict (project_set h C) act = project_act h (Restrict C x)} = {act. \<exists>x\<in>AllowedActs F. Restrict (project_set h C) act = project_act h (Restrict C x)}
[PROOF STEP]
apply (subst insert_absorb)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. Id \<in> {act. \<exists>x\<in>AllowedActs F. Restrict (project_set h C) act = project_act h (Restrict C x)}
 2. {act. \<exists>x\<in>AllowedActs F. Restrict (project_set h C) act = project_act h (Restrict C x)} = {act. \<exists>x\<in>AllowedActs F. Restrict (project_set h C) act = project_act h (Restrict C x)}
[PROOF STEP]
apply (auto intro!: bexI [of _ Id] simp add: project_act_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mod_eq:
 "(m::int) mod n = (m + (-1)*n) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m mod n = (m + - 1 * n) mod n
[PROOF STEP]
using mod_mult_self1
[PROOF STATE]
proof (prove)
using this:
(?a + ?c * ?b) mod ?b = ?a mod ?b

goal (1 subgoal):
 1. m mod n = (m + - 1 * n) mod n
[PROOF STEP]
by metis


[STATEMENT]
lemma projection_on_orthogonal_complement[simp]:
  fixes M :: "'a::chilbert_space set"
  assumes a1: "closed_csubspace M"
  shows "projection (orthogonal_complement M) = id - projection M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. projection (orthogonal_complement M) = id - projection M
[PROOF STEP]
apply (auto intro!: ext)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. projection (orthogonal_complement M) x = x - projection M x
[PROOF STEP]
by (smt (verit, ccfv_SIG) add_diff_cancel_left' assms closed_csubspace.closed closed_csubspace.subspace complex_vector.subspace_0 csubspace_is_convex diff_add_cancel double_orthogonal_complement_increasing insert_absorb insert_not_empty is_projection_on_iff_orthog orthogonal_complement_closed_subspace projection_eqI projection_is_projection_on subset_eq)


[STATEMENT]
lemma sq_mtx_transpose_transpose[simp]: "(A\<^sup>\<dagger>)\<^sup>\<dagger> = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A\<^sup>\<dagger>\<^sup>\<dagger> = A
[PROOF STEP]
by (transfer, simp)


[STATEMENT]
lemma fps_divide_shift_numer:
  fixes   f g :: "'a::{inverse,comm_monoid_add,uminus,mult_zero} fps"
  assumes "n \<le> subdegree f"
  shows   "fps_shift n f / g = fps_shift n (f/g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_shift n f / g = fps_shift n (f / g)
[PROOF STEP]
using   assms fps_shift_mult_right_noncomm[of n f "inverse (unit_factor g)"]
          fps_shift_fps_shift_reorder[of "subdegree g" n "f * inverse (unit_factor g)"]
[PROOF STATE]
proof (prove)
using this:
n \<le> subdegree f
n \<le> subdegree f \<Longrightarrow> fps_shift n (f * inverse (unit_factor g)) = fps_shift n f * inverse (unit_factor g)
fps_shift (subdegree g) (fps_shift n (f * inverse (unit_factor g))) = fps_shift n (fps_shift (subdegree g) (f * inverse (unit_factor g)))

goal (1 subgoal):
 1. fps_shift n f / g = fps_shift n (f / g)
[PROOF STEP]
by      (simp add: fps_divide_def)


[STATEMENT]
lemma Ints_sum: "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> \<int>) \<Longrightarrow> sum f A \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> A \<Longrightarrow> f x \<in> \<int>) \<Longrightarrow> sum f A \<in> \<int>
[PROOF STEP]
by (induction A rule: infinite_finite_induct) auto


[STATEMENT]
lemma foldl_ins_set_tree:
  assumes "inj_on fst (set ys)" "inj_on snd (set ys)" "distinct ys" "fst ` (set ys) \<inter> keys t = {}"
  shows "set_tree (foldl (\<lambda>t' (x, p). ins x p t') t ys) = set ys \<union> set_tree t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_tree (foldl (\<lambda>t' (x, p). ins x p t') t ys) = set ys \<union> set_tree t
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inj_on fst (set ys)
inj_on snd (set ys)
distinct ys
fst ` set ys \<inter> keys t = {}

goal (1 subgoal):
 1. set_tree (foldl (\<lambda>t' (x, p). ins x p t') t ys) = set ys \<union> set_tree t
[PROOF STEP]
by (induction ys arbitrary: t) (auto simp add: case_prod_beta' set_tree_ins_eq keys_ins)


[STATEMENT]
lemma lead_monom_sym_mpoly_prod:
  assumes "finite A"
  shows   "lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i :: 'a mpoly) =
             (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i :: 'a mpoly))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
have "(\<Prod>i=1..n. lead_coeff (sym_mpoly A i ^ h i :: 'a mpoly)) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = (1::'a)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. (\<Prod>i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = (1::'a)
[PROOF STEP]
unfolding n_def
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. (\<Prod>i = 1..card A. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = (1::'a)
[PROOF STEP]
by (intro prod.neutral allI) (auto simp: lead_coeff_power)
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = (1::'a)

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
hence "lead_monom (\<Prod>i=1..n. sym_mpoly A i ^ h i :: 'a mpoly) =
           (\<Sum>i=1..n. lead_monom (sym_mpoly A i ^ h i :: 'a mpoly))"
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = (1::'a)

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. lead_monom (sym_mpoly A i ^ h i))
[PROOF STEP]
by (subst lead_monom_prod) auto
[PROOF STATE]
proof (state)
this:
lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. lead_monom (sym_mpoly A i ^ h i))

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. lead_monom (sym_mpoly A i ^ h i))

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
have "\<dots> = (\<Sum>i=1..n. of_nat (h i) * lead_monom (sym_mpoly A i :: 'a mpoly))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 1..n. lead_monom (sym_mpoly A i ^ h i)) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
by (intro sum.cong refl, subst lead_monom_power)
       (auto simp: lead_coeff_power assms n_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 1..n. lead_monom (sym_mpoly A i ^ h i)) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))

goal (1 subgoal):
 1. lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
lead_monom (\<Prod>i = 1..n. sym_mpoly A i ^ h i) = (\<Sum>i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "((\<exists>x. p(x)) = (\<exists>x. q(x))) \<and>
      (\<forall>x. \<forall>y. p(x) \<and> q(y) \<longrightarrow> (r(x) = s(y)))
  \<longrightarrow> ((\<forall>x. p(x)\<longrightarrow>r(x)) = (\<forall>x. q(x)\<longrightarrow>s(x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x. p x) = (\<exists>x. q x) \<and> (\<forall>x y. p x \<and> q y \<longrightarrow> r x = s y) \<longrightarrow> (\<forall>x. p x \<longrightarrow> r x) = (\<forall>x. q x \<longrightarrow> s x)
[PROOF STEP]
by blast


[STATEMENT]
lemma size_merge: "size(merge t1 t2) = size t1 + size t2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (merge t1 t2) = size t1 + size t2
[PROOF STEP]
by(induction t1 t2 rule: merge.induct) auto


[STATEMENT]
lemma square_subtract:"(((p::rat_poly) - (q::rat_poly))^2)
         = (p^2) - (2*p*q) + (q^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
have 1:"(((p::rat_poly) - (q::rat_poly))^2)
             = (p- q)*(p - q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_times (p - q) (p - q)
[PROOF STEP]
by (metis power2_eq_square)
[PROOF STATE]
proof (state)
this:
(p - q)\<^sup>2 = rat_poly_times (p - q) (p - q)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(p - q)\<^sup>2 = rat_poly_times (p - q) (p - q)
[PROOF STEP]
have "(p - q)*(p - q) = (p - q)*p - (p - q)*q"
[PROOF STATE]
proof (prove)
using this:
(p - q)\<^sup>2 = rat_poly_times (p - q) (p - q)

goal (1 subgoal):
 1. rat_poly_times (p - q) (p - q) = rat_poly_times (p - q) p - rat_poly_times (p - q) q
[PROOF STEP]
by (metis minus_right_distributivity rat_poly.comm)
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) (p - q) = rat_poly_times (p - q) p - rat_poly_times (p - q) q

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) (p - q) = rat_poly_times (p - q) p - rat_poly_times (p - q) q

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
have "(p - q)*p = p*p - q*p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_poly_times (p - q) p = rat_poly_times p p - rat_poly_times q p
[PROOF STEP]
by (metis minus_left_distributivity rat_poly.comm)
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) p = rat_poly_times p p - rat_poly_times q p

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) p = rat_poly_times p p - rat_poly_times q p

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
have "(p - q)*q = p*q - q*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_poly_times (p - q) q = rat_poly_times p q - rat_poly_times q q
[PROOF STEP]
by (metis minus_left_distributivity rat_poly.comm)
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) q = rat_poly_times p q - rat_poly_times q q

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
rat_poly_times (p - q) (p - q) = rat_poly_times (p - q) p - rat_poly_times (p - q) q
rat_poly_times (p - q) p = rat_poly_times p p - rat_poly_times q p
rat_poly_times (p - q) q = rat_poly_times p q - rat_poly_times q q
[PROOF STEP]
have "(p - q)*(p - q) = p*p - q*p - (p*q - q*q)"
[PROOF STATE]
proof (prove)
using this:
rat_poly_times (p - q) (p - q) = rat_poly_times (p - q) p - rat_poly_times (p - q) q
rat_poly_times (p - q) p = rat_poly_times p p - rat_poly_times q p
rat_poly_times (p - q) q = rat_poly_times p q - rat_poly_times q q

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

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rat_poly_times (p - q) (p - q) = rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
have "... = (p*p) - q*p - p*q + q*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
have "... = (p^2) -p*q - p*q + (q^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)
[PROOF STEP]
using power2_eq_square
[PROOF STATE]
proof (prove)
using this:
?a\<^sup>2 = ?a * ?a

goal (1 subgoal):
 1. rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
rat_poly_times (p - q) (p - q) = rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q)
rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)
rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rat_poly_times (p - q) (p - q) = rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q)
rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)
rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
rat_poly_times (p - q) (p - q) = rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q)
rat_poly_times p p - rat_poly_times q p - (rat_poly_times p q - rat_poly_times q q) = rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q)
rat_poly_plus (rat_poly_times p p - rat_poly_times q p - rat_poly_times p q) (rat_poly_times q q) = rat_poly_plus (p\<^sup>2 - rat_poly_times p q - rat_poly_times p q) (q\<^sup>2)
(p - q)\<^sup>2 = rat_poly_times (p - q) (p - q)

goal (1 subgoal):
 1. (p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(p - q)\<^sup>2 = rat_poly_plus (p\<^sup>2 - rat_poly_times (rat_poly_times 2 p) q) (q\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))"
  for x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
obtain y where low: "- (pi/2) < y" and high: "y < pi/2" and y_eq: "tan y = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>y. \<lbrakk>- (pi / 2) < y; y < pi / 2; tan y = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using tan_total
[PROOF STATE]
proof (prove)
using this:
\<exists>!x. - (pi / 2) < x \<and> x < pi / 2 \<and> tan x = ?y

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>- (pi / 2) < y; y < pi / 2; tan y = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
- (pi / 2) < y
y < pi / 2
tan y = x

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
- (pi / 2) < y
y < pi / 2
tan y = x
[PROOF STEP]
have low2: "- (pi/2) < y / 2" and high2: "y / 2 < pi/2"
[PROOF STATE]
proof (prove)
using this:
- (pi / 2) < y
y < pi / 2
tan y = x

goal (1 subgoal):
 1. - (pi / 2) < y / 2 &&& y / 2 < pi / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- (pi / 2) < y / 2
y / 2 < pi / 2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "0 < cos y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < cos y
[PROOF STEP]
by (rule cos_gt_zero_pi[OF low high])
[PROOF STATE]
proof (state)
this:
0 < cos y

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < cos y
[PROOF STEP]
have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y"
[PROOF STATE]
proof (prove)
using this:
0 < cos y

goal (1 subgoal):
 1. cos y \<noteq> 0 &&& sqrt ((cos y)\<^sup>2) = cos y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cos y \<noteq> 0
sqrt ((cos y)\<^sup>2) = cos y

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2
[PROOF STEP]
unfolding tan_def power_divide
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2
[PROOF STEP]
using \<open>cos y \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
cos y \<noteq> 0

goal (1 subgoal):
 1. 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = 1 / (cos y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = 1 / (cos y)\<^sup>2
[PROOF STEP]
unfolding add_divide_distrib[symmetric] sin_cos_squared_add2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / (cos y)\<^sup>2 = 1 / (cos y)\<^sup>2
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2 = 1 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2
[PROOF STEP]
have "1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2

goal (1 subgoal):
 1. 1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)
[PROOF STEP]
unfolding tan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin y / (cos y + 1) = sin y / cos y / ((cos y + 1) / cos y)
[PROOF STEP]
using \<open>cos y \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
cos y \<noteq> 0

goal (1 subgoal):
 1. sin y / (cos y + 1) = sin y / cos y / ((cos y + 1) / cos y)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = tan y / (1 + 1 / cos y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan y / ((cos y + 1) / cos y) = tan y / (1 + 1 / cos y)
[PROOF STEP]
using \<open>cos y \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
cos y \<noteq> 0

goal (1 subgoal):
 1. tan y / ((cos y + 1) / cos y) = tan y / (1 + 1 / cos y)
[PROOF STEP]
unfolding add_divide_distrib
[PROOF STATE]
proof (prove)
using this:
cos y \<noteq> 0

goal (1 subgoal):
 1. tan y / (cos y / cos y + 1 / cos y) = tan y / (1 + 1 / cos y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tan y / ((cos y + 1) / cos y) = tan y / (1 + 1 / cos y)

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
tan y / ((cos y + 1) / cos y) = tan y / (1 + 1 / cos y)

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan y / (1 + 1 / cos y) = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))
[PROOF STEP]
unfolding cos_sqrt
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan y / (1 + 1 / cos y) = tan y / (1 + 1 / cos y)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
tan y / (1 + 1 / cos y) = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
tan y / (1 + 1 / cos y) = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan y / (1 + 1 / sqrt ((cos y)\<^sup>2)) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))
[PROOF STEP]
unfolding real_sqrt_divide
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan y / (1 + 1 / sqrt ((cos y)\<^sup>2)) = tan y / (1 + sqrt 1 / sqrt ((cos y)\<^sup>2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tan y / (1 + 1 / sqrt ((cos y)\<^sup>2)) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sin y / (cos y + 1) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))
[PROOF STEP]
have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))"
[PROOF STATE]
proof (prove)
using this:
sin y / (cos y + 1) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))

goal (1 subgoal):
 1. sin y / (cos y + 1) = tan y / (1 + sqrt (1 + (tan y)\<^sup>2))
[PROOF STEP]
unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close>
[PROOF STATE]
proof (prove)
using this:
sin y / (cos y + 1) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))

goal (1 subgoal):
 1. sin y / (cos y + 1) = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sin y / (cos y + 1) = tan y / (1 + sqrt (1 + (tan y)\<^sup>2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "arctan x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arctan x = y
[PROOF STEP]
using arctan_tan low high y_eq
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>- (pi / 2) < ?x; ?x < pi / 2\<rbrakk> \<Longrightarrow> arctan (tan ?x) = ?x
- (pi / 2) < y
y < pi / 2
tan y = x

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

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
arctan x = y

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = 2 * (arctan (tan (y/2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y = 2 * arctan (tan (y / 2))
[PROOF STEP]
using arctan_tan[OF low2 high2]
[PROOF STATE]
proof (prove)
using this:
arctan (tan (y / 2)) = y / 2

goal (1 subgoal):
 1. y = 2 * arctan (tan (y / 2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y = 2 * arctan (tan (y / 2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
y = 2 * arctan (tan (y / 2))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * arctan (tan (y / 2)) = 2 * arctan (sin y / (cos y + 1))
[PROOF STEP]
unfolding tan_half
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * arctan (sin (2 * (y / 2)) / (cos (2 * (y / 2)) + 1)) = 2 * arctan (sin y / (cos y + 1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 * arctan (tan (y / 2)) = 2 * arctan (sin y / (cos y + 1))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
arctan x = 2 * arctan (sin y / (cos y + 1))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
arctan x = 2 * arctan (sin y / (cos y + 1))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
unfolding eq \<open>tan y = x\<close>
[PROOF STATE]
proof (prove)
using this:
arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))

goal (1 subgoal):
 1. arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
arctan x = 2 * arctan (x / (1 + sqrt (1 + x\<^sup>2)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_cvec_gt_0:
  assumes "z \<noteq> vec_zero"
  shows "\<langle>z\<rangle> > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < \<langle>z\<rangle>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
z \<noteq> vec_zero

goal (1 subgoal):
 1. 0 < \<langle>z\<rangle>
[PROOF STEP]
by (simp del: inprod_cvec_def)


[STATEMENT]
lemma d_cospoly_sinpoly:
    "(cospoly (Suc n) has_field_derivative -sinpoly n x) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x)
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (cospoly (Suc 0) has_real_derivative - sinpoly 0 x) (at x)
 2. \<And>n. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x) \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (cospoly (Suc 0) has_real_derivative - sinpoly 0 x) (at x)
 2. \<And>n. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x) \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cospoly (Suc 0) has_real_derivative - sinpoly 0 x) (at x)
[PROOF STEP]
by (simp add: sinpoly_def cospoly_def)
[PROOF STATE]
proof (state)
this:
(cospoly (Suc 0) has_real_derivative - sinpoly 0 x) (at x)

goal (1 subgoal):
 1. \<And>n. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x) \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x) \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
(cospoly (Suc n) has_real_derivative - sinpoly n x) (at x)

goal (1 subgoal):
 1. \<And>n. (cospoly (Suc n) has_real_derivative - sinpoly n x) (at x) \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
proof (cases "n=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
 2. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
 2. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
by (simp add: sinpoly_def cospoly_def cos_coeff_def)
[PROOF STATE]
proof (state)
this:
(cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
[PROOF STEP]
have xn: "x ^ (n - Suc 0) * x = x ^ n"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. x ^ (n - Suc 0) * x = x ^ n
[PROOF STEP]
by (metis Suc_pred mult.commute not_gr0 power_Suc)
[PROOF STATE]
proof (state)
this:
x ^ (n - Suc 0) * x = x ^ n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
have m1: "odd n \<Longrightarrow> (-1 :: real) ^ ((n - Suc 0) div 2) = - ((-1) ^ (Suc n div 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd n \<Longrightarrow> (- 1) ^ ((n - Suc 0) div 2) = - ((- 1) ^ (Suc n div 2))
[PROOF STEP]
by (cases n) simp_all
[PROOF STATE]
proof (state)
this:
odd n \<Longrightarrow> (- 1) ^ ((n - Suc 0) div 2) = - ((- 1) ^ (Suc n div 2))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
using Suc False
[PROOF STATE]
proof (prove)
using this:
(cospoly (Suc n) has_real_derivative - sinpoly n x) (at x)
n \<noteq> 0

goal (1 subgoal):
 1. (cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)
[PROOF STEP]
apply (simp add: cospoly_Suc [of "Suc n"] sinpoly_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(cospoly (Suc n) has_real_derivative - (\<Sum>k<n. sin_coeff k * x ^ k)) (at x); 0 < n\<rbrakk> \<Longrightarrow> ((\<lambda>a. cospoly (Suc n) a + cos_coeff (Suc n) * (a * a ^ n)) has_real_derivative - (\<Sum>k<n. sin_coeff k * x ^ k) - sin_coeff n * x ^ n) (at x)
[PROOF STEP]
apply (intro derivative_eq_intros | simp)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(cospoly (Suc n) has_real_derivative - (\<Sum>k<n. sin_coeff k * x ^ k)) (at x); 0 < n\<rbrakk> \<Longrightarrow> (x ^ n + real n * x ^ (n - Suc 0) * x) * cos_coeff (Suc n) = - (sin_coeff n * x ^ n)
[PROOF STEP]
apply (simp add: xn mult.assoc sin_coeff_def cos_coeff_def m1 divide_simps del: fact_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(cospoly (Suc n) has_real_derivative - (\<Sum>k<n. (if even k then 0 else (- 1) ^ ((k - Suc 0) div 2) / fact k) * x ^ k)) (at x); 0 < n\<rbrakk> \<Longrightarrow> odd n \<longrightarrow> (x ^ n + real n * x ^ n) * fact n = x ^ n * fact (Suc n)
[PROOF STEP]
apply (simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(cospoly (Suc (Suc n)) has_real_derivative - sinpoly (Suc n) x) (at x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma yun_erel_mult: "yun_erel F f \<Longrightarrow> yun_erel G g \<Longrightarrow> yun_erel (F * G) (f * g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>yun_erel F f; yun_erel G g\<rbrakk> \<Longrightarrow> yun_erel (F * G) (f * g)
[PROOF STEP]
unfolding yun_erel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>c. yun_rel F c f; \<exists>c. yun_rel G c g\<rbrakk> \<Longrightarrow> \<exists>c. yun_rel (F * G) c (f * g)
[PROOF STEP]
using yun_rel_mult[of F _ f G _ g]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>yun_rel F ?c f; yun_rel G ?d g\<rbrakk> \<Longrightarrow> yun_rel (F * G) (?c * ?d) (f * g)

goal (1 subgoal):
 1. \<lbrakk>\<exists>c. yun_rel F c f; \<exists>c. yun_rel G c g\<rbrakk> \<Longrightarrow> \<exists>c. yun_rel (F * G) c (f * g)
[PROOF STEP]
by blast


[STATEMENT]
lemma affine_hull_translation: "affine hull ((\<lambda>x. a + x) `  S) = (\<lambda>x. a + x) ` (affine hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
have "affine ((\<lambda>x. a + x) ` (affine hull S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine ((+) a ` (affine hull S))
[PROOF STEP]
using affine_translation affine_affine_hull
[PROOF STATE]
proof (prove)
using this:
affine ?S = affine ((+) ?a ` ?S)
affine (affine hull ?s)

goal (1 subgoal):
 1. affine ((+) a ` (affine hull S))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
affine ((+) a ` (affine hull S))

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
affine ((+) a ` (affine hull S))

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
have "(\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (+) a ` S \<subseteq> (+) a ` (affine hull S)
[PROOF STEP]
using hull_subset[of S]
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> ?S hull S

goal (1 subgoal):
 1. (+) a ` S \<subseteq> (+) a ` (affine hull S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(+) a ` S \<subseteq> (+) a ` (affine hull S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
affine ((+) a ` (affine hull S))
(+) a ` S \<subseteq> (+) a ` (affine hull S)
[PROOF STEP]
have h1: "affine hull ((\<lambda>x. a + x) `  S) \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
[PROOF STATE]
proof (prove)
using this:
affine ((+) a ` (affine hull S))
(+) a ` S \<subseteq> (+) a ` (affine hull S)

goal (1 subgoal):
 1. affine hull (+) a ` S \<subseteq> (+) a ` (affine hull S)
[PROOF STEP]
by (metis hull_minimal)
[PROOF STATE]
proof (state)
this:
affine hull (+) a ` S \<subseteq> (+) a ` (affine hull S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
have "affine((\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine ((+) (- a) ` (affine hull (+) a ` S))
[PROOF STEP]
using affine_translation affine_affine_hull
[PROOF STATE]
proof (prove)
using this:
affine ?S = affine ((+) ?a ` ?S)
affine (affine hull ?s)

goal (1 subgoal):
 1. affine ((+) (- a) ` (affine hull (+) a ` S))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
affine ((+) (- a) ` (affine hull (+) a ` S))

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
affine ((+) (- a) ` (affine hull (+) a ` S))

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
have "(\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
[PROOF STEP]
using hull_subset[of "(\<lambda>x. a + x) `  S"]
[PROOF STATE]
proof (prove)
using this:
(+) a ` S \<subseteq> ?S hull (+) a ` S

goal (1 subgoal):
 1. (+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
have "S = (\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S = (+) (- a) ` (+) a ` S
[PROOF STEP]
using translation_assoc[of "-a" a]
[PROOF STATE]
proof (prove)
using this:
(+) (- a) ` (+) a ` ?S = (+) (a + - a) ` ?S

goal (1 subgoal):
 1. S = (+) (- a) ` (+) a ` S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S = (+) (- a) ` (+) a ` S

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
affine ((+) (- a) ` (affine hull (+) a ` S))
(+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
S = (+) (- a) ` (+) a ` S
[PROOF STEP]
have "(\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)) >= (affine hull S)"
[PROOF STATE]
proof (prove)
using this:
affine ((+) (- a) ` (affine hull (+) a ` S))
(+) (- a) ` (+) a ` S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
S = (+) (- a) ` (+) a ` S

goal (1 subgoal):
 1. affine hull S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
[PROOF STEP]
by (metis hull_minimal)
[PROOF STATE]
proof (state)
this:
affine hull S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
affine hull S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)
[PROOF STEP]
have "affine hull ((\<lambda>x. a + x) ` S) >= (\<lambda>x. a + x) ` (affine hull S)"
[PROOF STATE]
proof (prove)
using this:
affine hull S \<subseteq> (+) (- a) ` (affine hull (+) a ` S)

goal (1 subgoal):
 1. (+) a ` (affine hull S) \<subseteq> affine hull (+) a ` S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(+) a ` (affine hull S) \<subseteq> affine hull (+) a ` S

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(+) a ` (affine hull S) \<subseteq> affine hull (+) a ` S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(+) a ` (affine hull S) \<subseteq> affine hull (+) a ` S

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
using h1
[PROOF STATE]
proof (prove)
using this:
(+) a ` (affine hull S) \<subseteq> affine hull (+) a ` S
affine hull (+) a ` S \<subseteq> (+) a ` (affine hull S)

goal (1 subgoal):
 1. affine hull (+) a ` S = (+) a ` (affine hull S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
affine hull (+) a ` S = (+) a ` (affine hull S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma \<theta>_upper_bound_coarse:
  assumes "x \<ge> 1"
  shows   "\<theta> x \<le> x * ln x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
have "\<theta> x \<le> sum_upto (\<lambda>_. ln x) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<theta> x \<le> sum_upto (\<lambda>_. ln x) x
[PROOF STEP]
unfolding \<theta>_def prime_sum_upto_altdef1 sum_upto_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p\<in>{i. 0 < i \<and> real i \<le> x}. ind prime p * ln (real p)) \<le> (\<Sum>_\<in>{i. 0 < i \<and> real i \<le> x}. ln x)
[PROOF STEP]
by (intro sum_mono) (auto simp: ind_def)
[PROOF STATE]
proof (state)
this:
\<theta> x \<le> sum_upto (\<lambda>_. ln x) x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<theta> x \<le> sum_upto (\<lambda>_. ln x) x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
have "\<dots> \<le> real_of_int \<lfloor>x\<rfloor> * ln x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_upto (\<lambda>_. ln x) x \<le> real_of_int \<lfloor>x\<rfloor> * ln x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> x

goal (1 subgoal):
 1. sum_upto (\<lambda>_. ln x) x \<le> real_of_int \<lfloor>x\<rfloor> * ln x
[PROOF STEP]
by (simp add: sum_upto_altdef)
[PROOF STATE]
proof (state)
this:
sum_upto (\<lambda>_. ln x) x \<le> real_of_int \<lfloor>x\<rfloor> * ln x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_upto (\<lambda>_. ln x) x \<le> real_of_int \<lfloor>x\<rfloor> * ln x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
have "\<dots> \<le> x * ln x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int \<lfloor>x\<rfloor> * ln x \<le> x * ln x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> x

goal (1 subgoal):
 1. real_of_int \<lfloor>x\<rfloor> * ln x \<le> x * ln x
[PROOF STEP]
by (intro mult_right_mono) auto
[PROOF STATE]
proof (state)
this:
real_of_int \<lfloor>x\<rfloor> * ln x \<le> x * ln x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<theta> x \<le> x * ln x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<theta> x \<le> x * ln x

goal (1 subgoal):
 1. \<theta> x \<le> x * ln x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<theta> x \<le> x * ln x

goal:
No subgoals!
[PROOF STEP]
qed