[STATEMENT]
lemma coprime_eq_empty_prime_inter:
  assumes "(n::nat) \<noteq> 0" "m \<noteq> 0"
  shows "coprime n m \<longleftrightarrow> (prime_factors n) \<inter> (prime_factors m) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime n m = (prime_factors n \<inter> prime_factors m = {})
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. coprime n m \<Longrightarrow> prime_factors n \<inter> prime_factors m = {}
 2. prime_factors n \<inter> prime_factors m = {} \<Longrightarrow> coprime n m
[PROOF STEP]
show "coprime n m \<Longrightarrow> prime_factors n \<inter> prime_factors m = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime n m \<Longrightarrow> prime_factors n \<inter> prime_factors m = {}
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume cp: "coprime n m"
[PROOF STATE]
proof (state)
this:
coprime n m

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume pf: "prime_factors n \<inter> prime_factors m \<noteq> {}"
[PROOF STATE]
proof (state)
this:
prime_factors n \<inter> prime_factors m \<noteq> {}

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime_factors n \<inter> prime_factors m \<noteq> {}
[PROOF STEP]
obtain p where p: "p \<in> prime_factors n" "p \<in> prime_factors m"
[PROOF STATE]
proof (prove)
using this:
prime_factors n \<inter> prime_factors m \<noteq> {}

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>p \<in># prime_factorization n; p \<in># prime_factorization m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p \<in># prime_factorization n
p \<in># prime_factorization m

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p \<in># prime_factorization n
p \<in># prime_factorization m
[PROOF STEP]
have p_dvd: "p dvd n" "p dvd m"
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization n
p \<in># prime_factorization m

goal (1 subgoal):
 1. p dvd n &&& p dvd m
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
p dvd n
p dvd m

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd n
p dvd m

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "\<not>is_unit p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_unit p
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization n
p \<in># prime_factorization m

goal (1 subgoal):
 1. \<not> is_unit p
[PROOF STEP]
using not_prime_unit
[PROOF STATE]
proof (prove)
using this:
p \<in># prime_factorization n
p \<in># prime_factorization m
is_unit ?x \<Longrightarrow> \<not> prime ?x

goal (1 subgoal):
 1. \<not> is_unit p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<not> is_unit p

goal (1 subgoal):
 1. \<lbrakk>coprime n m; prime_factors n \<inter> prime_factors m \<noteq> {}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd n
p dvd m
\<not> is_unit p
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
p dvd n
p dvd m
\<not> is_unit p

goal (1 subgoal):
 1. False
[PROOF STEP]
using cp
[PROOF STATE]
proof (prove)
using this:
p dvd n
p dvd m
\<not> is_unit p
coprime n m

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding coprime_def
[PROOF STATE]
proof (prove)
using this:
p dvd n
p dvd m
\<not> is_unit p
\<forall>c. c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime n m \<Longrightarrow> prime_factors n \<inter> prime_factors m = {}

goal (1 subgoal):
 1. prime_factors n \<inter> prime_factors m = {} \<Longrightarrow> coprime n m
[PROOF STEP]
assume assm: "prime_factors n \<inter> prime_factors m = {}"
[PROOF STATE]
proof (state)
this:
prime_factors n \<inter> prime_factors m = {}

goal (1 subgoal):
 1. prime_factors n \<inter> prime_factors m = {} \<Longrightarrow> coprime n m
[PROOF STEP]
show "coprime n m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime n m
[PROOF STEP]
unfolding coprime_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>c. c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c
[PROOF STEP]
fix c
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c
[PROOF STEP]
show "c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c
[PROOF STEP]
proof(rule; rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>c dvd n; c dvd m\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
assume c: "c dvd n" "c dvd m"
[PROOF STATE]
proof (state)
this:
c dvd n
c dvd m

goal (1 subgoal):
 1. \<lbrakk>c dvd n; c dvd m\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c dvd n
c dvd m
[PROOF STEP]
have "prime_factors c \<subseteq> prime_factors n" "prime_factors c \<subseteq> prime_factors m"
[PROOF STATE]
proof (prove)
using this:
c dvd n
c dvd m

goal (1 subgoal):
 1. prime_factors c \<subseteq> prime_factors n &&& prime_factors c \<subseteq> prime_factors m
[PROOF STEP]
using assms dvd_prime_factors
[PROOF STATE]
proof (prove)
using this:
c dvd n
c dvd m
n \<noteq> 0
m \<noteq> 0
\<lbrakk>?y \<noteq> (0::?'a); ?x dvd ?y\<rbrakk> \<Longrightarrow> prime_factors ?x \<subseteq> prime_factors ?y

goal (1 subgoal):
 1. prime_factors c \<subseteq> prime_factors n &&& prime_factors c \<subseteq> prime_factors m
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
prime_factors c \<subseteq> prime_factors n
prime_factors c \<subseteq> prime_factors m

goal (1 subgoal):
 1. \<lbrakk>c dvd n; c dvd m\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime_factors c \<subseteq> prime_factors n
prime_factors c \<subseteq> prime_factors m
[PROOF STEP]
have "prime_factors c = {}"
[PROOF STATE]
proof (prove)
using this:
prime_factors c \<subseteq> prime_factors n
prime_factors c \<subseteq> prime_factors m

goal (1 subgoal):
 1. prime_factors c = {}
[PROOF STEP]
using assm
[PROOF STATE]
proof (prove)
using this:
prime_factors c \<subseteq> prime_factors n
prime_factors c \<subseteq> prime_factors m
prime_factors n \<inter> prime_factors m = {}

goal (1 subgoal):
 1. prime_factors c = {}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
prime_factors c = {}

goal (1 subgoal):
 1. \<lbrakk>c dvd n; c dvd m\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
thus "is_unit c"
[PROOF STATE]
proof (prove)
using this:
prime_factors c = {}

goal (1 subgoal):
 1. is_unit c
[PROOF STEP]
using assms c
[PROOF STATE]
proof (prove)
using this:
prime_factors c = {}
n \<noteq> 0
m \<noteq> 0
c dvd n
c dvd m

goal (1 subgoal):
 1. is_unit c
[PROOF STEP]
by (metis dvd_0_left_iff prime_factorization_empty_iff set_mset_eq_empty_iff)
[PROOF STATE]
proof (state)
this:
is_unit c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
c dvd n \<longrightarrow> c dvd m \<longrightarrow> is_unit c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime n m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma geometric_sums:
  assumes "norm c < 1"
  shows "(\<lambda>n. c^n) sums (1 / (1 - c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
have neq_0: "c - 1 \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c - (1::'a) \<noteq> (0::'a)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
norm c < 1

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

goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c - (1::'a) \<noteq> (0::'a)
[PROOF STEP]
have "(\<lambda>n. c ^ n / (c - 1) - 1 / (c - 1)) \<longlonglongrightarrow> 0 / (c - 1) - 1 / (c - 1)"
[PROOF STATE]
proof (prove)
using this:
c - (1::'a) \<noteq> (0::'a)

goal (1 subgoal):
 1. (\<lambda>n. c ^ n / (c - (1::'a)) - (1::'a) / (c - (1::'a))) \<longlonglongrightarrow> (0::'a) / (c - (1::'a)) - (1::'a) / (c - (1::'a))
[PROOF STEP]
by (intro tendsto_intros assms)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. c ^ n / (c - (1::'a)) - (1::'a) / (c - (1::'a))) \<longlonglongrightarrow> (0::'a) / (c - (1::'a)) - (1::'a) / (c - (1::'a))

goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. c ^ n / (c - (1::'a)) - (1::'a) / (c - (1::'a))) \<longlonglongrightarrow> (0::'a) / (c - (1::'a)) - (1::'a) / (c - (1::'a))
[PROOF STEP]
have "(\<lambda>n. (c ^ n - 1) / (c - 1)) \<longlonglongrightarrow> 1 / (1 - c)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. c ^ n / (c - (1::'a)) - (1::'a) / (c - (1::'a))) \<longlonglongrightarrow> (0::'a) / (c - (1::'a)) - (1::'a) / (c - (1::'a))

goal (1 subgoal):
 1. (\<lambda>n. (c ^ n - (1::'a)) / (c - (1::'a))) \<longlonglongrightarrow> (1::'a) / ((1::'a) - c)
[PROOF STEP]
by (simp add: nonzero_minus_divide_right [OF neq_0] diff_divide_distrib)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (c ^ n - (1::'a)) / (c - (1::'a))) \<longlonglongrightarrow> (1::'a) / ((1::'a) - c)

goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
with neq_0
[PROOF STATE]
proof (chain)
picking this:
c - (1::'a) \<noteq> (0::'a)
(\<lambda>n. (c ^ n - (1::'a)) / (c - (1::'a))) \<longlonglongrightarrow> (1::'a) / ((1::'a) - c)
[PROOF STEP]
show "(\<lambda>n. c ^ n) sums (1 / (1 - c))"
[PROOF STATE]
proof (prove)
using this:
c - (1::'a) \<noteq> (0::'a)
(\<lambda>n. (c ^ n - (1::'a)) / (c - (1::'a))) \<longlonglongrightarrow> (1::'a) / ((1::'a) - c)

goal (1 subgoal):
 1. (^) c sums ((1::'a) / ((1::'a) - c))
[PROOF STEP]
by (simp add: sums_def geometric_sum)
[PROOF STATE]
proof (state)
this:
(^) c sums ((1::'a) / ((1::'a) - c))

goal:
No subgoals!
[PROOF STEP]
qed


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

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

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

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

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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma stieltjes_gamma_aux6: "(\<Sum>t<k. (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) -
                  Ln 2 ^ (k + 1) / of_nat (k + 1) =
                (-1)^k * fact k * (\<Sum>i=1..k+1. (-Ln 2) ^ i * A (k-(i-1)) / fact i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
have "(\<Sum>t<k. (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) -
          Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1
[PROOF STEP]
using stieltjes_gamma_aux5[of k]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (deriv ^^ k) g 1

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
have "(deriv ^^ k) g 1 = fact k * fps_nth G k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (deriv ^^ k) g 1 = fact k * G $ k
[PROOF STEP]
by (rule stieltjes_gamma_aux2)
[PROOF STATE]
proof (state)
this:
(deriv ^^ k) g 1 = fact k * G $ k

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(deriv ^^ k) g 1 = fact k * G $ k

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
have "fps_nth G k = (\<Sum>i=1..k + 1. (-Ln 2) ^ i * A (k - (i - 1)) / fact i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. G $ k = (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
by (rule stieltjes_gamma_aux4)
[PROOF STATE]
proof (state)
this:
G $ k = (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * (fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i))

goal (1 subgoal):
 1. (\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)
[PROOF STEP]
by (simp add: mult_ac)
[PROOF STATE]
proof (state)
this:
(\<Sum>t<k. of_nat (k choose t) * Ln 2 ^ (k - t) * stieltjes_gamma t) - Ln 2 ^ (k + 1) / of_nat (k + 1) = (- 1) ^ k * fact k * (\<Sum>i = 1..k + 1. (- Ln 2) ^ i * A (k - (i - 1)) / fact i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma kronecker_inverse_index:
  assumes "r < dim_row A" "s < dim_col A"
  assumes "v < dim_row B" "w < dim_col B"
  shows "kronecker_product A B $$ (dim_row B*r+v, dim_col B*s+w) = A $$ (r,s) * B $$ (v,w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
from arith[OF assms(1) assms(3)]
[PROOF STATE]
proof (chain)
picking this:
dim_row B * r + v < dim_row A * dim_row B
[PROOF STEP]
have "dim_row B*r+v < dim_row A * dim_row B"
[PROOF STATE]
proof (prove)
using this:
dim_row B * r + v < dim_row A * dim_row B

goal (1 subgoal):
 1. dim_row B * r + v < dim_row A * dim_row B
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_row B * r + v < dim_row A * dim_row B

goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_row B * r + v < dim_row A * dim_row B

goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
from arith[OF assms(2) assms(4)]
[PROOF STATE]
proof (chain)
picking this:
dim_col B * s + w < dim_col A * dim_col B
[PROOF STEP]
have "dim_col B * s + w < dim_col A * dim_col B"
[PROOF STATE]
proof (prove)
using this:
dim_col B * s + w < dim_col A * dim_col B

goal (1 subgoal):
 1. dim_col B * s + w < dim_col A * dim_col B
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_col B * s + w < dim_col A * dim_col B

goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_row B * r + v < dim_row A * dim_row B
dim_col B * s + w < dim_col A * dim_col B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_row B * r + v < dim_row A * dim_row B
dim_col B * s + w < dim_col A * dim_col B

goal (1 subgoal):
 1. kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
unfolding kronecker_product_def Let_def
[PROOF STATE]
proof (prove)
using this:
dim_row B * r + v < dim_row A * dim_row B
dim_col B * s + w < dim_col A * dim_col B

goal (1 subgoal):
 1. mat (dim_row A * dim_row B) (dim_col A * dim_col B) (\<lambda>(i, j). A $$ (i div dim_row B, j div dim_col B) * B $$ (i mod dim_row B, j mod dim_col B)) $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
dim_row B * r + v < dim_row A * dim_row B
dim_col B * s + w < dim_col A * dim_col B
r < dim_row A
s < dim_col A
v < dim_row B
w < dim_col B

goal (1 subgoal):
 1. mat (dim_row A * dim_row B) (dim_col A * dim_col B) (\<lambda>(i, j). A $$ (i div dim_row B, j div dim_col B) * B $$ (i mod dim_row B, j mod dim_col B)) $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
kronecker_product A B $$ (dim_row B * r + v, dim_col B * s + w) = A $$ (r, s) * B $$ (v, w)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_cube_plus_cos_cube:
  "sin x ^ 3 + cos x ^ 3 = 1/2 * (sin x + cos x) * (2 - sin (2 * x))"
  for x :: "'a::{real_normed_field,banach}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))
[PROOF STEP]
have "sin x ^ 3 + cos x ^ 3 = (sin x + cos x) * (cos x ^ 2 - cos x * sin x + sin x ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (sin x + cos x) * ((cos x)\<^sup>2 - cos x * sin x + (sin x)\<^sup>2)
[PROOF STEP]
by (smt (z3) add.commute combine_common_factor diff_add_cancel distrib_left
          mult.commute mult.left_commute power2_eq_square power3_eq_cube)
[PROOF STATE]
proof (state)
this:
sin x ^ 3 + cos x ^ 3 = (sin x + cos x) * ((cos x)\<^sup>2 - cos x * sin x + (sin x)\<^sup>2)

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

goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))
[PROOF STEP]
have "\<dots> = (sin x + cos x) * (1 - cos x * sin x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sin x + cos x) * ((cos x)\<^sup>2 - cos x * sin x + (sin x)\<^sup>2) = (sin x + cos x) * ((1::'a) - cos x * sin x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(sin x + cos x) * ((cos x)\<^sup>2 - cos x * sin x + (sin x)\<^sup>2) = (sin x + cos x) * ((1::'a) - cos x * sin x)

goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sin x ^ 3 + cos x ^ 3 = (sin x + cos x) * ((1::'a) - cos x * sin x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sin x ^ 3 + cos x ^ 3 = (sin x + cos x) * ((1::'a) - cos x * sin x)

goal (1 subgoal):
 1. sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))
[PROOF STEP]
by (smt (z3) mult.commute mult.left_neutral mult_2 nonzero_mult_div_cancel_left
          right_diff_distrib' sin_add times_divide_eq_left zero_neq_numeral)
[PROOF STATE]
proof (state)
this:
sin x ^ 3 + cos x ^ 3 = (1::'a) / (2::'a) * (sin x + cos x) * ((2::'a) - sin ((2::'a) * x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ld_ld_1_less:
  assumes "x > 0" "y > 0" shows "log 2 x + log 2 y + 1 < 2 * log 2 (x+y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
have "2 powr (log 2 x + log 2 y + 1) = 2*x*y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 powr (log 2 x + log 2 y + 1) = 2 * x * y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
0 < y

goal (1 subgoal):
 1. 2 powr (log 2 x + log 2 y + 1) = 2 * x * y
[PROOF STEP]
by(simp add: powr_add)
[PROOF STATE]
proof (state)
this:
2 powr (log 2 x + log 2 y + 1) = 2 * x * y

goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 powr (log 2 x + log 2 y + 1) = 2 * x * y

goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
have "\<dots> < (x+y)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * x * y < (x + y)\<^sup>2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
0 < y

goal (1 subgoal):
 1. 2 * x * y < (x + y)\<^sup>2
[PROOF STEP]
by(simp add: numeral_eq_Suc algebra_simps add_pos_pos)
[PROOF STATE]
proof (state)
this:
2 * x * y < (x + y)\<^sup>2

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

goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
have "\<dots> = 2 powr (2 * log 2 (x+y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y)\<^sup>2 = 2 powr (2 * log 2 (x + y))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
0 < y

goal (1 subgoal):
 1. (x + y)\<^sup>2 = 2 powr (2 * log 2 (x + y))
[PROOF STEP]
by(simp add: powr_add log_powr[symmetric])
[PROOF STATE]
proof (state)
this:
(x + y)\<^sup>2 = 2 powr (2 * log 2 (x + y))

goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 powr (log 2 x + log 2 y + 1) < 2 powr (2 * log 2 (x + y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 powr (log 2 x + log 2 y + 1) < 2 powr (2 * log 2 (x + y))

goal (1 subgoal):
 1. log 2 x + log 2 y + 1 < 2 * log 2 (x + y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
log 2 x + log 2 y + 1 < 2 * log 2 (x + y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_of_poly_n_add: "vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n
[PROOF STEP]
proof (induct n arbitrary: a b)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. vec_of_poly_n (a + b) 0 = vec_of_poly_n a 0 + vec_of_poly_n b 0
 2. \<And>n a b. (\<And>a b. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n) \<Longrightarrow> vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>a b. vec_of_poly_n (a + b) 0 = vec_of_poly_n a 0 + vec_of_poly_n b 0
 2. \<And>n a b. (\<And>a b. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n) \<Longrightarrow> vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (a + b) 0 = vec_of_poly_n a 0 + vec_of_poly_n b 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (a + b) 0 = vec_of_poly_n a 0 + vec_of_poly_n b 0

goal (1 subgoal):
 1. \<And>n a b. (\<And>a b. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n) \<Longrightarrow> vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n a b. (\<And>a b. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n) \<Longrightarrow> vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (?a + ?b) n = vec_of_poly_n ?a n + vec_of_poly_n ?b n

goal (1 subgoal):
 1. \<And>n a b. (\<And>a b. vec_of_poly_n (a + b) n = vec_of_poly_n a n + vec_of_poly_n b n) \<Longrightarrow> vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec_of_poly_n (?a + ?b) n = vec_of_poly_n ?a n + vec_of_poly_n ?b n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
vec_of_poly_n (?a + ?b) n = vec_of_poly_n ?a n + vec_of_poly_n ?b n

goal (1 subgoal):
 1. vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)
[PROOF STEP]
by (cases a, cases b, auto)
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (a + b) (Suc n) = vec_of_poly_n a (Suc n) + vec_of_poly_n b (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma csegment_midpoint_subset: "closed_segment (midpoint a b) b \<subseteq> closed_segment a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed_segment (midpoint a b) b \<subseteq> closed_segment a b
[PROOF STEP]
apply (clarsimp simp: midpoint_def in_segment)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>u. \<lbrakk>0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> \<exists>ua\<ge>0. ua \<le> 1 \<and> ((1 - u) / 2) *\<^sub>R (a + b) + u *\<^sub>R b = (1 - ua) *\<^sub>R a + ua *\<^sub>R b
[PROOF STEP]
apply (rule_tac x="(1 + u) / 2" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>u. \<lbrakk>0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> 0 \<le> (1 + u) / 2 \<and> (1 + u) / 2 \<le> 1 \<and> ((1 - u) / 2) *\<^sub>R (a + b) + u *\<^sub>R b = (1 - (1 + u) / 2) *\<^sub>R a + ((1 + u) / 2) *\<^sub>R b
[PROOF STEP]
apply (auto simp: algebra_simps add_divide_distrib diff_divide_distrib)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>u. \<lbrakk>0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> u *\<^sub>R b = (u / 2) *\<^sub>R b + (u / 2) *\<^sub>R b
[PROOF STEP]
by (metis field_sum_of_halves scaleR_left.add)


[STATEMENT]
lemma poly_of_list_split_at: assumes "split_at n f = (f0,f1)"
  shows "poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
split_at n f = (f0, f1)
[PROOF STEP]
have id: "f1 = drop n f" "f0 = take n f"
[PROOF STATE]
proof (prove)
using this:
split_at n f = (f0, f1)

goal (1 subgoal):
 1. f1 = drop n f &&& f0 = take n f
[PROOF STEP]
unfolding split_at_def
[PROOF STATE]
proof (prove)
using this:
(take n f, drop n f) = (f0, f1)

goal (1 subgoal):
 1. f1 = drop n f &&& f0 = take n f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f1 = drop n f
f0 = take n f

goal (1 subgoal):
 1. poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_list f = monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)
[PROOF STEP]
proof (rule poly_eqI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff (poly_of_list f) na = coeff (monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)) na
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff (poly_of_list f) na = coeff (monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)) na
[PROOF STEP]
show "coeff (poly_of_list f) i =
      coeff (monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (poly_of_list f) i = coeff (monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)) i
[PROOF STEP]
unfolding monom_mult_def coeff_monom_mult coeff_add poly_of_list_def coeff_Poly
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_default (0::'a) f i = (if n \<le> i then (1::'a) * nth_default (0::'a) (drop n f) (i - n) else (0::'a)) + nth_default (0::'a) (take n f) i
[PROOF STEP]
by (cases "n \<le> i"; cases "i \<ge> length f", auto simp: nth_default_nth nth_default_beyond)
[PROOF STATE]
proof (state)
this:
coeff (poly_of_list f) i = coeff (monom_mult n (poly_of_list (drop n f)) + poly_of_list (take n f)) i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly_of_list f = monom_mult n (poly_of_list f1) + poly_of_list f0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_lessThan_split:
fixes g :: "nat \<Rightarrow> real" shows "prod g {..<n+m} = prod g {..<n} * prod (\<lambda>x. g (x+n)) {..<m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod g {..<n + m} = prod g {..<n} * (\<Prod>x<m. g (x + n))
[PROOF STEP]
using Groups_Big.comm_monoid_mult_class.prod.union_inter_neutral[of "{..<n}" "{n..<n+m}" g, unfolded ivl_disj_un_one(2)[OF le_add1], OF finite_lessThan finite_atLeastLessThan]
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{..<n} \<inter> {n..<n + m}. g x = 1 \<Longrightarrow> prod g {..<n + m} = prod g {..<n} * prod g {n..<n + m}

goal (1 subgoal):
 1. prod g {..<n + m} = prod g {..<n} * (\<Prod>x<m. g (x + n))
[PROOF STEP]
by (metis (no_types) add.commute add.left_neutral atLeast0LessThan empty_iff ivl_disj_int_one(2) prod.shift_bounds_nat_ivl)


[STATEMENT]
lemma injf_max_order_preserving2:
  assumes "m < n" and E: "\<forall>x. \<exists>y \<in> E. x < y"
  shows  "injf_max m E < injf_max n E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. injf_max m E < injf_max n E
[PROOF STEP]
using \<open>m < n\<close>
[PROOF STATE]
proof (prove)
using this:
m < n

goal (1 subgoal):
 1. injf_max m E < injf_max n E
[PROOF STEP]
proof (induction n arbitrary: m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. m < 0 \<Longrightarrow> injf_max m E < injf_max 0 E
 2. \<And>n m. \<lbrakk>\<And>m. m < n \<Longrightarrow> injf_max m E < injf_max n E; m < Suc n\<rbrakk> \<Longrightarrow> injf_max m E < injf_max (Suc n) E
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
m < 0

goal (2 subgoals):
 1. \<And>m. m < 0 \<Longrightarrow> injf_max m E < injf_max 0 E
 2. \<And>n m. \<lbrakk>\<And>m. m < n \<Longrightarrow> injf_max m E < injf_max n E; m < Suc n\<rbrakk> \<Longrightarrow> injf_max m E < injf_max (Suc n) E
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m < 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
m < 0

goal (1 subgoal):
 1. injf_max m E < injf_max 0 E
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
injf_max m E < injf_max 0 E

goal (1 subgoal):
 1. \<And>n m. \<lbrakk>\<And>m. m < n \<Longrightarrow> injf_max m E < injf_max n E; m < Suc n\<rbrakk> \<Longrightarrow> injf_max m E < injf_max (Suc n) E
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n m. \<lbrakk>\<And>m. m < n \<Longrightarrow> injf_max m E < injf_max n E; m < Suc n\<rbrakk> \<Longrightarrow> injf_max m E < injf_max (Suc n) E
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
?m < n \<Longrightarrow> injf_max ?m E < injf_max n E
m < Suc n

goal (1 subgoal):
 1. \<And>n m. \<lbrakk>\<And>m. m < n \<Longrightarrow> injf_max m E < injf_max n E; m < Suc n\<rbrakk> \<Longrightarrow> injf_max m E < injf_max (Suc n) E
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?m < n \<Longrightarrow> injf_max ?m E < injf_max n E
m < Suc n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?m < n \<Longrightarrow> injf_max ?m E < injf_max n E
m < Suc n

goal (1 subgoal):
 1. injf_max m E < injf_max (Suc n) E
[PROOF STEP]
by (metis E injf_max_order_preserving less_Suc_eq order_less_trans)
[PROOF STATE]
proof (state)
this:
injf_max m E < injf_max (Suc n) E

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_bijections_domain_and_range_permutation:
  assumes "finite A" "finite B"
  shows "card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_and_range_permutation A B) = iverson (card A = card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_and_range_permutation A B) = iverson (card A = card B)
[PROOF STEP]
using assms card_bijections_domain_and_range_permutation_eq_0 card_bijections_domain_and_range_permutation_eq_1
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card ?A \<noteq> card ?B \<Longrightarrow> card ({f \<in> ?A \<rightarrow>\<^sub>E ?B. bij_betw f ?A ?B} // domain_and_range_permutation ?A ?B) = 0
\<lbrakk>finite ?A; finite ?B; card ?A = card ?B\<rbrakk> \<Longrightarrow> card ({f \<in> ?A \<rightarrow>\<^sub>E ?B. bij_betw f ?A ?B} // domain_and_range_permutation ?A ?B) = 1

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_and_range_permutation A B) = iverson (card A = card B)
[PROOF STEP]
unfolding iverson_def
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card ?A \<noteq> card ?B \<Longrightarrow> card ({f \<in> ?A \<rightarrow>\<^sub>E ?B. bij_betw f ?A ?B} // domain_and_range_permutation ?A ?B) = 0
\<lbrakk>finite ?A; finite ?B; card ?A = card ?B\<rbrakk> \<Longrightarrow> card ({f \<in> ?A \<rightarrow>\<^sub>E ?B. bij_betw f ?A ?B} // domain_and_range_permutation ?A ?B) = 1

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_and_range_permutation A B) = (if card A = card B then 1 else 0)
[PROOF STEP]
by auto


[STATEMENT]
lemma not_icard_Diff_subset: "\<exists>(A::nat set) B. B \<subseteq> A \<and> \<not> icard (A - B) = icard A - icard B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>A B. B \<subseteq> A \<and> icard (A - B) \<noteq> icard A - icard B
[PROOF STEP]
apply (rule_tac x="{0..}" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>B\<subseteq>{0..}. icard ({0..} - B) \<noteq> icard {0..} - icard B
[PROOF STEP]
apply (rule_tac x="{1..}" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1..} \<subseteq> {0..} \<and> icard ({0..} - {1..}) \<noteq> icard {0..} - icard {1..}
[PROOF STEP]
apply (simp add: set_diff_eq linorder_not_le icard_UNIV_nat eSuc_enat)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)"
  for w :: "'a::{real_normed_field,banach}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin w + sin z = (2::'a) * sin ((w + z) / (2::'a)) * cos ((w - z) / (2::'a))
[PROOF STEP]
apply (simp add: mult.assoc sin_times_cos)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin w * (2::'a) + sin z * (2::'a) = (2::'a) * sin ((w + z) / (2::'a) + (w - z) / (2::'a)) + (2::'a) * sin ((w + z) / (2::'a) - (w - z) / (2::'a))
[PROOF STEP]
apply (simp add: field_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma precedesTransitivity:
  assumes
  "precedes a b l" and "precedes b c l"
  shows
  "precedes a c l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. precedes a c l
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
precedes a b l
precedes b c l

goal (1 subgoal):
 1. precedes a c l
[PROOF STEP]
unfolding precedes_def
[PROOF STATE]
proof (prove)
using this:
a \<in> set l \<and> b \<in> set l \<and> firstPos a l \<le> firstPos b l
b \<in> set l \<and> c \<in> set l \<and> firstPos b l \<le> firstPos c l

goal (1 subgoal):
 1. a \<in> set l \<and> c \<in> set l \<and> firstPos a l \<le> firstPos c l
[PROOF STEP]
by auto


[STATEMENT]
lemma exproj_psi_minus_1_tensor:
  "(2 \<cdot>\<^sub>m tensor_P proj_psi (1\<^sub>m K)) - 1\<^sub>m d = tensor_P (2 \<cdot>\<^sub>m proj_psi - (1\<^sub>m N)) (1\<^sub>m K)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<cdot>\<^sub>m tensor_P proj_psi (1\<^sub>m K) - 1\<^sub>m d = tensor_P (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
unfolding ps2_P.ptensor_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<cdot>\<^sub>m ps_P.tensor_mat proj_psi (1\<^sub>m K) - 1\<^sub>m d = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
apply (subst ps_P.tensor_mat_id[symmetric, simplified ps_P_d])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<cdot>\<^sub>m ps_P.tensor_mat proj_psi (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m ps_P.d1) (1\<^sub>m ps_P.d2) = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
apply (auto simp add: ps_P_d1 ps_P_d2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<cdot>\<^sub>m ps_P.tensor_mat proj_psi (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m N) (1\<^sub>m K) = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
apply (subst ps_P.tensor_mat_scale1[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. proj_psi \<in> carrier_mat ps_P.d1 ps_P.d1
 2. 1\<^sub>m K \<in> carrier_mat ps_P.d2 ps_P.d2
 3. ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi) (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m N) (1\<^sub>m K) = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
apply (auto simp add: ps_P_d1 ps_P_d2 proj_psi_dim)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi) (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m N) (1\<^sub>m K) = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi - 1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
apply (subst ps_P.tensor_mat_minus1)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. 2 \<cdot>\<^sub>m proj_psi \<in> carrier_mat ps_P.d1 ps_P.d1
 2. 1\<^sub>m N \<in> carrier_mat ps_P.d1 ps_P.d1
 3. 1\<^sub>m K \<in> carrier_mat ps_P.d2 ps_P.d2
 4. ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi) (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m N) (1\<^sub>m K) = ps_P.tensor_mat (2 \<cdot>\<^sub>m proj_psi) (1\<^sub>m K) - ps_P.tensor_mat (1\<^sub>m N) (1\<^sub>m K)
[PROOF STEP]
by (auto simp add: ps_P_d1 ps_P_d2 proj_psi_dim)


[STATEMENT]
theorem card_partition_on:
  assumes "finite A"
  shows "card {P. partition_on A P \<and> card P = k} = Stirling (card A) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k
[PROOF STEP]
proof (induct A arbitrary: k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>k. card {P. partition_on {} P \<and> card P = k} = Stirling (card {}) k
 2. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>k. card {P. partition_on {} P \<and> card P = k} = Stirling (card {}) k
 2. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
have eq: "{P. P = {} \<and> card P = 0} = {{}}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {P. P = {} \<and> card P = 0} = {{}}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{P. P = {} \<and> card P = 0} = {{}}

goal (2 subgoals):
 1. \<And>k. card {P. partition_on {} P \<and> card P = k} = Stirling (card {}) k
 2. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on {} P \<and> card P = k} = Stirling (card {}) k
[PROOF STEP]
by (cases k) (auto simp add: partition_on_empty eq)
[PROOF STATE]
proof (state)
this:
card {P. partition_on {} P \<and> card P = k} = Stirling (card {}) k

goal (1 subgoal):
 1. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
case (insert a A)
[PROOF STATE]
proof (state)
this:
finite A
a \<notin> A
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k

goal (1 subgoal):
 1. \<And>x F k. \<lbrakk>finite F; x \<notin> F; \<And>k. card {P. partition_on F P \<and> card P = k} = Stirling (card F) k\<rbrakk> \<Longrightarrow> card {P. partition_on (insert x F) P \<and> card P = k} = Stirling (card (insert x F)) k
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
finite A
a \<notin> A
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite A
a \<notin> A
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k

goal (1 subgoal):
 1. card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
proof (cases k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = 0\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
 2. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
k = 0

goal (2 subgoals):
 1. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = 0\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
 2. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
from insert(1)
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
have empty: "{P. partition_on (insert a A) P \<and> card P = 0} = {}"
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. {P. partition_on (insert a A) P \<and> card P = 0} = {}
[PROOF STEP]
unfolding partition_on_def
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. {P. (\<Union> P = insert a A \<and> disjoint P \<and> {} \<notin> P) \<and> card P = 0} = {}
[PROOF STEP]
by (auto simp add: card_eq_0_iff finite_UnionD)
[PROOF STATE]
proof (state)
this:
{P. partition_on (insert a A) P \<and> card P = 0} = {}

goal (2 subgoals):
 1. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = 0\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
 2. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
from 0 insert
[PROOF STATE]
proof (chain)
picking this:
k = 0
finite A
a \<notin> A
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k = 0
finite A
a \<notin> A
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k

goal (1 subgoal):
 1. card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
by (auto simp add: empty)
[PROOF STATE]
proof (state)
this:
card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
k = Suc k'

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
let ?subexpr1 = "do {
      P <- {P. partition_on A P \<and> card P = Suc k'};
      p <- P;
      {insert (insert a p) (P - {p})}
    }"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
let ?subexpr2 = "do {
      P <- {P. partition_on A P \<and> card P = k'};
      {insert {a} P}
    }"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
let ?expr = "?subexpr1 \<union> ?subexpr2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
have "card {P. partition_on (insert a A) P \<and> card P = k} = card ?expr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on (insert a A) P \<and> card P = k} = card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})))
[PROOF STEP]
using \<open>finite A\<close> \<open>a \<notin> A\<close> \<open>k = Suc k'\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
a \<notin> A
k = Suc k'

goal (1 subgoal):
 1. card {P. partition_on (insert a A) P \<and> card P = k} = card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})))
[PROOF STEP]
by (simp add: set_partition_on_insert_with_fixed_card_eq)
[PROOF STATE]
proof (state)
this:
card {P. partition_on (insert a A) P \<and> card P = k} = card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})))

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {P. partition_on (insert a A) P \<and> card P = k} = card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})))

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
have "card ?expr = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "finite ?subexpr1 \<and> card ?subexpr1 = Stirling (card A) (Suc k') * Suc k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
from \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
have "finite {P. partition_on A P \<and> card P = Suc k'}"
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. finite {P. partition_on A P \<and> card P = Suc k'}
[PROOF STEP]
by (simp add: finitely_many_partition_on)
[PROOF STATE]
proof (state)
this:
finite {P. partition_on A P \<and> card P = Suc k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {P. partition_on A P \<and> card P = Suc k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))
[PROOF STEP]
using finite_elements \<open>finite A\<close> finite_bind
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; partition_on ?A ?P\<rbrakk> \<Longrightarrow> finite ?P
finite A
\<lbrakk>finite ?S; \<forall>x\<in>?S. finite (?f x)\<rbrakk> \<Longrightarrow> finite (?S \<bind> ?f)

goal (1 subgoal):
 1. \<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))
[PROOF STEP]
by (metis (no_types, lifting) finite.emptyI finite_insert mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}
[PROOF STEP]
by (injectivity_solver rule: injectivity_subexpr1(1)[OF \<open>a \<notin> A\<close>])
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'"
          if "P \<in> {P. partition_on A P \<and> card P = Suc k'}" for P
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
from that \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}
finite A
[PROOF STEP]
have "finite P"
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}
finite A

goal (1 subgoal):
 1. finite P
[PROOF STEP]
using finite_elements
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}
finite A
\<lbrakk>finite ?A; partition_on ?A ?P\<rbrakk> \<Longrightarrow> finite ?P

goal (1 subgoal):
 1. finite P
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite P

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite P

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
have "inj_on (\<lambda>p. insert (insert a p) (P - {p})) P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>p. insert (insert a p) (P - {p})) P
[PROOF STEP]
using that injectivity_subexpr1(2)[OF \<open>a \<notin> A\<close>]
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}
\<lbrakk>?X \<in> ?P \<and> ?X' \<in> ?P'; insert (insert a ?X) (?P - {?X}) = insert (insert a ?X') (?P' - {?X'}); (partition_on A ?P \<and> card ?P = Suc ?k') \<and> partition_on A ?P' \<and> card ?P' = Suc ?k'\<rbrakk> \<Longrightarrow> ?X = ?X'

goal (1 subgoal):
 1. inj_on (\<lambda>p. insert (insert a p) (P - {p})) P
[PROOF STEP]
by (simp add: inj_onI)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>p. insert (insert a p) (P - {p})) P

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>p. insert (insert a p) (P - {p})) P

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
from that
[PROOF STATE]
proof (chain)
picking this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}
[PROOF STEP]
have "card P = Suc k'"
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. partition_on A P \<and> card P = Suc k'}

goal (1 subgoal):
 1. card P = Suc k'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card P = Suc k'

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite P
inj_on (\<lambda>p. insert (insert a p) (P - {p})) P
card P = Suc k'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite P
inj_on (\<lambda>p. insert (insert a p) (P - {p})) P
card P = Suc k'

goal (1 subgoal):
 1. card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'
[PROOF STEP]
by (simp add: card_bind_singleton)
[PROOF STATE]
proof (state)
this:
card (P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) = Suc k'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?P \<in> {P. partition_on A P \<and> card P = Suc k'} \<Longrightarrow> card (?P \<bind> (\<lambda>p. {insert (insert a p) (?P - {p})})) = Suc k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {P. partition_on A P \<and> card P = Suc k'}
\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))
disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}
?P \<in> {P. partition_on A P \<and> card P = Suc k'} \<Longrightarrow> card (?P \<bind> (\<lambda>p. {insert (insert a p) (?P - {p})})) = Suc k'
[PROOF STEP]
have "card ?subexpr1 = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'"
[PROOF STATE]
proof (prove)
using this:
finite {P. partition_on A P \<and> card P = Suc k'}
\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))
disjoint_family_on (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})) {P. partition_on A P \<and> card P = Suc k'}
?P \<in> {P. partition_on A P \<and> card P = Suc k'} \<Longrightarrow> card (?P \<bind> (\<lambda>p. {insert (insert a p) (?P - {p})})) = Suc k'

goal (1 subgoal):
 1. card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'
[PROOF STEP]
by (subst card_bind_constant) simp+
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'
[PROOF STEP]
have "card ?subexpr1 = Stirling (card A) (Suc k') * Suc k'"
[PROOF STATE]
proof (prove)
using this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'

goal (1 subgoal):
 1. card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
using insert.hyps(3)
[PROOF STATE]
proof (prove)
using this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = card {P. partition_on A P \<and> card P = Suc k'} * Suc k'
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k

goal (1 subgoal):
 1. card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "finite ?subexpr1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})))
[PROOF STEP]
using \<open>finite {P. partition_on A P \<and> card P = Suc k'}\<close>
          \<open>\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))\<close>
[PROOF STATE]
proof (prove)
using this:
finite {P. partition_on A P \<and> card P = Suc k'}
\<forall>X\<in>{P. partition_on A P \<and> card P = Suc k'}. finite (X \<bind> (\<lambda>p. {insert (insert a p) (X - {p})}))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})))
[PROOF STEP]
by (auto intro: finite_bind)
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "finite ?subexpr2 \<and> card ?subexpr2 = Stirling (card A) k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
from \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
have "finite {P. partition_on A P \<and> card P = k'}"
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. finite {P. partition_on A P \<and> card P = k'}
[PROOF STEP]
by (simp add: finitely_many_partition_on)
[PROOF STATE]
proof (state)
this:
finite {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
have " inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}
[PROOF STEP]
using injectivity_subexpr2[OF \<open>a \<notin> A\<close>]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>insert {a} ?P = insert {a} ?P'; (partition_on A ?P \<and> card ?P = ?k') \<and> partition_on A ?P' \<and> card ?P' = ?k'\<rbrakk> \<Longrightarrow> ?P = ?P'

goal (1 subgoal):
 1. inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}
[PROOF STEP]
by (simp add: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {P. partition_on A P \<and> card P = k'}
inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}
[PROOF STEP]
have "card ?subexpr2 = card {P. partition_on A P \<and> card P = k'}"
[PROOF STATE]
proof (prove)
using this:
finite {P. partition_on A P \<and> card P = k'}
inj_on (insert {a}) {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = card {P. partition_on A P \<and> card P = k'}
[PROOF STEP]
by (simp add: card_bind_singleton)
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = card {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = card {P. partition_on A P \<and> card P = k'}

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
have "\<dots> = Stirling (card A) k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P = k'} = Stirling (card A) k'
[PROOF STEP]
using insert.hyps(3)
[PROOF STATE]
proof (prove)
using this:
card {P. partition_on A P \<and> card P = ?k} = Stirling (card A) ?k

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P = k'} = Stirling (card A) k'
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P = k'} = Stirling (card A) k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
have "card ?subexpr2 = Stirling (card A) k'"
[PROOF STATE]
proof (prove)
using this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal (1 subgoal):
 1. card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
have "finite ?subexpr2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))
[PROOF STEP]
by (simp add: \<open>finite {P. partition_on A P \<and> card P = k'}\<close> finite_bind)
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))

goal (1 subgoal):
 1. finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
have "?subexpr1 \<inter> ?subexpr2 = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
have "\<forall>P\<in>?subexpr1. {a} \<notin> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P
[PROOF STEP]
using insert.hyps(2)
[PROOF STATE]
proof (prove)
using this:
a \<notin> A

goal (1 subgoal):
 1. \<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P
[PROOF STEP]
by (force elim!: partition_onE)
[PROOF STATE]
proof (state)
this:
\<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P

goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P

goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
have "\<forall>P\<in>?subexpr2. {a} \<in> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>P\<in>{P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}). {a} \<in> P
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>P\<in>{P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}). {a} \<in> P

goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P
\<forall>P\<in>{P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}). {a} \<in> P
[PROOF STEP]
show "?subexpr1 \<inter> ?subexpr2 = {}"
[PROOF STATE]
proof (prove)
using this:
\<forall>P\<in>{P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})})). {a} \<notin> P
\<forall>P\<in>{P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}). {a} \<in> P

goal (1 subgoal):
 1. ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<and> card ({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) = Stirling (card A) (Suc k') * Suc k'
finite ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) \<and> card ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = Stirling (card A) k'
({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<inter> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P})) = {}

goal (1 subgoal):
 1. card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'
[PROOF STEP]
by (simp add: card_Un_disjoint)
[PROOF STATE]
proof (state)
this:
card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (({P. partition_on A P \<and> card P = Suc k'} \<bind> (\<lambda>P. P \<bind> (\<lambda>p. {insert (insert a p) (P - {p})}))) \<union> ({P. partition_on A P \<and> card P = k'} \<bind> (\<lambda>P. {insert {a} P}))) = Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k'

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
have "\<dots> = Stirling (card (insert a A)) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k' = Stirling (card (insert a A)) k
[PROOF STEP]
using insert(1, 2) \<open>k = Suc k'\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
a \<notin> A
k = Suc k'

goal (1 subgoal):
 1. Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k' = Stirling (card (insert a A)) k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Stirling (card A) k' + Stirling (card A) (Suc k') * Suc k' = Stirling (card (insert a A)) k

goal (1 subgoal):
 1. \<And>nat. \<lbrakk>finite A; a \<notin> A; \<And>k. card {P. partition_on A P \<and> card P = k} = Stirling (card A) k; k = Suc nat\<rbrakk> \<Longrightarrow> card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k

goal (1 subgoal):
 1. card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {P. partition_on (insert a A) P \<and> card P = k} = Stirling (card (insert a A)) k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scalar_product_linear_right:
  "scalar_product a (b+c) =
   scalar_product a b + scalar_product a (c :: ('a qr, 'k) vec)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_product a (b + c) = scalar_product a b + scalar_product a c
[PROOF STEP]
unfolding scalar_product_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. a $ i * (b + c) $ i) = (\<Sum>i\<in>UNIV. a $ i * b $ i) + (\<Sum>i\<in>UNIV. a $ i * c $ i)
[PROOF STEP]
by auto (metis (no_types, lifting) distrib_left sum.cong sum.distrib)


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

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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


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

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

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

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

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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma choose_reduce_nat:
  "0 < n \<Longrightarrow> 0 < k \<Longrightarrow>
    n choose k = ((n - 1) choose (k - 1)) + ((n - 1) choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < n; 0 < k\<rbrakk> \<Longrightarrow> n choose k = n - 1 choose (k - 1) + (n - 1 choose k)
[PROOF STEP]
using binomial_Suc_Suc [of "n - 1" "k - 1"]
[PROOF STATE]
proof (prove)
using this:
Suc (n - 1) choose Suc (k - 1) = n - 1 choose (k - 1) + (n - 1 choose Suc (k - 1))

goal (1 subgoal):
 1. \<lbrakk>0 < n; 0 < k\<rbrakk> \<Longrightarrow> n choose k = n - 1 choose (k - 1) + (n - 1 choose k)
[PROOF STEP]
by simp