[STATEMENT]
theorem Digamma_of_nat:
  "Digamma (of_nat (Suc n) :: 'a :: {real_normed_field,banach}) = harm n - euler_mascheroni"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc n)) = harm n - euler_mascheroni

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
have "Digamma (of_nat (Suc (Suc n)) :: 'a) = Digamma (of_nat (Suc n) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma (of_nat (Suc (Suc n))) = Digamma (of_nat (Suc n) + (1::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc (Suc n))) = Digamma (of_nat (Suc n) + (1::'a))

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc (Suc n))) = Digamma (of_nat (Suc n) + (1::'a))

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
have "\<dots> = Digamma (of_nat (Suc n)) + inverse (of_nat (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma (of_nat (Suc n) + (1::'a)) = Digamma (of_nat (Suc n)) + inverse (of_nat (Suc n))
[PROOF STEP]
by (subst Digamma_plus1) (simp_all add: inverse_eq_divide del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc n) + (1::'a)) = Digamma (of_nat (Suc n)) + inverse (of_nat (Suc n))

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc n) + (1::'a)) = Digamma (of_nat (Suc n)) + inverse (of_nat (Suc n))

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
have "Digamma (of_nat (Suc n) :: 'a) = harm n - euler_mascheroni "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni
[PROOF STEP]
by (rule Suc)
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc n)) = harm n - euler_mascheroni

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc n)) = harm n - euler_mascheroni

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
have "\<dots> + inverse (of_nat (Suc n)) = harm (Suc n) - euler_mascheroni"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. harm n - euler_mascheroni + inverse (of_nat (Suc n)) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
by (simp add: harm_Suc)
[PROOF STATE]
proof (state)
this:
harm n - euler_mascheroni + inverse (of_nat (Suc n)) = harm (Suc n) - euler_mascheroni

goal (2 subgoals):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
 2. \<And>n. Digamma (of_nat (Suc n)) = harm n - euler_mascheroni \<Longrightarrow> Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni

goal (1 subgoal):
 1. Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Digamma (of_nat (Suc (Suc n))) = harm (Suc n) - euler_mascheroni

goal (1 subgoal):
 1. Digamma (of_nat (Suc 0)) = harm 0 - euler_mascheroni
[PROOF STEP]
qed (simp add: harm_def)


[STATEMENT]
lemma mset_set_Diff:
  assumes "finite A" "B \<subseteq> A"
  shows  "mset_set (A - B) = mset_set A - mset_set B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
finite A
B \<subseteq> A
[PROOF STEP]
have "mset_set ((A - B) \<union> B) = mset_set (A - B) + mset_set B"
[PROOF STATE]
proof (prove)
using this:
finite A
B \<subseteq> A

goal (1 subgoal):
 1. mset_set (A - B \<union> B) = mset_set (A - B) + mset_set B
[PROOF STEP]
by (intro mset_set_Union) (auto dest: finite_subset)
[PROOF STATE]
proof (state)
this:
mset_set (A - B \<union> B) = mset_set (A - B) + mset_set B

goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mset_set (A - B \<union> B) = mset_set (A - B) + mset_set B

goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
finite A
B \<subseteq> A
[PROOF STEP]
have "A - B \<union> B = A"
[PROOF STATE]
proof (prove)
using this:
finite A
B \<subseteq> A

goal (1 subgoal):
 1. A - B \<union> B = A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A - B \<union> B = A

goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mset_set A = mset_set (A - B) + mset_set B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mset_set A = mset_set (A - B) + mset_set B

goal (1 subgoal):
 1. mset_set (A - B) = mset_set A - mset_set B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mset_set (A - B) = mset_set A - mset_set B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prime_dvd_choose:
  assumes "0 < k" "k < p" "prime p"
  shows "p dvd (p choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "k \<le> p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> p
[PROOF STEP]
using \<open>k < p\<close>
[PROOF STATE]
proof (prove)
using this:
k < p

goal (1 subgoal):
 1. k \<le> p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<le> p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "p dvd fact p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd fact p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < k
k < p
prime p

goal (1 subgoal):
 1. p dvd fact p
[PROOF STEP]
by (simp add: prime_dvd_fact_iff)
[PROOF STATE]
proof (state)
this:
p dvd fact p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd fact p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "\<not> p dvd fact k * fact (p - k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> p dvd fact k * fact (p - k)
[PROOF STEP]
unfolding prime_dvd_mult_iff[OF assms(3)] prime_dvd_fact_iff[OF assms(3)]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (p \<le> k \<or> p \<le> p - k)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < k
k < p
prime p

goal (1 subgoal):
 1. \<not> (p \<le> k \<or> p \<le> p - k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd fact p
\<not> p dvd fact k * fact (p - k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p dvd fact p
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
unfolding binomial_fact_lemma[OF \<open>k \<le> p\<close>, symmetric]
[PROOF STATE]
proof (prove)
using this:
p dvd fact k * fact (p - k) * (p choose k)
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
using assms prime_dvd_multD
[PROOF STATE]
proof (prove)
using this:
p dvd fact k * fact (p - k) * (p choose k)
\<not> p dvd fact k * fact (p - k)
0 < k
k < p
prime p
\<lbrakk>prime ?p; ?p dvd ?a * ?b\<rbrakk> \<Longrightarrow> ?p dvd ?a \<or> ?p dvd ?b

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p dvd p choose k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_integral_Un:
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
  assumes "A \<inter> B = {}"
  and "set_integrable M A f"
  and "set_integrable M B f"
shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_lebesgue_integral M (A \<union> B) f = set_lebesgue_integral M A f + set_lebesgue_integral M B f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<inter> B = {}
set_integrable M A f
set_integrable M B f

goal (1 subgoal):
 1. set_lebesgue_integral M (A \<union> B) f = set_lebesgue_integral M A f + set_lebesgue_integral M B f
[PROOF STEP]
unfolding set_integrable_def set_lebesgue_integral_def
[PROOF STATE]
proof (prove)
using this:
A \<inter> B = {}
integrable M (\<lambda>x. indicat_real A x *\<^sub>R f x)
integrable M (\<lambda>x. indicat_real B x *\<^sub>R f x)

goal (1 subgoal):
 1. LINT x|M. indicat_real (A \<union> B) x *\<^sub>R f x = (LINT x|M. indicat_real A x *\<^sub>R f x) + (LINT x|M. indicat_real B x *\<^sub>R f x)
[PROOF STEP]
by (auto simp add: indicator_union_arith indicator_inter_arith[symmetric] scaleR_add_left)


[STATEMENT]
theorem s1_1_th: "(\<lambda> y. (nat_to_pr n) (c_pair x y)) = nat_to_pr (s1_1 n x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
have "nat_to_pr (s1_1 n x) = nat_to_pr (comp_by_index n (index_of_c_pair_n x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_to_pr (s1_1 n x) = nat_to_pr (comp_by_index n (index_of_c_pair_n x))
[PROOF STEP]
by (simp add: s1_1_def)
[PROOF STATE]
proof (state)
this:
nat_to_pr (s1_1 n x) = nat_to_pr (comp_by_index n (index_of_c_pair_n x))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nat_to_pr (s1_1 n x) = nat_to_pr (comp_by_index n (index_of_c_pair_n x))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
have "\<dots> = (\<lambda> z. (nat_to_pr n) ((nat_to_pr (index_of_c_pair_n x)) z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_to_pr (comp_by_index n (index_of_c_pair_n x)) = (\<lambda>z. nat_to_pr n (nat_to_pr (index_of_c_pair_n x) z))
[PROOF STEP]
by (simp add: comp_by_index_main)
[PROOF STATE]
proof (state)
this:
nat_to_pr (comp_by_index n (index_of_c_pair_n x)) = (\<lambda>z. nat_to_pr n (nat_to_pr (index_of_c_pair_n x) z))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nat_to_pr (comp_by_index n (index_of_c_pair_n x)) = (\<lambda>z. nat_to_pr n (nat_to_pr (index_of_c_pair_n x) z))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
have "\<dots> = (\<lambda> z. (nat_to_pr n) ((\<lambda> u. c_pair x u) z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>z. nat_to_pr n (nat_to_pr (index_of_c_pair_n x) z)) = (\<lambda>z. nat_to_pr n (c_pair x z))
[PROOF STEP]
by (simp add: index_of_c_pair_n_main)
[PROOF STATE]
proof (state)
this:
(\<lambda>z. nat_to_pr n (nat_to_pr (index_of_c_pair_n x) z)) = (\<lambda>z. nat_to_pr n (c_pair x z))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nat_to_pr (s1_1 n x) = (\<lambda>z. nat_to_pr n (c_pair x z))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nat_to_pr (s1_1 n x) = (\<lambda>z. nat_to_pr n (c_pair x z))

goal (1 subgoal):
 1. (\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>y. nat_to_pr n (c_pair x y)) = nat_to_pr (s1_1 n x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_NleastTr:"\<lbrakk>a \<in> (A::nat set); \<not> (\<exists>m. m\<in>A \<and> (\<forall>x\<in>A. m \<le> x))\<rbrakk> \<Longrightarrow>
                        (ndec_seq A a n) \<le> (a - n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x)\<rbrakk> \<Longrightarrow> ndec_seq A a n \<le> a - n
[PROOF STEP]
apply (induct_tac n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x)\<rbrakk> \<Longrightarrow> ndec_seq A a 0 \<le> a - 0
 2. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
[PROOF STEP]
apply (frule_tac n = n in ndec_seqn1[of "a" "A"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
[PROOF STEP]
apply (subgoal_tac "ndec_seq A a n - 1 \<le> (a - n) - 1")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1; ndec_seq A a n - 1 \<le> a - n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
 2. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a n - 1 \<le> a - n - 1
[PROOF STEP]
prefer 2
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a n - 1 \<le> a - n - 1
 2. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1; ndec_seq A a n - 1 \<le> a - n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>a \<in> A; \<nexists>m. m \<in> A \<and> (\<forall>x\<in>A. m \<le> x); ndec_seq A a n \<le> a - n; ndec_seq A a (Suc n) \<le> ndec_seq A a n - 1; ndec_seq A a n - 1 \<le> a - n - 1\<rbrakk> \<Longrightarrow> ndec_seq A a (Suc n) \<le> a - Suc n
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma inner_axis_axis:
  "inner (axis i x) (axis j y) = (if i = j then inner x y else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner (axis i x) (axis j y) = (if i = j then inner x y else 0)
[PROOF STEP]
by (simp add: inner_vec_def axis_def sum.neutral sum.remove [of _ j])


[STATEMENT]
lemma orthogonal_matrix2:
  fixes A::"real^'n^'n"
  shows "orthogonal_matrix A = ((pairwise orthogonal (columns A)) \<and> (\<forall>i. norm (column i A) = 1) \<and>
  (card (columns A) = ncols A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_matrix A = (pairwise orthogonal (columns A) \<and> (\<forall>i. norm (column i A) = 1) \<and> card (columns A) = ncols A)
[PROOF STEP]
using orthogonal_matrix_intro[of A]
    orthogonal_matrix_is_orthogonal[of A]
    orthogonal_matrix_norm[of A]
    orthogonal_matrix_card[of A]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>pairwise orthogonal (columns A); \<forall>i. norm (column i A) = 1; card (columns A) = ncols A\<rbrakk> \<Longrightarrow> orthogonal_matrix A
orthogonal_matrix A \<Longrightarrow> pairwise orthogonal (columns A)
orthogonal_matrix A \<Longrightarrow> norm (column ?i A) = 1
orthogonal_matrix A \<Longrightarrow> card (columns A) = ncols A

goal (1 subgoal):
 1. orthogonal_matrix A = (pairwise orthogonal (columns A) \<and> (\<forall>i. norm (column i A) = 1) \<and> card (columns A) = ncols A)
[PROOF STEP]
by auto


[STATEMENT]
lemma zmod_eq_diff_mod_0_conv: "
  ((a::int) mod m = b mod m) = ((b - a) mod m = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a mod m = b mod m) = ((b - a) mod m = 0)
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. a mod m = b mod m \<Longrightarrow> (b - a) mod m = 0
 2. (b - a) mod m = 0 \<Longrightarrow> a mod m = b mod m
[PROOF STEP]
apply (rule zmod_eq_imp_diff_mod_0, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (b - a) mod m = 0 \<Longrightarrow> a mod m = b mod m
[PROOF STEP]
apply (rule zdiff_mod_0_imp_mod_eq, assumption)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma autonomous_linear_sol_is_exp:
  assumes "D X = (\<lambda>t. A *\<^sub>V X t) on {t\<^sub>0--t}" and "X t\<^sub>0 = s"
  shows "X t = exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X t = exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V s
[PROOF STEP]
apply(rule sq_mtx_unique_sol_autonomous_affine[of "\<lambda>s. {t\<^sub>0--t}" _ t X A 0])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. is_interval {t\<^sub>0--t}
 2. t \<in> {t\<^sub>0--t}
 3. X \<in> Sols (\<lambda>t s. A *\<^sub>V s + 0) (\<lambda>s. {t\<^sub>0--t}) UNIV ?t\<^sub>0 ?s
 4. (\<lambda>a. exp ((a - t\<^sub>0) *\<^sub>R A) *\<^sub>V s) \<in> Sols (\<lambda>t s. A *\<^sub>V s + 0) (\<lambda>s. {t\<^sub>0--t}) UNIV ?t\<^sub>0 ?s
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
 D X = (\<lambda>t. A *\<^sub>V X t) on {t\<^sub>0--t}
X t\<^sub>0 = s

goal (4 subgoals):
 1. is_interval {t\<^sub>0--t}
 2. t \<in> {t\<^sub>0--t}
 3. X \<in> Sols (\<lambda>t s. A *\<^sub>V s + 0) (\<lambda>s. {t\<^sub>0--t}) UNIV ?t\<^sub>0 ?s
 4. (\<lambda>a. exp ((a - t\<^sub>0) *\<^sub>R A) *\<^sub>V s) \<in> Sols (\<lambda>t s. A *\<^sub>V s + 0) (\<lambda>s. {t\<^sub>0--t}) UNIV ?t\<^sub>0 ?s
[PROOF STEP]
apply(simp_all add: ivp_sols_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>i.  D (\<lambda>x. X x $ i) = (\<lambda>x. A *\<^sub>V X x $ i) on {t\<^sub>0--t}; X t\<^sub>0 = s\<rbrakk> \<Longrightarrow> X ?t\<^sub>0 = ?s \<and> ?t\<^sub>0 \<in> {t\<^sub>0--t}
 2. \<lbrakk>\<forall>i.  D (\<lambda>x. X x $ i) = (\<lambda>x. A *\<^sub>V X x $ i) on {t\<^sub>0--t}; X t\<^sub>0 = s\<rbrakk> \<Longrightarrow> (\<forall>i.  D (\<lambda>x. exp ((x - t\<^sub>0) *\<^sub>R A) *\<^sub>V s $ i) = (\<lambda>x. A *\<^sub>V (exp ((x - t\<^sub>0) *\<^sub>R A) *\<^sub>V s) $ i) on {t\<^sub>0--t}) \<and> exp ((?t\<^sub>0 - t\<^sub>0) *\<^sub>R A) *\<^sub>V s = ?s \<and> ?t\<^sub>0 \<in> {t\<^sub>0--t}
[PROOF STEP]
using has_vderiv_on_sq_mtx_linear
[PROOF STATE]
proof (prove)
using this:
 D (\<lambda>t. exp ((t - ?t\<^sub>0) *\<^sub>R ?A) *\<^sub>V ?s) = (\<lambda>t. ?A *\<^sub>V (exp ((t - ?t\<^sub>0) *\<^sub>R ?A) *\<^sub>V ?s)) on {?t\<^sub>0--?t}

goal (2 subgoals):
 1. \<lbrakk>\<forall>i.  D (\<lambda>x. X x $ i) = (\<lambda>x. A *\<^sub>V X x $ i) on {t\<^sub>0--t}; X t\<^sub>0 = s\<rbrakk> \<Longrightarrow> X ?t\<^sub>0 = ?s \<and> ?t\<^sub>0 \<in> {t\<^sub>0--t}
 2. \<lbrakk>\<forall>i.  D (\<lambda>x. X x $ i) = (\<lambda>x. A *\<^sub>V X x $ i) on {t\<^sub>0--t}; X t\<^sub>0 = s\<rbrakk> \<Longrightarrow> (\<forall>i.  D (\<lambda>x. exp ((x - t\<^sub>0) *\<^sub>R A) *\<^sub>V s $ i) = (\<lambda>x. A *\<^sub>V (exp ((x - t\<^sub>0) *\<^sub>R A) *\<^sub>V s) $ i) on {t\<^sub>0--t}) \<and> exp ((?t\<^sub>0 - t\<^sub>0) *\<^sub>R A) *\<^sub>V s = ?s \<and> ?t\<^sub>0 \<in> {t\<^sub>0--t}
[PROOF STEP]
by force+


[STATEMENT]
lemma span_not_univ_subset_hyperplane:
  fixes S :: "'a::euclidean_space set"
  assumes SU: "span S \<noteq> UNIV"
  shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'a) \<and> span S \<subseteq> {x. a \<bullet> x = 0}
[PROOF STEP]
using span_not_univ_orthogonal[OF SU]
[PROOF STATE]
proof (prove)
using this:
\<exists>a. a \<noteq> (0::'a) \<and> (\<forall>x\<in>span S. a \<bullet> x = 0)

goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'a) \<and> span S \<subseteq> {x. a \<bullet> x = 0}
[PROOF STEP]
by auto


[STATEMENT]
lemma card_UNIV_set: "CARD('a set) = (if CARD('a) = 0 then 0 else 2 ^ CARD('a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD('a set) = (if CARD('a) = 0 then 0 else 2 ^ CARD('a))
[PROOF STEP]
by(simp add: card_eq_0_iff card_Pow flip: Pow_UNIV)


[STATEMENT]
lemma prime_dvd_choose:
  assumes "0 < k" "k < p" "prime p"
  shows "p dvd (p choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "k \<le> p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> p
[PROOF STEP]
using \<open>k < p\<close>
[PROOF STATE]
proof (prove)
using this:
k < p

goal (1 subgoal):
 1. k \<le> p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<le> p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "p dvd fact p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd fact p
[PROOF STEP]
using \<open>prime p\<close>
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. p dvd fact p
[PROOF STEP]
by (simp add: prime_dvd_fact_iff)
[PROOF STATE]
proof (state)
this:
p dvd fact p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd fact p

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
have "\<not> p dvd fact k * fact (p - k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> p dvd fact k * fact (p - k)
[PROOF STEP]
unfolding prime_dvd_mult_iff[OF \<open>prime p\<close>] prime_dvd_fact_iff[OF \<open>prime p\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (p \<le> k \<or> p \<le> p - k)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < k
k < p
prime p

goal (1 subgoal):
 1. \<not> (p \<le> k \<or> p \<le> p - k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd fact p
\<not> p dvd fact k * fact (p - k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p dvd fact p
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
unfolding binomial_fact_lemma[OF \<open>k \<le> p\<close>, symmetric]
[PROOF STATE]
proof (prove)
using this:
p dvd fact k * fact (p - k) * (p choose k)
\<not> p dvd fact k * fact (p - k)

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
using assms prime_dvd_multD
[PROOF STATE]
proof (prove)
using this:
p dvd fact k * fact (p - k) * (p choose k)
\<not> p dvd fact k * fact (p - k)
0 < k
k < p
prime p
\<lbrakk>prime ?p; ?p dvd ?a * ?b\<rbrakk> \<Longrightarrow> ?p dvd ?a \<or> ?p dvd ?b

goal (1 subgoal):
 1. p dvd p choose k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p dvd p choose k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem sum_of_naturals:
  "2 * (\<Sum>i::nat=0..n. i) = n * (n + 1)"
  (is "?P n" is "?S n = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<Sum> {0..n} = n * (n + 1)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 2 * \<Sum> {0..0} = 0 * (0 + 1)
 2. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
show "?P 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<Sum> {0..0} = 0 * (0 + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..0} = 0 * (0 + 1)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
have "?S (n + 1) = ?S n + 2 * (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<Sum> {0..n + 1} = 2 * \<Sum> {0..n} + 2 * (n + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n + 1} = 2 * \<Sum> {0..n} + 2 * (n + 1)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n + 1} = 2 * \<Sum> {0..n} + 2 * (n + 1)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
assume "?S n = n * (n + 1)"
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n} = n * (n + 1)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..n} = n * (n + 1)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
have "\<dots> + 2 * (n + 1) = (n + 1) * (n + 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n * (n + 1) + 2 * (n + 1) = (n + 1) * (n + 2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n * (n + 1) + 2 * (n + 1) = (n + 1) * (n + 2)

goal (1 subgoal):
 1. \<And>n. 2 * \<Sum> {0..n} = n * (n + 1) \<Longrightarrow> 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * \<Sum> {0..n + 1} = (n + 1) * (n + 2)
[PROOF STEP]
show "?P (Suc n)"
[PROOF STATE]
proof (prove)
using this:
2 * \<Sum> {0..n + 1} = (n + 1) * (n + 2)

goal (1 subgoal):
 1. 2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * \<Sum> {0..Suc n} = Suc n * (Suc n + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma index_mat_four_block[simp]:
  "i < dim_row A + dim_row D \<Longrightarrow> j < dim_col A + dim_col D \<Longrightarrow> four_block_mat A B C D $$ (i,j)
  = (if i < dim_row A then
      if j < dim_col A then A $$ (i,j) else B $$ (i,j - dim_col A)
      else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A))"
  "dim_row (four_block_mat A B C D) = dim_row A + dim_row D"
  "dim_col (four_block_mat A B C D) = dim_col A + dim_col D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>i < dim_row A + dim_row D; j < dim_col A + dim_col D\<rbrakk> \<Longrightarrow> four_block_mat A B C D $$ (i, j) = (if i < dim_row A then if j < dim_col A then A $$ (i, j) else B $$ (i, j - dim_col A) else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A))) &&& dim_row (four_block_mat A B C D) = dim_row A + dim_row D &&& dim_col (four_block_mat A B C D) = dim_col A + dim_col D
[PROOF STEP]
unfolding four_block_mat_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>i < dim_row A + dim_row D; j < dim_col A + dim_col D\<rbrakk> \<Longrightarrow> mat (dim_row A + dim_row D) (dim_col A + dim_col D) (\<lambda>(i, j). if i < dim_row A then if j < dim_col A then A $$ (i, j) else B $$ (i, j - dim_col A) else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A)) $$ (i, j) = (if i < dim_row A then if j < dim_col A then A $$ (i, j) else B $$ (i, j - dim_col A) else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A))) &&& dim_row (mat (dim_row A + dim_row D) (dim_col A + dim_col D) (\<lambda>(i, j). if i < dim_row A then if j < dim_col A then A $$ (i, j) else B $$ (i, j - dim_col A) else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A))) = dim_row A + dim_row D &&& dim_col (mat (dim_row A + dim_row D) (dim_col A + dim_col D) (\<lambda>(i, j). if i < dim_row A then if j < dim_col A then A $$ (i, j) else B $$ (i, j - dim_col A) else if j < dim_col A then C $$ (i - dim_row A, j) else D $$ (i - dim_row A, j - dim_col A))) = dim_col A + dim_col D
[PROOF STEP]
by auto


[STATEMENT]
lemma card_seqs [simp]: "card (seqs n) = 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (seqs n) = 2 ^ n
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card (seqs 0) = 2 ^ 0
 2. \<And>n. card (seqs n) = 2 ^ n \<Longrightarrow> card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
card (seqs n) = 2 ^ n

goal (2 subgoals):
 1. card (seqs 0) = 2 ^ 0
 2. \<And>n. card (seqs n) = 2 ^ n \<Longrightarrow> card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
have "card (seqs (Suc n)) = card ((#) True ` seqs n \<union> (#) False ` seqs n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (seqs (Suc n)) = card ((#) True ` seqs n \<union> (#) False ` seqs n)
[PROOF STEP]
by (auto simp: seqs_Suc)
[PROOF STATE]
proof (state)
this:
card (seqs (Suc n)) = card ((#) True ` seqs n \<union> (#) False ` seqs n)

goal (2 subgoals):
 1. card (seqs 0) = 2 ^ 0
 2. \<And>n. card (seqs n) = 2 ^ n \<Longrightarrow> card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (seqs (Suc n)) = card ((#) True ` seqs n \<union> (#) False ` seqs n)

goal (2 subgoals):
 1. card (seqs 0) = 2 ^ 0
 2. \<And>n. card (seqs n) = 2 ^ n \<Longrightarrow> card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
from Suc.IH
[PROOF STATE]
proof (chain)
picking this:
card (seqs n) = 2 ^ n
[PROOF STEP]
have "\<dots> = 2 ^ Suc n"
[PROOF STATE]
proof (prove)
using this:
card (seqs n) = 2 ^ n

goal (1 subgoal):
 1. card ((#) True ` seqs n \<union> (#) False ` seqs n) = 2 ^ Suc n
[PROOF STEP]
by (subst card_Un_disjoint) (auto simp: card_image)
[PROOF STATE]
proof (state)
this:
card ((#) True ` seqs n \<union> (#) False ` seqs n) = 2 ^ Suc n

goal (2 subgoals):
 1. card (seqs 0) = 2 ^ 0
 2. \<And>n. card (seqs n) = 2 ^ n \<Longrightarrow> card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
card (seqs (Suc n)) = 2 ^ Suc n

goal (1 subgoal):
 1. card (seqs (Suc n)) = 2 ^ Suc n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (seqs (Suc n)) = 2 ^ Suc n

goal (1 subgoal):
 1. card (seqs 0) = 2 ^ 0
[PROOF STEP]
qed auto


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

goal (2 subgoals):
 1. limsup (\<lambda>x. ereal (real (card (A \<inter> {..<x})) / real x)) \<le> ereal l
 2. ereal l \<le> liminf (\<lambda>x. ereal (real (card (A \<inter> {..<x})) / real x))
[PROOF STEP]
by auto


[STATEMENT]
lemma real_inverse_gt_one_lemma:
      "\<lbrakk> 0 < (a::real); a < 1 \<rbrakk> \<Longrightarrow> inverse a > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < a; a < 1\<rbrakk> \<Longrightarrow> 1 < inverse a
[PROOF STEP]
by (metis one_less_inverse_iff)


[STATEMENT]
theorem sum_of_squares:
  "6 * (\<Sum>i::nat=0..n. i^Suc (Suc 0)) = n * (n + 1) * (2 * n + 1)"
  (is "?P n" is "?S n = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 6 * (\<Sum>i = 0..0. i ^ Suc (Suc 0)) = 0 * (0 + 1) * (2 * 0 + 1)
 2. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
show "?P 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 6 * (\<Sum>i = 0..0. i ^ Suc (Suc 0)) = 0 * (0 + 1) * (2 * 0 + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..0. i ^ Suc (Suc 0)) = 0 * (0 + 1) * (2 * 0 + 1)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
have "?S (n + 1) = ?S n + 6 * (n + 1)^Suc (Suc 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 6 * (\<Sum>i = 0..n + 1. i ^ Suc (Suc 0)) = 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) + 6 * (n + 1) ^ Suc (Suc 0)
[PROOF STEP]
by (simp add: distrib)
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..n + 1. i ^ Suc (Suc 0)) = 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) + 6 * (n + 1) ^ Suc (Suc 0)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..n + 1. i ^ Suc (Suc 0)) = 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) + 6 * (n + 1) ^ Suc (Suc 0)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
assume "?S n = n * (n + 1) * (2 * n + 1)"
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
have "\<dots> + 6 * (n + 1)^Suc (Suc 0) =
      (n + 1) * (n + 2) * (2 * (n + 1) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n * (n + 1) * (2 * n + 1) + 6 * (n + 1) ^ Suc (Suc 0) = (n + 1) * (n + 2) * (2 * (n + 1) + 1)
[PROOF STEP]
by (simp add: distrib)
[PROOF STATE]
proof (state)
this:
n * (n + 1) * (2 * n + 1) + 6 * (n + 1) ^ Suc (Suc 0) = (n + 1) * (n + 2) * (2 * (n + 1) + 1)

goal (1 subgoal):
 1. \<And>n. 6 * (\<Sum>i = 0..n. i ^ Suc (Suc 0)) = n * (n + 1) * (2 * n + 1) \<Longrightarrow> 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
6 * (\<Sum>i = 0..n + 1. i ^ Suc (Suc 0)) = (n + 1) * (n + 2) * (2 * (n + 1) + 1)
[PROOF STEP]
show "?P (Suc n)"
[PROOF STATE]
proof (prove)
using this:
6 * (\<Sum>i = 0..n + 1. i ^ Suc (Suc 0)) = (n + 1) * (n + 2) * (2 * (n + 1) + 1)

goal (1 subgoal):
 1. 6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
6 * (\<Sum>i = 0..Suc n. i ^ Suc (Suc 0)) = Suc n * (Suc n + 1) * (2 * Suc n + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem heap_minimum:
  assumes
    "l < r"
    "is_heap (\<le>) heap l r"
  shows "heap l = Min_mset (arr_mset heap l r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. heap l = Min_mset (arr_mset heap l r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. heap l = Min_mset (arr_mset heap l r)
[PROOF STEP]
have "(\<forall>x \<in># (arr_mset heap l r). (heap l) \<le> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>#arr_mset heap l r. heap l \<le> x
[PROOF STEP]
using assms(2) heap_first_el_alt transp_le
[PROOF STATE]
proof (prove)
using this:
is_heap (\<le>) heap l r
\<lbrakk>transp ?cmp; is_heap ?cmp ?heap ?l ?r; ?x \<in># arr_mset ?heap ?l ?r; ?heap ?l \<noteq> ?x\<rbrakk> \<Longrightarrow> ?cmp (?heap ?l) ?x
transp (\<le>)

goal (1 subgoal):
 1. \<forall>x\<in>#arr_mset heap l r. heap l \<le> x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>#arr_mset heap l r. heap l \<le> x

goal (1 subgoal):
 1. heap l = Min_mset (arr_mset heap l r)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>#arr_mset heap l r. heap l \<le> x

goal (1 subgoal):
 1. heap l = Min_mset (arr_mset heap l r)
[PROOF STEP]
by (simp add: assms(1) dual_order.antisym)
[PROOF STATE]
proof (state)
this:
heap l = Min_mset (arr_mset heap l r)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem powerset_enum_correct: "set (map set (powerset_enum xs)) = Pow (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map set (powerset_enum xs)) = Pow (set xs)
[PROOF STEP]
proof(standard)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set (map set (powerset_enum xs)) \<subseteq> Pow (set xs)
 2. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
show "set (map set (powerset_enum xs)) \<subseteq> Pow (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map set (powerset_enum xs)) \<subseteq> Pow (set xs)
[PROOF STEP]
using filter_bool_list_not_elem
[PROOF STATE]
proof (prove)
using this:
?x \<notin> set ?xs \<Longrightarrow> ?x \<notin> set (filter_bool_list ?bs ?xs)

goal (1 subgoal):
 1. set (map set (powerset_enum xs)) \<subseteq> Pow (set xs)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
set (map set (powerset_enum xs)) \<subseteq> Pow (set xs)

goal (1 subgoal):
 1. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
have "\<And>x. x \<subseteq> set xs \<Longrightarrow> x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<subseteq> set xs \<Longrightarrow> x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}
[PROOF STEP]
unfolding image_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<subseteq> set xs \<Longrightarrow> x \<in> {y. \<exists>x\<in>{zs. length zs = length xs}. y = set (filter_bool_list x xs)}
[PROOF STEP]
using filter_bool_list_exist_length image_def
[PROOF STATE]
proof (prove)
using this:
?A \<subseteq> set ?xs \<Longrightarrow> \<exists>bs. length bs = length ?xs \<and> ?A = set (filter_bool_list bs ?xs)
?f ` ?A = {y. \<exists>x\<in>?A. y = ?f x}

goal (1 subgoal):
 1. \<And>x. x \<subseteq> set xs \<Longrightarrow> x \<in> {y. \<exists>x\<in>{zs. length zs = length xs}. y = set (filter_bool_list x xs)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?x \<subseteq> set xs \<Longrightarrow> ?x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}

goal (1 subgoal):
 1. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?x \<subseteq> set xs \<Longrightarrow> ?x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}
[PROOF STEP]
show "Pow (set xs) \<subseteq> set (map set (powerset_enum xs))"
[PROOF STATE]
proof (prove)
using this:
?x \<subseteq> set xs \<Longrightarrow> ?x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}

goal (1 subgoal):
 1. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
using all_bool_lists_correct
[PROOF STATE]
proof (prove)
using this:
?x \<subseteq> set xs \<Longrightarrow> ?x \<in> (\<lambda>x. set (filter_bool_list x xs)) ` {zs. length zs = length xs}
set (all_bool_lists ?x) = {xs. length xs = ?x}

goal (1 subgoal):
 1. Pow (set xs) \<subseteq> set (map set (powerset_enum xs))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Pow (set xs) \<subseteq> set (map set (powerset_enum xs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in prime_number_theorem) ln_divisor_count_primorial'_asymp_equiv:
  "(\<lambda>k. ln (divisor_count (primorial' k))) \<sim>[at_top]
     (\<lambda>k. ln 2 * ln (primorial' k) / ln (ln (primorial' k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
have "(\<lambda>k. ln 2 * (ln (primorial' k) / ln (ln (primorial' k)))) \<sim>[at_top] (\<lambda>k. ln 2 * k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. ln 2 * (ln (real (primorial' k)) / ln (ln (real (primorial' k))))) \<sim>[sequentially] (\<lambda>x. ln 2 * real x)
[PROOF STEP]
by (intro asymp_equiv_intros ln_over_ln_ln_primorial'_asymp_equiv)
[PROOF STATE]
proof (state)
this:
(\<lambda>k. ln 2 * (ln (real (primorial' k)) / ln (ln (real (primorial' k))))) \<sim>[sequentially] (\<lambda>x. ln 2 * real x)

goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>k. ln 2 * (ln (real (primorial' k)) / ln (ln (real (primorial' k))))) \<sim>[sequentially] (\<lambda>x. ln 2 * real x)

goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>k. ln (divisor_count (primorial' k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. ln 2 * real x) \<sim>[sequentially] (\<lambda>k. ln (real (divisor_count (primorial' k))))
[PROOF STEP]
by (simp add: ln_realpow mult_ac)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. ln 2 * real x) \<sim>[sequentially] (\<lambda>k. ln (real (divisor_count (primorial' k))))

goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d) \<Longrightarrow> (\<lambda>k. ln 2 * (ln (real (primorial' k)) / ln (ln (real (primorial' k))))) \<sim>[sequentially] (\<lambda>a. ln (real (divisor_count (primorial' a))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d) \<Longrightarrow> (\<lambda>k. ln 2 * (ln (real (primorial' k)) / ln (ln (real (primorial' k))))) \<sim>[sequentially] (\<lambda>a. ln (real (divisor_count (primorial' a))))

goal (1 subgoal):
 1. (\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))
[PROOF STEP]
by (simp add: asymp_equiv_sym mult_ac)
[PROOF STATE]
proof (state)
this:
(\<lambda>k. ln (real (divisor_count (primorial' k)))) \<sim>[sequentially] (\<lambda>k. ln 2 * ln (real (primorial' k)) / ln (ln (real (primorial' k))))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma edge_density_Un:
  assumes "disjnt X1 X2" "finite X1" "finite X2" "finite Y"
  shows "edge_density (X1 \<union> X2) Y = (edge_density X1 Y * card X1 + edge_density X2 Y * card X2) / (card X1 + card X2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. edge_density (X1 \<union> X2) Y = (edge_density X1 Y * real (card X1) + edge_density X2 Y * real (card X2)) / real (card X1 + card X2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
disjnt X1 X2
finite X1
finite X2
finite Y

goal (1 subgoal):
 1. edge_density (X1 \<union> X2) Y = (edge_density X1 Y * real (card X1) + edge_density X2 Y * real (card X2)) / real (card X1 + card X2)
[PROOF STEP]
unfolding edge_density_def
[PROOF STATE]
proof (prove)
using this:
disjnt X1 X2
finite X1
finite X2
finite Y

goal (1 subgoal):
 1. real (card (all_edges_between (X1 \<union> X2) Y)) / real (card (X1 \<union> X2) * card Y) = (real (card (all_edges_between X1 Y)) / real (card X1 * card Y) * real (card X1) + real (card (all_edges_between X2 Y)) / real (card X2 * card Y) * real (card X2)) / real (card X1 + card X2)
[PROOF STEP]
by (simp add: all_edges_between_disjnt1 all_edges_between_Un1 finite_all_edges_between card_Un_disjnt divide_simps)


[STATEMENT]
lemma sigma_algebra_intersection:
  assumes "sigma_algebra \<Omega> A"
          "sigma_algebra \<Omega> B"
  shows "sigma_algebra \<Omega> (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_algebra \<Omega> (A \<inter> B)
[PROOF STEP]
apply (subst sigma_algebra_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebra \<Omega> (A \<inter> B) \<and> (\<forall>Aa. range Aa \<subseteq> A \<inter> B \<longrightarrow> \<Union> (range Aa) \<in> A \<inter> B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sigma_algebra \<Omega> A
sigma_algebra \<Omega> B

goal (1 subgoal):
 1. algebra \<Omega> (A \<inter> B) \<and> (\<forall>Aa. range Aa \<subseteq> A \<inter> B \<longrightarrow> \<Union> (range Aa) \<in> A \<inter> B)
[PROOF STEP]
by (auto simp add: sigma_algebra_iff algebra_intersection)


[STATEMENT]
lemma card_3_eq':
    "\<lbrakk>card X = 3; card {a,b,c} = 3; {a,b,c} \<subseteq>X\<rbrakk> \<Longrightarrow> X = {a,b,c}"
    "\<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a,b,c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>card X = 3; card {a, b, c} = 3; {a, b, c} \<subseteq> X\<rbrakk> \<Longrightarrow> X = {a, b, c}) &&& (\<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a, b, c})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>card X = 3; card {a, b, c} = 3; {a, b, c} \<subseteq> X\<rbrakk> \<Longrightarrow> X = {a, b, c}
 2. \<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a, b, c}
[PROOF STEP]
show "\<lbrakk>card X = 3; card {a,b,c} = 3; {a,b,c} \<subseteq>X\<rbrakk> \<Longrightarrow> X = {a,b,c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>card X = 3; card {a, b, c} = 3; {a, b, c} \<subseteq> X\<rbrakk> \<Longrightarrow> X = {a, b, c}
[PROOF STEP]
by (metis card.infinite card_subset_eq zero_neq_numeral)
[PROOF STATE]
proof (state)
this:
\<lbrakk>card X = 3; card {a, b, c} = 3; {a, b, c} \<subseteq> X\<rbrakk> \<Longrightarrow> X = {a, b, c}

goal (1 subgoal):
 1. \<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a, b, c}
[PROOF STEP]
thus "\<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a,b,c}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card X = 3; card {a, b, c} = 3; {a, b, c} \<subseteq> X\<rbrakk> \<Longrightarrow> X = {a, b, c}

goal (1 subgoal):
 1. \<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a, b, c}
[PROOF STEP]
by (meson card_3_dist empty_subsetI insert_subset)
[PROOF STATE]
proof (state)
this:
\<lbrakk>card X = 3; a \<in> X; b \<in> X; c \<in> X; a \<noteq> b; a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> X = {a, b, c}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fib_closed_form:
  fixes \<phi> \<psi> :: real
  defines "\<phi> \<equiv> (1 + sqrt 5) / 2"
    and "\<psi> \<equiv> (1 - sqrt 5) / 2"
  shows "of_nat (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5
[PROOF STEP]
proof (induct n rule: fib.induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
assume IH1: "of_nat (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5"
[PROOF STATE]
proof (state)
this:
real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
assume IH2: "of_nat (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5"
[PROOF STATE]
proof (state)
this:
real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
have "of_nat (fib (Suc (Suc n))) = of_nat (fib (Suc n)) + of_nat (fib n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (fib (Suc (Suc n))) = of_nat (fib (Suc n)) + of_nat (fib n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_nat (fib (Suc (Suc n))) = of_nat (fib (Suc n)) + of_nat (fib n)

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_nat (fib (Suc (Suc n))) = of_nat (fib (Suc n)) + of_nat (fib n)

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
have "\<dots> = (\<phi>^n * (\<phi> + 1) - \<psi>^n * (\<psi> + 1)) / sqrt 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (fib (Suc n)) + real (fib n) = (\<phi> ^ n * (\<phi> + 1) - \<psi> ^ n * (\<psi> + 1)) / sqrt 5
[PROOF STEP]
by (simp add: IH1 IH2 field_simps)
[PROOF STATE]
proof (state)
this:
real (fib (Suc n)) + real (fib n) = (\<phi> ^ n * (\<phi> + 1) - \<psi> ^ n * (\<psi> + 1)) / sqrt 5

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (fib (Suc n)) + real (fib n) = (\<phi> ^ n * (\<phi> + 1) - \<psi> ^ n * (\<psi> + 1)) / sqrt 5

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
have "\<phi> + 1 = \<phi>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> + 1 = \<phi>\<^sup>2
[PROOF STEP]
by (simp add: \<phi>_def field_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
\<phi> + 1 = \<phi>\<^sup>2

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<phi> + 1 = \<phi>\<^sup>2

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
have "\<psi> + 1 = \<psi>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<psi> + 1 = \<psi>\<^sup>2
[PROOF STEP]
by (simp add: \<psi>_def field_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
\<psi> + 1 = \<psi>\<^sup>2

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<psi> + 1 = \<psi>\<^sup>2

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
have "\<phi>^n * \<phi>\<^sup>2 - \<psi>^n * \<psi>\<^sup>2 = \<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> ^ n * \<phi>\<^sup>2 - \<psi> ^ n * \<psi>\<^sup>2 = \<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
\<phi> ^ n * \<phi>\<^sup>2 - \<psi> ^ n * \<psi>\<^sup>2 = \<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)

goal (3 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
 3. \<And>n. \<lbrakk>real (fib (Suc n)) = (\<phi> ^ Suc n - \<psi> ^ Suc n) / sqrt 5; real (fib n) = (\<phi> ^ n - \<psi> ^ n) / sqrt 5\<rbrakk> \<Longrightarrow> real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
show "of_nat (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5"
[PROOF STATE]
proof (prove)
using this:
real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5

goal (1 subgoal):
 1. real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real (fib (Suc (Suc n))) = (\<phi> ^ Suc (Suc n) - \<psi> ^ Suc (Suc n)) / sqrt 5

goal (2 subgoals):
 1. real (fib 0) = (\<phi> ^ 0 - \<psi> ^ 0) / sqrt 5
 2. real (fib (Suc 0)) = (\<phi> ^ Suc 0 - \<psi> ^ Suc 0) / sqrt 5
[PROOF STEP]
qed (simp_all add: \<phi>_def \<psi>_def field_simps)


[STATEMENT]
lemma (*bt_map_append:*)
     "bt_map f (append t1 t2) = append (bt_map f t1) (bt_map f t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bt_map f (Binary_Tree.append t1 t2) = Binary_Tree.append (bt_map f t1) (bt_map f t2)
[PROOF STEP]
apply (induct t1)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. bt_map f (Binary_Tree.append Lf t2) = Binary_Tree.append (bt_map f Lf) (bt_map f t2)
 2. \<And>x1 t11 t12. \<lbrakk>bt_map f (Binary_Tree.append t11 t2) = Binary_Tree.append (bt_map f t11) (bt_map f t2); bt_map f (Binary_Tree.append t12 t2) = Binary_Tree.append (bt_map f t12) (bt_map f t2)\<rbrakk> \<Longrightarrow> bt_map f (Binary_Tree.append (Br x1 t11 t12) t2) = Binary_Tree.append (bt_map f (Br x1 t11 t12)) (bt_map f t2)
[PROOF STEP]
apply (metis append.simps(1) bt_map.simps(1))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 t11 t12. \<lbrakk>bt_map f (Binary_Tree.append t11 t2) = Binary_Tree.append (bt_map f t11) (bt_map f t2); bt_map f (Binary_Tree.append t12 t2) = Binary_Tree.append (bt_map f t12) (bt_map f t2)\<rbrakk> \<Longrightarrow> bt_map f (Binary_Tree.append (Br x1 t11 t12) t2) = Binary_Tree.append (bt_map f (Br x1 t11 t12)) (bt_map f t2)
[PROOF STEP]
by (metis bt_map_append)


[STATEMENT]
lemma set_to_nat_of_interval: "set_to_nat {i. (i::nat)<m} = 2 ^ m - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_nat {i. i < m} = 2 ^ m - 1
[PROOF STEP]
proof (induct m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
 2. \<And>m. set_to_nat {i. i < m} = 2 ^ m - 1 \<Longrightarrow> set_to_nat {i. i < Suc m} = 2 ^ Suc m - 1
[PROOF STEP]
show "set_to_nat {i. i < 0} = 2 ^ 0 - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
[PROOF STEP]
have S1: "{i. (i::nat) < 0} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {i. i < 0} = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{i. i < 0} = {}

goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
[PROOF STEP]
with set_to_nat_at_empty
[PROOF STATE]
proof (chain)
picking this:
set_to_nat {} = 0
{i. i < 0} = {}
[PROOF STEP]
have "set_to_nat {i. i<0} = 0"
[PROOF STATE]
proof (prove)
using this:
set_to_nat {} = 0
{i. i < 0} = {}

goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat {i. i < 0} = 0

goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
set_to_nat {i. i < 0} = 0

goal (1 subgoal):
 1. set_to_nat {i. i < 0} = 2 ^ 0 - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat {i. i < 0} = 2 ^ 0 - 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
set_to_nat {i. i < 0} = 2 ^ 0 - 1

goal (1 subgoal):
 1. \<And>m. set_to_nat {i. i < m} = 2 ^ m - 1 \<Longrightarrow> set_to_nat {i. i < Suc m} = 2 ^ Suc m - 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m. set_to_nat {i. i < m} = 2 ^ m - 1 \<Longrightarrow> set_to_nat {i. i < Suc m} = 2 ^ Suc m - 1
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m. set_to_nat {i. i < m} = 2 ^ m - 1 \<Longrightarrow> set_to_nat {i. i < Suc m} = 2 ^ Suc m - 1
[PROOF STEP]
show "set_to_nat {i. i < Suc n} = 2 ^ Suc n - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_nat {i. i < Suc n} = 2 ^ Suc n - 1
[PROOF STEP]
by (unfold set_to_nat_def, rule two_power_sum)
[PROOF STATE]
proof (state)
this:
set_to_nat {i. i < Suc n} = 2 ^ Suc n - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_roots_set_same:
  fixes a b c:: "real"
  shows "{(x::real). a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {x. a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
have "\<forall>x. a*x^2 + b*x + c = poly [:c, b, a:] x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. a * x\<^sup>2 + b * x + c = poly [:c, b, a:] x
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. a * x\<^sup>2 + b * x = x * (b + x * a)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. a * x\<^sup>2 + b * x = x * (b + x * a)
[PROOF STEP]
show "a * x\<^sup>2 + b * x = x * (b + x * a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * x\<^sup>2 + b * x = x * (b + x * a)
[PROOF STEP]
using quadratic_poly_eval[of c b a x]
[PROOF STATE]
proof (prove)
using this:
poly [:c, b, a:] x = a * x\<^sup>2 + b * x + c

goal (1 subgoal):
 1. a * x\<^sup>2 + b * x = x * (b + x * a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a * x\<^sup>2 + b * x = x * (b + x * a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x. a * x\<^sup>2 + b * x + c = poly [:c, b, a:] x

goal (1 subgoal):
 1. {x. a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. a * x\<^sup>2 + b * x + c = poly [:c, b, a:] x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x. a * x\<^sup>2 + b * x + c = poly [:c, b, a:] x

goal (1 subgoal):
 1. {x. a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. a * x\<^sup>2 + b * x + c = 0} = {x. poly [:c, b, a:] x = 0}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma divisor_count_upper_bound':
  fixes n :: nat
  shows "real (divisor_count n) \<le> 2 * sqrt n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
have "real (divisor_count n) \<le> 2 * real (nat \<lfloor>sqrt n\<rfloor>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * real (nat \<lfloor>sqrt (real n)\<rfloor>)
[PROOF STEP]
using divisor_count_upper_bound[of n]
[PROOF STATE]
proof (prove)
using this:
divisor_count n \<le> 2 * nat \<lfloor>sqrt (real n)\<rfloor>

goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * real (nat \<lfloor>sqrt (real n)\<rfloor>)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
real (divisor_count n) \<le> 2 * real (nat \<lfloor>sqrt (real n)\<rfloor>)

goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (divisor_count n) \<le> 2 * real (nat \<lfloor>sqrt (real n)\<rfloor>)

goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
have "\<dots> \<le> 2 * sqrt n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * real (nat \<lfloor>sqrt (real n)\<rfloor>) \<le> 2 * sqrt (real n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * real (nat \<lfloor>sqrt (real n)\<rfloor>) \<le> 2 * sqrt (real n)

goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real (divisor_count n) \<le> 2 * sqrt (real n)

goal (1 subgoal):
 1. real (divisor_count n) \<le> 2 * sqrt (real n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real (divisor_count n) \<le> 2 * sqrt (real n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma EVEN_ODD_infinite:
  shows "infinite EVEN"
  and   "infinite ODD"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite EVEN &&& infinite ODD
[PROOF STEP]
unfolding infinite_iff_countable_subset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> EVEN &&& \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>f. inj f \<and> range f \<subseteq> EVEN
 2. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
let ?f = "\<lambda>n. atom (2*n)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>f. inj f \<and> range f \<subseteq> EVEN
 2. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
have "inj ?f \<and> range ?f \<subseteq> EVEN"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj (\<lambda>n. atom (2 * n)) \<and> range (\<lambda>n. atom (2 * n)) \<subseteq> EVEN
[PROOF STEP]
by (auto simp add: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj (\<lambda>n. atom (2 * n)) \<and> range (\<lambda>n. atom (2 * n)) \<subseteq> EVEN

goal (2 subgoals):
 1. \<exists>f. inj f \<and> range f \<subseteq> EVEN
 2. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inj (\<lambda>n. atom (2 * n)) \<and> range (\<lambda>n. atom (2 * n)) \<subseteq> EVEN
[PROOF STEP]
show "\<exists>f::nat\<Rightarrow>atom. inj f \<and> range f \<subseteq> EVEN"
[PROOF STATE]
proof (prove)
using this:
inj (\<lambda>n. atom (2 * n)) \<and> range (\<lambda>n. atom (2 * n)) \<subseteq> EVEN

goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> EVEN
[PROOF STEP]
by (rule_tac exI)
[PROOF STATE]
proof (state)
this:
\<exists>f. inj f \<and> range f \<subseteq> EVEN

goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
let ?f = "\<lambda>n. atom (2*n+1)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
have "inj ?f \<and> range ?f \<subseteq> ODD"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj (\<lambda>n. atom (2 * n + 1)) \<and> range (\<lambda>n. atom (2 * n + 1)) \<subseteq> ODD
[PROOF STEP]
by (auto simp add: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj (\<lambda>n. atom (2 * n + 1)) \<and> range (\<lambda>n. atom (2 * n + 1)) \<subseteq> ODD

goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inj (\<lambda>n. atom (2 * n + 1)) \<and> range (\<lambda>n. atom (2 * n + 1)) \<subseteq> ODD
[PROOF STEP]
show "\<exists>f::nat\<Rightarrow>atom. inj f \<and> range f \<subseteq> ODD"
[PROOF STATE]
proof (prove)
using this:
inj (\<lambda>n. atom (2 * n + 1)) \<and> range (\<lambda>n. atom (2 * n + 1)) \<subseteq> ODD

goal (1 subgoal):
 1. \<exists>f. inj f \<and> range f \<subseteq> ODD
[PROOF STEP]
by (rule_tac exI)
[PROOF STATE]
proof (state)
this:
\<exists>f. inj f \<and> range f \<subseteq> ODD

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lcm_eq_0_iff: "lcm a b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
  (is "?P \<longleftrightarrow> ?Q")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (lcm a b = (0::'a)) = (a = (0::'a) \<or> b = (0::'a))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. lcm a b = (0::'a) \<Longrightarrow> a = (0::'a) \<or> b = (0::'a)
 2. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
assume ?P
[PROOF STATE]
proof (state)
this:
lcm a b = (0::'a)

goal (2 subgoals):
 1. lcm a b = (0::'a) \<Longrightarrow> a = (0::'a) \<or> b = (0::'a)
 2. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
lcm a b = (0::'a)
[PROOF STEP]
have "0 dvd lcm a b"
[PROOF STATE]
proof (prove)
using this:
lcm a b = (0::'a)

goal (1 subgoal):
 1. (0::'a) dvd lcm a b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(0::'a) dvd lcm a b

goal (2 subgoals):
 1. lcm a b = (0::'a) \<Longrightarrow> a = (0::'a) \<or> b = (0::'a)
 2. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(0::'a) dvd lcm a b

goal (2 subgoals):
 1. lcm a b = (0::'a) \<Longrightarrow> a = (0::'a) \<or> b = (0::'a)
 2. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
have "lcm a b dvd (a * b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lcm a b dvd a * b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
lcm a b dvd a * b

goal (2 subgoals):
 1. lcm a b = (0::'a) \<Longrightarrow> a = (0::'a) \<or> b = (0::'a)
 2. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(0::'a) dvd a * b
[PROOF STEP]
show ?Q
[PROOF STATE]
proof (prove)
using this:
(0::'a) dvd a * b

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

goal (1 subgoal):
 1. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
assume ?Q
[PROOF STATE]
proof (state)
this:
a = (0::'a) \<or> b = (0::'a)

goal (1 subgoal):
 1. a = (0::'a) \<or> b = (0::'a) \<Longrightarrow> lcm a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a = (0::'a) \<or> b = (0::'a)
[PROOF STEP]
show ?P
[PROOF STATE]
proof (prove)
using this:
a = (0::'a) \<or> b = (0::'a)

goal (1 subgoal):
 1. lcm a b = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lcm a b = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infnorm_triangle:
  fixes x :: "'a::euclidean_space"
  shows "infnorm (x + y) \<le> infnorm x + infnorm y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infnorm (x + y) \<le> infnorm x + infnorm y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infnorm (x + y) \<le> infnorm x + infnorm y
[PROOF STEP]
have *: "\<And>a b c d :: real. \<bar>a\<bar> \<le> c \<Longrightarrow> \<bar>b\<bar> \<le> d \<Longrightarrow> \<bar>a + b\<bar> \<le> c + d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b c d. \<lbrakk>\<bar>a\<bar> \<le> c; \<bar>b\<bar> \<le> d\<rbrakk> \<Longrightarrow> \<bar>a + b\<bar> \<le> c + d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<bar>?a\<bar> \<le> ?c; \<bar>?b\<bar> \<le> ?d\<rbrakk> \<Longrightarrow> \<bar>?a + ?b\<bar> \<le> ?c + ?d

goal (1 subgoal):
 1. infnorm (x + y) \<le> infnorm x + infnorm y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infnorm (x + y) \<le> infnorm x + infnorm y
[PROOF STEP]
by (auto simp: infnorm_Max inner_add_left intro!: *)
[PROOF STATE]
proof (state)
this:
infnorm (x + y) \<le> infnorm x + infnorm y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma permutation_mat_id_1: assumes p: "p permutes {..<n}"
  shows "permutation_mat n p * permutation_mat n (inv p) = 1\<^sub>m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. permutation_mat n p * permutation_mat n (inv p) = 1\<^sub>m n
[PROOF STEP]
by (subst permutation_mat_left[OF _ p, of _ n], force, unfold permutation_mat_def, rule eq_matI,
   auto simp: permutes_lt[OF permutes_inv[OF p]] permutes_iff[OF permutes_inv[OF p]])


[STATEMENT]
lemma append_rows_le: assumes A: "A \<in> carrier_mat nr1 nc"
  and B: "B \<in> carrier_mat nr2 nc"
  and a: "a \<in> carrier_vec nr1"
  and v: "v \<in> carrier_vec nc"
shows "(A @\<^sub>r B) *\<^sub>v v \<le> (a @\<^sub>v b) \<longleftrightarrow> A *\<^sub>v v \<le> a \<and> B *\<^sub>v v \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((A @\<^sub>r B) *\<^sub>v v \<le> a @\<^sub>v b) = (A *\<^sub>v v \<le> a \<and> B *\<^sub>v v \<le> b)
[PROOF STEP]
unfolding mat_mult_append[OF A B v]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A *\<^sub>v v @\<^sub>v B *\<^sub>v v \<le> a @\<^sub>v b) = (A *\<^sub>v v \<le> a \<and> B *\<^sub>v v \<le> b)
[PROOF STEP]
by (rule append_vec_le[OF _ a], insert A v, auto)


[STATEMENT]
lemma  trace_mul_sym: "trace ((A::'a::comm_semiring_1^'n^'m) ** B) = trace (B**A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (A ** B) = trace (B ** A)
[PROOF STEP]
apply (simp add: trace_def matrix_matrix_mult_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. \<Sum>k\<in>UNIV. A $ i $ k * B $ k $ i) = (\<Sum>i\<in>UNIV. \<Sum>k\<in>UNIV. B $ i $ k * A $ k $ i)
[PROOF STEP]
apply (subst sum.swap)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<in>UNIV. \<Sum>i\<in>UNIV. A $ i $ j * B $ j $ i) = (\<Sum>i\<in>UNIV. \<Sum>k\<in>UNIV. B $ i $ k * A $ k $ i)
[PROOF STEP]
apply (simp add: mult.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma measure_UNION_AE:
  assumes I: "finite I"
  shows "(\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M) \<Longrightarrow> pairwise (\<lambda>i j. AE x in M. x \<notin> F i \<or> x \<notin> F j) I \<Longrightarrow>
    measure M (\<Union>i\<in>I. F i) = (\<Sum>i\<in>I. measure M (F i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; pairwise (\<lambda>i j. AE x in M. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
[PROOF STEP]
unfolding AE_pairwise[OF countable_finite, OF I]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
[PROOF STEP]
using I
[PROOF STATE]
proof (prove)
using this:
finite I

goal (1 subgoal):
 1. \<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
[PROOF STEP]
proof (induction I rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>i. i \<in> {} \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) {}\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` {})) = (\<Sum>i\<in>{}. Sigma_Algebra.measure M (F i))
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; \<lbrakk>\<And>i. i \<in> Fa \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) Fa\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` Fa)) = (\<Sum>i\<in>Fa. Sigma_Algebra.measure M (F i)); \<And>i. i \<in> insert x Fa \<Longrightarrow> F i \<in> fmeasurable M; AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x Fa)\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` insert x Fa)) = (\<Sum>i\<in>insert x Fa. Sigma_Algebra.measure M (F i))
[PROOF STEP]
case (insert x I)
[PROOF STATE]
proof (state)
this:
finite I
x \<notin> I
\<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
?i \<in> insert x I \<Longrightarrow> F ?i \<in> fmeasurable M
AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x I)

goal (2 subgoals):
 1. \<lbrakk>\<And>i. i \<in> {} \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) {}\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` {})) = (\<Sum>i\<in>{}. Sigma_Algebra.measure M (F i))
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; \<lbrakk>\<And>i. i \<in> Fa \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) Fa\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` Fa)) = (\<Sum>i\<in>Fa. Sigma_Algebra.measure M (F i)); \<And>i. i \<in> insert x Fa \<Longrightarrow> F i \<in> fmeasurable M; AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x Fa)\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` insert x Fa)) = (\<Sum>i\<in>insert x Fa. Sigma_Algebra.measure M (F i))
[PROOF STEP]
have "measure M (F x \<union> \<Union>(F ` I)) = measure M (F x) + measure M (\<Union>(F ` I))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M (F x \<union> \<Union> (F ` I)) = Sigma_Algebra.measure M (F x) + Sigma_Algebra.measure M (\<Union> (F ` I))
[PROOF STEP]
by (rule measure_Un_AE) (use insert in \<open>auto simp: pairwise_insert\<close>)
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M (F x \<union> \<Union> (F ` I)) = Sigma_Algebra.measure M (F x) + Sigma_Algebra.measure M (\<Union> (F ` I))

goal (2 subgoals):
 1. \<lbrakk>\<And>i. i \<in> {} \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) {}\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` {})) = (\<Sum>i\<in>{}. Sigma_Algebra.measure M (F i))
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; \<lbrakk>\<And>i. i \<in> Fa \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) Fa\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` Fa)) = (\<Sum>i\<in>Fa. Sigma_Algebra.measure M (F i)); \<And>i. i \<in> insert x Fa \<Longrightarrow> F i \<in> fmeasurable M; AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x Fa)\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` insert x Fa)) = (\<Sum>i\<in>insert x Fa. Sigma_Algebra.measure M (F i))
[PROOF STEP]
with insert
[PROOF STATE]
proof (chain)
picking this:
finite I
x \<notin> I
\<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
?i \<in> insert x I \<Longrightarrow> F ?i \<in> fmeasurable M
AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x I)
Sigma_Algebra.measure M (F x \<union> \<Union> (F ` I)) = Sigma_Algebra.measure M (F x) + Sigma_Algebra.measure M (\<Union> (F ` I))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite I
x \<notin> I
\<lbrakk>\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) I\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` I)) = (\<Sum>i\<in>I. Sigma_Algebra.measure M (F i))
?i \<in> insert x I \<Longrightarrow> F ?i \<in> fmeasurable M
AE xa in M. pairwise (\<lambda>i j. xa \<notin> F i \<or> xa \<notin> F j) (insert x I)
Sigma_Algebra.measure M (F x \<union> \<Union> (F ` I)) = Sigma_Algebra.measure M (F x) + Sigma_Algebra.measure M (\<Union> (F ` I))

goal (1 subgoal):
 1. Sigma_Algebra.measure M (\<Union> (F ` insert x I)) = (\<Sum>i\<in>insert x I. Sigma_Algebra.measure M (F i))
[PROOF STEP]
by (simp add: pairwise_insert )
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M (\<Union> (F ` insert x I)) = (\<Sum>i\<in>insert x I. Sigma_Algebra.measure M (F i))

goal (1 subgoal):
 1. \<lbrakk>\<And>i. i \<in> {} \<Longrightarrow> F i \<in> fmeasurable M; AE x in M. pairwise (\<lambda>i j. x \<notin> F i \<or> x \<notin> F j) {}\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (\<Union> (F ` {})) = (\<Sum>i\<in>{}. Sigma_Algebra.measure M (F i))
[PROOF STEP]
qed simp


[STATEMENT]
lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)"
  for x :: "'a::{real_normed_field,banach,field}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan x = sin ((2::'a) * x) / (cos ((2::'a) * x) + (1::'a))
[PROOF STEP]
unfolding tan_def sin_double cos_double sin_squared_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin x / cos x = (2::'a) * sin x * cos x / ((cos x)\<^sup>2 - ((1::'a) - (cos x)\<^sup>2) + (1::'a))
[PROOF STEP]
by (simp add: power2_eq_square)


[STATEMENT]
lemma real_polynomial_function_sum_of_powers:
  "\<exists>p. real_polynomial_function p \<and> (\<forall>n. (\<Sum>i\<le>n. real i ^ j) = p (real n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. real_polynomial_function p \<and> (\<forall>n. (\<Sum>i\<le>n. real i ^ j) = p (real n))
[PROOF STEP]
proof (intro exI conjI strip)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. real_polynomial_function ?p
 2. \<And>n. (\<Sum>i\<le>n. real i ^ j) = ?p (real n)
[PROOF STEP]
let ?p = "\<lambda>n. (bernpoly (Suc j) (1 + n) - bernpoly (Suc j) 0) / (Suc j)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. real_polynomial_function ?p
 2. \<And>n. (\<Sum>i\<le>n. real i ^ j) = ?p (real n)
[PROOF STEP]
show "real_polynomial_function ?p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_polynomial_function (\<lambda>n. (bernpoly (Suc j) (1 + n) - bernpoly (Suc j) 0) / real (Suc j))
[PROOF STEP]
by (force simp add: bernpoly_def)
[PROOF STATE]
proof (state)
this:
real_polynomial_function (\<lambda>n. (bernpoly (Suc j) (1 + n) - bernpoly (Suc j) 0) / real (Suc j))

goal (1 subgoal):
 1. \<And>n. (\<Sum>i\<le>n. real i ^ j) = (bernpoly (Suc j) (1 + real n) - bernpoly (Suc j) 0) / real (Suc j)
[PROOF STEP]
qed (simp add: add.commute sum_of_powers)


[STATEMENT]
lemma card_union_disjoint_fset:
  shows "xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys
[PROOF STEP]
unfolding card_fset union_fset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs |\<inter>| ys = {||} \<Longrightarrow> card (fset xs \<union> fset ys) = card (fset xs) + card (fset ys)
[PROOF STEP]
apply (rule card_Un_disjoint[OF finite_fset finite_fset])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs |\<inter>| ys = {||} \<Longrightarrow> fset xs \<inter> fset ys = {}
[PROOF STEP]
by (metis inter_fset fset_simps(1))


[STATEMENT]
lemma (in real_inner) parallelogram_law: "(norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2
[PROOF STEP]
have "(norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = inner (x + y) (x + y) + inner (x - y) (x - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = (x + y) \<bullet> (x + y) + (x - y) \<bullet> (x - y)
[PROOF STEP]
by (simp add: norm_eq_sqrt_inner)
[PROOF STATE]
proof (state)
this:
(norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = (x + y) \<bullet> (x + y) + (x - y) \<bullet> (x - y)

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

goal (1 subgoal):
 1. (norm (x + y))\<^sup>2 + (norm (x - y))\<^sup>2 = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2
[PROOF STEP]
have "\<dots> = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y) \<bullet> (x + y) + (x - y) \<bullet> (x - y) = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2
[PROOF STEP]
by (simp add: algebra_simps norm_eq_sqrt_inner)
[PROOF STATE]
proof (state)
this:
(x + y) \<bullet> (x + y) + (x - y) \<bullet> (x - y) = 2 * (norm x)\<^sup>2 + 2 * (norm y)\<^sup>2

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma exp1': "exp 3 (A) < 3 * ((exp 3 A) * (exp 3 B)) + C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp 3 A < 3 * (exp 3 A * exp 3 B) + C
[PROOF STEP]
apply(subgoal_tac "exp 3 (A) < 3 * ((exp 3 A) * (exp 3 B))")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. exp 3 A < 3 * (exp 3 A * exp 3 B) \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B) + C
 2. exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply(case_tac "exp 3 A")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. exp 3 A = 0 \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
 2. \<And>nat. exp 3 A = Suc nat \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
using exp3Min[of A]
[PROOF STATE]
proof (prove)
using this:
0 < exp 3 A

goal (2 subgoals):
 1. exp 3 A = 0 \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
 2. \<And>nat. exp 3 A = Suc nat \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>nat. exp 3 A = Suc nat \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply(case_tac "exp 3 B")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>nat. \<lbrakk>exp 3 A = Suc nat; exp 3 B = 0\<rbrakk> \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
 2. \<And>nat nata. \<lbrakk>exp 3 A = Suc nat; exp 3 B = Suc nata\<rbrakk> \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
using exp3Min[of B]
[PROOF STATE]
proof (prove)
using this:
0 < exp 3 B

goal (2 subgoals):
 1. \<And>nat. \<lbrakk>exp 3 A = Suc nat; exp 3 B = 0\<rbrakk> \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
 2. \<And>nat nata. \<lbrakk>exp 3 A = Suc nat; exp 3 B = Suc nata\<rbrakk> \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>nat nata. \<lbrakk>exp 3 A = Suc nat; exp 3 B = Suc nata\<rbrakk> \<Longrightarrow> exp 3 A < 3 * (exp 3 A * exp 3 B)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma has_derivative_divide'[derivative_intros]:
  fixes f :: "_ \<Rightarrow> 'a::real_normed_field"
  assumes f: "(f has_derivative f') (at x within S)"
    and g: "(g has_derivative g') (at x within S)"
    and x: "g x \<noteq> 0"
  shows "((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)
[PROOF STEP]
have "f' h / g x - f x * (inverse (g x) * g' h * inverse (g x)) =
      (f' h * g x - f x * g' h) / (g x * g x)" for h
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f' h / g x - f x * (inverse (g x) * g' h * inverse (g x)) = (f' h * g x - f x * g' h) / (g x * g x)
[PROOF STEP]
by (simp add: field_simps x)
[PROOF STATE]
proof (state)
this:
f' ?h / g x - f x * (inverse (g x) * g' ?h * inverse (g x)) = (f' ?h * g x - f x * g' ?h) / (g x * g x)

goal (1 subgoal):
 1. ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f' ?h / g x - f x * (inverse (g x) * g' ?h * inverse (g x)) = (f' ?h * g x - f x * g' ?h) / (g x * g x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f' ?h / g x - f x * (inverse (g x) * g' ?h * inverse (g x)) = (f' ?h * g x - f x * g' ?h) / (g x * g x)

goal (1 subgoal):
 1. ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)
[PROOF STEP]
using has_derivative_divide [OF f g] x
[PROOF STATE]
proof (prove)
using this:
f' ?h / g x - f x * (inverse (g x) * g' ?h * inverse (g x)) = (f' ?h * g x - f x * g' ?h) / (g x * g x)
g x \<noteq> (0::'a) \<Longrightarrow> ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. - f x * (inverse (g x) * g' h * inverse (g x)) + f' h / g x)) (at x within S)
g x \<noteq> (0::'a)

goal (1 subgoal):
 1. ((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma winding_number_exp_2pi:
    "\<lbrakk>path p; z \<notin> path_image p\<rbrakk>
     \<Longrightarrow> pathfinish p - z = exp (2 * pi * \<i> * winding_number p z) * (pathstart p - z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>path p; z \<notin> path_image p\<rbrakk> \<Longrightarrow> pathfinish p - z = exp (complex_of_real (2 * pi) * \<i> * winding_number p z) * (pathstart p - z)
[PROOF STEP]
using winding_number [of p z 1]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>path p; z \<notin> path_image p; 0 < 1\<rbrakk> \<Longrightarrow> \<exists>pa. winding_number_prop p z 1 pa (winding_number p z)

goal (1 subgoal):
 1. \<lbrakk>path p; z \<notin> path_image p\<rbrakk> \<Longrightarrow> pathfinish p - z = exp (complex_of_real (2 * pi) * \<i> * winding_number p z) * (pathstart p - z)
[PROOF STEP]
unfolding valid_path_def path_image_def pathstart_def pathfinish_def winding_number_prop_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>path p; z \<notin> p ` {0..1}; 0 < 1\<rbrakk> \<Longrightarrow> \<exists>pa. pa piecewise_C1_differentiable_on {0..1} \<and> z \<notin> pa ` {0..1} \<and> pa 0 = p 0 \<and> pa 1 = p 1 \<and> (\<forall>t\<in>{0..1}. cmod (p t - pa t) < 1) \<and> contour_integral pa (\<lambda>w. 1 / (w - z)) = complex_of_real (2 * pi) * \<i> * winding_number p z

goal (1 subgoal):
 1. \<lbrakk>path p; z \<notin> p ` {0..1}\<rbrakk> \<Longrightarrow> p 1 - z = exp (complex_of_real (2 * pi) * \<i> * winding_number p z) * (p 0 - z)
[PROOF STEP]
by (force dest: winding_number_exp_integral(2) [of _ 0 1 z] simp: field_simps contour_integral_integral exp_minus)