[STATEMENT]
lemma insort_aux_le: "\<forall>x\<in>set nxs. n \<le> fst x \<Longrightarrow> \<forall>x\<in>set mys. m \<le> fst x \<Longrightarrow> n \<le> m \<Longrightarrow>
  insort n (sort (map fst nxs @ m # map fst mys)) = n # sort (map fst nxs @ m # map fst mys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>set nxs. n \<le> fst x; \<forall>x\<in>set mys. m \<le> fst x; n \<le> m\<rbrakk> \<Longrightarrow> insort n (sort (map fst nxs @ m # map fst mys)) = n # sort (map fst nxs @ m # map fst mys)
[PROOF STEP]
by (induction nxs) (auto simp: insort_is_Cons insort_left_comm)


[STATEMENT]
lemma integrable_MIN:
  fixes f:: "_ \<Rightarrow> _ \<Rightarrow> real"
  shows "\<lbrakk> finite I;  I \<noteq> {}; \<And>i. i \<in> I \<Longrightarrow> integrable M (f i) \<rbrakk>
   \<Longrightarrow> integrable M (\<lambda>x. MIN i\<in>I. f i x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; \<And>i. i \<in> I \<Longrightarrow> integrable M (f i)\<rbrakk> \<Longrightarrow> integrable M (\<lambda>x. MIN i\<in>I. f i x)
[PROOF STEP]
by (induct rule: finite_ne_induct) simp+


[STATEMENT]
lemma uncountable_half_open_interval_2: "uncountable {a<..b} \<longleftrightarrow> a < b" for a b :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uncountable {a<..b} = (a < b)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. uncountable {a<..b} \<Longrightarrow> a < b
 2. \<lbrakk>a < b; countable {a<..b}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
using atLeastLessThan_empty_iff
[PROOF STATE]
proof (prove)
using this:
({?a..<?b} = {}) = (\<not> ?a < ?b)

goal (2 subgoals):
 1. uncountable {a<..b} \<Longrightarrow> a < b
 2. \<lbrakk>a < b; countable {a<..b}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a < b; countable {a<..b}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
using uncountable_open_interval [of a b]
[PROOF STATE]
proof (prove)
using this:
uncountable {a<..<b} = (a < b)

goal (1 subgoal):
 1. \<lbrakk>a < b; countable {a<..b}\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (metis countable_Un_iff ivl_disj_un_singleton(4))
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma filterlim_at_left_to_right:
  "filterlim f F (at_left a) \<longleftrightarrow> filterlim (\<lambda>x. f (- x)) F (at_right (-a))"
  for a :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim f F (at_left a) = (LIM x at_right (- a). f (- x) :> F)
[PROOF STEP]
unfolding filterlim_def filtermap_filtermap at_left_minus[of a]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (filtermap (\<lambda>x. f (- x)) (at_right (- a)) \<le> F) = (filtermap (\<lambda>x. f (- x)) (at_right (- a)) \<le> F)
[PROOF STEP]
..


[STATEMENT]
lemma binary_chinese_remainder_nat:
  fixes m1 m2 :: nat
  assumes a: "coprime m1 m2"
  shows "\<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
have "\<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
from cong_solve_coprime_nat [OF a]
[PROOF STATE]
proof (chain)
picking this:
\<exists>x. [m1 * x = Suc 0] (mod m2)
[PROOF STEP]
obtain x1 where 1: "[m1 * x1 = 1] (mod m2)"
[PROOF STATE]
proof (prove)
using this:
\<exists>x. [m1 * x = Suc 0] (mod m2)

goal (1 subgoal):
 1. (\<And>x1. [m1 * x1 = 1] (mod m2) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[m1 * x1 = 1] (mod m2)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
from a
[PROOF STATE]
proof (chain)
picking this:
coprime m1 m2
[PROOF STEP]
have b: "coprime m2 m1"
[PROOF STATE]
proof (prove)
using this:
coprime m1 m2

goal (1 subgoal):
 1. coprime m2 m1
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
coprime m2 m1

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
from cong_solve_coprime_nat [OF b]
[PROOF STATE]
proof (chain)
picking this:
\<exists>x. [m2 * x = Suc 0] (mod m1)
[PROOF STEP]
obtain x2 where 2: "[m2 * x2 = 1] (mod m1)"
[PROOF STATE]
proof (prove)
using this:
\<exists>x. [m2 * x = Suc 0] (mod m1)

goal (1 subgoal):
 1. (\<And>x2. [m2 * x2 = 1] (mod m1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[m2 * x2 = 1] (mod m1)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
have "[m1 * x1 = 0] (mod m1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [m1 * x1 = 0] (mod m1)
[PROOF STEP]
by (simp add: cong_mult_self_left)
[PROOF STATE]
proof (state)
this:
[m1 * x1 = 0] (mod m1)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[m1 * x1 = 0] (mod m1)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
have "[m2 * x2 = 0] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [m2 * x2 = 0] (mod m2)
[PROOF STEP]
by (simp add: cong_mult_self_left)
[PROOF STATE]
proof (state)
this:
[m2 * x2 = 0] (mod m2)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[m1 * x1 = 0] (mod m1)
[m2 * x2 = 0] (mod m2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[m1 * x1 = 0] (mod m1)
[m2 * x2 = 0] (mod m2)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
using 1 2
[PROOF STATE]
proof (prove)
using this:
[m1 * x1 = 0] (mod m1)
[m2 * x2 = 0] (mod m2)
[m1 * x1 = 1] (mod m2)
[m2 * x2 = 1] (mod m1)

goal (1 subgoal):
 1. \<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)
[PROOF STEP]
obtain b1 b2
    where "[b1 = 1] (mod m1)" and "[b1 = 0] (mod m2)"
      and "[b2 = 0] (mod m1)" and "[b2 = 1] (mod m2)"
[PROOF STATE]
proof (prove)
using this:
\<exists>b1 b2. [b1 = 1] (mod m1) \<and> [b1 = 0] (mod m2) \<and> [b2 = 0] (mod m1) \<and> [b2 = 1] (mod m2)

goal (1 subgoal):
 1. (\<And>b1 b2. \<lbrakk>[b1 = 1] (mod m1); [b1 = 0] (mod m2); [b2 = 0] (mod m1); [b2 = 1] (mod m2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[b1 = 1] (mod m1)
[b1 = 0] (mod m2)
[b2 = 0] (mod m1)
[b2 = 1] (mod m2)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
let ?x = "u1 * b1 + u2 * b2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
have "[?x = u1 * 1 + u2 * 0] (mod m1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u1 * 1 + u2 * 0] (mod m1)
[PROOF STEP]
using \<open>[b1 = 1] (mod m1)\<close> \<open>[b2 = 0] (mod m1)\<close> cong_add cong_scalar_left
[PROOF STATE]
proof (prove)
using this:
[b1 = 1] (mod m1)
[b2 = 0] (mod m1)
\<lbrakk>[?b = ?c] (mod ?a); [?d = ?e] (mod ?a)\<rbrakk> \<Longrightarrow> [?b + ?d = ?c + ?e] (mod ?a)
[?b = ?c] (mod ?a) \<Longrightarrow> [?d * ?b = ?d * ?c] (mod ?a)

goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u1 * 1 + u2 * 0] (mod m1)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[u1 * b1 + u2 * b2 = u1 * 1 + u2 * 0] (mod m1)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[u1 * b1 + u2 * b2 = u1 * 1 + u2 * 0] (mod m1)
[PROOF STEP]
have "[?x = u1] (mod m1)"
[PROOF STATE]
proof (prove)
using this:
[u1 * b1 + u2 * b2 = u1 * 1 + u2 * 0] (mod m1)

goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u1] (mod m1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[u1 * b1 + u2 * b2 = u1] (mod m1)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
have "[?x = u1 * 0 + u2 * 1] (mod m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u1 * 0 + u2 * 1] (mod m2)
[PROOF STEP]
using \<open>[b1 = 0] (mod m2)\<close> \<open>[b2 = 1] (mod m2)\<close> cong_add cong_scalar_left
[PROOF STATE]
proof (prove)
using this:
[b1 = 0] (mod m2)
[b2 = 1] (mod m2)
\<lbrakk>[?b = ?c] (mod ?a); [?d = ?e] (mod ?a)\<rbrakk> \<Longrightarrow> [?b + ?d = ?c + ?e] (mod ?a)
[?b = ?c] (mod ?a) \<Longrightarrow> [?d * ?b = ?d * ?c] (mod ?a)

goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u1 * 0 + u2 * 1] (mod m2)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[u1 * b1 + u2 * b2 = u1 * 0 + u2 * 1] (mod m2)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[u1 * b1 + u2 * b2 = u1 * 0 + u2 * 1] (mod m2)
[PROOF STEP]
have "[?x = u2] (mod m2)"
[PROOF STATE]
proof (prove)
using this:
[u1 * b1 + u2 * b2 = u1 * 0 + u2 * 1] (mod m2)

goal (1 subgoal):
 1. [u1 * b1 + u2 * b2 = u2] (mod m2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[u1 * b1 + u2 * b2 = u2] (mod m2)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
with \<open>[?x = u1] (mod m1)\<close>
[PROOF STATE]
proof (chain)
picking this:
[u1 * b1 + u2 * b2 = u1] (mod m1)
[u1 * b1 + u2 * b2 = u2] (mod m2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[u1 * b1 + u2 * b2 = u1] (mod m1)
[u1 * b1 + u2 * b2 = u2] (mod m2)

goal (1 subgoal):
 1. \<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>x. [x = u1] (mod m1) \<and> [x = u2] (mod m2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma numgcd0:
  assumes g0: "numgcd t = 0"
  shows "Inum bs t = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inum bs t = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Inum bs t = 0
[PROOF STEP]
have "\<And>x. numgcdh t x= 0 \<Longrightarrow> Inum bs t = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. numgcdh t x = 0 \<Longrightarrow> Inum bs t = 0
[PROOF STEP]
by (induct t rule: numgcdh.induct, auto)
[PROOF STATE]
proof (state)
this:
numgcdh t ?x = 0 \<Longrightarrow> Inum bs t = 0

goal (1 subgoal):
 1. Inum bs t = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
numgcdh t ?x = 0 \<Longrightarrow> Inum bs t = 0

goal (1 subgoal):
 1. Inum bs t = 0
[PROOF STEP]
using g0[simplified numgcd_def]
[PROOF STATE]
proof (prove)
using this:
numgcdh t ?x = 0 \<Longrightarrow> Inum bs t = 0
numgcdh t (maxcoeff t) = 0

goal (1 subgoal):
 1. Inum bs t = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Inum bs t = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma double_inclusion:
  assumes "A \<subseteq> B"
      and "B \<subseteq> A"
    shows "A = B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> B
B \<subseteq> A

goal (1 subgoal):
 1. A = B
[PROOF STEP]
by blast


[STATEMENT]
lemma convergent_prod_prod: "(\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> convergent_prod (\<lambda>n. \<Prod>i\<in>I. f i n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> convergent_prod (\<lambda>n. \<Prod>i\<in>I. f i n)
[PROOF STEP]
using convergent_prod_has_prod_iff has_prod_prod prodinf_prod
[PROOF STATE]
proof (prove)
using this:
convergent_prod ?f = ?f has_prod prodinf ?f
(\<And>i. i \<in> I \<Longrightarrow> f i has_prod ?x i) \<Longrightarrow> (\<lambda>n. \<Prod>i\<in>I. f i n) has_prod prod ?x I
(\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> (\<Prod>n. \<Prod>i\<in>I. f i n) = (\<Prod>i\<in>I. \<Prod>n. f i n)

goal (1 subgoal):
 1. (\<And>i. i \<in> I \<Longrightarrow> convergent_prod (f i)) \<Longrightarrow> convergent_prod (\<lambda>n. \<Prod>i\<in>I. f i n)
[PROOF STEP]
by force


[STATEMENT]
lemma split_C:
  assumes \<omega>: "\<omega> \<in> space (PiM {0..<n} M)" shows "(C n m \<omega> \<bind> C (n + m) l) = C n (m + l) \<omega>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega>
[PROOF STEP]
proof (induction l)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. C n m \<omega> \<bind> C (n + m) 0 = C n (m + 0) \<omega>
 2. \<And>l. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega> \<Longrightarrow> C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. C n m \<omega> \<bind> C (n + m) 0 = C n (m + 0) \<omega>
 2. \<And>l. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega> \<Longrightarrow> C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
with \<omega>
[PROOF STATE]
proof (chain)
picking this:
\<omega> \<in> space (Pi\<^sub>M {0..<n} M)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<omega> \<in> space (Pi\<^sub>M {0..<n} M)

goal (1 subgoal):
 1. C n m \<omega> \<bind> C (n + m) 0 = C n (m + 0) \<omega>
[PROOF STEP]
by (simp add: bind_return_distr' prob_space_C[THEN prob_space.not_empty]
                  distr_cong[OF refl sets_C[symmetric, OF \<omega>]])
[PROOF STATE]
proof (state)
this:
C n m \<omega> \<bind> C (n + m) 0 = C n (m + 0) \<omega>

goal (1 subgoal):
 1. \<And>l. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega> \<Longrightarrow> C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>l. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega> \<Longrightarrow> C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
case (Suc l)
[PROOF STATE]
proof (state)
this:
C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega>

goal (1 subgoal):
 1. \<And>l. C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega> \<Longrightarrow> C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
with \<omega>
[PROOF STATE]
proof (chain)
picking this:
\<omega> \<in> space (Pi\<^sub>M {0..<n} M)
C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<omega> \<in> space (Pi\<^sub>M {0..<n} M)
C n m \<omega> \<bind> C (n + m) l = C n (m + l) \<omega>

goal (1 subgoal):
 1. C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>
[PROOF STEP]
by (simp add: bind_assoc[symmetric, OF _ measurable_eP]) (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
C n m \<omega> \<bind> C (n + m) (Suc l) = C n (m + Suc l) \<omega>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_in_nlists [iff]:
  "(\<exists>n. ST \<in> nlists n A \<and> n \<le> mxs) = (set ST \<subseteq> A \<and> size ST \<le> mxs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>n. ST \<in> nlists n A \<and> n \<le> mxs) = (set ST \<subseteq> A \<and> length ST \<le> mxs)
[PROOF STEP]
by (unfold nlists_def) auto


[STATEMENT]
lemma term_is_le_rel_canc_left:
  assumes "ord_term_lin.is_le_rel rel"
  shows "rel (t \<oplus> u) (t \<oplus> v) \<longleftrightarrow> rel u v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel (t \<oplus> u) (t \<oplus> v) = rel u v
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ord_term_lin.is_le_rel rel

goal (1 subgoal):
 1. rel (t \<oplus> u) (t \<oplus> v) = rel u v
[PROOF STEP]
by (rule ord_term_lin.is_le_relE,
      auto simp: splus_left_canc dest: ord_term_canc ord_term_strict_canc splus_mono splus_mono_strict)


[STATEMENT]
lemma non_empty_candidate_results:
  assumes "\<And> (f :: three \<Rightarrow> three \<Rightarrow> three) (xs :: three list).
             \<lbrakk> associative f ; xs \<noteq> [] \<rbrakk>  \<Longrightarrow> candidate f xs = scanl1 f xs"
      and "js \<in> set (candidate (@) (map wrap [0..<n + 1]))"
  shows   "js \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
proof -
  \<comment> \<open>We define a mapping of lists to values of @{text three} as explained\<close>
  \<comment> \<open>above, and a function which behaves like @{text @} on values of\<close>
  \<comment> \<open>@{text three}.\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
let ?h = "\<lambda>xs. case xs of [] \<Rightarrow> Zero | (_#_) \<Rightarrow> One"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
let ?g = "\<lambda>x y. if (x = One \<or> y = One) then One else Zero"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
have g_assoc: "associative ?g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. associative (\<lambda>x y. if x = One \<or> y = One then One else Zero)
[PROOF STEP]
unfolding associative_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y z. (if x = One \<or> (if y = One \<or> z = One then One else Zero) = One then One else Zero) = (if (if x = One \<or> y = One then One else Zero) = One \<or> z = One then One else Zero)
[PROOF STEP]
by auto

  \<comment> \<open>Our defined functions fulfill the requirements of the free theorem of\<close>
  \<comment> \<open>@{text candidate}, that is:\<close>
[PROOF STATE]
proof (state)
this:
associative (\<lambda>x y. if x = One \<or> y = One then One else Zero)

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
have req_free_theorem: "\<And>xs ys. ?h (xs @ ys) = ?g (?h xs) (?h ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs ys. (case xs @ ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs ys. (case xs @ ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)
[PROOF STEP]
fix xs ys
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs ys. (case xs @ ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)
[PROOF STEP]
show "?h (xs @ ys) = ?g (?h xs) (?h ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case xs @ ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)
[PROOF STEP]
by (cases xs, simp_all, cases ys, simp_all)
[PROOF STATE]
proof (state)
this:
(case xs @ ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ys of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)

goal:
No subgoals!
[PROOF STEP]
qed

  \<comment> \<open>Before applying the assumptions, we show that @{text candidate}'s\<close>
  \<comment> \<open>counterpart @{text scanl1}, applied to a non-empty list, returns only\<close>
  \<comment> \<open>a repetition of the value @{text One}.\<close>
[PROOF STATE]
proof (state)
this:
(case ?xs1 @ ?ys1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case ?xs1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ?ys1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
have set_scanl1_is_One:
    "set (scanl1 ?g (map ?h (map wrap [0..<n + 1]))) = {One}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have const_One: "map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. map (\<lambda>x. One) [0..<0 + 1] = replicate (0 + 1) One
 2. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. map (\<lambda>x. One) [0..<0 + 1] = replicate (0 + 1) One
 2. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<0 + 1] = replicate (0 + 1) One
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<0 + 1] = replicate (0 + 1) One

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
have
          "map (\<lambda>x. One) [0..<Suc n + 1]
           = map (\<lambda>x. One) ([0..<Suc n] @ [Suc n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<Suc n + 1] = map (\<lambda>x. One) ([0..<Suc n] @ [Suc n])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<Suc n + 1] = map (\<lambda>x. One) ([0..<Suc n] @ [Suc n])

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<Suc n + 1] = map (\<lambda>x. One) ([0..<Suc n] @ [Suc n])

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
have
          "\<dots> = map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>x. One) ([0..<Suc n] @ [Suc n]) = map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) ([0..<Suc n] @ [Suc n]) = map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n]

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) ([0..<Suc n] @ [Suc n]) = map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n]

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
have "\<dots> = replicate (Suc n) One @ replicate 1 One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n] = replicate (Suc n) One @ replicate 1 One
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n] = replicate (Suc n) One @ replicate 1 One
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n] = replicate (Suc n) One @ replicate 1 One

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<Suc n] @ map (\<lambda>x. One) [Suc n] = replicate (Suc n) One @ replicate 1 One

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
have "\<dots> = replicate (Suc n + 1) One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. replicate (Suc n) One @ replicate 1 One = replicate (Suc n + 1) One
[PROOF STEP]
using List.replicate_add
                      [symmetric, where x=One and n="Suc n" and m=1]
[PROOF STATE]
proof (prove)
using this:
replicate (Suc n) One @ replicate 1 One = replicate (Suc n + 1) One

goal (1 subgoal):
 1. replicate (Suc n) One @ replicate 1 One = replicate (Suc n + 1) One
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
replicate (Suc n) One @ replicate 1 One = replicate (Suc n + 1) One

goal (1 subgoal):
 1. \<And>n. map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One \<Longrightarrow> map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One

goal (1 subgoal):
 1. map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<Suc n + 1] = replicate (Suc n + 1) One

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have foldl1_One: "\<And>xs. foldl1 ?g (One # xs) = One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # xs) = One
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # xs) = One
[PROOF STEP]
fix xs
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # xs) = One
[PROOF STEP]
show "foldl1 ?g (One # xs) = One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # xs) = One
[PROOF STEP]
proof (induct xs rule: measure_induct [where f=length])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<forall>y. length y < length x \<longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # y) = One \<Longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # x) = One
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<forall>y. length y < length x \<longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # y) = One \<Longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # x) = One
[PROOF STEP]
assume "\<forall>y. length y < length (x::three list)
                        \<longrightarrow> foldl1 ?g (One # y) = One"
[PROOF STATE]
proof (state)
this:
\<forall>y. length y < length x \<longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # y) = One

goal (1 subgoal):
 1. \<And>x. \<forall>y. length y < length x \<longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # y) = One \<Longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # x) = One
[PROOF STEP]
thus "foldl1 ?g (One # x) = One"
[PROOF STATE]
proof (prove)
using this:
\<forall>y. length y < length x \<longrightarrow> foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # y) = One

goal (1 subgoal):
 1. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # x) = One
[PROOF STEP]
by (cases x, auto)
[PROOF STATE]
proof (state)
this:
foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # x) = One

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # xs) = One

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # ?xs2) = One

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "scanl1 ?g (map ?h (map wrap [0..<n + 1]))
       = scanl1 ?g (map (?h \<circ> wrap) [0..<n + 1])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1])
[PROOF STEP]
using L1 [where g="?h" and f=wrap and xs="[0..<n + 1]"]
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]) = map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1]

goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = scanl1 ?g (map (\<lambda>x. One) [0..<n + 1])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1])
[PROOF STEP]
by (simp add: Fun.o_def)
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map ((\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<circ> wrap) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = scanl1 ?g (replicate (n + 1) One)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One)
[PROOF STEP]
using const_One
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One)

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>x. One) [0..<n + 1]) = scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One)

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map (\<lambda>k. foldl1 ?g (take k (replicate (n + 1) One)))
               [1..<length (replicate (n + 1) One) + 1]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One) = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One) = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (n + 1) One) = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map (\<lambda>k. foldl1 ?g (take k (replicate (n + 1) One)))
               (map Suc [0..<length (replicate (n + 1) One)])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)])
[PROOF STEP]
using List.map_Suc_upt
[PROOF STATE]
proof (prove)
using this:
map Suc [?m..<?n] = [Suc ?m..<Suc ?n]

goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) [1..<length (replicate (n + 1) One) + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)])

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map ((\<lambda>k. foldl1 ?g (take k (replicate (n + 1) One))) \<circ> Suc)
               [0..<length (replicate (n + 1) One)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)]) = map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)]
[PROOF STEP]
using L1
[PROOF STATE]
proof (prove)
using this:
map ?g (map ?f ?xs) = map (?g \<circ> ?f) ?xs

goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)]) = map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)]) = map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) (map Suc [0..<length (replicate (n + 1) One)]) = map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map (\<lambda>k. foldl1 ?g (replicate (min (k + 1) (n + 1)) One))
               [0..<n + 1]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1]
[PROOF STEP]
using Fun.o_def
[PROOF STATE]
proof (prove)
using this:
?f \<circ> ?g = (\<lambda>x. ?f (?g x))

goal (1 subgoal):
 1. map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map ((\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (take k (replicate (n + 1) One))) \<circ> Suc) [0..<length (replicate (n + 1) One)] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map (\<lambda>k. foldl1 ?g (One # replicate (min k n) One))
               [0..<n + 1]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (replicate (min (k + 1) (n + 1)) One)) [0..<n + 1] = map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = map (\<lambda>k. One) [0..<n + 1]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1] = map (\<lambda>k. One) [0..<n + 1]
[PROOF STEP]
using foldl1_One
[PROOF STATE]
proof (prove)
using this:
foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # ?xs2) = One

goal (1 subgoal):
 1. map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1] = map (\<lambda>k. One) [0..<n + 1]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1] = map (\<lambda>k. One) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. foldl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (One # replicate (min k n) One)) [0..<n + 1] = map (\<lambda>k. One) [0..<n + 1]

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
have
      "\<dots> = replicate (n + 1) One"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. One) [0..<n + 1] = replicate (n + 1) One
[PROOF STEP]
using const_One
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. map (\<lambda>k. One) [0..<n + 1] = replicate (n + 1) One
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. One) [0..<n + 1] = replicate (n + 1) One

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = replicate (n + 1) One
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = replicate (n + 1) One

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
using List.set_replicate [where n="n + 1"]
[PROOF STATE]
proof (prove)
using this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = replicate (n + 1) One
n + 1 \<noteq> 0 \<Longrightarrow> set (replicate (n + 1) ?x) = {?x}

goal (1 subgoal):
 1. set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}

goal:
No subgoals!
[PROOF STEP]
qed

  \<comment> \<open>Thus, with the assumptions and the free theorem of candidate, we show\<close>
  \<comment> \<open>that results of @{text candidate}, after applying @{text h}, can only\<close>
  \<comment> \<open>have the value @{text One}.\<close>
[PROOF STATE]
proof (state)
this:
set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
have
  "scanl1 ?g (map ?h (map wrap [0..<n + 1]))
   = candidate ?g (map ?h (map wrap [0..<n + 1]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))
[PROOF STEP]
using assms and g_assoc
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>associative ?f; ?xs \<noteq> []\<rbrakk> \<Longrightarrow> candidate ?f ?xs = scanl1 ?f ?xs
js \<in> set (candidate (@) (map wrap [0..<n + 1]))
associative (\<lambda>x y. if x = One \<or> y = One then One else Zero)

goal (1 subgoal):
 1. scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
have
  "\<dots> = map ?h (candidate (@) (map wrap [0..<n + 1]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
using candidate_free_theorem [symmetric, where f="(@)" and g="?g"
      and h="?h" and zs="(map wrap [0..<n + 1])"] and req_free_theorem
[PROOF STATE]
proof (prove)
using this:
(case ?x @ ?y of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case ?x of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ?y of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero) \<Longrightarrow> candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))
(case ?xs1 @ ?ys1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = (if (case ?xs1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One \<or> (case ?ys1 of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One then One else Zero)

goal (1 subgoal):
 1. candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
candidate (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
have set_is_One:
  "\<And>x. x \<in> set (map ?h (candidate (@) (map wrap [0..<n + 1])))
       \<Longrightarrow> x = One"
[PROOF STATE]
proof (prove)
using this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. \<And>x. x \<in> set (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))) \<Longrightarrow> x = One
[PROOF STEP]
using set_scanl1_is_One
[PROOF STATE]
proof (prove)
using this:
scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1])) = map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))
set (scanl1 (\<lambda>x y. if x = One \<or> y = One then One else Zero) (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (map wrap [0..<n + 1]))) = {One}

goal (1 subgoal):
 1. \<And>x. x \<in> set (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))) \<Longrightarrow> x = One
[PROOF STEP]
by auto

  \<comment> \<open>Now, it is easy to conclude the thesis.\<close>
[PROOF STATE]
proof (state)
this:
?x2 \<in> set (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))) \<Longrightarrow> ?x2 = One

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>associative ?f; ?xs \<noteq> []\<rbrakk> \<Longrightarrow> candidate ?f ?xs = scanl1 ?f ?xs
js \<in> set (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
have "?h js \<in> ?h ` set (candidate (@) (map wrap [0..<n + 1]))"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>associative ?f; ?xs \<noteq> []\<rbrakk> \<Longrightarrow> candidate ?f ?xs = scanl1 ?f ?xs
js \<in> set (candidate (@) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. (case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<in> (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) ` set (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<in> (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) ` set (candidate (@) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
with set_is_One
[PROOF STATE]
proof (chain)
picking this:
?x2 \<in> set (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))) \<Longrightarrow> ?x2 = One
(case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<in> (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) ` set (candidate (@) (map wrap [0..<n + 1]))
[PROOF STEP]
have "?h js = One"
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> set (map (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) (candidate (@) (map wrap [0..<n + 1]))) \<Longrightarrow> ?x2 = One
(case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) \<in> (\<lambda>xs. case xs of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) ` set (candidate (@) (map wrap [0..<n + 1]))

goal (1 subgoal):
 1. (case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One

goal (1 subgoal):
 1. js \<noteq> []
[PROOF STEP]
thus "js \<noteq> []"
[PROOF STATE]
proof (prove)
using this:
(case js of [] \<Rightarrow> Zero | x # xa \<Rightarrow> One) = One

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma not_less_funE:
  assumes "\<not> f \<prec> g" and "c > 0"
  obtains m where "m > n" and "c * g m < f m"
    | d q where "\<And>m. d > 0 \<Longrightarrow> m > q \<Longrightarrow> g q \<le> d * f q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>m. \<lbrakk>n < m; c * g m < f m\<rbrakk> \<Longrightarrow> thesis; \<And>d q. (\<And>m. \<lbrakk>0 < d; q < m\<rbrakk> \<Longrightarrow> g q \<le> d * f q) \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> f \<prec> g
0 < c

goal (1 subgoal):
 1. \<lbrakk>\<And>m. \<lbrakk>n < m; c * g m < f m\<rbrakk> \<Longrightarrow> thesis; \<And>d q. (\<And>m. \<lbrakk>0 < d; q < m\<rbrakk> \<Longrightarrow> g q \<le> d * f q) \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
unfolding less_fun_def linorder_not_less [symmetric]
[PROOF STATE]
proof (prove)
using this:
\<not> (f \<lesssim> g \<and> \<not> g \<lesssim> f)
0 < c

goal (1 subgoal):
 1. \<lbrakk>\<And>m. \<lbrakk>n < m; c * g m < f m\<rbrakk> \<Longrightarrow> thesis; \<And>d q. (\<And>m. \<lbrakk>0 < d; q < m\<rbrakk> \<Longrightarrow> \<not> d * f q < g q) \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by blast


[STATEMENT]
lemma good_mapI:
     assumes surj_h: "surj h"
         and prem:   "!! x x' y y'. h(x,y) = h(x',y') ==> x=x'"
     shows "good_map h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. good_map h
[PROOF STEP]
apply (simp add: good_map_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj h \<and> (\<forall>x y. fst (inv h (h (x, y))) = x)
[PROOF STEP]
apply (safe intro!: surj_h)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. fst (inv h (h (x, y))) = x
[PROOF STEP]
apply (rule prem)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. h (fst (inv h (h (x, y))), ?y9 x y) = h (x, ?y'9 x y)
[PROOF STEP]
apply (subst surjective_pairing [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. h (inv h (h (x, y))) = h (x, ?y'12 x x y y)
[PROOF STEP]
apply (subst surj_h [THEN surj_f_inv_f])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. h (x, y) = h (x, ?y'14 x x x y y y)
flex-flex pairs:
\<lambda>x y. ?y'14 x x x y y y \<equiv>\<^sup>? \<lambda>x y. ?y'12 x x y y
[PROOF STEP]
apply (rule refl)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma pow_res_zero:
  assumes "n > 0"
  shows "pow_res n \<zero> = {\<zero>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pow_res n \<zero> = {\<zero>}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. pow_res n \<zero> \<subseteq> {\<zero>}
 2. {\<zero>} \<subseteq> pow_res n \<zero>
[PROOF STEP]
show "pow_res n \<zero> \<subseteq> {\<zero>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pow_res n \<zero> \<subseteq> {\<zero>}
[PROOF STEP]
unfolding pow_res_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<zero> \<otimes> y [^] n} \<subseteq> {\<zero>}
[PROOF STEP]
using Qp.l_null Qp.nat_pow_closed Qp.nonzero_closed
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier Q\<^sub>p \<Longrightarrow> \<zero> \<otimes> ?x = \<zero>
?x \<in> carrier Q\<^sub>p \<Longrightarrow> ?x [^] ?n \<in> carrier Q\<^sub>p
?a \<in> nonzero Q\<^sub>p \<Longrightarrow> ?a \<in> carrier Q\<^sub>p

goal (1 subgoal):
 1. {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<zero> \<otimes> y [^] n} \<subseteq> {\<zero>}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
pow_res n \<zero> \<subseteq> {\<zero>}

goal (1 subgoal):
 1. {\<zero>} \<subseteq> pow_res n \<zero>
[PROOF STEP]
show "{\<zero>} \<subseteq> pow_res n \<zero>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {\<zero>} \<subseteq> pow_res n \<zero>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. {\<zero>} \<subseteq> pow_res n \<zero>
[PROOF STEP]
unfolding pow_res_def
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. {\<zero>} \<subseteq> {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<zero> \<otimes> y [^] n}
[PROOF STEP]
using Qp.l_null Qp.one_closed Qp.one_nonzero empty_subsetI insert_subset
[PROOF STATE]
proof (prove)
using this:
0 < n
?x \<in> carrier Q\<^sub>p \<Longrightarrow> \<zero> \<otimes> ?x = \<zero>
\<one> \<in> carrier Q\<^sub>p
\<one> \<in> nonzero Q\<^sub>p
{} \<subseteq> ?A
(insert ?x ?A \<subseteq> ?B) = (?x \<in> ?B \<and> ?A \<subseteq> ?B)

goal (1 subgoal):
 1. {\<zero>} \<subseteq> {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<zero> \<otimes> y [^] n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{\<zero>} \<subseteq> pow_res n \<zero>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mat_unitary_mat [intro]:
  assumes "unitary M"
  shows "inverts_mat M (M\<^sup>\<dagger>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverts_mat M M\<^sup>\<dagger>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
unitary M

goal (1 subgoal):
 1. inverts_mat M M\<^sup>\<dagger>
[PROOF STEP]
by (simp add: unitary_def inverts_mat_def)


[STATEMENT]
lemma (in linordered_nonzero_semiring) prod_mono:
  "\<forall>i\<in>A. 0 \<le> f i \<and> f i \<le> g i \<Longrightarrow> prod f A \<le> prod g A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>A. (0::'a) \<le> f i \<and> f i \<le> g i \<Longrightarrow> prod f A \<le> prod g A
[PROOF STEP]
by (induct A rule: infinite_finite_induct) (auto intro!: prod_nonneg mult_mono)


[STATEMENT]
lemma face_of_convex_hull_subset:
  fixes S :: "'a::euclidean_space set"
  assumes "compact S" and T: "T face_of (convex hull S)"
  obtains s' where "s' \<subseteq> S" "T = convex hull s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>s'. \<lbrakk>s' \<subseteq> S; T = convex hull s'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>s'. \<lbrakk>s' \<subseteq> S; T = convex hull s'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> ?s'2 \<subseteq> S
 2. (\<And>s'. \<lbrakk>s' \<subseteq> S; T = convex hull s'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> T = convex hull ?s'2
[PROOF STEP]
show "{x. x extreme_point_of T} \<subseteq> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. x extreme_point_of T} \<subseteq> S
[PROOF STEP]
using T extreme_point_of_convex_hull extreme_point_of_face
[PROOF STATE]
proof (prove)
using this:
T face_of convex hull S
?x extreme_point_of convex hull ?S \<Longrightarrow> ?x \<in> ?S
?F face_of ?S \<Longrightarrow> (?v extreme_point_of ?F) = (?v extreme_point_of ?S \<and> ?v \<in> ?F)

goal (1 subgoal):
 1. {x. x extreme_point_of T} \<subseteq> S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{x. x extreme_point_of T} \<subseteq> S

goal (1 subgoal):
 1. (\<And>s'. \<lbrakk>s' \<subseteq> S; T = convex hull s'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> T = convex hull {x. x extreme_point_of T}
[PROOF STEP]
show "T = convex hull {x. x extreme_point_of T}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T = convex hull {x. x extreme_point_of T}
[PROOF STEP]
proof (rule Krein_Milman_Minkowski)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. compact T
 2. convex T
[PROOF STEP]
show "compact T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact T
[PROOF STEP]
using T assms compact_convex_hull face_of_imp_compact
[PROOF STATE]
proof (prove)
using this:
T face_of convex hull S
compact S
T face_of convex hull S
compact ?S \<Longrightarrow> compact (convex hull ?S)
\<lbrakk>convex ?S; compact ?S; ?T face_of ?S\<rbrakk> \<Longrightarrow> compact ?T

goal (1 subgoal):
 1. compact T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
compact T

goal (1 subgoal):
 1. convex T
[PROOF STEP]
show "convex T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex T
[PROOF STEP]
using T face_of_imp_convex
[PROOF STATE]
proof (prove)
using this:
T face_of convex hull S
?T face_of ?S \<Longrightarrow> convex ?T

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
T = convex hull {x. x extreme_point_of T}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma l11_63_existence:
  assumes "Coplanar A B C D" and
    "\<not> Coplanar A B C P"
  shows "\<exists> Q. A B C Orth D Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Q. A B C Orth D Q
[PROOF STEP]
using Orth_def assms(1) assms(2) l11_62_existence_bis l11_63_aux
[PROOF STATE]
proof (prove)
using this:
?A ?B ?C Orth ?U ?V \<equiv> \<exists>X. X OrthAt ?A ?B ?C ?U ?V
Coplanar A B C D
\<not> Coplanar A B C P
\<not> Coplanar ?A ?B ?C ?P \<Longrightarrow> \<exists>X. X OrthAt ?A ?B ?C X ?P
\<lbrakk>Coplanar ?A ?B ?C ?D; ?D \<noteq> ?E; ?E OrthAt ?A ?B ?C ?E ?P\<rbrakk> \<Longrightarrow> \<exists>Q. ?D ?E OS ?P Q \<and> ?A ?B ?C Orth ?D Q

goal (1 subgoal):
 1. \<exists>Q. A B C Orth D Q
[PROOF STEP]
by fastforce


[STATEMENT]
lemma sum_inverse_squares_remainder_bigo:
  assumes "N > 0"
  shows   "R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))
[PROOF STEP]
from sum_inverse_squares_remainder_bound[OF assms]
[PROOF STATE]
proof (chain)
picking this:
\<exists>C. \<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)) \<le> C / real n ^ (2 * N + 2)
[PROOF STEP]
obtain C
    where "\<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n))
      \<le> C / real n ^ (2 * N + 2)"
[PROOF STATE]
proof (prove)
using this:
\<exists>C. \<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)) \<le> C / real n ^ (2 * N + 2)

goal (1 subgoal):
 1. (\<And>C. \<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)) \<le> C / real n ^ (2 * N + 2) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)) \<le> C / real n ^ (2 * N + 2)

goal (1 subgoal):
 1. R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>n\<ge>1. norm (EM_remainder (2 * N + 1) (\<lambda>x. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)) \<le> C / real n ^ (2 * N + 2)

goal (1 subgoal):
 1. R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))
[PROOF STEP]
by (intro bigoI[of _ C] eventually_mono[OF eventually_ge_at_top[of 1]]) (auto simp: R_def)
[PROOF STATE]
proof (state)
this:
R N \<in> O(\<lambda>n. 1 / real n ^ (2 * N + 2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma seqs_Suc': "seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
have "rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) =
          rev ` ((\<lambda>xs. True # xs) ` rev ` seqs n \<union> (\<lambda>xs. False # xs) ` rev ` seqs n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = rev ` ((#) True ` rev ` seqs n \<union> (#) False ` rev ` seqs n)
[PROOF STEP]
unfolding image_Un image_image
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. rev (rev (x @ [True]))) ` seqs n \<union> (\<lambda>x. rev (rev (x @ [False]))) ` seqs n = (\<lambda>x. rev (True # rev x)) ` seqs n \<union> (\<lambda>x. rev (False # rev x)) ` seqs n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = rev ` ((#) True ` rev ` seqs n \<union> (#) False ` rev ` seqs n)

goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = rev ` ((#) True ` rev ` seqs n \<union> (#) False ` rev ` seqs n)

goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
have "(\<lambda>xs. True # xs) ` rev ` seqs n \<union> (\<lambda>xs. False # xs) ` rev ` seqs n = seqs (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (#) True ` rev ` seqs n \<union> (#) False ` rev ` seqs n = seqs (Suc n)
[PROOF STEP]
by (simp add: seqs_Suc)
[PROOF STATE]
proof (state)
this:
(#) True ` rev ` seqs n \<union> (#) False ` rev ` seqs n = seqs (Suc n)

goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = rev ` seqs (Suc n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rev ` rev ` ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = rev ` seqs (Suc n)

goal (1 subgoal):
 1. seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n
[PROOF STEP]
by (simp add: image_image)
[PROOF STATE]
proof (state)
this:
seqs (Suc n) = (\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma p_antitone_iff:
  "x \<le> -y \<longleftrightarrow> y \<le> -x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<le> - y) = (y \<le> - x)
[PROOF STEP]
using order_lesseq_imp p_antitone pp_increasing
[PROOF STATE]
proof (prove)
using this:
(\<forall>z\<ge>?x. ?y \<le> z) = (?y \<le> ?x)
?x \<le> ?y \<Longrightarrow> - ?y \<le> - ?x
?x \<le> - - ?x

goal (1 subgoal):
 1. (x \<le> - y) = (y \<le> - x)
[PROOF STEP]
by blast


[STATEMENT]
lemma locally_finite_onD:
  assumes "locally_finite_on X I U"
  assumes "p \<in> X"
  shows "finite {i\<in>I. p \<in> U i}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {i \<in> I. p \<in> U i}
[PROOF STEP]
apply (rule locally_finite_onE[OF assms])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>N. \<lbrakk>p \<in> N; open N; finite {i \<in> I. U i \<inter> N \<noteq> {}}\<rbrakk> \<Longrightarrow> finite {i \<in> I. p \<in> U i}
[PROOF STEP]
apply (rule finite_subset)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>N. \<lbrakk>p \<in> N; open N; finite {i \<in> I. U i \<inter> N \<noteq> {}}\<rbrakk> \<Longrightarrow> {i \<in> I. p \<in> U i} \<subseteq> ?B2 N
 2. \<And>N. \<lbrakk>p \<in> N; open N; finite {i \<in> I. U i \<inter> N \<noteq> {}}\<rbrakk> \<Longrightarrow> finite (?B2 N)
[PROOF STEP]
by auto


[STATEMENT]
lemma (in completely_multiplicative_function) dirichlet_prod_self:
  "dirichlet_prod f f n = f n * of_nat (divisor_count n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
have "dirichlet_prod f f n = (\<Sum>(r, d) | r * d = n. f (r * d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod f f n = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d))
[PROOF STEP]
by (simp add: dirichlet_prod_altdef2 mult)
[PROOF STATE]
proof (state)
this:
dirichlet_prod f f n = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dirichlet_prod f f n = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
have "\<dots> = (\<Sum>(r, d) | r * d = n. f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d)) = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n)
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d)) = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f (r * d)) = (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
have "\<dots> = f n * of_nat (card {(r, d). r * d = n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n) = f n * of_nat (card {(r, d). r * d = n})
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n) = f n * of_nat (card {(r, d). r * d = n})

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f n) = f n * of_nat (card {(r, d). r * d = n})

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
have "bij_betw fst {(r, d). r * d = n} {r. r dvd n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw fst {(r, d). r * d = n} {r. r dvd n}
[PROOF STEP]
by (rule bij_betwI[of _ _ _ "\<lambda>r. (r, n div r)"]) (use False in auto)
[PROOF STATE]
proof (state)
this:
bij_betw fst {(r, d). r * d = n} {r. r dvd n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
hence "card {(r, d). r * d = n} = card {r. r dvd n}"
[PROOF STATE]
proof (prove)
using this:
bij_betw fst {(r, d). r * d = n} {r. r dvd n}

goal (1 subgoal):
 1. card {(r, d). r * d = n} = card {r. r dvd n}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card {(r, d). r * d = n} = card {r. r dvd n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {(r, d). r * d = n} = card {r. r dvd n}

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
have "\<dots> = divisor_count n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {r. r dvd n} = divisor_count n
[PROOF STEP]
by (simp add: divisor_count_def)
[PROOF STATE]
proof (state)
this:
card {r. r dvd n} = divisor_count n

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dirichlet_prod f f n = f n * of_nat (divisor_count n)

goal (1 subgoal):
 1. dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dirichlet_prod f f n = f n * of_nat (divisor_count n)

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> dirichlet_prod f f n = f n * of_nat (divisor_count n)
[PROOF STEP]
qed auto


[STATEMENT]
lemma prim_card_set: assumes "primitive u" and "\<^bold>|u\<^bold>| \<noteq> 1" shows "1 < card (set u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < card (set u)
[PROOF STEP]
using \<open>\<^bold>|u\<^bold>| \<noteq> 1\<close> \<open>primitive u\<close> pow_non_prim[OF \<open>\<^bold>|u\<^bold>| \<noteq> 1\<close>, of "[hd u]"]
[PROOF STATE]
proof (prove)
using this:
\<^bold>|u\<^bold>| \<noteq> 1
primitive u
\<not> primitive ([hd u] \<^sup>@ \<^bold>|u\<^bold>|)

goal (1 subgoal):
 1. 1 < card (set u)
[PROOF STEP]
by (elim not_le_imp_less[OF contrapos_nn] card_set_le_1_imp_hd_pow[elim_format]) simp


[STATEMENT]
lemma gval_fold_rev_equiv_fold:
  "gval (fold gAnd (rev G) (Bc True)) s =  gval (fold gAnd G (Bc True)) s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
[PROOF STEP]
apply (cases "gval (fold gAnd (rev G) (Bc True)) s")
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. gval (fold gAnd (rev G) (Bc True)) s = true \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
 2. gval (fold gAnd (rev G) (Bc True)) s = false \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
 3. gval (fold gAnd (rev G) (Bc True)) s = invalid \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
[PROOF STEP]
apply (simp add: gval_fold_rev_true)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. gval (fold gAnd (rev G) (Bc True)) s = false \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
 2. gval (fold gAnd (rev G) (Bc True)) s = invalid \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
[PROOF STEP]
apply (simp add: gval_fold_rev_false)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gval (fold gAnd (rev G) (Bc True)) s = invalid \<Longrightarrow> gval (fold gAnd (rev G) (Bc True)) s = gval (fold gAnd G (Bc True)) s
[PROOF STEP]
by (simp add: gval_fold_rev_invalid)


[STATEMENT]
lemma borel_measurable_power_ennreal [measurable (raw)]:
  fixes f :: "_ \<Rightarrow> ennreal"
  assumes f: "f \<in> borel_measurable M"
  shows "(\<lambda>x. (f x) ^ n) \<in> borel_measurable M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x ^ n) \<in> borel_measurable M
[PROOF STEP]
by (induction n) (use f in auto)


[STATEMENT]
lemma inj_on_arccos: "S \<subseteq> {-1..1} \<Longrightarrow> inj_on arccos S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<subseteq> {- 1..1} \<Longrightarrow> inj_on arccos S
[PROOF STEP]
by (metis atLeastAtMost_iff cos_arccos inj_onI subsetCE)


[STATEMENT]
lemma bal_simps:
  "bal 0 xs = (Leaf, xs)"
  "n > 0 \<Longrightarrow>
   bal n xs =
  (let m = n div 2;
      (l, ys) = bal m xs;
      (r, zs) = bal (n-1-m) (tl ys)
  in (Node l (hd ys) r, zs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bal 0 xs = (\<langle>\<rangle>, xs) &&& (0 < n \<Longrightarrow> bal n xs = (let m = n div 2; (l, ys) = bal m xs; (r, zs) = bal (n - 1 - m) (tl ys) in (\<langle>l, hd ys, r\<rangle>, zs)))
[PROOF STEP]
by(simp_all add: bal_def2)


[STATEMENT]
lemma NSLIM_diff: "f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l \<Longrightarrow> g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m \<Longrightarrow> (\<lambda>x. f x - g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S (l - m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l; g \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) \<midarrow>x\<rightarrow>\<^sub>N\<^sub>S l - m
[PROOF STEP]
by (simp only: NSLIM_add NSLIM_minus diff_conv_add_uminus)


[STATEMENT]
lemma mult_vec_monomial_monomial:
  "(monomial c u) ** (monomial d v) =
          (monomial (c * d) (term_of_pair (pp_of_term u + pp_of_term v, component_of_term u)) when
            component_of_term u = component_of_term v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monomial c u ** monomial d v = (monomial (c * d) (term_of_pair (pp_of_term u + pp_of_term v, component_of_term u)) when component_of_term u = component_of_term v)
[PROOF STEP]
by (rule poly_mapping_eqI_proj, simp add: proj_monomial mult_single when_def term_simps)


[STATEMENT]
lemma erlang_CDF_at0: "erlang_CDF k l 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. erlang_CDF k l 0 = 0
[PROOF STEP]
by (induction k) (auto simp: erlang_CDF_def)


[STATEMENT]
lemma Cd_simps[simp, nitpick_simp]:
  shows "Cd d {} = {}"
        "Cd d (insert x A) = (if x \<in> Field (Pd d) then if Cd d A = {} then {x} else {maxR d x y |y. y \<in> Cd d A} else Cd d A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cd d {} = {} &&& Cd d (insert x A) = (if x \<in> Field (Pd d) then if Cd d A = {} then {x} else {maxR d x y |y. y \<in> Cd d A} else Cd d A)
[PROOF STEP]
unfolding Cd.simps MaxR_maxR
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {} = {} &&& (if x \<in> Field (Pd d) then if Cd d A = {} then {x} else {maxR d x y |y. y \<in> Cd d A} else Cd d A) = (if x \<in> Field (Pd d) then if Cd d A = {} then {x} else {maxR d x y |y. y \<in> Cd d A} else Cd d A)
[PROOF STEP]
by simp_all


[STATEMENT]
lemma SPLIT_prodE:
    assumes "SPLIT (x1, y1) (x2, y2)"
    obtains "SPLIT x1 x2" "SPLIT y1 y2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>SPLIT x1 x2; SPLIT y1 y2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
SPLIT (x1, y1) (x2, y2)

goal (1 subgoal):
 1. (\<lbrakk>SPLIT x1 x2; SPLIT y1 y2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding SPLIT_def
[PROOF STATE]
proof (prove)
using this:
(x1, y1) = (x2, y2)

goal (1 subgoal):
 1. (\<lbrakk>x1 = x2; y1 = y2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto


[STATEMENT]
lemma incseq_ereal: "incseq f \<Longrightarrow> incseq (\<lambda>x. ereal (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. incseq f \<Longrightarrow> incseq (\<lambda>x. ereal (f x))
[PROOF STEP]
unfolding incseq_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>m n. m \<le> n \<longrightarrow> f m \<le> f n \<Longrightarrow> \<forall>m n. m \<le> n \<longrightarrow> ereal (f m) \<le> ereal (f n)
[PROOF STEP]
by auto


[STATEMENT]
lemma ennreal_numeral[simp]: "ennreal (numeral n) = numeral n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (numeral n) = numeral n
[PROOF STEP]
using ennreal_of_nat_eq_real_of_nat[of "numeral n"]
[PROOF STATE]
proof (prove)
using this:
of_nat (numeral n) = ennreal (real (numeral n))

goal (1 subgoal):
 1. ennreal (numeral n) = numeral n
[PROOF STEP]
by simp


[STATEMENT]
lemma (in comm_group) cong_DirProds_IDirProds:
  assumes "is_idirprod (carrier G) S I" "finite I"
  shows "DirProds (\<lambda>i. G\<lparr>carrier := (S i)\<rparr>) I \<cong> G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DirProds (\<lambda>i. G\<lparr>carrier := S i\<rparr>) I \<cong> G
[PROOF STEP]
by (intro is_isoI, use iso_DirProds_IDirProds[OF assms] in blast)


[STATEMENT]
lemma expands_to_max_eq:
  assumes "(f expands_to F) basis" "eventually (\<lambda>x. f x = g x) at_top"
  shows   "((\<lambda>x. max (f x) (g x)) expands_to F) basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. max (f x) (g x)) expands_to F) basis
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
(f expands_to F) basis

goal (1 subgoal):
 1. ((\<lambda>x. max (f x) (g x)) expands_to F) basis
[PROOF STEP]
by (rule expands_to_cong) (insert assms(2), auto simp: max_def elim: eventually_mono)


[STATEMENT]
lemma le_trans_trans[trans]:
  "\<lbrakk> le_trans x y; le_trans y z \<rbrakk> \<Longrightarrow> le_trans x z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>le_trans x y; le_trans y z\<rbrakk> \<Longrightarrow> le_trans x z
[PROOF STEP]
unfolding le_trans_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>P. sound P \<longrightarrow> x P \<tturnstile> y P; \<forall>P. sound P \<longrightarrow> y P \<tturnstile> z P\<rbrakk> \<Longrightarrow> \<forall>P. sound P \<longrightarrow> x P \<tturnstile> z P
[PROOF STEP]
by(blast dest:order_trans)


[STATEMENT]
lemma bal_simps:
  "bal 0 xs = (Leaf, xs)"
  "n > 0 \<Longrightarrow>
   bal n xs =
  (let m = n div 2;
      (l, ys) = bal m xs;
      (r, zs) = bal (n-1-m) (tl ys)
  in (Node l (hd ys) r, zs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bal 0 xs = (\<langle>\<rangle>, xs) &&& (0 < n \<Longrightarrow> bal n xs = (let m = n div 2; (l, ys) = bal m xs; (r, zs) = bal (n - 1 - m) (tl ys) in (\<langle>l, hd ys, r\<rangle>, zs)))
[PROOF STEP]
by(simp_all add: bal.simps)


[STATEMENT]
lemma summable_pre_sin: "summable (\<lambda>n. mssnth sin_series_stream n * (x::real) ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
have *: "summable (\<lambda>n. 1 / fact n * abs x ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. 1 / fact n * \<bar>x\<bar> ^ n)
[PROOF STEP]
using exp_converges[of "abs x"]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<bar>x\<bar> ^ n /\<^sub>R fact n) sums exp \<bar>x\<bar>

goal (1 subgoal):
 1. summable (\<lambda>n. 1 / fact n * \<bar>x\<bar> ^ n)
[PROOF STEP]
by (simp add: sums_iff field_simps)
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. 1 / fact n * \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. 1 / fact n * \<bar>x\<bar> ^ n)

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
have "\<bar>x\<bar> ^ n / fact (2 * n + 1) \<le> \<bar>x\<bar> ^ n / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>x\<bar> ^ n / fact (2 * n + 1) \<le> \<bar>x\<bar> ^ n / fact n
[PROOF STEP]
by (intro divide_left_mono fact_mono) auto
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar> ^ n / fact (2 * n + 1) \<le> \<bar>x\<bar> ^ n / fact n

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
hence "norm (mssnth sin_series_stream n * x ^ n) \<le> 1 / fact n * abs x ^ n"
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar> ^ n / fact (2 * n + 1) \<le> \<bar>x\<bar> ^ n / fact n

goal (1 subgoal):
 1. norm (mssnth sin_series_stream n * x ^ n) \<le> 1 / fact n * \<bar>x\<bar> ^ n
[PROOF STEP]
by (simp add: mssnth_sin_series_stream abs_mult power_abs field_simps)
[PROOF STATE]
proof (state)
this:
norm (mssnth sin_series_stream n * x ^ n) \<le> 1 / fact n * \<bar>x\<bar> ^ n

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
norm (mssnth sin_series_stream ?n2 * x ^ ?n2) \<le> 1 / fact ?n2 * \<bar>x\<bar> ^ ?n2

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (mssnth sin_series_stream ?n2 * x ^ ?n2) \<le> 1 / fact ?n2 * \<bar>x\<bar> ^ ?n2

goal (1 subgoal):
 1. summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)
[PROOF STEP]
by (intro summable_comparison_test[OF _ *]) (auto intro!: exI[of _ 0])
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. mssnth sin_series_stream n * x ^ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma product_reachable_snd[simp]:
      assumes "alphabet\<^sub>1 A \<supseteq> alphabet\<^sub>2 B"
      shows "snd ` c.reachable (product A B) (p, q) = b.reachable B q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd ` c.reachable' (product A B) (p, q) = b.reachable' B q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>2 B \<subseteq> alphabet\<^sub>1 A

goal (1 subgoal):
 1. snd ` c.reachable' (product A B) (p, q) = b.reachable' B q
[PROOF STEP]
unfolding a.reachable_alt_def a.path_alt_def
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>2 B \<subseteq> alphabet\<^sub>1 A

goal (1 subgoal):
 1. snd ` c.reachable' (product A B) (p, q) = b.reachable' B q
[PROOF STEP]
unfolding b.reachable_alt_def b.path_alt_def
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>2 B \<subseteq> alphabet\<^sub>1 A

goal (1 subgoal):
 1. snd ` c.reachable' (product A B) (p, q) = {b.target B r q |r. r \<in> lists (alphabet\<^sub>2 B)}
[PROOF STEP]
unfolding c.reachable_alt_def c.path_alt_def
[PROOF STATE]
proof (prove)
using this:
alphabet\<^sub>2 B \<subseteq> alphabet\<^sub>1 A

goal (1 subgoal):
 1. snd ` {c.target (product A B) r (p, q) |r. r \<in> lists (alphabet\<^sub>3 (product A B))} = {b.target B r q |r. r \<in> lists (alphabet\<^sub>2 B)}
[PROOF STEP]
by auto force


[STATEMENT]
lemma field_differentiable_caratheodory_at:
  "f field_differentiable (at z) \<longleftrightarrow>
         (\<exists>g. (\<forall>w. f(w) - f(z) = g(w) * (w - z)) \<and> continuous (at z) g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f field_differentiable at z) = (\<exists>g. (\<forall>w. f w - f z = g w * (w - z)) \<and> isCont g z)
[PROOF STEP]
using CARAT_DERIV [of f]
[PROOF STATE]
proof (prove)
using this:
(f has_field_derivative ?l) (at ?x) = (\<exists>g. (\<forall>z. f z - f ?x = g z * (z - ?x)) \<and> isCont g ?x \<and> g ?x = ?l)

goal (1 subgoal):
 1. (f field_differentiable at z) = (\<exists>g. (\<forall>w. f w - f z = g w * (w - z)) \<and> isCont g z)
[PROOF STEP]
by (simp add: field_differentiable_def has_field_derivative_def)


[STATEMENT]
lemma has_vector_derivative_mult_right[derivative_intros]:
  fixes a :: "'a::real_normed_algebra"
  shows "(f has_vector_derivative x) F \<Longrightarrow> ((\<lambda>x. a * f x) has_vector_derivative (a * x)) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_vector_derivative x) F \<Longrightarrow> ((\<lambda>x. a * f x) has_vector_derivative a * x) F
[PROOF STEP]
by (rule bounded_linear.has_vector_derivative[OF bounded_linear_mult_right])


[STATEMENT]
lemma take_map_index: "take p (map_index f xs) = map_index f (take p xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take p (map_index f xs) = map_index f (take p xs)
[PROOF STEP]
unfolding map_index
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take p (map2 f [0..<length xs] xs) = map2 f [0..<length (take p xs)] (take p xs)
[PROOF STEP]
by (auto simp: min_def take_map take_zip)


[STATEMENT]
lemma replicate_le_diff2: "\<lbrakk> k \<le> m; m \<le> n \<rbrakk> \<Longrightarrow> x\<^bsup>m - k\<^esup> @ x\<^bsup>n - m\<^esup> = x\<^bsup>n - k\<^esup>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>k \<le> m; m \<le> n\<rbrakk> \<Longrightarrow> x\<^bsup>m - k\<^esup> @ x\<^bsup>n - m\<^esup> = x\<^bsup>n - k\<^esup>
[PROOF STEP]
by (subst replicate_add[symmetric], simp)