[STATEMENT]
lemma norm_normalize_set_of_vec:
  assumes "x \<noteq> 0"
  and "x \<in> normalize_set_of_vec X"
  shows "norm x = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm x = 1
[PROOF STEP]
using assms norm_normalize normalize_0
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)
x \<in> normalize_set_of_vec X
?x \<noteq> (0::?'a) \<Longrightarrow> norm (Projections.normalize ?x) = 1
(Projections.normalize ?x = (0::?'a)) = (?x = (0::?'a))

goal (1 subgoal):
 1. norm x = 1
[PROOF STEP]
unfolding normalize_set_of_vec_def
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)
x \<in> Projections.normalize ` X
?x \<noteq> (0::?'a) \<Longrightarrow> norm (Projections.normalize ?x) = 1
(Projections.normalize ?x = (0::?'a)) = (?x = (0::?'a))

goal (1 subgoal):
 1. norm x = 1
[PROOF STEP]
by blast


[STATEMENT]
lemma map_list_snoc_snoc: "
  length fs = length xs \<Longrightarrow>
  map_list (fs @ [f]) (xs @ [x]) =
  map_list fs xs @ [f x]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length fs = length xs \<Longrightarrow> map_list (fs @ [f]) (xs @ [x]) = map_list fs xs @ [f x]
[PROOF STEP]
by (simp add: map_list_append_append)


[STATEMENT]
lemma set_iterator_filter_correct :
  assumes it_OK: "set_iterator it S"
  shows "set_iterator (set_iterator_filter P it) {x. x \<in> S \<and> P x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_iterator (set_iterator_filter P it) {x \<in> S. P x}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_iterator (set_iterator_filter P it) {x \<in> S. P x}
[PROOF STEP]
note res' = set_iterator_genord_filter_correct [OF it_OK[unfolded set_iterator_def],
    of P]
[PROOF STATE]
proof (state)
this:
set_iterator_genord (set_iterator_filter P it) {x \<in> S. P x} (\<lambda>_ _. True)

goal (1 subgoal):
 1. set_iterator (set_iterator_filter P it) {x \<in> S. P x}
[PROOF STEP]
note res = set_iterator_intro [OF res']
[PROOF STATE]
proof (state)
this:
set_iterator (set_iterator_filter P it) {x \<in> S. P x}

goal (1 subgoal):
 1. set_iterator (set_iterator_filter P it) {x \<in> S. P x}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
set_iterator (set_iterator_filter P it) {x \<in> S. P x}

goal (1 subgoal):
 1. set_iterator (set_iterator_filter P it) {x \<in> S. P x}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set_iterator (set_iterator_filter P it) {x \<in> S. P x}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_real_code[code]: "algebraic_real (real_of x) = True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_real (real_of x) = True
[PROOF STEP]
proof (cases "info_real_alg x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a. info_real_alg x = Inl a \<Longrightarrow> algebraic_real (real_of x) = True
 2. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
case (Inl r)
[PROOF STATE]
proof (state)
this:
info_real_alg x = Inl r

goal (2 subgoals):
 1. \<And>a. info_real_alg x = Inl a \<Longrightarrow> algebraic_real (real_of x) = True
 2. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_real (real_of x) = True
[PROOF STEP]
using info_real_alg(2)[OF Inl]
[PROOF STATE]
proof (prove)
using this:
real_of x = real_of_rat r

goal (1 subgoal):
 1. algebraic_real (real_of x) = True
[PROOF STEP]
by (auto simp: algebraic_of_rat)
[PROOF STATE]
proof (state)
this:
algebraic_real (real_of x) = True

goal (1 subgoal):
 1. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
case (Inr pair)
[PROOF STATE]
proof (state)
this:
info_real_alg x = Inr pair

goal (1 subgoal):
 1. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
info_real_alg x = Inr pair
[PROOF STEP]
obtain p n where Inr: "info_real_alg x = Inr (p,n)"
[PROOF STATE]
proof (prove)
using this:
info_real_alg x = Inr pair

goal (1 subgoal):
 1. (\<And>p n. info_real_alg x = Inr (p, n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases pair, auto)
[PROOF STATE]
proof (state)
this:
info_real_alg x = Inr (p, n)

goal (1 subgoal):
 1. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
from info_real_alg(1)[OF Inr]
[PROOF STATE]
proof (chain)
picking this:
p represents real_of x \<and> card {y. y \<le> real_of x \<and> poly (real_of_int_poly p) y = 0} = n \<and> irreducible p
[PROOF STEP]
have "p represents (real_of x)"
[PROOF STATE]
proof (prove)
using this:
p represents real_of x \<and> card {y. y \<le> real_of x \<and> poly (real_of_int_poly p) y = 0} = n \<and> irreducible p

goal (1 subgoal):
 1. p represents real_of x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p represents real_of x

goal (1 subgoal):
 1. \<And>b. info_real_alg x = Inr b \<Longrightarrow> algebraic_real (real_of x) = True
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p represents real_of x

goal (1 subgoal):
 1. algebraic_real (real_of x) = True
[PROOF STEP]
by (auto simp: algebraic_altdef_ipoly)
[PROOF STATE]
proof (state)
this:
algebraic_real (real_of x) = True

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cross_ratio_swap_34:
  shows "cross_ratio p q s r = 1 / (cross_ratio p q r s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cross_ratio p q s r = 1 / cross_ratio p q r s
[PROOF STEP]
by (unfold cross_ratio_def) simp


[STATEMENT]
lemma subtopologyI:
  fixes S (structure)
  fixes T (structure)
  assumes H1: "\<And>s. s open \<Longrightarrow> \<exists>t. t open\<^bsub>T\<^esub> \<and> s = t \<inter> carrier"
  and     H2: "\<And>t. t open\<^bsub>T\<^esub> \<Longrightarrow> t \<inter> carrier open"
  shows "subtopology S T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subtopology S T
[PROOF STEP]
by (auto simp: subtopology_def intro: assms)


[STATEMENT]
lemma pred_of_set_set_fold_sup:
  "pred_of_set (set xs) = fold sup (List.map Predicate.single xs) bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pred_of_set (set xs) = fold (\<squnion>) (list.map single xs) \<bottom>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pred_of_set (set xs) = fold (\<squnion>) (list.map single xs) \<bottom>
[PROOF STEP]
interpret comp_fun_idem "sup :: 'a Predicate.pred \<Rightarrow> 'a Predicate.pred \<Rightarrow> 'a Predicate.pred"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comp_fun_idem (\<squnion>)
[PROOF STEP]
by (fact comp_fun_idem_sup)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pred_of_set (set xs) = fold (\<squnion>) (list.map single xs) \<bottom>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pred_of_set (set xs) = fold (\<squnion>) (list.map single xs) \<bottom>
[PROOF STEP]
by (simp add: pred_of_set_fold_sup fold_set_fold [symmetric])
[PROOF STATE]
proof (state)
this:
pred_of_set (set xs) = fold (\<squnion>) (list.map single xs) \<bottom>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iso_semicategory_refl:
  assumes "semicategory \<alpha> \<AA>"
  shows "\<AA> \<approx>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<AA> \<approx>\<^sub>S\<^sub>M\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>
[PROOF STEP]
proof(rule iso_semicategoryI[of _  _ _ \<open>smcf_id \<AA>\<close>])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dghm_id \<AA> : \<AA> \<mapsto>\<mapsto>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>
[PROOF STEP]
interpret semicategory \<alpha> \<AA>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. semicategory \<alpha> \<AA>
[PROOF STEP]
by (rule assms)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dghm_id \<AA> : \<AA> \<mapsto>\<mapsto>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>
[PROOF STEP]
show "smcf_id \<AA> : \<AA> \<mapsto>\<mapsto>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dghm_id \<AA> : \<AA> \<mapsto>\<mapsto>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>
[PROOF STEP]
by (simp add: smc_smcf_id_is_iso_semifunctor)
[PROOF STATE]
proof (state)
this:
dghm_id \<AA> : \<AA> \<mapsto>\<mapsto>\<^sub>S\<^sub>M\<^sub>C\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma R\<^sub>N_recurrence:
  assumes "0 < n" "p \<in> {0<..1}"
  shows   "R\<^sub>N n u l =
             do {
               b \<leftarrow> bernoulli_pmf p;
               if b then               \<comment> \<open>leftwards\<close>
                 map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l)
               else do {               \<comment> \<open>upwards\<close>
                 m \<leftarrow> binomial_pmf (n - 1) (1 - p);
                 map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)
               }
             }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
define B where "B = (\<lambda>b. insert (n-1) {x \<in> {..<n - 1}. \<not> b x})"
[PROOF STATE]
proof (state)
this:
B = (\<lambda>b. insert (n - 1) {x \<in> {..<n - 1}. \<not> b x})

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "R\<^sub>N n u l = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R\<^sub>N n u l = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n)
[PROOF STEP]
by (auto simp add: R\<^sub>N_def R_def SL\<^sub>N_def)
[PROOF STATE]
proof (state)
this:
R\<^sub>N n u l = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n)

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
R\<^sub>N n u l = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n)

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> = map_pmf (\<lambda>f. steps {..<n} f 0 u l)
                          (map_pmf (\<lambda>(y, f). f(n-1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))
[PROOF STEP]
have "{..<n} = insert (n - Suc 0) {..<n - 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {..<n} = insert (n - Suc 0) {..<n - 1}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. {..<n} = insert (n - Suc 0) {..<n - 1}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{..<n} = insert (n - Suc 0) {..<n - 1}

goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{..<n} = insert (n - Suc 0) {..<n - 1}
[PROOF STEP]
have "(Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p)) =
                map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p)
                     (Pi_pmf {..<n-1} 0 (\<lambda>_. geometric_pmf p)))"
[PROOF STATE]
proof (prove)
using this:
{..<n} = insert (n - Suc 0) {..<n - 1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p) = map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{..<n} = insert (n - Suc 0) {..<n - 1}
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p) = map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p)))
[PROOF STEP]
by (subst Pi_pmf_insert[of "{..<n-1}" "n-1" 0 "\<lambda>_. geometric_pmf p", symmetric])  (auto)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p) = map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p)))

goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Pi_pmf.Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p) = map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Pi_pmf.Pi_pmf {..<n} 0 (\<lambda>_. geometric_pmf p) = map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p)))

goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))
[PROOF STEP]
by (simp add: SL\<^sub>N_def SL_def)
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>f. steps {..<n} f 0 u l) (SL\<^sub>N n) = map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
        do { g \<leftarrow> geometric_pmf p;
             f \<leftarrow> SL\<^sub>N (n - 1);
             return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1)))) = geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))
[PROOF STEP]
by (simp add: case_prod_beta map_pmf_def pair_pmf_def)
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1)))) = geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>f. steps {..<n} f 0 u l) (map_pmf (\<lambda>(y, f). f(n - 1 := y)) (pair_pmf (geometric_pmf p) (SL\<^sub>N (n - 1)))) = geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
        do { b \<leftarrow>  bernoulli_pmf p;
             g \<leftarrow> if b then return_pmf 0 else map_pmf Suc (geometric_pmf p);
             f \<leftarrow> SL\<^sub>N (n - 1);
             return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
by (subst geometric_bind_pmf_unfold) (auto)
[PROOF STATE]
proof (state)
this:
geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
geometric_pmf p \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
        do { b \<leftarrow> bernoulli_pmf p;
             if b
               then do { g \<leftarrow> return_pmf 0;
                         f \<leftarrow> SL\<^sub>N (n - 1);
                         return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l) }
               else do { g \<leftarrow> map_pmf Suc (geometric_pmf p);
                         f \<leftarrow> SL\<^sub>N (n - 1);
                         return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l) }}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = bernoulli_pmf p \<bind> (\<lambda>b. if b then return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) else map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
by (subst bind_pmf_if') (auto)
[PROOF STATE]
proof (state)
this:
bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = bernoulli_pmf p \<bind> (\<lambda>b. if b then return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) else map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bernoulli_pmf p \<bind> (\<lambda>b. (if b then return_pmf 0 else map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = bernoulli_pmf p \<bind> (\<lambda>b. if b then return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) else map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "do { g \<leftarrow> return_pmf 0;
                       f \<leftarrow> SL\<^sub>N (n - 1);
                       return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l) }  =
              do { f \<leftarrow> SL\<^sub>N (n - 1);
                        return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l) }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l))
[PROOF STEP]
by (subst bind_return_pmf) auto
[PROOF STATE]
proof (state)
this:
return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
return_pmf 0 \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
have I: "{..<n} - {n - Suc 0} = {..<n - Suc 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {..<n} - {n - Suc 0} = {..<n - Suc 0}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
{..<n} - {n - Suc 0} = {..<n - Suc 0}

goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
have "Max {..<n} = n - Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {..<n} = n - Suc 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Max {..<n} = n - Suc 0
[PROOF STEP]
by (intro Max_eqI) (auto)
[PROOF STATE]
proof (state)
this:
Max {..<n} = n - Suc 0

goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Max {..<n} = n - Suc 0
[PROOF STEP]
have "steps {..<n} (f(n - 1 := 0)) 0 u l = l + steps {..<n - 1} f 0 u l" for f
[PROOF STATE]
proof (prove)
using this:
Max {..<n} = n - Suc 0

goal (1 subgoal):
 1. steps {..<n} (f(n - 1 := 0)) 0 u l = l + steps {..<n - 1} f 0 u l
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Max {..<n} = n - Suc 0
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. steps {..<n} (f(n - 1 := 0)) 0 u l = l + steps {..<n - 1} f 0 u l
[PROOF STEP]
by (subst steps.simps) (auto intro!: steps_cong simp add: I simp add: Let_def)
[PROOF STATE]
proof (state)
this:
steps {..<n} (?f3(n - 1 := 0)) 0 u l = l + steps {..<n - 1} ?f3 0 u l

goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
steps {..<n} (?f3(n - 1 := 0)) 0 u l = l + steps {..<n - 1} ?f3 0 u l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
steps {..<n} (?f3(n - 1 := 0)) 0 u l = l + steps {..<n - 1} ?f3 0 u l

goal (1 subgoal):
 1. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))
[PROOF STEP]
by (auto simp add: add_ac map_pmf_def)
[PROOF STATE]
proof (state)
this:
SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := 0)) 0 u l)) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> = map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1))) = map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l)
[PROOF STEP]
unfolding R\<^sub>N_def R_def SL\<^sub>N_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL {..<n - 1})) = map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL {..<n - 1}))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1))) = map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l)

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (\<lambda>n. n + l) (map_pmf (\<lambda>f. steps {..<n - 1} f 0 u l) (SL\<^sub>N (n - 1))) = map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l)

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "map_pmf Suc (geometric_pmf p) \<bind>
             (\<lambda>g. SL\<^sub>N (n - 1) \<bind>
             (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))
             =
             Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind>
             (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind>
             (\<lambda>g. Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind>
             (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
unfolding SL\<^sub>N_def SL_def
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {..<n - 1} 0 (\<lambda>_. geometric_pmf p) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))
[PROOF STEP]
by (subst Pi_pmf_geometric_filter) (auto)
[PROOF STATE]
proof (state)
this:
map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. SL\<^sub>N (n - 1) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l))))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
             do {
             b \<leftarrow> Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p);
             f \<leftarrow> Pi_pmf (insert (n-1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p));
             return_pmf (steps {..<n} f 0 u l)}" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l)))
[PROOF STEP]
by (subst Pi_pmf_insert') (auto)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. map_pmf Suc (geometric_pmf p) \<bind> (\<lambda>g. Pi_pmf.Pi_pmf {x \<in> {..<n - 1}. \<not> b x} 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (f(n - 1 := g)) 0 u l)))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
             do {
               b \<leftarrow> Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p);
               f \<leftarrow> Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p));
               return_pmf (steps {..<n} (\<lambda>x. if x \<in> (B b) then f x else 0) 0 u l)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l)))
[PROOF STEP]
by (subst Pi_pmf_default_swap[symmetric, of _ _ _ 1]) (auto simp add: map_pmf_def B_def)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) 0 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} f 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
             do {
               b \<leftarrow> Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p);
               f \<leftarrow> SL (B b);
               return_pmf (steps {..<n} (\<lambda>x. if x \<in> (B b) then Suc (f x) else 0) 0 u l)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))
[PROOF STEP]
have *: "(Suc \<circ> f) x = Suc (f x)" for x and f::"nat \<Rightarrow> nat"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Suc \<circ> f) x = Suc (f x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(Suc \<circ> ?f3) ?x3 = Suc (?f3 ?x3)

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))
[PROOF STEP]
have "(\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then (Suc \<circ> f) x else 0) 0 u l)) =
          (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))" for b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then (Suc \<circ> f) x else 0) 0 u l)) = (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))
[PROOF STEP]
by (subst *) (simp)
[PROOF STATE]
proof (state)
this:
(\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then (Suc \<circ> f) x else 0) 0 u l)) = (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (f x) else 0) 0 u l))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then (Suc \<circ> f) x else 0) 0 u l)) = (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (f x) else 0) 0 u l))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then (Suc \<circ> f) x else 0) 0 u l)) = (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (f x) else 0) 0 u l))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))
[PROOF STEP]
by (subst Pi_pmf_map[of _ _ 0]) (auto simp add: map_pmf_def B_def SL_def)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. Pi_pmf.Pi_pmf (B b) 1 (\<lambda>_. map_pmf Suc (geometric_pmf p)) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then f x else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> =
               do {
               b \<leftarrow> Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p);
               r \<leftarrow> R (B b) u l;
               return_pmf (u + r)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
have "steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l"
      for f b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
have "Max {..<n} = n - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {..<n} = n - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Max {..<n} = n - 1
[PROOF STEP]
by (intro Max_eqI) auto
[PROOF STATE]
proof (state)
this:
Max {..<n} = n - 1

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Max {..<n} = n - 1
[PROOF STEP]
have "steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l =
              u + (steps {..<n} (\<lambda>x. if x \<in> (B b) then Suc (f x) else 0) 1 u l)"
[PROOF STATE]
proof (prove)
using this:
Max {..<n} = n - 1

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
using this:
Max {..<n} = n - 1

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> insert (n - 1) {x \<in> {..<n - 1}. \<not> b x} then Suc (f x) else 0) 0 u l = u + steps {..<n} (\<lambda>x. if x \<in> insert (n - 1) {x \<in> {..<n - 1}. \<not> b x} then Suc (f x) else 0) 1 u l
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Max {..<n} = n - 1
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> insert (n - 1) {x \<in> {..<n - 1}. \<not> b x} then Suc (f x) else 0) 0 u l = u + steps {..<n} (\<lambda>x. if x \<in> insert (n - 1) {x \<in> {..<n - 1}. \<not> b x} then Suc (f x) else 0) 1 u l
[PROOF STEP]
by (subst steps.simps) (auto simp add: Let_def)
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
have "steps {..<n} (\<lambda>x. if x \<in> (B b) then Suc (f x) else 0) 1 u l =
                   steps (B b) (\<lambda>x. if x \<in> (B b) then Suc (f x) else 0) 1 u l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l
[PROOF STEP]
have "{x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. {x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. {x \<in> {..<n}. 1 \<le> (if x \<in> insert (n - 1) {x \<in> {..<n - 1}. \<not> b x} then Suc (f x) else 0)} = insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x \<in> {..<n}. 1 \<le> (if x \<in> B b then Suc (f x) else 0)} = B b

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l
[PROOF STEP]
by (subst steps_smaller_set[of _ 1]) auto
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
have "\<dots> = steps (B b) (\<lambda>x. f x + 1) 1 u l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. f x + 1) 1 u l
[PROOF STEP]
by (rule steps_cong) (auto)
[PROOF STATE]
proof (state)
this:
steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. f x + 1) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
steps (B b) (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 1 u l = steps (B b) (\<lambda>x. f x + 1) 1 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
have "\<dots> = steps (B b) f 0 u l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. steps (B b) (\<lambda>x. f x + 1) 1 u l = steps (B b) f 0 u l
[PROOF STEP]
by (subst (2) steps_f_add'[of _ _ _ _ _ 1]) simp
[PROOF STATE]
proof (state)
this:
steps (B b) (\<lambda>x. f x + 1) 1 u l = steps (B b) f 0 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l

goal (1 subgoal):
 1. steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l = u + steps (B b) f 0 u l

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (?f3 x) else 0) 0 u l = u + steps (B ?b3) ?f3 0 u l

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (?f3 x) else 0) 0 u l = u + steps (B ?b3) ?f3 0 u l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
steps {..<n} (\<lambda>x. if x \<in> B ?b3 then Suc (?f3 x) else 0) 0 u l = u + steps (B ?b3) ?f3 0 u l

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
by (simp add: R_def map_pmf_def)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. SL (B b) \<bind> (\<lambda>f. return_pmf (steps {..<n} (\<lambda>x. if x \<in> B b then Suc (f x) else 0) 0 u l))) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> = do {
                   b \<leftarrow> Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p));
                   let m = 1 + card {x. x < n - 1 \<and> b x};
                   r \<leftarrow> R {..<m} u l;
                   return_pmf (u + r)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
have *: "card (insert (n - Suc 0) {x. x < n - 1 \<and> b x}) =
              (Suc (card {x. x < n - 1 \<and> b x}))" for b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (insert (n - Suc 0) {x. x < n - 1 \<and> b x}) = Suc (card {x. x < n - 1 \<and> b x})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. card (insert (n - Suc 0) {x. x < n - 1 \<and> b x}) = Suc (card {x. x < n - 1 \<and> b x})
[PROOF STEP]
by (auto simp add: card_insert_if)
[PROOF STATE]
proof (state)
this:
card (insert (n - Suc 0) {x. x < n - 1 \<and> ?b3 x}) = Suc (card {x. x < n - 1 \<and> ?b3 x})

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
have "Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) =
              Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p)))
[PROOF STEP]
by (subst bernoulli_pmf_Not) auto
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p)))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p)))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
have "\<dots> = map_pmf ((\<circ>) Not) (Pi_pmf {..<n - 1}  False (\<lambda>_. bernoulli_pmf (1 - p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p))) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p))) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))
[PROOF STEP]
by (subst Pi_pmf_map[of _ _ False]) auto
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. map_pmf Not (bernoulli_pmf (1 - p))) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
using this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
using assms *
[PROOF STATE]
proof (prove)
using this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) = map_pmf ((\<circ>) Not) (Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)))
0 < n
p \<in> {0<..1}
card (insert (n - Suc 0) {x. x < n - 1 \<and> ?b3 x}) = Suc (card {x. x < n - 1 \<and> ?b3 x})

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (insert (n - 1) {x \<in> {..<n - 1}. \<not> b x}) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))
[PROOF STEP]
by (subst R_R\<^sub>N) (auto simp add: R_R\<^sub>N map_pmf_def)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} True (\<lambda>_. bernoulli_pmf p) \<bind> (\<lambda>b. R (B b) u l \<bind> (\<lambda>r. return_pmf (u + r))) = Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
have "\<dots> = binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r))) = binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
p \<in> {0<..1}

goal (1 subgoal):
 1. Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r))) = binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l))
[PROOF STEP]
by (subst binomial_pmf_altdef'[where A = "{..<n - 1}" and dflt = "False"])
      (auto simp add: R\<^sub>N_def R_def SL_def map_pmf_def ac_simps)
[PROOF STATE]
proof (state)
this:
Pi_pmf.Pi_pmf {..<n - 1} False (\<lambda>_. bernoulli_pmf (1 - p)) \<bind> (\<lambda>b. let m = 1 + card {x. x < n - 1 \<and> b x} in R {..<m} u l \<bind> (\<lambda>r. return_pmf (u + r))) = binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))

goal (1 subgoal):
 1. R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
R\<^sub>N n u l = bernoulli_pmf p \<bind> (\<lambda>b. if b then map_pmf (\<lambda>n. n + l) (R\<^sub>N (n - 1) u l) else binomial_pmf (n - 1) (1 - p) \<bind> (\<lambda>m. map_pmf (\<lambda>n. n + u) (R\<^sub>N (m + 1) u l)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma P5_b: "x r\<rightarrow> y = 1 \<Longrightarrow> y r\<rightarrow> z = 1 \<Longrightarrow> x r\<rightarrow> z = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x r\<rightarrow> y = (1::'a); y r\<rightarrow> z = (1::'a)\<rbrakk> \<Longrightarrow> x r\<rightarrow> z = (1::'a)
[PROOF STEP]
apply (cut_tac a = x and b = y and c = z in W3b)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x r\<rightarrow> y = (1::'a); y r\<rightarrow> z = (1::'a); (x r\<rightarrow> y) r\<rightarrow> (y r\<rightarrow> z) l\<rightarrow> x r\<rightarrow> z = (1::'a)\<rbrakk> \<Longrightarrow> x r\<rightarrow> z = (1::'a)
[PROOF STEP]
by simp


[STATEMENT]
lemma has_real_derivative_iff:
  fixes f :: "real \<Rightarrow> real"
  shows "(\<exists>c. (f has_real_derivative c) F) = (\<exists>D. (f has_derivative D) F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>c. (f has_real_derivative c) F) = (\<exists>D. (f has_derivative D) F)
[PROOF STEP]
by (metis has_field_derivative_def has_real_derivative)


[STATEMENT]
lemma mset_trees_empty_iff[simp]: "mset_trees ts = {#} \<longleftrightarrow> ts=[]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mset_trees ts = {#}) = (ts = [])
[PROOF STEP]
by (auto simp: mset_trees_def)


[STATEMENT]
lemma rule_states_code [code]:
  "rule_states \<Delta> = |\<Union>| ((\<lambda> r. finsert (r_rhs r) (fset_of_list (r_lhs_states r))) |`| \<Delta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rule_states \<Delta> = |\<Union>| ((\<lambda>r. finsert (r_rhs r) (fset_of_list (r_lhs_states r))) |`| \<Delta>)
[PROOF STEP]
unfolding rule_states_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rule_arg_states \<Delta> |\<union>| rule_target_states \<Delta> = |\<Union>| ((\<lambda>r. finsert (r_rhs r) (fset_of_list (r_lhs_states r))) |`| \<Delta>)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma sqrt_int_main'_code[code]: "sqrt_int_main' x n = (let x2 = x * x in if x2 \<le> n then (x, x2 = n)
    else sqrt_int_main' ((n div x + x) div 2) n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt_int_main' x n = (let x2 = x * x in if x2 \<le> n then (x, x2 = n) else sqrt_int_main' ((n div x + x) div 2) n)
[PROOF STEP]
using root_int_main'.simps[of 1 1 2 x n]
[PROOF STATE]
proof (prove)
using this:
root_int_main' 1 1 2 x n = (let xpm = x ^ 1; xp = xpm * x in if xp \<le> n then (x, xp = n) else root_int_main' 1 1 2 ((n div xpm + x * 1) div 2) n)

goal (1 subgoal):
 1. sqrt_int_main' x n = (let x2 = x * x in if x2 \<le> n then (x, x2 = n) else sqrt_int_main' ((n div x + x) div 2) n)
[PROOF STEP]
unfolding Let_def
[PROOF STATE]
proof (prove)
using this:
root_int_main' 1 1 2 x n = (if x ^ 1 * x \<le> n then (x, x ^ 1 * x = n) else root_int_main' 1 1 2 ((n div x ^ 1 + x * 1) div 2) n)

goal (1 subgoal):
 1. sqrt_int_main' x n = (if x * x \<le> n then (x, x * x = n) else sqrt_int_main' ((n div x + x) div 2) n)
[PROOF STEP]
by auto


[STATEMENT]
lemma False_epsclosure_conc[iff]:
 "((False # p, q) : (eps (conc L R))\<^sup>*) =
 (\<exists>r. q = False # r \<and> (p, r) : (eps R)\<^sup>*)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((False # p, q) \<in> (eps (RegExp2NAe.conc L R))\<^sup>*) = (\<exists>r. q = False # r \<and> (p, r) \<in> (eps R)\<^sup>*)
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (False # p, q) \<in> (eps (RegExp2NAe.conc L R))\<^sup>* \<Longrightarrow> \<exists>r. q = False # r \<and> (p, r) \<in> (eps R)\<^sup>*
 2. \<exists>r. q = False # r \<and> (p, r) \<in> (eps R)\<^sup>* \<Longrightarrow> (False # p, q) \<in> (eps (RegExp2NAe.conc L R))\<^sup>*
[PROOF STEP]
apply (blast dest: lemma1b')
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>r. q = False # r \<and> (p, r) \<in> (eps R)\<^sup>* \<Longrightarrow> (False # p, q) \<in> (eps (RegExp2NAe.conc L R))\<^sup>*
[PROOF STEP]
apply (blast dest: lemma2b')
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in Module) linmap_im_of_lincombTr:"\<lbrakk>ideal R A; R module N;
      f \<in> mHom R M N; H \<subseteq> carrier M\<rbrakk> \<Longrightarrow>
      s \<in> {j. j \<le> (n::nat)} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow>
      f (l_comb R M n s g) = l_comb R N n s (cmp f g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)
[PROOF STEP]
apply (induct_tac n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> 0} \<rightarrow> A \<and> g \<in> {j. j \<le> 0} \<rightarrow> H \<longrightarrow> f (l_comb R M 0 s g) = l_comb R N 0 s (cmp f g)
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> Suc n} \<rightarrow> A \<and> g \<in> {j. j \<le> Suc n} \<rightarrow> H \<longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (rule impI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> 0} \<rightarrow> A \<and> g \<in> {j. j \<le> 0} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (l_comb R M 0 s g) = l_comb R N 0 s (cmp f g)
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> Suc n} \<rightarrow> A \<and> g \<in> {j. j \<le> Suc n} \<rightarrow> H \<longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (erule conjE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> 0} \<rightarrow> A; g \<in> {j. j \<le> 0} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (l_comb R M 0 s g) = l_comb R N 0 s (cmp f g)
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> Suc n} \<rightarrow> A \<and> g \<in> {j. j \<le> Suc n} \<rightarrow> H \<longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (simp add:l_comb_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s 0 \<in> A; g 0 \<in> H\<rbrakk> \<Longrightarrow> f (s 0 \<cdot>\<^sub>s g 0) = s 0 \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g 0
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> Suc n} \<rightarrow> A \<and> g \<in> {j. j \<le> Suc n} \<rightarrow> H \<longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (cut_tac m = "g 0" and f = f and a = "s 0" in mHom_lin [of N],
        assumption+,
        simp add:Pi_def subsetD, assumption,
        cut_tac sc_Ring,
        simp add:Pi_def Ring.ideal_subset, simp add:cmp_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g)\<rbrakk> \<Longrightarrow> s \<in> {j. j \<le> Suc n} \<rightarrow> A \<and> g \<in> {j. j \<le> Suc n} \<rightarrow> H \<longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (rule impI, erule conjE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> A \<and> g \<in> {j. j \<le> n} \<rightarrow> H \<longrightarrow> f (l_comb R M n s g) = l_comb R N n s (cmp f g); s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (frule_tac f = s in func_pre,
        frule_tac f = g in func_pre, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (l_comb R M n s g) = l_comb R N n s (cmp f g); s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (l_comb R M (Suc n) s g) = l_comb R N (Suc n) s (cmp f g)
[PROOF STEP]
apply (simp add:l_comb_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n \<plusminus> s (Suc n) \<cdot>\<^sub>s g (Suc n)) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n \<plusminus>\<^bsub>N\<^esub> s (Suc n) \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g (Suc n)
[PROOF STEP]
apply (subst mHom_add[of N f], assumption+)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n \<in> carrier M
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> s (Suc n) \<cdot>\<^sub>s g (Suc n) \<in> carrier M
 3. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) \<plusminus>\<^bsub>N\<^esub> f (s (Suc n) \<cdot>\<^sub>s g (Suc n)) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n \<plusminus>\<^bsub>N\<^esub> s (Suc n) \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g (Suc n)
[PROOF STEP]
apply (rule nsum_mem,
        rule allI, rule impI, rule sc_mem,
        cut_tac sc_Ring,
        simp add:Pi_def Ring.ideal_subset,
        simp add:Pi_def subsetD)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> s (Suc n) \<cdot>\<^sub>s g (Suc n) \<in> carrier M
 2. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H\<rbrakk> \<Longrightarrow> f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) \<plusminus>\<^bsub>N\<^esub> f (s (Suc n) \<cdot>\<^sub>s g (Suc n)) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n \<plusminus>\<^bsub>N\<^esub> s (Suc n) \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g (Suc n)
[PROOF STEP]
apply (rule sc_mem,
         cut_tac sc_Ring,
        simp add:Pi_def Ring.ideal_subset,
        simp add:Pi_def subsetD, simp,
        frule_tac x = "Suc n" and A = "{j. j \<le> Suc n}" and f = s and
                  B = A in funcset_mem, simp,
        cut_tac sc_Ring,
        frule_tac h = "s (Suc n)" in Ring.ideal_subset[of R A], assumption+,
        frule_tac x = "Suc n" and A = "{j. j \<le> Suc n}" and f = g and
                  B = H in funcset_mem, simp,
        frule_tac c = "g (Suc n)" in subsetD[of H "carrier M"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>ideal R A; R module N; f \<in> mHom R M N; H \<subseteq> carrier M; f (\<Sigma>\<^sub>e M (\<lambda>j. s j \<cdot>\<^sub>s g j) n) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n; s \<in> {j. j \<le> Suc n} \<rightarrow> A; g \<in> {j. j \<le> Suc n} \<rightarrow> H; s \<in> {j. j \<le> n} \<rightarrow> A; g \<in> {j. j \<le> n} \<rightarrow> H; s (Suc n) \<in> A; Ring R; s (Suc n) \<in> carrier R; g (Suc n) \<in> H; g (Suc n) \<in> carrier M\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n \<plusminus>\<^bsub>N\<^esub> f (s (Suc n) \<cdot>\<^sub>s g (Suc n)) = \<Sigma>\<^sub>e N (\<lambda>j. s j \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g j) n \<plusminus>\<^bsub>N\<^esub> s (Suc n) \<cdot>\<^sub>s\<^bsub>N\<^esub> cmp f g (Suc n)
[PROOF STEP]
apply (simp add:mHom_lin cmp_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma norm_bfun_one[simp]: "norm (1 :: 'a \<Rightarrow>\<^sub>b real) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm 1 = 1
[PROOF STEP]
unfolding norm_bfun_def'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Squnion>x. norm (apply_bfun 1 x)) = 1
[PROOF STEP]
by auto


[STATEMENT]
lemma awalk_app_isoD:
  assumes w: "pre_digraph.awalk (app_iso hom G) u p v" and hom: "digraph_isomorphism hom"
  shows "awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)
[PROOF STEP]
interpret H: wf_digraph "app_iso hom G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_digraph (app_iso hom G)
[PROOF STEP]
using hom
[PROOF STATE]
proof (prove)
using this:
digraph_isomorphism hom

goal (1 subgoal):
 1. wf_digraph (app_iso hom G)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
H.awalk u p v
digraph_isomorphism hom
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
H.awalk u p v
digraph_isomorphism hom

goal (1 subgoal):
 1. awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)
[PROOF STEP]
by (induct p arbitrary: u)
       (force simp: awalk_simps H.awalk_simps iso_verts_head iso_verts_tail)+
[PROOF STATE]
proof (state)
this:
awalk (iso_verts (inv_iso hom) u) (map (iso_arcs (inv_iso hom)) p) (iso_verts (inv_iso hom) v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mset_subset_diff_self: "c \<in># B \<Longrightarrow> B - {#c#} \<subset># B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<in># B \<Longrightarrow> B - {#c#} \<subset># B
[PROOF STEP]
by (auto simp: subset_mset_def elim: mset_add)


[STATEMENT]
lemma nonzero_mod_p: "0 < x \<Longrightarrow> x < int p \<Longrightarrow> [x \<noteq> 0](mod p)"
  for x :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < x; x < int p\<rbrakk> \<Longrightarrow> [x \<noteq> 0] (mod int p)
[PROOF STEP]
by (simp add: cong_def)


[STATEMENT]
lemma monotone_if_fun [partial_function_mono]:
  "\<lbrakk> monotone (fun_ord orda) (fun_ord ordb) F; monotone (fun_ord orda) (fun_ord ordb) G \<rbrakk>
  \<Longrightarrow> monotone (fun_ord orda) (fun_ord ordb) (\<lambda>f n. if c n then F f n else G f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>monotone (fun_ord orda) (fun_ord ordb) F; monotone (fun_ord orda) (fun_ord ordb) G\<rbrakk> \<Longrightarrow> monotone (fun_ord orda) (fun_ord ordb) (\<lambda>f n. if c n then F f n else G f n)
[PROOF STEP]
by(simp add: monotone_def fun_ord_def)


[STATEMENT]
lemma vfield_vsubset_VUnion2: "\<F>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> \<Union>\<^sub>\<circ>(\<Union>\<^sub>\<circ>r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<F>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> \<Union>\<^sub>\<circ> (\<Union>\<^sub>\<circ> r)
[PROOF STEP]
using vdomain_vsubset_VUnion2 vrange_vsubset_VUnion2
[PROOF STATE]
proof (prove)
using this:
\<D>\<^sub>\<circ> ?r \<subseteq>\<^sub>\<circ> \<Union>\<^sub>\<circ> (\<Union>\<^sub>\<circ> ?r)
\<R>\<^sub>\<circ> ?r \<subseteq>\<^sub>\<circ> \<Union>\<^sub>\<circ> (\<Union>\<^sub>\<circ> ?r)

goal (1 subgoal):
 1. \<F>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> \<Union>\<^sub>\<circ> (\<Union>\<^sub>\<circ> r)
[PROOF STEP]
by (auto simp: app_vfield_def)


[STATEMENT]
lemma width_add1:"\<Turnstile>((\<^bold>\<omega> = x) \<^bold>\<smile> (\<^bold>\<omega> = y) \<^bold>\<rightarrow> \<^bold>\<omega> = x+y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>ts v. (\<exists>va u. v=va--u \<and> |lan va| = x \<and> |lan u| = y) \<longrightarrow> |lan v| = x + y
[PROOF STEP]
using vertical_chop_add1
[PROOF STATE]
proof (prove)
using this:
?v=?u--?w \<longrightarrow> |lan ?v| = |lan ?u| + |lan ?w|

goal (1 subgoal):
 1. \<forall>ts v. (\<exists>va u. v=va--u \<and> |lan va| = x \<and> |lan u| = y) \<longrightarrow> |lan v| = x + y
[PROOF STEP]
by fastforce


[STATEMENT]
lemma poly_power_card_as_sum_of_monoms:
  fixes h :: "'a mod_ring poly"
  shows "h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a)*i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
have "h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a)
[PROOF STEP]
by (simp add: poly_as_sum_of_monoms)
[PROOF STATE]
proof (state)
this:
h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a)

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a)

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
have "... = (\<Sum>i\<le>degree h. (monom (coeff h i) i) ^ CARD('a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i ^ CARD('a))
[PROOF STEP]
by (simp add: power_poly_sum_mod_ring)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i ^ CARD('a))

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>degree h. monom (coeff h i) i) ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) i ^ CARD('a))

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
have "... = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a)*i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>degree h. monom (coeff h i) i ^ CARD('a)) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
proof (rule sum.cong, rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..degree h} \<Longrightarrow> monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..degree h} \<Longrightarrow> monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)
[PROOF STEP]
assume x: "x \<in> {..degree h}"
[PROOF STATE]
proof (state)
this:
x \<in> {..degree h}

goal (1 subgoal):
 1. \<And>x. x \<in> {..degree h} \<Longrightarrow> monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)
[PROOF STEP]
show "monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)
[PROOF STEP]
by (unfold poly_eq_iff, auto simp add: monom_power)
[PROOF STATE]
proof (state)
this:
monom (coeff h x) x ^ CARD('a) = monom (coeff h x) (CARD('a) * x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>degree h. monom (coeff h i) i ^ CARD('a)) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))

goal (1 subgoal):
 1. h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
h ^ CARD('a) = (\<Sum>i\<le>degree h. monom (coeff h i) (CARD('a) * i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complete_iff_height:
  "complete kdt \<longleftrightarrow> (min_height kdt = height kdt)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. KD_Tree.complete kdt = (min_height kdt = height kdt)
[PROOF STEP]
apply (induction kdt)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. KD_Tree.complete (Leaf x) = (min_height (Leaf x) = height (Leaf x))
 2. \<And>x1a x2 kdt1 kdt2. \<lbrakk>KD_Tree.complete kdt1 = (min_height kdt1 = height kdt1); KD_Tree.complete kdt2 = (min_height kdt2 = height kdt2)\<rbrakk> \<Longrightarrow> KD_Tree.complete (Node x1a x2 kdt1 kdt2) = (min_height (Node x1a x2 kdt1 kdt2) = height (Node x1a x2 kdt1 kdt2))
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1a x2 kdt1 kdt2. \<lbrakk>KD_Tree.complete kdt1 = (min_height kdt1 = height kdt1); KD_Tree.complete kdt2 = (min_height kdt2 = height kdt2)\<rbrakk> \<Longrightarrow> KD_Tree.complete (Node x1a x2 kdt1 kdt2) = (min_height (Node x1a x2 kdt1 kdt2) = height (Node x1a x2 kdt1 kdt2))
[PROOF STEP]
apply (simp add: min_def max_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>kdt1 kdt2. \<lbrakk>KD_Tree.complete kdt1 = (min_height kdt1 = height kdt1); KD_Tree.complete kdt2 = (min_height kdt2 = height kdt2)\<rbrakk> \<Longrightarrow> (min_height kdt1 \<le> min_height kdt2 \<longrightarrow> (height kdt1 \<le> height kdt2 \<longrightarrow> (min_height kdt1 = height kdt1 \<and> min_height kdt2 = height kdt2 \<and> height kdt1 = height kdt2) = (min_height kdt1 = height kdt2)) \<and> (\<not> height kdt1 \<le> height kdt2 \<longrightarrow> min_height kdt1 \<noteq> height kdt1)) \<and> (\<not> min_height kdt1 \<le> min_height kdt2 \<longrightarrow> (height kdt1 \<le> height kdt2 \<longrightarrow> (min_height kdt1 = height kdt1 \<and> min_height kdt2 = height kdt2 \<and> height kdt1 = height kdt2) = (min_height kdt2 = height kdt2)) \<and> (\<not> height kdt1 \<le> height kdt2 \<longrightarrow> min_height kdt2 \<noteq> height kdt1))
[PROOF STEP]
by (metis le_antisym le_trans min_height_le_height)


[STATEMENT]
lemma cut_less_cut_greater_ident: "
  \<lbrakk> t2 \<le> t1; I \<inter> {t1..t2} = {} \<rbrakk> \<Longrightarrow> I \<down>< t1 \<union> I \<down>> t2 = I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t2 \<le> t1; I \<inter> {t1..t2} = {}\<rbrakk> \<Longrightarrow> I \<down>< t1 \<union> I \<down>> t2 = I
[PROOF STEP]
by fastforce