[STATEMENT]
lemma r01_binary_expression'_sum_range:
 "\<exists>k::nat.  (snd (snd (r01_binary_expansion'' r n))) = real k/2^(Suc n) \<and>
             k < 2^(Suc n) \<and>
            ((r01_binary_expansion' r n) = 0 \<longrightarrow> even k) \<and>
            ((r01_binary_expansion' r n) = 1 \<longrightarrow> odd k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
have [simp]:"(snd (snd (r01_binary_expansion'' r n))) = (\<Sum>i=0..n. real (r01_binary_expansion' r i) * ((1/2)^(Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (snd (r01_binary_expansion'' r n)) = (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i)
[PROOF STEP]
using r01_binary_expression_eq_lr[of r n]
[PROOF STATE]
proof (prove)
using this:
snd (snd (r01_binary_expansion'' r n)) = r01_binary_expression r n

goal (1 subgoal):
 1. snd (snd (r01_binary_expansion'' r n)) = (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i)
[PROOF STEP]
by(simp add: r01_binary_expression_def r01_binary_sum_def)
[PROOF STATE]
proof (state)
this:
snd (snd (r01_binary_expansion'' r n)) = (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i)

goal (1 subgoal):
 1. \<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "\<exists>k::nat. (\<Sum>i=0..n. real (r01_binary_expansion' r i) * ((1/2)^(Suc i))) = real k/2^(Suc n) \<and>
             k < 2^(Suc n) \<and>
            ((r01_binary_expansion' r n) = 0 \<longrightarrow> even k) \<and>
            ((r01_binary_expansion' r n) = 1 \<longrightarrow> odd k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
proof(induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>k. (\<Sum>i = 0..0. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc 0 \<and> k < 2 ^ Suc 0 \<and> (r01_binary_expansion' r 0 = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r 0 = 1 \<longrightarrow> odd k)
 2. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<exists>k. (\<Sum>i = 0..0. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc 0 \<and> k < 2 ^ Suc 0 \<and> (r01_binary_expansion' r 0 = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r 0 = 1 \<longrightarrow> odd k)
 2. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
consider "r01_binary_expansion' r 0 = 0" | "r01_binary_expansion' r 0 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>r01_binary_expansion' r 0 = 0 \<Longrightarrow> thesis; r01_binary_expansion' r 0 = 1 \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
using real01_binary_expansion'_0or1[of r 0]
[PROOF STATE]
proof (prove)
using this:
r01_binary_expansion' r 0 \<in> {0, 1}

goal (1 subgoal):
 1. \<lbrakk>r01_binary_expansion' r 0 = 0 \<Longrightarrow> thesis; r01_binary_expansion' r 0 = 1 \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>r01_binary_expansion' r 0 = 0 \<Longrightarrow> ?thesis; r01_binary_expansion' r 0 = 1 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (2 subgoals):
 1. \<exists>k. (\<Sum>i = 0..0. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc 0 \<and> k < 2 ^ Suc 0 \<and> (r01_binary_expansion' r 0 = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r 0 = 1 \<longrightarrow> odd k)
 2. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>r01_binary_expansion' r 0 = 0 \<Longrightarrow> ?thesis; r01_binary_expansion' r 0 = 1 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>r01_binary_expansion' r 0 = 0 \<Longrightarrow> ?thesis; r01_binary_expansion' r 0 = 1 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<exists>k. (\<Sum>i = 0..0. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc 0 \<and> k < 2 ^ Suc 0 \<and> (r01_binary_expansion' r 0 = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r 0 = 1 \<longrightarrow> odd k)
[PROOF STEP]
by cases auto
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i = 0..0. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc 0 \<and> k < 2 ^ Suc 0 \<and> (r01_binary_expansion' r 0 = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r 0 = 1 \<longrightarrow> odd k)

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
case (Suc n')
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n' \<and> (r01_binary_expansion' r n' = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n' = 1 \<longrightarrow> odd k)

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n' \<and> (r01_binary_expansion' r n' = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n' = 1 \<longrightarrow> odd k)
[PROOF STEP]
obtain k :: nat where ih:
     "(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2^(Suc n') \<and> k < 2^(Suc n')"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n' \<and> (r01_binary_expansion' r n' = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n' = 1 \<longrightarrow> odd k)

goal (1 subgoal):
 1. (\<And>k. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n'

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "... = real k / 2^(Suc n') + (real (r01_binary_expansion' r (Suc n')))/ 2^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
have "\<And>r ra n. (r::real) * (1 / ra) ^ n = r / ra ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>r ra n. r * (1 / ra) ^ n = r / ra ^ n
[PROOF STEP]
by (simp add: power_one_over)
[PROOF STATE]
proof (state)
this:
?r * (1 / ?ra) ^ ?n = ?r / ?ra ^ ?n

goal (1 subgoal):
 1. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?r * (1 / ?ra) ^ ?n = ?r / ?ra ^ ?n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?r * (1 / ?ra) ^ ?n = ?r / ?ra ^ ?n

goal (1 subgoal):
 1. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
using ih
[PROOF STATE]
proof (prove)
using this:
?r * (1 / ?ra) ^ ?n = ?r / ?ra ^ ?n
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n'

goal (1 subgoal):
 1. (\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) + real (r01_binary_expansion' r (Suc n')) * (1 / 2) ^ Suc (Suc n') = real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "... = (2*real k) / 2^(Suc (Suc n')) + (real (r01_binary_expansion' r (Suc n')))/ 2^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = 2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = 2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real k / 2 ^ Suc n' + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = 2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "... = (2*(real k) + real (r01_binary_expansion' r (Suc n')))/2 ^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = (2 * real k + real (r01_binary_expansion' r (Suc n'))) / 2 ^ Suc (Suc n')
[PROOF STEP]
by (simp add: add_divide_distrib)
[PROOF STATE]
proof (state)
this:
2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = (2 * real k + real (r01_binary_expansion' r (Suc n'))) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * real k / 2 ^ Suc (Suc n') + real (r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n') = (2 * real k + real (r01_binary_expansion' r (Suc n'))) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "... = (real (2*k + r01_binary_expansion' r (Suc n')))/2 ^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 * real k + real (r01_binary_expansion' r (Suc n'))) / 2 ^ Suc (Suc n') = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(2 * real k + real (r01_binary_expansion' r (Suc n'))) / 2 ^ Suc (Suc n') = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
have "(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. (\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "2 * k + r01_binary_expansion' r (Suc n') < 2^Suc (Suc n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
have "k + 1 \<le> 2^Suc n'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k + 1 \<le> 2 ^ Suc n'
[PROOF STEP]
using ih
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n' \<and> k < 2 ^ Suc n'

goal (1 subgoal):
 1. k + 1 \<le> 2 ^ Suc n'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k + 1 \<le> 2 ^ Suc n'

goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
hence "2*k + 2 \<le> 2^Suc (Suc n')"
[PROOF STATE]
proof (prove)
using this:
k + 1 \<le> 2 ^ Suc n'

goal (1 subgoal):
 1. 2 * k + 2 \<le> 2 ^ Suc (Suc n')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * k + 2 \<le> 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * k + 2 \<le> 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
using real01_binary_expansion'_0or1[of r "Suc n'"]
[PROOF STATE]
proof (prove)
using this:
2 * k + 2 \<le> 2 ^ Suc (Suc n')
r01_binary_expansion' r (Suc n') \<in> {0, 1}

goal (1 subgoal):
 1. 2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
have "r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd (2 * k + r01_binary_expansion' r (Suc n'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd (2 * k + r01_binary_expansion' r (Suc n'))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd (2 * k + r01_binary_expansion' r (Suc n'))

goal (1 subgoal):
 1. \<And>n. \<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k) \<Longrightarrow> \<exists>k. (\<Sum>i = 0..Suc n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n) \<and> k < 2 ^ Suc (Suc n) \<and> (r01_binary_expansion' r (Suc n) = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n) = 1 \<longrightarrow> odd k)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))
r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd (2 * k + r01_binary_expansion' r (Suc n'))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real (2 * k + r01_binary_expansion' r (Suc n')) / 2 ^ Suc (Suc n')
2 * k + r01_binary_expansion' r (Suc n') < 2 ^ Suc (Suc n')
r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even (2 * k + r01_binary_expansion' r (Suc n'))
r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd (2 * k + r01_binary_expansion' r (Suc n'))

goal (1 subgoal):
 1. \<exists>k. (\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n') \<and> k < 2 ^ Suc (Suc n') \<and> (r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd k)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i = 0..Suc n'. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc (Suc n') \<and> k < 2 ^ Suc (Suc n') \<and> (r01_binary_expansion' r (Suc n') = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r (Suc n') = 1 \<longrightarrow> odd k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)

goal (1 subgoal):
 1. \<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (\<Sum>i = 0..n. real (r01_binary_expansion' r i) * (1 / 2) ^ Suc i) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)

goal (1 subgoal):
 1. \<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>k. snd (snd (r01_binary_expansion'' r n)) = real k / 2 ^ Suc n \<and> k < 2 ^ Suc n \<and> (r01_binary_expansion' r n = 0 \<longrightarrow> even k) \<and> (r01_binary_expansion' r n = 1 \<longrightarrow> odd k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma image_mset_mono:
  assumes
    mono_f: "\<forall>x \<in> set_mset M. \<forall>y \<in> set_mset N. x < y \<longrightarrow> f x < f y" and
    less: "M \<le> N"
  shows "image_mset f M \<le> image_mset f N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset f M \<le> image_mset f N
[PROOF STEP]
by (metis eq_iff image_mset_strict_mono less less_imp_le mono_f order.not_eq_order_implies_strict)


[STATEMENT]
theorem heron:
  fixes A B C :: "real ^ 2"
  defines "a \<equiv> dist B C" and "b \<equiv> dist A C" and "c \<equiv> dist A B"
  defines "s \<equiv> (a + b + c) / 2"
  shows   "content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have [simp]: "(UNIV :: 2 set) = {1, 2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = {1, 2}
[PROOF STEP]
using exhaust_2
[PROOF STATE]
proof (prove)
using this:
?x = 1 \<or> ?x = 2

goal (1 subgoal):
 1. UNIV = {1, 2}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
UNIV = {1, 2}

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have dist_eq: "dist (A :: real ^ 2) B ^ 2 = (A $ 1 - B $ 1) ^ 2 + (A $ 2 - B $ 2) ^ 2"
    for A B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (dist A B)\<^sup>2 = (A $ 1 - B $ 1)\<^sup>2 + (A $ 2 - B $ 2)\<^sup>2
[PROOF STEP]
by (simp add: dist_vec_def dist_real_def)
[PROOF STATE]
proof (state)
this:
(dist ?A ?B)\<^sup>2 = (?A $ 1 - ?B $ 1)\<^sup>2 + (?A $ 2 - ?B $ 2)\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have nonneg: "s * (s - a) * (s - b) * (s - c) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> s * (s - a) * (s - b) * (s - c)
[PROOF STEP]
using dist_triangle[of A B C] dist_triangle[of A C B] dist_triangle[of B C A]
[PROOF STATE]
proof (prove)
using this:
dist A B \<le> dist A C + dist C B
dist A C \<le> dist A B + dist B C
dist B C \<le> dist B A + dist A C

goal (1 subgoal):
 1. 0 \<le> s * (s - a) * (s - b) * (s - c)
[PROOF STEP]
by (intro mult_nonneg_nonneg) (auto simp: s_def a_def b_def c_def dist_commute)
[PROOF STATE]
proof (state)
this:
0 \<le> s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have "16 * content (convex hull {A, B, C}) ^ 2 =
          4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2)) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 16 * (content (convex hull {A, B, C}))\<^sup>2 = 4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2
[PROOF STEP]
by (subst content_triangle) (simp add: power_divide)
[PROOF STATE]
proof (state)
this:
16 * (content (convex hull {A, B, C}))\<^sup>2 = 4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
16 * (content (convex hull {A, B, C}))\<^sup>2 = 4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have "\<dots> = (2 * (dist A B ^ 2 * dist A C ^ 2 + dist A B ^ 2 * dist B C ^ 2 +
      dist A C ^ 2 * dist B C ^ 2) - (dist A B ^ 2) ^ 2 - (dist A C ^ 2) ^ 2 - (dist B C ^ 2) ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2 = 2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2
[PROOF STEP]
unfolding dist_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2 = 2 * (((A $ 1 - B $ 1)\<^sup>2 + (A $ 2 - B $ 2)\<^sup>2) * ((A $ 1 - C $ 1)\<^sup>2 + (A $ 2 - C $ 2)\<^sup>2) + ((A $ 1 - B $ 1)\<^sup>2 + (A $ 2 - B $ 2)\<^sup>2) * ((B $ 1 - C $ 1)\<^sup>2 + (B $ 2 - C $ 2)\<^sup>2) + ((A $ 1 - C $ 1)\<^sup>2 + (A $ 2 - C $ 2)\<^sup>2) * ((B $ 1 - C $ 1)\<^sup>2 + (B $ 2 - C $ 2)\<^sup>2)) - ((A $ 1 - B $ 1)\<^sup>2 + (A $ 2 - B $ 2)\<^sup>2)\<^sup>2 - ((A $ 1 - C $ 1)\<^sup>2 + (A $ 2 - C $ 2)\<^sup>2)\<^sup>2 - ((B $ 1 - C $ 1)\<^sup>2 + (B $ 2 - C $ 2)\<^sup>2)\<^sup>2
[PROOF STEP]
unfolding power2_eq_square
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 * (((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2)) * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))) = 2 * (((A $ 1 - B $ 1) * (A $ 1 - B $ 1) + (A $ 2 - B $ 2) * (A $ 2 - B $ 2)) * ((A $ 1 - C $ 1) * (A $ 1 - C $ 1) + (A $ 2 - C $ 2) * (A $ 2 - C $ 2)) + ((A $ 1 - B $ 1) * (A $ 1 - B $ 1) + (A $ 2 - B $ 2) * (A $ 2 - B $ 2)) * ((B $ 1 - C $ 1) * (B $ 1 - C $ 1) + (B $ 2 - C $ 2) * (B $ 2 - C $ 2)) + ((A $ 1 - C $ 1) * (A $ 1 - C $ 1) + (A $ 2 - C $ 2) * (A $ 2 - C $ 2)) * ((B $ 1 - C $ 1) * (B $ 1 - C $ 1) + (B $ 2 - C $ 2) * (B $ 2 - C $ 2))) - ((A $ 1 - B $ 1) * (A $ 1 - B $ 1) + (A $ 2 - B $ 2) * (A $ 2 - B $ 2)) * ((A $ 1 - B $ 1) * (A $ 1 - B $ 1) + (A $ 2 - B $ 2) * (A $ 2 - B $ 2)) - ((A $ 1 - C $ 1) * (A $ 1 - C $ 1) + (A $ 2 - C $ 2) * (A $ 2 - C $ 2)) * ((A $ 1 - C $ 1) * (A $ 1 - C $ 1) + (A $ 2 - C $ 2) * (A $ 2 - C $ 2)) - ((B $ 1 - C $ 1) * (B $ 1 - C $ 1) + (B $ 2 - C $ 2) * (B $ 2 - C $ 2)) * ((B $ 1 - C $ 1) * (B $ 1 - C $ 1) + (B $ 2 - C $ 2) * (B $ 2 - C $ 2))
[PROOF STEP]
by algebra
[PROOF STATE]
proof (state)
this:
4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2 = 2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
4 * ((C $ 1 - A $ 1) * (B $ 2 - A $ 2) - (B $ 1 - A $ 1) * (C $ 2 - A $ 2))\<^sup>2 = 2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have "\<dots> = (a + b + c) * ((a + b + c) - 2 * a) * ((a + b + c) - 2 * b) *
                    ((a + b + c) - 2 * c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2 = (a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c)
[PROOF STEP]
unfolding power2_eq_square
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (dist A B * dist A B * (dist A C * dist A C) + dist A B * dist A B * (dist B C * dist B C) + dist A C * dist A C * (dist B C * dist B C)) - dist A B * dist A B * (dist A B * dist A B) - dist A C * dist A C * (dist A C * dist A C) - dist B C * dist B C * (dist B C * dist B C) = (a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c)
[PROOF STEP]
by (simp add: s_def a_def b_def c_def algebra_simps)
[PROOF STATE]
proof (state)
this:
2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2 = (a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * ((dist A B)\<^sup>2 * (dist A C)\<^sup>2 + (dist A B)\<^sup>2 * (dist B C)\<^sup>2 + (dist A C)\<^sup>2 * (dist B C)\<^sup>2) - ((dist A B)\<^sup>2)\<^sup>2 - ((dist A C)\<^sup>2)\<^sup>2 - ((dist B C)\<^sup>2)\<^sup>2 = (a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have "\<dots> = 16 * s * (s - a) * (s - b) * (s - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c) = 16 * s * (s - a) * (s - b) * (s - c)
[PROOF STEP]
by (simp add: s_def field_split_simps)
[PROOF STATE]
proof (state)
this:
(a + b + c) * (a + b + c - 2 * a) * (a + b + c - 2 * b) * (a + b + c - 2 * c) = 16 * s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
16 * (content (convex hull {A, B, C}))\<^sup>2 = 16 * s * (s - a) * (s - b) * (s - c)
[PROOF STEP]
have "content (convex hull {A, B, C}) ^ 2 = s * (s - a) * (s - b) * (s - c)"
[PROOF STATE]
proof (prove)
using this:
16 * (content (convex hull {A, B, C}))\<^sup>2 = 16 * s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. (content (convex hull {A, B, C}))\<^sup>2 = s * (s - a) * (s - b) * (s - c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(content (convex hull {A, B, C}))\<^sup>2 = s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(content (convex hull {A, B, C}))\<^sup>2 = s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
have "\<dots> = sqrt (s * (s - a) * (s - b) * (s - c)) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s * (s - a) * (s - b) * (s - c) = (sqrt (s * (s - a) * (s - b) * (s - c)))\<^sup>2
[PROOF STEP]
by (intro real_sqrt_pow2 [symmetric] nonneg)
[PROOF STATE]
proof (state)
this:
s * (s - a) * (s - b) * (s - c) = (sqrt (s * (s - a) * (s - b) * (s - c)))\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(content (convex hull {A, B, C}))\<^sup>2 = (sqrt (s * (s - a) * (s - b) * (s - c)))\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(content (convex hull {A, B, C}))\<^sup>2 = (sqrt (s * (s - a) * (s - b) * (s - c)))\<^sup>2

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
using nonneg
[PROOF STATE]
proof (prove)
using this:
(content (convex hull {A, B, C}))\<^sup>2 = (sqrt (s * (s - a) * (s - b) * (s - c)))\<^sup>2
0 \<le> s * (s - a) * (s - b) * (s - c)

goal (1 subgoal):
 1. content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))
[PROOF STEP]
by (subst (asm) power2_eq_iff_nonneg) auto
[PROOF STATE]
proof (state)
this:
content (convex hull {A, B, C}) = sqrt (s * (s - a) * (s - b) * (s - c))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nth_prime_2 [simp]: "nth_prime 2 = 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_prime 2 = 5
[PROOF STEP]
by (simp add: nth_prime_eval)


[STATEMENT]
lemma im_set_un:"\<lbrakk> f\<in>A \<rightarrow> B; A1 \<subseteq> A; A2 \<subseteq> A \<rbrakk> \<Longrightarrow>
             f`(A1 \<union> A2) = (f`A1) \<union> (f`A2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; A1 \<subseteq> A; A2 \<subseteq> A\<rbrakk> \<Longrightarrow> f ` (A1 \<union> A2) = f ` A1 \<union> f ` A2
[PROOF STEP]
apply (simp add:image_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; A1 \<subseteq> A; A2 \<subseteq> A\<rbrakk> \<Longrightarrow> {y. \<exists>x\<in>A1 \<union> A2. y = f x} = {y. \<exists>x\<in>A1. y = f x} \<union> {y. \<exists>x\<in>A2. y = f x}
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma linear_iff: "linear s1 s2 f \<longleftrightarrow>
  (vector_space s1 \<and> vector_space s2 \<and> (\<forall>x y. f (x + y) = f x + f y) \<and> (\<forall>c x. f (s1 c x) = s2 c (f x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear s1 s2 f = (vector_space s1 \<and> vector_space s2 \<and> (\<forall>x y. f (x + y) = f x + f y) \<and> (\<forall>c x. f (s1 c x) = s2 c (f x)))
[PROOF STEP]
unfolding linear_def module_hom_iff vector_space_def module_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((((\<forall>a x y. s1 a (x + y) = s1 a x + s1 a y) \<and> (\<forall>a b x. s1 (a + b) x = s1 a x + s1 b x)) \<and> (\<forall>a b x. s1 a (s1 b x) = s1 (a * b) x) \<and> (\<forall>x. s1 (1::'a) x = x)) \<and> (((\<forall>a x y. s2 a (x + y) = s2 a x + s2 a y) \<and> (\<forall>a b x. s2 (a + b) x = s2 a x + s2 b x)) \<and> (\<forall>a b x. s2 a (s2 b x) = s2 (a * b) x) \<and> (\<forall>x. s2 (1::'a) x = x)) \<and> (((\<forall>a x y. s1 a (x + y) = s1 a x + s1 a y) \<and> (\<forall>a b x. s1 (a + b) x = s1 a x + s1 b x)) \<and> (\<forall>a b x. s1 a (s1 b x) = s1 (a * b) x) \<and> (\<forall>x. s1 (1::'a) x = x)) \<and> (((\<forall>a x y. s2 a (x + y) = s2 a x + s2 a y) \<and> (\<forall>a b x. s2 (a + b) x = s2 a x + s2 b x)) \<and> (\<forall>a b x. s2 a (s2 b x) = s2 (a * b) x) \<and> (\<forall>x. s2 (1::'a) x = x)) \<and> (\<forall>x y. f (x + y) = f x + f y) \<and> (\<forall>c x. f (s1 c x) = s2 c (f x))) = ((((\<forall>a x y. s1 a (x + y) = s1 a x + s1 a y) \<and> (\<forall>a b x. s1 (a + b) x = s1 a x + s1 b x)) \<and> (\<forall>a b x. s1 a (s1 b x) = s1 (a * b) x) \<and> (\<forall>x. s1 (1::'a) x = x)) \<and> (((\<forall>a x y. s2 a (x + y) = s2 a x + s2 a y) \<and> (\<forall>a b x. s2 (a + b) x = s2 a x + s2 b x)) \<and> (\<forall>a b x. s2 a (s2 b x) = s2 (a * b) x) \<and> (\<forall>x. s2 (1::'a) x = x)) \<and> (\<forall>x y. f (x + y) = f x + f y) \<and> (\<forall>c x. f (s1 c x) = s2 c (f x)))
[PROOF STEP]
by auto


[STATEMENT]
lemma integral_reflect_real[simp]:
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
  shows "integral\<^sup>L (lebesgue_on {-b .. -a}) (\<lambda>x. f(-x)) = integral\<^sup>L (lebesgue_on {a..b::real}) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|lebesgue_on {- b..- a}. f (- x) = integral\<^sup>L (lebesgue_on {a..b}) f
[PROOF STEP]
using has_bochner_integral_reflect_real [of b a f]
[PROOF STATE]
proof (prove)
using this:
has_bochner_integral (lebesgue_on {- b..- a}) (\<lambda>x. f (- x)) ?i = has_bochner_integral (lebesgue_on {a..b}) f ?i

goal (1 subgoal):
 1. LINT x|lebesgue_on {- b..- a}. f (- x) = integral\<^sup>L (lebesgue_on {a..b}) f
[PROOF STEP]
by (metis has_bochner_integral_iff not_integrable_integral_eq)


[STATEMENT]
lemma scalar_prod_left_zero[simp]: "v \<in> carrier_vec n \<Longrightarrow> 0\<^sub>v n \<bullet> v = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> carrier_vec n \<Longrightarrow> 0\<^sub>v n \<bullet> v = (0::'a)
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> carrier_vec n \<Longrightarrow> (\<Sum>i = 0..<dim_vec v. 0\<^sub>v n $ i * v $ i) = (0::'a)
[PROOF STEP]
by (rule sum.neutral, auto)


[STATEMENT]
lemma DERIV_const_ratio_const2:
  fixes f :: "real \<Rightarrow> real"
  assumes "a \<noteq> b" and df: "\<And>x. DERIV f x :> k"
  shows "(f b - f a) / (b - a) = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f b - f a) / (b - a) = k
[PROOF STEP]
using DERIV_const_ratio_const [OF assms] \<open>a \<noteq> b\<close>
[PROOF STATE]
proof (prove)
using this:
f b - f a = (b - a) * k
a \<noteq> b

goal (1 subgoal):
 1. (f b - f a) / (b - a) = k
[PROOF STEP]
by auto


[STATEMENT]
lemma countable_iff_vcard_less1: "countable (elts x) \<longleftrightarrow> vcard x < \<aleph>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (elts x) = (vcard x < \<aleph>1)
[PROOF STEP]
by (simp add: countable_iff_le_Aleph0 lt_csucc_iff one_V_def)


[STATEMENT]
lemma interval_of_prod: "interval_of (a * b) = interval_of a * interval_of b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interval_of (a * b) = interval_of a * interval_of b
[PROOF STEP]
by (simp add: lower_times upper_times interval_eqI)


[STATEMENT]
lemma wens_single_FF_eq_UNIV:
     "wens_single (range (\<lambda>x::int. (x, x + 1))) (atLeast k) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wens_single (range (\<lambda>x. (x, x + 1))) {k..} = UNIV
[PROOF STEP]
apply (auto simp add: wens_single_eq_Union)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<exists>xa. x \<in> wens_single_finite (range (\<lambda>x. (x, x + 1))) {k..} xa
[PROOF STEP]
apply (rule_tac x="nat (k-x)" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> wens_single_finite (range (\<lambda>x. (x, x + 1))) {k..} (nat (k - x))
[PROOF STEP]
apply (simp add: wens_single_finite_FF)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem (in abelian_group) a_lagrange:
     "\<lbrakk>finite(carrier G); additive_subgroup H G\<rbrakk>
      \<Longrightarrow> card(a_rcosets H) * card(H) = order(G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite (carrier G); additive_subgroup H G\<rbrakk> \<Longrightarrow> card (a_rcosets H) * card H = order G
[PROOF STEP]
by (rule group.lagrange [OF a_group,
    folded A_RCOSETS_def, simplified monoid_record_simps order_def, folded order_def])
    (fast intro!: additive_subgroup.a_subgroup)+


[STATEMENT]
lemma DERIV_inverse'[derivative_intros]:
  assumes "(f has_field_derivative D) (at x within s)"
    and "f x \<noteq> 0"
  shows "((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x)))
    (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
have "(f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)
[PROOF STEP]
by (rule arg_cong [of "\<lambda>x. x * D"]) (simp add: fun_eq_iff)
[PROOF STATE]
proof (state)
this:
(f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)

goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
(f has_field_derivative D) (at x within s)
f x \<noteq> (0::'a)
(f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)
[PROOF STEP]
have "(f has_derivative (\<lambda>x. x * D)) (at x within s)"
[PROOF STATE]
proof (prove)
using this:
(f has_field_derivative D) (at x within s)
f x \<noteq> (0::'a)
(f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)

goal (1 subgoal):
 1. (f has_derivative (\<lambda>x. x * D)) (at x within s)
[PROOF STEP]
by (auto dest!: has_field_derivative_imp_has_derivative)
[PROOF STATE]
proof (state)
this:
(f has_derivative (\<lambda>x. x * D)) (at x within s)

goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(f has_derivative (\<lambda>x. x * D)) (at x within s)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(f has_derivative (\<lambda>x. x * D)) (at x within s)

goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
using \<open>f x \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(f has_derivative (\<lambda>x. x * D)) (at x within s)
f x \<noteq> (0::'a)

goal (1 subgoal):
 1. ((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)
[PROOF STEP]
by (auto intro: has_derivative_imp_has_field_derivative has_derivative_inverse)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fpower_Inf_comm:
  fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
  shows "Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
assume "Inf_pres f"
[PROOF STATE]
proof (state)
this:
Inf_pres f

goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
hence "f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f (Suc i) x)"
[PROOF STATE]
proof (prove)
using this:
Inf_pres f

goal (1 subgoal):
 1. f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f (Suc i) x)
[PROOF STEP]
by (simp add: fun_eq_iff image_comp)
[PROOF STATE]
proof (state)
this:
f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f (Suc i) x)

goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f (Suc i) x)

goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
have "... =  (\<Sqinter>i. fpower f i (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sqinter>i. fpower f (Suc i) x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
by (metis comp_eq_dest_lhs fun_mon.power_Suc2)
[PROOF STATE]
proof (state)
this:
(\<Sqinter>i. fpower f (Suc i) x) = (\<Sqinter>i. fpower f i (f x))

goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))

goal (1 subgoal):
 1. f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
f (\<Sqinter>i. fpower f i x) = (\<Sqinter>i. fpower f i (f x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma LIMSEQ_n_over_Suc_n: "(\<lambda>n. of_nat n / of_nat (Suc n) :: 'a :: real_normed_field) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. of_nat n / of_nat (Suc n)) \<longlonglongrightarrow> (1::'a)
[PROOF STEP]
proof (rule Lim_transform_eventually)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> (1::'a)
 2. \<forall>\<^sub>F x in sequentially. ?f x = of_nat x / of_nat (Suc x)
[PROOF STEP]
show "eventually (\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a) =
      of_nat n / of_nat (Suc n)) sequentially"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. inverse (of_nat (Suc n) / of_nat n) = of_nat n / of_nat (Suc n)
[PROOF STEP]
using eventually_gt_at_top[of "0::nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. inverse (of_nat (Suc n) / of_nat n) = of_nat n / of_nat (Suc n)
[PROOF STEP]
by eventually_elim (simp add: field_simps del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. inverse (of_nat (Suc n) / of_nat n) = of_nat n / of_nat (Suc n)

goal (1 subgoal):
 1. (\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> (1::'a)
[PROOF STEP]
have "(\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a)) \<longlonglongrightarrow> inverse 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> inverse (1::'a)
[PROOF STEP]
by (intro tendsto_inverse LIMSEQ_Suc_n_over_n) simp_all
[PROOF STATE]
proof (state)
this:
(\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> inverse (1::'a)

goal (1 subgoal):
 1. (\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> (1::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> inverse (1::'a)
[PROOF STEP]
show "(\<lambda>n. inverse (of_nat (Suc n) / of_nat n :: 'a)) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> inverse (1::'a)

goal (1 subgoal):
 1. (\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> (1::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. inverse (of_nat (Suc n) / of_nat n)) \<longlonglongrightarrow> (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pos_distrib_left:
  assumes "c > 0"
  shows "(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * (u z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
have "(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = (\<Sum>z\<in>outcomes. pmf q z * c * u z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = (\<Sum>z\<in>outcomes. pmf q z * c * u z)
[PROOF STEP]
by (simp add: ab_semigroup_mult_class.mult_ac(1))
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = (\<Sum>z\<in>outcomes. pmf q z * c * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = (\<Sum>z\<in>outcomes. pmf q z * c * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
have "... = (\<Sum>z\<in>outcomes. c * pmf q z *  u z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * c * u z) = (\<Sum>z\<in>outcomes. c * pmf q z * u z)
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. pmf q z * c * u z) = (\<Sum>z\<in>outcomes. c * pmf q z * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. pmf q z * c * u z) = (\<Sum>z\<in>outcomes. c * pmf q z * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
have "... = c * (\<Sum>z\<in>outcomes. pmf q z *  u z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. c * pmf q z * u z) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
by (simp add: ab_semigroup_mult_class.mult_ac(1) sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. c * pmf q z * u z) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)

goal (1 subgoal):
 1. (\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>outcomes. pmf q z * (c * u z)) = c * (\<Sum>z\<in>outcomes. pmf q z * u z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hyperpow_not_zero: "\<And>r n. r \<noteq> (0::'a::{field} star) \<Longrightarrow> r pow n \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>r n. r \<noteq> 0 \<Longrightarrow> r pow n \<noteq> 0
[PROOF STEP]
by transfer (rule power_not_zero)


[STATEMENT]
lemma hausdorff_distance_sym:
  "hausdorff_distance A B = hausdorff_distance B A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hausdorff_distance A B = hausdorff_distance B A
[PROOF STEP]
unfolding hausdorff_distance_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if A = {} \<or> B = {} \<or> \<not> bounded A \<or> \<not> bounded B then 0 else max (SUP x\<in>A. infdist x B) (SUP x\<in>B. infdist x A)) = (if B = {} \<or> A = {} \<or> \<not> bounded B \<or> \<not> bounded A then 0 else max (SUP x\<in>B. infdist x A) (SUP x\<in>A. infdist x B))
[PROOF STEP]
by auto


[STATEMENT]
lemma convex_imp_path_connected:
  fixes S :: "'a::real_normed_vector set"
  assumes "convex S"
  shows "path_connected S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_connected S
[PROOF STEP]
unfolding path_connected_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>S. \<forall>y\<in>S. \<exists>g. path g \<and> path_image g \<subseteq> S \<and> pathstart g = x \<and> pathfinish g = y
[PROOF STEP]
using assms convex_contains_segment
[PROOF STATE]
proof (prove)
using this:
convex S
convex ?S = (\<forall>a\<in>?S. \<forall>b\<in>?S. closed_segment a b \<subseteq> ?S)

goal (1 subgoal):
 1. \<forall>x\<in>S. \<forall>y\<in>S. \<exists>g. path g \<and> path_image g \<subseteq> S \<and> pathstart g = x \<and> pathfinish g = y
[PROOF STEP]
by fastforce


[STATEMENT]
lemma integral_norm_bound_integral_component:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  fixes g :: "'n \<Rightarrow> 'b::euclidean_space"
  assumes f: "f integrable_on S" and g: "g integrable_on S"
    and fg: "\<And>x. x \<in> S \<Longrightarrow> norm(f x) \<le> (g x)\<bullet>k"
  shows "norm (integral S f) \<le> (integral S g)\<bullet>k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (integral S f) \<le> integral S g \<bullet> k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (integral S f) \<le> integral S g \<bullet> k
[PROOF STEP]
have "norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)
[PROOF STEP]
using integral_norm_bound_integral[OF f integrable_linear[OF g]]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>bounded_linear ?h1; \<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> (?h1 \<circ> g) x\<rbrakk> \<Longrightarrow> norm (integral S f) \<le> integral S (?h1 \<circ> g)

goal (1 subgoal):
 1. norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)
[PROOF STEP]
by (simp add: bounded_linear_inner_left fg)
[PROOF STATE]
proof (state)
this:
norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)

goal (1 subgoal):
 1. norm (integral S f) \<le> integral S g \<bullet> k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (integral S f) \<le> integral S ((\<lambda>x. x \<bullet> k) \<circ> g)

goal (1 subgoal):
 1. norm (integral S f) \<le> integral S g \<bullet> k
[PROOF STEP]
unfolding o_def integral_component_eq[OF g]
[PROOF STATE]
proof (prove)
using this:
norm (integral S f) \<le> integral S g \<bullet> k

goal (1 subgoal):
 1. norm (integral S f) \<le> integral S g \<bullet> k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (integral S f) \<le> integral S g \<bullet> k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_bijections_eq_zero:
  assumes "finite A" "finite B"
  assumes "card A \<noteq> card B"
  shows "card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = 0
[PROOF STEP]
using bij_betw_set_is_empty[OF assms]
[PROOF STATE]
proof (prove)
using this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = {}

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = 0
[PROOF STEP]
by (simp only: card.empty)


[STATEMENT]
lemma inf_3_elms: assumes "infinite X" shows "(\<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
obtain x y where 1: "x\<in>X" "y\<in>X" "y\<noteq>x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x y. \<lbrakk>x \<in> X; y \<in> X; y \<noteq> x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis assms finite.emptyI finite.insertI rev_finite_subset singleton_iff subsetI)
[PROOF STATE]
proof (state)
this:
x \<in> X
y \<in> X
y \<noteq> x

goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
have "infinite (X-{x,y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite (X - {x, y})
[PROOF STEP]
using infinite_remove
[PROOF STATE]
proof (prove)
using this:
infinite ?S \<Longrightarrow> infinite (?S - {?a})

goal (1 subgoal):
 1. infinite (X - {x, y})
[PROOF STEP]
by (simp add: assms)
[PROOF STATE]
proof (state)
this:
infinite (X - {x, y})

goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infinite (X - {x, y})
[PROOF STEP]
obtain z where 2: "z\<in>X" "x\<noteq>z" "z\<noteq>y"
[PROOF STATE]
proof (prove)
using this:
infinite (X - {x, y})

goal (1 subgoal):
 1. (\<And>z. \<lbrakk>z \<in> X; x \<noteq> z; z \<noteq> y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using infinite_imp_nonempty
[PROOF STATE]
proof (prove)
using this:
infinite (X - {x, y})
infinite ?S \<Longrightarrow> ?S \<noteq> {}

goal (1 subgoal):
 1. (\<And>z. \<lbrakk>z \<in> X; x \<noteq> z; z \<noteq> y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis Diff_eq_empty_iff insertCI subset_eq)
[PROOF STATE]
proof (state)
this:
z \<in> X
x \<noteq> z
z \<noteq> y

goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
using 1 2
[PROOF STATE]
proof (prove)
using this:
x \<in> X
y \<in> X
y \<noteq> x
z \<in> X
x \<noteq> z
z \<noteq> y

goal (1 subgoal):
 1. \<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>X. \<exists>y\<in>X. \<exists>z\<in>X. x \<noteq> y \<and> y \<noteq> z \<and> x \<noteq> z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma discriminant_nonneg:
  fixes a b c x :: real
  assumes "a \<noteq> 0"
    and "discrim a b c \<ge> 0"
  shows "a * x\<^sup>2 + b * x + c = 0 \<longleftrightarrow>
    x = (-b + sqrt (discrim a b c)) / (2 * a) \<or>
    x = (-b - sqrt (discrim a b c)) / (2 * a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
from complete_square and plus_or_minus_sqrt and assms
[PROOF STATE]
proof (chain)
picking this:
?a \<noteq> 0 \<Longrightarrow> (?a * ?x\<^sup>2 + ?b * ?x + ?c = 0) = ((2 * ?a * ?x + ?b)\<^sup>2 = discrim ?a ?b ?c)
0 \<le> ?y \<Longrightarrow> (?x\<^sup>2 = ?y) = (?x = sqrt ?y \<or> ?x = - sqrt ?y)
a \<noteq> 0
0 \<le> discrim a b c
[PROOF STEP]
have "a * x\<^sup>2 + b * x + c = 0 \<longleftrightarrow>
    (2 * a) * x + b = sqrt (discrim a b c) \<or>
    (2 * a) * x + b = - sqrt (discrim a b c)"
[PROOF STATE]
proof (prove)
using this:
?a \<noteq> 0 \<Longrightarrow> (?a * ?x\<^sup>2 + ?b * ?x + ?c = 0) = ((2 * ?a * ?x + ?b)\<^sup>2 = discrim ?a ?b ?c)
0 \<le> ?y \<Longrightarrow> (?x\<^sup>2 = ?y) = (?x = sqrt ?y \<or> ?x = - sqrt ?y)
a \<noteq> 0
0 \<le> discrim a b c

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(a * x\<^sup>2 + b * x + c = 0) = (2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a * x\<^sup>2 + b * x + c = 0) = (2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
have "\<dots> \<longleftrightarrow> (2 * a) * x = (-b + sqrt (discrim a b c)) \<or>
    (2 * a) * x = (-b - sqrt (discrim a b c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c)) = (2 * a * x = - b + sqrt (discrim a b c) \<or> 2 * a * x = - b - sqrt (discrim a b c))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c)) = (2 * a * x = - b + sqrt (discrim a b c) \<or> 2 * a * x = - b - sqrt (discrim a b c))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(2 * a * x + b = sqrt (discrim a b c) \<or> 2 * a * x + b = - sqrt (discrim a b c)) = (2 * a * x = - b + sqrt (discrim a b c) \<or> 2 * a * x = - b - sqrt (discrim a b c))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
from \<open>a \<noteq> 0\<close> and divide_non_zero [of "2 * a" x]
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> 0
2 * a \<noteq> 0 \<Longrightarrow> (2 * a * x = ?z) = (x = ?z / (2 * a))
[PROOF STEP]
have "\<dots> \<longleftrightarrow> x = (-b + sqrt (discrim a b c)) / (2 * a) \<or>
    x = (-b - sqrt (discrim a b c)) / (2 * a)"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> 0
2 * a \<noteq> 0 \<Longrightarrow> (2 * a * x = ?z) = (x = ?z / (2 * a))

goal (1 subgoal):
 1. (2 * a * x = - b + sqrt (discrim a b c) \<or> 2 * a * x = - b - sqrt (discrim a b c)) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(2 * a * x = - b + sqrt (discrim a b c) \<or> 2 * a * x = - b - sqrt (discrim a b c)) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
show "a * x\<^sup>2 + b * x + c = 0 \<longleftrightarrow>
    x = (-b + sqrt (discrim a b c)) / (2 * a) \<or>
    x = (-b - sqrt (discrim a b c)) / (2 * a)"
[PROOF STATE]
proof (prove)
using this:
(a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))

goal (1 subgoal):
 1. (a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(a * x\<^sup>2 + b * x + c = 0) = (x = (- b + sqrt (discrim a b c)) / (2 * a) \<or> x = (- b - sqrt (discrim a b c)) / (2 * a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma powr_half_sqrt: "0 \<le> x \<Longrightarrow> x powr (1/2) = sqrt x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> x powr (1 / 2) = sqrt x
[PROOF STEP]
by (simp add: powr_def root_powr_inverse sqrt_def)


[STATEMENT]
lemma reduce_not0':
  assumes A: "A \<in> carrier_mat m n" and a: "a<m" and a_less_b: "a<b" and j: "0<n" and b: "b<m"
    and Aaj: "A $$ (a,0) \<noteq> 0"
  shows "reduce a b 0 A $$ (a, 0) \<noteq> 0" (is "?reduce_ab $$ (a,0) \<noteq> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
have "?reduce_ab $$ (a,0) = (let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) = (let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r)
[PROOF STEP]
by (rule reduce_gcd[OF A _ j Aaj], insert a, simp)
[PROOF STATE]
proof (state)
this:
reduce a b 0 A $$ (a, 0) = (let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r)

goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
reduce a b 0 A $$ (a, 0) = (let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r)

goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
have "... \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r) \<noteq> 0
[PROOF STEP]
unfolding Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 0 dvd gcd (A $$ (a, 0)) (A $$ (b, 0)) then 0 else gcd (A $$ (a, 0)) (A $$ (b, 0))) \<noteq> 0
[PROOF STEP]
by (simp add: assms(6))
[PROOF STATE]
proof (state)
this:
(let r = gcd (A $$ (a, 0)) (A $$ (b, 0)) in if 0 dvd r then 0 else r) \<noteq> 0

goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
reduce a b 0 A $$ (a, 0) \<noteq> 0

goal (1 subgoal):
 1. reduce a b 0 A $$ (a, 0) \<noteq> 0
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
reduce a b 0 A $$ (a, 0) \<noteq> 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_one_sin_zero:
  fixes x :: "'a::{real_normed_field,banach}"
  assumes "cos x = 1"
  shows "sin x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin x = (0::'a)
[PROOF STEP]
using sin_cos_squared_add [of x, unfolded assms]
[PROOF STATE]
proof (prove)
using this:
(sin x)\<^sup>2 + (1::'a)\<^sup>2 = (1::'a)

goal (1 subgoal):
 1. sin x = (0::'a)
[PROOF STEP]
by simp


[STATEMENT]
lemma roots1: fixes p :: "'a :: field poly"
  assumes p1: "degree p = 1"
  shows "{x. poly p x = 0} = {roots1 p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. poly p x = (0::'a)} = {roots1 p}
[PROOF STEP]
using degree1_coeffs[OF p1]
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. p = [:b, a:] \<and> a \<noteq> (0::'a)

goal (1 subgoal):
 1. {x. poly p x = (0::'a)} = {roots1 p}
[PROOF STEP]
unfolding roots1_def
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. p = [:b, a:] \<and> a \<noteq> (0::'a)

goal (1 subgoal):
 1. {x. poly p x = (0::'a)} = {- coeff p 0 / coeff p 1}
[PROOF STEP]
by (auto simp: add_eq_0_iff nonzero_neg_divide_eq_eq2)


[STATEMENT]
theorem IF2set_simps:
  "IF2set (ctor2 x) = F2set1 x \<union> ((\<Union>a \<in> F2set2 x. IF1set a) \<union> (\<Union>a \<in> F2set3 x. IF2set a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IF2set (ctor2 x) = F2set1 x \<union> (\<Union> (IF1set ` F2set2 x) \<union> \<Union> (IF2set ` F2set3 x))
[PROOF STEP]
apply (rule trans[OF o_eq_dest[OF IF2set]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IF2col (F2map id IF1set IF2set x) = F2set1 x \<union> (\<Union> (IF1set ` F2set2 x) \<union> \<Union> (IF2set ` F2set3 x))
[PROOF STEP]
apply (rule arg_cong2[of _ _ _ _ "(\<union>)"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. F2set1 (F2map id IF1set IF2set x) = F2set1 x
 2. \<Union> (F2set2 (F2map id IF1set IF2set x)) \<union> \<Union> (F2set3 (F2map id IF1set IF2set x)) = \<Union> (IF1set ` F2set2 x) \<union> \<Union> (IF2set ` F2set3 x)
[PROOF STEP]
apply (rule trans[OF F2.set_map(1) trans[OF fun_cong[OF image_id] id_apply]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (F2set2 (F2map id IF1set IF2set x)) \<union> \<Union> (F2set3 (F2map id IF1set IF2set x)) = \<Union> (IF1set ` F2set2 x) \<union> \<Union> (IF2set ` F2set3 x)
[PROOF STEP]
apply (rule arg_cong2[of _ _ _ _ "(\<union>)"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<Union> (F2set2 (F2map id IF1set IF2set x)) = \<Union> (IF1set ` F2set2 x)
 2. \<Union> (F2set3 (F2map id IF1set IF2set x)) = \<Union> (IF2set ` F2set3 x)
[PROOF STEP]
apply (rule arg_cong[OF F2.set_map(2)])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (F2set3 (F2map id IF1set IF2set x)) = \<Union> (IF2set ` F2set3 x)
[PROOF STEP]
apply (rule arg_cong[OF F2.set_map(3)])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ceiling_add_le: "\<lceil>x + y\<rceil> \<le> \<lceil>x\<rceil> + \<lceil>y\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>x + y\<rceil> \<le> \<lceil>x\<rceil> + \<lceil>y\<rceil>
[PROOF STEP]
by (simp only: ceiling_le_iff of_int_add add_mono le_of_int_ceiling)


[STATEMENT]
lemma tendsto_null_power: "\<lbrakk>(f \<longlongrightarrow> 0) F; 0 < n\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> 0) F"
    for f :: "'a \<Rightarrow> 'b::{power,real_normed_algebra_1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f \<longlongrightarrow> (0::'b)) F; 0 < n\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> (0::'b)) F
[PROOF STEP]
using tendsto_power [of f 0 F n]
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> (0::'b)) F \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> (0::'b) ^ n) F

goal (1 subgoal):
 1. \<lbrakk>(f \<longlongrightarrow> (0::'b)) F; 0 < n\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x ^ n) \<longlongrightarrow> (0::'b)) F
[PROOF STEP]
by (simp add: power_0_left)


[STATEMENT]
lemma col_mat_mult_index :
  assumes wf1: "mat nr n m1"
  and wf2: "mat n nc m2"
  and j: "j < nc"
  shows "col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda> i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0 ..< nr]" (is "col ?l j = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]
[PROOF STEP]
have wf12: "mat nr nc ?l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat nr nc (mat_multI ze pl ti nr m1 m2)
[PROOF STEP]
by (rule mat_mult[OF wf1 wf2])
[PROOF STATE]
proof (state)
this:
mat nr nc (mat_multI ze pl ti nr m1 m2)

goal (1 subgoal):
 1. col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]
[PROOF STEP]
have len: "length (col ?l j) = length ?r" and nr: "length (col ?l j) = nr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (col (mat_multI ze pl ti nr m1 m2) j) = length (map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]) &&& length (col (mat_multI ze pl ti nr m1 m2) j) = nr
[PROOF STEP]
using wf1 wf2 wf12 j
[PROOF STATE]
proof (prove)
using this:
mat nr n m1
mat n nc m2
mat nr nc (mat_multI ze pl ti nr m1 m2)
j < nc

goal (1 subgoal):
 1. length (col (mat_multI ze pl ti nr m1 m2) j) = length (map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]) &&& length (col (mat_multI ze pl ti nr m1 m2) j) = nr
[PROOF STEP]
unfolding mat_def col_def
[PROOF STATE]
proof (prove)
using this:
length m1 = n \<and> Ball (set m1) (vec nr)
length m2 = nc \<and> Ball (set m2) (vec n)
length (mat_multI ze pl ti nr m1 m2) = nc \<and> Ball (set (mat_multI ze pl ti nr m1 m2)) (vec nr)
j < nc

goal (1 subgoal):
 1. length (mat_multI ze pl ti nr m1 m2 ! j) = length (map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (m2 ! j)) [0..<nr]) &&& length (mat_multI ze pl ti nr m1 m2 ! j) = nr
[PROOF STEP]
by (auto simp: vec_def)
[PROOF STATE]
proof (state)
this:
length (col (mat_multI ze pl ti nr m1 m2) j) = length (map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr])
length (col (mat_multI ze pl ti nr m1 m2) j) = nr

goal (1 subgoal):
 1. col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]
[PROOF STEP]
by (rule nth_equalityI[OF len], simp add: j nr, unfold col_def, simp only:
    mat_mult_index[OF wf1 wf2 _ j], simp add: col_def)
[PROOF STATE]
proof (state)
this:
col (mat_multI ze pl ti nr m1 m2) j = map (\<lambda>i. scalar_prodI ze pl ti (row m1 i) (col m2 j)) [0..<nr]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma isUCont_prod_metric:
  fixes f :: \<open>('a::metric_space \<times> 'b::metric_space) \<Rightarrow> 'c::metric_space\<close>
  shows \<open>isUCont f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x. \<forall>y. \<forall>x'. \<forall>y'. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isUCont f = (\<forall>e>0. \<exists>d>0. \<forall>x y x' y'. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e)
[PROOF STEP]
using uniformly_continuous_on_prod_metric[of UNIV UNIV]
[PROOF STATE]
proof (prove)
using this:
uniformly_continuous_on (UNIV \<times> UNIV) ?f = (\<forall>e>0. \<exists>d>0. \<forall>x\<in>UNIV. \<forall>y\<in>UNIV. \<forall>x'\<in>UNIV. \<forall>y'\<in>UNIV. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (?f (x, x')) (?f (y, y')) < e)

goal (1 subgoal):
 1. isUCont f = (\<forall>e>0. \<exists>d>0. \<forall>x y x' y'. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e)
[PROOF STEP]
by auto


[STATEMENT]
lemma prod_Suc_fact: "prod Suc {0..<n} = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod Suc {0..<n} = fact n
[PROOF STEP]
by (simp add: fact_prod_Suc)


[STATEMENT]
lemma times_iff_sum_squares: "f*g = (f+g)\<^sup>2/4 - (f-g)\<^sup>2/(4::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f * g = (f + g)\<^sup>2 / 4 - (f - g)\<^sup>2 / 4
[PROOF STEP]
by (simp add: power2_eq_square field_simps)


[STATEMENT]
lemma coplanar_linear_image:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  assumes "coplanar S" "linear f" shows "coplanar(f ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
fix u v w
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
assume "S \<subseteq> affine hull {u, v, w}"
[PROOF STATE]
proof (state)
this:
S \<subseteq> affine hull {u, v, w}

goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S \<subseteq> affine hull {u, v, w}
[PROOF STEP]
have "f ` S \<subseteq> f ` (affine hull {u, v, w})"
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> affine hull {u, v, w}

goal (1 subgoal):
 1. f ` S \<subseteq> f ` (affine hull {u, v, w})
[PROOF STEP]
by (simp add: image_mono)
[PROOF STATE]
proof (state)
this:
f ` S \<subseteq> f ` (affine hull {u, v, w})

goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f ` S \<subseteq> f ` (affine hull {u, v, w})
[PROOF STEP]
have "f ` S \<subseteq> affine hull (f ` {u, v, w})"
[PROOF STATE]
proof (prove)
using this:
f ` S \<subseteq> f ` (affine hull {u, v, w})

goal (1 subgoal):
 1. f ` S \<subseteq> affine hull f ` {u, v, w}
[PROOF STEP]
by (metis assms(2) linear_conv_bounded_linear affine_hull_linear_image)
[PROOF STATE]
proof (state)
this:
f ` S \<subseteq> affine hull f ` {u, v, w}

goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
S \<subseteq> affine hull {?u2, ?v2, ?w2} \<Longrightarrow> f ` S \<subseteq> affine hull f ` {?u2, ?v2, ?w2}

goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S \<subseteq> affine hull {?u2, ?v2, ?w2} \<Longrightarrow> f ` S \<subseteq> affine hull f ` {?u2, ?v2, ?w2}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> affine hull {?u2, ?v2, ?w2} \<Longrightarrow> f ` S \<subseteq> affine hull f ` {?u2, ?v2, ?w2}

goal (1 subgoal):
 1. coplanar (f ` S)
[PROOF STEP]
by auto (meson assms(1) coplanar_def)
[PROOF STATE]
proof (state)
this:
coplanar (f ` S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hnorm_triangle_ineq: "\<And>x y::'a::real_normed_vector star. hnorm (x + y) \<le> hnorm x + hnorm y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. hnorm (x + y) \<le> hnorm x + hnorm y
[PROOF STEP]
by transfer (rule norm_triangle_ineq)


[STATEMENT]
lemma ccSup_inter_less_eq: "countable A \<Longrightarrow> countable B \<Longrightarrow> Sup (A \<inter> B) \<le> inf (Sup A) (Sup B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; countable B\<rbrakk> \<Longrightarrow> Sup (A \<inter> B) \<le> inf (Sup A) (Sup B)
[PROOF STEP]
by (auto intro: ccSup_least ccSup_upper)


[STATEMENT]
lemma powr_lower_bound: "\<lbrakk>(l::real) > 0; l \<le> x; x \<le> u\<rbrakk> \<Longrightarrow> min (l powr z) (u powr z) \<le> x powr z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; l \<le> x; x \<le> u\<rbrakk> \<Longrightarrow> min (l powr z) (u powr z) \<le> x powr z
[PROOF STEP]
apply (cases "z \<ge> 0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < l; l \<le> x; x \<le> u; 0 \<le> z\<rbrakk> \<Longrightarrow> min (l powr z) (u powr z) \<le> x powr z
 2. \<lbrakk>0 < l; l \<le> x; x \<le> u; \<not> 0 \<le> z\<rbrakk> \<Longrightarrow> min (l powr z) (u powr z) \<le> x powr z
[PROOF STEP]
apply (rule order.trans[OF min.cobounded1 powr_mono2], simp_all) []
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; l \<le> x; x \<le> u; \<not> 0 \<le> z\<rbrakk> \<Longrightarrow> min (l powr z) (u powr z) \<le> x powr z
[PROOF STEP]
apply (rule order.trans[OF min.cobounded2 powr_mono2'], simp_all) []
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma complex_neq_0: "z\<noteq>0 \<longleftrightarrow> (Re z)\<^sup>2 + (Im z)\<^sup>2 > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z \<noteq> 0) = (0 < (Re z)\<^sup>2 + (Im z)\<^sup>2)
[PROOF STEP]
by (metis complex_eq_0 less_numeral_extra(3) sum_power2_gt_zero_iff)


[STATEMENT]
lemma L2_set_nonneg [simp]: "0 \<le> L2_set f A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> L2_set f A
[PROOF STEP]
unfolding L2_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> sqrt (\<Sum>i\<in>A. (f i)\<^sup>2)
[PROOF STEP]
by (simp add: sum_nonneg)


[STATEMENT]
lemma all_countings: "all_countings a b = (a + b) choose a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. all_countings a b = a + b choose a
[PROOF STEP]
unfolding all_countings_set
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {V \<in> Pow {0..<a + b}. card V = a} = a + b choose a
[PROOF STEP]
by (simp add: n_subsets)


[STATEMENT]
lemma DirProds_one:
  assumes "x \<in> carrier (DirProds G I)"
  shows "(\<forall>i \<in> I. x i = \<one>\<^bsub>G i\<^esub>) \<longleftrightarrow> x = \<one>\<^bsub>DirProds G I\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>i\<in>I. x i = \<one>\<^bsub>G i\<^esub>) = (x = \<one>\<^bsub>DirProds G I\<^esub>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier (DirProds G I)

goal (1 subgoal):
 1. (\<forall>i\<in>I. x i = \<one>\<^bsub>G i\<^esub>) = (x = \<one>\<^bsub>DirProds G I\<^esub>)
[PROOF STEP]
unfolding DirProds_def
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier \<lparr>carrier = Pi\<^sub>E I (carrier \<circ> G), monoid.mult = \<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i, one = \<lambda>i\<in>I. \<one>\<^bsub>G i\<^esub>\<rparr>

goal (1 subgoal):
 1. (\<forall>i\<in>I. x i = \<one>\<^bsub>G i\<^esub>) = (x = \<one>\<^bsub>\<lparr>carrier = Pi\<^sub>E I (carrier \<circ> G), monoid.mult = \<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i, one = \<lambda>i\<in>I. \<one>\<^bsub>G i\<^esub>\<rparr>\<^esub>)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma fps_mult_commute_lemma:
  fixes n :: nat
    and f :: "nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add"
  shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. f i (n - i)) = (\<Sum>i = 0..n. f (n - i) i)
[PROOF STEP]
by (rule sum.reindex_bij_witness[where i="(-) n" and j="(-) n"]) auto


[STATEMENT]
lemma inj_on_mult':
  assumes coprime: "coprime x (q::nat)"
  shows "inj_on (\<lambda> b. x*b mod q) ({..<q} - {0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>b. x * b mod q) ({..<q} - {0})
[PROOF STEP]
apply(auto simp add: inj_on_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa y. \<lbrakk>xa < q; 0 < xa; y < q; x * xa mod q = x * y mod q; 0 < y\<rbrakk> \<Longrightarrow> xa = y
[PROOF STEP]
using coprime
[PROOF STATE]
proof (prove)
using this:
coprime x q

goal (1 subgoal):
 1. \<And>xa y. \<lbrakk>xa < q; 0 < xa; y < q; x * xa mod q = x * y mod q; 0 < y\<rbrakk> \<Longrightarrow> xa = y
[PROOF STEP]
by(simp only: mult_inj_eq)