[STATEMENT]
lemma ln_series:
  assumes "0 < x" and "x < 2"
  shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))"
    (is "ln x = suminf (?f (x - 1))")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)
[PROOF STEP]
let ?f' = "\<lambda>x n. (-1)^n * (x - 1)^n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)
[PROOF STEP]
have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) = ln 1 - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (1 - 1) ^ Suc a)
[PROOF STEP]
proof (rule DERIV_isconst3 [where x = x])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
fix x :: real
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
assume "x \<in> {0 <..< 2}"
[PROOF STATE]
proof (state)
this:
x \<in> {0<..<2}

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {0<..<2}
[PROOF STEP]
have "0 < x" and "x < 2"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0<..<2}

goal (1 subgoal):
 1. 0 < x &&& x < 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < x
x < 2

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have "norm (1 - x) < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (1 - x) < 1
[PROOF STEP]
using \<open>0 < x\<close> and \<open>x < 2\<close>
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 2

goal (1 subgoal):
 1. norm (1 - x) < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
norm (1 - x) < 1

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have "1 / x = 1 / (1 - (1 - x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / x = 1 / (1 - (1 - x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 / x = 1 / (1 - (1 - x))

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / x = 1 / (1 - (1 - x))

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have "\<dots> = (\<Sum> n. (1 - x)^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / (1 - (1 - x)) = (\<Sum>n. (1 - x) ^ n)
[PROOF STEP]
using geometric_sums[OF \<open>norm (1 - x) < 1\<close>]
[PROOF STATE]
proof (prove)
using this:
(^) (1 - x) sums (1 / (1 - (1 - x)))

goal (1 subgoal):
 1. 1 / (1 - (1 - x)) = (\<Sum>n. (1 - x) ^ n)
[PROOF STEP]
by (rule sums_unique)
[PROOF STATE]
proof (state)
this:
1 / (1 - (1 - x)) = (\<Sum>n. (1 - x) ^ n)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / (1 - (1 - x)) = (\<Sum>n. (1 - x) ^ n)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have "\<dots> = suminf (?f' x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. (1 - x) ^ n) = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)
[PROOF STEP]
unfolding power_mult_distrib[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. (1 - x) ^ n) = (\<Sum>n. (- 1 * (x - 1)) ^ n)
[PROOF STEP]
by (rule arg_cong[where f=suminf], rule arg_cong[where f="(^)"], auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>n. (1 - x) ^ n) = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 / x = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)
[PROOF STEP]
have "DERIV ln x :> suminf (?f' x)"
[PROOF STATE]
proof (prove)
using this:
1 / x = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)

goal (1 subgoal):
 1. (ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
using DERIV_ln[OF \<open>0 < x\<close>]
[PROOF STATE]
proof (prove)
using this:
1 / x = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)
(ln has_real_derivative inverse x) (at x)

goal (1 subgoal):
 1. (ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
unfolding divide_inverse
[PROOF STATE]
proof (prove)
using this:
1 * inverse x = (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)
(ln has_real_derivative inverse x) (at x)

goal (1 subgoal):
 1. (ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have repos: "\<And> h x :: real. h - 1 + x = h + x - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>h x. h - 1 + x = h + x - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?h1 - 1 + ?x1 = ?h1 + ?x1 - 1

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :>
      (\<Sum>n. (-1)^n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)) (at (x - 1))
[PROOF STEP]
proof (rule DERIV_power_series')
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> {- ?R<..<?R} \<Longrightarrow> summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
 2. x - 1 \<in> {- ?R<..<?R}
 3. 0 < ?R
[PROOF STEP]
show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x - 1 \<in> {- 1<..<1} &&& 0 < 1
[PROOF STEP]
using \<open>0 < x\<close> \<open>x < 2\<close>
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 2

goal (1 subgoal):
 1. x - 1 \<in> {- 1<..<1} &&& 0 < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x - 1 \<in> {- 1<..<1}
0 < 1

goal (1 subgoal):
 1. \<And>x. x \<in> {- 1<..<1} \<Longrightarrow> summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {- 1<..<1} \<Longrightarrow> summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
[PROOF STEP]
fix x :: real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {- 1<..<1} \<Longrightarrow> summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
[PROOF STEP]
assume "x \<in> {- 1<..<1}"
[PROOF STATE]
proof (state)
this:
x \<in> {- 1<..<1}

goal (1 subgoal):
 1. \<And>x. x \<in> {- 1<..<1} \<Longrightarrow> summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {- 1<..<1}
[PROOF STEP]
show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)"
[PROOF STATE]
proof (prove)
using this:
x \<in> {- 1<..<1}

goal (1 subgoal):
 1. summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)
[PROOF STEP]
by (simp add: abs_if flip: power_mult_distrib)
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)) (at (x - 1))

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)) (at (x - 1))
[PROOF STEP]
have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)) (at (x - 1))

goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at (x - 1))
[PROOF STEP]
unfolding One_nat_def
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + Suc 0)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (1 / real (n + Suc 0)) * real (Suc n) * (x - 1) ^ n)) (at (x - 1))

goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + Suc 0)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at (x - 1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at (x - 1))

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at (x - 1))
[PROOF STEP]
have "DERIV (\<lambda>x. suminf (?f (x - 1))) x :> suminf (?f' x)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * x ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at (x - 1))

goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
unfolding DERIV_def repos
[PROOF STATE]
proof (prove)
using this:
(\<lambda>h. ((\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x + h - 1) ^ Suc a) - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) / h) \<midarrow>0\<rightarrow> (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)

goal (1 subgoal):
 1. (\<lambda>h. ((\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x + h - 1) ^ Suc a) - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) / h) \<midarrow>0\<rightarrow> (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
have "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> suminf (?f' x) - suminf (?f' x)"
[PROOF STATE]
proof (prove)
using this:
(ln has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
((\<lambda>x. \<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (1 subgoal):
 1. ((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n) - (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
by (rule DERIV_diff)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n) - (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (4 subgoals):
 1. ?a < ?b
 2. x \<in> {?a<..<?b}
 3. 1 \<in> {?a<..<?b}
 4. \<And>x. x \<in> {?a<..<?b} \<Longrightarrow> ((\<lambda>a. ln a - (\<Sum>b. (- 1) ^ b * (1 / real (b + 1)) * (a - 1) ^ Suc b)) has_real_derivative 0) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n) - (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)
[PROOF STEP]
show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative (\<Sum>n. (- 1) ^ n * (x - 1) ^ n) - (\<Sum>n. (- 1) ^ n * (x - 1) ^ n)) (at x)

goal (1 subgoal):
 1. ((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative 0) (at x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((\<lambda>x. ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a)) has_real_derivative 0) (at x)

goal (3 subgoals):
 1. 0 < 2
 2. x \<in> {0<..<2}
 3. 1 \<in> {0<..<2}
[PROOF STEP]
qed (auto simp: assms)
[PROOF STATE]
proof (state)
this:
ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) = ln 1 - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (1 - 1) ^ Suc a)

goal (1 subgoal):
 1. ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) = ln 1 - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (1 - 1) ^ Suc a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ln x - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (x - 1) ^ Suc a) = ln 1 - (\<Sum>a. (- 1) ^ a * (1 / real (a + 1)) * (1 - 1) ^ Suc a)

goal (1 subgoal):
 1. ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ln x = (\<Sum>n. (- 1) ^ n * (1 / real (n + 1)) * (x - 1) ^ Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma twisted_cartesian_project_left:
  assumes "A \<subseteq> carrier (R\<^bsup>n\<^esup>)"
  assumes "B \<subseteq> carrier (R\<^bsup>m\<^esup>)"
  assumes "A \<noteq> {}"
  assumes "B \<noteq> {}"
  assumes "card S = n"
  assumes "card S' = m"
  assumes "S \<union> S' = {..<n + m}"
  shows "\<pi>\<^bsub>S\<^esub> ` (Prod\<^bsub>S,S'\<^esub> A B) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B = A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B \<subseteq> A
 2. A \<subseteq> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have f0: "S \<inter> S' = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<inter> S' = {}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. S \<inter> S' = {}
[PROOF STEP]
have "card (S \<union> S') = card S + card S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (S \<union> S') = card S + card S'
[PROOF STEP]
by (simp add: assms(5) assms(6) assms(7))
[PROOF STATE]
proof (state)
this:
card (S \<union> S') = card S + card S'

goal (1 subgoal):
 1. S \<inter> S' = {}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card (S \<union> S') = card S + card S'

goal (1 subgoal):
 1. S \<inter> S' = {}
[PROOF STEP]
by (metis Nat.add_diff_assoc2 add.right_neutral add_diff_cancel_left' assms(6)
        assms(7) card_0_eq card_Un_Int finite_Int finite_Un finite_lessThan le_add1)
[PROOF STATE]
proof (state)
this:
S \<inter> S' = {}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
S \<inter> S' = {}

goal (2 subgoals):
 1. (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B \<subseteq> A
 2. A \<subseteq> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
show "\<pi>\<^bsub>S\<^esub> ` (Prod\<^bsub>S,S'\<^esub> A B) \<subseteq> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B \<subseteq> A
[PROOF STEP]
unfolding twisted_cartesian_product_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>as. nths as S) ` {a. length a = card S + card S' \<and> nths a S \<in> A \<and> nths a S' \<in> B} \<subseteq> A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B \<subseteq> A

goal (1 subgoal):
 1. A \<subseteq> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
show "A \<subseteq> \<pi>\<^bsub>S\<^esub> ` (Prod\<^bsub>S,S'\<^esub> A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
assume A: "x \<in> A"
[PROOF STATE]
proof (state)
this:
x \<in> A

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
obtain y where y_def: "y \<in> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>y. y \<in> B \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms(4)
[PROOF STATE]
proof (prove)
using this:
B \<noteq> {}

goal (1 subgoal):
 1. (\<And>y. y \<in> B \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
y \<in> B

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
obtain a where a_def:
      "a = map (\<lambda>i. if i \<in> S then (x ! set_rank S i) else (y ! set_rank S' i)) [0..<n+m]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. a = map (\<lambda>i. if i \<in> S then x ! set_rank S i else y ! set_rank S' i) [0..<n + m] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a = map (\<lambda>i. if i \<in> S then x ! set_rank S i else y ! set_rank S' i) [0..<n + m]

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have 0: "S \<subseteq> indices_of a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<subseteq> indices_of a
[PROOF STEP]
by (metis (no_types, lifting) Un_upper1 a_def assms(7) diff_zero indices_of_def length_map length_upt)
[PROOF STATE]
proof (state)
this:
S \<subseteq> indices_of a

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have 1: "S' \<subseteq> indices_of a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S' \<subseteq> indices_of a
[PROOF STEP]
by (metis (no_types, lifting) Un_upper2 a_def assms(7) diff_zero indices_of_def length_map length_upt)
[PROOF STATE]
proof (state)
this:
S' \<subseteq> indices_of a

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have 2: "\<pi>\<^bsub>S\<^esub> a = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
have 20: "length (\<pi>\<^bsub>S\<^esub> a) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (nths a S) = n
[PROOF STEP]
by (metis (no_types, lifting) Un_upper1 a_def assms(5) assms(7) diff_zero indices_of_def length_map length_upt proj_at_index_list_length)
[PROOF STATE]
proof (state)
this:
length (nths a S) = n

goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
have "\<And>i. i < n \<Longrightarrow> \<pi>\<^bsub>S\<^esub> a ! i = x ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> nths a S ! i = x ! i
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> nths a S ! i = x ! i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> nths a S ! i = x ! i
[PROOF STEP]
assume A: "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> nths a S ! i = x ! i
[PROOF STEP]
show "\<pi>\<^bsub>S\<^esub> a ! i = x ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths a S ! i = x ! i
[PROOF STEP]
using 0 assms a_def project_at_indices_nth'[of S a "nth_elem S i"] set_rank_nth_elem_inv[of S i]
                nth_map[of i "[0..<n+m]"]
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> indices_of a
A \<subseteq> carrier (R\<^bsup>n\<^esup>)
B \<subseteq> carrier (R\<^bsup>m\<^esup>)
A \<noteq> {}
B \<noteq> {}
card S = n
card S' = m
S \<union> S' = {..<n + m}
a = map (\<lambda>i. if i \<in> S then x ! set_rank S i else y ! set_rank S' i) [0..<n + m]
\<lbrakk>S \<subseteq> indices_of a; nth_elem S i \<in> S\<rbrakk> \<Longrightarrow> a ! nth_elem S i = nths a S ! set_rank S (nth_elem S i)
\<lbrakk>finite S; i < card S\<rbrakk> \<Longrightarrow> set_rank S (nth_elem S i) = i
i < length [0..<n + m] \<Longrightarrow> map ?f [0..<n + m] ! i = ?f ([0..<n + m] ! i)

goal (1 subgoal):
 1. nths a S ! i = x ! i
[PROOF STEP]
by (smt (z3) A add.left_neutral card.infinite diff_zero indices_of_def length_map length_upt lessThan_iff not_less_zero nth_elem_closed nth_map nth_upt subsetD)
[PROOF STATE]
proof (state)
this:
nths a S ! i = x ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> nths a S ! ?i = x ! ?i

goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> nths a S ! ?i = x ! ?i

goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
using 20
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> nths a S ! ?i = x ! ?i
length (nths a S) = n

goal (1 subgoal):
 1. nths a S = x
[PROOF STEP]
by (metis A assms(1) cartesian_power_car_memE nth_equalityI subsetD)
[PROOF STATE]
proof (state)
this:
nths a S = x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
nths a S = x

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have 3: "\<pi>\<^bsub>S'\<^esub> a = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nths a S' = y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nths a S' = y
[PROOF STEP]
have 20: "length (\<pi>\<^bsub>S'\<^esub> a) = m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (nths a S') = m
[PROOF STEP]
using "1" assms(6) proj_at_index_list_length
[PROOF STATE]
proof (prove)
using this:
S' \<subseteq> indices_of a
card S' = m
?S \<subseteq> indices_of ?as \<Longrightarrow> length (nths ?as ?S) = card ?S

goal (1 subgoal):
 1. length (nths a S') = m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
length (nths a S') = m

goal (1 subgoal):
 1. nths a S' = y
[PROOF STEP]
have "\<And>i. i < m \<Longrightarrow> \<pi>\<^bsub>S'\<^esub> a ! i = y ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < m \<Longrightarrow> nths a S' ! i = y ! i
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < m \<Longrightarrow> nths a S' ! i = y ! i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < m \<Longrightarrow> nths a S' ! i = y ! i
[PROOF STEP]
assume A: "i < m"
[PROOF STATE]
proof (state)
this:
i < m

goal (1 subgoal):
 1. \<And>i. i < m \<Longrightarrow> nths a S' ! i = y ! i
[PROOF STEP]
have "nth_elem S' i \<notin> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_elem S' i \<notin> S
[PROOF STEP]
using nth_elem_closed[of i S']  f0  A assms(6)
[PROOF STATE]
proof (prove)
using this:
i < card S' \<Longrightarrow> nth_elem S' i \<in> S'
S \<inter> S' = {}
i < m
card S' = m

goal (1 subgoal):
 1. nth_elem S' i \<notin> S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
nth_elem S' i \<notin> S

goal (1 subgoal):
 1. \<And>i. i < m \<Longrightarrow> nths a S' ! i = y ! i
[PROOF STEP]
thus "\<pi>\<^bsub>S'\<^esub> a ! i = y ! i"
[PROOF STATE]
proof (prove)
using this:
nth_elem S' i \<notin> S

goal (1 subgoal):
 1. nths a S' ! i = y ! i
[PROOF STEP]
using 0 assms a_def project_at_indices_nth'[of S' a "nth_elem S' i"] set_rank_nth_elem_inv[of S' i]
                nth_map[of i "[0..<n+m]"]
[PROOF STATE]
proof (prove)
using this:
nth_elem S' i \<notin> S
S \<subseteq> indices_of a
A \<subseteq> carrier (R\<^bsup>n\<^esup>)
B \<subseteq> carrier (R\<^bsup>m\<^esup>)
A \<noteq> {}
B \<noteq> {}
card S = n
card S' = m
S \<union> S' = {..<n + m}
a = map (\<lambda>i. if i \<in> S then x ! set_rank S i else y ! set_rank S' i) [0..<n + m]
\<lbrakk>S' \<subseteq> indices_of a; nth_elem S' i \<in> S'\<rbrakk> \<Longrightarrow> a ! nth_elem S' i = nths a S' ! set_rank S' (nth_elem S' i)
\<lbrakk>finite S'; i < card S'\<rbrakk> \<Longrightarrow> set_rank S' (nth_elem S' i) = i
i < length [0..<n + m] \<Longrightarrow> map ?f [0..<n + m] ! i = ?f ([0..<n + m] ! i)

goal (1 subgoal):
 1. nths a S' ! i = y ! i
[PROOF STEP]
by (smt "1" A add.left_neutral card.infinite diff_zero indices_of_def length_map length_upt lessThan_iff not_less0 nth_elem_closed nth_map nth_upt subsetD)
[PROOF STATE]
proof (state)
this:
nths a S' ! i = y ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < m \<Longrightarrow> nths a S' ! ?i = y ! ?i

goal (1 subgoal):
 1. nths a S' = y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?i < m \<Longrightarrow> nths a S' ! ?i = y ! ?i

goal (1 subgoal):
 1. nths a S' = y
[PROOF STEP]
by (metis "20" assms(2) cartesian_power_car_memE nth_equalityI subsetD y_def)
[PROOF STATE]
proof (state)
this:
nths a S' = y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
nths a S' = y

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
have"a \<in> (Prod\<^bsub>S,S'\<^esub> A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
apply(rule twisted_cartesian_product_memI)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. nths a S \<in> A
 2. nths a S' \<in> B
 3. length a = card S + card S'
[PROOF STEP]
apply (simp add: "2" A)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. nths a S' \<in> B
 2. length a = card S + card S'
[PROOF STEP]
apply (simp add: "3" y_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length a = card S + card S'
[PROOF STEP]
by (metis (no_types, lifting) a_def assms(5) assms(6) diff_zero length_map length_upt)
[PROOF STATE]
proof (state)
this:
a \<in> Prod\<^bsub>S, S'\<^esub> A B

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
thus "x \<in> \<pi>\<^bsub>S\<^esub> ` (Prod\<^bsub>S,S'\<^esub> A B)"
[PROOF STATE]
proof (prove)
using this:
a \<in> Prod\<^bsub>S, S'\<^esub> A B

goal (1 subgoal):
 1. x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
using "2"
[PROOF STATE]
proof (prove)
using this:
a \<in> Prod\<^bsub>S, S'\<^esub> A B
nths a S = x

goal (1 subgoal):
 1. x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
A \<subseteq> (\<lambda>as. nths as S) ` Prod\<^bsub>S, S'\<^esub> A B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mapping_of_pmf_pmf_of_list':
  assumes "pmf_of_list_wf xs"
  defines "xs' \<equiv> filter (\<lambda>z. snd z \<noteq> 0) xs"
  shows   "mapping_of_pmf (pmf_of_list xs) =
             Mapping.tabulate (remdups (map fst xs'))
               (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
have wf: "pmf_of_list_wf xs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_list_wf xs'
[PROOF STEP]
unfolding xs'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_list_wf (filter (\<lambda>z. snd z \<noteq> 0) xs)
[PROOF STEP]
by (rule pmf_of_list_remove_zeros) fact
[PROOF STATE]
proof (state)
this:
pmf_of_list_wf xs'

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
have pos: "\<forall>x\<in>snd`set xs'. x > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>snd ` set xs'. 0 < x
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
pmf_of_list_wf xs

goal (1 subgoal):
 1. \<forall>x\<in>snd ` set xs'. 0 < x
[PROOF STEP]
unfolding xs'_def
[PROOF STATE]
proof (prove)
using this:
pmf_of_list_wf xs

goal (1 subgoal):
 1. \<forall>x\<in>snd ` set (filter (\<lambda>z. snd z \<noteq> 0) xs). 0 < x
[PROOF STEP]
by (force simp: pmf_of_list_wf_def)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>snd ` set xs'. 0 < x

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
pmf_of_list_wf xs
xs' \<equiv> filter (\<lambda>z. snd z \<noteq> 0) xs
[PROOF STEP]
have "pmf_of_list xs = pmf_of_list xs'"
[PROOF STATE]
proof (prove)
using this:
pmf_of_list_wf xs
xs' \<equiv> filter (\<lambda>z. snd z \<noteq> 0) xs

goal (1 subgoal):
 1. pmf_of_list xs = pmf_of_list xs'
[PROOF STEP]
unfolding xs'_def
[PROOF STATE]
proof (prove)
using this:
pmf_of_list_wf xs
filter (\<lambda>z. snd z \<noteq> 0) xs \<equiv> filter (\<lambda>z. snd z \<noteq> 0) xs

goal (1 subgoal):
 1. pmf_of_list xs = pmf_of_list (filter (\<lambda>z. snd z \<noteq> 0) xs)
[PROOF STEP]
by (subst pmf_of_list_remove_zeros) simp_all
[PROOF STATE]
proof (state)
this:
pmf_of_list xs = pmf_of_list xs'

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_list xs = pmf_of_list xs'

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
from wf pos
[PROOF STATE]
proof (chain)
picking this:
pmf_of_list_wf xs'
\<forall>x\<in>snd ` set xs'. 0 < x
[PROOF STEP]
have "mapping_of_pmf \<dots> = ?rhs"
[PROOF STATE]
proof (prove)
using this:
pmf_of_list_wf xs'
\<forall>x\<in>snd ` set xs'. 0 < x

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs') = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
by (intro mapping_of_pmf_pmf_of_list) (auto simp: pmf_of_list_wf_def)
[PROOF STATE]
proof (state)
this:
mapping_of_pmf (pmf_of_list xs') = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))

goal (1 subgoal):
 1. mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mapping_of_pmf (pmf_of_list xs) = Mapping.tabulate (remdups (map fst xs')) (\<lambda>x. sum_list (map snd (filter (\<lambda>z. fst z = x) xs')))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sq_mtx_minus_eq: "A - B = to_mtx (\<chi> i j. A$$i$j - B$$i$j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A - B = to_mtx (\<chi>i j. A $$ i $ j - B $$ i $ j)
[PROOF STEP]
by transfer (simp add: vec_eq_iff)


[STATEMENT]
lemma fwi_invariant_aux_1:
  "j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
proof (induction j)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j'' \<le> 0 \<Longrightarrow> fwi m n k i 0 i' j' \<le> fwi m n k i j'' i' j'
 2. \<And>j. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
j'' \<le> 0

goal (2 subgoals):
 1. j'' \<le> 0 \<Longrightarrow> fwi m n k i 0 i' j' \<le> fwi m n k i j'' i' j'
 2. \<And>j. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
j'' \<le> 0

goal (1 subgoal):
 1. fwi m n k i 0 i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fwi m n k i 0 i' j' \<le> fwi m n k i j'' i' j'

goal (1 subgoal):
 1. \<And>j. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
case (Suc j)
[PROOF STATE]
proof (state)
this:
j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'
j'' \<le> Suc j

goal (1 subgoal):
 1. \<And>j. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'
j'' \<le> Suc j

goal (1 subgoal):
 1. fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
proof (cases "j'' = Suc j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' = Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
 2. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j'' = Suc j

goal (2 subgoals):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' = Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
 2. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
j'' = Suc j

goal (1 subgoal):
 1. fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'

goal (1 subgoal):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
j'' \<noteq> Suc j

goal (1 subgoal):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
have "fw_upd (fwi m n k i j) k i (Suc j) i' j' \<le> fwi m n k i j i' j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fw_upd (fwi m n k i j) k i (Suc j) i' j' \<le> fwi m n k i j i' j'
[PROOF STEP]
by (simp add: fw_upd_mono)
[PROOF STATE]
proof (state)
this:
fw_upd (fwi m n k i j) k i (Suc j) i' j' \<le> fwi m n k i j i' j'

goal (1 subgoal):
 1. \<lbrakk>j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'; j'' \<le> Suc j; j'' \<noteq> Suc j\<rbrakk> \<Longrightarrow> fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
fw_upd (fwi m n k i j) k i (Suc j) i' j' \<le> fwi m n k i j i' j'

goal (1 subgoal):
 1. fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
using Suc False
[PROOF STATE]
proof (prove)
using this:
fw_upd (fwi m n k i j) k i (Suc j) i' j' \<le> fwi m n k i j i' j'
j'' \<le> j \<Longrightarrow> fwi m n k i j i' j' \<le> fwi m n k i j'' i' j'
j'' \<le> Suc j
j'' \<noteq> Suc j

goal (1 subgoal):
 1. fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
fwi m n k i (Suc j) i' j' \<le> fwi m n k i j'' i' j'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hom_pivot_positions[simp]: "pivot_positions (mat\<^sub>h A) = pivot_positions A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pivot_positions (mat\<^sub>h A) = pivot_positions A
[PROOF STEP]
unfolding pivot_positions_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pivot_positions_main (mat\<^sub>h A) (dim_row (mat\<^sub>h A)) (dim_col (mat\<^sub>h A)) 0 0 = pivot_positions_main A (dim_row A) (dim_col A) 0 0
[PROOF STEP]
by (subst hom_pivot_positions_main_gen, auto)


[STATEMENT]
lemma snd_Gauss_Jordan_iarrays_PA_eq: "snd (Gauss_Jordan_iarrays_PA A) = Gauss_Jordan_iarrays A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (Gauss_Jordan_iarrays_PA A) = Gauss_Jordan_iarrays A
[PROOF STEP]
unfolding Gauss_Jordan_iarrays_def Gauss_Jordan_iarrays_PA_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (Gauss_Jordan_upt_k_iarrays_PA A (ncols_iarray A - 1)) = Gauss_Jordan_upt_k_iarrays A (ncols_iarray A - 1)
[PROOF STEP]
using snd_Gauss_Jordan_upt_k_iarrays_PA
[PROOF STATE]
proof (prove)
using this:
snd (Gauss_Jordan_upt_k_iarrays_PA ?A ?k) = Gauss_Jordan_upt_k_iarrays ?A ?k

goal (1 subgoal):
 1. snd (Gauss_Jordan_upt_k_iarrays_PA A (ncols_iarray A - 1)) = Gauss_Jordan_upt_k_iarrays A (ncols_iarray A - 1)
[PROOF STEP]
by auto


[STATEMENT]
lemma local_flow_ball: "local_flow (f g) UNIV UNIV (\<phi> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local_flow (f g) UNIV UNIV (\<lambda>t s. \<chi>i. if i = 1 then g \<cdot> t\<^sup>2 / 2 + s $ 2 \<cdot> t + s $ 1 else g \<cdot> t + s $ 2)
[PROOF STEP]
apply(unfold_locales, simp_all add: local_lipschitz_def lipschitz_on_def vec_eq_iff, clarsimp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x t. \<exists>u>0. (\<exists>ta. dist t ta \<le> u) \<longrightarrow> (\<exists>L\<ge>0. \<forall>xa\<in>cball x u. \<forall>y\<in>cball x u. dist (f g xa) (f g y) \<le> L \<cdot> dist xa y)
 2. \<And>t s. \<forall>i.  D (\<lambda>x. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) = (\<lambda>x. if i = 1 then (\<chi>i. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) $ 2 else g) on {0--t}
 3. \<And>s. \<forall>i. i \<noteq> 1 \<longrightarrow> s $ 2 = s $ i
[PROOF STEP]
apply(rule_tac x="1/2" in exI, clarsimp, rule_tac x=1 in exI)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x t ta. dist t ta \<cdot> 2 \<le> 1 \<Longrightarrow> 0 \<le> 1 \<and> (\<forall>xa\<in>cball x (1 / 2). \<forall>y\<in>cball x (1 / 2). dist (f g xa) (f g y) \<le> 1 \<cdot> dist xa y)
 2. \<And>t s. \<forall>i.  D (\<lambda>x. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) = (\<lambda>x. if i = 1 then (\<chi>i. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) $ 2 else g) on {0--t}
 3. \<And>s. \<forall>i. i \<noteq> 1 \<longrightarrow> s $ 2 = s $ i
[PROOF STEP]
apply(simp add: dist_norm norm_vec_def L2_set_def UNIV_2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>t s. \<forall>i.  D (\<lambda>x. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) = (\<lambda>x. if i = 1 then (\<chi>i. if i = 1 then g \<cdot> x\<^sup>2 / 2 + s $ 2 \<cdot> x + s $ 1 else g \<cdot> x + s $ 2) $ 2 else g) on {0--t}
 2. \<And>s. \<forall>i. i \<noteq> 1 \<longrightarrow> s $ 2 = s $ i
[PROOF STEP]
by (auto simp: forall_2 intro!: poly_derivatives)


[STATEMENT]
lemma minus_some:
  assumes "a \<succeq> b"
  shows "Some a = b \<oplus> (a \<ominus> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Some a = b \<oplus> (a \<ominus> b)
[PROOF STEP]
using assms commutative minus_equiv_def
[PROOF STATE]
proof (prove)
using this:
a \<succeq> b
?a \<oplus> ?b = ?b \<oplus> ?a
?b \<succeq> ?a \<Longrightarrow> Some ?b = ?a \<oplus> (?b \<ominus> ?a) \<and> ?b \<ominus> ?a \<succeq>  |?b|

goal (1 subgoal):
 1. Some a = b \<oplus> (a \<ominus> b)
[PROOF STEP]
by force


[STATEMENT]
lemma frac_neg: "frac (- x) = (if x \<in> \<int> then 0 else 1 - frac x)"
  for x :: "'a::floor_ceiling"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frac (- x) = (if x \<in> \<int> then 0::'a else (1::'a) - frac x)
[PROOF STEP]
apply (auto simp add: frac_unique_iff)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. x \<notin> \<int> \<Longrightarrow> - x - ((1::'a) - frac x) \<in> \<int>
 2. x \<notin> \<int> \<Longrightarrow> frac x \<le> (1::'a)
[PROOF STEP]
apply (simp add: frac_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> \<int> \<Longrightarrow> frac x \<le> (1::'a)
[PROOF STEP]
apply (meson frac_lt_1 less_iff_diff_less_0 not_le not_less_iff_gr_or_eq)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma phull_Macaulay_list: "phull (set (Macaulay_list ps)) = phull (set ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
have *: "Keys (set ps) \<subseteq> set (Keys_to_list ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Keys (set ps) \<subseteq> set (Keys_to_list ps)
[PROOF STEP]
by (simp add: set_Keys_to_list)
[PROOF STATE]
proof (state)
this:
Keys (set ps) \<subseteq> set (Keys_to_list ps)

goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
have "phull (set (Macaulay_list ps)) =
          phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps))))
[PROOF STEP]
by (simp only: set_Macaulay_list phull.span_Diff_zero)
[PROOF STATE]
proof (state)
this:
phull (set (Macaulay_list ps)) = phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps))))

goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
phull (set (Macaulay_list ps)) = phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps))))

goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
have "... = phull (set ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps)))) = phull (set ps)
[PROOF STEP]
by (simp only: Macaulay_mat_def phull_row_echelon[OF * distinct_Keys_to_list])
[PROOF STATE]
proof (state)
this:
phull (set (mat_to_polys (Keys_to_list ps) (row_echelon (Macaulay_mat ps)))) = phull (set ps)

goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
phull (set (Macaulay_list ps)) = phull (set ps)

goal (1 subgoal):
 1. phull (set (Macaulay_list ps)) = phull (set ps)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
phull (set (Macaulay_list ps)) = phull (set ps)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linorder_min_same1 [simp]:
  "(min y x = y) = (y \<le> (x::'a::linorder))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (min y x = y) = (y \<le> x)
[PROOF STEP]
by (auto simp: min_def linorder_not_less)


[STATEMENT]
lemma rel_fun_eq_conversep: includes lifting_syntax shows "(A\<inverse>\<inverse> ===> (=)) = (A ===> (=))\<inverse>\<inverse>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A\<inverse>\<inverse> ===> (=) = (A ===> (=))\<inverse>\<inverse>
[PROOF STEP]
by(auto simp add: fun_eq_iff rel_fun_def)


[STATEMENT]
lemma finite_nonzero_count: "finite {t. count M t > 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {t. 0 < count M t}
[PROOF STEP]
using count
[PROOF STATE]
proof (prove)
using this:
count ?x \<in> {f. finite {x. 0 < f x}}

goal (1 subgoal):
 1. finite {t. 0 < count M t}
[PROOF STEP]
by auto


[STATEMENT]
lemma mset_sublist_eq:
  assumes \<open>mset xs' = mset xs\<close>
    and \<open>\<And> i. i<lo \<Longrightarrow> xs'!i = xs!i\<close>
    and \<open>\<And> j. \<lbrakk>hi<j; j<length xs\<rbrakk> \<Longrightarrow> xs'!j = xs!j\<close>
    and bounds: \<open>lo \<le> hi\<close> \<open>hi < length xs\<close>
  shows \<open>set (sublist xs' lo hi) = set (sublist xs lo hi)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (WB_Sort.sublist xs' lo hi) = set (WB_Sort.sublist xs lo hi)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set (WB_Sort.sublist xs' lo hi) \<subseteq> set (WB_Sort.sublist xs lo hi)
 2. set (WB_Sort.sublist xs lo hi) \<subseteq> set (WB_Sort.sublist xs' lo hi)
[PROOF STEP]
show \<open>set (sublist xs' lo hi) \<subseteq> set (sublist xs lo hi)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (WB_Sort.sublist xs' lo hi) \<subseteq> set (WB_Sort.sublist xs lo hi)
[PROOF STEP]
apply (rule mset_sublist_incl)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. mset xs' = mset xs
 2. \<And>i. i < lo \<Longrightarrow> xs' ! i = xs ! i
 3. \<And>j. \<lbrakk>hi < j; j < length xs\<rbrakk> \<Longrightarrow> xs' ! j = xs ! j
 4. lo \<le> hi
 5. hi < length xs
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
mset xs' = mset xs
?i < lo \<Longrightarrow> xs' ! ?i = xs ! ?i
\<lbrakk>hi < ?j; ?j < length xs\<rbrakk> \<Longrightarrow> xs' ! ?j = xs ! ?j
lo \<le> hi
hi < length xs

goal (5 subgoals):
 1. mset xs' = mset xs
 2. \<And>i. i < lo \<Longrightarrow> xs' ! i = xs ! i
 3. \<And>j. \<lbrakk>hi < j; j < length xs\<rbrakk> \<Longrightarrow> xs' ! j = xs ! j
 4. lo \<le> hi
 5. hi < length xs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (WB_Sort.sublist xs' lo hi) \<subseteq> set (WB_Sort.sublist xs lo hi)

goal (1 subgoal):
 1. set (WB_Sort.sublist xs lo hi) \<subseteq> set (WB_Sort.sublist xs' lo hi)
[PROOF STEP]
show \<open>set (sublist xs lo hi) \<subseteq> set (sublist xs' lo hi)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (WB_Sort.sublist xs lo hi) \<subseteq> set (WB_Sort.sublist xs' lo hi)
[PROOF STEP]
by (rule mset_sublist_incl) (metis assms size_mset)+
[PROOF STATE]
proof (state)
this:
set (WB_Sort.sublist xs lo hi) \<subseteq> set (WB_Sort.sublist xs' lo hi)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma word_count_from_top:
  "n \<noteq> 0 \<Longrightarrow> {0 ..< n :: 'a :: len word} = {0 ..< n - 1} \<union> {n - 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> {0..<n} = {0..<n - 1} \<union> {n - 1}
[PROOF STEP]
apply (rule set_eqI, rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n}\<rbrakk> \<Longrightarrow> x \<in> {0..<n - 1} \<union> {n - 1}
 2. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n - 1} \<union> {n - 1}\<rbrakk> \<Longrightarrow> x \<in> {0..<n}
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x < n\<rbrakk> \<Longrightarrow> x = n - 1 \<or> x < n - 1
 2. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n - 1} \<union> {n - 1}\<rbrakk> \<Longrightarrow> x \<in> {0..<n}
[PROOF STEP]
apply (drule word_le_minus_one_leq)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x \<le> n - 1\<rbrakk> \<Longrightarrow> x = n - 1 \<or> x < n - 1
 2. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n - 1} \<union> {n - 1}\<rbrakk> \<Longrightarrow> x \<in> {0..<n}
[PROOF STEP]
apply (rule disjCI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x \<le> n - 1; \<not> x < n - 1\<rbrakk> \<Longrightarrow> x = n - 1
 2. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n - 1} \<union> {n - 1}\<rbrakk> \<Longrightarrow> x \<in> {0..<n}
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x \<in> {0..<n - 1} \<union> {n - 1}\<rbrakk> \<Longrightarrow> x \<in> {0..<n}
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>n \<noteq> 0; x = n - 1 \<or> x < n - 1\<rbrakk> \<Longrightarrow> x < n
[PROOF STEP]
apply (erule word_leq_minus_one_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x = n - 1 \<or> x < n - 1 \<Longrightarrow> x \<le> n - 1
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma rGamma_series_complex_converges:
        "convergent (rGamma_series (z :: complex))" (is "?thesis1")
  and rGamma_complex_altdef:
        "rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (-ln_Gamma z))" (is "?thesis2")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent (rGamma_series z) &&& rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. convergent (rGamma_series z)
 2. rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
have "?thesis1 \<and> ?thesis2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
proof (cases "z \<in> \<int>\<^sub>\<le>\<^sub>0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
 2. z \<notin> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (2 subgoals):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
 2. z \<notin> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
have "rGamma_series z \<longlonglongrightarrow> exp (- ln_Gamma z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rGamma_series z \<longlonglongrightarrow> exp (- ln_Gamma z)
[PROOF STEP]
proof (rule Lim_transform_eventually)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> exp (- ln_Gamma z)
 2. \<forall>\<^sub>F x in sequentially. ?f x = rGamma_series z x
[PROOF STEP]
from ln_Gamma_series_complex_converges'[OF False]
[PROOF STATE]
proof (chain)
picking this:
\<exists>d>0. uniformly_convergent_on (ball z d) (\<lambda>n z. ln_Gamma_series z n)
[PROOF STEP]
obtain d where "0 < d" "uniformly_convergent_on (ball z d) (\<lambda>n z. ln_Gamma_series z n)"
[PROOF STATE]
proof (prove)
using this:
\<exists>d>0. uniformly_convergent_on (ball z d) (\<lambda>n z. ln_Gamma_series z n)

goal (1 subgoal):
 1. (\<And>d. \<lbrakk>0 < d; uniformly_convergent_on (ball z d) (\<lambda>n z. ln_Gamma_series z n)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < d
uniformly_convergent_on (ball z d) (\<lambda>n z. ln_Gamma_series z n)

goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> exp (- ln_Gamma z)
 2. \<forall>\<^sub>F x in sequentially. ?f x = rGamma_series z x
[PROOF STEP]
from this(1) uniformly_convergent_imp_convergent[OF this(2), of z]
[PROOF STATE]
proof (chain)
picking this:
0 < d
z \<in> ball z d \<Longrightarrow> convergent (ln_Gamma_series z)
[PROOF STEP]
have "ln_Gamma_series z \<longlonglongrightarrow> lim (ln_Gamma_series z)"
[PROOF STATE]
proof (prove)
using this:
0 < d
z \<in> ball z d \<Longrightarrow> convergent (ln_Gamma_series z)

goal (1 subgoal):
 1. ln_Gamma_series z \<longlonglongrightarrow> lim (ln_Gamma_series z)
[PROOF STEP]
by (simp add: convergent_LIMSEQ_iff)
[PROOF STATE]
proof (state)
this:
ln_Gamma_series z \<longlonglongrightarrow> lim (ln_Gamma_series z)

goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> exp (- ln_Gamma z)
 2. \<forall>\<^sub>F x in sequentially. ?f x = rGamma_series z x
[PROOF STEP]
thus "(\<lambda>n. exp (-ln_Gamma_series z n)) \<longlonglongrightarrow> exp (- ln_Gamma z)"
[PROOF STATE]
proof (prove)
using this:
ln_Gamma_series z \<longlonglongrightarrow> lim (ln_Gamma_series z)

goal (1 subgoal):
 1. (\<lambda>n. exp (- ln_Gamma_series z n)) \<longlonglongrightarrow> exp (- ln_Gamma z)
[PROOF STEP]
unfolding convergent_def ln_Gamma_def
[PROOF STATE]
proof (prove)
using this:
ln_Gamma_series z \<longlonglongrightarrow> lim (ln_Gamma_series z)

goal (1 subgoal):
 1. (\<lambda>n. exp (- ln_Gamma_series z n)) \<longlonglongrightarrow> exp (- lim (ln_Gamma_series z))
[PROOF STEP]
by (intro tendsto_exp tendsto_minus)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. exp (- ln_Gamma_series z n)) \<longlonglongrightarrow> exp (- ln_Gamma z)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. exp (- ln_Gamma_series z x) = rGamma_series z x
[PROOF STEP]
from eventually_gt_at_top[of "0::nat"] exp_ln_Gamma_series_complex False
[PROOF STATE]
proof (chain)
picking this:
eventually ((<) 0) sequentially
\<lbrakk>0 < ?n; ?z \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> exp (ln_Gamma_series ?z ?n) = Gamma_series ?z ?n
z \<notin> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
show "eventually (\<lambda>n. exp (-ln_Gamma_series z n) = rGamma_series z n) sequentially"
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially
\<lbrakk>0 < ?n; ?z \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> exp (ln_Gamma_series ?z ?n) = Gamma_series ?z ?n
z \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. exp (- ln_Gamma_series z n) = rGamma_series z n
[PROOF STEP]
by (force elim!: eventually_mono simp: exp_minus Gamma_series_def rGamma_series_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. exp (- ln_Gamma_series z n) = rGamma_series z n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rGamma_series z \<longlonglongrightarrow> exp (- ln_Gamma z)

goal (2 subgoals):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
 2. z \<notin> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
rGamma_series z \<longlonglongrightarrow> exp (- ln_Gamma z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
rGamma_series z \<longlonglongrightarrow> exp (- ln_Gamma z)

goal (1 subgoal):
 1. convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
by (auto simp: convergent_def rGamma_complex_def intro!: limI)
[PROOF STATE]
proof (state)
this:
convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))

goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
z \<in> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<in> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
obtain k where "z = - of_nat k"
[PROOF STATE]
proof (prove)
using this:
z \<in> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. (\<And>k. z = - of_nat k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (erule nonpos_Ints_cases')
[PROOF STATE]
proof (state)
this:
z = - of_nat k

goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
z = - of_nat k

goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
have "rGamma_series \<dots> \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rGamma_series (- of_nat k) \<longlonglongrightarrow> 0
[PROOF STEP]
by (subst tendsto_cong[OF rGamma_series_minus_of_nat]) (simp_all add: convergent_const)
[PROOF STATE]
proof (state)
this:
rGamma_series (- of_nat k) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. z \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rGamma_series z \<longlonglongrightarrow> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rGamma_series z \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
rGamma_series z \<longlonglongrightarrow> 0
z \<in> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
by (auto simp: rGamma_complex_def convergent_def intro!: limI)
[PROOF STATE]
proof (state)
this:
convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))

goal (2 subgoals):
 1. convergent (rGamma_series z)
 2. rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
thus "?thesis1" "?thesis2"
[PROOF STATE]
proof (prove)
using this:
convergent (rGamma_series z) \<and> rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))

goal (1 subgoal):
 1. convergent (rGamma_series z) &&& rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
convergent (rGamma_series z)
rGamma z = (if z \<in> \<int>\<^sub>\<le>\<^sub>0 then 0 else exp (- ln_Gamma z))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma count_image_mset_le_imp_lt_raw:
  assumes
    "finite A" and
    "A = set_mset M \<union> set_mset N" and
    "count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a"
  shows "\<exists>b. f b = f a \<and> count M b < count N b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
A = set_mset M \<union> set_mset N
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
proof (induct A arbitrary: M N rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case (insert x F)
[PROOF STATE]
proof (state)
this:
finite F
x \<notin> F
\<lbrakk>F = set_mset ?M \<union> set_mset ?N; count (image_mset f ?M) (f a) + count ?N a < count (image_mset f ?N) (f a) + count ?M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count ?M b < count ?N b
insert x F = set_mset M \<union> set_mset N
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a

goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
note fin = this(1) and x_ni_f = this(2) and ih = this(3) and x_f_eq_m_n = this(4) and
    cnt_lt = this(5)
[PROOF STATE]
proof (state)
this:
finite F
x \<notin> F
\<lbrakk>F = set_mset ?M \<union> set_mset ?N; count (image_mset f ?M) (f a) + count ?N a < count (image_mset f ?N) (f a) + count ?M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count ?M b < count ?N b
insert x F = set_mset M \<union> set_mset N
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a

goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
let ?Ma = "{#y \<in># M. y \<noteq> x#}"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
let ?Mb = "{#y \<in># M. y = x#}"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
let ?Na = "{#y \<in># N. y \<noteq> x#}"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
let ?Nb = "{#y \<in># N. y = x#}"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have m_part: "M = ?Mb + ?Ma" and n_part: "N = ?Nb + ?Na"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M = {#y \<in># M. y = x#} + {#y \<in># M. y \<noteq> x#} &&& N = {#y \<in># N. y = x#} + {#y \<in># N. y \<noteq> x#}
[PROOF STEP]
using multiset_partition
[PROOF STATE]
proof (prove)
using this:
?M = filter_mset ?P ?M + {#x \<in># ?M. \<not> ?P x#}

goal (1 subgoal):
 1. M = {#y \<in># M. y = x#} + {#y \<in># M. y \<noteq> x#} &&& N = {#y \<in># N. y = x#} + {#y \<in># N. y \<noteq> x#}
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
M = {#y \<in># M. y = x#} + {#y \<in># M. y \<noteq> x#}
N = {#y \<in># N. y = x#} + {#y \<in># N. y \<noteq> x#}

goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have f_eq_ma_na: "F = set_mset ?Ma \<union> set_mset ?Na"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F = set_mset {#y \<in># M. y \<noteq> x#} \<union> set_mset {#y \<in># N. y \<noteq> x#}
[PROOF STEP]
using x_f_eq_m_n x_ni_f
[PROOF STATE]
proof (prove)
using this:
insert x F = set_mset M \<union> set_mset N
x \<notin> F

goal (1 subgoal):
 1. F = set_mset {#y \<in># M. y \<noteq> x#} \<union> set_mset {#y \<in># N. y \<noteq> x#}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
F = set_mset {#y \<in># M. y \<noteq> x#} \<union> set_mset {#y \<in># N. y \<noteq> x#}

goal (2 subgoals):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<And>x F M N. \<lbrakk>finite F; x \<notin> F; \<And>M N. \<lbrakk>F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b; insert x F = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
proof (cases "f x = f a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case fx_ne_fa: False
[PROOF STATE]
proof (state)
this:
f x \<noteq> f a

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_fma_fa: "count (image_mset f ?Ma) (f a) = count (image_mset f M) (f a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) = count (image_mset f M) (f a)
[PROOF STEP]
using fx_ne_fa
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f a

goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) = count (image_mset f M) (f a)
[PROOF STEP]
by (subst (2) m_part) auto
[PROOF STATE]
proof (state)
this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) = count (image_mset f M) (f a)

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_fna_fa: "count (image_mset f ?Na) (f a) = count (image_mset f N) (f a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) = count (image_mset f N) (f a)
[PROOF STEP]
using fx_ne_fa
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f a

goal (1 subgoal):
 1. count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) = count (image_mset f N) (f a)
[PROOF STEP]
by (subst (2) n_part) auto
[PROOF STATE]
proof (state)
this:
count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) = count (image_mset f N) (f a)

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_ma_a: "count ?Ma a = count M a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count {#y \<in># M. y \<noteq> x#} a = count M a
[PROOF STEP]
using fx_ne_fa
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f a

goal (1 subgoal):
 1. count {#y \<in># M. y \<noteq> x#} a = count M a
[PROOF STEP]
by (subst (2) m_part) auto
[PROOF STATE]
proof (state)
this:
count {#y \<in># M. y \<noteq> x#} a = count M a

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_na_a: "count ?Na a = count N a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count {#y \<in># N. y \<noteq> x#} a = count N a
[PROOF STEP]
using fx_ne_fa
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f a

goal (1 subgoal):
 1. count {#y \<in># N. y \<noteq> x#} a = count N a
[PROOF STEP]
by (subst (2) n_part) auto
[PROOF STATE]
proof (state)
this:
count {#y \<in># N. y \<noteq> x#} a = count N a

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
obtain b where fb_eq_fa: "f b = f a" and cnt_b: "count ?Ma b < count ?Na b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. \<lbrakk>f b = f a; count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ih[OF f_eq_ma_na] cnt_lt
[PROOF STATE]
proof (prove)
using this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a \<Longrightarrow> \<exists>b. f b = f a \<and> count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a

goal (1 subgoal):
 1. (\<And>b. \<lbrakk>f b = f a; count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding cnt_fma_fa cnt_fna_fa cnt_ma_a cnt_na_a
[PROOF STATE]
proof (prove)
using this:
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a \<Longrightarrow> \<exists>b. f b = f a \<and> count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a

goal (1 subgoal):
 1. (\<And>b. \<lbrakk>f b = f a; count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f b = f a
count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have fx_ne_fb: "f x \<noteq> f b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<noteq> f b
[PROOF STEP]
using fb_eq_fa fx_ne_fa
[PROOF STATE]
proof (prove)
using this:
f b = f a
f x \<noteq> f a

goal (1 subgoal):
 1. f x \<noteq> f b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f x \<noteq> f b

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_ma_b: "count ?Ma b = count M b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count {#y \<in># M. y \<noteq> x#} b = count M b
[PROOF STEP]
using fx_ne_fb
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f b

goal (1 subgoal):
 1. count {#y \<in># M. y \<noteq> x#} b = count M b
[PROOF STEP]
by (subst (2) m_part) auto
[PROOF STATE]
proof (state)
this:
count {#y \<in># M. y \<noteq> x#} b = count M b

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have cnt_na_b: "count ?Na b = count N b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count {#y \<in># N. y \<noteq> x#} b = count N b
[PROOF STEP]
using fx_ne_fb
[PROOF STATE]
proof (prove)
using this:
f x \<noteq> f b

goal (1 subgoal):
 1. count {#y \<in># N. y \<noteq> x#} b = count N b
[PROOF STEP]
by (subst (2) n_part) auto
[PROOF STATE]
proof (state)
this:
count {#y \<in># N. y \<noteq> x#} b = count N b

goal (2 subgoals):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. f x \<noteq> f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
using fb_eq_fa cnt_b
[PROOF STATE]
proof (prove)
using this:
f b = f a
count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
unfolding cnt_ma_b cnt_na_b
[PROOF STATE]
proof (prove)
using this:
f b = f a
count M b < count N b

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal (1 subgoal):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case fx_eq_fa: True
[PROOF STATE]
proof (state)
this:
f x = f a

goal (1 subgoal):
 1. f x = f a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
proof (cases "x = a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case x_eq_a: True
[PROOF STATE]
proof (state)
this:
x = a

goal (2 subgoals):
 1. x = a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have "count (image_mset f ?Ma) (f a) + count ?Na a
        < count (image_mset f ?Na) (f a) + count ?Ma a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
using cnt_lt x_eq_a
[PROOF STATE]
proof (prove)
using this:
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a
x = a

goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
by (subst (asm) (1 2) m_part, subst (asm) (1 2) n_part, auto)
[PROOF STATE]
proof (state)
this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (2 subgoals):
 1. x = a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
using ih[OF f_eq_ma_na]
[PROOF STATE]
proof (prove)
using this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a \<Longrightarrow> \<exists>b. f b = f a \<and> count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
by (metis count_filter_mset nat_neq_iff)
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal (1 subgoal):
 1. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case x_ne_a: False
[PROOF STATE]
proof (state)
this:
x \<noteq> a

goal (1 subgoal):
 1. x \<noteq> a \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
proof (cases "count M x < count N x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
count M x < count N x

goal (2 subgoals):
 1. count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
 2. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
count M x < count N x

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
using fx_eq_fa
[PROOF STATE]
proof (prove)
using this:
count M x < count N x
f x = f a

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> count M x < count N x

goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
hence cnt_x: "count M x \<ge> count N x"
[PROOF STATE]
proof (prove)
using this:
\<not> count M x < count N x

goal (1 subgoal):
 1. count N x \<le> count M x
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
count N x \<le> count M x

goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
have "count M x + count (image_mset f ?Ma) (f a) + count ?Na a
          < count N x + count (image_mset f ?Na) (f a) + count ?Ma a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count M x + count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count N x + count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
using cnt_lt x_ne_a fx_eq_fa
[PROOF STATE]
proof (prove)
using this:
count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a
x \<noteq> a
f x = f a

goal (1 subgoal):
 1. count M x + count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count N x + count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
by (subst (asm) (1 2) m_part, subst (asm) (1 2) n_part, auto)
[PROOF STATE]
proof (state)
this:
count M x + count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count N x + count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
hence "count (image_mset f ?Ma) (f a) + count ?Na a
          < count (image_mset f ?Na) (f a) + count ?Ma a"
[PROOF STATE]
proof (prove)
using this:
count M x + count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count N x + count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
using cnt_x
[PROOF STATE]
proof (prove)
using this:
count M x + count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count N x + count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
count N x \<le> count M x

goal (1 subgoal):
 1. count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (1 subgoal):
 1. \<not> count M x < count N x \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
using ih[OF f_eq_ma_na]
[PROOF STATE]
proof (prove)
using this:
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a
count (image_mset f {#y \<in># M. y \<noteq> x#}) (f a) + count {#y \<in># N. y \<noteq> x#} a < count (image_mset f {#y \<in># N. y \<noteq> x#}) (f a) + count {#y \<in># M. y \<noteq> x#} a \<Longrightarrow> \<exists>b. f b = f a \<and> count {#y \<in># M. y \<noteq> x#} b < count {#y \<in># N. y \<noteq> x#} b

goal (1 subgoal):
 1. \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
by (metis count_filter_mset nat_neq_iff)
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b. f b = f a \<and> count M b < count N b

goal (1 subgoal):
 1. \<And>M N. \<lbrakk>{} = set_mset M \<union> set_mset N; count (image_mset f M) (f a) + count N a < count (image_mset f N) (f a) + count M a\<rbrakk> \<Longrightarrow> \<exists>b. f b = f a \<and> count M b < count N b
[PROOF STEP]
qed auto


[STATEMENT]
lemma inv_embed[simp]: "inv_embed (to_fract x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_embed (to_fract x) = x
[PROOF STEP]
unfolding inv_embed_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. the_inv to_fract (to_fract x) = x
[PROOF STEP]
by (rule the_inv_f_f, auto simp: inj_on_def)


[STATEMENT]
lemma hrabs_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> < e \<Longrightarrow> x \<in> Infinitesimal"
  for x :: hypreal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>e \<in> Infinitesimal; \<bar>x\<bar> < e\<rbrakk> \<Longrightarrow> x \<in> Infinitesimal
[PROOF STEP]
by (erule hnorm_less_Infinitesimal) simp


[STATEMENT]
lemma par_strict_not_col_1:
  assumes "A B ParStrict C D"
  shows "\<not> Col A B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> Col A B C
[PROOF STEP]
using Col_perm ParStrict_def assms col_trivial_1
[PROOF STATE]
proof (prove)
using this:
Col ?A ?B ?C \<Longrightarrow> Col ?A ?B ?C \<and> Col ?A ?C ?B \<and> Col ?B ?A ?C \<and> Col ?B ?C ?A \<and> Col ?C ?A ?B \<and> Col ?C ?B ?A
?A ?B ParStrict ?C ?D \<equiv> Coplanar ?A ?B ?C ?D \<and> (\<nexists>X. Col X ?A ?B \<and> Col X ?C ?D)
A B ParStrict C D
Col ?A ?A ?B

goal (1 subgoal):
 1. \<not> Col A B C
[PROOF STEP]
by blast


[STATEMENT]
lemma (in gcd_condition_monoid) gcd_divides_r:
  assumes "a \<in> carrier G"  "b \<in> carrier G"
  shows "(somegcd G a b) divides b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. somegcd G a b divides b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. somegcd G a b divides b
[PROOF STEP]
interpret weak_lower_semilattice "division_rel G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weak_lower_semilattice (division_rel G)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. somegcd G a b divides b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. somegcd G a b divides b
[PROOF STEP]
by (metis assms gcd_isgcd isgcd_def)
[PROOF STATE]
proof (state)
this:
somegcd G a b divides b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in normal) oVeblen_oLimit_0:
"oVeblen F (oLimit f) 0 = oLimit (\<lambda>n. oVeblen F (f n) 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. oVeblen F (oLimit f) 0 = oLimit (\<lambda>n. oVeblen F (f n) 0)
[PROOF STEP]
by (rule continuousD[OF continuous_oVeblen_0])


[STATEMENT]
lemma of_bl_True [simp]: "(of_bl (True # xs) :: 'a::len word) = 2^length xs + of_bl xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_bl (True # xs) = 2 ^ length xs + of_bl xs
[PROOF STEP]
by (subst of_bl_append [where xs="[True]", simplified]) (simp add: word_1_bl)


[STATEMENT]
lemma affine_binop:
  assumes "degree_aforms [X, Y] \<le> k"
  shows "aform_val e (affine_binop X Y a b c d k) =
    a * aform_val e X + b * aform_val e Y + c + e k * d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aform_val e (affine_binop X Y a b c d k) = a * aform_val e X + b * aform_val e Y + c + e k * d
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
degree_aforms [X, Y] \<le> k

goal (1 subgoal):
 1. aform_val e (affine_binop X Y a b c d k) = a * aform_val e X + b * aform_val e Y + c + e k * d
[PROOF STEP]
by (auto simp: aform_val_def affine_binop_def degrees_def
      pdevs_val_msum_pdevs degree_add_pdevs_le pdevs_val_One_pdevs Basis_list_real_def
      algebra_simps)


[STATEMENT]
lemma L1_I:
  assumes "integrable M f"
  shows "f \<in> space\<^sub>N (\<LL> 1 M)"
        "Norm (\<LL> 1 M) f = (\<integral>x. \<bar>f x\<bar> \<partial>M)"
        "eNorm (\<LL> 1 M) f = (\<integral>x. \<bar>f x\<bar> \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> space\<^sub>N (\<LL> 1 M) &&& Norm (\<LL> 1 M) f = LINT x|M. \<bar>f x\<bar> &&& eNorm (\<LL> 1 M) f = ennreal (LINT x|M. \<bar>f x\<bar>)
[PROOF STEP]
unfolding one_ereal_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> space\<^sub>N (\<LL> 1 M) &&& Norm (\<LL> 1 M) f = LINT x|M. \<bar>f x\<bar> &&& eNorm (\<LL> 1 M) f = ennreal (LINT x|M. \<bar>f x\<bar>)
[PROOF STEP]
using Lp_I[of 1, OF _ borel_measurable_integrable[OF assms]] assms powr_to_1
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 1; integrable M (\<lambda>x. \<bar>f x\<bar> powr 1)\<rbrakk> \<Longrightarrow> f \<in> space\<^sub>N (\<LL> (ennreal 1) M)
\<lbrakk>0 < 1; integrable M (\<lambda>x. \<bar>f x\<bar> powr 1)\<rbrakk> \<Longrightarrow> Norm (\<LL> (ennreal 1) M) f = (LINT x|M. \<bar>f x\<bar> powr 1) powr (1 / 1)
\<lbrakk>0 < 1; integrable M (\<lambda>x. \<bar>f x\<bar> powr 1)\<rbrakk> \<Longrightarrow> eNorm (\<LL> (ennreal 1) M) f = ennreal ((LINT x|M. \<bar>f x\<bar> powr 1) powr (1 / 1))
integrable M f
?z powr 1 = ?z

goal (1 subgoal):
 1. f \<in> space\<^sub>N (\<LL> 1 M) &&& Norm (\<LL> 1 M) f = LINT x|M. \<bar>f x\<bar> &&& eNorm (\<LL> 1 M) f = ennreal (LINT x|M. \<bar>f x\<bar>)
[PROOF STEP]
by auto


[STATEMENT]
lemma left_in_interval: "\<lbrakk>a \<in> A; b \<in> A; interval r a b \<noteq> {}\<rbrakk> \<Longrightarrow> a \<in> interval r a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> A; b \<in> A; interval r a b \<noteq> {}\<rbrakk> \<Longrightarrow> a \<in> interval r a b
[PROOF STEP]
using interval_def interval_not_empty reflE
[PROOF STATE]
proof (prove)
using this:
interval ?r ?a ?b = {x. (?a, x) \<in> ?r \<and> (x, ?b) \<in> ?r}
interval r ?a ?b \<noteq> {} \<Longrightarrow> (?a, ?b) \<in> r
?x \<in> A \<Longrightarrow> (?x, ?x) \<in> r

goal (1 subgoal):
 1. \<lbrakk>a \<in> A; b \<in> A; interval r a b \<noteq> {}\<rbrakk> \<Longrightarrow> a \<in> interval r a b
[PROOF STEP]
by fastforce


[STATEMENT]
lemma lt_word_bits_lt_pow:
  "sz < word_bits \<Longrightarrow> sz < 2 ^ word_bits"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sz < word_bits \<Longrightarrow> sz < 2 ^ word_bits
[PROOF STEP]
by (simp add: word_bits_conv)