[STATEMENT]
lemma wp_while:
 "wp (WHILE b DO c) Q =
           (\<lambda>s. if b s then wp (c;WHILE b DO c) Q s else Q s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wp (WHILE b DO c) Q = (\<lambda>s. if b s then wp (c; WHILE b DO c) Q s else Q s)
[PROOF STEP]
apply(rule ext)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>s. wp (WHILE b DO c) Q s = (if b s then wp (c; WHILE b DO c) Q s else Q s)
[PROOF STEP]
apply(unfold wp_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>s. (\<forall>t. s -WHILE b DO c\<rightarrow> t \<longrightarrow> Q t) = (if b s then \<forall>t. s -c; WHILE b DO c\<rightarrow> t \<longrightarrow> Q t else Q s)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>s t ta. \<lbrakk>b s; \<forall>t. s -WHILE b DO c\<rightarrow> t \<longrightarrow> Q t; s -c\<rightarrow> ta; ta -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
 2. \<And>s t. \<lbrakk>b s; \<forall>t. (\<exists>ta. s -c\<rightarrow> ta \<and> ta -WHILE b DO c\<rightarrow> t) \<longrightarrow> Q t; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
 3. \<And>s. \<lbrakk>\<not> b s; \<forall>t. s -WHILE b DO c\<rightarrow> t \<longrightarrow> Q t\<rbrakk> \<Longrightarrow> Q s
 4. \<And>s t. \<lbrakk>\<not> b s; Q s; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
[PROOF STEP]
apply(blast intro:exec.intros)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>s t. \<lbrakk>b s; \<forall>t. (\<exists>ta. s -c\<rightarrow> ta \<and> ta -WHILE b DO c\<rightarrow> t) \<longrightarrow> Q t; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
 2. \<And>s. \<lbrakk>\<not> b s; \<forall>t. s -WHILE b DO c\<rightarrow> t \<longrightarrow> Q t\<rbrakk> \<Longrightarrow> Q s
 3. \<And>s t. \<lbrakk>\<not> b s; Q s; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
[PROOF STEP]
apply(simp add:unfold_while)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>s. \<lbrakk>\<not> b s; \<forall>t. s -WHILE b DO c\<rightarrow> t \<longrightarrow> Q t\<rbrakk> \<Longrightarrow> Q s
 2. \<And>s t. \<lbrakk>\<not> b s; Q s; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
[PROOF STEP]
apply(blast intro:exec.intros)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>s t. \<lbrakk>\<not> b s; Q s; s -WHILE b DO c\<rightarrow> t\<rbrakk> \<Longrightarrow> Q t
[PROOF STEP]
apply(simp add:unfold_while)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma omega_mono: "x \<le> y \<Longrightarrow> x ^ \<omega> \<le> y ^ \<omega>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> x ^ \<omega> \<le> y ^ \<omega>
[PROOF STEP]
apply (cut_tac x = x and y = 1 and z = "y ^ \<omega>" in omega_least, simp_all)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> x * y ^ \<omega> \<sqinter> (1::'a) \<le> y ^ \<omega>
[PROOF STEP]
apply (subst (2) omega_fix, simp_all)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> x * y ^ \<omega> \<sqinter> (1::'a) \<le> y * y ^ \<omega>
[PROOF STEP]
apply (rule_tac y = "x * y ^ \<omega>" in order_trans, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> x * y ^ \<omega> \<le> y * y ^ \<omega>
[PROOF STEP]
by (rule le_comp_right, simp)


[STATEMENT]
lemma ordinal_modI: "\<lbrakk>x = y * q + r; r < y\<rbrakk> \<Longrightarrow> x mod y = (r::ordinal)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x = y * q + r; r < y\<rbrakk> \<Longrightarrow> x mod y = r
[PROOF STEP]
apply (unfold mod_ordinal_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x = y * q + r; r < y\<rbrakk> \<Longrightarrow> x - y * (x div y) = r
[PROOF STEP]
apply (rule ordinal_minusI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x = y * q + r; r < y\<rbrakk> \<Longrightarrow> x = y * (x div y) + r
[PROOF STEP]
apply (simp add: ordinal_divI)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma assoc'_apply[simp]: \<open>assoc' (a \<otimes>\<^sub>u (b \<otimes>\<^sub>u c)) =  ((a \<otimes>\<^sub>u b) \<otimes>\<^sub>u c)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. assoc' (a \<otimes>\<^sub>u b \<otimes>\<^sub>u c) = (a \<otimes>\<^sub>u b) \<otimes>\<^sub>u c
[PROOF STEP]
by (auto simp: assoc'_def register_pair_apply Fst_def Snd_def tensor_update_mult)


[STATEMENT]
lemma HNatInfinite_diff: "\<lbrakk>x \<in> HNatInfinite; y \<in> Nats\<rbrakk> \<Longrightarrow> x - y \<in> HNatInfinite"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> HNatInfinite; y \<in> \<nat>\<rbrakk> \<Longrightarrow> x - y \<in> HNatInfinite
[PROOF STEP]
by (metis HNatInfinite_not_Nats_iff Nats_add Nats_le_HNatInfinite le_add_diff_inverse)


[STATEMENT]
theorem insert_bound_size_univ: "invar_vebt t n \<Longrightarrow> u =  2^n \<Longrightarrow>   T\<^sub>i\<^sub>n\<^sub>s\<^sub>e\<^sub>r\<^sub>t t x \<le> 46 + 23 * lb (lb u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; u = 2 ^ n\<rbrakk> \<Longrightarrow> real (T\<^sub>i\<^sub>n\<^sub>s\<^sub>e\<^sub>r\<^sub>t t x) \<le> 46 + 23 * log 2 (log 2 u)
[PROOF STEP]
using insert_bound_height[of t n x]  height_double_log_univ_size[of u n t] algebra_simps
[PROOF STATE]
proof (prove)
using this:
invar_vebt t n \<Longrightarrow> T\<^sub>i\<^sub>n\<^sub>s\<^sub>e\<^sub>r\<^sub>t t x \<le> (1 + height t) * 23
\<lbrakk>u = 2 ^ n; invar_vebt t n\<rbrakk> \<Longrightarrow> real (height t) \<le> 1 + log 2 (log 2 u)
?a + ?b + ?c = ?a + (?b + ?c)
?a + ?b = ?b + ?a
?b + (?a + ?c) = ?a + (?b + ?c)
?a * ?b * ?c = ?a * (?b * ?c)
?a * ?b = ?b * ?a
?b * (?a * ?c) = ?a * (?b * ?c)
?a - ?b - ?c = ?a - (?b + ?c)
?a + (?b - ?c) = ?a + ?b - ?c
(?a - ?b = ?c) = (?a = ?c + ?b)
(?a = ?c - ?b) = (?a + ?b = ?c)
?a - (?b - ?c) = ?a + ?c - ?b
?a - ?b + ?c = ?a + ?c - ?b
(?a - ?b < ?c) = (?a < ?c + ?b)
(?a < ?c - ?b) = (?a + ?b < ?c)
(?a - ?b \<le> ?c) = (?a \<le> ?c + ?b)
(?a \<le> ?c - ?b) = (?a + ?b \<le> ?c)
(?a + ?b) * ?c = ?a * ?c + ?b * ?c
?a * (?b + ?c) = ?a * ?b + ?a * ?c
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?b - ?c) * ?a = ?b * ?a - ?c * ?a
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?a - ?b) * ?c = ?a * ?c - ?b * ?c
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n
?a *\<^sub>R (?x + ?y) = ?a *\<^sub>R ?x + ?a *\<^sub>R ?y
(?a + ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x + ?b *\<^sub>R ?x
(?a - ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x - ?b *\<^sub>R ?x
?a *\<^sub>R (?x - ?y) = ?a *\<^sub>R ?x - ?a *\<^sub>R ?y

goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; u = 2 ^ n\<rbrakk> \<Longrightarrow> real (T\<^sub>i\<^sub>n\<^sub>s\<^sub>e\<^sub>r\<^sub>t t x) \<le> 46 + 23 * log 2 (log 2 u)
[PROOF STEP]
by simp


[STATEMENT]
lemma minus_plus_sub:
  assumes " a \<in> carrier R"
  shows "X_minus a of X_plus a = X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cring_Poly.compose R (X_poly_minus R a) (X_poly_plus R a) = X_poly R
[PROOF STEP]
using plus_minus_sub[of "\<ominus>a"]
[PROOF STATE]
proof (prove)
using this:
\<ominus> a \<in> carrier R \<Longrightarrow> Cring_Poly.compose R (X_poly_plus R (\<ominus> a)) (X_poly_minus R (\<ominus> a)) = X_poly R

goal (1 subgoal):
 1. Cring_Poly.compose R (X_poly_minus R a) (X_poly_plus R a) = X_poly R
[PROOF STEP]
unfolding X_poly_minus_def
[PROOF STATE]
proof (prove)
using this:
\<ominus> a \<in> carrier R \<Longrightarrow> Cring_Poly.compose R (X_poly_plus R (\<ominus> a)) (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) = X_poly R

goal (1 subgoal):
 1. Cring_Poly.compose R (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R a) (X_poly_plus R a) = X_poly R
[PROOF STEP]
unfolding X_poly_plus_def
[PROOF STATE]
proof (prove)
using this:
\<ominus> a \<in> carrier R \<Longrightarrow> Cring_Poly.compose R (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) = X_poly R

goal (1 subgoal):
 1. Cring_Poly.compose R (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R a) (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R a) = X_poly R
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<ominus> a \<in> carrier R \<Longrightarrow> Cring_Poly.compose R (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) = X_poly R
a \<in> carrier R

goal (1 subgoal):
 1. Cring_Poly.compose R (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R a) (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R a) = X_poly R
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Cring_Poly.compose R (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R (\<ominus> a)) = X_poly R; a \<in> carrier R\<rbrakk> \<Longrightarrow> Cring_Poly.compose R (X_poly R \<ominus>\<^bsub>UP R\<^esub> to_polynomial R a) (X_poly R \<oplus>\<^bsub>UP R\<^esub> to_polynomial R a) = X_poly R
[PROOF STEP]
by (metis P_def R.add.inv_closed R.minus_minus a_minus_def to_poly_a_inv)


[STATEMENT]
lemma max_factor_degree: assumes sub: "mset ws \<subseteq># mset vs"
  and len: "length ws + length ws \<le> length vs"
  shows "degree (prod_list ws) \<le> max_factor_degree (map degree vs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
define ds where "ds \<equiv> map degree ws"
[PROOF STATE]
proof (state)
this:
ds \<equiv> map degree ws

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
define es where "es \<equiv> sort (map degree vs)"
[PROOF STATE]
proof (state)
this:
es \<equiv> sort (map degree vs)

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
from sub len
[PROOF STATE]
proof (chain)
picking this:
mset ws \<subseteq># mset vs
length ws + length ws \<le> length vs
[PROOF STEP]
have sub: "mset ds \<subseteq># mset es" and len: "length ds + length ds \<le> length es"
    and es: "sorted es"
[PROOF STATE]
proof (prove)
using this:
mset ws \<subseteq># mset vs
length ws + length ws \<le> length vs

goal (1 subgoal):
 1. mset ds \<subseteq># mset es &&& length ds + length ds \<le> length es &&& sorted es
[PROOF STEP]
unfolding ds_def es_def
[PROOF STATE]
proof (prove)
using this:
mset ws \<subseteq># mset vs
length ws + length ws \<le> length vs

goal (1 subgoal):
 1. mset (map degree ws) \<subseteq># mset (sort (map degree vs)) &&& length (map degree ws) + length (map degree ws) \<le> length (sort (map degree vs)) &&& sorted (sort (map degree vs))
[PROOF STEP]
by (auto simp: image_mset_subseteq_mono)
[PROOF STATE]
proof (state)
this:
mset ds \<subseteq># mset es
length ds + length ds \<le> length es
sorted es

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
have "degree (prod_list ws) \<le> sum_list (map degree ws)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (prod_list ws) \<le> sum_list (map degree ws)
[PROOF STEP]
by (rule degree_prod_list_le)
[PROOF STATE]
proof (state)
this:
degree (prod_list ws) \<le> sum_list (map degree ws)

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
degree (prod_list ws) \<le> sum_list (map degree ws)

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
have "\<dots> \<le> max_factor_degree (map degree vs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map degree ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
unfolding max_factor_degree_def Let_def ds_def[symmetric] es_def[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list ds \<le> sum_list (drop (length es div 2) es)
[PROOF STEP]
using sub len es
[PROOF STATE]
proof (prove)
using this:
mset ds \<subseteq># mset es
length ds + length ds \<le> length es
sorted es

goal (1 subgoal):
 1. sum_list ds \<le> sum_list (drop (length es div 2) es)
[PROOF STEP]
by (rule max_factor_degree_aux)
[PROOF STATE]
proof (state)
this:
sum_list (map degree ws) \<le> max_factor_degree (map degree vs)

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
degree (prod_list ws) \<le> max_factor_degree (map degree vs)

goal (1 subgoal):
 1. degree (prod_list ws) \<le> max_factor_degree (map degree vs)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
degree (prod_list ws) \<le> max_factor_degree (map degree vs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closure_eq_empty [iff]: "closure S = {} \<longleftrightarrow> S = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (closure S = {}) = (S = {})
[PROOF STEP]
using closure_empty closure_subset[of S]
[PROOF STATE]
proof (prove)
using this:
closure {} = {}
S \<subseteq> closure S

goal (1 subgoal):
 1. (closure S = {}) = (S = {})
[PROOF STEP]
by blast


[STATEMENT]
lemma insert_sort_by_perm :
  "(insert_sort_by cmp l) <~~> l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (insert_sort_by cmp l) = mset l
[PROOF STEP]
by (induction l) (simp_all add: insert_sort_insert_by_perm)


[STATEMENT]
lemma power_half_summable:
 "summable (\<lambda>n. ((1::real) / 2) ^ Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. (1 / 2) ^ Suc n)
[PROOF STEP]
using power_half_series summable_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. (1 / 2) ^ Suc n) sums 1
summable ?f = (\<exists>s. ?f sums s)

goal (1 subgoal):
 1. summable (\<lambda>n. (1 / 2) ^ Suc n)
[PROOF STEP]
by blast


[STATEMENT]
lemma bij_swap_iff: "bij (Fun.swap a b f) \<longleftrightarrow> bij f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij (f \<circ> Transposition.transpose a b) = bij f
[PROOF STEP]
by (simp add: bij_betw_swap_iff)


[STATEMENT]
lemma agg_sum_bot:
  "(\<Sum>\<^sub>k bot::'a::aggregation_order) = bot + bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aggregation.sum_0 (\<lambda>k. bot) {k. True} = zero
[PROOF STEP]
proof (induct rule: infinite_finite_induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) A = zero
 2. aggregation.sum_0 (\<lambda>k. bot) {} = zero
 3. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
case (infinite A)
[PROOF STATE]
proof (state)
this:
infinite A

goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) A = zero
 2. aggregation.sum_0 (\<lambda>k. bot) {} = zero
 3. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
infinite A

goal (1 subgoal):
 1. aggregation.sum_0 (\<lambda>k. bot) A = zero
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
aggregation.sum_0 (\<lambda>k. bot) A = zero

goal (2 subgoals):
 1. aggregation.sum_0 (\<lambda>k. bot) {} = zero
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. aggregation.sum_0 (\<lambda>k. bot) {} = zero
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. aggregation.sum_0 (\<lambda>k. bot) {} = zero
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aggregation.sum_0 (\<lambda>k. bot) {} = zero
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
aggregation.sum_0 (\<lambda>k. bot) {} = zero

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
case (insert x F)
[PROOF STATE]
proof (state)
this:
finite F
x \<notin> F
aggregation.sum_0 (\<lambda>k. bot) F = zero

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; aggregation.sum_0 (\<lambda>k. bot) F = zero\<rbrakk> \<Longrightarrow> aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
finite F
x \<notin> F
aggregation.sum_0 (\<lambda>k. bot) F = zero

goal (1 subgoal):
 1. aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero
[PROOF STEP]
by (metis add.commute add_add_bot aggregation.sum_0.insert)
[PROOF STATE]
proof (state)
this:
aggregation.sum_0 (\<lambda>k. bot) (insert x F) = zero

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma embedding_map_eq:
   "\<lbrakk>embedding_map X Y f; \<And>x. x \<in> topspace X \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> embedding_map X Y g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>embedding_map X Y f; \<And>x. x \<in> topspace X \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> embedding_map X Y g
[PROOF STEP]
unfolding embedding_map_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>homeomorphic_map X (subtopology Y (f ` topspace X)) f; \<And>x. x \<in> topspace X \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> homeomorphic_map X (subtopology Y (g ` topspace X)) g
[PROOF STEP]
by (metis homeomorphic_map_eq image_cong)


[STATEMENT]
lemma ladder_n_minus_1_bound: "is_ladder D L \<Longrightarrow> index \<ge> 1 \<Longrightarrow> index < length L \<Longrightarrow>
  ladder_n L (index - Suc 0) < length D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_ladder D L; 1 \<le> index; index < length L\<rbrakk> \<Longrightarrow> ladder_n L (index - Suc 0) < length D
[PROOF STEP]
by (metis (no_types, lifting) One_nat_def Suc_diff_1 Suc_le_lessD dual_order.strict_implies_order
  is_ladder_def le_neq_implies_less not_less)


[STATEMENT]
lemma sigma_finite_measure_count_space_finite:
  assumes A: "finite A" shows "sigma_finite_measure (count_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_finite_measure (count_space A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sigma_finite_measure (count_space A)
[PROOF STEP]
interpret finite_measure "count_space A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_measure (count_space A)
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. finite_measure (count_space A)
[PROOF STEP]
by (rule finite_measure_count_space)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sigma_finite_measure (count_space A)
[PROOF STEP]
show "sigma_finite_measure (count_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_finite_measure (count_space A)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
sigma_finite_measure (count_space A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma word_induct2 [case_names zero suc, induct type]: "P 0 \<Longrightarrow> (\<And>n. 1 + n \<noteq> 0 \<Longrightarrow> P n \<Longrightarrow> P (1 + n)) \<Longrightarrow> P n"
  for P :: "'b::len word \<Rightarrow> bool"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>P 0; \<And>n. \<lbrakk>1 + n \<noteq> 0; P n\<rbrakk> \<Longrightarrow> P (1 + n)\<rbrakk> \<Longrightarrow> P n
[PROOF STEP]
by (induction rule: word_induct_less; force)


[STATEMENT]
lemma "\<lbrakk> rbt l; rbt r \<rbrakk> \<Longrightarrow> bheight(join l x r) \<le> max (bheight l) (bheight r) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>rbt l; rbt r\<rbrakk> \<Longrightarrow> bheight (Set2_Join_RBT.join l x r) \<le> max (bheight l) (bheight r) + 1
[PROOF STEP]
using bheight_paint_Black[of "joinL l x r"] bheight_paint_Black[of "joinR l x r"]
  bheight_joinL[of l r x] bheight_joinR[of l r x]
[PROOF STATE]
proof (prove)
using this:
bheight (paint Black (joinL l x r)) \<le> bheight (joinL l x r) + 1
bheight (paint Black (joinR l x r)) \<le> bheight (joinR l x r) + 1
\<lbrakk>invh l; invh r; bheight l \<le> bheight r\<rbrakk> \<Longrightarrow> bheight (joinL l x r) = bheight r
\<lbrakk>invh l; invh r; bheight r \<le> bheight l\<rbrakk> \<Longrightarrow> bheight (joinR l x r) = bheight l

goal (1 subgoal):
 1. \<lbrakk>rbt l; rbt r\<rbrakk> \<Longrightarrow> bheight (Set2_Join_RBT.join l x r) \<le> max (bheight l) (bheight r) + 1
[PROOF STEP]
by(auto simp: max_def rbt_def join_def)


[STATEMENT]
lemma \<K>_rw2:
  assumes "0 < k"
shows "(\<Sum>m=0..<Suc (k * max_len). card (set_of_k_words_length_m k m)/ b^m) \<le> (k * max_len)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
have
    "(\<Sum>m=1..<Suc (k * max_len). card (set_of_k_words_length_m k m) / b^m)
    \<le> (\<Sum>m=1..<Suc(k * max_len). b^m / b^m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)
[PROOF STEP]
using set_of_k_words_bound b_val
    Groups_Big.sum_mono[of "{1..<Suc(k * max_len)}"
    "(\<lambda>m. (card (set_of_k_words_length_m k m))/b^m)" "\<lambda>m. b^m /b^m"]
[PROOF STATE]
proof (prove)
using this:
real (card (set_of_k_words_length_m ?k ?m)) \<le> b ^ ?m
b = 2
(\<And>i. i \<in> {1..<Suc (k * max_len)} \<Longrightarrow> real (card (set_of_k_words_length_m k i)) / b ^ i \<le> b ^ i / b ^ i) \<Longrightarrow> (\<Sum>i = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k i)) / b ^ i) \<le> (\<Sum>i = 1..<Suc (k * max_len). b ^ i / b ^ i)

goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
have"(\<Sum>m=1..<Suc(k * max_len). b^m / b^m) = (\<Sum>m=1..<Suc(k *max_len). 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)
[PROOF STEP]
using b_gt_1
[PROOF STATE]
proof (prove)
using this:
1 < b

goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
have "(\<Sum>m=1..<Suc(k * max_len). 1) = (k * max_len)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). 1) = k * max_len
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). 1) = k * max_len

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)
(\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)
(\<Sum>m = 1..<Suc (k * max_len). 1) = k * max_len
[PROOF STEP]
have
    "(\<Sum>m = 1..<Suc (k * max_len). card (set_of_k_words_length_m k m) / b ^ m) \<le> k * max_len"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> (\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m)
(\<Sum>m = 1..<Suc (k * max_len). b ^ m / b ^ m) = (\<Sum>m = 1..<Suc (k * max_len). 1)
(\<Sum>m = 1..<Suc (k * max_len). 1) = k * max_len

goal (1 subgoal):
 1. (\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
by (metis One_nat_def card_atLeastLessThan card_eq_sum diff_Suc_Suc real_of_card)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
using empty_set_k_words assms
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 1..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
0 < ?k \<Longrightarrow> set_of_k_words_length_m ?k 0 = {}
0 < k

goal (1 subgoal):
 1. (\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)
[PROOF STEP]
by (simp add: sum_shift_lb_Suc0_0_upt split: if_split_asm)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 0..<Suc (k * max_len). real (card (set_of_k_words_length_m k m)) / b ^ m) \<le> real (k * max_len)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma positive_gauss_norm_valuation_ring_coeffs:
  assumes "g \<in> carrier Q\<^sub>p_x"
  assumes "gauss_norm g \<ge> 0"
  shows "g n \<in> \<O>\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g n \<in> \<O>\<^sub>p
[PROOF STEP]
apply(rule val_ringI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. g n \<in> carrier Q\<^sub>p
 2. 0 \<le> val (g n)
[PROOF STEP]
using cfs_closed assms(1)
[PROOF STATE]
proof (prove)
using this:
?f \<in> carrier (UP Q\<^sub>p) \<Longrightarrow> ?f ?n \<in> carrier Q\<^sub>p
g \<in> carrier (UP Q\<^sub>p)

goal (2 subgoals):
 1. g n \<in> carrier Q\<^sub>p
 2. 0 \<le> val (g n)
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> val (g n)
[PROOF STEP]
using gauss_normE[of g n] assms
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier (UP Q\<^sub>p) \<Longrightarrow> gauss_norm g \<le> val (g n)
g \<in> carrier (UP Q\<^sub>p)
0 \<le> gauss_norm g

goal (1 subgoal):
 1. 0 \<le> val (g n)
[PROOF STEP]
by auto


[STATEMENT]
lemma drop_bit_int_code [code]:
  fixes i :: int shows
  \<open>drop_bit 0 i = i\<close>
  \<open>drop_bit (Suc n) 0 = (0 :: int)\<close>
  \<open>drop_bit (Suc n) (Int.Pos num.One) = 0\<close>
  \<open>drop_bit (Suc n) (Int.Pos (num.Bit0 m)) = drop_bit n (Int.Pos m)\<close>
  \<open>drop_bit (Suc n) (Int.Pos (num.Bit1 m)) = drop_bit n (Int.Pos m)\<close>
  \<open>drop_bit (Suc n) (Int.Neg num.One) = - 1\<close>
  \<open>drop_bit (Suc n) (Int.Neg (num.Bit0 m)) = drop_bit n (Int.Neg m)\<close>
  \<open>drop_bit (Suc n) (Int.Neg (num.Bit1 m)) = drop_bit n (Int.Neg (Num.inc m))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((drop_bit 0 i = i &&& drop_bit (Suc n) 0 = 0) &&& drop_bit (Suc n) (Int.Pos num.One) = 0 &&& drop_bit (Suc n) (Int.Pos (num.Bit0 m)) = drop_bit n (Int.Pos m)) &&& (drop_bit (Suc n) (Int.Pos (num.Bit1 m)) = drop_bit n (Int.Pos m) &&& drop_bit (Suc n) (Int.Neg num.One) = - 1) &&& drop_bit (Suc n) (Int.Neg (num.Bit0 m)) = drop_bit n (Int.Neg m) &&& drop_bit (Suc n) (Int.Neg (num.Bit1 m)) = drop_bit n (Int.Neg (Num.inc m))
[PROOF STEP]
by (simp_all add: drop_bit_Suc add_One)


[STATEMENT]
lemma less_rat [simp]:
  "b \<noteq> 0 \<Longrightarrow> d \<noteq> 0 \<Longrightarrow> Fract a b < Fract c d \<longleftrightarrow> (a * d) * (b * d) < (c * b) * (b * d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b \<noteq> 0; d \<noteq> 0\<rbrakk> \<Longrightarrow> (Fract a b < Fract c d) = (a * d * (b * d) < c * b * (b * d))
[PROOF STEP]
by (simp add: less_rat_def positive_rat algebra_simps)


[STATEMENT]
lemma LIMSEQ_indicator_INT:
  "(\<lambda>k. indicator (\<Inter>i<k. A i) x :: 'a::{topological_space,zero_neq_one}) \<longlonglongrightarrow> indicator (\<Inter>i. A i) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
have "(\<lambda>k. indicator (\<Inter>i<k. A i) x::'a) \<longlonglongrightarrow> indicator (\<Inter>k. \<Inter>i<k. A i) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter>k. \<Inter> (A ` {..<k})) x
[PROOF STEP]
by (intro LIMSEQ_indicator_decseq) (auto simp: decseq_def intro: less_le_trans)
[PROOF STATE]
proof (state)
this:
(\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter>k. \<Inter> (A ` {..<k})) x

goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter>k. \<Inter> (A ` {..<k})) x

goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
have "(\<Inter>k. \<Inter>i<k. A i) = (\<Inter>i. A i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Inter>k. \<Inter> (A ` {..<k})) = \<Inter> (range A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Inter>k. \<Inter> (A ` {..<k})) = \<Inter> (range A)

goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x

goal (1 subgoal):
 1. (\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>k. indicator (\<Inter> (A ` {..<k})) x) \<longlonglongrightarrow> indicator (\<Inter> (range A)) x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in Module) mQmpTr2:"\<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N ;
        X \<in> carrier (M /\<^sub>m H)\<rbrakk> \<Longrightarrow> (mQmp M H N) X \<in> carrier (M /\<^sub>m N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N; X \<in> carrier (M /\<^sub>m H)\<rbrakk> \<Longrightarrow> (Mp\<^bsub>M  H,N\<^esub>) X \<in> carrier (M /\<^sub>m N)
[PROOF STEP]
apply (simp add:qmodule_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N; X \<in> set_mr_cos M H\<rbrakk> \<Longrightarrow> (Mp\<^bsub>M  H,N\<^esub>) X \<in> set_mr_cos M N
[PROOF STEP]
apply (simp add:set_mr_cos_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N; \<exists>a\<in>carrier M. X = a \<uplus>\<^bsub>M\<^esub> H\<rbrakk> \<Longrightarrow> \<exists>a\<in>carrier M. (Mp\<^bsub>M  H,N\<^esub>) X = a \<uplus>\<^bsub>M\<^esub> N
[PROOF STEP]
apply (erule bexE, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. \<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N; a \<in> carrier M; X = a \<uplus>\<^bsub>M\<^esub> H\<rbrakk> \<Longrightarrow> \<exists>aa\<in>carrier M. (Mp\<^bsub>M  H,N\<^esub>) (a \<uplus>\<^bsub>M\<^esub> H) = aa \<uplus>\<^bsub>M\<^esub> N
[PROOF STEP]
apply (frule_tac m = a in mQmpTr0 [of H N], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. \<lbrakk>submodule R M H; submodule R M N; H \<subseteq> N; a \<in> carrier M; X = a \<uplus>\<^bsub>M\<^esub> H; (Mp\<^bsub>M  H,N\<^esub>) (a \<uplus>\<^bsub>M\<^esub> H) = a \<uplus>\<^bsub>M\<^esub> N\<rbrakk> \<Longrightarrow> \<exists>aa\<in>carrier M. (Mp\<^bsub>M  H,N\<^esub>) (a \<uplus>\<^bsub>M\<^esub> H) = aa \<uplus>\<^bsub>M\<^esub> N
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma i_f_join_i_shrink_iT_Plus_iT_Div_mod: "
  \<lbrakk> 0 < k; finite I; \<forall>x\<in>I. x mod k = 0 \<rbrakk> \<Longrightarrow>
  (f \<longmapsto>\<^sub>i k) \<Join>\<^bsub>i-f\<^esub> (I \<oplus> (k - 1))= f \<div>\<^sub>i k \<Join>\<^bsub>i-f\<^esub> (I \<oslash> k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0\<rbrakk> \<Longrightarrow> f \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - 1) = f \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (case_tac "I = {}")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I = {}\<rbrakk> \<Longrightarrow> f \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - 1) = f \<div> k \<Join>\<^sub> (I \<oslash> k)
 2. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - 1) = f \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: iT_Plus_empty iT_Div_empty i_f_join_empty)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - 1) = f \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: i_f_join_def iT_Plus_Max iT_Div_Max)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<longmapsto> k \<Down> (Max I + k) \<Join>\<^sub> (I \<oplus> k - Suc 0) = f \<div> k \<Down> Suc (Max I div k) \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: i_last_message_hold_i_take[symmetric] i_shrink_i_take_mult[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<Down> (Max I + k) \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - Suc 0) = f \<Down> (k + Max I div k * k) \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: add.commute[of k])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<Down> (Max I + k) \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - Suc 0) = f \<Down> (Max I div k * k + k) \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: mod_0_div_mult_cancel[THEN iffD1])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; finite I; \<forall>x\<in>I. x mod k = 0; I \<noteq> {}\<rbrakk> \<Longrightarrow> f \<Down> (Max I + k) \<longmapsto> k \<Join>\<^sub> (I \<oplus> k - Suc 0) = f \<Down> (Max I + k) \<div> k \<Join>\<^sub> (I \<oslash> k)
[PROOF STEP]
apply (simp add: f_join_f_shrink_iT_Plus_iT_Div_mod[unfolded One_nat_def])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma zero_le_mat_iff [simp]: "0 \<le> mat (x :: 'c :: {zero, order}) \<longleftrightarrow> 0 \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 \<le> mat x) = ((0::'c) \<le> x)
[PROOF STEP]
by (auto simp: Finite_Cartesian_Product.less_eq_vec_def mat_def)


[STATEMENT]
lemma union_less_mono:
  fixes A B C D :: "'a::preorder multiset"
  shows "A < C \<Longrightarrow> B < D \<Longrightarrow> A + B < C + D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A < C; B < D\<rbrakk> \<Longrightarrow> A + B < C + D
[PROOF STEP]
by (blast intro!: union_le_mono1 union_le_mono2 less_trans)


[STATEMENT]
lemma dim_mult_mat_vec[simp]: "dim_vec (A *\<^sub>v v) = dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (A *\<^sub>v v) = dim_row A
[PROOF STEP]
by (auto simp: mult_mat_vec_def)


[STATEMENT]
lemma map2set_finite[relator_props]:
  assumes "finite_map_rel (\<langle>Rk,Id\<rangle>R)"
  shows "finite_set_rel (\<langle>Rk\<rangle>map2set_rel R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_set_rel (\<langle>Rk\<rangle>map2set_rel R)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite_map_rel (\<langle>Rk, unit_rel\<rangle>R)

goal (1 subgoal):
 1. finite_set_rel (\<langle>Rk\<rangle>map2set_rel R)
[PROOF STEP]
unfolding map2set_rel_def finite_set_rel_def finite_map_rel_def
[PROOF STATE]
proof (prove)
using this:
Range (\<langle>Rk, unit_rel\<rangle>R) \<subseteq> Collect (finite \<circ> dom)

goal (1 subgoal):
 1. Range (\<langle>Rk, unit_rel\<rangle>R O {(m, dom m) |m. True}) \<subseteq> Collect finite
[PROOF STEP]
by auto


[STATEMENT]
lemma det_swap_final_cols: assumes A: "A \<in> carrier_mat m m"
  and m: "m = l + k + n"
  shows "det A = (- 1) ^ (k * n) *
    det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
have "det A = det (A\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = det A\<^sup>T
[PROOF STEP]
unfolding det_transpose[OF A]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = det A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
det A = det A\<^sup>T

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det A = det A\<^sup>T

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
have "\<dots> = (- 1) ^ (k * n) *
    det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))"
    (is "_ = _ * det ?M")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A\<^sup>T = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))
[PROOF STEP]
by (rule det_swap_final_rows[OF _ m], insert A, auto)
[PROOF STATE]
proof (state)
this:
det A\<^sup>T = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det A\<^sup>T = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
have "det ?M = det (?M\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j))) = det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))\<^sup>T
[PROOF STEP]
by (subst det_transpose, auto)
[PROOF STATE]
proof (state)
this:
det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j))) = det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))\<^sup>T

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j))) = det (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))\<^sup>T

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
have "?M\<^sup>T = mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))\<^sup>T = mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n))
[PROOF STEP]
unfolding transpose_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (dim_col (mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)))) (dim_row (mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)))) (\<lambda>(i, j). mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)) $$ (j, i)) = mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n))
[PROOF STEP]
using A m
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m m
m = l + k + n

goal (1 subgoal):
 1. mat (dim_col (mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)))) (dim_row (mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)))) (\<lambda>(i, j). mat m m (\<lambda>(i, j). mat (dim_col A) (dim_row A) (\<lambda>(i, j). A $$ (j, i)) $$ (if i < l then i else if i < l + n then i + k else i - n, j)) $$ (j, i)) = mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n))
[PROOF STEP]
by (intro eq_matI, auto)
[PROOF STATE]
proof (state)
this:
(mat m m (\<lambda>(i, j). A\<^sup>T $$ (if i < l then i else if i < l + n then i + k else i - n, j)))\<^sup>T = mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n))

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
det A = (- (1::'a)) ^ (k * n) * det (mat m m (\<lambda>(i, j). A $$ (i, if j < l then j else if j < l + n then j + k else j - n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma [simp]:
  shows max_eSuc_eSuc: "max (eSuc n) (eSuc m) = eSuc (max n m)"
  and min_eSuc_eSuc: "min (eSuc n) (eSuc m) = eSuc (min n m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (eSuc n) (eSuc m) = eSuc (max n m) &&& min (eSuc n) (eSuc m) = eSuc (min n m)
[PROOF STEP]
by(simp_all add: eSuc_def split: enat.split)


[STATEMENT]
lemma Max_less_iMin_imp_less: "
  \<lbrakk> finite A; Max A < iMin B; a \<in> A; b \<in> B \<rbrakk> \<Longrightarrow> a < b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; Max A < iMin B; a \<in> A; b \<in> B\<rbrakk> \<Longrightarrow> a < b
[PROOF STEP]
by (blast dest: Max_less_iff intro: order_less_le_trans iMin_le)


[STATEMENT]
lemma sup_corr_eq_chain: "\<And>M::('a::complete_lattice*'a) set. (\<forall>(A,B)\<in>M. f(A)=g(B)) \<Longrightarrow> (Sup {f(A) | A. A\<in>fst_proj M} = Sup {g(B) | B. B\<in>snd_proj M})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>M. \<forall>(A, B)\<in>M. f A = g B \<Longrightarrow> Sup {f A |A. A \<in> fst_proj M} = Sup {g B |B. B \<in> snd_proj M}
[PROOF STEP]
by (metis (mono_tags, lifting) case_prod_conv fst_proj_mem snd_proj_mem)


[STATEMENT]
lemma continuous_compose:
  "\<lbrakk> continuous f S T; continuous g T U \<rbrakk> \<Longrightarrow> continuous (g \<circ> f) S U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>continuous f S T; continuous g T U\<rbrakk> \<Longrightarrow> continuous (g \<circ> f) S U
[PROOF STEP]
by (auto intro!: continuousI funcset_comp
       elim!: continuousE simp add: vimage_comp)


[STATEMENT]
lemma in_keys_mapI: "x \<in> keys m \<Longrightarrow> f (lookup m x) \<noteq> 0 \<Longrightarrow> x \<in> keys (Poly_Mapping.map f m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> keys m; f (lookup m x) \<noteq> (0::'c)\<rbrakk> \<Longrightarrow> x \<in> keys (Poly_Mapping.map f m)
[PROOF STEP]
by transfer auto


[STATEMENT]
lemma hamming_unfold:
  "hamming = LCons 1 (lmerge (lmap ((*) 2) hamming) (lmerge (lmap ((*) 3) hamming) (lmap ((*) 5) hamming)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hamming = LCons 1 (lmerge (lmap ((*) 2) hamming) (lmerge (lmap ((*) 3) hamming) (lmap ((*) 5) hamming)))
[PROOF STEP]
by(rule llist.expand) simp_all


[STATEMENT]
lemma size_less_than_median_of_medians_strong:
  fixes xs :: "'a :: linorder list" and d :: nat
  assumes d: "d > 0"
  assumes median: "\<And>xs. xs \<noteq> [] \<Longrightarrow> length xs \<le> d \<Longrightarrow> is_median (med xs) xs"
  assumes median': "is_median x (map med (chop d xs))"
  defines "m \<equiv> length (chop d xs)"
  shows   "size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define n where [simp]: "n = length xs"
  \<comment> \<open>The medians of the sublists\<close>
[PROOF STATE]
proof (state)
this:
n = length xs

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define M where "M = mset (map med (chop d xs))"
[PROOF STATE]
proof (state)
this:
M = mset (map med (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS where "YS = mset (chop d xs)"
  \<comment> \<open>The sublists with a smaller median than the median-of-medians @{term x} and the rest.\<close>
[PROOF STATE]
proof (state)
this:
YS = mset (chop d xs)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS1 where "YS1 = filter_mset (\<lambda>ys. med ys < x) (mset (chop d xs))"
[PROOF STATE]
proof (state)
this:
YS1 = {#ys \<in># mset (chop d xs). med ys < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS2 where "YS2 = filter_mset (\<lambda>ys. \<not>(med ys < x)) (mset (chop d xs))"

  \<comment> \<open>At most roughly half of the lists have a median that is smaller than @{term M}\<close>
[PROOF STATE]
proof (state)
this:
YS2 = {#ys \<in># mset (chop d xs). \<not> med ys < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 = size (image_mset med YS1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 = size (image_mset med YS1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
size YS1 = size (image_mset med YS1)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 = size (image_mset med YS1)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}
[PROOF STEP]
unfolding YS1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset med {#ys \<in># mset (chop d xs). med ys < x#} = {#y \<in># mset (map med (chop d xs)). y < x#}
[PROOF STEP]
by (subst filter_mset_image_mset [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size \<dots> \<le> (length (map med (chop d xs))) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
using median'
[PROOF STATE]
proof (prove)
using this:
is_median x (map med (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
unfolding is_median_altdef
[PROOF STATE]
proof (prove)
using this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2 \<and> size (filter_mset ((<) x) (mset (map med (chop d xs)))) \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = m div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map med (chop d xs)) div 2 = m div 2
[PROOF STEP]
by (simp add: m_def)
[PROOF STATE]
proof (state)
this:
length (map med (chop d xs)) div 2 = m div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
size YS1 \<le> m div 2
[PROOF STEP]
have size_YS1: "size YS1 \<le> m div 2"
[PROOF STATE]
proof (prove)
using this:
size YS1 \<le> m div 2

goal (1 subgoal):
 1. size YS1 \<le> m div 2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
size YS1 \<le> m div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "m = size (mset (chop d xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m = size (mset (chop d xs))
[PROOF STEP]
by (simp add: m_def)
[PROOF STATE]
proof (state)
this:
m = size (mset (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m = size (mset (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "mset (chop d xs) = YS1 + YS2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (chop d xs) = YS1 + YS2
[PROOF STEP]
unfolding YS1_def YS2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (chop d xs) = {#ys \<in># mset (chop d xs). med ys < x#} + {#ys \<in># mset (chop d xs). \<not> med ys < x#}
[PROOF STEP]
by (rule multiset_partition)
[PROOF STATE]
proof (state)
this:
mset (chop d xs) = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
m = size (YS1 + YS2)
[PROOF STEP]
have m_eq: "m = size YS1 + size YS2"
[PROOF STATE]
proof (prove)
using this:
m = size (YS1 + YS2)

goal (1 subgoal):
 1. m = size YS1 + size YS2
[PROOF STEP]
by simp

  \<comment> \<open>We estimate the number of elements less than @{term x} by grouping them into elements
      coming from @{term YS1} and elements coming from @{term YS2}. In the first case, we
      just note that no more than @{term d} elements can come from each sublist, whereas in
      the second case, we make the analysis more precise and note that only elements that are
      less than the median of their sublist can be less than @{term x}.\<close>
[PROOF STATE]
proof (state)
this:
m = size YS1 + size YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "{# y \<in># mset xs. y < x#} = {# y \<in># (\<Sum>ys\<leftarrow>chop d xs. mset ys). y < x#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}
[PROOF STEP]
by (subst sum_msets_chop) simp_all
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})
[PROOF STEP]
by (subst filter_mset_sum_list) (simp add: o_def)
[PROOF STATE]
proof (state)
this:
{#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})
[PROOF STEP]
unfolding YS_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#mset (chop d xs). {#y \<in># mset ys. y < x#})
[PROOF STEP]
by (subst sum_mset_sum_list [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "YS = YS1 + YS2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. YS = YS1 + YS2
[PROOF STEP]
by (simp add: YS_def YS1_def YS2_def not_le)
[PROOF STATE]
proof (state)
this:
YS = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
YS = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#\<dots>. {#y \<in># mset ys. y < x#}) =
               (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> \<subseteq># (\<Sum>ys\<in>#YS1. mset ys) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#}) \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
by (intro subset_mset.add_mono sum_mset_mset_mono mset_filter_mono) (auto simp: YS2_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#}) \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
have "{# y \<in># mset xs. y < x #} \<subseteq># \<dots>"
[PROOF STATE]
proof (prove)
using this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
hence "size {# y \<in># mset xs. y < x #} \<le> size \<dots>"
[PROOF STATE]
proof (prove)
using this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))
[PROOF STEP]
by (rule size_mset_mono)

  \<comment> \<open>We do some further straightforward estimations and arrive at our goal.\<close>
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<in>#YS1. length ys) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})
[PROOF STEP]
by (simp add: size_mset_sum_mset_distrib multiset.map_comp o_def)
[PROOF STATE]
proof (state)
this:
size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#YS1. length ys) \<le> (\<Sum>ys\<in>#YS1. d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)
[PROOF STEP]
by (intro sum_mset_mono) (auto simp: YS1_def length_chop_part_le)
[PROOF STATE]
proof (state)
this:
\<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = size YS1 * d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1. d) = size YS1 * d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. d) = size YS1 * d

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. d) = size YS1 * d

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have d: "d = (d div 2) + ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d = d div 2 + (d + 1) div 2
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. d = d div 2 + (d + 1) div 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
d = d div 2 + (d + 1) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)
[PROOF STEP]
by (subst d) (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le>
               (\<Sum>ys\<in>#YS2. length ys div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)
[PROOF STEP]
proof (intro sum_mset_mono size_less_than_median, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
case (1 ys)
[PROOF STATE]
proof (state)
this:
ys \<in># YS2

goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
hence "ys \<noteq> []" "length ys \<le> d"
[PROOF STATE]
proof (prove)
using this:
ys \<in># YS2

goal (1 subgoal):
 1. ys \<noteq> [] &&& length ys \<le> d
[PROOF STEP]
by (auto simp: YS2_def length_chop_part_le)
[PROOF STATE]
proof (state)
this:
ys \<noteq> []
length ys \<le> d

goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
from median[OF this]
[PROOF STATE]
proof (chain)
picking this:
is_median (med ys) ys
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
is_median (med ys) ys

goal (1 subgoal):
 1. size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
by (auto simp: is_median_altdef)
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> \<le> (\<Sum>ys\<in>#YS2. d div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)
[PROOF STEP]
by (intro sum_mset_mono div_le_mono diff_le_mono) (auto simp: YS2_def dest: length_chop_part_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = size YS2 * (d div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + \<dots> =
               m * (d div 2) + size YS1 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)
[PROOF STEP]
by (simp add: m_eq algebra_simps)
[PROOF STATE]
proof (state)
this:
size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * ((d + 1) div 2) \<le> (m div 2) * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * ((d + 1) div 2) \<le> m div 2 * ((d + 1) div 2)
[PROOF STEP]
by (intro mult_right_mono size_YS1) auto
[PROOF STATE]
proof (state)
this:
size YS1 * ((d + 1) div 2) \<le> m div 2 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>ys y. ys \<le> y \<Longrightarrow> ys + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> y + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}); \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> m * (d div 2) + x \<le> m * (d div 2) + y\<rbrakk> \<Longrightarrow> size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
show "size {#y \<in># mset xs. y < x#} \<le>
                  m * (d div 2) + m div 2 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>ys y. ys \<le> y \<Longrightarrow> ys + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> y + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}); \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> m * (d div 2) + x \<le> m * (d div 2) + y\<rbrakk> \<Longrightarrow> size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_list_of_set_mono_on:
  "finite A \<Longrightarrow> mono_on {..<card A} (\<lambda>n. sorted_list_of_set A ! n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> mono_on {..<card A} ((!) (sorted_list_of_set A))
[PROOF STEP]
by (rule nth_mono_on) (auto)


[STATEMENT]
lemma minus_core_weaker:
  "|a \<ominus> b| = |a| \<ominus> |b|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
proof (cases "a \<succeq> b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
 2. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a \<succeq> b

goal (2 subgoals):
 1. a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
 2. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<succeq> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<succeq> b

goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
by (metis greater_equiv max_projection_prop_pure_core minus_core minus_default minus_equiv_def mpp_invo succ_antisym)
[PROOF STATE]
proof (state)
this:
 |a \<ominus> b|  =  |a|  \<ominus>  |b|

goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> a \<succeq> b

goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> a \<succeq> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> a \<succeq> b

goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
by (metis greater_equiv max_projection_prop_pure_core minus_default minus_equiv_def mpp_invo succ_antisym)
[PROOF STATE]
proof (state)
this:
 |a \<ominus> b|  =  |a|  \<ominus>  |b|

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma of_nat_word_less_eq_iff:
  \<open>of_nat m \<le> (of_nat n :: 'a::len word) \<longleftrightarrow> take_bit LENGTH('a) m \<le> take_bit LENGTH('a) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (word_of_nat m \<le> word_of_nat n) = (take_bit LENGTH('a) m \<le> take_bit LENGTH('a) n)
[PROOF STEP]
by transfer (simp add: take_bit_of_nat)


[STATEMENT]
lemma has_vector_derivative_circlepath [derivative_intros]:
 "((circlepath z r) has_vector_derivative (2 * pi * \<i> * r * exp (2 * of_real pi * \<i> * x)))
   (at x within X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (circlepath z r has_vector_derivative complex_of_real (2 * pi) * \<i> * complex_of_real r * exp (2 * complex_of_real pi * \<i> * complex_of_real x)) (at x within X)
[PROOF STEP]
unfolding circlepath_def scaleR_conv_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (part_circlepath z r 0 (2 * pi) has_vector_derivative complex_of_real (2 * pi) * \<i> * complex_of_real r * exp (2 * complex_of_real pi * \<i> * complex_of_real x)) (at x within X)
[PROOF STEP]
by (rule derivative_eq_intros) (simp add: algebra_simps)


[STATEMENT]
lemma F2set3_bd: "|F2set3 x| <o bd_F1 +c bd_F2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |F2set3 x| <o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLess_ordLeq_trans)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. |F2set3 x| <o ?r'
 2. ?r' \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule F2.set_bd(3))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bd_F2 \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLeq_csum2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Card_order bd_F2
[PROOF STEP]
apply (rule F2.bd_Card_order)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma A_authenticates_B:
     "\<lbrakk> Outpts (Card A) A  \<lbrace>Agent B, Nonce Nb, Key K, Certificate\<rbrace> \<in> set evs;
        \<not>illegalUse(Card B);
        evs \<in> srb \<rbrakk>
 \<Longrightarrow> \<exists> Na. Outpts (Card B) B \<lbrace>Nonce Nb, Agent A, Key K,
                Crypt (pairK(A,B)) \<lbrace>Nonce Na, Nonce Nb\<rbrace>,
                Crypt (pairK(A,B)) (Nonce Nb)\<rbrace> \<in> set evs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Outpts (Card A) A \<lbrace>Agent B, Nonce Nb, Key K, Certificate\<rbrace> \<in> set evs; \<not> illegalUse (Card B); evs \<in> srb\<rbrakk> \<Longrightarrow> \<exists>Na. Outpts (Card B) B \<lbrace>Nonce Nb, Agent A, Key K, Crypt (pairK (A, B)) \<lbrace>Nonce Na, Nonce Nb\<rbrace>, Crypt (pairK (A, B)) (Nonce Nb)\<rbrace> \<in> set evs
[PROOF STEP]
apply (blast dest: Na_Nb_certificate_authentic Outpts_A_Card_form_10 Outpts_A_Card_imp_pairK_parts)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma RDirProd_list_is_ring:
  assumes "\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)" shows "ring (RDirProd_list Rs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring (RDirProd_list Rs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?i < length Rs \<Longrightarrow> ring (Rs ! ?i)

goal (1 subgoal):
 1. ring (RDirProd_list Rs)
[PROOF STEP]
proof (induct Rs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>i. i < length [] \<Longrightarrow> ring ([] ! i)) \<Longrightarrow> ring (RDirProd_list [])
 2. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (2 subgoals):
 1. (\<And>i. i < length [] \<Longrightarrow> ring ([] ! i)) \<Longrightarrow> ring (RDirProd_list [])
 2. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (1 subgoal):
 1. ring (RDirProd_list [])
[PROOF STEP]
unfolding RDirProd_list_def
[PROOF STATE]
proof (prove)
using this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (1 subgoal):
 1. ring (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) [] nil_ring)
[PROOF STEP]
by (unfold_locales, auto simp add: monoid.defs Units_def)
[PROOF STATE]
proof (state)
this:
ring (RDirProd_list [])

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
case (Cons R Rs)
[PROOF STATE]
proof (state)
this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
hence is_ring: "ring (RDirProd R (RDirProd_list Rs))"
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)

goal (1 subgoal):
 1. ring (RDirProd R (RDirProd_list Rs))
[PROOF STEP]
using RDirProd_ring[of R "RDirProd_list Rs"]
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)
\<lbrakk>ring R; ring (RDirProd_list Rs)\<rbrakk> \<Longrightarrow> ring (RDirProd R (RDirProd_list Rs))

goal (1 subgoal):
 1. ring (RDirProd R (RDirProd_list Rs))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
ring (RDirProd R (RDirProd_list Rs))

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring (RDirProd_list (R # Rs))
[PROOF STEP]
using ring.inj_imp_image_ring_is_ring[OF is_ring inj_on_RDirProd_carrier]
[PROOF STATE]
proof (prove)
using this:
ring (image_ring (\<lambda>(a, as). a # as) (RDirProd R (RDirProd_list Rs)))

goal (1 subgoal):
 1. ring (RDirProd_list (R # Rs))
[PROOF STEP]
unfolding RDirProd_list_def
[PROOF STATE]
proof (prove)
using this:
ring (image_ring (\<lambda>(a, as). a # as) (RDirProd R (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) Rs nil_ring)))

goal (1 subgoal):
 1. ring (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) (R # Rs) nil_ring)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ring (RDirProd_list (R # Rs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rGamma_series_real:
  "eventually (\<lambda>n. rGamma_series x n = Re (rGamma_series (of_real x) n)) sequentially"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
using eventually_gt_at_top[of "0 :: nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
proof eventually_elim
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
assume n: "n > 0"
[PROOF STATE]
proof (state)
this:
0 < n

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
have "Re (rGamma_series (of_real x) n) =
          Re (of_real (pochhammer x (Suc n)) / (fact n * exp (of_real (x * ln (real_of_nat n)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))
[PROOF STEP]
by (simp add: rGamma_series_def powr_def pochhammer_of_real)
[PROOF STATE]
proof (state)
this:
Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "\<dots> = Re (of_real ((pochhammer x (Suc n)) /
                              (fact n * (exp (x * ln (real_of_nat n))))))"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))
[PROOF STEP]
by (subst exp_of_real) simp
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "\<dots> = rGamma_series x n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n))))) = rGamma_series x n
[PROOF STEP]
by (subst Re_complex_of_real) (simp add: rGamma_series_def powr_def)
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n))))) = rGamma_series x n

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Re (rGamma_series (complex_of_real x) n) = rGamma_series x n
[PROOF STEP]
show "rGamma_series x n = Re (rGamma_series (of_real x) n)"
[PROOF STATE]
proof (prove)
using this:
Re (rGamma_series (complex_of_real x) n) = rGamma_series x n

goal (1 subgoal):
 1. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
rGamma_series x n = Re (rGamma_series (complex_of_real x) n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_contI:
  assumes  "\<And> Y. chain Y \<Longrightarrow> f (\<Squnion> i. Y i) = \<Union> (f ` range Y)"
  shows "cont f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cont f
[PROOF STEP]
proof(rule contI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
fix Y :: "nat \<Rightarrow> 'a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
assume "chain Y"
[PROOF STATE]
proof (state)
this:
chain Y

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
hence "f (\<Squnion> i. Y i) = \<Union> (f ` range Y)"
[PROOF STATE]
proof (prove)
using this:
chain Y

goal (1 subgoal):
 1. f (\<Squnion>i. Y i) = \<Union> (f ` range Y)
[PROOF STEP]
by (rule assms)
[PROOF STATE]
proof (state)
this:
f (\<Squnion>i. Y i) = \<Union> (f ` range Y)

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f (\<Squnion>i. Y i) = \<Union> (f ` range Y)

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
have "\<dots> = \<Union> (range (\<lambda>i. f (Y i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (f ` range Y) = (\<Union>i. f (Y i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Union> (f ` range Y) = (\<Union>i. f (Y i))

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))
[PROOF STEP]
show "range (\<lambda>i. f (Y i)) <<| f (\<Squnion> i. Y i)"
[PROOF STATE]
proof (prove)
using this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))

goal (1 subgoal):
 1. range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
using is_lub_set
[PROOF STATE]
proof (prove)
using this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))
?S <<| \<Union> ?S

goal (1 subgoal):
 1. range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma additive_implies_homogenous:
  assumes "\<And>x y. f (x + y) = f x + ((f (y::'a::monoid_add))::'b::cancel_comm_monoid_add)"
  shows "f 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
have "f (0 + 0) = f 0 + f 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)
[PROOF STEP]
by (rule assms)
[PROOF STATE]
proof (state)
this:
f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)

goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
hence "f 0 = f 0 + f 0"
[PROOF STATE]
proof (prove)
using this:
f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)

goal (1 subgoal):
 1. f (0::'a) = f (0::'a) + f (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f (0::'a) = f (0::'a) + f (0::'a)

goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
thus "f 0 = 0"
[PROOF STATE]
proof (prove)
using this:
f (0::'a) = f (0::'a) + f (0::'a)

goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f (0::'a) = (0::'b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_aligned_weaken:
  "\<lbrakk> is_aligned w x; x \<ge> y \<rbrakk> \<Longrightarrow> is_aligned w y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned w x; y \<le> x\<rbrakk> \<Longrightarrow> is_aligned w y
[PROOF STEP]
unfolding is_aligned_iff_dvd_nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>2 ^ x dvd unat w; y \<le> x\<rbrakk> \<Longrightarrow> 2 ^ y dvd unat w
[PROOF STEP]
by (erule dvd_trans [rotated]) (simp add: le_imp_power_dvd)


[STATEMENT]
lemma countable_Image:
  assumes "\<And>y. y \<in> Y \<Longrightarrow> countable (X `` {y})"
  assumes "countable Y"
  shows "countable (X `` Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
have "countable (X `` (\<Union>y\<in>Y. {y}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (X `` (\<Union>y\<in>Y. {y}))
[PROOF STEP]
unfolding Image_UN
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (\<Union>x\<in>Y. X `` {x})
[PROOF STEP]
by (intro countable_UN assms)
[PROOF STATE]
proof (state)
this:
countable (X `` (\<Union>y\<in>Y. {y}))

goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
countable (X `` (\<Union>y\<in>Y. {y}))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
countable (X `` (\<Union>y\<in>Y. {y}))

goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
countable (X `` Y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma symetric:
  fixes P :: pi
  and   Q :: pi

  assumes "P \<simeq> Q"

  shows "Q \<simeq> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q \<simeq> P
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P \<simeq> Q

goal (1 subgoal):
 1. Q \<simeq> P
[PROOF STEP]
by(force simp add: substClosed_def congruence_def)


[STATEMENT]
lemma cos_limit_1:
  assumes "(\<lambda>j. cos (\<theta> j)) \<longlonglongrightarrow> 1"
  shows "\<exists>k. (\<lambda>j. \<theta> j - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
have "\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
[PROOF STEP]
have "(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}

goal (1 subgoal):
 1. (\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
[PROOF STEP]
using continuous_on_tendsto_compose [OF continuous_on_arccos' assms]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
\<lbrakk>1 \<in> {- 1..1}; \<forall>\<^sub>F x in sequentially. cos (\<theta> x) \<in> {- 1..1}\<rbrakk> \<Longrightarrow> (\<lambda>x. arccos (cos (\<theta> x))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. (\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
have "\<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int k * (2 * pi)\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
using arccos_cos_eq_abs_2pi
[PROOF STATE]
proof (prove)
using this:
(\<And>k. arccos (cos ?\<theta>) = \<bar>?\<theta> - real_of_int k * (2 * pi)\<bar> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
have "\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>
[PROOF STEP]
have "\<exists>k. (\<lambda>j. \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
by (simp add: tendsto_rabs_zero_iff)
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0

goal:
No subgoals!
[PROOF STEP]
qed