[STATEMENT]
lemma transpose_mat_mult_entries: "i < dim_row A \<Longrightarrow> j < dim_row A \<Longrightarrow>
    (A * A\<^sup>T) $$ (i, j) = (\<Sum>k\<in> {0..<(dim_col A)}. (A $$ (i, k)) * (A $$ (j, k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < dim_row A; j < dim_row A\<rbrakk> \<Longrightarrow> (A * A\<^sup>T) $$ (i, j) = (\<Sum>k = 0..<dim_col A. A $$ (i, k) * A $$ (j, k))
[PROOF STEP]
by (simp add: times_mat_def scalar_prod_def)


[STATEMENT]
lemma sum_add:
  assumes A: "finite A"
  and B: "finite B"
  shows "sum f A + sum g B = sum f (A - B) + sum g (B - A) + sum (\<lambda>x. f x + g x) (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
have 1: "sum f A = sum f (A - B) + sum f (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A = sum f (A - B) + sum f (A \<inter> B)
[PROOF STEP]
by (metis A Int_Diff_disjoint Un_Diff_Int finite_Diff finite_Int inf_sup_aci(1) local.sum.union_disjoint)
[PROOF STATE]
proof (state)
this:
sum f A = sum f (A - B) + sum f (A \<inter> B)

goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
have 2: "sum g B = sum g (B - A) + sum g (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum g B = sum g (B - A) + sum g (A \<inter> B)
[PROOF STEP]
by (metis B Int_Diff_disjoint Int_commute Un_Diff_Int finite_Diff finite_Int local.sum.union_disjoint)
[PROOF STATE]
proof (state)
this:
sum g B = sum g (B - A) + sum g (A \<inter> B)

goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
have 3: "sum f (A \<inter> B) + sum g (A \<inter> B) = sum (\<lambda>x. f x + g x) (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f (A \<inter> B) + sum g (A \<inter> B) = (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
by (simp add: sum.distrib)
[PROOF STATE]
proof (state)
this:
sum f (A \<inter> B) + sum g (A \<inter> B) = (\<Sum>x\<in>A \<inter> B. f x + g x)

goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)
[PROOF STEP]
by (simp add: "1" "2" "3" add.assoc add.left_commute)
[PROOF STATE]
proof (state)
this:
sum f A + sum g B = sum f (A - B) + sum g (B - A) + (\<Sum>x\<in>A \<inter> B. f x + g x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma path_component_imp_homotopic_points:
  assumes "path_component S a b"
  shows "homotopic_loops S (linepath a a) (linepath b b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_loops S (linepath a a) (linepath b b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. homotopic_loops S (linepath a a) (linepath b b)
[PROOF STEP]
obtain g :: "real \<Rightarrow> 'a" where g: "continuous_on {0..1} g" "g ` {0..1} \<subseteq> S" "g 0 = a" "g 1 = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<lbrakk>continuous_on {0..1} g; g ` {0..1} \<subseteq> S; g 0 = a; g 1 = b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
path_component S a b

goal (1 subgoal):
 1. (\<And>g. \<lbrakk>continuous_on {0..1} g; g ` {0..1} \<subseteq> S; g 0 = a; g 1 = b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: path_defs)
[PROOF STATE]
proof (state)
this:
continuous_on {0..1} g
g ` {0..1} \<subseteq> S
g 0 = a
g 1 = b

goal (1 subgoal):
 1. homotopic_loops S (linepath a a) (linepath b b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
continuous_on {0..1} g
g ` {0..1} \<subseteq> S
g 0 = a
g 1 = b
[PROOF STEP]
have "continuous_on ({0..1} \<times> {0..1}) (g \<circ> fst)"
[PROOF STATE]
proof (prove)
using this:
continuous_on {0..1} g
g ` {0..1} \<subseteq> S
g 0 = a
g 1 = b

goal (1 subgoal):
 1. continuous_on ({0..1} \<times> {0::'b..1::'b}) (g \<circ> fst)
[PROOF STEP]
by (fastforce intro!: continuous_intros)+
[PROOF STATE]
proof (state)
this:
continuous_on ({0..1} \<times> {0::?'b1..1::?'b1}) (g \<circ> fst)

goal (1 subgoal):
 1. homotopic_loops S (linepath a a) (linepath b b)
[PROOF STEP]
with g
[PROOF STATE]
proof (chain)
picking this:
continuous_on {0..1} g
g ` {0..1} \<subseteq> S
g 0 = a
g 1 = b
continuous_on ({0..1} \<times> {0::?'b1..1::?'b1}) (g \<circ> fst)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
continuous_on {0..1} g
g ` {0..1} \<subseteq> S
g 0 = a
g 1 = b
continuous_on ({0..1} \<times> {0::?'b1..1::?'b1}) (g \<circ> fst)

goal (1 subgoal):
 1. homotopic_loops S (linepath a a) (linepath b b)
[PROOF STEP]
by (auto simp add: homotopic_loops_def homotopic_with_def path_defs image_subset_iff)
[PROOF STATE]
proof (state)
this:
homotopic_loops S (linepath a a) (linepath b b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma unit_cpx_vec_length [simp]:
  assumes "i < n"
  shows "\<parallel>unit_vec n i\<parallel> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
have "(\<Sum>j<n. (cmod((unit_vec n i) $ j))\<^sup>2) = (\<Sum>j<n. if j = i then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = (\<Sum>j<n. if j = i then 1 else 0)
[PROOF STEP]
using norm_vec_index_unit_vec_is_0 norm_vec_index_unit_vec_is_1
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?j < ?n; ?j \<noteq> ?i\<rbrakk> \<Longrightarrow> cmod (unit_vec ?n ?i $ ?j) = 0
\<lbrakk>?j < ?n; ?j = ?i\<rbrakk> \<Longrightarrow> cmod (unit_vec ?n ?i $ ?j) = 1

goal (1 subgoal):
 1. (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = (\<Sum>j<n. if j = i then 1 else 0)
[PROOF STEP]
by (smt lessThan_iff one_power2 sum.cong zero_power2)
[PROOF STATE]
proof (state)
this:
(\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = (\<Sum>j<n. if j = i then 1 else 0)

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = (\<Sum>j<n. if j = i then 1 else 0)

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
have "\<dots> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j<n. if j = i then 1 else 0) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. (\<Sum>j<n. if j = i then 1 else 0) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>j<n. if j = i then 1 else 0) = 1

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1
[PROOF STEP]
have "sqrt (\<Sum>j<n. (cmod((unit_vec n i) $ j))\<^sup>2) = 1"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1

goal (1 subgoal):
 1. sqrt (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
sqrt (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
using cpx_vec_length_def
[PROOF STATE]
proof (prove)
using this:
sqrt (\<Sum>j<n. (cmod (unit_vec n i $ j))\<^sup>2) = 1
\<parallel>?v\<parallel> \<equiv> sqrt (\<Sum>i<dim_vec ?v. (cmod (?v $ i))\<^sup>2)

goal (1 subgoal):
 1. \<parallel>unit_vec n i\<parallel> = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<parallel>unit_vec n i\<parallel> = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma r01_to_r01_r01_snd_def':
  "r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2*n + 1)) * (1/2)^(n+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))
[PROOF STEP]
have "r01_to_r01_r01_snd_sum r = (\<lambda>n. \<Sum>i=0..n. real (r01_binary_expansion' r (2*i + 1)) * (1/2)^(i+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_to_r01_r01_snd_sum r = (\<lambda>n. \<Sum>i = 0..n. real (r01_binary_expansion' r (2 * i + 1)) * (1 / 2) ^ (i + 1))
[PROOF STEP]
by(auto simp add: r01_to_r01_r01_snd_sum_def r01_binary_sum_def r01_to_r01_r01_snd'_def)
[PROOF STATE]
proof (state)
this:
r01_to_r01_r01_snd_sum r = (\<lambda>n. \<Sum>i = 0..n. real (r01_binary_expansion' r (2 * i + 1)) * (1 / 2) ^ (i + 1))

goal (1 subgoal):
 1. r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
r01_to_r01_r01_snd_sum r = (\<lambda>n. \<Sum>i = 0..n. real (r01_binary_expansion' r (2 * i + 1)) * (1 / 2) ^ (i + 1))

goal (1 subgoal):
 1. r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))
[PROOF STEP]
using lim_sum_ai real01_binary_expansion'_0or1
[PROOF STATE]
proof (prove)
using this:
r01_to_r01_r01_snd_sum r = (\<lambda>n. \<Sum>i = 0..n. real (r01_binary_expansion' r (2 * i + 1)) * (1 / 2) ^ (i + 1))
(\<And>n. ?a n \<in> {0, 1}) \<Longrightarrow> lim (\<lambda>n. \<Sum>i = 0..n. real (?a i) * (1 / 2) ^ Suc i) = (\<Sum>n. real (?a n) * (1 / 2) ^ Suc n)
r01_binary_expansion' ?r ?n \<in> {0, 1}

goal (1 subgoal):
 1. r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))
[PROOF STEP]
by(simp add: r01_to_r01_r01_snd_def)
[PROOF STATE]
proof (state)
this:
r01_to_r01_r01_snd r = (\<Sum>n. real (r01_binary_expansion' r (2 * n + 1)) * (1 / 2) ^ (n + 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma compact_scaling:
  fixes s :: "'a::real_normed_vector set"
  assumes "compact s"
  shows "compact ((\<lambda>x. c *\<^sub>R x) ` s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
let ?f = "\<lambda>x. scaleR c x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
have *: "bounded_linear ?f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded_linear ((*\<^sub>R) c)
[PROOF STEP]
by (rule bounded_linear_scaleR_right)
[PROOF STATE]
proof (state)
this:
bounded_linear ((*\<^sub>R) c)

goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>continuous_on s ((*\<^sub>R) c); compact s\<rbrakk> \<Longrightarrow> compact ((*\<^sub>R) c ` s)
\<forall>x\<in>s. isCont ((*\<^sub>R) c) x \<Longrightarrow> continuous_on s ((*\<^sub>R) c)

goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
using linear_continuous_at[OF *] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>continuous_on s ((*\<^sub>R) c); compact s\<rbrakk> \<Longrightarrow> compact ((*\<^sub>R) c ` s)
\<forall>x\<in>s. isCont ((*\<^sub>R) c) x \<Longrightarrow> continuous_on s ((*\<^sub>R) c)
isCont ((*\<^sub>R) c) ?a
compact s

goal (1 subgoal):
 1. compact ((*\<^sub>R) c ` s)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
compact ((*\<^sub>R) c ` s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_lists_length_le:
  assumes "finite A" shows "card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = (\<Sum>i\<le>n. card A^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
have "(\<Sum>i\<le>n. card A^i) = card (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) (card A)) {..n} = card (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i})
[PROOF STEP]
using \<open>finite A\<close>
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. sum ((^) (card A)) {..n} = card (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i})
[PROOF STEP]
by (subst card_UN_disjoint)
       (auto simp add: card_lists_length_eq finite_lists_length_eq)
[PROOF STATE]
proof (state)
this:
sum ((^) (card A)) {..n} = card (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i})

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((^) (card A)) {..n} = card (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i})

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
have "(\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i}) = {xs. set xs \<subseteq> A \<and> length xs \<le> n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i}) = {xs. set xs \<subseteq> A \<and> length xs \<le> n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Union>i\<le>n. {xs. set xs \<subseteq> A \<and> length xs = i}) = {xs. set xs \<subseteq> A \<and> length xs \<le> n}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum ((^) (card A)) {..n} = card {xs. set xs \<subseteq> A \<and> length xs \<le> n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum ((^) (card A)) {..n} = card {xs. set xs \<subseteq> A \<and> length xs \<le> n}

goal (1 subgoal):
 1. card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {xs. set xs \<subseteq> A \<and> length xs \<le> n} = sum ((^) (card A)) {..n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ld_bounded: "Max {i. 2 ^ i \<le> Suc n} \<le> Suc n" (is "?m \<le> Suc n")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
have "?m \<le> 2 ^ ?m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> 2 ^ Max {i. 2 ^ i \<le> Suc n}
[PROOF STEP]
by (rule le_pow2) simp
[PROOF STATE]
proof (state)
this:
Max {i. 2 ^ i \<le> Suc n} \<le> 2 ^ Max {i. 2 ^ i \<le> Suc n}

goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Max {i. 2 ^ i \<le> Suc n} \<le> 2 ^ Max {i. 2 ^ i \<le> Suc n}

goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
have "?m \<in> {i. 2 ^ i \<le> Suc n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<in> {i. 2 ^ i \<le> Suc n}
[PROOF STEP]
by (rule Max_in) (auto intro: exI[of _ 0])
[PROOF STATE]
proof (state)
this:
Max {i. 2 ^ i \<le> Suc n} \<in> {i. 2 ^ i \<le> Suc n}

goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Max {i. 2 ^ i \<le> Suc n} \<in> {i. 2 ^ i \<le> Suc n}
[PROOF STEP]
have "2 ^ ?m \<le> Suc n"
[PROOF STATE]
proof (prove)
using this:
Max {i. 2 ^ i \<le> Suc n} \<in> {i. 2 ^ i \<le> Suc n}

goal (1 subgoal):
 1. 2 ^ Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ Max {i. 2 ^ i \<le> Suc n} \<le> Suc n

goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Max {i. 2 ^ i \<le> Suc n} \<le> 2 ^ Max {i. 2 ^ i \<le> Suc n}
2 ^ Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Max {i. 2 ^ i \<le> Suc n} \<le> 2 ^ Max {i. 2 ^ i \<le> Suc n}
2 ^ Max {i. 2 ^ i \<le> Suc n} \<le> Suc n

goal (1 subgoal):
 1. Max {i. 2 ^ i \<le> Suc n} \<le> Suc n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
Max {i. 2 ^ i \<le> Suc n} \<le> Suc n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma all_le_eq_imp_eq: "\<And> c::nat. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> (d = c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c
[PROOF STEP]
proof (induct d)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>c. (\<forall>a. (a < 0) = (a < c)) \<longrightarrow> 0 = c
 2. \<And>d c. (\<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c) \<Longrightarrow> (\<forall>a. (a < Suc d) = (a < c)) \<longrightarrow> Suc d = c
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>c. (\<forall>a. (a < 0) = (a < c)) \<longrightarrow> 0 = c
 2. \<And>d c. (\<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c) \<Longrightarrow> (\<forall>a. (a < Suc d) = (a < c)) \<longrightarrow> Suc d = c
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a. (a < 0) = (a < c)) \<longrightarrow> 0 = c
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<forall>a. (a < 0) = (a < c)) \<longrightarrow> 0 = c

goal (1 subgoal):
 1. \<And>d c. (\<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c) \<Longrightarrow> (\<forall>a. (a < Suc d) = (a < c)) \<longrightarrow> Suc d = c
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d c. (\<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c) \<Longrightarrow> (\<forall>a. (a < Suc d) = (a < c)) \<longrightarrow> Suc d = c
[PROOF STEP]
case (Suc n c)
[PROOF STATE]
proof (state)
this:
(\<forall>a. (a < n) = (a < ?c)) \<longrightarrow> n = ?c

goal (1 subgoal):
 1. \<And>d c. (\<And>c. (\<forall>a. (a < d) = (a < c)) \<longrightarrow> d = c) \<Longrightarrow> (\<forall>a. (a < Suc d) = (a < c)) \<longrightarrow> Suc d = c
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
(\<forall>a. (a < n) = (a < ?c)) \<longrightarrow> n = ?c

goal (1 subgoal):
 1. (\<forall>a. (a < Suc n) = (a < c)) \<longrightarrow> Suc n = c
[PROOF STEP]
by (cases c) (auto simp add: le_Suc_eq)
[PROOF STATE]
proof (state)
this:
(\<forall>a. (a < Suc n) = (a < c)) \<longrightarrow> Suc n = c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem derangements_formula:
  assumes "n \<noteq> 0" "finite S" "card S = n"
  shows "int (card (derangements S)) = round (fact n / exp 1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card (derangements S)) = round (fact n / exp 1)
[PROOF STEP]
using count_derangements_approximation[of n] assms
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0 \<Longrightarrow> \<bar>real (count_derangements n) - fact n / exp 1\<bar> < 1 / 2
n \<noteq> 0
finite S
card S = n

goal (1 subgoal):
 1. int (card (derangements S)) = round (fact n / exp 1)
[PROOF STEP]
by (intro round_unique' [symmetric]) (auto simp: card_derangements abs_minus_commute)


[STATEMENT]
lemma "Carmichael 122200 = 1380"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Carmichael 122200 = 1380
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Carmichael 122200 = 1380
[PROOF STEP]
have "prime_factorization (2^3 * 5^2 * 13 * 47) = {#2, 2, 2, 5, 5, 13, 47::nat#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime_factorization (2 ^ 3 * 5\<^sup>2 * 13 * 47) = {#2, 2, 2, 5, 5, 13, 47#}
[PROOF STEP]
by (intro prime_factorization_eqI) auto
[PROOF STATE]
proof (state)
this:
prime_factorization (2 ^ 3 * 5\<^sup>2 * 13 * 47) = {#2, 2, 2, 5, 5, 13, 47#}

goal (1 subgoal):
 1. Carmichael 122200 = 1380
[PROOF STEP]
from eval_Carmichael[OF this]
[PROOF STATE]
proof (chain)
picking this:
Carmichael (2 ^ 3 * 5\<^sup>2 * 13 * 47) = (LCM p\<in>set_mset {#2, 2, 2, 5, 5, 13, 47#}. let k = count {#2, 2, 2, 5, 5, 13, 47#} p in if p = 2 \<and> 2 < k then 2 ^ (k - 2) else p ^ (k - 1) * (p - 1))
[PROOF STEP]
show "Carmichael 122200 = 1380"
[PROOF STATE]
proof (prove)
using this:
Carmichael (2 ^ 3 * 5\<^sup>2 * 13 * 47) = (LCM p\<in>set_mset {#2, 2, 2, 5, 5, 13, 47#}. let k = count {#2, 2, 2, 5, 5, 13, 47#} p in if p = 2 \<and> 2 < k then 2 ^ (k - 2) else p ^ (k - 1) * (p - 1))

goal (1 subgoal):
 1. Carmichael 122200 = 1380
[PROOF STEP]
by (simp add: lcm_nat_def gcd_non_0_nat)
[PROOF STATE]
proof (state)
this:
Carmichael 122200 = 1380

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma icard_Un_Int: "icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
[PROOF STEP]
apply (case_tac "finite A", case_tac "finite B")
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
 2. \<lbrakk>finite A; infinite B\<rbrakk> \<Longrightarrow> icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
 3. infinite A \<Longrightarrow> icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
[PROOF STEP]
apply (simp add: icard_finite card_Un_Int[of A])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite A; infinite B\<rbrakk> \<Longrightarrow> icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
 2. infinite A \<Longrightarrow> icard A + icard B = icard (A \<union> B) + icard (A \<inter> B)
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma T'_mom_select_le': "\<exists>C\<^sub>1 C\<^sub>2. \<forall>n. T'_mom_select n \<le> C\<^sub>1 * n + C\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>C\<^sub>1 C\<^sub>2. \<forall>n. T'_mom_select n \<le> C\<^sub>1 * n + C\<^sub>2
[PROOF STEP]
proof (rule akra_bazzi_light_nat)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. 0 < ?a
 2. 0 < ?c
 3. ?a + ?c < 1
 4. 0 \<le> ?C\<^sub>1
 5. \<forall>n>?n\<^sub>0. T'_mom_select n = T'_mom_select (nat \<lceil>?a * real n + ?b\<rceil>) + T'_mom_select (nat \<lceil>?c * real n + ?d\<rceil>) + ?C\<^sub>1 * n + ?C\<^sub>2
[PROOF STEP]
show "\<forall>n>20. T'_mom_select n = T'_mom_select (nat \<lceil>0.2 * n + 0\<rceil>) +
                 T'_mom_select (nat \<lceil>0.7 * n + 3\<rceil>) + 17 * n + 50"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n>20. T'_mom_select n = T'_mom_select (nat \<lceil>2 / 10 * real n + 0\<rceil>) + T'_mom_select (nat \<lceil>7 / 10 * real n + 3\<rceil>) + 17 * n + 50
[PROOF STEP]
using T'_mom_select.simps
[PROOF STATE]
proof (prove)
using this:
T'_mom_select ?n = (if ?n \<le> 20 then 463 else T'_mom_select (nat \<lceil>2 / 10 * real ?n\<rceil>) + T'_mom_select (nat \<lceil>7 / 10 * real ?n + 3\<rceil>) + 17 * ?n + 50)

goal (1 subgoal):
 1. \<forall>n>20. T'_mom_select n = T'_mom_select (nat \<lceil>2 / 10 * real n + 0\<rceil>) + T'_mom_select (nat \<lceil>7 / 10 * real n + 3\<rceil>) + 17 * n + 50
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>n>20. T'_mom_select n = T'_mom_select (nat \<lceil>2 / 10 * real n + 0\<rceil>) + T'_mom_select (nat \<lceil>7 / 10 * real n + 3\<rceil>) + 17 * n + 50

goal (4 subgoals):
 1. 0 < 2 / 10
 2. 0 < 7 / 10
 3. 2 / 10 + 7 / 10 < 1
 4. 0 \<le> 17
[PROOF STEP]
qed auto


[STATEMENT]
lemma convex_contains_segment:
  "convex S \<longleftrightarrow> (\<forall>a\<in>S. \<forall>b\<in>S. closed_segment a b \<subseteq> S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex S = (\<forall>a\<in>S. \<forall>b\<in>S. closed_segment a b \<subseteq> S)
[PROOF STEP]
unfolding convex_alt closed_segment_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>S. \<forall>y\<in>S. \<forall>u. 0 \<le> u \<and> u \<le> 1 \<longrightarrow> (1 - u) *\<^sub>R x + u *\<^sub>R y \<in> S) = (\<forall>a\<in>S. \<forall>b\<in>S. {(1 - u) *\<^sub>R a + u *\<^sub>R b |u. 0 \<le> u \<and> u \<le> 1} \<subseteq> S)
[PROOF STEP]
by auto


[STATEMENT]
theorem squarefree_asymptotics'':
  "(\<lambda>x. card {n. real n \<le> x \<and> squarefree n}) \<sim>[at_top] (\<lambda>x. 6 / pi\<^sup>2 * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
have "(\<lambda>x. card {n. real n \<le> x \<and> squarefree n} - 6 / pi\<^sup>2 * x) \<in> O(\<lambda>x. sqrt x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n}) - 6 / pi\<^sup>2 * x) \<in> O(sqrt)
[PROOF STEP]
by (rule squarefree_asymptotics)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n}) - 6 / pi\<^sup>2 * x) \<in> O(sqrt)

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n}) - 6 / pi\<^sup>2 * x) \<in> O(sqrt)

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
have "(sqrt :: real \<Rightarrow> real) \<in> \<Theta>(\<lambda>x. x powr (1/2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt \<in> \<Theta>(\<lambda>x. x powr (1 / 2))
[PROOF STEP]
by (intro bigthetaI_cong eventually_mono[OF eventually_ge_at_top[of "0::real"]])
       (auto simp: powr_half_sqrt)
[PROOF STATE]
proof (state)
this:
sqrt \<in> \<Theta>(\<lambda>x. x powr (1 / 2))

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sqrt \<in> \<Theta>(\<lambda>x. x powr (1 / 2))

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
have "(\<lambda>x::real. x powr (1/2)) \<in> o(\<lambda>x. 6 / pi ^ 2 * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x powr (1 / 2)) \<in> o((*) (6 / pi\<^sup>2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x powr (1 / 2)) \<in> o((*) (6 / pi\<^sup>2))

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n}) - 6 / pi\<^sup>2 * x) \<in> o((*) (6 / pi\<^sup>2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n}) - 6 / pi\<^sup>2 * x) \<in> o((*) (6 / pi\<^sup>2))

goal (1 subgoal):
 1. (\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)
[PROOF STEP]
by (simp add: asymp_equiv_altdef)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (card {n. real n \<le> x \<and> squarefree n})) \<sim>[at_top] (*) (6 / pi\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dim_affine_hull:
  fixes S :: "'n::euclidean_space set"
  shows "dim (affine hull S) = dim S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
have "dim (affine hull S) \<ge> dim S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim S \<le> dim (affine hull S)
[PROOF STEP]
using dim_subset
[PROOF STATE]
proof (prove)
using this:
?S \<subseteq> ?T \<Longrightarrow> dim ?S \<le> dim ?T

goal (1 subgoal):
 1. dim S \<le> dim (affine hull S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim S \<le> dim (affine hull S)

goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim S \<le> dim (affine hull S)

goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
have "dim (span S) \<ge> dim (affine hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim (affine hull S) \<le> dim (span S)
[PROOF STEP]
using dim_subset affine_hull_subset_span
[PROOF STATE]
proof (prove)
using this:
?S \<subseteq> ?T \<Longrightarrow> dim ?S \<le> dim ?T
affine hull ?s \<subseteq> span ?s

goal (1 subgoal):
 1. dim (affine hull S) \<le> dim (span S)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
dim (affine hull S) \<le> dim (span S)

goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim (affine hull S) \<le> dim (span S)

goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
have "dim (span S) = dim S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim (span S) = dim S
[PROOF STEP]
using dim_span
[PROOF STATE]
proof (prove)
using this:
dim (span ?S) = dim ?S

goal (1 subgoal):
 1. dim (span S) = dim S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim (span S) = dim S

goal (1 subgoal):
 1. dim (affine hull S) = dim S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim S \<le> dim (affine hull S)
dim (affine hull S) \<le> dim (span S)
dim (span S) = dim S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim S \<le> dim (affine hull S)
dim (affine hull S) \<le> dim (span S)
dim (span S) = dim S

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "(a::int) ^ 3 - b ^ 3 = (a - b) * (a ^ 2 + a * b + b ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ 3 - b ^ 3 = (a - b) * (a\<^sup>2 + a * b + b\<^sup>2)
[PROOF STEP]
by ring


[STATEMENT]
lemma tan_45: "tan (pi / 4) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan (pi / 4) = 1
[PROOF STEP]
unfolding tan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (pi / 4) / cos (pi / 4) = 1
[PROOF STEP]
by (simp add: sin_45 cos_45)


[STATEMENT]
lemma multTensor2 [simp]:
  assumes a1:"A = Matrix.mat 2 1 (\<lambda>(i,j). if i = 0 then a0 else a1)" and
          a2:"B = Matrix.mat 2 1 (\<lambda>(i,j). if i = 0 then b0 else b1)"
  shows "mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0*b0, a0*b1, a1*b0, a1*b1]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
have "mat_to_cols_list A = [[a0, a1]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_to_cols_list A = [[a0, a1]]
[PROOF STEP]
by (auto simp: a1 mat_to_cols_list_def) (simp add: numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
mat_to_cols_list A = [[a0, a1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
mat_to_cols_list A = [[a0, a1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
have f2:"mat_to_cols_list B = [[b0, b1]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_to_cols_list B = [[b0, b1]]
[PROOF STEP]
by (auto simp: a2 mat_to_cols_list_def) (simp add: numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
mat_to_cols_list B = [[b0, b1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
mat_to_cols_list A = [[a0, a1]]
mat_to_cols_list B = [[b0, b1]]
[PROOF STEP]
have "mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) =
                   mult.Tensor (*) [[a0,a1]] [[b0,b1]]"
[PROOF STATE]
proof (prove)
using this:
mat_to_cols_list A = [[a0, a1]]
mat_to_cols_list B = [[b0, b1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = mult.Tensor (*) [[a0, a1]] [[b0, b1]]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = mult.Tensor (*) [[a0, a1]] [[b0, b1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = mult.Tensor (*) [[a0, a1]] [[b0, b1]]

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
using mult.Tensor_def[of "(1::complex)" "(*)"] mult.times_def[of "(1::complex)" "(*)"]
[PROOF STATE]
proof (prove)
using this:
mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = mult.Tensor (*) [[a0, a1]] [[b0, b1]]
Matrix_Tensor.mult 1 (*) \<Longrightarrow> mult.Tensor (*) \<equiv> rec_list (\<lambda>xs. []) (\<lambda>x xs xsa ys. mult.vec_mat_Tensor (*) x ys @ xsa ys)
Matrix_Tensor.mult 1 (*) \<Longrightarrow> mult.times (*) \<equiv> \<lambda>uu uua. rec_list (\<lambda>n. []) (\<lambda>y ys ysa n. n * y # ysa n) uua uu

goal (1 subgoal):
 1. mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]
[PROOF STEP]
by (metis (mono_tags, lifting) append_self_conv list.simps(6) mult.Tensor.simps(2) mult.vec_mat_Tensor.simps(1)
mult.vec_mat_Tensor.simps(2) plus_mult_cpx plus_mult_def tensor_prod_2)
[PROOF STATE]
proof (state)
this:
mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list B) = [[a0 * b0, a0 * b1, a1 * b0, a1 * b1]]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma natUnion_subset: "(\<And> n. \<exists> m. f n \<subseteq> g m) \<Longrightarrow> natUnion f \<subseteq> natUnion g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. \<exists>m. f n \<subseteq> g m) \<Longrightarrow> natUnion f \<subseteq> natUnion g
[PROOF STEP]
by (meson natUnion_elem natUnion_upperbound subset_iff)


[STATEMENT]
lemma power_mult_cong:
  assumes "[x^n = a](mod m)" "[y^n = b](mod m)"
  shows "[(x*y)^n = a*b](mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(x * y) ^ n = a * b] (mod m)
[PROOF STEP]
using assms cong_mult[of "x^n" a m "y^n" b] power_mult_distrib
[PROOF STATE]
proof (prove)
using this:
[x ^ n = a] (mod m)
[y ^ n = b] (mod m)
\<lbrakk>[x ^ n = a] (mod m); [y ^ n = b] (mod m)\<rbrakk> \<Longrightarrow> [x ^ n * y ^ n = a * b] (mod m)
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n

goal (1 subgoal):
 1. [(x * y) ^ n = a * b] (mod m)
[PROOF STEP]
by metis


[STATEMENT]
lemma erfc_aux_unroll:
  "x > 0 \<Longrightarrow>
     erfc_aux x = (\<Sum>i<n. (-1)^i * fact (2*i) / (4^i*fact i) / x^(2*i+1)) + erf_remainder' n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> erfc_aux x = (\<Sum>i<n. (- 1) ^ i * fact (2 * i) / (4 ^ i * fact i) / x ^ (2 * i + 1)) + erf_remainder' n x
[PROOF STEP]
using erfc_unroll[of x n]
[PROOF STATE]
proof (prove)
using this:
0 < x \<Longrightarrow> erfc x = exp (- x\<^sup>2) / sqrt pi * (\<Sum>i<n. (- 1) ^ i * fact (2 * i) / (4 ^ i * fact i) / x ^ (2 * i + 1)) + erf_remainder n x

goal (1 subgoal):
 1. 0 < x \<Longrightarrow> erfc_aux x = (\<Sum>i<n. (- 1) ^ i * fact (2 * i) / (4 ^ i * fact i) / x ^ (2 * i + 1)) + erf_remainder' n x
[PROOF STEP]
by (simp add: erfc_aux_def erf_remainder'_def exp_minus field_simps del: of_nat_Suc)


[STATEMENT]
lemma unitary_comp:
  assumes "unitary M1" and "unitary M2"
  shows "unitary (M1 *\<^sub>m\<^sub>m M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unitary (M1 *\<^sub>m\<^sub>m M2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
unitary M1
unitary M2

goal (1 subgoal):
 1. unitary (M1 *\<^sub>m\<^sub>m M2)
[PROOF STEP]
unfolding unitary_def
[PROOF STATE]
proof (prove)
using this:
mat_adj M1 *\<^sub>m\<^sub>m M1 = eye
mat_adj M2 *\<^sub>m\<^sub>m M2 = eye

goal (1 subgoal):
 1. mat_adj (M1 *\<^sub>m\<^sub>m M2) *\<^sub>m\<^sub>m (M1 *\<^sub>m\<^sub>m M2) = eye
[PROOF STEP]
by (metis mat_adj_mult_mm mat_eye_l mult_mm_assoc)


[STATEMENT]
lemma (in group) int_pow_eq_id:
  assumes "x \<in> carrier G"
  shows "(pow G x i = one G \<longleftrightarrow> int (ord x) dvd i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
proof (cases i rule: int_cases2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. i = int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
 2. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
case (nonneg n)
[PROOF STATE]
proof (state)
this:
i = int n

goal (2 subgoals):
 1. \<And>n. i = int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
 2. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i = int n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i = int n

goal (1 subgoal):
 1. (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
by (simp add: int_pow_int pow_eq_id assms)
[PROOF STATE]
proof (state)
this:
(x [^] i = \<one>) = (int (ord x) dvd i)

goal (1 subgoal):
 1. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
case (nonpos n)
[PROOF STATE]
proof (state)
this:
i = - int n

goal (1 subgoal):
 1. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i = - int n
[PROOF STEP]
have "x [^] i = inv (x [^] n)"
[PROOF STATE]
proof (prove)
using this:
i = - int n

goal (1 subgoal):
 1. x [^] i = inv (x [^] n)
[PROOF STEP]
by (simp add: assms int_pow_int int_pow_neg)
[PROOF STATE]
proof (state)
this:
x [^] i = inv (x [^] n)

goal (1 subgoal):
 1. \<And>n. i = - int n \<Longrightarrow> (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x [^] i = inv (x [^] n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x [^] i = inv (x [^] n)

goal (1 subgoal):
 1. (x [^] i = \<one>) = (int (ord x) dvd i)
[PROOF STEP]
by (simp add: assms pow_eq_id nonpos)
[PROOF STATE]
proof (state)
this:
(x [^] i = \<one>) = (int (ord x) dvd i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma q64_upto_def: "q64 = (\<lambda>k. k\<^sup>2 mod 64) ` {..<64}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q64 = (\<lambda>k. k\<^sup>2 mod 64) ` {..<64}
[PROOF STEP]
by (simp add: q64_def lessThan_nat_numeral lessThan_Suc insert_commute)


[STATEMENT]
lemma ai_exists0_less_than1:
  assumes "\<And>n. a n \<in> {0,1}"
      and "\<exists>i. a i = 0"
    shows "(\<Sum>n::nat. real (a n) * (1/2)^(Suc n)) < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. real (a n) * (1 / 2) ^ Suc n) < 1
[PROOF STEP]
using ai_exists0_less_than_sum[of a 0] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>n. a n \<in> {0, 1}; 0 \<le> ?i; a ?i = 0\<rbrakk> \<Longrightarrow> (\<Sum>n. real (a (n + 0)) * (1 / 2) ^ Suc (n + 0)) < (1 / 2) ^ 0
a ?n \<in> {0, 1}
\<exists>i. a i = 0

goal (1 subgoal):
 1. (\<Sum>n. real (a n) * (1 / 2) ^ Suc n) < 1
[PROOF STEP]
by auto


[STATEMENT]
lemma bij_betw_image_mset_set:
  assumes "bij_betw f A B"
  shows   "image_mset f (mset_set A) = mset_set B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset f (mset_set A) = mset_set B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bij_betw f A B

goal (1 subgoal):
 1. image_mset f (mset_set A) = mset_set B
[PROOF STEP]
by (simp add: bij_betw_def image_mset_mset_set)


[STATEMENT]
lemma crk_is_preserved:
fixes A::"'a::{field}^'cols::{finite, wellorder}^'rows"
  and P::"'a::{field}^'rows^'rows"
assumes inv_P: "invertible P"
shows "col_rank A = col_rank (P**A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col_rank A = col_rank (P ** A)
[PROOF STEP]
using rank_nullity_theorem_matrices
[PROOF STATE]
proof (prove)
using this:
ncols ?A = vec.dim (null_space ?A) + vec.dim (col_space ?A)

goal (1 subgoal):
 1. col_rank A = col_rank (P ** A)
[PROOF STEP]
unfolding ncols_def
[PROOF STATE]
proof (prove)
using this:
CARD(?'cols) = vec.dim (null_space ?A) + vec.dim (col_space ?A)

goal (1 subgoal):
 1. col_rank A = col_rank (P ** A)
[PROOF STEP]
by (metis col_rank_def inv_P add_left_cancel null_space_is_preserved)


[STATEMENT]
lemma take_map: "take n (map f xs) = map f (take n xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take n (map f xs) = map f (take n xs)
[PROOF STEP]
proof (induct n arbitrary: xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs. take 0 (map f xs) = map f (take 0 xs)
 2. \<And>n xs. (\<And>xs. take n (map f xs) = map f (take n xs)) \<Longrightarrow> take (Suc n) (map f xs) = map f (take (Suc n) xs)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>xs. take 0 (map f xs) = map f (take 0 xs)
 2. \<And>n xs. (\<And>xs. take n (map f xs) = map f (take n xs)) \<Longrightarrow> take (Suc n) (map f xs) = map f (take (Suc n) xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take 0 (map f xs) = map f (take 0 xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
take 0 (map f xs) = map f (take 0 xs)

goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. take n (map f xs) = map f (take n xs)) \<Longrightarrow> take (Suc n) (map f xs) = map f (take (Suc n) xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. take n (map f xs) = map f (take n xs)) \<Longrightarrow> take (Suc n) (map f xs) = map f (take (Suc n) xs)
[PROOF STEP]
case Suc
[PROOF STATE]
proof (state)
this:
take n_ (map f ?xs) = map f (take n_ ?xs)

goal (1 subgoal):
 1. \<And>n xs. (\<And>xs. take n (map f xs) = map f (take n xs)) \<Longrightarrow> take (Suc n) (map f xs) = map f (take (Suc n) xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
take n_ (map f ?xs) = map f (take n_ ?xs)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
take n_ (map f ?xs) = map f (take n_ ?xs)

goal (1 subgoal):
 1. take (Suc n_) (map f xs) = map f (take (Suc n_) xs)
[PROOF STEP]
by (cases xs) simp_all
[PROOF STATE]
proof (state)
this:
take (Suc n_) (map f xs) = map f (take (Suc n_) xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bij_betw_totatives:
  assumes "m1 > 1" "m2 > 1" "coprime m1 m2"
  shows   "bij_betw (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2))
             (totatives m1 \<times> totatives m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2)) (totatives m1 \<times> totatives m2)
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2)) \<and> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inj_on (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2))
 2. (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2
[PROOF STEP]
show "inj_on (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2))
[PROOF STEP]
proof (intro inj_onI, clarify)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> totatives (m1 * m2); y \<in> totatives (m1 * m2); x mod m1 = y mod m1; x mod m2 = y mod m2\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> totatives (m1 * m2); y \<in> totatives (m1 * m2); x mod m1 = y mod m1; x mod m2 = y mod m2\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume xy: "x \<in> totatives (m1 * m2)" "y \<in> totatives (m1 * m2)"
                       "x mod m1 = y mod m1" "x mod m2 = y mod m2"
[PROOF STATE]
proof (state)
this:
x \<in> totatives (m1 * m2)
y \<in> totatives (m1 * m2)
x mod m1 = y mod m1
x mod m2 = y mod m2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> totatives (m1 * m2); y \<in> totatives (m1 * m2); x mod m1 = y mod m1; x mod m2 = y mod m2\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have ex: "\<exists>!z. z < m1 * m2 \<and> [z = x] (mod m1) \<and> [z = x] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>!z. z < m1 * m2 \<and> [z = x] (mod m1) \<and> [z = x] (mod m2)
[PROOF STEP]
by (rule binary_chinese_remainder_unique_nat) (insert assms, simp_all)
[PROOF STATE]
proof (state)
this:
\<exists>!z. z < m1 * m2 \<and> [z = x] (mod m1) \<and> [z = x] (mod m2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> totatives (m1 * m2); y \<in> totatives (m1 * m2); x mod m1 = y mod m1; x mod m2 = y mod m2\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "x < m1 * m2 \<and> [x = x] (mod m1) \<and> [x = x] (mod m2)"
         "y < m1 * m2 \<and> [y = x] (mod m1) \<and> [y = x] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < m1 * m2 \<and> [x = x] (mod m1) \<and> [x = x] (mod m2) &&& y < m1 * m2 \<and> [y = x] (mod m1) \<and> [y = x] (mod m2)
[PROOF STEP]
using xy assms
[PROOF STATE]
proof (prove)
using this:
x \<in> totatives (m1 * m2)
y \<in> totatives (m1 * m2)
x mod m1 = y mod m1
x mod m2 = y mod m2
1 < m1
1 < m2
coprime m1 m2

goal (1 subgoal):
 1. x < m1 * m2 \<and> [x = x] (mod m1) \<and> [x = x] (mod m2) &&& y < m1 * m2 \<and> [y = x] (mod m1) \<and> [y = x] (mod m2)
[PROOF STEP]
by (simp_all add: totatives_less one_less_mult cong_def)
[PROOF STATE]
proof (state)
this:
x < m1 * m2 \<and> [x = x] (mod m1) \<and> [x = x] (mod m2)
y < m1 * m2 \<and> [y = x] (mod m1) \<and> [y = x] (mod m2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> totatives (m1 * m2); y \<in> totatives (m1 * m2); x mod m1 = y mod m1; x mod m2 = y mod m2\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
from this[THEN the1_equality[OF ex]]
[PROOF STATE]
proof (chain)
picking this:
(THE xa. xa < m1 * m2 \<and> [xa = x] (mod m1) \<and> [xa = x] (mod m2)) = x
(THE xa. xa < m1 * m2 \<and> [xa = x] (mod m1) \<and> [xa = x] (mod m2)) = y
[PROOF STEP]
show "x = y"
[PROOF STATE]
proof (prove)
using this:
(THE xa. xa < m1 * m2 \<and> [xa = x] (mod m1) \<and> [xa = x] (mod m2)) = x
(THE xa. xa < m1 * m2 \<and> [xa = x] (mod m1) \<and> [xa = x] (mod m2)) = y

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. (x mod m1, x mod m2)) (totatives (m1 * m2))

goal (1 subgoal):
 1. (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2
[PROOF STEP]
show "(\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m1 \<in> totatives m1
 2. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m2 \<in> totatives m2
 3. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m1 \<in> totatives m1
 2. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m2 \<in> totatives m2
 3. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
assume "x \<in> totatives (m1 * m2)"
[PROOF STATE]
proof (state)
this:
x \<in> totatives (m1 * m2)

goal (3 subgoals):
 1. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m1 \<in> totatives m1
 2. \<And>a b x. x \<in> totatives (m1 * m2) \<Longrightarrow> x mod m2 \<in> totatives m2
 3. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
1 < m1
1 < m2
coprime m1 m2
x \<in> totatives (m1 * m2)
[PROOF STEP]
show "x mod m1 \<in> totatives m1" "x mod m2 \<in> totatives m2"
[PROOF STATE]
proof (prove)
using this:
1 < m1
1 < m2
coprime m1 m2
x \<in> totatives (m1 * m2)

goal (1 subgoal):
 1. x mod m1 \<in> totatives m1 &&& x mod m2 \<in> totatives m2
[PROOF STEP]
using coprime_common_divisor [of x m1 m1] coprime_common_divisor [of x m2 m2]
[PROOF STATE]
proof (prove)
using this:
1 < m1
1 < m2
coprime m1 m2
x \<in> totatives (m1 * m2)
\<lbrakk>coprime x m1; m1 dvd x; m1 dvd m1\<rbrakk> \<Longrightarrow> is_unit m1
\<lbrakk>coprime x m2; m2 dvd x; m2 dvd m2\<rbrakk> \<Longrightarrow> is_unit m2

goal (1 subgoal):
 1. x mod m1 \<in> totatives m1 &&& x mod m2 \<in> totatives m2
[PROOF STEP]
by (auto simp add: in_totatives_iff mod_greater_zero_iff_not_dvd)
[PROOF STATE]
proof (state)
this:
x mod m1 \<in> totatives m1
x mod m2 \<in> totatives m2

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
fix a b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
assume ab: "a \<in> totatives m1" "b \<in> totatives m2"
[PROOF STATE]
proof (state)
this:
a \<in> totatives m1
b \<in> totatives m2

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
1 < m1
1 < m2
coprime m1 m2
a \<in> totatives m1
b \<in> totatives m2
[PROOF STEP]
have ab': "a < m1" "b < m2"
[PROOF STATE]
proof (prove)
using this:
1 < m1
1 < m2
coprime m1 m2
a \<in> totatives m1
b \<in> totatives m2

goal (1 subgoal):
 1. a < m1 &&& b < m2
[PROOF STEP]
by (auto simp: totatives_less)
[PROOF STATE]
proof (state)
this:
a < m1
b < m2

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
with binary_chinese_remainder_unique_nat[OF assms(3), of a b]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>m1 \<noteq> 0; m2 \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>!x. x < m1 * m2 \<and> [x = a] (mod m1) \<and> [x = b] (mod m2)
a < m1
b < m2
[PROOF STEP]
obtain x
      where x: "x < m1 * m2" "x mod m1 = a" "x mod m2 = b"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>m1 \<noteq> 0; m2 \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>!x. x < m1 * m2 \<and> [x = a] (mod m1) \<and> [x = b] (mod m2)
a < m1
b < m2

goal (1 subgoal):
 1. (\<And>x. \<lbrakk>x < m1 * m2; x mod m1 = a; x mod m2 = b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: cong_def)
[PROOF STATE]
proof (state)
this:
x < m1 * m2
x mod m1 = a
x mod m2 = b

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
from x ab assms(3)
[PROOF STATE]
proof (chain)
picking this:
x < m1 * m2
x mod m1 = a
x mod m2 = b
a \<in> totatives m1
b \<in> totatives m2
coprime m1 m2
[PROOF STEP]
have "x \<in> totatives (m1 * m2)"
[PROOF STATE]
proof (prove)
using this:
x < m1 * m2
x mod m1 = a
x mod m2 = b
a \<in> totatives m1
b \<in> totatives m2
coprime m1 m2

goal (1 subgoal):
 1. x \<in> totatives (m1 * m2)
[PROOF STEP]
by (auto intro: ccontr simp add: in_totatives_iff)
[PROOF STATE]
proof (state)
this:
x \<in> totatives (m1 * m2)

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>a \<in> totatives m1; b \<in> totatives m2\<rbrakk> \<Longrightarrow> (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
with x
[PROOF STATE]
proof (chain)
picking this:
x < m1 * m2
x mod m1 = a
x mod m2 = b
x \<in> totatives (m1 * m2)
[PROOF STEP]
show "(a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1*m2)"
[PROOF STATE]
proof (prove)
using this:
x < m1 * m2
x mod m1 = a
x mod m2 = b
x \<in> totatives (m1 * m2)

goal (1 subgoal):
 1. (a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(a, b) \<in> (\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (x mod m1, x mod m2)) ` totatives (m1 * m2) = totatives m1 \<times> totatives m2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pi_approx: "3.141592653588 \<le> pi" "pi \<le> 3.1415926535899"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3141592653588 / 10 ^ 12 \<le> pi &&& pi \<le> 31415926535899 / 10 ^ 13
[PROOF STEP]
unfolding pi_machin
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3141592653588 / 10 ^ 12 \<le> 16 * arctan (1 / 5) - 4 * arctan (1 / 239) &&& 16 * arctan (1 / 5) - 4 * arctan (1 / 239) \<le> 31415926535899 / 10 ^ 13
[PROOF STEP]
using arctan_bounds[of "1/5"   4]
        arctan_bounds[of "1/239" 4]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> 1 / 5; 1 / 5 < 1\<rbrakk> \<Longrightarrow> (\<Sum>k<2 * 4. (- 1) ^ k * (1 / real (k * 2 + 1) * (1 / 5) ^ (k * 2 + 1))) \<le> arctan (1 / 5)
\<lbrakk>0 \<le> 1 / 5; 1 / 5 < 1\<rbrakk> \<Longrightarrow> arctan (1 / 5) \<le> (\<Sum>k<2 * 4 + 1. (- 1) ^ k * (1 / real (k * 2 + 1) * (1 / 5) ^ (k * 2 + 1)))
\<lbrakk>0 \<le> 1 / 239; 1 / 239 < 1\<rbrakk> \<Longrightarrow> (\<Sum>k<2 * 4. (- 1) ^ k * (1 / real (k * 2 + 1) * (1 / 239) ^ (k * 2 + 1))) \<le> arctan (1 / 239)
\<lbrakk>0 \<le> 1 / 239; 1 / 239 < 1\<rbrakk> \<Longrightarrow> arctan (1 / 239) \<le> (\<Sum>k<2 * 4 + 1. (- 1) ^ k * (1 / real (k * 2 + 1) * (1 / 239) ^ (k * 2 + 1)))

goal (1 subgoal):
 1. 3141592653588 / 10 ^ 12 \<le> 16 * arctan (1 / 5) - 4 * arctan (1 / 239) &&& 16 * arctan (1 / 5) - 4 * arctan (1 / 239) \<le> 31415926535899 / 10 ^ 13
[PROOF STEP]
by (simp_all add: eval_nat_numeral)


[STATEMENT]
lemma summable_Cauchy_product:
  fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}"
  assumes "summable (\<lambda>k. norm (a k))"
    and "summable (\<lambda>k. norm (b k))"
  shows "summable (\<lambda>k. \<Sum>i\<le>k. a i * b (k - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>k. \<Sum>i\<le>k. a i * b (k - i))
[PROOF STEP]
using Cauchy_product_sums[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. \<Sum>i\<le>k. a i * b (k - i)) sums ((\<Sum>k. a k) * (\<Sum>k. b k))

goal (1 subgoal):
 1. summable (\<lambda>k. \<Sum>i\<le>k. a i * b (k - i))
[PROOF STEP]
by (simp add: sums_iff)


[STATEMENT]
lemma convex_hull_scaling:
  "convex hull ((\<lambda>x. c *\<^sub>R x) ` S) = (\<lambda>x. c *\<^sub>R x) ` (convex hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex hull (*\<^sub>R) c ` S = (*\<^sub>R) c ` (convex hull S)
[PROOF STEP]
using linear_scaleR
[PROOF STATE]
proof (prove)
using this:
linear ((*\<^sub>R) ?c)

goal (1 subgoal):
 1. convex hull (*\<^sub>R) c ` S = (*\<^sub>R) c ` (convex hull S)
[PROOF STEP]
by (rule convex_hull_linear_image [symmetric])


[STATEMENT]
lemma snd_safe_distance_iff_nonneg_D2:
  assumes "a\<^sub>e < a\<^sub>o"
  shows "s\<^sub>o - s\<^sub>e \<le> snd_safe_distance \<longleftrightarrow> 0 \<le> D2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
from snd_safe_distance_def assms pos_le_divide_eq[of "2 * (a\<^sub>o - a\<^sub>e)"]
[PROOF STATE]
proof (chain)
picking this:
snd_safe_distance = (v\<^sub>o - v\<^sub>e)\<^sup>2 / (2 * (a\<^sub>o - a\<^sub>e))
a\<^sub>e < a\<^sub>o
0 < 2 * (a\<^sub>o - a\<^sub>e) \<Longrightarrow> (?a \<le> ?b / (2 * (a\<^sub>o - a\<^sub>e))) = (?a * (2 * (a\<^sub>o - a\<^sub>e)) \<le> ?b)
[PROOF STEP]
have "s\<^sub>o - s\<^sub>e \<le> snd_safe_distance \<longleftrightarrow> (s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
snd_safe_distance = (v\<^sub>o - v\<^sub>e)\<^sup>2 / (2 * (a\<^sub>o - a\<^sub>e))
a\<^sub>e < a\<^sub>o
0 < 2 * (a\<^sub>o - a\<^sub>e) \<Longrightarrow> (?a \<le> ?b / (2 * (a\<^sub>o - a\<^sub>e))) = (?a * (2 * (a\<^sub>o - a\<^sub>e)) \<le> ?b)

goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = ((s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = ((s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2)

goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = ((s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2)

goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
have "... \<longleftrightarrow> 0 \<le> D2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2) = (0 \<le> D2)
[PROOF STEP]
by (auto simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
((s\<^sub>o - s\<^sub>e) * (2 * (a\<^sub>o - a\<^sub>e)) \<le> (v\<^sub>o - v\<^sub>e)\<^sup>2) = (0 \<le> D2)

goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)

goal (1 subgoal):
 1. (s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(s\<^sub>o - s\<^sub>e \<le> snd_safe_distance) = (0 \<le> D2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma invertible_imp_matrix_inv:
  assumes i: "invertible (A :: ('a :: {comm_ring_1,euclidean_semiring}) ^ 'b ^ 'b)"
  shows "matrix_inv A = (1 div (det A)) *k adjugate A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
let ?A = "adjugate A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
have "A ** ?A = det A *k mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ** adjugate A = det A *k mat (1::'a)
[PROOF STEP]
unfolding mult_adjugate_det
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (det A) = det A *k mat (1::'a)
[PROOF STEP]
by (simp add: scalar_mult_mat)
[PROOF STATE]
proof (state)
this:
A ** adjugate A = det A *k mat (1::'a)

goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
hence "matrix_inv A ** (A ** ?A) = matrix_inv A ** (det A *k mat 1)"
[PROOF STATE]
proof (prove)
using this:
A ** adjugate A = det A *k mat (1::'a)

goal (1 subgoal):
 1. matrix_inv A ** (A ** adjugate A) = matrix_inv A ** (det A *k mat (1::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_inv A ** (A ** adjugate A) = matrix_inv A ** (det A *k mat (1::'a))

goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
hence "?A = det A *k matrix_inv A"
[PROOF STATE]
proof (prove)
using this:
matrix_inv A ** (A ** adjugate A) = matrix_inv A ** (det A *k mat (1::'a))

goal (1 subgoal):
 1. adjugate A = det A *k matrix_inv A
[PROOF STEP]
unfolding matrix_mul_assoc matrix_inv_left[OF i] matrix_mul_lid scalar_mult_mat matrix_mul_mat
[PROOF STATE]
proof (prove)
using this:
adjugate A = det A * (1::'a) *k matrix_inv A

goal (1 subgoal):
 1. adjugate A = det A *k matrix_inv A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
adjugate A = det A *k matrix_inv A

goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
with i
[PROOF STATE]
proof (chain)
picking this:
invertible A
adjugate A = det A *k matrix_inv A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
invertible A
adjugate A = det A *k matrix_inv A

goal (1 subgoal):
 1. matrix_inv A = (1::'a) div det A *k adjugate A
[PROOF STEP]
by (metis (no_types, lifting) dvd_mult_div_cancel invertible_iff_is_unit
                 matrix_mul_assoc matrix_mul_mat matrix_mul_rid scalar_mult_mat mult.commute)
[PROOF STATE]
proof (state)
this:
matrix_inv A = (1::'a) div det A *k adjugate A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_update:
  fixes X v b
  assumes "finite (X :: 'a set)" "v \<notin> X"
  shows "
    card ((\<lambda>s. fmupd v b s) ` {s :: 'a state. fmdom' s = X})
    = card {s :: 'a state. fmdom' s = X}
  "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}
[PROOF STEP]
have "inj_on (\<lambda>s. fmupd v b s) {s :: 'a state. fmdom' s = X}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (fmupd v b) {s. fmdom' s = X}
[PROOF STEP]
using assms bool_update_inj
[PROOF STATE]
proof (prove)
using this:
finite X
v \<notin> X
\<lbrakk>finite ?X; ?v \<notin> ?X\<rbrakk> \<Longrightarrow> inj_on (fmupd ?v ?b) {s. fmdom' s = ?X}

goal (1 subgoal):
 1. inj_on (fmupd v b) {s. fmdom' s = X}
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
inj_on (fmupd v b) {s. fmdom' s = X}

goal (1 subgoal):
 1. card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inj_on (fmupd v b) {s. fmdom' s = X}
[PROOF STEP]
show
    "card ((\<lambda>s. fmupd v b s) ` {s :: 'a state. fmdom' s = X}) = card {s :: 'a state. fmdom' s = X}"
[PROOF STATE]
proof (prove)
using this:
inj_on (fmupd v b) {s. fmdom' s = X}

goal (1 subgoal):
 1. card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}
[PROOF STEP]
using card_image
[PROOF STATE]
proof (prove)
using this:
inj_on (fmupd v b) {s. fmdom' s = X}
inj_on ?f ?A \<Longrightarrow> card (?f ` ?A) = card ?A

goal (1 subgoal):
 1. card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (fmupd v b ` {s. fmdom' s = X}) = card {s. fmdom' s = X}

goal:
No subgoals!
[PROOF STEP]
qed

\<comment> \<open>NOTE added lemma.\<close>


[STATEMENT]
lemma uniformly_continuous_on_add[continuous_intros]:
  fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
  assumes "uniformly_continuous_on s f"
    and "uniformly_continuous_on s g"
  shows "uniformly_continuous_on s (\<lambda>x. f x + g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniformly_continuous_on s (\<lambda>x. f x + g x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
uniformly_continuous_on s f
uniformly_continuous_on s g

goal (1 subgoal):
 1. uniformly_continuous_on s (\<lambda>x. f x + g x)
[PROOF STEP]
unfolding uniformly_continuous_on_sequentially
[PROOF STATE]
proof (prove)
using this:
\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. dist (f (x n)) (f (y n))) \<longlonglongrightarrow> 0
\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. dist (g (x n)) (g (y n))) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. dist (f (x n) + g (x n)) (f (y n) + g (y n))) \<longlonglongrightarrow> 0
[PROOF STEP]
unfolding dist_norm tendsto_norm_zero_iff add_diff_add
[PROOF STATE]
proof (prove)
using this:
\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. f (x n) - f (y n)) \<longlonglongrightarrow> (0::'b)
\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. g (x n) - g (y n)) \<longlonglongrightarrow> (0::'b)

goal (1 subgoal):
 1. \<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. f (x n) - f (y n) + (g (x n) - g (y n))) \<longlonglongrightarrow> (0::'b)
[PROOF STEP]
by (auto intro: tendsto_add_zero)


[STATEMENT]
lemma lower_asymptotic_density_one_lim:
  assumes "lower_asymptotic_density A = 1"
  shows "(\<lambda>n. card(A \<inter> {..<n})/n) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. real (card (A \<inter> {..<n})) / real n) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (rule lower_asymptotic_density_eq_upper)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. lower_asymptotic_density A = 1
 2. upper_asymptotic_density A = 1
[PROOF STEP]
using assms lower_asymptotic_density_le_upper[of A] upper_asymptotic_density_in_01(2)[of A]
[PROOF STATE]
proof (prove)
using this:
lower_asymptotic_density A = 1
lower_asymptotic_density A \<le> upper_asymptotic_density A
upper_asymptotic_density A \<le> 1

goal (2 subgoals):
 1. lower_asymptotic_density A = 1
 2. upper_asymptotic_density A = 1
[PROOF STEP]
by auto


[STATEMENT]
theorem FNTT_inv_IFNTT:
  assumes "length numbers = n"
  shows "FNTT (IFNTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FNTT (IFNTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
by (simp add: FNTT_correct IFNTT_correct assms inv_ntt_correct length_INTT)


[STATEMENT]
lemma tanh_real_gt_neg1: "tanh (x :: real) > -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 < tanh x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. - 1 < tanh x
[PROOF STEP]
have "- cosh x < sinh x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - cosh x < sinh x
[PROOF STEP]
by (simp add: sinh_def cosh_def field_split_simps)
[PROOF STATE]
proof (state)
this:
- cosh x < sinh x

goal (1 subgoal):
 1. - 1 < tanh x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
- cosh x < sinh x

goal (1 subgoal):
 1. - 1 < tanh x
[PROOF STEP]
by (simp add: tanh_def field_simps)
[PROOF STATE]
proof (state)
this:
- 1 < tanh x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem polyfun_eq_const:
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
    shows  "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = k) \<longleftrightarrow> c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
have "(\<Sum>i\<le>n. c i * z^i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z^i) + k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. c i * z ^ i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) + k
[PROOF STEP]
by (induct n) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. c i * z ^ i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) + k

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * ?z2 ^ i) + k

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * ?z2 ^ i) + k
[PROOF STEP]
have "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = k) \<longleftrightarrow> (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z^i) = 0)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * ?z2 ^ i) + k

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) = (0::'a))

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) = (0::'a))

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
have "... \<longleftrightarrow>  c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) = (0::'a)) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
by (auto simp: polyfun_eq_0)
[PROOF STATE]
proof (state)
this:
(\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z ^ i) = (0::'a)) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))

goal (1 subgoal):
 1. (\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = k) = (c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = (0::'a)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hermitian_decomp_eigenvalues:
  assumes "hermitian_decomp A B U"
  shows "diag_mat B = (eigvals A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_mat B = eigvals A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
hermitian_decomp A B U

goal (1 subgoal):
 1. diag_mat B = eigvals A
[PROOF STEP]
unfolding hermitian_decomp_def
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dim_row B. B $$ (i, i) \<in> \<real>)

goal (1 subgoal):
 1. diag_mat B = eigvals A
[PROOF STEP]
by simp


[STATEMENT]
lemma rref_condition3:
  assumes r: "reduced_row_echelon_form A"
  shows "(\<forall>i. i<i+1 \<and> \<not> (is_zero_row i A) \<and> \<not> (is_zero_row (i+1) A) \<longrightarrow> ((LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ (i+1) $ n \<noteq> 0)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. i < i + (1::'c) \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row (i + (1::'c)) A \<longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'c)) $ n \<noteq> (0::'a))
[PROOF STEP]
using r
[PROOF STATE]
proof (prove)
using this:
reduced_row_echelon_form A

goal (1 subgoal):
 1. \<forall>i. i < i + (1::'c) \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row (i + (1::'c)) A \<longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'c)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding reduced_row_echelon_form_def'
[PROOF STATE]
proof (prove)
using this:
(\<forall>i. is_zero_row i A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row j A)) \<and> (\<forall>i. \<not> is_zero_row i A \<longrightarrow> A $ i $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (1::'a)) \<and> (\<forall>i. i < i + (1::'c) \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row (i + (1::'c)) A \<longrightarrow> (LEAST k. A $ i $ k \<noteq> (0::'a)) < (LEAST k. A $ (i + (1::'c)) $ k \<noteq> (0::'a))) \<and> (\<forall>i. \<not> is_zero_row i A \<longrightarrow> (\<forall>j. i \<noteq> j \<longrightarrow> A $ j $ (LEAST k. A $ i $ k \<noteq> (0::'a)) = (0::'a)))

goal (1 subgoal):
 1. \<forall>i. i < i + (1::'c) \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row (i + (1::'c)) A \<longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'c)) $ n \<noteq> (0::'a))
[PROOF STEP]
by simp


[STATEMENT]
lemma harm_altdef: "harm n = (\<Sum>k<n. inverse (of_nat (Suc k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. harm n = (\<Sum>k<n. inverse (of_nat (Suc k)))
[PROOF STEP]
unfolding harm_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 1..n. inverse (of_nat k)) = (\<Sum>k<n. inverse (of_nat (Suc k)))
[PROOF STEP]
by (induction n) simp_all


[STATEMENT]
lemma equivalent_objects_transitive [trans]:
    assumes "equivalent_objects a b" and "equivalent_objects b c"
    shows "equivalent_objects a c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
obtain f where f: "\<guillemotleft>f : a \<rightarrow> b\<guillemotright> \<and> equivalence_map f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. \<guillemotleft>f : a \<rightarrow> b\<guillemotright> \<and> equivalence_map f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms equivalent_objects_def
[PROOF STATE]
proof (prove)
using this:
equivalent_objects a b
equivalent_objects b c
equivalent_objects ?a ?b \<equiv> \<exists>f. \<guillemotleft>f : ?a \<rightarrow> ?b\<guillemotright> \<and> equivalence_map f

goal (1 subgoal):
 1. (\<And>f. \<guillemotleft>f : a \<rightarrow> b\<guillemotright> \<and> equivalence_map f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<guillemotleft>f : a \<rightarrow> b\<guillemotright> \<and> equivalence_map f

goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
obtain g where g: "\<guillemotleft>g : b \<rightarrow> c\<guillemotright> \<and> equivalence_map g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<guillemotleft>g : b \<rightarrow> c\<guillemotright> \<and> equivalence_map g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms equivalent_objects_def
[PROOF STATE]
proof (prove)
using this:
equivalent_objects a b
equivalent_objects b c
equivalent_objects ?a ?b \<equiv> \<exists>f. \<guillemotleft>f : ?a \<rightarrow> ?b\<guillemotright> \<and> equivalence_map f

goal (1 subgoal):
 1. (\<And>g. \<guillemotleft>g : b \<rightarrow> c\<guillemotright> \<and> equivalence_map g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<guillemotleft>g : b \<rightarrow> c\<guillemotright> \<and> equivalence_map g

goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
have "\<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)
[PROOF STEP]
using f g equivalence_maps_compose
[PROOF STATE]
proof (prove)
using this:
\<guillemotleft>f : a \<rightarrow> b\<guillemotright> \<and> equivalence_map f
\<guillemotleft>g : b \<rightarrow> c\<guillemotright> \<and> equivalence_map g
\<lbrakk>equivalence_map ?f; equivalence_map ?f'; src ?f' = trg ?f\<rbrakk> \<Longrightarrow> equivalence_map (?f' \<star> ?f)

goal (1 subgoal):
 1. \<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)

goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)

goal (1 subgoal):
 1. equivalent_objects a c
[PROOF STEP]
using equivalent_objects_def
[PROOF STATE]
proof (prove)
using this:
\<guillemotleft>g \<star> f : a \<rightarrow> c\<guillemotright> \<and> equivalence_map (g \<star> f)
equivalent_objects ?a ?b \<equiv> \<exists>f. \<guillemotleft>f : ?a \<rightarrow> ?b\<guillemotright> \<and> equivalence_map f

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Bseq_mult:
  fixes f g :: "nat \<Rightarrow> 'a::real_normed_field"
  assumes "Bseq f" and "Bseq g"
  shows "Bseq (\<lambda>x. f x * g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Bseq (\<lambda>x. f x * g x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Bseq (\<lambda>x. f x * g x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
Bseq f
Bseq g
[PROOF STEP]
obtain K1 K2 where K: "norm (f x) \<le> K1" "K1 > 0" "norm (g x) \<le> K2" "K2 > 0"
    for x
[PROOF STATE]
proof (prove)
using this:
Bseq f
Bseq g

goal (1 subgoal):
 1. (\<And>K1 K2. \<lbrakk>\<And>x. norm (f x) \<le> K1; 0 < K1; \<And>x. norm (g x) \<le> K2; 0 < K2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding Bseq_def
[PROOF STATE]
proof (prove)
using this:
\<exists>K>0. \<forall>n. norm (f n) \<le> K
\<exists>K>0. \<forall>n. norm (g n) \<le> K

goal (1 subgoal):
 1. (\<And>K1 K2. \<lbrakk>\<And>x. norm (f x) \<le> K1; 0 < K1; \<And>x. norm (g x) \<le> K2; 0 < K2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
norm (f ?x) \<le> K1
0 < K1
norm (g ?x) \<le> K2
0 < K2

goal (1 subgoal):
 1. Bseq (\<lambda>x. f x * g x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (f ?x) \<le> K1
0 < K1
norm (g ?x) \<le> K2
0 < K2
[PROOF STEP]
have "norm (f x * g x) \<le> K1 * K2" for x
[PROOF STATE]
proof (prove)
using this:
norm (f ?x) \<le> K1
0 < K1
norm (g ?x) \<le> K2
0 < K2

goal (1 subgoal):
 1. norm (f x * g x) \<le> K1 * K2
[PROOF STEP]
by (auto simp: norm_mult intro!: mult_mono)
[PROOF STATE]
proof (state)
this:
norm (f ?x * g ?x) \<le> K1 * K2

goal (1 subgoal):
 1. Bseq (\<lambda>x. f x * g x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (f ?x * g ?x) \<le> K1 * K2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (f ?x * g ?x) \<le> K1 * K2

goal (1 subgoal):
 1. Bseq (\<lambda>x. f x * g x)
[PROOF STEP]
by (rule BseqI')
[PROOF STATE]
proof (state)
this:
Bseq (\<lambda>x. f x * g x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transpose_matrix_add: "transpose_matrix ((A::('a::monoid_add) matrix)+B) = transpose_matrix A + transpose_matrix B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transpose_matrix (A + B) = transpose_matrix A + transpose_matrix B
[PROOF STEP]
by (simp add: plus_matrix_def transpose_combine_matrix)


[STATEMENT]
lemma tendsto_ln_powr_over_powr:
  assumes "(a::real) > 0" "b > 0"
  shows   "((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
have "eventually (\<lambda>x. ln x powr a / x powr b = (ln x / x powr (b/a)) powr a) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a
[PROOF STEP]
using assms eventually_gt_at_top[of "1::real"]
[PROOF STATE]
proof (prove)
using this:
0 < a
0 < b
eventually ((<) 1) at_top

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a
[PROOF STEP]
by (elim eventually_mono) (simp add: powr_divide powr_powr)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a

goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a

goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
have "eventually (\<lambda>x. 0 < ln x / x powr (b / a)) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. 0 < ln x / x powr (b / a)
[PROOF STEP]
using eventually_gt_at_top[of "1::real"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 1) at_top

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. 0 < ln x / x powr (b / a)
[PROOF STEP]
by (elim eventually_mono) simp
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. 0 < ln x / x powr (b / a)

goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < a
0 < b
\<forall>\<^sub>F x in at_top. 0 < ln x / x powr (b / a)
[PROOF STEP]
have "((\<lambda>x. (ln x / x powr (b/a)) powr a) \<longlongrightarrow> 0) at_top"
[PROOF STATE]
proof (prove)
using this:
0 < a
0 < b
\<forall>\<^sub>F x in at_top. 0 < ln x / x powr (b / a)

goal (1 subgoal):
 1. ((\<lambda>x. (ln x / x powr (b / a)) powr a) \<longlongrightarrow> 0) at_top
[PROOF STEP]
by (intro tendsto_zero_powrI tendsto_ln_over_powr) (simp_all add: eventually_mono)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. (ln x / x powr (b / a)) powr a) \<longlongrightarrow> 0) at_top

goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a
((\<lambda>x. (ln x / x powr (b / a)) powr a) \<longlongrightarrow> 0) at_top
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. ln x powr a / x powr b = (ln x / x powr (b / a)) powr a
((\<lambda>x. (ln x / x powr (b / a)) powr a) \<longlongrightarrow> 0) at_top

goal (1 subgoal):
 1. ((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top
[PROOF STEP]
by (subst tendsto_cong) simp_all
[PROOF STATE]
proof (state)
this:
((\<lambda>x. ln x powr a / x powr b) \<longlongrightarrow> 0) at_top

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Ints_scalar_prod:
  "v \<in> carrier_vec n \<Longrightarrow> w \<in> carrier_vec n
   \<Longrightarrow> (\<And> i. i < n \<Longrightarrow> v $ i \<in> \<int>) \<Longrightarrow> (\<And> i. i < n \<Longrightarrow> w $ i \<in> \<int>) \<Longrightarrow> v \<bullet> w \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>v \<in> carrier_vec n; w \<in> carrier_vec n; \<And>i. i < n \<Longrightarrow> v $ i \<in> \<int>; \<And>i. i < n \<Longrightarrow> w $ i \<in> \<int>\<rbrakk> \<Longrightarrow> v \<bullet> w \<in> \<int>
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>v \<in> carrier_vec n; w \<in> carrier_vec n; \<And>i. i < n \<Longrightarrow> v $ i \<in> \<int>; \<And>i. i < n \<Longrightarrow> w $ i \<in> \<int>\<rbrakk> \<Longrightarrow> (\<Sum>i = 0..<dim_vec w. v $ i * w $ i) \<in> \<int>
[PROOF STEP]
by (intro Ints_sum Ints_mult, auto)


[STATEMENT]
lemma dist_riemann_sphere_sym:
  shows "dist_riemann_sphere' M1 M2 = dist_riemann_sphere' M2 M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_riemann_sphere' M1 M2 = dist_riemann_sphere' M2 M1
[PROOF STEP]
proof transfer
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>M1 M2. \<lbrakk>M1 \<in> unit_sphere; M2 \<in> unit_sphere\<rbrakk> \<Longrightarrow> dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1
[PROOF STEP]
fix M1 M2 :: R3
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>M1 M2. \<lbrakk>M1 \<in> unit_sphere; M2 \<in> unit_sphere\<rbrakk> \<Longrightarrow> dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1
[PROOF STEP]
obtain x1 y1 z1 x2 y2 z2 where MM: "(x1, y1, z1) = M1" "(x2, y2, z2) = M2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x1 y1 z1 x2 y2 z2. \<lbrakk>(x1, y1, z1) = M1; (x2, y2, z2) = M2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases "M1", cases "M2", auto)
[PROOF STATE]
proof (state)
this:
(x1, y1, z1) = M1
(x2, y2, z2) = M2

goal (1 subgoal):
 1. \<And>M1 M2. \<lbrakk>M1 \<in> unit_sphere; M2 \<in> unit_sphere\<rbrakk> \<Longrightarrow> dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1
[PROOF STEP]
show "dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1
[PROOF STEP]
using norm_minus_cancel[of "(x1 - x2, y1 - y2, z1 - z2)"] MM[symmetric]
[PROOF STATE]
proof (prove)
using this:
norm (- (x1 - x2, y1 - y2, z1 - z2)) = norm (x1 - x2, y1 - y2, z1 - z2)
M1 = (x1, y1, z1)
M2 = (x2, y2, z2)

goal (1 subgoal):
 1. dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dist_riemann_sphere_r3 M1 M2 = dist_riemann_sphere_r3 M2 M1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem ln_lower_9_eq: "0 < x \<Longrightarrow>
      ln_lower_9 x = (1/30)*(6 + 481*x + 1881*x^2 + 1281*x^3 + 131*x^4)*(x - 1) /
                     (x*(5 + 40*x + 60*x^2 + 20*x^3 + x^4))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> ln_lower_9 x = 1 / 30 * (6 + 481 * x + 1881 * x\<^sup>2 + 1281 * x ^ 3 + 131 * x ^ 4) * (x - 1) / (x * (5 + 40 * x + 60 * x\<^sup>2 + 20 * x ^ 3 + x ^ 4))
[PROOF STEP]
unfolding ln_lower_9_def ln_upper_9_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> - ((6 * inverse x ^ 4 + 481 * inverse x ^ 3 + 1881 * (inverse x)\<^sup>2 + 1281 * inverse x + 131) * (inverse x - 1) / (30 * (5 * inverse x ^ 4 + 40 * inverse x ^ 3 + 60 * (inverse x)\<^sup>2 + 20 * inverse x + 1))) = 1 / 30 * (6 + 481 * x + 1881 * x\<^sup>2 + 1281 * x ^ 3 + 131 * x ^ 4) * (x - 1) / (x * (5 + 40 * x + 60 * x\<^sup>2 + 20 * x ^ 3 + x ^ 4))
[PROOF STEP]
by (simp add: zero_less_mult_iff add_pos_pos dual_order.strict_implies_not_eq divide_simps)
     algebra


[STATEMENT]
lemma pochhammer_absorb_comp: "(r - of_nat k) * pochhammer (- r) k = r * pochhammer (-r + 1) k"
  (is "?lhs = ?rhs")
  for r :: "'a::comm_ring_1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
have "?lhs = - pochhammer (- r) (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = - pochhammer (- r) (Suc k)
[PROOF STEP]
by (subst pochhammer_rec') (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(r - of_nat k) * pochhammer (- r) k = - pochhammer (- r) (Suc k)

goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(r - of_nat k) * pochhammer (- r) k = - pochhammer (- r) (Suc k)

goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
have "\<dots> = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - pochhammer (- r) (Suc k) = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
by (subst pochhammer_rec) simp
[PROOF STATE]
proof (state)
this:
- pochhammer (- r) (Suc k) = r * pochhammer (- r + (1::'a)) k

goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k

goal (1 subgoal):
 1. (r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(r - of_nat k) * pochhammer (- r) k = r * pochhammer (- r + (1::'a)) k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prime_factors_gcd [simp]:
  "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> prime_factors (gcd a b) =
     prime_factors a \<inter> prime_factors b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<noteq> (0::'a); b \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> prime_factors (gcd a b) = prime_factors a \<inter> prime_factors b
[PROOF STEP]
by (subst prime_factorization_gcd) auto


[STATEMENT]
lemma exp_integer_2pi_plus1:
  assumes "n \<in> \<int>"
  shows "exp(((2 * n + 1) * pi) * \<i>) = - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
n \<in> \<int>
[PROOF STEP]
obtain n' where [simp]: "n = of_int n'"
[PROOF STATE]
proof (prove)
using this:
n \<in> \<int>

goal (1 subgoal):
 1. (\<And>n'. n = real_of_int n' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: Ints_def)
[PROOF STATE]
proof (state)
this:
n = real_of_int n'

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
have "exp(((2 * n + 1) * pi) * \<i>) = exp (pi * \<i>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = exp (complex_of_real pi * \<i>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n \<in> \<int>

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = exp (complex_of_real pi * \<i>)
[PROOF STEP]
by (subst exp_eq) (auto intro!: exI[of _ n'] simp: algebra_simps)
[PROOF STATE]
proof (state)
this:
exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = exp (complex_of_real pi * \<i>)

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = exp (complex_of_real pi * \<i>)

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
have "\<dots> = - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (complex_of_real pi * \<i>) = - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
exp (complex_of_real pi * \<i>) = - 1

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1

goal (1 subgoal):
 1. exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
exp (complex_of_real ((2 * n + 1) * pi) * \<i>) = - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem c_card_is_pr: "c_card \<in> PrimRec1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
define g :: "nat \<Rightarrow> nat" where "g x = 1" for x
[PROOF STATE]
proof (state)
this:
g ?x = 1

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
have g_is_pr: "g \<in> PrimRec1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<in> PrimRec1
[PROOF STEP]
by (unfold g_def, rule const_is_pr)
[PROOF STATE]
proof (state)
this:
g \<in> PrimRec1

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
have "c_card = (\<lambda> u. sum g (nat_to_set u))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_card = (\<lambda>u. sum g (nat_to_set u))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. c_card u = sum g (nat_to_set u)
[PROOF STEP]
fix u
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. c_card u = sum g (nat_to_set u)
[PROOF STEP]
show "c_card u = sum g (nat_to_set u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_card u = sum g (nat_to_set u)
[PROOF STEP]
by (unfold c_card_def, unfold g_def, rule card_eq_sum)
[PROOF STATE]
proof (state)
this:
c_card u = sum g (nat_to_set u)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
c_card = (\<lambda>u. sum g (nat_to_set u))

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
c_card = (\<lambda>u. sum g (nat_to_set u))

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
from g_is_pr
[PROOF STATE]
proof (chain)
picking this:
g \<in> PrimRec1
[PROOF STEP]
have "(\<lambda> u. sum g (nat_to_set u)) \<in> PrimRec1"
[PROOF STATE]
proof (prove)
using this:
g \<in> PrimRec1

goal (1 subgoal):
 1. (\<lambda>u. sum g (nat_to_set u)) \<in> PrimRec1
[PROOF STEP]
by (rule sum_is_pr)
[PROOF STATE]
proof (state)
this:
(\<lambda>u. sum g (nat_to_set u)) \<in> PrimRec1

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
c_card = (\<lambda>u. sum g (nat_to_set u))
(\<lambda>u. sum g (nat_to_set u)) \<in> PrimRec1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c_card = (\<lambda>u. sum g (nat_to_set u))
(\<lambda>u. sum g (nat_to_set u)) \<in> PrimRec1

goal (1 subgoal):
 1. c_card \<in> PrimRec1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c_card \<in> PrimRec1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma degree_polyadd:
  fixes p::"'a::{plus,zero} poly"
  assumes np: "isnpolyh p n0"
    and nq: "isnpolyh q n1"
  shows "degree (p +\<^sub>p q) \<le> max (degree p) (degree q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Polynomial_Expression.degree (p +\<^sub>p q) \<le> max (Polynomial_Expression.degree p) (Polynomial_Expression.degree q)
[PROOF STEP]
using degreen_polyadd[OF np nq, where m= "0"]
[PROOF STATE]
proof (prove)
using this:
0 \<le> max n0 n1 \<Longrightarrow> degreen (p +\<^sub>p q) 0 \<le> max (degreen p 0) (degreen q 0)

goal (1 subgoal):
 1. Polynomial_Expression.degree (p +\<^sub>p q) \<le> max (Polynomial_Expression.degree p) (Polynomial_Expression.degree q)
[PROOF STEP]
by (simp add: degree_eq_degreen0)