[STATEMENT]
lemma (in sigma_finite_measure) approx_PInf_emeasure_with_finite:
  fixes C::real
  assumes W_meas: "W \<in> sets M"
      and W_inf: "emeasure M W = \<infinity>"
  obtains Z where "Z \<in> sets M" "Z \<subseteq> W" "emeasure M Z < \<infinity>" "emeasure M Z > C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain A :: "nat \<Rightarrow> 'a set"
    where A: "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "incseq A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>A. \<lbrakk>range A \<subseteq> sets M; \<Union> (range A) = space M; \<And>i. emeasure M (A i) \<noteq> \<infinity>; incseq A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using sigma_finite_incseq
[PROOF STATE]
proof (prove)
using this:
(\<And>A. \<lbrakk>range A \<subseteq> sets M; \<Union> (range A) = space M; \<And>i. emeasure M (A i) \<noteq> \<infinity>; incseq A\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>A. \<lbrakk>range A \<subseteq> sets M; \<Union> (range A) = space M; \<And>i. emeasure M (A i) \<noteq> \<infinity>; incseq A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
range A \<subseteq> sets M
\<Union> (range A) = space M
emeasure M (A ?i) \<noteq> \<infinity>
incseq A

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define B where "B = (\<lambda>i. W \<inter> A i)"
[PROOF STATE]
proof (state)
this:
B = (\<lambda>i. W \<inter> A i)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have B_meas: "\<And>i. B i \<in> sets M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. B i \<in> sets M
[PROOF STEP]
using W_meas \<open>range A \<subseteq> sets M\<close> B_def
[PROOF STATE]
proof (prove)
using this:
W \<in> sets M
range A \<subseteq> sets M
B = (\<lambda>i. W \<inter> A i)

goal (1 subgoal):
 1. \<And>i. B i \<in> sets M
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
B ?i \<in> sets M

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have b: "\<And>i. B i \<subseteq> W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. B i \<subseteq> W
[PROOF STEP]
using B_def
[PROOF STATE]
proof (prove)
using this:
B = (\<lambda>i. W \<inter> A i)

goal (1 subgoal):
 1. \<And>i. B i \<subseteq> W
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
B ?i \<subseteq> W

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
B ?i \<subseteq> W

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "emeasure M (B i) \<le> emeasure M (A i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure M (B i) \<le> emeasure M (A i)
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
range A \<subseteq> sets M
\<Union> (range A) = space M
emeasure M (A ?i) \<noteq> \<infinity>
incseq A

goal (1 subgoal):
 1. emeasure M (B i) \<le> emeasure M (A i)
[PROOF STEP]
by (intro emeasure_mono) (auto simp: B_def)
[PROOF STATE]
proof (state)
this:
emeasure M (B i) \<le> emeasure M (A i)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure M (B i) \<le> emeasure M (A i)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "emeasure M (A i) < \<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure M (A i) < \<infinity>
[PROOF STEP]
using \<open>\<And>i. emeasure M (A i) \<noteq> \<infinity>\<close>
[PROOF STATE]
proof (prove)
using this:
emeasure M (A ?i) \<noteq> \<infinity>

goal (1 subgoal):
 1. emeasure M (A i) < \<infinity>
[PROOF STEP]
by (simp add: less_top)
[PROOF STATE]
proof (state)
this:
emeasure M (A i) < \<infinity>

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
emeasure M (B i) < \<infinity>
[PROOF STEP]
have "emeasure M (B i) < \<infinity>"
[PROOF STATE]
proof (prove)
using this:
emeasure M (B i) < \<infinity>

goal (1 subgoal):
 1. emeasure M (B i) < \<infinity>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
emeasure M (B i) < \<infinity>

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
emeasure M (B ?i2) < \<infinity>

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
note c = this
[PROOF STATE]
proof (state)
this:
emeasure M (B ?i2) < \<infinity>

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "W = (\<Union>i. B i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. W = \<Union> (range B)
[PROOF STEP]
using B_def \<open>(\<Union>i. A i) = space M\<close> W_meas
[PROOF STATE]
proof (prove)
using this:
B = (\<lambda>i. W \<inter> A i)
\<Union> (range A) = space M
W \<in> sets M

goal (1 subgoal):
 1. W = \<Union> (range B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
W = \<Union> (range B)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
W = \<Union> (range B)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "incseq B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. incseq B
[PROOF STEP]
using B_def \<open>incseq A\<close>
[PROOF STATE]
proof (prove)
using this:
B = (\<lambda>i. W \<inter> A i)
incseq A

goal (1 subgoal):
 1. incseq B
[PROOF STEP]
by (simp add: incseq_def subset_eq)
[PROOF STATE]
proof (state)
this:
incseq B

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
W = \<Union> (range B)
incseq B
[PROOF STEP]
have "(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W"
[PROOF STATE]
proof (prove)
using this:
W = \<Union> (range B)
incseq B

goal (1 subgoal):
 1. (\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W
[PROOF STEP]
using W_meas B_meas
[PROOF STATE]
proof (prove)
using this:
W = \<Union> (range B)
incseq B
W \<in> sets M
B ?i \<in> sets M

goal (1 subgoal):
 1. (\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W
[PROOF STEP]
by (simp add: B_meas Lim_emeasure_incseq image_subset_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W
[PROOF STEP]
have "(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> \<infinity>"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W

goal (1 subgoal):
 1. (\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
using W_inf
[PROOF STATE]
proof (prove)
using this:
(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> emeasure M W
emeasure M W = \<infinity>

goal (1 subgoal):
 1. (\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>i. emeasure M (B i)) \<longlonglongrightarrow> \<infinity>

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from order_tendstoD(1)[OF this, of C]
[PROOF STATE]
proof (chain)
picking this:
ennreal C < \<infinity> \<Longrightarrow> \<forall>\<^sub>F x in sequentially. ennreal C < emeasure M (B x)
[PROOF STEP]
obtain i where d: "emeasure M (B i) > C"
[PROOF STATE]
proof (prove)
using this:
ennreal C < \<infinity> \<Longrightarrow> \<forall>\<^sub>F x in sequentially. ennreal C < emeasure M (B x)

goal (1 subgoal):
 1. (\<And>i. ennreal C < emeasure M (B i) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: eventually_sequentially)
[PROOF STATE]
proof (state)
this:
ennreal C < emeasure M (B i)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "B i \<in> sets M" "B i \<subseteq> W" "emeasure M (B i) < \<infinity>" "emeasure M (B i) > C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (B i \<in> sets M &&& B i \<subseteq> W) &&& emeasure M (B i) < \<infinity> &&& ennreal C < emeasure M (B i)
[PROOF STEP]
using B_meas b c d
[PROOF STATE]
proof (prove)
using this:
B ?i \<in> sets M
B ?i \<subseteq> W
emeasure M (B ?i2) < \<infinity>
ennreal C < emeasure M (B i)

goal (1 subgoal):
 1. (B i \<in> sets M &&& B i \<subseteq> W) &&& emeasure M (B i) < \<infinity> &&& ennreal C < emeasure M (B i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B i \<in> sets M
B i \<subseteq> W
emeasure M (B i) < \<infinity>
ennreal C < emeasure M (B i)

goal (1 subgoal):
 1. (\<And>Z. \<lbrakk>Z \<in> sets M; Z \<subseteq> W; emeasure M Z < \<infinity>; ennreal C < emeasure M Z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
B i \<in> sets M
B i \<subseteq> W
emeasure M (B i) < \<infinity>
ennreal C < emeasure M (B i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
B i \<in> sets M
B i \<subseteq> W
emeasure M (B i) < \<infinity>
ennreal C < emeasure M (B i)

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
B i \<in> sets M
B i \<subseteq> W
emeasure M (B i) < \<infinity>
ennreal C < emeasure M (B i)
\<lbrakk>?Z \<in> sets M; ?Z \<subseteq> W; emeasure M ?Z < \<infinity>; ennreal C < emeasure M ?Z\<rbrakk> \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_assn_pure_conv[simp]: "prod_assn (pure R1) (pure R2) = pure (R1 \<times>\<^sub>r R2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pure R1 \<times>\<^sub>a pure R2 = pure (R1 \<times>\<^sub>r R2)
[PROOF STEP]
by (auto simp: pure_def prod_assn_def intro!: ext)


[STATEMENT]
lemma "\<forall>i. \<not> can_take_transition t i r \<and> \<not> can_take_transition t' i r \<Longrightarrow>
       Label t = Label t' \<Longrightarrow>
       Arity t = Arity t' \<Longrightarrow>
       subsumes t' r t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>i. \<not> can_take_transition t i r \<and> \<not> can_take_transition t' i r; Label t = Label t'; Arity t = Arity t'\<rbrakk> \<Longrightarrow> subsumes t' r t
[PROOF STEP]
by (simp add: subsumes_def posterior_separate_def can_take_transition_def)


[STATEMENT]
lemma hd_rot90_knights_path:
  assumes "knights_path (board n m) ps" "hd ps = (i,j)"
  shows "hd (mirror1 (transpose ps)) = (int m+1-j,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
knights_path (board n m) ps
hd ps = (i, j)

goal (1 subgoal):
 1. hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>knights_path (board n m) ps; hd ps = (i, j)\<rbrakk> \<Longrightarrow> hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
have "hd (transpose ps) = (j,i)" "knights_path (board m n) (transpose ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd (KnightsTour.transpose ps) = (j, i) &&& knights_path (board m n) (KnightsTour.transpose ps)
[PROOF STEP]
using assms knights_path_non_nil hd_transpose transpose_knights_path
[PROOF STATE]
proof (prove)
using this:
knights_path (board n m) ps
hd ps = (i, j)
knights_path ?b ?ps \<Longrightarrow> ?ps \<noteq> []
?ps \<noteq> [] \<Longrightarrow> hd (KnightsTour.transpose ?ps) = transpose_square (hd ?ps)
knights_path (board ?n ?m) ?ps \<Longrightarrow> knights_path (board ?m ?n) (KnightsTour.transpose ?ps)

goal (1 subgoal):
 1. hd (KnightsTour.transpose ps) = (j, i) &&& knights_path (board m n) (KnightsTour.transpose ps)
[PROOF STEP]
by (auto simp: transpose_square_def)
[PROOF STATE]
proof (state)
this:
hd (KnightsTour.transpose ps) = (j, i)
knights_path (board m n) (KnightsTour.transpose ps)

goal (1 subgoal):
 1. \<lbrakk>knights_path (board n m) ps; hd ps = (i, j)\<rbrakk> \<Longrightarrow> hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
hd (KnightsTour.transpose ps) = (j, i)
knights_path (board m n) (KnightsTour.transpose ps)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
hd (KnightsTour.transpose ps) = (j, i)
knights_path (board m n) (KnightsTour.transpose ps)

goal (1 subgoal):
 1. hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
using hd_mirror1
[PROOF STATE]
proof (prove)
using this:
hd (KnightsTour.transpose ps) = (j, i)
knights_path (board m n) (KnightsTour.transpose ps)
\<lbrakk>knights_path (board ?n ?m) ?ps; hd ?ps = (?i, ?j)\<rbrakk> \<Longrightarrow> hd (mirror1 ?ps) = (int ?n + 1 - ?i, ?j)

goal (1 subgoal):
 1. hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hd (mirror1 (KnightsTour.transpose ps)) = (int m + 1 - j, i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_asymp_equiv: "(\<lambda>x. poly p (real x)) \<sim>[at_top] (\<lambda>x. lead_coeff p * real x ^ (degree p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
proof (cases "degree p = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
 2. degree p \<noteq> 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
degree p \<noteq> 0

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
 2. degree p \<noteq> 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
hence lc: "lead_coeff p \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
degree p \<noteq> 0

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

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
 2. degree p \<noteq> 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
have 1: "1 = (\<Sum>n\<le>degree p. if n = degree p then (1 :: real) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = (\<Sum>n\<le>degree p. if n = degree p then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 = (\<Sum>n\<le>degree p. if n = degree p then 1 else 0)

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
 2. degree p \<noteq> 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
degree p \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
degree p \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
proof (intro asymp_equivI', unfold poly_altdef sum_divide_distrib,
      subst 1, intro tendsto_sum, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; n \<in> {..degree p}\<rbrakk> \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
case (1 n)
[PROOF STATE]
proof (state)
this:
degree p \<noteq> 0
degree p \<noteq> 0
degree p \<noteq> 0
degree p \<noteq> 0
n \<in> {..degree p}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; n \<in> {..degree p}\<rbrakk> \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
hence "n = degree p \<or> n < degree p"
[PROOF STATE]
proof (prove)
using this:
degree p \<noteq> 0
degree p \<noteq> 0
degree p \<noteq> 0
degree p \<noteq> 0
n \<in> {..degree p}

goal (1 subgoal):
 1. n = degree p \<or> n < degree p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n = degree p \<or> n < degree p

goal (1 subgoal):
 1. \<And>n. \<lbrakk>degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; degree p \<noteq> 0; n \<in> {..degree p}\<rbrakk> \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
n = degree p \<or> n < degree p

goal (1 subgoal):
 1. (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = degree p \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
 2. n < degree p \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
assume "n = degree p"
[PROOF STATE]
proof (state)
this:
n = degree p

goal (2 subgoals):
 1. n = degree p \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
 2. n < degree p \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = degree p

goal (1 subgoal):
 1. (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
using False lc
[PROOF STATE]
proof (prove)
using this:
n = degree p
degree p \<noteq> 0
lead_coeff p \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
by (simp, intro LIMSEQ_I exI[of _ "Suc 0"], auto)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)

goal (1 subgoal):
 1. n < degree p \<Longrightarrow> (\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)
[PROOF STEP]
qed (insert False lc, real_asymp)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. coeff p n * real x ^ n / (lead_coeff p * real x ^ degree p)) \<longlonglongrightarrow> (if n = degree p then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)

goal (1 subgoal):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
degree p = 0

goal (1 subgoal):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree p = 0
[PROOF STEP]
obtain c where p: "p = [:c:]"
[PROOF STATE]
proof (prove)
using this:
degree p = 0

goal (1 subgoal):
 1. (\<And>c. p = [:c:] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis degree_eq_zeroE)
[PROOF STATE]
proof (state)
this:
p = [:c:]

goal (1 subgoal):
 1. degree p = 0 \<Longrightarrow> (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)
[PROOF STEP]
unfolding p
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. poly [:c:] (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff [:c:] * real x ^ degree [:c:])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. poly p (real x)) \<sim>[sequentially] (\<lambda>x. lead_coeff p * real x ^ degree p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma filter_simp: "(\<And>x. x \<in> set xs \<Longrightarrow> P x) \<Longrightarrow> [x\<leftarrow>xs. P x \<and> Q x] = [x\<leftarrow>xs. Q x]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> set xs \<Longrightarrow> P x) \<Longrightarrow> filter (\<lambda>x. P x \<and> Q x) xs = filter Q xs
[PROOF STEP]
by (induct xs) auto


[STATEMENT]
lemma LeadsTo_empty: "[|F \<in> A LeadsTo {}; all_total F|] ==> F \<in> Always (-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> A \<longmapsto>w {}; all_total F\<rbrakk> \<Longrightarrow> F \<in> Always (- A)
[PROOF STEP]
apply (simp add: LeadsTo_def Always_eq_includes_reachable)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> reachable F \<inter> A \<longmapsto> {}; all_total F\<rbrakk> \<Longrightarrow> reachable F \<subseteq> - A
[PROOF STEP]
apply (drule leadsTo_empty, auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma set_case_simps [simp] :
  "set_case {} c_empty c_sing c_else = c_empty"
  "set_case {x} c_empty c_sing c_else = c_sing x"
  "card s > 1 \<Longrightarrow> set_case s c_empty c_sing c_else = c_else"
  "\<not>(finite s) \<Longrightarrow> set_case s c_empty c_sing c_else = c_else"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set_case {} c_empty c_sing c_else = c_empty &&& set_case {x} c_empty c_sing c_else = c_sing x) &&& (1 < card s \<Longrightarrow> set_case s c_empty c_sing c_else = c_else) &&& (infinite s \<Longrightarrow> set_case s c_empty c_sing c_else = c_else)
[PROOF STEP]
unfolding set_case_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((if {} = {} then c_empty else if card {} = 1 then c_sing (set_choose {}) else c_else) = c_empty &&& (if {x} = {} then c_empty else if card {x} = 1 then c_sing (set_choose {x}) else c_else) = c_sing x) &&& (1 < card s \<Longrightarrow> (if s = {} then c_empty else if card s = 1 then c_sing (set_choose s) else c_else) = c_else) &&& (infinite s \<Longrightarrow> (if s = {} then c_empty else if card s = 1 then c_sing (set_choose s) else c_else) = c_else)
[PROOF STEP]
by auto


[STATEMENT]
lemma inj_onTr2:"\<lbrakk>inj_on f A; x \<in> A; y \<in> A; f x \<noteq> f y\<rbrakk>  \<Longrightarrow> x \<noteq> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inj_on f A; x \<in> A; y \<in> A; f x \<noteq> f y\<rbrakk> \<Longrightarrow> x \<noteq> y
[PROOF STEP]
apply (rule contrapos_pp, simp+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma cltn2_inverse_is_K2_isometry:
  assumes "is_K2_isometry J"
  shows "is_K2_isometry (cltn2_inverse J)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
from \<open>is_K2_isometry J\<close>
[PROOF STATE]
proof (chain)
picking this:
is_K2_isometry J
[PROOF STEP]
have "apply_cltn2 p (cltn2_inverse J) \<in> S
      \<longleftrightarrow> apply_cltn2 (apply_cltn2 p (cltn2_inverse J)) J \<in> S"
[PROOF STATE]
proof (prove)
using this:
is_K2_isometry J

goal (1 subgoal):
 1. (apply_cltn2 p (cltn2_inverse J) \<in> S) = (apply_cltn2 (apply_cltn2 p (cltn2_inverse J)) J \<in> S)
[PROOF STEP]
unfolding is_K2_isometry_def
[PROOF STATE]
proof (prove)
using this:
\<forall>p. (apply_cltn2 p J \<in> S) = (p \<in> S)

goal (1 subgoal):
 1. (apply_cltn2 p (cltn2_inverse J) \<in> S) = (apply_cltn2 (apply_cltn2 p (cltn2_inverse J)) J \<in> S)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(apply_cltn2 p (cltn2_inverse J) \<in> S) = (apply_cltn2 (apply_cltn2 p (cltn2_inverse J)) J \<in> S)

goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
hence "apply_cltn2 p (cltn2_inverse J) \<in> S \<longleftrightarrow> p \<in> S"
[PROOF STATE]
proof (prove)
using this:
(apply_cltn2 p (cltn2_inverse J) \<in> S) = (apply_cltn2 (apply_cltn2 p (cltn2_inverse J)) J \<in> S)

goal (1 subgoal):
 1. (apply_cltn2 p (cltn2_inverse J) \<in> S) = (p \<in> S)
[PROOF STEP]
by (simp add: cltn2.act_inv_act [simplified])
[PROOF STATE]
proof (state)
this:
(apply_cltn2 p (cltn2_inverse J) \<in> S) = (p \<in> S)

goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(apply_cltn2 ?p2 (cltn2_inverse J) \<in> S) = (?p2 \<in> S)

goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
thus "is_K2_isometry (cltn2_inverse J)"
[PROOF STATE]
proof (prove)
using this:
(apply_cltn2 ?p2 (cltn2_inverse J) \<in> S) = (?p2 \<in> S)

goal (1 subgoal):
 1. is_K2_isometry (cltn2_inverse J)
[PROOF STEP]
unfolding is_K2_isometry_def
[PROOF STATE]
proof (prove)
using this:
(apply_cltn2 ?p2 (cltn2_inverse J) \<in> S) = (?p2 \<in> S)

goal (1 subgoal):
 1. \<forall>p. (apply_cltn2 p (cltn2_inverse J) \<in> S) = (p \<in> S)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
is_K2_isometry (cltn2_inverse J)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma non_sym_dist_pairs_elems :
  assumes "x \<in> set xs"
  and     "y \<in> set xs"
  and     "x \<noteq> y"
shows "(x,y) \<in> set (non_sym_dist_pairs xs) \<or> (y,x) \<in> set (non_sym_dist_pairs xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x, y) \<in> set (non_sym_dist_pairs xs) \<or> (y, x) \<in> set (non_sym_dist_pairs xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> set xs
y \<in> set xs
x \<noteq> y

goal (1 subgoal):
 1. (x, y) \<in> set (non_sym_dist_pairs xs) \<or> (y, x) \<in> set (non_sym_dist_pairs xs)
[PROOF STEP]
by (induction xs; auto)


[STATEMENT]
lemma higher_differentiable_on_uminus:
  "higher_differentiable_on S (\<lambda>x. - f x) n"
  if "higher_differentiable_on S f n" "open S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. higher_differentiable_on S (\<lambda>x. - f x) n
[PROOF STEP]
using higher_differentiable_on_scaleR[of S "\<lambda>x. -1" n f] that
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>higher_differentiable_on S (\<lambda>x. - 1) n; higher_differentiable_on S f n; open S\<rbrakk> \<Longrightarrow> higher_differentiable_on S (\<lambda>x. - 1 *\<^sub>R f x) n
higher_differentiable_on S f n
open S

goal (1 subgoal):
 1. higher_differentiable_on S (\<lambda>x. - f x) n
[PROOF STEP]
by (auto simp: higher_differentiable_on_const)


[STATEMENT]
lemma Assoc_List_set_eq_lookup:
  "(k,v) \<in> Assoc_List.set vs \<longleftrightarrow> Assoc_List.lookup vs k = Some v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((k, v) \<in> Assoc_List.set vs) = (Assoc_List.lookup vs k = Some v)
[PROOF STEP]
by (simp add: Assoc_List.lookup_def Assoc_List.set_def)


[STATEMENT]
lemma abs_norm_cancel [simp]: "\<bar>norm a\<bar> = norm a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>norm a\<bar> = norm a
[PROOF STEP]
by (rule abs_of_nonneg [OF norm_ge_zero])


[STATEMENT]
lemma finite_ran:
  assumes "finite (dom p)"
  shows "finite (ran p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (ran p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (ran p)
[PROOF STEP]
have "ran p = (\<lambda>x. the (p x)) ` dom p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ran p = (\<lambda>x. the (p x)) ` dom p
[PROOF STEP]
unfolding ran_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {b. \<exists>a. p a = Some b} = (\<lambda>x. the (p x)) ` dom p
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
ran p = (\<lambda>x. the (p x)) ` dom p

goal (1 subgoal):
 1. finite (ran p)
[PROOF STEP]
from this \<open>finite (dom p)\<close>
[PROOF STATE]
proof (chain)
picking this:
ran p = (\<lambda>x. the (p x)) ` dom p
finite (dom p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ran p = (\<lambda>x. the (p x)) ` dom p
finite (dom p)

goal (1 subgoal):
 1. finite (ran p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (ran p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem wls_fresh_swap_exchange2:
assumes "wls s X"
shows "fresh xs x2 (X #[x2 \<and> x1]_xs) = fresh xs x1 X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fresh xs x2 (X #[x2 \<and> x1]_xs) = fresh xs x1 X
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wls s X

goal (1 subgoal):
 1. fresh xs x2 (X #[x2 \<and> x1]_xs) = fresh xs x1 X
[PROOF STEP]
by (intro fresh_swap_exchange2) fastforce+


[STATEMENT]
lemma x_larger_0: "x \<in> consumption_set \<Longrightarrow> x \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> consumption_set \<Longrightarrow> (0::'a) \<le> x
[PROOF STEP]
using r_plus
[PROOF STATE]
proof (prove)
using this:
consumption_set \<subseteq> {x. (0::'a) \<le> x}

goal (1 subgoal):
 1. x \<in> consumption_set \<Longrightarrow> (0::'a) \<le> x
[PROOF STEP]
by auto


[STATEMENT]
lemma indI: "\<lbrakk>(x, y) \<in> r; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> (x, y) \<in> induced S r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> r; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> (x, y) \<in> induced S r
[PROOF STEP]
by (simp add: induced_def)


[STATEMENT]
lemma rel_restrict_alt_def:
  "rel_restrict R A = R \<inter> (-A) \<times> (-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_restrict R A = Restr R (- A)
[PROOF STEP]
unfolding rel_restrict_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(v, w). (v, w) \<in> R \<and> v \<notin> A \<and> w \<notin> A} = Restr R (- A)
[PROOF STEP]
by auto


[STATEMENT]
lemma G_fact: "G (of_nat n + 1) = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. G (real n + 1) = fact n
[PROOF STEP]
using G_plus1[of "real n + 1" for n]
[PROOF STATE]
proof (prove)
using this:
0 < real ?na2 + 1 \<Longrightarrow> G (real ?na2 + 1 + 1) = (real ?na2 + 1) * G (real ?na2 + 1)

goal (1 subgoal):
 1. G (real n + 1) = fact n
[PROOF STEP]
by (induction n) (simp_all add: G_1 G_plus1)


[STATEMENT]
lemma Lambert_W'_gtI:
  assumes "y * exp y > x" "y \<le> -1" "x \<ge> -exp(-1)"
  shows   "Lambert_W' x \<ge> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
x < y * exp y
y \<le> - 1
- exp (- 1) \<le> x
[PROOF STEP]
have "y * exp y < 0"
[PROOF STATE]
proof (prove)
using this:
x < y * exp y
y \<le> - 1
- exp (- 1) \<le> x

goal (1 subgoal):
 1. y * exp y < 0
[PROOF STEP]
by (intro mult_neg_pos) auto
[PROOF STATE]
proof (state)
this:
y * exp y < 0

goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
hence "Lambert_W' x > Lambert_W' (y * exp y)"
[PROOF STATE]
proof (prove)
using this:
y * exp y < 0

goal (1 subgoal):
 1. Lambert_W' (y * exp y) < Lambert_W' x
[PROOF STEP]
using assms exp_times_self_ge[of y]
[PROOF STATE]
proof (prove)
using this:
y * exp y < 0
x < y * exp y
y \<le> - 1
- exp (- 1) \<le> x
- exp (- 1) \<le> y * exp y

goal (1 subgoal):
 1. Lambert_W' (y * exp y) < Lambert_W' x
[PROOF STEP]
by (intro Lambert_W'_strict_antimono) auto
[PROOF STATE]
proof (state)
this:
Lambert_W' (y * exp y) < Lambert_W' x

goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Lambert_W' (y * exp y) < Lambert_W' x

goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Lambert_W' (y * exp y) < Lambert_W' x
x < y * exp y
y \<le> - 1
- exp (- 1) \<le> x

goal (1 subgoal):
 1. y \<le> Lambert_W' x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y \<le> Lambert_W' x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma subseq_sum_path_weights_le:
  "map LBL xs \<preceq> map LBL ys \<Longrightarrow> sum_path_weights xs \<le> sum_path_weights ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>(s, l, t). l) xs \<preceq> map (\<lambda>(s, l, t). l) ys \<Longrightarrow> sum_weights (map (\<lambda>(s, l, t). l) xs) \<le> sum_weights (map (\<lambda>(s, l, t). l) ys)
[PROOF STEP]
by (rule subseq_sum_weights_le)


[STATEMENT]
lemma tree_recurse_fusion:
  assumes "h \<circ> l = l' \<circ> h" and "h \<circ> r = r' \<circ> h"
  shows "map_tree h (tree_recurse l r x) = tree_recurse l' r' (h x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_tree h (tree_recurse l r x) = tree_recurse l' r' (h x)
[PROOF STEP]
by(rule tree_recurse.unique)(simp add: tree.expand assms)


[STATEMENT]
lemma eqvtUnion[intro]:
  fixes Rel  :: "('a::pt_name \<times> 'a) set"
  and   Rel' :: "('a \<times> 'a) set"

  assumes EqvtRel:  "eqvt Rel"
  and     EqvtRel': "eqvt Rel'"

  shows "eqvt (Rel \<union> Rel')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eqvt (Rel \<union> Rel')
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
eqvt Rel
eqvt Rel'

goal (1 subgoal):
 1. eqvt (Rel \<union> Rel')
[PROOF STEP]
by(force simp add: eqvt_def)


[STATEMENT]
lemma qfN_pos: "\<lbrakk> N \<ge> 1; is_qfN A N \<rbrakk> \<Longrightarrow> A \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
assume N: "N \<ge> 1" and "is_qfN A N"
[PROOF STATE]
proof (state)
this:
1 \<le> N
is_qfN A N

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 \<le> N
is_qfN A N
[PROOF STEP]
obtain a b where ab: "A = a^2 + N*b^2"
[PROOF STATE]
proof (prove)
using this:
1 \<le> N
is_qfN A N

goal (1 subgoal):
 1. (\<And>a b. A = a\<^sup>2 + N * b\<^sup>2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: is_qfN_def)
[PROOF STATE]
proof (state)
this:
A = a\<^sup>2 + N * b\<^sup>2

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
have "N*b^2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> N * b\<^sup>2
[PROOF STEP]
proof (cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> 0 \<le> N * b\<^sup>2
 2. \<not> ?P \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
assume "b = 0"
[PROOF STATE]
proof (state)
this:
b = 0

goal (2 subgoals):
 1. ?P \<Longrightarrow> 0 \<le> N * b\<^sup>2
 2. \<not> ?P \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
b = 0

goal (1 subgoal):
 1. 0 \<le> N * b\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> N * b\<^sup>2

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
assume "\<not> b = 0"
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
hence " b^2 > 0"
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0

goal (1 subgoal):
 1. 0 < b\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < b\<^sup>2

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < b\<^sup>2

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
from N
[PROOF STATE]
proof (chain)
picking this:
1 \<le> N
[PROOF STEP]
have "N>0"
[PROOF STATE]
proof (prove)
using this:
1 \<le> N

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

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < b\<^sup>2
0 < N
[PROOF STEP]
have "N*b^2 > N*0"
[PROOF STATE]
proof (prove)
using this:
0 < b\<^sup>2
0 < N

goal (1 subgoal):
 1. N * 0 < N * b\<^sup>2
[PROOF STEP]
by (auto simp only: zmult_zless_mono2)
[PROOF STATE]
proof (state)
this:
N * 0 < N * b\<^sup>2

goal (1 subgoal):
 1. b \<noteq> 0 \<Longrightarrow> 0 \<le> N * b\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
N * 0 < N * b\<^sup>2

goal (1 subgoal):
 1. 0 \<le> N * b\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> N * b\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 \<le> N * b\<^sup>2

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
with ab
[PROOF STATE]
proof (chain)
picking this:
A = a\<^sup>2 + N * b\<^sup>2
0 \<le> N * b\<^sup>2
[PROOF STEP]
have "A \<ge> a^2"
[PROOF STATE]
proof (prove)
using this:
A = a\<^sup>2 + N * b\<^sup>2
0 \<le> N * b\<^sup>2

goal (1 subgoal):
 1. a\<^sup>2 \<le> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a\<^sup>2 \<le> A

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
a\<^sup>2 \<le> A

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
have "a^2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> a\<^sup>2
[PROOF STEP]
by (rule zero_le_power2)
[PROOF STATE]
proof (state)
this:
0 \<le> a\<^sup>2

goal (1 subgoal):
 1. \<lbrakk>1 \<le> N; is_qfN A N\<rbrakk> \<Longrightarrow> 0 \<le> A
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 \<le> A
0 \<le> a\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 \<le> A
0 \<le> a\<^sup>2

goal (1 subgoal):
 1. 0 \<le> A
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
0 \<le> A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma countable_cycles [simp]:
  assumes "countable (\<^bold>V\<^bsub>G\<^esub>)"
  shows "countable (cycles G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (cycles G)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. countable (cycles G)
[PROOF STEP]
have "cycles G \<subseteq> lists \<^bold>V\<^bsub>G\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cycles G \<subseteq> lists \<^bold>V\<^bsub>G\<^esub>
[PROOF STEP]
by(auto elim!: cycle.cases dest: rtrancl_path_Range_end rtrancl_path_Range simp add: vertex_def)
[PROOF STATE]
proof (state)
this:
cycles G \<subseteq> lists \<^bold>V\<^bsub>G\<^esub>

goal (1 subgoal):
 1. countable (cycles G)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
cycles G \<subseteq> lists \<^bold>V\<^bsub>G\<^esub>

goal (1 subgoal):
 1. countable (cycles G)
[PROOF STEP]
by(rule countable_subset)(simp add: assms)
[PROOF STATE]
proof (state)
this:
countable (cycles G)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vsubset_vunion_leftI[intro]:
  assumes "A \<subseteq>\<^sub>\<circ> C" and "B \<subseteq>\<^sub>\<circ> C"
  shows "(A \<union>\<^sub>\<circ> B) \<subseteq>\<^sub>\<circ> C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<union>\<^sub>\<circ> B \<subseteq>\<^sub>\<circ> C
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq>\<^sub>\<circ> C
B \<subseteq>\<^sub>\<circ> C

goal (1 subgoal):
 1. A \<union>\<^sub>\<circ> B \<subseteq>\<^sub>\<circ> C
[PROOF STEP]
by auto


[STATEMENT]
lemma Lim_linear:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" and h :: "'b \<Rightarrow> 'c::real_normed_vector"
  assumes "(f \<longlongrightarrow> l) F" "linear h"
  shows "((\<lambda>x. h(f x)) \<longlongrightarrow> h l) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. h (f x)) \<longlongrightarrow> h l) F
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. h (f x)) \<longlongrightarrow> h l) F
[PROOF STEP]
obtain B where B: "B > 0" "\<And>x. norm (h x) \<le> B * norm x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. \<lbrakk>0 < B; \<And>x. norm (h x) \<le> B * norm x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using linear_bounded_pos [OF \<open>linear h\<close>]
[PROOF STATE]
proof (prove)
using this:
(\<And>B. \<lbrakk>0 < B; \<And>x. norm (h x) \<le> B * norm x\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>B. \<lbrakk>0 < B; \<And>x. norm (h x) \<le> B * norm x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
0 < B
norm (h ?x) \<le> B * norm ?x

goal (1 subgoal):
 1. ((\<lambda>x. h (f x)) \<longlongrightarrow> h l) F
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. h (f x)) \<longlongrightarrow> h l) F
[PROOF STEP]
unfolding tendsto_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>e>0. \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
proof (intro allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
show "\<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e" if "e > 0" for e
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
have "\<forall>\<^sub>F x in F. dist (f x) l < e/B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (f x) l < e / B
[PROOF STEP]
by (simp add: \<open>0 < B\<close> assms(1) tendstoD that)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. dist (f x) l < e / B

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in F. dist (f x) l < e / B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. dist (f x) l < e / B

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e
[PROOF STEP]
unfolding dist_norm
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. norm (f x - l) < e / B

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. norm (h (f x) - h l) < e
[PROOF STEP]
proof (rule eventually_mono)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. norm (f x - l) < e / B \<Longrightarrow> norm (h (f x) - h l) < e
[PROOF STEP]
show "norm (h (f x) - h l) < e" if "norm (f x - l) < e / B" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (h (f x) - h l) < e
[PROOF STEP]
using that B
[PROOF STATE]
proof (prove)
using this:
norm (f x - l) < e / B
0 < B
norm (h ?x) \<le> B * norm ?x

goal (1 subgoal):
 1. norm (h (f x) - h l) < e
[PROOF STEP]
apply (simp add: field_split_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B * norm (f x - l) < e; 0 < B; \<And>x. norm (h x) \<le> B * norm x\<rbrakk> \<Longrightarrow> norm (h (f x) - h l) < e
[PROOF STEP]
by (metis \<open>linear h\<close> le_less_trans linear_diff)
[PROOF STATE]
proof (state)
this:
norm (f ?x - l) < e / B \<Longrightarrow> norm (h (f ?x) - h l) < e

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. dist (h (f x)) (h l) < e

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < ?e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (h (f x)) (h l) < ?e

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>x. h (f x)) \<longlongrightarrow> h l) F

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma order_gcd:
  assumes "p\<noteq>0" "q\<noteq>0"
  shows "order x (gcd p q) = min (order x p) (order x q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order x (gcd p q) = min (order x p) (order x q)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. order x (gcd p q) = min (order x p) (order x q)
[PROOF STEP]
have "prime [:- x, 1:]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime [:- x, 1::'a:]
[PROOF STEP]
apply (auto simp add: prime_elem_linear_poly normalize_poly_def  intro!:primeI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:- x, 1::'a:] div [:1::'a:] = [:- x, 1::'a:]
[PROOF STEP]
by (simp add: pCons_one)
[PROOF STATE]
proof (state)
this:
prime [:- x, 1::'a:]

goal (1 subgoal):
 1. order x (gcd p q) = min (order x p) (order x q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime [:- x, 1::'a:]
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prime [:- x, 1::'a:]

goal (1 subgoal):
 1. order x (gcd p q) = min (order x p) (order x q)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prime [:- x, 1::'a:]
p \<noteq> 0
q \<noteq> 0

goal (1 subgoal):
 1. order x (gcd p q) = min (order x p) (order x q)
[PROOF STEP]
by (auto simp add:order_multiplicity_eq intro:multiplicity_gcd)
[PROOF STATE]
proof (state)
this:
order x (gcd p q) = min (order x p) (order x q)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transp_inv_image: "transp r \<Longrightarrow> transp (\<lambda>x y. r (f x) (f y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transp r \<Longrightarrow> transp (\<lambda>x y. r (f x) (f y))
[PROOF STEP]
using trans_inv_image[where r="{(x, y). r x y}" and f = f]
[PROOF STATE]
proof (prove)
using this:
trans {(x, y). r x y} \<Longrightarrow> trans (inv_image {(x, y). r x y} f)

goal (1 subgoal):
 1. transp r \<Longrightarrow> transp (\<lambda>x y. r (f x) (f y))
[PROOF STEP]
by(simp add: transp_trans inv_image_def)


[STATEMENT]
lemma trivial_integer_mod_group: "trivial_group(integer_mod_group n) \<longleftrightarrow> n = 1"
  (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trivial_group (integer_mod_group n) = (n = 1)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. trivial_group (integer_mod_group n) \<Longrightarrow> n = 1
 2. n = 1 \<Longrightarrow> trivial_group (integer_mod_group n)
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
trivial_group (integer_mod_group n)

goal (2 subgoals):
 1. trivial_group (integer_mod_group n) \<Longrightarrow> n = 1
 2. n = 1 \<Longrightarrow> trivial_group (integer_mod_group n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
trivial_group (integer_mod_group n)
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
trivial_group (integer_mod_group n)

goal (1 subgoal):
 1. n = 1
[PROOF STEP]
by (simp add: trivial_group_def carrier_integer_mod_group set_eq_iff split: if_split_asm) (presburger+)
[PROOF STATE]
proof (state)
this:
n = 1

goal (1 subgoal):
 1. n = 1 \<Longrightarrow> trivial_group (integer_mod_group n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 1 \<Longrightarrow> trivial_group (integer_mod_group n)
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
n = 1

goal (1 subgoal):
 1. n = 1 \<Longrightarrow> trivial_group (integer_mod_group n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 1
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
n = 1

goal (1 subgoal):
 1. trivial_group (integer_mod_group n)
[PROOF STEP]
by (force simp: trivial_group_def carrier_integer_mod_group)
[PROOF STATE]
proof (state)
this:
trivial_group (integer_mod_group n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma imp_reverse:
  "PRE (\<lambda>s:: 'a list store. s ''x'' = X)
   (''y'' ::= (\<lambda>s. []));
   (WHILE (\<lambda>s. s ''x'' \<noteq> []) INV (\<lambda>s. rev (s ''x'') @ s ''y'' = rev X)
    DO
     (''y'' ::= (\<lambda>s. hd (s ''x'') # s ''y''));
     (''x'' ::= (\<lambda>s. tl (s ''x'')))
    OD)
   POST (\<lambda>s. s ''y''= rev X )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. PRE (\<lambda>s. s ''x'' = X) (''y'' ::= (\<lambda>s. [])) ; (WHILE (\<lambda>s. s ''x'' \<noteq> []) INV (\<lambda>s. rev (s ''x'') @ s ''y'' = rev X) DO (''y'' ::= (\<lambda>s. hd (s ''x'') # s ''y'')) ; (''x'' ::= (\<lambda>s. tl (s ''x''))) OD) POST (\<lambda>s. s ''y'' = rev X)
[PROOF STEP]
apply hoare
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. \<forall>s. ?Q7 s \<longrightarrow> rev (s ''x'') @ s ''y'' = rev X
 2. \<forall>s. rev (s ''x'') @ s ''y'' = rev X \<and> \<not> s ''x'' \<noteq> [] \<longrightarrow> s ''y'' = rev X
 3. \<forall>s. ?Q28 s \<longrightarrow> rev ((s(''x'' := tl (s ''x''))) ''x'') @ (s(''x'' := tl (s ''x''))) ''y'' = rev X
 4. \<forall>s. ((\<lambda>s. rev (s ''x'') @ s ''y'' = rev X) \<sqinter> (\<lambda>s. s ''x'' \<noteq> [])) s \<longrightarrow> ?Q28 (s(''y'' := hd (s ''x'') # s ''y''))
 5. \<forall>s. s ''x'' = X \<longrightarrow> ?Q7 (s(''y'' := []))
[PROOF STEP]
apply auto[3]
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>s. ((\<lambda>s. rev (s ''x'') @ s ''y'' = rev X) \<sqinter> (\<lambda>s. s ''x'' \<noteq> [])) s \<longrightarrow> rev (tl ((s(''y'' := hd (s ''x'') # s ''y'')) ''x'')) @ (s(''y'' := hd (s ''x'') # s ''y'')) ''y'' = rev X
 2. \<forall>s. s ''x'' = X \<longrightarrow> rev ((s(''y'' := [])) ''x'') @ (s(''y'' := [])) ''y'' = rev X
[PROOF STEP]
apply (clarsimp, metis (no_types, lifting) Cons_eq_appendI append_eq_append_conv2 hd_Cons_tl rev.simps(2) self_append_conv)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>s. s ''x'' = X \<longrightarrow> rev ((s(''y'' := [])) ''x'') @ (s(''y'' := [])) ''y'' = rev X
[PROOF STEP]
by simp


[STATEMENT]
lemma simple_distributed_measure:
  "simple_distributed M X P \<Longrightarrow> a \<in> X`space M \<Longrightarrow> P a = measure M (X -` {a} \<inter> space M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>simple_distributed M X P; a \<in> X ` space M\<rbrakk> \<Longrightarrow> P a = Sigma_Algebra.measure M (X -` {a} \<inter> space M)
[PROOF STEP]
using distributed_count_space[of M "X`space M" X P a, symmetric]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>distributed M (count_space (X ` space M)) X (\<lambda>x. ennreal (P x)); a \<in> X ` space M; finite (X ` space M)\<rbrakk> \<Longrightarrow> emeasure M (X -` {a} \<inter> space M) = ennreal (P a)

goal (1 subgoal):
 1. \<lbrakk>simple_distributed M X P; a \<in> X ` space M\<rbrakk> \<Longrightarrow> P a = Sigma_Algebra.measure M (X -` {a} \<inter> space M)
[PROOF STEP]
by (auto simp: simple_distributed_def measure_def)


[STATEMENT]
lemma pi_approx_64:
  "abs (pi - 57952155664616982739 / 2^64 :: real) \<le> inverse (2^64)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - 57952155664616982739 / 2 ^ 64\<bar> \<le> inverse (2 ^ 64)
[PROOF STEP]
by (rule approx_coarsen[OF pi_approx_54_decimals]) simp


[STATEMENT]
lemma givenBy_o_eq_extend_set:
     "givenBy (v o f) = extend_set h ` (givenBy v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. givenBy (v \<circ> f) = extend_set h ` givenBy v
[PROOF STEP]
apply (simp add: givenBy_eq_Collect)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {A. \<exists>P. A = {s. P (v (f s))}} = extend_set h ` {A. \<exists>P. A = {s. P (v s)}}
[PROOF STEP]
apply (rule equalityI, best)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. extend_set h ` {A. \<exists>P. A = {s. P (v s)}} \<subseteq> {A. \<exists>P. A = {s. P (v (f s))}}
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma octo_inner_e7_left [simp]: "inner e7 x  = Im7 x"
 and octo_inner_e7_right [simp]: "inner x e7 = Im7 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e7 \<bullet> x = Im7 x &&& x \<bullet> e7 = Im7 x
[PROOF STEP]
unfolding inner_octo_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ree e7 * Ree x + Im1 e7 * Im1 x + Im2 e7 * Im2 x + Im3 e7 * Im3 x + Im4 e7 * Im4 x + Im5 e7 * Im5 x + Im6 e7 * Im6 x + Im7 e7 * Im7 x = Im7 x &&& Ree x * Ree e7 + Im1 x * Im1 e7 + Im2 x * Im2 e7 + Im3 x * Im3 e7 + Im4 x * Im4 e7 + Im5 x * Im5 e7 + Im6 x * Im6 e7 + Im7 x * Im7 e7 = Im7 x
[PROOF STEP]
by simp_all


[STATEMENT]
lemma neg_true_until_always: "-(\<top> until -p) = \<box> p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (\<top> until - p) = \<box> p
[PROOF STEP]
by (simp add: fun_eq_iff always_def until_def uminus_SUP uminus_INF)


[STATEMENT]
lemma alice_step_2:
  assumes "state 1 \<phi>" and "\<alpha> = \<phi> $$ (0,0)" and "\<beta> = \<phi> $$ (1,0)"
  shows "(CNOT \<Otimes> Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>) = mat_of_cols_list 8 [[\<alpha>/sqrt(2),0,0,\<alpha>/sqrt(2),0,\<beta>/sqrt(2),\<beta>/sqrt(2),0]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]); j < dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]] $$ (i, j)
 2. dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
 3. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
[PROOF STEP]
have f0:"(\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>) = mat_of_cols_list 8 [[\<alpha>/sqrt(2),0,0,\<alpha>/sqrt(2),\<beta>/sqrt(2),0,0,\<beta>/sqrt(2)]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle> = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0, 0, \<beta> / complex_of_real (sqrt 2)]]
[PROOF STEP]
using assms alice_step_1
[PROOF STATE]
proof (prove)
using this:
state 1 \<phi>
\<alpha> = \<phi> $$ (0, 0)
\<beta> = \<phi> $$ (1, 0)
\<lbrakk>state 1 ?\<phi>; ?\<alpha> = ?\<phi> $$ (0, 0); ?\<beta> = ?\<phi> $$ (1, 0)\<rbrakk> \<Longrightarrow> ?\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle> = Tensor.mat_of_cols_list 8 [[?\<alpha> / complex_of_real (sqrt 2), 0, 0, ?\<alpha> / complex_of_real (sqrt 2), ?\<beta> / complex_of_real (sqrt 2), 0, 0, ?\<beta> / complex_of_real (sqrt 2)]]

goal (1 subgoal):
 1. \<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle> = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0, 0, \<beta> / complex_of_real (sqrt 2)]]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle> = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0, 0, \<beta> / complex_of_real (sqrt 2)]]

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]); j < dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]] $$ (i, j)
 2. dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
 3. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
[PROOF STEP]
define v where asm:"v = mat_of_cols_list 8 [[\<alpha>/sqrt(2),0,0,\<alpha>/sqrt(2),0,\<beta>/sqrt(2),\<beta>/sqrt(2),0]]"
[PROOF STATE]
proof (state)
this:
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]); j < dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]] $$ (i, j)
 2. dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
 3. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]
[PROOF STEP]
show "dim_row ((CNOT \<Otimes> Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row v"
[PROOF STATE]
proof (prove)
using this:
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]

goal (1 subgoal):
 1. dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row v
[PROOF STEP]
using assms(1) alice_step_2_state state.dim_row mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]
state 1 \<phi>
state 1 ?\<phi> \<Longrightarrow> state 3 ((CNOT \<Otimes> Quantum.Id 1) * (?\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>))
state ?n ?v \<Longrightarrow> dim_row ?v = 2 ^ ?n
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row v
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
dim_row ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_row v

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]); j < dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]] $$ (i, j)
 2. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])
[PROOF STEP]
show "dim_col ((CNOT \<Otimes> Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col v
[PROOF STEP]
using assms(1) alice_step_2_state state.is_column asm mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
state 1 \<phi>
state 1 ?\<phi> \<Longrightarrow> state 3 ((CNOT \<Otimes> Quantum.Id 1) * (?\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>))
state ?n ?v \<Longrightarrow> dim_col ?v = 1
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col v
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
dim_col ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) = dim_col v

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]); j < dim_col (Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]])\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]] $$ (i, j)
[PROOF STEP]
show "\<And>i j. i<dim_row v \<Longrightarrow> j<dim_col v \<Longrightarrow> ((CNOT \<Otimes> Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i,j) = v $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
assume "i < dim_row v" and "j < dim_col v"
[PROOF STATE]
proof (state)
this:
i < dim_row v
j < dim_col v

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row v
j < dim_col v
[PROOF STEP]
have "i \<in> {0..<8::nat} \<and> j = 0"
[PROOF STATE]
proof (prove)
using this:
i < dim_row v
j < dim_col v

goal (1 subgoal):
 1. i \<in> {0..<8} \<and> j = 0
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
i < dim_row v
j < dim_col v
v = Tensor.mat_of_cols_list 8 [[\<alpha> / complex_of_real (sqrt 2), 0, 0, \<alpha> / complex_of_real (sqrt 2), 0, \<beta> / complex_of_real (sqrt 2), \<beta> / complex_of_real (sqrt 2), 0]]

goal (1 subgoal):
 1. i \<in> {0..<8} \<and> j = 0
[PROOF STEP]
by (auto simp add: mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
i \<in> {0..<8} \<and> j = 0

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<in> {0..<8} \<and> j = 0
[PROOF STEP]
have "(M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i,j) = v $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
i \<in> {0..<8} \<and> j = 0

goal (1 subgoal):
 1. (M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
by (auto simp add: f0 asm mat_of_cols_list_def times_mat_def scalar_prod_def)
[PROOF STATE]
proof (state)
this:
(M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row v; j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
show "((CNOT \<Otimes> Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i,j) = v $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
(M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)

goal (1 subgoal):
 1. ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
using tensor_prod_of_cnot_id_1
[PROOF STATE]
proof (prove)
using this:
(M1 * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
CNOT \<Otimes> Quantum.Id 1 = M1

goal (1 subgoal):
 1. ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (i, j) = v $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row v; ?j < dim_col v\<rbrakk> \<Longrightarrow> ((CNOT \<Otimes> Quantum.Id 1) * (\<phi> \<Otimes> |\<beta>\<^sub>0\<^sub>0\<rangle>)) $$ (?i, ?j) = v $$ (?i, ?j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Suc_Suc_Tr:"Suc (Suc 0) \<le> n \<Longrightarrow> Suc (n - Suc (Suc 0)) = n - Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (Suc 0) \<le> n \<Longrightarrow> Suc (n - Suc (Suc 0)) = n - Suc 0
[PROOF STEP]
by arith


[STATEMENT]
lemma symbolic_checker:
  "collision {0..} \<longleftrightarrow>
    (quadroot_in 0 (min ego.t_stop other.t_stop) (1/2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)) \<or>
    (quadroot_in ego.t_stop other.t_stop (1/2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)) \<or>
    (quadroot_in other.t_stop ego.t_stop (1/2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))"
 (is "_ \<longleftrightarrow> ?q1 \<or> ?q2 \<or> ?q3")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
have *: "{0..max ego.t_stop other.t_stop} =
    {0 .. min ego.t_stop other.t_stop} \<union> {ego.t_stop .. other.t_stop} \<union> {other.t_stop .. ego.t_stop}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0..max ego.t_stop other.t_stop} = {0..min ego.t_stop other.t_stop} \<union> {ego.t_stop..other.t_stop} \<union> {other.t_stop..ego.t_stop}
[PROOF STEP]
using ego.t_stop_nonneg other.t_stop_nonneg
[PROOF STATE]
proof (prove)
using this:
0 \<le> ego.t_stop
0 \<le> other.t_stop

goal (1 subgoal):
 1. {0..max ego.t_stop other.t_stop} = {0..min ego.t_stop other.t_stop} \<union> {ego.t_stop..other.t_stop} \<union> {other.t_stop..ego.t_stop}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0..max ego.t_stop other.t_stop} = {0..min ego.t_stop other.t_stop} \<union> {ego.t_stop..other.t_stop} \<union> {other.t_stop..ego.t_stop}

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
have "collision {0..min (movement.t_stop a\<^sub>e v\<^sub>e) (movement.t_stop a\<^sub>o v\<^sub>o)} = ?q1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)
[PROOF STEP]
by (force simp: collision_def quadroot_in_def root_in_def d_def
      power2_eq_square field_split_simps movement.p_def movement.s_cond_def)
[PROOF STATE]
proof (state)
this:
collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
have "collision {ego.t_stop .. other.t_stop} = ?q2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)
[PROOF STEP]
using ego.t_stop_nonneg
[PROOF STATE]
proof (prove)
using this:
0 \<le> ego.t_stop

goal (1 subgoal):
 1. collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)
[PROOF STEP]
by (force simp: collision_def quadroot_in_def root_in_def d_def
      ego.s_eq_s_stop movement.s_cond_def movement.p_def)
[PROOF STATE]
proof (state)
this:
collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
have "collision {other.t_stop .. ego.t_stop} = ?q3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)
[PROOF STEP]
using other.t_stop_nonneg
[PROOF STATE]
proof (prove)
using this:
0 \<le> other.t_stop

goal (1 subgoal):
 1. collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)
[PROOF STEP]
by (force simp: collision_def quadroot_in_def root_in_def d_def
      other.s_eq_s_stop movement.s_cond_def movement.p_def)
[PROOF STATE]
proof (state)
this:
collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)
collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)
collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)
collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)
collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)

goal (1 subgoal):
 1. collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
unfolding collision_restrict * collision_union
[PROOF STATE]
proof (prove)
using this:
collision {0..min ego.t_stop other.t_stop} = quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e)
collision {ego.t_stop..other.t_stop} = quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop)
collision {other.t_stop..ego.t_stop} = quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop)

goal (1 subgoal):
 1. ((collision {0..min ego.t_stop other.t_stop} \<or> collision {ego.t_stop..other.t_stop}) \<or> collision {other.t_stop..ego.t_stop}) = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
collision {0..} = (quadroot_in 0 (min ego.t_stop other.t_stop) (1 / 2 * (a\<^sub>o - a\<^sub>e)) (v\<^sub>o - v\<^sub>e) (s\<^sub>o - s\<^sub>e) \<or> quadroot_in ego.t_stop other.t_stop (1 / 2 * a\<^sub>o) v\<^sub>o (s\<^sub>o - ego.s_stop) \<or> quadroot_in other.t_stop ego.t_stop (1 / 2 * a\<^sub>e) v\<^sub>e (s\<^sub>e - other.s_stop))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pmf_bind_spmf_None: "pmf (p \<bind> f) None = pmf p None + \<integral> x. pmf (f x) None \<partial>measure_spmf p"
  (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
let ?f = "\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
have "?lhs = \<integral> x. ?f x \<partial>measure_pmf p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (p \<bind> f) None = measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None)
[PROOF STEP]
by(simp add: bind_spmf_def pmf_bind)
[PROOF STATE]
proof (state)
this:
pmf (p \<bind> f) None = measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf (p \<bind> f) None = measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
have "\<dots> = \<integral> x. ?f None * indicator {None} x + ?f x * indicator (range Some) x \<partial>measure_pmf p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)
[PROOF STEP]
by(rule Bochner_Integration.integral_cong)(auto simp add: indicator_def)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
have "\<dots> = (\<integral> x. ?f None * indicator {None} x \<partial>measure_pmf p) + (\<integral> x. ?f x * indicator (range Some) x \<partial>measure_pmf p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)
[PROOF STEP]
by(rule Bochner_Integration.integral_add)(auto 4 3 intro: integrable_real_mult_indicator measure_pmf.integrable_const_bound[where B=1] simp add: AE_measure_pmf_iff pmf_le_1)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x + pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
have "\<dots> = pmf p None + \<integral> x. indicator (range Some) x * pmf (f (the x)) None \<partial>measure_pmf p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None)
[PROOF STEP]
by(auto simp add: measure_measure_pmf_finite indicator_eq_0_iff intro!: Bochner_Integration.integral_cong)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation p (\<lambda>x. pmf (case None of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real {None} x) + measure_pmf.expectation p (\<lambda>x. pmf (case x of None \<Rightarrow> return_pmf None | Some x \<Rightarrow> f x) None * indicat_real (range Some) x) = pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
have "\<dots> = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None) = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
unfolding measure_spmf_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None) = pmf p None + (LINT x|distr (restrict_space (measure_pmf p) (range Some)) (count_space UNIV) the. pmf (f x) None)
[PROOF STEP]
by(subst integral_distr)(auto simp add: integral_restrict_space)
[PROOF STATE]
proof (state)
this:
pmf p None + measure_pmf.expectation p (\<lambda>x. indicat_real (range Some) x * pmf (f (the x)) None) = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)

goal (1 subgoal):
 1. pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
pmf (p \<bind> f) None = pmf p None + (LINT x|measure_spmf p. pmf (f x) None)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma val_of_divide':
  assumes "x \<in> carrier Zp"
  assumes "y \<in> carrier  Zp"
  assumes "y \<noteq> \<zero>"
  assumes "val_Zp x \<ge> val_Zp y"
  shows "val_Zp (divide x y) = val_Zp x - val_Zp y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. val_Zp (local.divide x y) = val_Zp x - val_Zp y
[PROOF STEP]
using Zp_def assms(1) assms(2) assms(3) assms(4) padic_integers.not_nonzero_Zp
    padic_integers.val_of_divide padic_integers_axioms
[PROOF STATE]
proof (prove)
using this:
Zp \<equiv> padic_int p
x \<in> carrier Zp
y \<in> carrier Zp
y \<noteq> \<zero>
val_Zp y \<le> val_Zp x
\<lbrakk>padic_integers ?p; ?x \<in> carrier (padic_int ?p); ?x \<notin> nonzero (padic_int ?p)\<rbrakk> \<Longrightarrow> ?x = \<zero>\<^bsub>padic_int ?p\<^esub>
\<lbrakk>padic_integers ?p; ?x \<in> carrier (padic_int ?p); ?y \<in> nonzero (padic_int ?p); padic_integers.val_Zp ?p ?y \<le> padic_integers.val_Zp ?p ?x\<rbrakk> \<Longrightarrow> padic_integers.val_Zp ?p (padic_integers.divide ?p ?x ?y) = padic_integers.val_Zp ?p ?x - padic_integers.val_Zp ?p ?y
padic_integers p

goal (1 subgoal):
 1. val_Zp (local.divide x y) = val_Zp x - val_Zp y
[PROOF STEP]
by blast


[STATEMENT]
lemma p1: "int p > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < int p
[PROOF STEP]
using nontriv [where ?'a = 'p] p
[PROOF STATE]
proof (prove)
using this:
1 < CARD('p)
p \<equiv> CARD('p)

goal (1 subgoal):
 1. 1 < int p
[PROOF STEP]
by simp