[STATEMENT]
lemma int_poly_factorization_algorithm_irreducible\<^sub>d:
  assumes "int_poly_factorization_algorithm alg f = fs"
  and "square_free f"
  and "degree f > 0"
shows "f = prod_list fs \<and> (\<forall> fi \<in> set fs. irreducible\<^sub>d fi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = prod_list fs \<and> (\<forall>fi\<in>set fs. irreducible\<^sub>d fi)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
int_poly_factorization_algorithm alg f = fs
square_free f
0 < degree f

goal (1 subgoal):
 1. f = prod_list fs \<and> (\<forall>fi\<in>set fs. irreducible\<^sub>d fi)
[PROOF STEP]
by (transfer, auto)


[STATEMENT]
lemma fold_map_idx_fst_snd_eq:
  assumes f: "\<And>i c x. fst (f i c x) = (c \<or> x \<noteq> snd (f i c x))"
  shows "fst (fold_map_idx f i c xs) = (c \<or> xs \<noteq> snd (fold_map_idx f i c xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (fold_map_idx f i c xs) = (c \<or> xs \<noteq> snd (fold_map_idx f i c xs))
[PROOF STEP]
by (induct xs arbitrary: i c) (simp_all add: split_beta f)


[STATEMENT]
lemma connectedI:
  "(\<And>A B. open A \<Longrightarrow> open B \<Longrightarrow> A \<inter> U \<noteq> {} \<Longrightarrow> B \<inter> U \<noteq> {} \<Longrightarrow> A \<inter> B \<inter> U = {} \<Longrightarrow> U \<subseteq> A \<union> B \<Longrightarrow> False)
  \<Longrightarrow> connected U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>A B. \<lbrakk>open A; open B; A \<inter> U \<noteq> {}; B \<inter> U \<noteq> {}; A \<inter> B \<inter> U = {}; U \<subseteq> A \<union> B\<rbrakk> \<Longrightarrow> False) \<Longrightarrow> connected U
[PROOF STEP]
by (auto simp: connected_def)


[STATEMENT]
lemma monic_Mp_prod_mset: assumes fs: "\<And> f. f \<in># fs \<Longrightarrow> monic (Mp f)"
  shows "monic (Mp (prod_mset fs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
have "monic (prod_mset (image_mset Mp fs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic (\<Prod>\<^sub># (image_mset Mp fs))
[PROOF STEP]
by (rule monic_prod_mset, insert fs, auto)
[PROOF STATE]
proof (state)
this:
monic (\<Prod>\<^sub># (image_mset Mp fs))

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
from monic_Mp[OF this]
[PROOF STATE]
proof (chain)
picking this:
monic (Mp (\<Prod>\<^sub># (image_mset Mp fs)))
[PROOF STEP]
have "monic (Mp (prod_mset (image_mset Mp fs)))"
[PROOF STATE]
proof (prove)
using this:
monic (Mp (\<Prod>\<^sub># (image_mset Mp fs)))

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># (image_mset Mp fs)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
monic (Mp (\<Prod>\<^sub># (image_mset Mp fs)))

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
monic (Mp (\<Prod>\<^sub># (image_mset Mp fs)))

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
have "Mp (prod_mset (image_mset Mp fs)) = Mp (prod_mset fs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (image_mset Mp fs) =m \<Prod>\<^sub># fs
[PROOF STEP]
by (rule Mp_prod_mset)
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (image_mset Mp fs) =m \<Prod>\<^sub># fs

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
monic (Mp (\<Prod>\<^sub># fs))

goal (1 subgoal):
 1. monic (Mp (\<Prod>\<^sub># fs))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
monic (Mp (\<Prod>\<^sub># fs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma FInter_rep_eq [simp]:
  "xs \<noteq> \<lbrace>\<rbrace> \<Longrightarrow> \<langle>\<Inter>\<^sub>f xs\<rangle>\<^sub>f = (\<Inter>x\<in>\<langle>xs\<rangle>\<^sub>f. \<langle>x\<rangle>\<^sub>f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> \<lbrace>\<rbrace> \<Longrightarrow> \<langle>\<Inter>\<^sub>fxs\<rangle>\<^sub>f = \<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f)
[PROOF STEP]
apply (simp add:FInter_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> \<lbrace>\<rbrace> \<Longrightarrow> \<langle>Abs_fset (\<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f))\<rangle>\<^sub>f = \<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f)
[PROOF STEP]
apply (subgoal_tac "finite (\<Inter>x\<in>\<langle>xs\<rangle>\<^sub>f. \<langle>x\<rangle>\<^sub>f)")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>xs \<noteq> \<lbrace>\<rbrace>; finite (\<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f))\<rbrakk> \<Longrightarrow> \<langle>Abs_fset (\<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f))\<rangle>\<^sub>f = \<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f)
 2. xs \<noteq> \<lbrace>\<rbrace> \<Longrightarrow> finite (\<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f))
[PROOF STEP]
apply (simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> \<lbrace>\<rbrace> \<Longrightarrow> finite (\<Inter> (fset ` \<langle>xs\<rangle>\<^sub>f))
[PROOF STEP]
apply (metis (poly_guards_query) bot_fset.rep_eq fglb_rep_eq finite_fset fset_inverse)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma minimum_spanning_forest_impl_tree2:
  assumes "minimum_spanning_forest F G"
  assumes connected_G: "connected_graph G"
  shows "minimum_spanning_tree F G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. minimum_spanning_tree F G
[PROOF STEP]
using assms connected_graph.maximally_connected_impl_connected[OF connected_G]
    minimum_spanning_forest_impl_tree connected_graph.axioms(1)[OF connected_G]
[PROOF STATE]
proof (prove)
using this:
minimum_spanning_forest F G
connected_graph G
\<lbrakk>maximally_connected ?H G; subgraph ?H G\<rbrakk> \<Longrightarrow> connected_graph ?H
\<lbrakk>minimum_spanning_forest ?F ?G; valid_graph ?G; connected_graph ?F\<rbrakk> \<Longrightarrow> minimum_spanning_tree ?F ?G
valid_graph G

goal (1 subgoal):
 1. minimum_spanning_tree F G
[PROOF STEP]
unfolding minimum_spanning_forest_def spanning_forest_def
[PROOF STATE]
proof (prove)
using this:
(forest F \<and> maximally_connected F G \<and> subgraph F G) \<and> optimal_forest F G
connected_graph G
\<lbrakk>maximally_connected ?H G; subgraph ?H G\<rbrakk> \<Longrightarrow> connected_graph ?H
\<lbrakk>(forest ?F \<and> maximally_connected ?F ?G \<and> subgraph ?F ?G) \<and> optimal_forest ?F ?G; valid_graph ?G; connected_graph ?F\<rbrakk> \<Longrightarrow> minimum_spanning_tree ?F ?G
valid_graph G

goal (1 subgoal):
 1. minimum_spanning_tree F G
[PROOF STEP]
by auto


[STATEMENT]
lemma ccSquare_eqvt[eqvt]: "\<pi> \<bullet> ccSquare S = ccSquare (\<pi> \<bullet> S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi> \<bullet> S\<^sup>2 = (\<pi> \<bullet> S)\<^sup>2
[PROOF STEP]
unfolding ccSquare_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi> \<bullet> S G\<times> S = (\<pi> \<bullet> S) G\<times> (\<pi> \<bullet> S)
[PROOF STEP]
by perm_simp rule


[STATEMENT]
lemma cnj_x_x_geq0[simp]: \<open>cnj x * x \<ge> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> cnj x * x
[PROOF STEP]
by (simp add: less_eq_complex_def)


[STATEMENT]
lemma NUM001_1:
  "(\<forall>A. equal(A::'a,A)) &
  (\<forall>B A C. equal(A::'a,B) & equal(B::'a,C) --> equal(A::'a,C)) &
  (\<forall>B A. equal(add(A::'a,B),add(B::'a,A))) &
  (\<forall>A B C. equal(add(A::'a,add(B::'a,C)),add(add(A::'a,B),C))) &
  (\<forall>B A. equal(subtract(add(A::'a,B),B),A)) &
  (\<forall>A B. equal(A::'a,subtract(add(A::'a,B),B))) &
  (\<forall>A C B. equal(add(subtract(A::'a,B),C),subtract(add(A::'a,C),B))) &
  (\<forall>A C B. equal(subtract(add(A::'a,B),C),add(subtract(A::'a,C),B))) &
  (\<forall>A C B D. equal(A::'a,B) & equal(C::'a,add(A::'a,D)) --> equal(C::'a,add(B::'a,D))) &
  (\<forall>A C D B. equal(A::'a,B) & equal(C::'a,add(D::'a,A)) --> equal(C::'a,add(D::'a,B))) &
  (\<forall>A C B D. equal(A::'a,B) & equal(C::'a,subtract(A::'a,D)) --> equal(C::'a,subtract(B::'a,D))) &
  (\<forall>A C D B. equal(A::'a,B) & equal(C::'a,subtract(D::'a,A)) --> equal(C::'a,subtract(D::'a,B))) &
  (~equal(add(add(a::'a,b),c),add(a::'a,add(b::'a,c)))) --> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>A. equal (A, A)) \<and> (\<forall>B A C. equal (A, B) \<and> equal (B, C) \<longrightarrow> equal (A, C)) \<and> (\<forall>B A. equal (add (A, B), add (B, A))) \<and> (\<forall>A B C. equal (add (A, add (B, C)), add (add (A, B), C))) \<and> (\<forall>B A. equal (subtract (add (A, B), B), A)) \<and> (\<forall>A B. equal (A, subtract (add (A, B), B))) \<and> (\<forall>A C B. equal (add (subtract (A, B), C), subtract (add (A, C), B))) \<and> (\<forall>A C B. equal (subtract (add (A, B), C), add (subtract (A, C), B))) \<and> (\<forall>A C B D. equal (A, B) \<and> equal (C, add (A, D)) \<longrightarrow> equal (C, add (B, D))) \<and> (\<forall>A C D B. equal (A, B) \<and> equal (C, add (D, A)) \<longrightarrow> equal (C, add (D, B))) \<and> (\<forall>A C B D. equal (A, B) \<and> equal (C, subtract (A, D)) \<longrightarrow> equal (C, subtract (B, D))) \<and> (\<forall>A C D B. equal (A, B) \<and> equal (C, subtract (D, A)) \<longrightarrow> equal (C, subtract (D, B))) \<and> \<not> equal (add (add (a, b), c), add (a, add (b, c))) \<longrightarrow> False
[PROOF STEP]
by meson


[STATEMENT]
theorem remove_sorted: "sorted t ==> sorted(remove x t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. BinaryTree_TacticStyle.sorted t \<Longrightarrow> BinaryTree_TacticStyle.sorted (remove x t)
[PROOF STEP]
by (induct t) (auto intro: less_trans rm_in_set_of sorted_rem)


[STATEMENT]
lemma prime_power_cancel2:
  assumes "prime p" "m * (p ^ k) = m' * (p ^ k')" "\<not> p dvd m" "\<not> p dvd m'"
  obtains "m = m'" "k = k'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>m = m'; k = k'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using prime_power_cancel [OF assms] assms
[PROOF STATE]
proof (prove)
using this:
k = k'
prime p
m * p ^ k = m' * p ^ k'
\<not> p dvd m
\<not> p dvd m'

goal (1 subgoal):
 1. (\<lbrakk>m = m'; k = k'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto


[STATEMENT]
lemma refl_trans_impl_idempotent[intro]: "refl_on A r \<Longrightarrow> trans r \<Longrightarrow> idempotent r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>refl_on A r; trans r\<rbrakk> \<Longrightarrow> idempotent r
[PROOF STEP]
by(auto simp:refl_on_def trans_def idempotent_def)


[STATEMENT]
lemma map2_Cons_if: "
  map2 f xs (y # ys) =
  (if (xs = []) then [] else (
    (f (hd xs) y) # map2 f (tl xs) ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. List2.map2 f xs (y # ys) = (if xs = [] then [] else f (hd xs) y # List2.map2 f (tl xs) ys)
[PROOF STEP]
by (case_tac "xs", simp+)


[STATEMENT]
lemma lemma_3_16_i: "p x x y = y \<and> p x y y = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p x x y = y \<and> p x y y = x
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. p x x y = y
 2. p x y y = x
[PROOF STEP]
apply (simp_all add: p_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. y \<sqinter> ((y l\<rightarrow> x) r\<rightarrow> x) = y
 2. ((x l\<rightarrow> y) r\<rightarrow> y) \<sqinter> x = x
[PROOF STEP]
apply (rule order.antisym)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. y \<sqinter> ((y l\<rightarrow> x) r\<rightarrow> x) \<le> y
 2. y \<le> y \<sqinter> ((y l\<rightarrow> x) r\<rightarrow> x)
 3. ((x l\<rightarrow> y) r\<rightarrow> y) \<sqinter> x = x
[PROOF STEP]
apply (simp_all add: lemma_2_10_24)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((x l\<rightarrow> y) r\<rightarrow> y) \<sqinter> x = x
[PROOF STEP]
apply (rule order.antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. ((x l\<rightarrow> y) r\<rightarrow> y) \<sqinter> x \<le> x
 2. x \<le> ((x l\<rightarrow> y) r\<rightarrow> y) \<sqinter> x
[PROOF STEP]
by (simp_all add: lemma_2_10_24)


[STATEMENT]
lemma (in finite_group) ord_pos:
  assumes "x \<in> carrier G"
  shows   "ord x > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < ord x
[PROOF STEP]
using ord_ge_1[of x] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (carrier G); x \<in> carrier G\<rbrakk> \<Longrightarrow> 1 \<le> ord x
x \<in> carrier G

goal (1 subgoal):
 1. 0 < ord x
[PROOF STEP]
by auto


[STATEMENT]
lemma gfinprod_insert [simp]:
  assumes "finite {x \<in> A. f x \<noteq> \<one>\<^bsub>G\<^esub>}" "f \<in> A \<rightarrow> carrier G" "f i \<in> carrier G"
  shows "gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
have f: "f \<in> {x \<in> A. f x \<noteq> \<one>} \<rightarrow> carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> {x \<in> A. f x \<noteq> \<one>} \<rightarrow> carrier G
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite {x \<in> A. f x \<noteq> \<one>}
f \<in> A \<rightarrow> carrier G
f i \<in> carrier G

goal (1 subgoal):
 1. f \<in> {x \<in> A. f x \<noteq> \<one>} \<rightarrow> carrier G
[PROOF STEP]
by (auto simp: image_subset_iff_funcset)
[PROOF STATE]
proof (state)
this:
f \<in> {x \<in> A. f x \<noteq> \<one>} \<rightarrow> carrier G

goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
have "{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})

goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})

goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})
finite {x \<in> A. f x \<noteq> \<one>}
f \<in> A \<rightarrow> carrier G
f i \<in> carrier G

goal (1 subgoal):
 1. gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)
[PROOF STEP]
unfolding gfinprod_def
[PROOF STATE]
proof (prove)
using this:
{x. x = i \<and> f x \<noteq> \<one> \<or> x \<in> A \<and> f x \<noteq> \<one>} = (if f i = \<one> then {x \<in> A. f x \<noteq> \<one>} else insert i {x \<in> A. f x \<noteq> \<one>})
finite {x \<in> A. f x \<noteq> \<one>}
f \<in> A \<rightarrow> carrier G
f i \<in> carrier G

goal (1 subgoal):
 1. (if finite {x \<in> insert i A. f x \<noteq> \<one>} then finprod G f {x \<in> insert i A. f x \<noteq> \<one>} else \<one>) = (if i \<in> A then if finite {x \<in> A. f x \<noteq> \<one>} then finprod G f {x \<in> A. f x \<noteq> \<one>} else \<one> else f i \<otimes> (if finite {x \<in> A. f x \<noteq> \<one>} then finprod G f {x \<in> A. f x \<noteq> \<one>} else \<one>))
[PROOF STEP]
by (simp add: conj_disj_distribR insert_absorb f split: if_split_asm)
[PROOF STATE]
proof (state)
this:
gfinprod G f (insert i A) = (if i \<in> A then gfinprod G f A else f i \<otimes> gfinprod G f A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ln_Gamma_real_conv_fact: "n > 0 \<Longrightarrow> ln_Gamma (real n) = ln (fact (n - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> ln_Gamma (real n) = ln (fact (n - 1))
[PROOF STEP]
using Gamma_fact[of "n - 1", where 'a = real]
[PROOF STATE]
proof (prove)
using this:
Gamma (1 + real (n - 1)) = fact (n - 1)

goal (1 subgoal):
 1. 0 < n \<Longrightarrow> ln_Gamma (real n) = ln (fact (n - 1))
[PROOF STEP]
by (simp add: ln_Gamma_real_pos of_nat_diff Ln_of_real [symmetric])


[STATEMENT]
lemma permutation_funpow:
  assumes "permutation p" shows "permutation (p ^^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. permutation (p ^^ n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
permutation p

goal (1 subgoal):
 1. permutation (p ^^ n)
[PROOF STEP]
by (induct n) (simp_all add: permutation_compose)


[STATEMENT]
lemma set_relator_eq_onp [relator_eq_onp]:
  "rel_bset (eq_onp P) = eq_onp (\<lambda>A. Ball (set_bset A) P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_bset (eq_onp P) = eq_onp (\<lambda>A. Ball (set_bset A) P)
[PROOF STEP]
unfolding fun_eq_iff eq_onp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x xa. rel_bset (\<lambda>x y. P x \<and> x = y) x xa = (Ball (set_bset x) P \<and> x = xa)
[PROOF STEP]
by transfer (auto simp: rel_set_def)


[STATEMENT]
lemma pre_to_univ_poly_inv_hom_is_hom:
  assumes "i < Suc n"
  shows "ring_hom_ring (R[\<X>\<^bsub>n\<^esub>]) (R[\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)
[PROOF STEP]
have 0: "ring_hom_ring (R[\<X>\<^bsub>n\<^esub>]) (R[\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))
[PROOF STEP]
unfolding coord_ring_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring_hom_ring (Pring R {..<n}) (Pring R {..<Suc n}) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))
[PROOF STEP]
apply(rule R.relabel_vars_is_morphism)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>j. if j < i then j else j + 1) \<in> {..<n} \<rightarrow> {..<Suc n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < Suc n

goal (1 subgoal):
 1. (\<lambda>j. if j < i then j else j + 1) \<in> {..<n} \<rightarrow> {..<Suc n}
[PROOF STEP]
by (smt Pi_I Suc_eq_plus1 add_less_cancel_right lessThan_iff less_Suc_eq)
[PROOF STATE]
proof (state)
this:
ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))

goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))

goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)
[PROOF STEP]
unfolding pre_to_univ_poly_inv_hom_def
[PROOF STATE]
proof (prove)
using this:
ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<n} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))

goal (1 subgoal):
 1. ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (R.relabel_vars {..<Suc n - 1} {..<Suc n} (\<lambda>j. if j < i then j else j + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ring_hom_ring (R [\<X>\<^bsub>n\<^esub>]) (R [\<X>\<^bsub>Suc n\<^esub>]) (pre_to_univ_poly_inv_hom (Suc n) i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma urel_integer_power: "urel_integer x x' \<Longrightarrow> urel_integer y (int y') \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>urel_integer x x'; urel_integer y (int y')\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
including bit_operations_syntax
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>urel_integer x x'; urel_integer y (int y')\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
proof (induct x' y' arbitrary: x y rule: power_p.induct[of _ p])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x n xa y. \<lbrakk>\<And>xa xb y xc ya. \<lbrakk>n \<noteq> 0; xa = Euclidean_Division.divmod_nat n 2; (xb, y) = xa; urel_integer xc (mult_p p x x); urel_integer ya (int xb)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xc ya) (power_p p (mult_p p x x) xb); urel_integer xa x; urel_integer y (int n)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xa y) (power_p p x n)
[PROOF STEP]
case (1 x' y' x y)
[PROOF STATE]
proof (state)
this:
\<lbrakk>y' \<noteq> 0; ?xa = Euclidean_Division.divmod_nat y' 2; (?xb, ?y) = ?xa; urel_integer ?x (mult_p p x' x'); urel_integer ?ya (int ?xb)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp ?x ?ya) (power_p p (mult_p p x' x') ?xb)
urel_integer x x'
urel_integer y (int y')

goal (1 subgoal):
 1. \<And>x n xa y. \<lbrakk>\<And>xa xb y xc ya. \<lbrakk>n \<noteq> 0; xa = Euclidean_Division.divmod_nat n 2; (xb, y) = xa; urel_integer xc (mult_p p x x); urel_integer ya (int xb)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xc ya) (power_p p (mult_p p x x) xb); urel_integer xa x; urel_integer y (int n)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xa y) (power_p p x n)
[PROOF STEP]
note x = 1(2)
[PROOF STATE]
proof (state)
this:
urel_integer x x'

goal (1 subgoal):
 1. \<And>x n xa y. \<lbrakk>\<And>xa xb y xc ya. \<lbrakk>n \<noteq> 0; xa = Euclidean_Division.divmod_nat n 2; (xb, y) = xa; urel_integer xc (mult_p p x x); urel_integer ya (int xb)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xc ya) (power_p p (mult_p p x x) xb); urel_integer xa x; urel_integer y (int n)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xa y) (power_p p x n)
[PROOF STEP]
note y = 1(3)
[PROOF STATE]
proof (state)
this:
urel_integer y (int y')

goal (1 subgoal):
 1. \<And>x n xa y. \<lbrakk>\<And>xa xb y xc ya. \<lbrakk>n \<noteq> 0; xa = Euclidean_Division.divmod_nat n 2; (xb, y) = xa; urel_integer xc (mult_p p x x); urel_integer ya (int xb)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xc ya) (power_p p (mult_p p x x) xb); urel_integer xa x; urel_integer y (int n)\<rbrakk> \<Longrightarrow> urel_integer (power_p_integer pp xa y) (power_p p x n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
proof (cases "y' \<le> 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
 2. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
y' \<le> 0

goal (2 subgoals):
 1. y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
 2. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
hence y: "y = 0" "y' = 0"
[PROOF STATE]
proof (prove)
using this:
y' \<le> 0

goal (1 subgoal):
 1. y = 0 &&& y' = 0
[PROOF STEP]
using urel_integer_eq[OF y urel_integer_0]
[PROOF STATE]
proof (prove)
using this:
y' \<le> 0
(y = 0) = (int y' = 0)

goal (1 subgoal):
 1. y = 0 &&& y' = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y = 0
y' = 0

goal (2 subgoals):
 1. y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
 2. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
unfolding y True
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (power_p_integer pp x 0) (power_p p x' 0)
[PROOF STEP]
by (simp add: power_p.simps urel_integer_1)
[PROOF STATE]
proof (state)
this:
urel_integer (power_p_integer pp x y) (power_p p x' y')

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> y' \<le> 0

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
hence id: "(y \<le> 0) = False" "(y' = 0) = False"
[PROOF STATE]
proof (prove)
using this:
\<not> y' \<le> 0

goal (1 subgoal):
 1. (y \<le> 0) = False &&& (y' = 0) = False
[PROOF STEP]
using False y
[PROOF STATE]
proof (prove)
using this:
\<not> y' \<le> 0
\<not> y' \<le> 0
urel_integer y (int y')

goal (1 subgoal):
 1. (y \<le> 0) = False &&& (y' = 0) = False
[PROOF STEP]
by (auto simp add: urel_integer_def not_le) (metis of_int_integer_of of_int_of_nat_eq of_nat_0_less_iff)
[PROOF STATE]
proof (state)
this:
(y \<le> 0) = False
(y' = 0) = False

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
obtain d' r' where dr': "Euclidean_Division.divmod_nat y' 2 = (d',r')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d' r'. Euclidean_Division.divmod_nat y' 2 = (d', r') \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
Euclidean_Division.divmod_nat y' 2 = (d', r')

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
from Euclidean_Division.divmod_nat_def[of y' 2, unfolded dr']
[PROOF STATE]
proof (chain)
picking this:
(d', r') = (y' div 2, y' mod 2)
[PROOF STEP]
have r': "r' = y' mod 2" and d': "d' = y' div 2"
[PROOF STATE]
proof (prove)
using this:
(d', r') = (y' div 2, y' mod 2)

goal (1 subgoal):
 1. r' = y' mod 2 &&& d' = y' div 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r' = y' mod 2
d' = y' div 2

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
have aux: "\<And> y'. int (y' mod 2) = int y' mod 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y'. int (y' mod 2) = int y' mod 2
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
int (?y' mod 2) = int ?y' mod 2

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
have "urel_integer (y AND 1) r'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (y AND 1) (int r')
[PROOF STEP]
unfolding r'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (y AND 1) (int (y' mod 2))
[PROOF STEP]
using y
[PROOF STATE]
proof (prove)
using this:
urel_integer y (int y')

goal (1 subgoal):
 1. urel_integer (y AND 1) (int (y' mod 2))
[PROOF STEP]
unfolding urel_integer_def
[PROOF STATE]
proof (prove)
using this:
int y' = int_of_integer y \<and> 0 \<le> int y' \<and> int y' < p

goal (1 subgoal):
 1. int (y' mod 2) = int_of_integer (y AND 1) \<and> 0 \<le> int (y' mod 2) \<and> int (y' mod 2) < p
[PROOF STEP]
unfolding ppp
[PROOF STATE]
proof (prove)
using this:
int y' = int_of_integer y \<and> 0 \<le> int y' \<and> int y' < int_of_integer pp

goal (1 subgoal):
 1. int (y' mod 2) = int_of_integer (y AND 1) \<and> 0 \<le> int (y' mod 2) \<and> int (y' mod 2) < int_of_integer pp
[PROOF STEP]
apply (auto simp add: and_one_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>int y' = int_of_integer y; int_of_integer y < int_of_integer pp\<rbrakk> \<Longrightarrow> int (y' mod 2) = int_of_integer y mod 2
[PROOF STEP]
apply (simp add: of_nat_mod)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
urel_integer (y AND 1) (int r')

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
from urel_integer_eq[OF this urel_integer_0]
[PROOF STATE]
proof (chain)
picking this:
(y AND 1 = 0) = (int r' = 0)
[PROOF STEP]
have rem: "(y AND 1 = 0) = (r' = 0)"
[PROOF STATE]
proof (prove)
using this:
(y AND 1 = 0) = (int r' = 0)

goal (1 subgoal):
 1. (y AND 1 = 0) = (r' = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(y AND 1 = 0) = (r' = 0)

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
have div: "urel_integer (drop_bit 1 y) (int d')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (drop_bit 1 y) (int d')
[PROOF STEP]
unfolding d'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (drop_bit 1 y) (int (y' div 2))
[PROOF STEP]
using y
[PROOF STATE]
proof (prove)
using this:
urel_integer y (int y')

goal (1 subgoal):
 1. urel_integer (drop_bit 1 y) (int (y' div 2))
[PROOF STEP]
unfolding urel_integer_def
[PROOF STATE]
proof (prove)
using this:
int y' = int_of_integer y \<and> 0 \<le> int y' \<and> int y' < p

goal (1 subgoal):
 1. int (y' div 2) = int_of_integer (drop_bit 1 y) \<and> 0 \<le> int (y' div 2) \<and> int (y' div 2) < p
[PROOF STEP]
unfolding ppp shiftr_integer_conv_div_pow2
[PROOF STATE]
proof (prove)
using this:
int y' = int_of_integer y \<and> 0 \<le> int y' \<and> int y' < int_of_integer pp

goal (1 subgoal):
 1. int (y' div 2) = int_of_integer (y div 2 ^ 1) \<and> 0 \<le> int (y' div 2) \<and> int (y' div 2) < int_of_integer pp
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
urel_integer (drop_bit 1 y) (int d')

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
from id
[PROOF STATE]
proof (chain)
picking this:
(y \<le> 0) = False
(y' = 0) = False
[PROOF STEP]
have "y' \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(y \<le> 0) = False
(y' = 0) = False

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

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
note IH = 1(1)[OF this refl dr'[symmetric] urel_integer_mult[OF x x] div]
[PROOF STATE]
proof (state)
this:
urel_integer (power_p_integer pp (mult_p_integer pp x x) (drop_bit 1 y)) (power_p p (mult_p p x' x') d')

goal (1 subgoal):
 1. \<not> y' \<le> 0 \<Longrightarrow> urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (power_p_integer pp x y) (power_p p x' y')
[PROOF STEP]
unfolding power_p.simps[of _ _ "y'"] power_p_integer.simps[of _ _ y] dr' id if_False rem
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. urel_integer (let rec = power_p_integer pp (mult_p_integer pp x x) (drop_bit 1 y) in if r' = 0 then rec else mult_p_integer pp rec x) (let (d, r) = (d', r'); rec = power_p p (mult_p p x' x') d in if r = 0 then rec else mult_p p rec x')
[PROOF STEP]
using IH urel_integer_mult[OF IH x]
[PROOF STATE]
proof (prove)
using this:
urel_integer (power_p_integer pp (mult_p_integer pp x x) (drop_bit 1 y)) (power_p p (mult_p p x' x') d')
urel_integer (mult_p_integer pp (power_p_integer pp (mult_p_integer pp x x) (drop_bit 1 y)) x) (mult_p p (power_p p (mult_p p x' x') d') x')

goal (1 subgoal):
 1. urel_integer (let rec = power_p_integer pp (mult_p_integer pp x x) (drop_bit 1 y) in if r' = 0 then rec else mult_p_integer pp rec x) (let (d, r) = (d', r'); rec = power_p p (mult_p p x' x') d in if r = 0 then rec else mult_p p rec x')
[PROOF STEP]
by (auto simp: Let_def)
[PROOF STATE]
proof (state)
this:
urel_integer (power_p_integer pp x y) (power_p p x' y')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
urel_integer (power_p_integer pp x y) (power_p p x' y')

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pnTimes_flatten_PLUS:
  "\<lbrakk>X1 \<noteq> {}; finite X1; \<forall>x \<in> X1. \<not>is_Zero x \<and> \<not>is_Plus x\<rbrakk>\<Longrightarrow>
  pnTimes (flatten PLUS X1) r = flatten PLUS (Timess X1 r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>X1 \<noteq> {}; finite X1; \<forall>x\<in>X1. \<not> is_Zero x \<and> \<not> is_Plus x\<rbrakk> \<Longrightarrow> pnTimes (flatten PLUS X1) r = flatten PLUS (Timess X1 r)
[PROOF STEP]
by (rule trans[OF pnTimes_PLUS]) auto


[STATEMENT]
lemma dual_blocks_ne_index_ne:  "j1 < length \<B>s* \<Longrightarrow> j2 < length \<B>s* \<Longrightarrow> \<B>s* ! j1 \<noteq> \<B>s* ! j2 \<Longrightarrow> j1 \<noteq> j2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>j1 < length \<B>s*; j2 < length \<B>s*; \<B>s* ! j1 \<noteq> \<B>s* ! j2\<rbrakk> \<Longrightarrow> j1 \<noteq> j2
[PROOF STEP]
by auto


[STATEMENT]
lemma residue_mult_group_coset:
  fixes m n m1 m2 :: nat and f :: "nat \<Rightarrow> nat" and G H
  defines "G \<equiv> residue_mult_group n"
  defines "H \<equiv> residue_mult_group m"
  defines "f \<equiv> (\<lambda>k. k mod m)"
  assumes "b \<in> (rcosets\<^bsub>G\<^esub> kernel G H f)"
  assumes "m1 \<in> b" "m2 \<in> b"
  assumes "n > 1" "m dvd n"
  shows "m1 mod m = m2 mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
have h_1: "\<one>\<^bsub>H\<^esub> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>H\<^esub> = 1
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
H \<equiv> residue_mult_group m

goal (1 subgoal):
 1. \<one>\<^bsub>H\<^esub> = 1
[PROOF STEP]
unfolding residue_mult_group_def totatives_def
[PROOF STATE]
proof (prove)
using this:
H \<equiv> \<lparr>carrier = {k \<in> {0<..m}. coprime k m}, monoid.mult = \<lambda>x y. x * y mod m, one = 1\<rparr>

goal (1 subgoal):
 1. \<one>\<^bsub>H\<^esub> = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>H\<^esub> = 1

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
from assms(4)
[PROOF STATE]
proof (chain)
picking this:
b \<in> rcosets\<^bsub>G\<^esub> kernel G H f
[PROOF STEP]
obtain a :: nat where cos_expr: "b = (kernel G H f) #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G"
[PROOF STATE]
proof (prove)
using this:
b \<in> rcosets\<^bsub>G\<^esub> kernel G H f

goal (1 subgoal):
 1. (\<And>a. b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using RCOSETS_def[of G "kernel G H f"]
[PROOF STATE]
proof (prove)
using this:
b \<in> rcosets\<^bsub>G\<^esub> kernel G H f
rcosets\<^bsub>G\<^esub> kernel G H f = (\<Union>a\<in>carrier G. {kernel G H f #>\<^bsub>G\<^esub> a})

goal (1 subgoal):
 1. (\<And>a. b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G
[PROOF STEP]
have cop: "coprime a n"
[PROOF STATE]
proof (prove)
using this:
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G

goal (1 subgoal):
 1. coprime a n
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G
G \<equiv> residue_mult_group n

goal (1 subgoal):
 1. coprime a n
[PROOF STEP]
unfolding residue_mult_group_def totatives_def
[PROOF STATE]
proof (prove)
using this:
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G
G \<equiv> \<lparr>carrier = {k \<in> {0<..n}. coprime k n}, monoid.mult = \<lambda>x y. x * y mod n, one = 1\<rparr>

goal (1 subgoal):
 1. coprime a n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coprime a n

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
obtain a' where "[a * a' = 1] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a'. [a * a' = 1] (mod n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using cong_solve_coprime_nat[OF cop]
[PROOF STATE]
proof (prove)
using this:
\<exists>x. [a * x = Suc 0] (mod n)

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

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[a * a' = 1] (mod n)
[PROOF STEP]
have a_inv: "(a*a') mod n = 1"
[PROOF STATE]
proof (prove)
using this:
[a * a' = 1] (mod n)

goal (1 subgoal):
 1. a * a' mod n = 1
[PROOF STEP]
using cong_def[of "a*a'" 1 n] assms(7)
[PROOF STATE]
proof (prove)
using this:
[a * a' = 1] (mod n)
[a * a' = 1] (mod n) = (a * a' mod n = 1 mod n)
1 < n

goal (1 subgoal):
 1. a * a' mod n = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a * a' mod n = 1

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
have "m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})"
       "m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a}) &&& m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
[PROOF STEP]
using r_coset_def[of G "kernel G H f" a] cos_expr assms(5,6)
[PROOF STATE]
proof (prove)
using this:
kernel G H f #>\<^bsub>G\<^esub> a = (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
b = kernel G H f #>\<^bsub>G\<^esub> a \<and> a \<in> carrier G
m1 \<in> b
m2 \<in> b

goal (1 subgoal):
 1. m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a}) &&& m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
[PROOF STEP]
have "m1 \<in> (\<Union>h\<in>kernel G H f. {(h * a) mod n})"
            "m2 \<in> (\<Union>h\<in>kernel G H f. {(h * a) mod n})"
[PROOF STATE]
proof (prove)
using this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})

goal (1 subgoal):
 1. m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n}) &&& m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
G \<equiv> residue_mult_group n

goal (1 subgoal):
 1. m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n}) &&& m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
[PROOF STEP]
unfolding residue_mult_group_def[of n]
[PROOF STATE]
proof (prove)
using this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
m2 \<in> (\<Union>h\<in>kernel G H f. {h \<otimes>\<^bsub>G\<^esub> a})
G \<equiv> \<lparr>carrier = totatives n, monoid.mult = \<lambda>x y. x * y mod n, one = 1\<rparr>

goal (1 subgoal):
 1. m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n}) &&& m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
[PROOF STEP]
obtain m1' m2' where
    m_expr: "m1 = (m1'* a) mod n \<and> m1' \<in> kernel G H f"
            "m2 = (m2'* a) mod n \<and> m2' \<in> kernel G H f"
[PROOF STATE]
proof (prove)
using this:
m1 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})
m2 \<in> (\<Union>h\<in>kernel G H f. {h * a mod n})

goal (1 subgoal):
 1. (\<And>m1' m2'. \<lbrakk>m1 = m1' * a mod n \<and> m1' \<in> kernel G H f; m2 = m2' * a mod n \<and> m2' \<in> kernel G H f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m1 = m1' * a mod n \<and> m1' \<in> kernel G H f
m2 = m2' * a mod n \<and> m2' \<in> kernel G H f

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
have eq_1: "m1 mod m = a mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
have "m1 mod m = ((m1'* a) mod n) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1 mod m = m1' * a mod n mod m
[PROOF STEP]
using m_expr
[PROOF STATE]
proof (prove)
using this:
m1 = m1' * a mod n \<and> m1' \<in> kernel G H f
m2 = m2' * a mod n \<and> m2' \<in> kernel G H f

goal (1 subgoal):
 1. m1 mod m = m1' * a mod n mod m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m1 mod m = m1' * a mod n mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m1 mod m = m1' * a mod n mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
have "\<dots> = (m1' * a) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1' * a mod n mod m = m1' * a mod m
[PROOF STEP]
using euclidean_semiring_cancel_class.mod_mod_cancel assms(8)
[PROOF STATE]
proof (prove)
using this:
?c dvd ?b \<Longrightarrow> ?a mod ?b mod ?c = ?a mod ?c
m dvd n

goal (1 subgoal):
 1. m1' * a mod n mod m = m1' * a mod m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m1' * a mod n mod m = m1' * a mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m1' * a mod n mod m = m1' * a mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
have "\<dots> = (m1' mod m) * (a mod m) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1' * a mod m = m1' mod m * (a mod m) mod m
[PROOF STEP]
by (simp add: mod_mult_eq)
[PROOF STATE]
proof (state)
this:
m1' * a mod m = m1' mod m * (a mod m) mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m1' * a mod m = m1' mod m * (a mod m) mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
have "\<dots> = (a mod m) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
using m_expr(1) h_1
[PROOF STATE]
proof (prove)
using this:
m1 = m1' * a mod n \<and> m1' \<in> kernel G H f
\<one>\<^bsub>H\<^esub> = 1

goal (1 subgoal):
 1. m1' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
unfolding kernel_def assms(3)
[PROOF STATE]
proof (prove)
using this:
m1 = m1' * a mod n \<and> m1' \<in> {x \<in> carrier G. x mod m = \<one>\<^bsub>H\<^esub>}
\<one>\<^bsub>H\<^esub> = 1

goal (1 subgoal):
 1. m1' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m1' mod m * (a mod m) mod m = a mod m mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m1' mod m * (a mod m) mod m = a mod m mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
have "\<dots> = a mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a mod m mod m = a mod m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a mod m mod m = a mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
m1 mod m = a mod m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m1 mod m = a mod m

goal (1 subgoal):
 1. m1 mod m = a mod m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m1 mod m = a mod m

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
m1 mod m = a mod m

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
have eq_2: "m2 mod m = a mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
have "m2 mod m = ((m2'* a) mod n) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2 mod m = m2' * a mod n mod m
[PROOF STEP]
using m_expr
[PROOF STATE]
proof (prove)
using this:
m1 = m1' * a mod n \<and> m1' \<in> kernel G H f
m2 = m2' * a mod n \<and> m2' \<in> kernel G H f

goal (1 subgoal):
 1. m2 mod m = m2' * a mod n mod m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m2 mod m = m2' * a mod n mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m2 mod m = m2' * a mod n mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
have "\<dots> = (m2' * a) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2' * a mod n mod m = m2' * a mod m
[PROOF STEP]
using euclidean_semiring_cancel_class.mod_mod_cancel assms(8)
[PROOF STATE]
proof (prove)
using this:
?c dvd ?b \<Longrightarrow> ?a mod ?b mod ?c = ?a mod ?c
m dvd n

goal (1 subgoal):
 1. m2' * a mod n mod m = m2' * a mod m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m2' * a mod n mod m = m2' * a mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m2' * a mod n mod m = m2' * a mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
have "\<dots> = (m2' mod m) * (a mod m) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2' * a mod m = m2' mod m * (a mod m) mod m
[PROOF STEP]
by (simp add: mod_mult_eq)
[PROOF STATE]
proof (state)
this:
m2' * a mod m = m2' mod m * (a mod m) mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m2' * a mod m = m2' mod m * (a mod m) mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
have "\<dots> = (a mod m) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m2' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
using m_expr(2) h_1
[PROOF STATE]
proof (prove)
using this:
m2 = m2' * a mod n \<and> m2' \<in> kernel G H f
\<one>\<^bsub>H\<^esub> = 1

goal (1 subgoal):
 1. m2' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
unfolding kernel_def assms(3)
[PROOF STATE]
proof (prove)
using this:
m2 = m2' * a mod n \<and> m2' \<in> {x \<in> carrier G. x mod m = \<one>\<^bsub>H\<^esub>}
\<one>\<^bsub>H\<^esub> = 1

goal (1 subgoal):
 1. m2' mod m * (a mod m) mod m = a mod m mod m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m2' mod m * (a mod m) mod m = a mod m mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m2' mod m * (a mod m) mod m = a mod m mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
have "\<dots> = a mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a mod m mod m = a mod m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a mod m mod m = a mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
m2 mod m = a mod m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m2 mod m = a mod m

goal (1 subgoal):
 1. m2 mod m = a mod m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m2 mod m = a mod m

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
m2 mod m = a mod m

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
from eq_1 eq_2
[PROOF STATE]
proof (chain)
picking this:
m1 mod m = a mod m
m2 mod m = a mod m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m1 mod m = a mod m
m2 mod m = a mod m

goal (1 subgoal):
 1. m1 mod m = m2 mod m
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
m1 mod m = m2 mod m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma findMin_correct:
  assumes I: "invar q"
  assumes NE: "q \<noteq> Nil"
  shows
  "findMin q \<in># queue_to_multiset q"
  "\<forall>y\<in>set_mset (queue_to_multiset q). snd (findMin q) \<le> snd y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. findMin q \<in># queue_to_multiset q &&& \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. findMin q \<in># queue_to_multiset q
 2. \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
from NE
[PROOF STATE]
proof (chain)
picking this:
q \<noteq> []
[PROOF STEP]
have "getMinTree q \<in> set q"
[PROOF STATE]
proof (prove)
using this:
q \<noteq> []

goal (1 subgoal):
 1. getMinTree q \<in> set q
[PROOF STEP]
by (simp only: mintree_exists)
[PROOF STATE]
proof (state)
this:
getMinTree q \<in> set q

goal (2 subgoals):
 1. findMin q \<in># queue_to_multiset q
 2. \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
thus "findMin q \<in># queue_to_multiset q"
[PROOF STATE]
proof (prove)
using this:
getMinTree q \<in> set q

goal (1 subgoal):
 1. findMin q \<in># queue_to_multiset q
[PROOF STEP]
by (simp add: treehead_in_multiset Let_def findMin_def)
[PROOF STATE]
proof (state)
this:
findMin q \<in># queue_to_multiset q

goal (1 subgoal):
 1. \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
show "\<forall>y\<in>set_mset (queue_to_multiset q). snd (findMin q) \<le> snd y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
using I[unfolded invar_def]
[PROOF STATE]
proof (prove)
using this:
queue_invar q \<and> rank_invar q

goal (1 subgoal):
 1. \<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y
[PROOF STEP]
by (auto simp add: getMinTree_min_prio Let_def findMin_def)
[PROOF STATE]
proof (state)
this:
\<forall>y\<in>#queue_to_multiset q. snd (findMin q) \<le> snd y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mod_exp_aux_correct:
  "mod_exp_aux m y x n mod m = (x ^ n * y) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
have "mod_exp_aux m y x n = efficient_funpow (\<lambda>x y. x * y mod m) y x n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_exp_aux m y x n = efficient_funpow (\<lambda>x y. x * y mod m) y x n
[PROOF STEP]
by (simp add: mod_exp_aux_def)
[PROOF STATE]
proof (state)
this:
mod_exp_aux m y x n = efficient_funpow (\<lambda>x y. x * y mod m) y x n

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mod_exp_aux m y x n = efficient_funpow (\<lambda>x y. x * y mod m) y x n

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
have "\<dots> = ((\<lambda>y. x * y mod m) ^^ n) y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. efficient_funpow (\<lambda>x y. x * y mod m) y x n = ((\<lambda>y. x * y mod m) ^^ n) y
[PROOF STEP]
by (rule efficient_funpow_correct) (simp add: mod_mult_left_eq mod_mult_right_eq mult_ac)
[PROOF STATE]
proof (state)
this:
efficient_funpow (\<lambda>x y. x * y mod m) y x n = ((\<lambda>y. x * y mod m) ^^ n) y

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
efficient_funpow (\<lambda>x y. x * y mod m) y x n = ((\<lambda>y. x * y mod m) ^^ n) y

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
have "((\<lambda>y. x * y mod m) ^^ n) y mod m = (x ^ n * y) mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ((\<lambda>y. x * y mod m) ^^ 0) y mod m = x ^ 0 * y mod m
 2. \<And>n. ((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m \<Longrightarrow> ((\<lambda>y. x * y mod m) ^^ Suc n) y mod m = x ^ Suc n * y mod m
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m

goal (2 subgoals):
 1. ((\<lambda>y. x * y mod m) ^^ 0) y mod m = x ^ 0 * y mod m
 2. \<And>n. ((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m \<Longrightarrow> ((\<lambda>y. x * y mod m) ^^ Suc n) y mod m = x ^ Suc n * y mod m
[PROOF STEP]
hence "x * ((\<lambda>y. x * y mod m) ^^ n) y mod m = x * x ^ n * y mod m"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m

goal (1 subgoal):
 1. x * ((\<lambda>y. x * y mod m) ^^ n) y mod m = x * x ^ n * y mod m
[PROOF STEP]
by (metis mod_mult_right_eq mult.assoc)
[PROOF STATE]
proof (state)
this:
x * ((\<lambda>y. x * y mod m) ^^ n) y mod m = x * x ^ n * y mod m

goal (2 subgoals):
 1. ((\<lambda>y. x * y mod m) ^^ 0) y mod m = x ^ 0 * y mod m
 2. \<And>n. ((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m \<Longrightarrow> ((\<lambda>y. x * y mod m) ^^ Suc n) y mod m = x ^ Suc n * y mod m
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
x * ((\<lambda>y. x * y mod m) ^^ n) y mod m = x * x ^ n * y mod m

goal (1 subgoal):
 1. ((\<lambda>y. x * y mod m) ^^ Suc n) y mod m = x ^ Suc n * y mod m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((\<lambda>y. x * y mod m) ^^ Suc n) y mod m = x ^ Suc n * y mod m

goal (1 subgoal):
 1. ((\<lambda>y. x * y mod m) ^^ 0) y mod m = x ^ 0 * y mod m
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
((\<lambda>y. x * y mod m) ^^ n) y mod m = x ^ n * y mod m

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mod_exp_aux m y x n mod m = x ^ n * y mod m

goal (1 subgoal):
 1. mod_exp_aux m y x n mod m = x ^ n * y mod m
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mod_exp_aux m y x n mod m = x ^ n * y mod m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem cascade:
\<comment> \<open>If @{term U} is a quorum of an intact node and @{term S} is a super-set of @{term U}, then either @{term S} includes
all intact nodes or there is an intact node outside of @{term S} which is blocked by the intact members of @{term S}.
This shows that, in SCP, once the intact members of a quorum accept a statement,
a cascading effect occurs and all intact nodes eventually accept it regardless of what befouled and faulty nodes do.\<close>
  fixes U S
  assumes "orig.quorum U" and "U \<inter> I \<noteq> {}" and "U \<subseteq> S"
  obtains "I \<subseteq> S" | "\<exists> n \<in> I - S . \<forall> Sl \<in> slices n . Sl \<inter> S \<inter> I \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>I \<subseteq> S \<Longrightarrow> thesis; \<exists>n\<in>I - S. \<forall>Sl\<in>slices n. Sl \<inter> S \<inter> I \<noteq> {} \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>I \<subseteq> S \<Longrightarrow> thesis; \<exists>n\<in>I - S. \<forall>Sl\<in>slices n. Sl \<inter> S \<inter> I \<noteq> {} \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have False if 1:"\<forall> n \<in> I - S . \<exists> Sl \<in> slices n . Sl \<inter> S \<inter> I = {}" and 2:"\<not>(I \<subseteq> S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
text \<open>First we show that @{term \<open>I-S\<close>} is a quorum in the projected system. This is immediate from the definition of quorum and assumption 1.\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
have "proj.quorum (I-S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj.quorum (I - S)
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
\<forall>n\<in>I - S. \<exists>Sl\<in>slices n. Sl \<inter> S \<inter> I = {}

goal (1 subgoal):
 1. proj.quorum (I - S)
[PROOF STEP]
unfolding proj.quorum_def project_def
[PROOF STATE]
proof (prove)
using this:
\<forall>n\<in>I - S. \<exists>Sl\<in>slices n. Sl \<inter> S \<inter> I = {}

goal (1 subgoal):
 1. \<forall>p\<in>(I - S) \<inter> W. \<exists>Sl\<in>{Sl \<inter> I |Sl. Sl \<in> slices p}. Sl \<subseteq> I - S
[PROOF STEP]
by (auto; smt DiffI Diff_Compl Diff_Int_distrib Diff_eq Diff_eq_empty_iff Int_commute)
[PROOF STATE]
proof (state)
this:
proj.quorum (I - S)

goal (1 subgoal):
 1. False
[PROOF STEP]
text \<open>Then we show that U is also a quorum in the projected system:\<close>
[PROOF STATE]
proof (state)
this:
proj.quorum (I - S)

goal (1 subgoal):
 1. False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proj.quorum (I - S)

goal (1 subgoal):
 1. False
[PROOF STEP]
have "proj.quorum U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj.quorum U
[PROOF STEP]
using \<open>orig.quorum U\<close>
[PROOF STATE]
proof (prove)
using this:
orig.quorum U

goal (1 subgoal):
 1. proj.quorum U
[PROOF STEP]
unfolding proj.quorum_def orig.quorum_def project_def
[PROOF STATE]
proof (prove)
using this:
\<forall>p\<in>U \<inter> W. \<exists>Sl\<in>slices p. Sl \<subseteq> U

goal (1 subgoal):
 1. \<forall>p\<in>U \<inter> W. \<exists>Sl\<in>{Sl \<inter> I |Sl. Sl \<in> slices p}. Sl \<subseteq> U
[PROOF STEP]
by (simp; meson Int_commute inf.coboundedI2)
[PROOF STATE]
proof (state)
this:
proj.quorum U

goal (1 subgoal):
 1. False
[PROOF STEP]
text \<open>Since quorums of @{term I} must intersect, we get a contradiction:\<close>
[PROOF STATE]
proof (state)
this:
proj.quorum U

goal (1 subgoal):
 1. False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
proj.quorum (I - S)
proj.quorum U
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
proj.quorum (I - S)
proj.quorum U

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>U \<subseteq> S\<close> \<open>U \<inter> I \<noteq> {}\<close> \<open>\<not>(I\<subseteq>S)\<close> q_inter
[PROOF STATE]
proof (prove)
using this:
proj.quorum (I - S)
proj.quorum U
U \<subseteq> S
U \<inter> I \<noteq> {}
\<not> I \<subseteq> S
\<lbrakk>proj.quorum ?Q; proj.quorum ?Q'; ?Q \<inter> I \<noteq> {}; ?Q' \<inter> I \<noteq> {}\<rbrakk> \<Longrightarrow> ?Q \<inter> ?Q' \<inter> I \<noteq> {}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<forall>n\<in>I - S. \<exists>Sl\<in>slices n. Sl \<inter> S \<inter> I = {}; \<not> I \<subseteq> S\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. \<lbrakk>I \<subseteq> S \<Longrightarrow> thesis; \<exists>n\<in>I - S. \<forall>Sl\<in>slices n. Sl \<inter> S \<inter> I \<noteq> {} \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>n\<in>I - S. \<exists>Sl\<in>slices n. Sl \<inter> S \<inter> I = {}; \<not> I \<subseteq> S\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<forall>n\<in>I - S. \<exists>Sl\<in>slices n. Sl \<inter> S \<inter> I = {}; \<not> I \<subseteq> S\<rbrakk> \<Longrightarrow> False
I \<subseteq> S \<Longrightarrow> thesis
\<exists>n\<in>I - S. \<forall>Sl\<in>slices n. Sl \<inter> S \<inter> I \<noteq> {} \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma foldl_pair_constl: "foldl (\<lambda>s e. map_prod (\<lambda>_. c) (\<lambda>r. f r e) s) (c, sr) l =
    Pair c (foldl (\<lambda>s e. f s e) sr l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>s e. map_prod (\<lambda>_. c) (\<lambda>r. f r e) s) (c, sr) l = (c, foldl f sr l)
[PROOF STEP]
by (induction l arbitrary: sr) (auto simp add: map_prod_def split_def)


[STATEMENT]
lemma mat_mult_right_mono: assumes A0: "A \<ge>\<^sub>m 0\<^sub>m n n"
  and BC: "B \<ge>\<^sub>m (C :: 'a :: ordered_semiring_0 mat)"
  and carr: "A \<in> carrier_mat n n" "B \<in> carrier_mat n n" "C \<in> carrier_mat n n"
  shows "A * B \<ge>\<^sub>m A * C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
assume i: "i < n" "j < n"
[PROOF STATE]
proof (state)
this:
i < n
j < n

goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
have "row A i \<bullet> col B j \<ge> row A i \<bullet> col C j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row A i \<bullet> col C j \<le> row A i \<bullet> col B j
[PROOF STEP]
by (rule scalar_right_mono[of _ n], insert A0 BC carr i, auto)
[PROOF STATE]
proof (state)
this:
row A i \<bullet> col C j \<le> row A i \<bullet> col B j

goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> row A ?i2 \<bullet> col C ?j2 \<le> row A ?i2 \<bullet> col B ?j2

goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> row A ?i2 \<bullet> col C ?j2 \<le> row A ?i2 \<bullet> col B ?j2

goal (1 subgoal):
 1. A * B \<ge>\<^sub>m A * C
[PROOF STEP]
by (intro mat_geI[of _ n n], insert carr, auto)
[PROOF STATE]
proof (state)
this:
A * B \<ge>\<^sub>m A * C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma of_nat_mono[intro]: assumes "n \<ge> m" shows "(of_nat n :: 'a :: ordered_semiring_1) \<ge> of_nat m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat m \<le> of_nat n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. of_nat m \<le> of_nat n
[PROOF STEP]
let ?n = "of_nat :: nat \<Rightarrow> 'a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. of_nat m \<le> of_nat n
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
m \<le> n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m \<le> n

goal (1 subgoal):
 1. of_nat m \<le> of_nat n
[PROOF STEP]
proof (induct m arbitrary: n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. 0 \<le> n \<Longrightarrow> of_nat 0 \<le> of_nat n
 2. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 \<le> n

goal (2 subgoals):
 1. \<And>n. 0 \<le> n \<Longrightarrow> of_nat 0 \<le> of_nat n
 2. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat 0 \<le> of_nat n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
of_nat 0 \<le> of_nat n

goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
case (Suc m nn)
[PROOF STATE]
proof (state)
this:
m \<le> ?n \<Longrightarrow> of_nat m \<le> of_nat ?n
Suc m \<le> nn

goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m \<le> ?n \<Longrightarrow> of_nat m \<le> of_nat ?n
Suc m \<le> nn
[PROOF STEP]
obtain n where nn: "nn = Suc n"
[PROOF STATE]
proof (prove)
using this:
m \<le> ?n \<Longrightarrow> of_nat m \<le> of_nat ?n
Suc m \<le> nn

goal (1 subgoal):
 1. (\<And>n. nn = Suc n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases nn, auto)
[PROOF STATE]
proof (state)
this:
nn = Suc n

goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
note Suc = Suc[unfolded nn]
[PROOF STATE]
proof (state)
this:
m \<le> ?n \<Longrightarrow> of_nat m \<le> of_nat ?n
Suc m \<le> Suc n

goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
hence rec: "?n n \<ge> ?n m"
[PROOF STATE]
proof (prove)
using this:
m \<le> ?n \<Longrightarrow> of_nat m \<le> of_nat ?n
Suc m \<le> Suc n

goal (1 subgoal):
 1. of_nat m \<le> of_nat n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_nat m \<le> of_nat n

goal (1 subgoal):
 1. \<And>m n. \<lbrakk>\<And>n. m \<le> n \<Longrightarrow> of_nat m \<le> of_nat n; Suc m \<le> n\<rbrakk> \<Longrightarrow> of_nat (Suc m) \<le> of_nat n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (Suc m) \<le> of_nat nn
[PROOF STEP]
unfolding nn of_nat_Suc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) + of_nat m \<le> (1::'a) + of_nat n
[PROOF STEP]
by (rule plus_right_mono[OF rec])
[PROOF STATE]
proof (state)
this:
of_nat (Suc m) \<le> of_nat nn

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
of_nat m \<le> of_nat n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma oStrictLimit_lub: "\<forall>n. f n < x \<Longrightarrow> oStrictLimit f \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. f n < x \<Longrightarrow> oStrictLimit f \<le> x
[PROOF STEP]
apply (erule contrapos_pp, simp add: linorder_not_less linorder_not_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < oStrictLimit f \<Longrightarrow> \<exists>n. x \<le> f n
[PROOF STEP]
apply (cases x, simp add: oStrictLimit_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z. \<lbrakk>z < ord0_Lim (\<lambda>n. SOME x. x \<in> Rep_ordinal (f n)); x = Abs_ordinal (ord0rel `` {z})\<rbrakk> \<Longrightarrow> \<exists>n. Abs_ordinal (ord0rel `` {z}) \<le> f n
[PROOF STEP]
apply (drule less_ord0_LimD, clarify)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z n. \<lbrakk>x = Abs_ordinal (ord0rel `` {z}); z \<le> (SOME x. x \<in> Rep_ordinal (f n))\<rbrakk> \<Longrightarrow> \<exists>n. Abs_ordinal (ord0rel `` {z}) \<le> f n
[PROOF STEP]
apply (rule_tac x=n in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z n. \<lbrakk>x = Abs_ordinal (ord0rel `` {z}); z \<le> (SOME x. x \<in> Rep_ordinal (f n))\<rbrakk> \<Longrightarrow> Abs_ordinal (ord0rel `` {z}) \<le> f n
[PROOF STEP]
apply (rule_tac x="f n" in Abs_ordinal_cases2, simp, rename_tac y)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z n y. \<lbrakk>x = Abs_ordinal (ord0rel `` {z}); z \<le> (SOME x. (y, x) \<in> ord0rel); f n = Abs_ordinal (ord0rel `` {y})\<rbrakk> \<Longrightarrow> z \<le> y
[PROOF STEP]
apply (erule ord0_order_trans)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z n y. \<lbrakk>x = Abs_ordinal (ord0rel `` {z}); f n = Abs_ordinal (ord0rel `` {y})\<rbrakk> \<Longrightarrow> (SOME x. (y, x) \<in> ord0rel) \<le> y
[PROOF STEP]
apply (rule ord0relD[THEN conjunct2])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>z n y. \<lbrakk>x = Abs_ordinal (ord0rel `` {z}); f n = Abs_ordinal (ord0rel `` {y})\<rbrakk> \<Longrightarrow> (y, SOME x. (y, x) \<in> ord0rel) \<in> ord0rel
[PROOF STEP]
apply (rule some_ord0rel)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma primitive_part_smult:
  fixes p :: "'a :: {factorial_semiring, semiring_Gcd, ring_gcd, idom_divide,
                     normalization_semidom_multiplicative} poly"
  shows "primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
have "smult a p = [:a:] * p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult a p = [:a:] * p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
smult a p = [:a:] * p

goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
smult a p = [:a:] * p

goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
have "primitive_part \<dots> = smult (unit_factor a) (primitive_part p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primitive_part ([:a:] * p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
by (subst primitive_part_mult) simp_all
[PROOF STATE]
proof (state)
this:
primitive_part ([:a:] * p) = smult (unit_factor a) (primitive_part p)

goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)

goal (1 subgoal):
 1. primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
primitive_part (smult a p) = smult (unit_factor a) (primitive_part p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma product_comm:
  "A \<otimes> B = B \<otimes> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<otimes> B = B \<otimes> A
[PROOF STEP]
unfolding product_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a |\<union>| b |a b. a \<in> A \<and> b \<in> B} = {a |\<union>| b |a b. a \<in> B \<and> b \<in> A}
[PROOF STEP]
by blast


[STATEMENT]
lemma compose_eq' [simp]:
  shows "compose A G F = restrict (G o F) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compose A G F = restrict (G \<circ> F) A
[PROOF STEP]
unfolding compose_def restrict_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if x \<in> A then G (F x) else undefined) = (\<lambda>x. if x \<in> A then (G \<circ> F) x else undefined)
[PROOF STEP]
by auto


[STATEMENT]
lemma empty_eff_drest_no_eff:
  fixes s and a and vs
  assumes "(fmdom' (fmrestrict_set vs (snd a)) = {})"
  shows "(fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s
[PROOF STEP]
have "fmdom' (snd (action_proj a vs)) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmdom' (snd (action_proj a vs)) = {}
[PROOF STEP]
unfolding action_proj_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmdom' (snd (fmrestrict_set vs (fst a), fmrestrict_set vs (snd a))) = {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
fmdom' (fmrestrict_set vs (snd a)) = {}

goal (1 subgoal):
 1. fmdom' (snd (fmrestrict_set vs (fst a), fmrestrict_set vs (snd a))) = {}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fmdom' (snd (action_proj a vs)) = {}

goal (1 subgoal):
 1. fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
fmdom' (snd (action_proj a vs)) = {}
[PROOF STEP]
have "state_succ s (action_proj a vs) = s"
[PROOF STATE]
proof (prove)
using this:
fmdom' (snd (action_proj a vs)) = {}

goal (1 subgoal):
 1. state_succ s (action_proj a vs) = s
[PROOF STEP]
using empty_eff_exec_eq
[PROOF STATE]
proof (prove)
using this:
fmdom' (snd (action_proj a vs)) = {}
fmdom' (snd ?a) = {} \<Longrightarrow> state_succ ?s ?a = ?s

goal (1 subgoal):
 1. state_succ s (action_proj a vs) = s
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
state_succ s (action_proj a vs) = s

goal (1 subgoal):
 1. fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
state_succ s (action_proj a vs) = s
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
state_succ s (action_proj a vs) = s

goal (1 subgoal):
 1. fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fmrestrict_set vs (state_succ s (action_proj a vs)) = fmrestrict_set vs s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_list_length_split:
  fixes xs::"real list"
  shows "length xs = length (list_neq xs m) + length (list_eq xs m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = length (list_neq xs m) + length (list_eq xs m)
[PROOF STEP]
apply (induct xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length [] = length (list_neq [] m) + length (list_eq [] m)
 2. \<And>a xs. length xs = length (list_neq xs m) + length (list_eq xs m) \<Longrightarrow> length (a # xs) = length (list_neq (a # xs) m) + length (list_eq (a # xs) m)
[PROOF STEP]
apply simp+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma underS_underS_trans:
assumes TRANS: "trans r" and ANTISYM: "antisym r" and
        IN1: "a \<in> underS r b" and IN2: "b \<in> underS r c"
shows "a \<in> underS r c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> underS r c
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<in> underS r c
[PROOF STEP]
have "a \<in> under r b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> under r b
[PROOF STEP]
using IN1 underS_subset_under
[PROOF STATE]
proof (prove)
using this:
a \<in> underS r b
underS ?r ?a \<subseteq> under ?r ?a

goal (1 subgoal):
 1. a \<in> under r b
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
a \<in> under r b

goal (1 subgoal):
 1. a \<in> underS r c
[PROOF STEP]
with assms under_underS_trans
[PROOF STATE]
proof (chain)
picking this:
trans r
antisym r
a \<in> underS r b
b \<in> underS r c
\<lbrakk>trans ?r; antisym ?r; ?a \<in> under ?r ?b; ?b \<in> underS ?r ?c\<rbrakk> \<Longrightarrow> ?a \<in> underS ?r ?c
a \<in> under r b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
trans r
antisym r
a \<in> underS r b
b \<in> underS r c
\<lbrakk>trans ?r; antisym ?r; ?a \<in> under ?r ?b; ?b \<in> underS ?r ?c\<rbrakk> \<Longrightarrow> ?a \<in> underS ?r ?c
a \<in> under r b

goal (1 subgoal):
 1. a \<in> underS r c
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
a \<in> underS r c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma n_distrib2: "n x \<oplus> n y \<cdot> n z = (n x \<oplus> n y) \<cdot> (n x \<oplus> n z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n x \<oplus> n y \<cdot> n z = (n x \<oplus> n y) \<cdot> (n x \<oplus> n z)
[PROOF STEP]
by (metis mult_t_closed n_distrib1 n_mult_idem  n_add_op_def)


[STATEMENT]
lemma hom_sup [simp]: "hom f (x \<squnion> y) = hom f x \<squnion> hom f y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hom f (x \<squnion> y) = hom f x \<squnion> hom f y
[PROOF STEP]
unfolding sup_conv_inf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hom f (- (- x \<sqinter> - y)) = - (- hom f x \<sqinter> - hom f y)
[PROOF STEP]
by (simp only: hom_compl hom_inf)


[STATEMENT]
lemma List_explode_goup_by_zeros: "List_explode (goup_by_zeros xs) = map Some xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. List_explode (goup_by_zeros xs) = map Some xs
[PROOF STEP]
apply(induction xs rule: goup_by_zeros.induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. List_explode (goup_by_zeros []) = map Some []
 2. \<And>x xs. \<lbrakk>x = 0 \<Longrightarrow> List_explode (goup_by_zeros (dropWhile (\<lambda>x. x = 0) xs)) = map Some (dropWhile (\<lambda>x. x = 0) xs); x \<noteq> 0 \<Longrightarrow> List_explode (goup_by_zeros xs) = map Some xs\<rbrakk> \<Longrightarrow> List_explode (goup_by_zeros (x # xs)) = map Some (x # xs)
[PROOF STEP]
apply(simp; fail)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>x = 0 \<Longrightarrow> List_explode (goup_by_zeros (dropWhile (\<lambda>x. x = 0) xs)) = map Some (dropWhile (\<lambda>x. x = 0) xs); x \<noteq> 0 \<Longrightarrow> List_explode (goup_by_zeros xs) = map Some xs\<rbrakk> \<Longrightarrow> List_explode (goup_by_zeros (x # xs)) = map Some (x # xs)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>x = 0 \<Longrightarrow> List_explode (goup_by_zeros (dropWhile (\<lambda>x. x = 0) xs)) = map Some (dropWhile (\<lambda>x. x = 0) xs); x \<noteq> 0 \<Longrightarrow> List_explode (goup_by_zeros xs) = map Some xs\<rbrakk> \<Longrightarrow> x = 0 \<longrightarrow> map Some (takeWhile (\<lambda>x. x = 0) xs) @ map Some (dropWhile (\<lambda>x. x = 0) xs) = map Some xs
[PROOF STEP]
apply(safe)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>0 = 0 \<Longrightarrow> List_explode (goup_by_zeros (dropWhile (\<lambda>x. x = 0) xs)) = map Some (dropWhile (\<lambda>x. x = 0) xs); 0 \<noteq> 0 \<Longrightarrow> List_explode (goup_by_zeros xs) = map Some xs\<rbrakk> \<Longrightarrow> map Some (takeWhile (\<lambda>x. x = 0) xs) @ map Some (dropWhile (\<lambda>x. x = 0) xs) = map Some xs
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs. List_explode (goup_by_zeros (dropWhile (\<lambda>x. x = 0) xs)) = map Some (dropWhile (\<lambda>x. x = 0) xs) \<Longrightarrow> map Some (takeWhile (\<lambda>x. x = 0) xs) @ map Some (dropWhile (\<lambda>x. x = 0) xs) = map Some xs
[PROOF STEP]
by (metis map_append takeWhile_dropWhile_id)


[STATEMENT]
lemma compact_Int_closed [intro]:
  assumes "compact S"
    and "closed T"
  shows "compact (S \<inter> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact (S \<inter> T)
[PROOF STEP]
proof (rule compactI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
fix C
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
assume C: "\<forall>c\<in>C. open c"
[PROOF STATE]
proof (state)
this:
Ball C open

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
assume cover: "S \<inter> T \<subseteq> \<Union>C"
[PROOF STATE]
proof (state)
this:
S \<inter> T \<subseteq> \<Union> C

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
from C \<open>closed T\<close>
[PROOF STATE]
proof (chain)
picking this:
Ball C open
closed T
[PROOF STEP]
have "\<forall>c\<in>C \<union> {- T}. open c"
[PROOF STATE]
proof (prove)
using this:
Ball C open
closed T

goal (1 subgoal):
 1. Ball (C \<union> {- T}) open
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Ball (C \<union> {- T}) open

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Ball (C \<union> {- T}) open

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
from cover
[PROOF STATE]
proof (chain)
picking this:
S \<inter> T \<subseteq> \<Union> C
[PROOF STEP]
have "S \<subseteq> \<Union>(C \<union> {- T})"
[PROOF STATE]
proof (prove)
using this:
S \<inter> T \<subseteq> \<Union> C

goal (1 subgoal):
 1. S \<subseteq> \<Union> (C \<union> {- T})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S \<subseteq> \<Union> (C \<union> {- T})

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Ball (C \<union> {- T}) open
S \<subseteq> \<Union> (C \<union> {- T})
[PROOF STEP]
have "\<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union>D"
[PROOF STATE]
proof (prove)
using this:
Ball (C \<union> {- T}) open
S \<subseteq> \<Union> (C \<union> {- T})

goal (1 subgoal):
 1. \<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D
[PROOF STEP]
using \<open>compact S\<close>
[PROOF STATE]
proof (prove)
using this:
Ball (C \<union> {- T}) open
S \<subseteq> \<Union> (C \<union> {- T})
compact S

goal (1 subgoal):
 1. \<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D
[PROOF STEP]
unfolding compact_eq_Heine_Borel
[PROOF STATE]
proof (prove)
using this:
Ball (C \<union> {- T}) open
S \<subseteq> \<Union> (C \<union> {- T})
\<forall>C. Ball C open \<and> S \<subseteq> \<Union> C \<longrightarrow> (\<exists>D\<subseteq>C. finite D \<and> S \<subseteq> \<Union> D)

goal (1 subgoal):
 1. \<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D
[PROOF STEP]
obtain D where "D \<subseteq> C \<union> {- T} \<and> finite D \<and> S \<subseteq> \<Union>D"
[PROOF STATE]
proof (prove)
using this:
\<exists>D\<subseteq>C \<union> {- T}. finite D \<and> S \<subseteq> \<Union> D

goal (1 subgoal):
 1. (\<And>D. D \<subseteq> C \<union> {- T} \<and> finite D \<and> S \<subseteq> \<Union> D \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
D \<subseteq> C \<union> {- T} \<and> finite D \<and> S \<subseteq> \<Union> D

goal (1 subgoal):
 1. \<And>C. \<lbrakk>Ball C open; S \<inter> T \<subseteq> \<Union> C\<rbrakk> \<Longrightarrow> \<exists>C'\<subseteq>C. finite C' \<and> S \<inter> T \<subseteq> \<Union> C'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
D \<subseteq> C \<union> {- T} \<and> finite D \<and> S \<subseteq> \<Union> D
[PROOF STEP]
show "\<exists>D\<subseteq>C. finite D \<and> S \<inter> T \<subseteq> \<Union>D"
[PROOF STATE]
proof (prove)
using this:
D \<subseteq> C \<union> {- T} \<and> finite D \<and> S \<subseteq> \<Union> D

goal (1 subgoal):
 1. \<exists>D\<subseteq>C. finite D \<and> S \<inter> T \<subseteq> \<Union> D
[PROOF STEP]
by (intro exI[of _ "D - {-T}"]) auto
[PROOF STATE]
proof (state)
this:
\<exists>D\<subseteq>C. finite D \<and> S \<inter> T \<subseteq> \<Union> D

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scaleC_eq_iff [simp]: "b + u *\<^sub>C a = a + u *\<^sub>C b \<longleftrightarrow> a = b \<or> u = 1"
  for a :: "'a::complex_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
proof (cases "u = 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. u = 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
 2. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
u = 1

goal (2 subgoals):
 1. u = 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
 2. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
u = 1

goal (1 subgoal):
 1. (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)

goal (1 subgoal):
 1. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
u \<noteq> 1

goal (1 subgoal):
 1. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
have "a = b" if "b + u *\<^sub>C a = a + u *\<^sub>C b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
from that
[PROOF STATE]
proof (chain)
picking this:
b + u *\<^sub>C a = a + u *\<^sub>C b
[PROOF STEP]
have "(u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b"
[PROOF STATE]
proof (prove)
using this:
b + u *\<^sub>C a = a + u *\<^sub>C b

goal (1 subgoal):
 1. (u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b

goal (1 subgoal):
 1. a = b
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
u \<noteq> 1
(u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
u \<noteq> 1
(u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b

goal (1 subgoal):
 1. a = b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a = b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b + u *\<^sub>C a = a + u *\<^sub>C b \<Longrightarrow> a = b

goal (1 subgoal):
 1. u \<noteq> 1 \<Longrightarrow> (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
b + u *\<^sub>C a = a + u *\<^sub>C b \<Longrightarrow> a = b

goal (1 subgoal):
 1. (b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(b + u *\<^sub>C a = a + u *\<^sub>C b) = (a = b \<or> u = 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rotate2_scaleR [simp]: "rotate2 (k *\<^sub>R x) = k *\<^sub>R (rotate2 x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotate2 (k *\<^sub>R x) = k *\<^sub>R rotate2 x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rotate2 (k *\<^sub>R x) = k *\<^sub>R rotate2 x
[PROOF STEP]
have "(rotate2 (k *\<^sub>R x))$1 = (k *\<^sub>R (rotate2 x))$1" and
    "(rotate2 (k *\<^sub>R x))$2 = (k *\<^sub>R (rotate2 x))$2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotate2 (k *\<^sub>R x) $ 1 = (k *\<^sub>R rotate2 x) $ 1 &&& rotate2 (k *\<^sub>R x) $ 2 = (k *\<^sub>R rotate2 x) $ 2
[PROOF STEP]
by simp+
[PROOF STATE]
proof (state)
this:
rotate2 (k *\<^sub>R x) $ 1 = (k *\<^sub>R rotate2 x) $ 1
rotate2 (k *\<^sub>R x) $ 2 = (k *\<^sub>R rotate2 x) $ 2

goal (1 subgoal):
 1. rotate2 (k *\<^sub>R x) = k *\<^sub>R rotate2 x
[PROOF STEP]
with real2_eq
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?u $ 1 = ?v $ 1; ?u $ 2 = ?v $ 2\<rbrakk> \<Longrightarrow> ?u = ?v
rotate2 (k *\<^sub>R x) $ 1 = (k *\<^sub>R rotate2 x) $ 1
rotate2 (k *\<^sub>R x) $ 2 = (k *\<^sub>R rotate2 x) $ 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u $ 1 = ?v $ 1; ?u $ 2 = ?v $ 2\<rbrakk> \<Longrightarrow> ?u = ?v
rotate2 (k *\<^sub>R x) $ 1 = (k *\<^sub>R rotate2 x) $ 1
rotate2 (k *\<^sub>R x) $ 2 = (k *\<^sub>R rotate2 x) $ 2

goal (1 subgoal):
 1. rotate2 (k *\<^sub>R x) = k *\<^sub>R rotate2 x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rotate2 (k *\<^sub>R x) = k *\<^sub>R rotate2 x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_list'_append[simp]: "sum_list' p (ds@[d]) = truncate_up p (d + sum_list' p ds)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list' p (ds @ [d]) = truncate_up p (d + sum_list' p ds)
[PROOF STEP]
unfolding sum_list'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fold (\<lambda>a b. eucl_truncate_up p (a + b)) (ds @ [d]) 0 = truncate_up p (d + fold (\<lambda>a b. eucl_truncate_up p (a + b)) ds 0)
[PROOF STEP]
by (simp add: eucl_truncate_up_real_def)


[STATEMENT]
lemma has_field_derivative_stirling_sum'_real [derivative_intros]:
  assumes "j > 0" "x > (0::real)"
  shows   "(stirling_sum' j m has_field_derivative stirling_sum' (Suc j) m x) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
proof (cases j)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
case (Suc j')
[PROOF STATE]
proof (state)
this:
j = Suc j'

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < j
0 < x
[PROOF STEP]
have [simp]: "x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
0 < j
0 < x

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

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
define c where "c = (\<lambda>n. (-1) ^ Suc j * (bernoulli' n) * pochhammer (of_nat (Suc n)) j')"
[PROOF STATE]
proof (state)
this:
c = (\<lambda>n. (- 1) ^ Suc j * bernoulli' n * pochhammer (real (Suc n)) j')

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
define T where "T = (\<lambda>n x. c n * inverse x ^ (j + n))"
[PROOF STATE]
proof (state)
this:
T = (\<lambda>n x. c n * inverse x ^ (j + n))

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
define T' where "T' = (\<lambda>n x. - (of_nat (j + n)) * c n * inverse x ^ (Suc (j + n)))"
[PROOF STATE]
proof (state)
this:
T' = (\<lambda>n x. - real (j + n) * c n * inverse x ^ Suc (j + n))

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
have "((\<lambda>x. \<Sum>k\<le>m. T k x) has_field_derivative (\<Sum>k\<le>m. T' k x)) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>k\<le>m. T k x) has_real_derivative (\<Sum>k\<le>m. T' k x)) (at x)
[PROOF STEP]
using assms Suc
[PROOF STATE]
proof (prove)
using this:
0 < j
0 < x
j = Suc j'

goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>k\<le>m. T k x) has_real_derivative (\<Sum>k\<le>m. T' k x)) (at x)
[PROOF STEP]
by (intro DERIV_sum)
       (auto simp: T_def T'_def intro!: derivative_eq_intros
             simp: field_simps power_add [symmetric]  simp del: of_nat_Suc power_Suc of_nat_add)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. \<Sum>k\<le>m. T k x) has_real_derivative (\<Sum>k\<le>m. T' k x)) (at x)

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((\<lambda>x. \<Sum>k\<le>m. T k x) has_real_derivative (\<Sum>k\<le>m. T' k x)) (at x)

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
have "(\<lambda>x. (\<Sum>k\<le>m. T k x)) = stirling_sum' j m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<Sum>k\<le>m. T k x) = stirling_sum' j m
[PROOF STEP]
by (simp add: Suc T_def c_def stirling_sum'_def fun_eq_iff add_ac mult.assoc sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>k\<le>m. T k x) = stirling_sum' j m

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>k\<le>m. T k x) = stirling_sum' j m

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
have "(\<Sum>k\<le>m. T' k x) = stirling_sum' (Suc j) m x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. T' k x) = stirling_sum' (Suc j) m x
[PROOF STEP]
by (simp add: T'_def c_def Suc stirling_sum'_def sum_distrib_left
          sum_distrib_right algebra_simps pochhammer_Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. T' k x) = stirling_sum' (Suc j) m x

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
 2. \<And>nat. j = Suc nat \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)

goal (1 subgoal):
 1. (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)

goal (1 subgoal):
 1. j = 0 \<Longrightarrow> (stirling_sum' j m has_real_derivative stirling_sum' (Suc j) m x) (at x)
[PROOF STEP]
qed (insert assms, simp_all)


[STATEMENT]
lemma mset_diff_cancel1elem[simp]: "~(a \<in># B) \<Longrightarrow> {#a#}-B = {#a#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
assume A: "~(a \<in># B)"
[PROOF STATE]
proof (state)
this:
a \<notin># B

goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
hence "count ({#a#}-B) a = count ({#a#}) a"
[PROOF STATE]
proof (prove)
using this:
a \<notin># B

goal (1 subgoal):
 1. count ({#a#} - B) a = count {#a#} a
[PROOF STEP]
by (auto simp add: not_in_iff)
[PROOF STATE]
proof (state)
this:
count ({#a#} - B) a = count {#a#} a

goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
count ({#a#} - B) a = count {#a#} a

goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
have "ALL e . e~=a \<longrightarrow> count ({#a#}-B) e = count ({#a#}) e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>e. e \<noteq> a \<longrightarrow> count ({#a#} - B) e = count {#a#} e
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>e. e \<noteq> a \<longrightarrow> count ({#a#} - B) e = count {#a#} e

goal (1 subgoal):
 1. a \<notin># B \<Longrightarrow> {#a#} - B = {#a#}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
count ({#a#} - B) a = count {#a#} a
\<forall>e. e \<noteq> a \<longrightarrow> count ({#a#} - B) e = count {#a#} e
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
count ({#a#} - B) a = count {#a#} a
\<forall>e. e \<noteq> a \<longrightarrow> count ({#a#} - B) e = count {#a#} e

goal (1 subgoal):
 1. {#a#} - B = {#a#}
[PROOF STEP]
by (auto simp add: multiset_eq_iff)
[PROOF STATE]
proof (state)
this:
{#a#} - B = {#a#}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prime_sum_upto_nonneg:
  assumes "\<And>n. n > 0 \<Longrightarrow> f n \<ge> (0 :: real)"
  shows   "prime_sum_upto f x \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> prime_sum_upto f x
[PROOF STEP]
unfolding prime_sum_upto_altdef1 sum_upto_altdef
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (\<Sum>p\<in>{0<..nat \<lfloor>x\<rfloor>}. ind prime p * f p)
[PROOF STEP]
by (intro sum_nonneg) (auto simp: ind_def assms)