[STATEMENT]
lemma prim_pyth_tripleE:
  assumes "prim_pyth_triple x y z"
  obtains u v :: nat
  where "0 < v" and "v < u" and "coprime u v" and "\<not>(odd u \<and> odd v)" and "z = u\<^sup>2 + v\<^sup>2"
    and "x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2  \<or>  x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have *: "(int z) ^ 2 = (int x) ^ 2 + (int y) ^ 2" "coprime (int x) (int y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (int z)\<^sup>2 = (int x)\<^sup>2 + (int y)\<^sup>2 &&& coprime (int x) (int y)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prim_pyth_triple x y z

goal (1 subgoal):
 1. (int z)\<^sup>2 = (int x)\<^sup>2 + (int y)\<^sup>2 &&& coprime (int x) (int y)
[PROOF STEP]
by (auto simp flip: of_nat_power of_nat_add simp: prim_pyth_triple_def)
[PROOF STATE]
proof (state)
this:
(int z)\<^sup>2 = (int x)\<^sup>2 + (int y)\<^sup>2
coprime (int x) (int y)

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain u v
    where uv: "coprime u v" "\<not>(odd u \<and> odd v)"
              "int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2  \<or>  int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2 \<or> int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using primitive_pythagorean_tripleE_int[OF *]
[PROOF STATE]
proof (prove)
using this:
(\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2 \<or> int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2 \<or> int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
coprime u v
\<not> (odd u \<and> odd v)
int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2 \<or> int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define u' v' where "u' = nat \<bar>u\<bar>" and "v' = nat \<bar>v\<bar>"
[PROOF STATE]
proof (state)
this:
u' = nat \<bar>u\<bar>
v' = nat \<bar>v\<bar>

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have **: "a = 2 * u' * v'" if "int a = 2 * u * v" for a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = 2 * u' * v'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = 2 * u' * v'
[PROOF STEP]
from that
[PROOF STATE]
proof (chain)
picking this:
int a = 2 * u * v
[PROOF STEP]
have "nat \<bar>int a\<bar> = nat \<bar>2 * u * v\<bar>"
[PROOF STATE]
proof (prove)
using this:
int a = 2 * u * v

goal (1 subgoal):
 1. nat \<bar>int a\<bar> = nat \<bar>2 * u * v\<bar>
[PROOF STEP]
by (simp only: )
[PROOF STATE]
proof (state)
this:
nat \<bar>int a\<bar> = nat \<bar>2 * u * v\<bar>

goal (1 subgoal):
 1. a = 2 * u' * v'
[PROOF STEP]
thus "a = 2 * u' * v'"
[PROOF STATE]
proof (prove)
using this:
nat \<bar>int a\<bar> = nat \<bar>2 * u * v\<bar>

goal (1 subgoal):
 1. a = 2 * u' * v'
[PROOF STEP]
by (simp add: u'_def v'_def abs_mult nat_mult_distrib)
[PROOF STATE]
proof (state)
this:
a = 2 * u' * v'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int ?a = 2 * u * v \<Longrightarrow> ?a = 2 * u' * v'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have ***: "a = u' ^ 2 - v' ^ 2" "v' \<le> u'" if "int a = u ^ 2 - v ^ 2" for a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2 &&& v' \<le> u'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a = u'\<^sup>2 - v'\<^sup>2
 2. v' \<le> u'
[PROOF STEP]
have "v ^ 2 \<le> v ^ 2 + int a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v\<^sup>2 \<le> v\<^sup>2 + int a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v\<^sup>2 \<le> v\<^sup>2 + int a

goal (2 subgoals):
 1. a = u'\<^sup>2 - v'\<^sup>2
 2. v' \<le> u'
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v\<^sup>2 \<le> v\<^sup>2 + int a

goal (2 subgoals):
 1. a = u'\<^sup>2 - v'\<^sup>2
 2. v' \<le> u'
[PROOF STEP]
have "\<dots> = u ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v\<^sup>2 + int a = u\<^sup>2
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
int a = u\<^sup>2 - v\<^sup>2

goal (1 subgoal):
 1. v\<^sup>2 + int a = u\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v\<^sup>2 + int a = u\<^sup>2

goal (2 subgoals):
 1. a = u'\<^sup>2 - v'\<^sup>2
 2. v' \<le> u'
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
v\<^sup>2 \<le> u\<^sup>2
[PROOF STEP]
have "\<bar>v\<bar> \<le> \<bar>u\<bar>"
[PROOF STATE]
proof (prove)
using this:
v\<^sup>2 \<le> u\<^sup>2

goal (1 subgoal):
 1. \<bar>v\<bar> \<le> \<bar>u\<bar>
[PROOF STEP]
using abs_le_square_iff
[PROOF STATE]
proof (prove)
using this:
v\<^sup>2 \<le> u\<^sup>2
(\<bar>?x\<bar> \<le> \<bar>?y\<bar>) = (?x\<^sup>2 \<le> ?y\<^sup>2)

goal (1 subgoal):
 1. \<bar>v\<bar> \<le> \<bar>u\<bar>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<bar>v\<bar> \<le> \<bar>u\<bar>

goal (2 subgoals):
 1. a = u'\<^sup>2 - v'\<^sup>2
 2. v' \<le> u'
[PROOF STEP]
thus "v' \<le> u'"
[PROOF STATE]
proof (prove)
using this:
\<bar>v\<bar> \<le> \<bar>u\<bar>

goal (1 subgoal):
 1. v' \<le> u'
[PROOF STEP]
by (simp add: v'_def u'_def)
[PROOF STATE]
proof (state)
this:
v' \<le> u'

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
from that
[PROOF STATE]
proof (chain)
picking this:
int a = u\<^sup>2 - v\<^sup>2
[PROOF STEP]
have "u ^ 2 = v ^ 2 + int a"
[PROOF STATE]
proof (prove)
using this:
int a = u\<^sup>2 - v\<^sup>2

goal (1 subgoal):
 1. u\<^sup>2 = v\<^sup>2 + int a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
u\<^sup>2 = v\<^sup>2 + int a

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
hence "nat \<bar>u ^ 2\<bar> = nat \<bar>v ^ 2 + int a\<bar>"
[PROOF STATE]
proof (prove)
using this:
u\<^sup>2 = v\<^sup>2 + int a

goal (1 subgoal):
 1. nat \<bar>u\<^sup>2\<bar> = nat \<bar>v\<^sup>2 + int a\<bar>
[PROOF STEP]
by (simp only: )
[PROOF STATE]
proof (state)
this:
nat \<bar>u\<^sup>2\<bar> = nat \<bar>v\<^sup>2 + int a\<bar>

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nat \<bar>u\<^sup>2\<bar> = nat \<bar>v\<^sup>2 + int a\<bar>

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
have "nat \<bar>u ^ 2\<bar> = u' ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat \<bar>u\<^sup>2\<bar> = u'\<^sup>2
[PROOF STEP]
by (simp add: u'_def flip: nat_power_eq)
[PROOF STATE]
proof (state)
this:
nat \<bar>u\<^sup>2\<bar> = u'\<^sup>2

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nat \<bar>u\<^sup>2\<bar> = u'\<^sup>2

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
have "nat \<bar>v ^ 2 + int a\<bar> = v' ^ 2 + a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat \<bar>v\<^sup>2 + int a\<bar> = v'\<^sup>2 + a
[PROOF STEP]
by (simp add: nat_add_distrib v'_def flip: nat_power_eq)
[PROOF STATE]
proof (state)
this:
nat \<bar>v\<^sup>2 + int a\<bar> = v'\<^sup>2 + a

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
u'\<^sup>2 = v'\<^sup>2 + a
[PROOF STEP]
show "a = u' ^ 2 - v' ^ 2"
[PROOF STATE]
proof (prove)
using this:
u'\<^sup>2 = v'\<^sup>2 + a

goal (1 subgoal):
 1. a = u'\<^sup>2 - v'\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a = u'\<^sup>2 - v'\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int ?a = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> ?a = u'\<^sup>2 - v'\<^sup>2
int ?a = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> v' \<le> u'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have eq: "x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2  \<or>  x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'" and "v' \<le> u'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v' &&& v' \<le> u'
[PROOF STEP]
using uv(3) **[of x] **[of y] ***[of x] ***[of y]
[PROOF STATE]
proof (prove)
using this:
int x = 2 * u * v \<and> int y = u\<^sup>2 - v\<^sup>2 \<or> int x = u\<^sup>2 - v\<^sup>2 \<and> int y = 2 * u * v
int x = 2 * u * v \<Longrightarrow> x = 2 * u' * v'
int y = 2 * u * v \<Longrightarrow> y = 2 * u' * v'
int x = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> x = u'\<^sup>2 - v'\<^sup>2
int x = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> v' \<le> u'
int y = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> y = u'\<^sup>2 - v'\<^sup>2
int y = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> v' \<le> u'

goal (1 subgoal):
 1. x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v' &&& v' \<le> u'
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
v' \<le> u'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
v' \<le> u'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "coprime u' v'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime u' v'
[PROOF STEP]
using \<open>coprime u v\<close>
[PROOF STATE]
proof (prove)
using this:
coprime u v

goal (1 subgoal):
 1. coprime u' v'
[PROOF STEP]
by (auto simp: u'_def v'_def)
[PROOF STATE]
proof (state)
this:
coprime u' v'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
coprime u' v'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<not>(odd u' \<and> odd v')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (odd u' \<and> odd v')
[PROOF STEP]
using uv(2)
[PROOF STATE]
proof (prove)
using this:
\<not> (odd u \<and> odd v)

goal (1 subgoal):
 1. \<not> (odd u' \<and> odd v')
[PROOF STEP]
by (auto simp: u'_def v'_def)
[PROOF STATE]
proof (state)
this:
\<not> (odd u' \<and> odd v')

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<not> (odd u' \<and> odd v')

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "v' \<noteq> u'" "v' > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v' \<noteq> u' &&& 0 < v'
[PROOF STEP]
using \<open>coprime u' v'\<close> eq assms
[PROOF STATE]
proof (prove)
using this:
coprime u' v'
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
prim_pyth_triple x y z

goal (1 subgoal):
 1. v' \<noteq> u' &&& 0 < v'
[PROOF STEP]
by (auto simp: prim_pyth_triple_def)
[PROOF STATE]
proof (state)
this:
v' \<noteq> u'
0 < v'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
v' \<noteq> u'
0 < v'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
v' \<noteq> u'
0 < v'
[PROOF STEP]
have "v' < u'"
[PROOF STATE]
proof (prove)
using this:
v' \<noteq> u'
0 < v'

goal (1 subgoal):
 1. v' < u'
[PROOF STEP]
using \<open>v' \<le> u'\<close>
[PROOF STATE]
proof (prove)
using this:
v' \<noteq> u'
0 < v'
v' \<le> u'

goal (1 subgoal):
 1. v' < u'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v' < u'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
v' < u'

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "z = u'\<^sup>2 + v'\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prim_pyth_triple x y z
[PROOF STEP]
have "z ^ 2 = x ^ 2 + y ^ 2"
[PROOF STATE]
proof (prove)
using this:
prim_pyth_triple x y z

goal (1 subgoal):
 1. z\<^sup>2 = x\<^sup>2 + y\<^sup>2
[PROOF STEP]
by (simp add: prim_pyth_triple_def)
[PROOF STATE]
proof (state)
this:
z\<^sup>2 = x\<^sup>2 + y\<^sup>2

goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
z\<^sup>2 = x\<^sup>2 + y\<^sup>2

goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
have "\<dots> = (2 * u' * v') ^ 2 + (u' ^ 2 - v' ^ 2) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 + y\<^sup>2 = (2 * u' * v')\<^sup>2 + (u'\<^sup>2 - v'\<^sup>2)\<^sup>2
[PROOF STEP]
using eq
[PROOF STATE]
proof (prove)
using this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'

goal (1 subgoal):
 1. x\<^sup>2 + y\<^sup>2 = (2 * u' * v')\<^sup>2 + (u'\<^sup>2 - v'\<^sup>2)\<^sup>2
[PROOF STEP]
by (auto simp: add_ac)
[PROOF STATE]
proof (state)
this:
x\<^sup>2 + y\<^sup>2 = (2 * u' * v')\<^sup>2 + (u'\<^sup>2 - v'\<^sup>2)\<^sup>2

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

goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
have "\<dots> = (u' ^ 2 + v' ^ 2) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 * u' * v')\<^sup>2 + (u'\<^sup>2 - v'\<^sup>2)\<^sup>2 = (u'\<^sup>2 + v'\<^sup>2)\<^sup>2
[PROOF STEP]
by (intro prim_pyth_triple_aux) fact
[PROOF STATE]
proof (state)
this:
(2 * u' * v')\<^sup>2 + (u'\<^sup>2 - v'\<^sup>2)\<^sup>2 = (u'\<^sup>2 + v'\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
z\<^sup>2 = (u'\<^sup>2 + v'\<^sup>2)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
z\<^sup>2 = (u'\<^sup>2 + v'\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
z = u'\<^sup>2 + v'\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
z = u'\<^sup>2 + v'\<^sup>2

goal (1 subgoal):
 1. (\<And>v u. \<lbrakk>0 < v; v < u; coprime u v; \<not> (odd u \<and> odd v); z = u\<^sup>2 + v\<^sup>2; x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
v' \<le> u'
coprime u' v'
\<not> (odd u' \<and> odd v')
v' \<noteq> u'
0 < v'
v' < u'
z = u'\<^sup>2 + v'\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
v' \<le> u'
coprime u' v'
\<not> (odd u' \<and> odd v')
v' \<noteq> u'
0 < v'
v' < u'
z = u'\<^sup>2 + v'\<^sup>2

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that[of v' u']
[PROOF STATE]
proof (prove)
using this:
x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'
v' \<le> u'
coprime u' v'
\<not> (odd u' \<and> odd v')
v' \<noteq> u'
0 < v'
v' < u'
z = u'\<^sup>2 + v'\<^sup>2
\<lbrakk>0 < v'; v' < u'; coprime u' v'; \<not> (odd u' \<and> odd v'); z = u'\<^sup>2 + v'\<^sup>2; x = 2 * u' * v' \<and> y = u'\<^sup>2 - v'\<^sup>2 \<or> x = u'\<^sup>2 - v'\<^sup>2 \<and> y = 2 * u' * v'\<rbrakk> \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma affine_translation:
  "affine S \<longleftrightarrow> affine ((+) a ` S)" for a :: "'a::real_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine S = affine ((+) a ` S)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. affine S \<Longrightarrow> affine ((+) a ` S)
 2. affine ((+) a ` S) \<Longrightarrow> affine S
[PROOF STEP]
show "affine ((+) a ` S)" if "affine S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine ((+) a ` S)
[PROOF STEP]
using that translation_assoc [of "- a" a S]
[PROOF STATE]
proof (prove)
using this:
affine S
(+) (- a) ` (+) a ` S = (+) (a + - a) ` S

goal (1 subgoal):
 1. affine ((+) a ` S)
[PROOF STEP]
by (auto intro: affine_translation_aux [of "- a" "((+) a ` S)"])
[PROOF STATE]
proof (state)
this:
affine S \<Longrightarrow> affine ((+) a ` S)

goal (1 subgoal):
 1. affine ((+) a ` S) \<Longrightarrow> affine S
[PROOF STEP]
show "affine S" if "affine ((+) a ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine S
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
affine ((+) a ` S)

goal (1 subgoal):
 1. affine S
[PROOF STEP]
by (rule affine_translation_aux)
[PROOF STATE]
proof (state)
this:
affine ((+) a ` S) \<Longrightarrow> affine S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma currentLevelPrefixToLevel:
  shows "currentLevel (prefixToLevel level M) \<le> level"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. currentLevel (prefixToLevel level M) \<le> level
[PROOF STEP]
using currentLevelPrefixToLevel_aux[of "0" "level" "M"]
[PROOF STATE]
proof (prove)
using this:
0 \<le> level \<Longrightarrow> currentLevel (prefixToLevel_aux M level 0) \<le> level - 0

goal (1 subgoal):
 1. currentLevel (prefixToLevel level M) \<le> level
[PROOF STEP]
unfolding prefixToLevel_def
[PROOF STATE]
proof (prove)
using this:
0 \<le> level \<Longrightarrow> currentLevel (prefixToLevel_aux M level 0) \<le> level - 0

goal (1 subgoal):
 1. currentLevel (prefixToLevel_aux M level 0) \<le> level
[PROOF STEP]
by simp


[STATEMENT]
lemma agree_on_then_eq:
  assumes "agree_on G f\<^sub>1 f\<^sub>2" "Domain f\<^sub>1 = vertices G" "Domain f\<^sub>2 = vertices G"
  shows "f\<^sub>1 = f\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
agree_on G f\<^sub>1 f\<^sub>2
Domain f\<^sub>1 = vertices G
Domain f\<^sub>2 = vertices G
[PROOF STEP]
have agr:"\<And> v. v\<in>Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {v} = f\<^sub>2 `` {v}"
[PROOF STATE]
proof (prove)
using this:
agree_on G f\<^sub>1 f\<^sub>2
Domain f\<^sub>1 = vertices G
Domain f\<^sub>2 = vertices G

goal (1 subgoal):
 1. \<And>v. v \<in> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {v} = f\<^sub>2 `` {v}
[PROOF STEP]
unfolding agree_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>v\<in>vertices G. f\<^sub>1 `` {v} = f\<^sub>2 `` {v}
Domain f\<^sub>1 = vertices G
Domain f\<^sub>2 = vertices G

goal (1 subgoal):
 1. \<And>v. v \<in> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {v} = f\<^sub>2 `` {v}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?v \<in> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = f\<^sub>2 `` {?v}

goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
have agr2:"\<And> v. v\<notin>Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {v} = {}"
            "\<And> v. v\<notin>Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {v} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>v. v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {v} = {}) &&& (\<And>v. v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {v} = {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = {}
?v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {?v} = {}

goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
with agr agr2 assms
[PROOF STATE]
proof (chain)
picking this:
?v \<in> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = f\<^sub>2 `` {?v}
?v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = {}
?v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {?v} = {}
agree_on G f\<^sub>1 f\<^sub>2
Domain f\<^sub>1 = vertices G
Domain f\<^sub>2 = vertices G
?v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = {}
?v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {?v} = {}
[PROOF STEP]
have "\<And> v. f\<^sub>1 `` {v} = f\<^sub>2 `` {v}"
[PROOF STATE]
proof (prove)
using this:
?v \<in> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = f\<^sub>2 `` {?v}
?v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = {}
?v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {?v} = {}
agree_on G f\<^sub>1 f\<^sub>2
Domain f\<^sub>1 = vertices G
Domain f\<^sub>2 = vertices G
?v \<notin> Domain f\<^sub>1 \<Longrightarrow> f\<^sub>1 `` {?v} = {}
?v \<notin> Domain f\<^sub>2 \<Longrightarrow> f\<^sub>2 `` {?v} = {}

goal (1 subgoal):
 1. \<And>v. f\<^sub>1 `` {v} = f\<^sub>2 `` {v}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f\<^sub>1 `` {?v} = f\<^sub>2 `` {?v}

goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f\<^sub>1 `` {?v} = f\<^sub>2 `` {?v}

goal (1 subgoal):
 1. f\<^sub>1 = f\<^sub>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f\<^sub>1 = f\<^sub>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_one_time_pad:
  assumes coprime: "coprime x q"
  shows "map_spmf (\<lambda> b. x*b mod q) (sample_uniform q) = (sample_uniform q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>b. x * b mod q) (sample_uniform q) = sample_uniform q
[PROOF STEP]
using inj_on_mult surj_on_mult one_time_pad coprime
[PROOF STATE]
proof (prove)
using this:
coprime ?x ?q \<Longrightarrow> inj_on (\<lambda>b. ?x * b mod ?q) {..<?q}
\<lbrakk>coprime ?x ?q; inj_on (\<lambda>b. ?x * b mod ?q) {..<?q}\<rbrakk> \<Longrightarrow> (\<lambda>b. ?x * b mod ?q) ` {..<?q} = {..<?q}
\<lbrakk>inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}\<rbrakk> \<Longrightarrow> map_spmf ?f (sample_uniform ?q) = sample_uniform ?q
coprime x q

goal (1 subgoal):
 1. map_spmf (\<lambda>b. x * b mod q) (sample_uniform q) = sample_uniform q
[PROOF STEP]
by simp


[STATEMENT]
lemma ideal_generated_eq_right_ideal: "ideal_generated A = right_ideal_generated A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ideal_generated A = right_ideal_generated A
[PROOF STEP]
unfolding ideal_generated_def ideal_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> {I. (left_ideal I \<and> right_ideal I) \<and> A \<subseteq> I} = right_ideal_generated A
[PROOF STEP]
by (metis (no_types, lifting) Collect_cong left_ideal_eq_right_ideal right_ideal_generated_def)


[STATEMENT]
lemma norm_triangle_ineq2: "norm a - norm b \<le> norm (a - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm a - norm b \<le> norm (a - b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm a - norm b \<le> norm (a - b)
[PROOF STEP]
have "norm (a - b + b) \<le> norm (a - b) + norm b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (a - b + b) \<le> norm (a - b) + norm b
[PROOF STEP]
by (rule norm_triangle_ineq)
[PROOF STATE]
proof (state)
this:
norm (a - b + b) \<le> norm (a - b) + norm b

goal (1 subgoal):
 1. norm a - norm b \<le> norm (a - b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (a - b + b) \<le> norm (a - b) + norm b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (a - b + b) \<le> norm (a - b) + norm b

goal (1 subgoal):
 1. norm a - norm b \<le> norm (a - b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm a - norm b \<le> norm (a - b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_on_cases:
  "closed s \<Longrightarrow> closed t \<Longrightarrow> continuous_on s f \<Longrightarrow> continuous_on t g \<Longrightarrow>
    \<forall>x. (x\<in>s \<and> \<not> P x) \<or> (x \<in> t \<and> P x) \<longrightarrow> f x = g x \<Longrightarrow>
    continuous_on (s \<union> t) (\<lambda>x. if P x then f x else g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed s; closed t; continuous_on s f; continuous_on t g; \<forall>x. x \<in> s \<and> \<not> P x \<or> x \<in> t \<and> P x \<longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> continuous_on (s \<union> t) (\<lambda>x. if P x then f x else g x)
[PROOF STEP]
by (rule continuous_on_If) auto


[STATEMENT]
lemma filter_shuffles:
  "filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)
[PROOF STEP]
have *: "filter P ` (#) x ` A = (if P x then (#) x ` filter P ` A else filter P ` A)" for x A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter P ` (#) x ` A = (if P x then (#) x ` filter P ` A else filter P ` A)
[PROOF STEP]
by (auto simp: image_image)
[PROOF STATE]
proof (state)
this:
filter P ` (#) ?x ` ?A = (if P ?x then (#) ?x ` filter P ` ?A else filter P ` ?A)

goal (1 subgoal):
 1. filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)
[PROOF STEP]
by (induction xs ys rule: shuffles.induct)
     (simp_all split: if_splits add: image_Un * Un_absorb1 Un_absorb2
           Cons_shuffles_subset1 Cons_shuffles_subset2)
[PROOF STATE]
proof (state)
this:
filter P ` shuffles xs ys = shuffles (filter P xs) (filter P ys)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma semantics_in_vertices:
  assumes "graph A" "(a,b) \<in> :A:\<lbrakk>e\<rbrakk>"
  shows "a \<in> vertices A" "b \<in> vertices A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> vertices A &&& b \<in> vertices A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
graph A
(a, b) \<in> :A:\<lbrakk>e\<rbrakk>

goal (1 subgoal):
 1. a \<in> vertices A &&& b \<in> vertices A
[PROOF STEP]
by(induct e arbitrary:a b,auto simp:getRel_def)


[STATEMENT]
lemma i4: assumes "inner x x = 0"
shows "x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = 0
[PROOF STEP]
proof (unfold vec_eq_iff, clarify, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
have "0 = real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inner x x = (0::'a)

goal (1 subgoal):
 1. 0 = real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i))
[PROOF STEP]
by (simp add: inner_vec_def)
[PROOF STATE]
proof (state)
this:
0 = real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i))

goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 = real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i))

goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
have "... = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i)) = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))
[PROOF STEP]
using real_sum
[PROOF STATE]
proof (prove)
using this:
real_of (sum ?f ?A) = (\<Sum>i\<in>?A. real_of (?f i))

goal (1 subgoal):
 1. real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i)) = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real_of (\<Sum>i\<in>UNIV. inner_field (x $ i) (x $ i)) = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))

goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))
[PROOF STEP]
have "0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))"
[PROOF STATE]
proof (prove)
using this:
0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))

goal (1 subgoal):
 1. 0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))

goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
hence "real_of (inner_field (x $ a) (x $ a)) = 0"
[PROOF STATE]
proof (prove)
using this:
0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))

goal (1 subgoal):
 1. real_of (inner_field (x $ a) (x $ a)) = 0
[PROOF STEP]
using sum_0_all F.inner_ge_zero
[PROOF STATE]
proof (prove)
using this:
0 = (\<Sum>i\<in>UNIV. real_of (inner_field (x $ i) (x $ i)))
\<lbrakk>\<forall>a\<in>?A. 0 \<le> ?f a; sum ?f ?A = 0; finite ?A\<rbrakk> \<Longrightarrow> \<forall>a\<in>?A. ?f a = 0
0 \<le> real_of (inner_field ?x ?x)

goal (1 subgoal):
 1. real_of (inner_field (x $ a) (x $ a)) = 0
[PROOF STEP]
by (metis (no_types, lifting) finite iso_tuple_UNIV_I)
[PROOF STATE]
proof (state)
this:
real_of (inner_field (x $ a) (x $ a)) = 0

goal (1 subgoal):
 1. \<And>i. x $ i = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of (inner_field (x $ a) (x $ a)) = 0
[PROOF STEP]
show "x $ a = 0"
[PROOF STATE]
proof (prove)
using this:
real_of (inner_field (x $ a) (x $ a)) = 0

goal (1 subgoal):
 1. x $ a = (0::'a)
[PROOF STEP]
by (metis F.inner_eq_zero_iff F.inner_gt_zero_iff real_0)
[PROOF STATE]
proof (state)
this:
x $ a = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma insertion_isovarspars_free :
  "insertion (nth_default 0 (list_update L var x)) (isolate_variable_sparse (p::real mpoly) var (i::nat))
  =insertion (nth_default 0 (list_update L var y)) (isolate_variable_sparse (p::real mpoly) var (i::nat))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)
[PROOF STEP]
have h : "var \<notin> vars(isolate_variable_sparse (p::real mpoly) var (i::nat))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. var \<notin> vars (isolate_variable_sparse p var i)
[PROOF STEP]
by (simp add: not_in_isovarspar)
[PROOF STATE]
proof (state)
this:
var \<notin> vars (isolate_variable_sparse p var i)

goal (1 subgoal):
 1. insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
var \<notin> vars (isolate_variable_sparse p var i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
var \<notin> vars (isolate_variable_sparse p var i)

goal (1 subgoal):
 1. insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)
[PROOF STEP]
using not_contains_insertion
[PROOF STATE]
proof (prove)
using this:
var \<notin> vars (isolate_variable_sparse p var i)
\<lbrakk>?var \<notin> vars ?p; insertion (nth_default 0 (?L[?var := ?x])) ?p = ?val\<rbrakk> \<Longrightarrow> insertion (nth_default 0 (?L[?var := ?y])) ?p = ?val

goal (1 subgoal):
 1. insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
insertion (nth_default 0 (L[var := x])) (isolate_variable_sparse p var i) = insertion (nth_default 0 (L[var := y])) (isolate_variable_sparse p var i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma InfCard_csucc: "InfCard \<kappa> \<Longrightarrow> InfCard (csucc \<kappa>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. InfCard \<kappa> \<Longrightarrow> InfCard (csucc \<kappa>)
[PROOF STEP]
using InfCard_def le_csucc
[PROOF STATE]
proof (prove)
using this:
InfCard ?\<kappa> \<equiv> Card ?\<kappa> \<and> \<omega> \<le> ?\<kappa>
Card ?\<kappa> \<Longrightarrow> ?\<kappa> \<le> csucc ?\<kappa>

goal (1 subgoal):
 1. InfCard \<kappa> \<Longrightarrow> InfCard (csucc \<kappa>)
[PROOF STEP]
by auto


[STATEMENT]
lemma primes_omega_0 [simp]: "primes_omega 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primes_omega 0 = 0
[PROOF STEP]
by (simp add: primes_omega_def)


[STATEMENT]
lemma fps_power_eqD:
  fixes f g :: "'a :: {idom,semiring_char_0} fps"
  assumes "f ^ m = g ^ m" "f $ 0 = g $ 0" "f $ 0 \<noteq> 0" "m > 0"
  shows   "f = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = g
[PROOF STEP]
by (rule fps_power_eqD'[of f m g]) (insert assms, simp_all)


[STATEMENT]
theorem wf_while_option_Some:
  assumes "wf {(t, s). (P s \<and> b s) \<and> t = c s}"
  and "\<And>s. P s \<Longrightarrow> b s \<Longrightarrow> P(c s)" and "P s"
  shows "\<exists>t. while_option b c s = Some t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>t. while_option b c s = Some t
[PROOF STEP]
using assms(1,3)
[PROOF STATE]
proof (prove)
using this:
wf {(t, s). (P s \<and> b s) \<and> t = c s}
P s

goal (1 subgoal):
 1. \<exists>t. while_option b c s = Some t
[PROOF STEP]
proof (induction s)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>(y, x) \<in> {(t, s). (P s \<and> b s) \<and> t = c s}; P y\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c y = Some t; P x\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c x = Some t
[PROOF STEP]
case less
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?y, x_) \<in> {(t, s). (P s \<and> b s) \<and> t = c s}; P ?y\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c ?y = Some t
P x_

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>(y, x) \<in> {(t, s). (P s \<and> b s) \<and> t = c s}; P y\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c y = Some t; P x\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c x = Some t
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?y, x_) \<in> {(t, s). (P s \<and> b s) \<and> t = c s}; P ?y\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c ?y = Some t
P x_

goal (1 subgoal):
 1. \<exists>t. while_option b c x_ = Some t
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(?y, x_) \<in> {(t, s). (P s \<and> b s) \<and> t = c s}; P ?y\<rbrakk> \<Longrightarrow> \<exists>t. while_option b c ?y = Some t
P x_
\<lbrakk>P ?s; b ?s\<rbrakk> \<Longrightarrow> P (c ?s)

goal (1 subgoal):
 1. \<exists>t. while_option b c x_ = Some t
[PROOF STEP]
by (subst while_option_unfold) simp
[PROOF STATE]
proof (state)
this:
\<exists>t. while_option b c x_ = Some t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma order_irr: "Coset.order (mult_of R) = CARD('a)^degree f - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order (mult_of R) = CARD('a) ^ degree f - 1
[PROOF STEP]
by (simp add: card_Diff_singleton Coset.order_def carrier_mult_of R_def)


[STATEMENT]
lemma meldUniq_mset: "\<lbrakk>queue_invar q; queue_invar q'\<rbrakk> \<Longrightarrow>
  queue_to_multiset (meldUniq q q') =
  queue_to_multiset q + queue_to_multiset q'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>queue_invar q; queue_invar q'\<rbrakk> \<Longrightarrow> queue_to_multiset (meldUniq q q') = queue_to_multiset q + queue_to_multiset q'
[PROOF STEP]
by(induct q q' rule: meldUniq.induct)
  (auto simp: ins_mset link_tree_invar invar_meldUniq union_ac)


[STATEMENT]
lemma nrows_diagonal_to_Smith[simp]: "nrows (diagonal_to_Smith A bezout) = nrows A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nrows (diagonal_to_Smith A bezout) = nrows A
[PROOF STEP]
unfolding diagonal_to_Smith_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nrows (diagonal_to_Smith_aux A [0..<min (nrows A) (ncols A) - 1] bezout) = nrows A
[PROOF STEP]
by auto


[STATEMENT]
lemma nat_diff_right_cancel_eq2: "\<lbrakk> m - k = n - (k::nat); k < n \<rbrakk> \<Longrightarrow> m = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m - k = n - k; k < n\<rbrakk> \<Longrightarrow> m = n
[PROOF STEP]
by simp


[STATEMENT]
lemma beukers_nn_integral1_swap:
  "beukers_nn_integral1 r s = beukers_nn_integral1 s r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. beukers_nn_integral1 r s = beukers_nn_integral1 s r
[PROOF STEP]
unfolding beukers_nn_integral1_def lborel_prod [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+x\<in>{0<..<1} \<times> {0<..<1}. (case x of (x, y) \<Rightarrow> ennreal (- ln (x * y) / (1 - x * y) * x ^ r * y ^ s))\<partial>lborel \<Otimes>\<^sub>M lborel = \<integral>\<^sup>+x\<in>{0<..<1} \<times> {0<..<1}. (case x of (x, y) \<Rightarrow> ennreal (- ln (x * y) / (1 - x * y) * x ^ s * y ^ r))\<partial>lborel \<Otimes>\<^sub>M lborel
[PROOF STEP]
by (subst lborel_pair.nn_integral_swap, simp)
     (intro nn_integral_cong, auto simp: indicator_def algebra_simps split: if_splits)


[STATEMENT]
lemma bbw_oa_dist: "(x AND y) OR z = (x OR z) AND (y OR z)"
  for x y z :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x AND y OR z = (x OR z) AND (y OR z)
[PROOF STEP]
by (auto simp add: bin_eq_iff bin_nth_ops)


[STATEMENT]
lemma pseudo_rationalizable_on_def2:
  "pseudo_rationalizable_on A Rs f
     \<longleftrightarrow> (\<forall>r\<in>Rs. Linear_order r) \<and> (\<forall>B\<subseteq>A. f B = (\<Union>r\<in>Rs. set_option (MaxR.MaxR_opt r B)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pseudo_rationalizable_on A Rs f = ((\<forall>r\<in>Rs. Linear_order r) \<and> (\<forall>B\<subseteq>A. f B = (\<Union>r\<in>Rs. set_option (MaxR.MaxR_opt r B))))
[PROOF STEP]
unfolding %invisible pseudo_rationalizable_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>r\<in>Rs. Linear_order r) \<and> (\<forall>B\<subseteq>A. f B = (\<Union>r\<in>Rs. greatest r (B \<inter> Field r)))) = ((\<forall>r\<in>Rs. Linear_order r) \<and> (\<forall>B\<subseteq>A. f B = (\<Union>r\<in>Rs. set_option (MaxR.MaxR_opt r B))))
[PROOF STEP]
by (metis (no_types, lifting) MaxR.greatest MaxR.intro SUP_cong)


[STATEMENT]
lemma (in comm_ring_hom) resultant_map_poly: "degree (map_poly hom p) = degree p \<Longrightarrow>
  degree (map_poly hom q) = degree q \<Longrightarrow> resultant (map_poly hom p) (map_poly hom q) = hom (resultant p q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>degree (map_poly hom p) = degree p; degree (map_poly hom q) = degree q\<rbrakk> \<Longrightarrow> resultant (map_poly hom p) (map_poly hom q) = hom (resultant p q)
[PROOF STEP]
unfolding resultant_def sylvester_mat_def sylvester_mat_sub_def hom_det[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>degree (map_poly hom p) = degree p; degree (map_poly hom q) = degree q\<rbrakk> \<Longrightarrow> det (mat (degree (map_poly hom p) + degree (map_poly hom q)) (degree (map_poly hom p) + degree (map_poly hom q)) (\<lambda>(i, j). if i < degree (map_poly hom q) then if i \<le> j \<and> j - i \<le> degree (map_poly hom p) then coeff (map_poly hom p) (degree (map_poly hom p) + i - j) else (0::'b) else if i - degree (map_poly hom q) \<le> j \<and> j \<le> i then coeff (map_poly hom q) (i - j) else (0::'b))) = det (mat\<^sub>h (mat (degree p + degree q) (degree p + degree q) (\<lambda>(i, j). if i < degree q then if i \<le> j \<and> j - i \<le> degree p then coeff p (degree p + i - j) else (0::'a) else if i - degree q \<le> j \<and> j \<le> i then coeff q (i - j) else (0::'a))))
[PROOF STEP]
by (rule arg_cong[of _ _ det], auto)


[STATEMENT]
lemma l2wi_negation_type_union: "wordinterval_to_set (l2wi_negation_type_union l) =
                      (\<Union> (i,j) \<in> set (getPos l). {i .. j}) \<union> (\<Union> (i,j) \<in> set (getNeg l). - {i .. j})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wordinterval_to_set (l2wi_negation_type_union l) = (\<Union>(i, j)\<in>set (getPos l). {i..j}) \<union> (\<Union>(i, j)\<in>set (getNeg l). - {i..j})
[PROOF STEP]
apply(simp add: l2wi)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wordinterval_to_set (l2wi_negation_type_union l) = (\<Union>x\<in>set (getPos l). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg l). case x of (i, j) \<Rightarrow> - {i..j})
[PROOF STEP]
apply(induction l rule: l2wi_negation_type_union.induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. wordinterval_to_set (l2wi_negation_type_union []) = (\<Union>x\<in>set (getPos []). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg []). case x of (i, j) \<Rightarrow> - {i..j})
 2. \<And>s e ls. wordinterval_to_set (l2wi_negation_type_union ls) = (\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j}) \<Longrightarrow> wordinterval_to_set (l2wi_negation_type_union (Pos (s, e) # ls)) = (\<Union>x\<in>set (getPos (Pos (s, e) # ls)). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg (Pos (s, e) # ls)). case x of (i, j) \<Rightarrow> - {i..j})
 3. \<And>s e ls. wordinterval_to_set (l2wi_negation_type_union ls) = (\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j}) \<Longrightarrow> wordinterval_to_set (l2wi_negation_type_union (Neg (s, e) # ls)) = (\<Union>x\<in>set (getPos (Neg (s, e) # ls)). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg (Neg (s, e) # ls)). case x of (i, j) \<Rightarrow> - {i..j})
[PROOF STEP]
apply(simp_all)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>s e ls. wordinterval_to_set (l2wi_negation_type_union ls) = (\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j}) \<Longrightarrow> {s..e} \<union> ((\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j})) = {s..e} \<union> (\<Union>(x, y)\<in>set (getPos ls). {x..y}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j})
 2. \<And>s e ls. wordinterval_to_set (l2wi_negation_type_union ls) = (\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j}) \<Longrightarrow> UNIV - {s..e} \<union> ((\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (\<Union>x\<in>set (getNeg ls). case x of (i, j) \<Rightarrow> - {i..j})) = (\<Union>x\<in>set (getPos ls). case x of (i, j) \<Rightarrow> {i..j}) \<union> (- {s..e} \<union> (\<Union>(i, j)\<in>set (getNeg ls). - {i..j}))
[PROOF STEP]
apply fast+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem (in ergodic_pmpt) birkhoff_theorem_L1:
  fixes f::"'a \<Rightarrow> real"
  assumes [measurable]: "integrable M f"
  shows "(\<lambda>n. \<integral>\<^sup>+x. norm(birkhoff_sum f n x / n - (\<integral> x. f x \<partial>M)) \<partial>M) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
fix n::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
have "AE x in M. real_cond_exp M Invariants f x = (\<integral> x. f x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. real_cond_exp M Invariants f x = expectation f
[PROOF STEP]
using Invariants_cond_exp_is_integral[OF assms]
[PROOF STATE]
proof (prove)
using this:
AE x in M. real_cond_exp M Invariants f x = expectation f

goal (1 subgoal):
 1. AE x in M. real_cond_exp M Invariants f x = expectation f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
AE x in M. real_cond_exp M Invariants f x = expectation f

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
AE x in M. real_cond_exp M Invariants f x = expectation f
[PROOF STEP]
have *: "AE x in M. norm(birkhoff_sum f n x / n - real_cond_exp M Invariants f x)
                = norm(birkhoff_sum f n x / n - (\<integral> x. f x \<partial>M))"
[PROOF STATE]
proof (prove)
using this:
AE x in M. real_cond_exp M Invariants f x = expectation f

goal (1 subgoal):
 1. AE x in M. norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x) = norm (birkhoff_sum f n x / real n - expectation f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
AE x in M. norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x) = norm (birkhoff_sum f n x / real n - expectation f)

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
have "(\<integral>\<^sup>+x. norm(birkhoff_sum f n x / n - real_cond_exp M Invariants f x) \<partial>M)
                = (\<integral>\<^sup>+x. norm(birkhoff_sum f n x / n - (\<integral> x. f x \<partial>M)) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M
[PROOF STEP]
apply (rule nn_integral_cong_AE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) = ennreal (norm (birkhoff_sum f n x / real n - expectation f))
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
AE x in M. norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x) = norm (birkhoff_sum f n x / real n - expectation f)

goal (1 subgoal):
 1. AE x in M. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) = ennreal (norm (birkhoff_sum f n x / real n - expectation f))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - expectation f)) \<partial>M

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - expectation f)) \<partial>M

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
have "(\<lambda>n. \<integral>\<^sup>+x. norm(birkhoff_sum f n x / n - real_cond_exp M Invariants f x) \<partial>M) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
using birkhoff_theorem_L1_nonergodic[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - expectation f)) \<partial>M
(\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - real_cond_exp M Invariants f x)) \<partial>M = \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f ?n14 x / real ?n14 - expectation f)) \<partial>M
(\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - real_cond_exp M Invariants f x)) \<partial>M) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<integral>\<^sup>+ x. ennreal (norm (birkhoff_sum f n x / real n - expectation f)) \<partial>M) \<longlonglongrightarrow> 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma not_coprime_iff_common_factor:
    "\<not> coprime p q \<longleftrightarrow> (\<exists>r. r dvd p \<and> r dvd q \<and> \<not> r dvd 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> coprime p q) = (\<exists>r. r dvd p \<and> r dvd q \<and> \<not> r dvd (1::'a))
[PROOF STEP]
by (auto simp add: coprime_def')


[STATEMENT]
lemma fset_equiv: "(f1 = f2) = (fset f1 = fset f2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f1 = f2) = (fset f1 = fset f2)
[PROOF STEP]
by (simp add: fset_inject)


[STATEMENT]
lemma trivial_empty_or_singleton: "trivial X = (X = {} \<or> X = {the_elem X})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trivial X = (X = {} \<or> X = {the_elem X})
[PROOF STEP]
by (metis subset_singletonD trivial_def trivial_empty trivial_singleton)


[STATEMENT]
lemma downset_set_idem [simp]: "\<Down> \<circ> \<Down> = \<Down>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Down> \<circ> \<Down> = \<Down>
[PROOF STEP]
unfolding fun_eq_iff downset_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. ((\<lambda>X. {y. Bex X ((\<le>) y)}) \<circ> (\<lambda>X. {y. Bex X ((\<le>) y)})) x = {y. Bex x ((\<le>) y)}
[PROOF STEP]
using order_trans
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<le> ?y; ?y \<le> ?z\<rbrakk> \<Longrightarrow> ?x \<le> ?z

goal (1 subgoal):
 1. \<forall>x. ((\<lambda>X. {y. Bex X ((\<le>) y)}) \<circ> (\<lambda>X. {y. Bex X ((\<le>) y)})) x = {y. Bex x ((\<le>) y)}
[PROOF STEP]
by auto


[STATEMENT]
lemma mod_eq_Suc_0_conv: "Suc 0 < k \<Longrightarrow> ((x + k - Suc 0) mod k = 0) = (x mod k = Suc 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc 0 < k \<Longrightarrow> ((x + k - Suc 0) mod k = 0) = (x mod k = Suc 0)
[PROOF STEP]
apply (simp only: mod_pred)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc 0 < k \<Longrightarrow> ((if (x + k) mod k = 0 then k - Suc 0 else (x + k) mod k - Suc 0) = 0) = (x mod k = Suc 0)
[PROOF STEP]
apply (case_tac "x mod k = Suc 0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Suc 0 < k; x mod k = Suc 0\<rbrakk> \<Longrightarrow> ((if (x + k) mod k = 0 then k - Suc 0 else (x + k) mod k - Suc 0) = 0) = (x mod k = Suc 0)
 2. \<lbrakk>Suc 0 < k; x mod k \<noteq> Suc 0\<rbrakk> \<Longrightarrow> ((if (x + k) mod k = 0 then k - Suc 0 else (x + k) mod k - Suc 0) = 0) = (x mod k = Suc 0)
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma wf_trm_subst_range_iff: "(\<forall>x. wf\<^sub>t\<^sub>r\<^sub>m (\<theta> x)) \<longleftrightarrow> wf\<^sub>t\<^sub>r\<^sub>m\<^sub>s (subst_range \<theta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. wf\<^sub>t\<^sub>r\<^sub>m (\<theta> x)) = wf\<^sub>t\<^sub>r\<^sub>m\<^sub>s (subst_range \<theta>)
[PROOF STEP]
by force


[STATEMENT]
lemma AE_all_imp_countable:
  assumes "countable {x. Q x}"
  shows "(AE x in M. \<forall>y. Q y \<longrightarrow> P x y) = (\<forall>y. Q y \<longrightarrow> (AE x in M. P x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (AE x in M. \<forall>y. Q y \<longrightarrow> P x y) = (\<forall>y. Q y \<longrightarrow> (AE x in M. P x y))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
countable {x. Q x}

goal (1 subgoal):
 1. (AE x in M. \<forall>y. Q y \<longrightarrow> P x y) = (\<forall>y. Q y \<longrightarrow> (AE x in M. P x y))
[PROOF STEP]
by (auto dest: AE_ball_countable)


[STATEMENT]
lemma subst\<^sub>0_pretty:
 "subst\<^sub>0 (Eq r (c#cs)) (Less s (d#ds)) = Less (s - (r*d)/c) (ds - (d/c) *\<^sub>s cs)"
 "subst\<^sub>0 (Eq r (c#cs)) (Eq s (d#ds)) = Eq (s - (r*d)/c) (ds - (d/c) *\<^sub>s cs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subst\<^sub>0 (Eq r (c # cs)) (Less s (d # ds)) = Less (s - r * d / c) (ds - (d / c) *\<^sub>s cs) &&& subst\<^sub>0 (Eq r (c # cs)) (Eq s (d # ds)) = Eq (s - r * d / c) (ds - (d / c) *\<^sub>s cs)
[PROOF STEP]
by auto


[STATEMENT]
lemma sin_int_2pin [simp]: "sin ((2 * pi) * of_int n) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (2 * pi * real_of_int n) = 0
[PROOF STEP]
by (metis Ints_of_int sin_integer_2pi)