[STATEMENT]
lemma Suc_rtos_div_r_1:"\<lbrakk> 0 < r; 0 < s; i \<le> r * s - Suc 0;
         Suc (rtos r s i) < r * s; i mod s = s - Suc 0;
         i div s < r - Suc 0\<rbrakk> \<Longrightarrow>  Suc (rtos r s i) div r = i mod s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc (rtos r s i) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0\<rbrakk> \<Longrightarrow> Suc (rtos r s i) div r = i mod s
[PROOF STEP]
apply (simp add:rtos_def,
       frule le_less_trans [of "i" "r * s - Suc 0" "r * s"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc (if i < r * s then i mod s * r + i div s else r * s) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> i < r * s \<longrightarrow> Suc ((s - Suc 0) * r + i div s) div r = s - Suc 0
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc ((s - Suc 0) * r + i div s) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> Suc ((s - Suc 0) * r + i div s) div r = s - Suc 0
[PROOF STEP]
apply (subgoal_tac "Suc ((s - Suc 0) * r + i div s) div r =
                      ((s - Suc 0) * r + Suc (i div s)) div r",
       simp del: add_Suc add_Suc_right)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc ((s - Suc 0) * r + i div s) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> Suc ((s - Suc 0) * r + i div s) div r = ((s - Suc 0) * r + Suc (i div s)) div r
[PROOF STEP]
apply (subgoal_tac "Suc (i div s) < Suc (r - Suc 0)")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc ((s - Suc 0) * r + i div s) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0; i < r * s; Suc (i div s) < Suc (r - Suc 0)\<rbrakk> \<Longrightarrow> Suc ((s - Suc 0) * r + i div s) div r = ((s - Suc 0) * r + Suc (i div s)) div r
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; Suc ((s - Suc 0) * r + i div s) < r * s; i mod s = s - Suc 0; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> Suc (i div s) < Suc (r - Suc 0)
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma residue_primroot_modulus_mult_coprimeD:
  assumes "coprime m n" and "residue_primroot (m * n) g"
  shows   "residue_primroot m g" "residue_primroot n g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residue_primroot m g &&& residue_primroot n g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. residue_primroot m g
 2. residue_primroot n g
[PROOF STEP]
have *: "m > 0" "n > 0" "coprime m g" "coprime n g"
          "lcm (ord m g) (ord n g) = totient m * totient n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < m &&& 0 < n) &&& coprime m g &&& coprime n g &&& lcm (ord m g) (ord n g) = totient m * totient n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
coprime m n
residue_primroot (m * n) g

goal (1 subgoal):
 1. (0 < m &&& 0 < n) &&& coprime m g &&& coprime n g &&& lcm (ord m g) (ord n g) = totient m * totient n
[PROOF STEP]
by (auto simp: residue_primroot_def ord_modulus_mult_coprime totient_mult_coprime)
[PROOF STATE]
proof (state)
this:
0 < m
0 < n
coprime m g
coprime n g
lcm (ord m g) (ord n g) = totient m * totient n

goal (2 subgoals):
 1. residue_primroot m g
 2. residue_primroot n g
[PROOF STEP]
define a b where "a = totient m div ord m g" and "b = totient n div ord n g"
[PROOF STATE]
proof (state)
this:
a = totient m div ord m g
b = totient n div ord n g

goal (2 subgoals):
 1. residue_primroot m g
 2. residue_primroot n g
[PROOF STEP]
have ab: "totient m = ord m g * a" "totient n = ord n g * b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totient m = ord m g * a &&& totient n = ord n g * b
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
0 < m
0 < n
coprime m g
coprime n g
lcm (ord m g) (ord n g) = totient m * totient n

goal (1 subgoal):
 1. totient m = ord m g * a &&& totient n = ord n g * b
[PROOF STEP]
by (auto simp: a_def b_def order_divides_totient)
[PROOF STATE]
proof (state)
this:
totient m = ord m g * a
totient n = ord n g * b

goal (2 subgoals):
 1. residue_primroot m g
 2. residue_primroot n g
[PROOF STEP]
have "a = 1" "b = 1" "coprime (ord m g) (ord n g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = 1 &&& b = 1 &&& coprime (ord m g) (ord n g)
[PROOF STEP]
unfolding coprime_iff_gcd_eq_1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = 1 &&& b = 1 &&& gcd (ord m g) (ord n g) = 1
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
0 < m
0 < n
coprime m g
coprime n g
lcm (ord m g) (ord n g) = totient m * totient n

goal (1 subgoal):
 1. a = 1 &&& b = 1 &&& gcd (ord m g) (ord n g) = 1
[PROOF STEP]
by (auto simp: ab lcm_nat_def dvd_div_eq_mult ord_eq_0)
[PROOF STATE]
proof (state)
this:
a = 1
b = 1
coprime (ord m g) (ord n g)

goal (2 subgoals):
 1. residue_primroot m g
 2. residue_primroot n g
[PROOF STEP]
with ab and *
[PROOF STATE]
proof (chain)
picking this:
totient m = ord m g * a
totient n = ord n g * b
0 < m
0 < n
coprime m g
coprime n g
lcm (ord m g) (ord n g) = totient m * totient n
a = 1
b = 1
coprime (ord m g) (ord n g)
[PROOF STEP]
show "residue_primroot m g" "residue_primroot n g"
[PROOF STATE]
proof (prove)
using this:
totient m = ord m g * a
totient n = ord n g * b
0 < m
0 < n
coprime m g
coprime n g
lcm (ord m g) (ord n g) = totient m * totient n
a = 1
b = 1
coprime (ord m g) (ord n g)

goal (1 subgoal):
 1. residue_primroot m g &&& residue_primroot n g
[PROOF STEP]
by (auto simp: residue_primroot_def)
[PROOF STATE]
proof (state)
this:
residue_primroot m g
residue_primroot n g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bw_diff_minus_pow [simp]:
  "(bw_diff ^^ k) (\<lambda>x. f x - g x) = (\<lambda>x. (bw_diff ^^ k) f x - (bw_diff ^^ k) g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (bw_diff ^^ k) (\<lambda>x. f x - g x) = (\<lambda>x. (bw_diff ^^ k) f x - (bw_diff ^^ k) g x)
[PROOF STEP]
by (induct k, simp_all)


[STATEMENT]
lemma ex_is_arg_min_on_if_finite: fixes f :: "'a \<Rightarrow> 'b :: linorder"
shows "\<lbrakk> finite S; S \<noteq> {} \<rbrakk> \<Longrightarrow> \<exists>x. is_arg_min_on f S x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x. is_arg_min_on f S x
[PROOF STEP]
unfolding is_arg_min_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x. x \<in> S \<and> (\<forall>y\<in>S. f x \<le> f y)
[PROOF STEP]
using ex_min_if_finite[of "f ` S"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (f ` S); f ` S \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>m\<in>f ` S. \<not> (\<exists>x\<in>f ` S. x < m)

goal (1 subgoal):
 1. \<lbrakk>finite S; S \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x. x \<in> S \<and> (\<forall>y\<in>S. f x \<le> f y)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma regular_division_eqI:
  assumes K: "K = {a + (b-a)*(real k / n) .. a + (b-a)*((1 + real k) / n)}"
    and "a<b" "k < n"
  shows "K \<in> regular_division a b n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K \<in> regular_division a b n
[PROOF STEP]
unfolding regular_division_def segments_def image_comp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K \<in> ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) ` {..<n}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. K = ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) ?x
 2. ?x \<in> {..<n}
[PROOF STEP]
have "K = (\<lambda>x. (b-a) * x + a) ` {real k / real n..(1 + real k) / real n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K = (\<lambda>x. (b - a) * x + a) ` {real k / real n..(1 + real k) / real n}
[PROOF STEP]
using K \<open>a<b\<close>
[PROOF STATE]
proof (prove)
using this:
K = {a + (b - a) * (real k / real n)..a + (b - a) * ((1 + real k) / real n)}
a < b

goal (1 subgoal):
 1. K = (\<lambda>x. (b - a) * x + a) ` {real k / real n..(1 + real k) / real n}
[PROOF STEP]
by (simp add: image_affinity_atLeastAtMost divide_simps)
[PROOF STATE]
proof (state)
this:
K = (\<lambda>x. (b - a) * x + a) ` {real k / real n..(1 + real k) / real n}

goal (2 subgoals):
 1. K = ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) ?x
 2. ?x \<in> {..<n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
K = (\<lambda>x. (b - a) * x + a) ` {real k / real n..(1 + real k) / real n}
[PROOF STEP]
show "K = ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) k"
[PROOF STATE]
proof (prove)
using this:
K = (\<lambda>x. (b - a) * x + a) ` {real k / real n..(1 + real k) / real n}

goal (1 subgoal):
 1. K = ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) k
[PROOF STEP]
by (simp add: segment_def add.commute)
[PROOF STATE]
proof (state)
this:
K = ((`) ((+) a \<circ> (*) (b - a)) \<circ> segment n) k

goal (1 subgoal):
 1. k \<in> {..<n}
[PROOF STEP]
qed (use assms in auto)


[STATEMENT]
lemma Cn_inter: \<open>K = Cn(A) \<inter> Cn(B) \<Longrightarrow> K = Cn(K)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
fix K
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
assume h:\<open>K = Cn(A) \<inter> Cn(B)\<close>
[PROOF STATE]
proof (state)
this:
K = Cn A \<inter> Cn B

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
from h
[PROOF STATE]
proof (chain)
picking this:
K = Cn A \<inter> Cn B
[PROOF STEP]
have \<open>K \<subseteq> Cn(A)\<close> and \<open>K \<subseteq> Cn(B)\<close>
[PROOF STATE]
proof (prove)
using this:
K = Cn A \<inter> Cn B

goal (1 subgoal):
 1. K \<subseteq> Cn A &&& K \<subseteq> Cn B
[PROOF STEP]
by simp+
[PROOF STATE]
proof (state)
this:
K \<subseteq> Cn A
K \<subseteq> Cn B

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
hence \<open>Cn(K) \<subseteq> Cn(A)\<close> and \<open>Cn(K) \<subseteq> Cn(B)\<close>
[PROOF STATE]
proof (prove)
using this:
K \<subseteq> Cn A
K \<subseteq> Cn B

goal (1 subgoal):
 1. Cn K \<subseteq> Cn A &&& Cn K \<subseteq> Cn B
[PROOF STEP]
using idempotency_L monotonicity_L
[PROOF STATE]
proof (prove)
using this:
K \<subseteq> Cn A
K \<subseteq> Cn B
Cn (Cn ?A) = Cn ?A
?A \<subseteq> ?B \<Longrightarrow> Cn ?A \<subseteq> Cn ?B

goal (1 subgoal):
 1. Cn K \<subseteq> Cn A &&& Cn K \<subseteq> Cn B
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
Cn K \<subseteq> Cn A
Cn K \<subseteq> Cn B

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
hence \<open>Cn(K) \<subseteq> Cn(A) \<inter> Cn(B)\<close>
[PROOF STATE]
proof (prove)
using this:
Cn K \<subseteq> Cn A
Cn K \<subseteq> Cn B

goal (1 subgoal):
 1. Cn K \<subseteq> Cn A \<inter> Cn B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Cn K \<subseteq> Cn A \<inter> Cn B

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
with h
[PROOF STATE]
proof (chain)
picking this:
K = Cn A \<inter> Cn B
Cn K \<subseteq> Cn A \<inter> Cn B
[PROOF STEP]
have \<open>K = Cn(K)\<close>
[PROOF STATE]
proof (prove)
using this:
K = Cn A \<inter> Cn B
Cn K \<subseteq> Cn A \<inter> Cn B

goal (1 subgoal):
 1. K = Cn K
[PROOF STEP]
by (simp add: inclusion_L subset_antisym)
[PROOF STATE]
proof (state)
this:
K = Cn K

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?Ka2 = Cn A \<inter> Cn B \<Longrightarrow> ?Ka2 = Cn ?Ka2

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
thus \<open>K = Cn(A) \<inter> Cn(B) \<Longrightarrow> K = Cn(K)\<close>
[PROOF STATE]
proof (prove)
using this:
?Ka2 = Cn A \<inter> Cn B \<Longrightarrow> ?Ka2 = Cn ?Ka2

goal (1 subgoal):
 1. K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
K = Cn A \<inter> Cn B \<Longrightarrow> K = Cn K

goal:
No subgoals!
[PROOF STEP]
qed

\<comment> \<open>
An infinite intersection of closures is closed.
\<close>


[STATEMENT]
lemma gcard_eq_card:
  assumes "finite X" shows "gcard X = ord_of_nat (card X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcard X = ord_of_nat (card X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcard X = ord_of_nat (card X)
[PROOF STEP]
have "\<And>y. Ord y \<and> elts y \<approx> X \<Longrightarrow> ord_of_nat (card X) \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. Ord y \<and> elts y \<approx> X \<Longrightarrow> ord_of_nat (card X) \<le> y
[PROOF STEP]
by (metis assms eqpoll_finite_iff eqpoll_iff_card order_le_less ordertype_VWF_finite_nat ordertype_eq_Ord)
[PROOF STATE]
proof (state)
this:
Ord ?y \<and> elts ?y \<approx> X \<Longrightarrow> ord_of_nat (card X) \<le> ?y

goal (1 subgoal):
 1. gcard X = ord_of_nat (card X)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Ord ?y \<and> elts ?y \<approx> X \<Longrightarrow> ord_of_nat (card X) \<le> ?y
[PROOF STEP]
have "(LEAST i. Ord i \<and> elts i \<approx> X) = ord_of_nat (card X)"
[PROOF STATE]
proof (prove)
using this:
Ord ?y \<and> elts ?y \<approx> X \<Longrightarrow> ord_of_nat (card X) \<le> ?y

goal (1 subgoal):
 1. (LEAST i. Ord i \<and> elts i \<approx> X) = ord_of_nat (card X)
[PROOF STEP]
by (simp add: assms eqpoll_iff_card finite_Ord_omega Least_equality)
[PROOF STATE]
proof (state)
this:
(LEAST i. Ord i \<and> elts i \<approx> X) = ord_of_nat (card X)

goal (1 subgoal):
 1. gcard X = ord_of_nat (card X)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
finite X
(LEAST i. Ord i \<and> elts i \<approx> X) = ord_of_nat (card X)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite X
(LEAST i. Ord i \<and> elts i \<approx> X) = ord_of_nat (card X)

goal (1 subgoal):
 1. gcard X = ord_of_nat (card X)
[PROOF STEP]
by (simp add: finite_imp_small gcard_def)
[PROOF STATE]
proof (state)
this:
gcard X = ord_of_nat (card X)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma count_list_full_elem: "count_list xs y = length xs \<longleftrightarrow> (\<forall>x \<in> set xs. x = y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y)
[PROOF STEP]
proof(induct xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (count_list [] y = length []) = (\<forall>x\<in>set []. x = y)
 2. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (count_list [] y = length []) = (\<forall>x\<in>set []. x = y)
 2. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (count_list [] y = length []) = (\<forall>x\<in>set []. x = y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(count_list [] y = length []) = (\<forall>x\<in>set []. x = y)

goal (1 subgoal):
 1. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
case (Cons z xs)
[PROOF STATE]
proof (state)
this:
(count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y)

goal (1 subgoal):
 1. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
have "\<lbrakk>count_list xs y = Suc (length xs); x \<in> set xs\<rbrakk> \<Longrightarrow> x = y" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>count_list xs y = Suc (length xs); x \<in> set xs\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
by (metis Suc_n_not_le_n count_le_length)
[PROOF STATE]
proof (state)
this:
\<lbrakk>count_list xs y = Suc (length xs); ?x \<in> set xs\<rbrakk> \<Longrightarrow> ?x = y

goal (1 subgoal):
 1. \<And>a xs. (count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y) \<Longrightarrow> (count_list (a # xs) y = length (a # xs)) = (\<forall>x\<in>set (a # xs). x = y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>count_list xs y = Suc (length xs); ?x \<in> set xs\<rbrakk> \<Longrightarrow> ?x = y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>count_list xs y = Suc (length xs); ?x \<in> set xs\<rbrakk> \<Longrightarrow> ?x = y

goal (1 subgoal):
 1. (count_list (z # xs) y = length (z # xs)) = (\<forall>x\<in>set (z # xs). x = y)
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>count_list xs y = Suc (length xs); ?x \<in> set xs\<rbrakk> \<Longrightarrow> ?x = y
(count_list xs y = length xs) = (\<forall>x\<in>set xs. x = y)

goal (1 subgoal):
 1. (count_list (z # xs) y = length (z # xs)) = (\<forall>x\<in>set (z # xs). x = y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(count_list (z # xs) y = length (z # xs)) = (\<forall>x\<in>set (z # xs). x = y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma left_null_space_subset_span_basis:
fixes A::"'a::{field}^'cols::{mod_type}^'rows::{mod_type}"
shows  "left_null_space A \<subseteq> vec.span (basis_left_null_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. left_null_space A \<subseteq> vec.span (basis_left_null_space A)
[PROOF STEP]
proof (rule vec.card_ge_dim_independent)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. basis_left_null_space A \<subseteq> left_null_space A
 2. vec.independent (basis_left_null_space A)
 3. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
show "basis_left_null_space A \<subseteq> left_null_space A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_left_null_space A \<subseteq> left_null_space A
[PROOF STEP]
by (rule basis_left_null_space_in_left_null_space)
[PROOF STATE]
proof (state)
this:
basis_left_null_space A \<subseteq> left_null_space A

goal (2 subgoals):
 1. vec.independent (basis_left_null_space A)
 2. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
show "vec.independent (basis_left_null_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.independent (basis_left_null_space A)
[PROOF STEP]
by (rule independent_basis_left_null_space)
[PROOF STATE]
proof (state)
this:
vec.independent (basis_left_null_space A)

goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
show "vec.dim (left_null_space A) \<le> card (basis_left_null_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
have "{x. x v* A = 0} = {x. (transpose A) *v x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. x v* A = 0} = {x. Finite_Cartesian_Product.transpose A *v x = 0}
[PROOF STEP]
by (metis transpose_vector)
[PROOF STATE]
proof (state)
this:
{x. x v* A = 0} = {x. Finite_Cartesian_Product.transpose A *v x = 0}

goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{x. x v* A = 0} = {x. Finite_Cartesian_Product.transpose A *v x = 0}

goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
using card_basis_left_null_space_eq_dim
[PROOF STATE]
proof (prove)
using this:
{x. x v* A = 0} = {x. Finite_Cartesian_Product.transpose A *v x = 0}
card (basis_left_null_space ?A) = vec.dim (left_null_space ?A)

goal (1 subgoal):
 1. vec.dim (left_null_space A) \<le> card (basis_left_null_space A)
[PROOF STEP]
by (metis order_refl)
[PROOF STATE]
proof (state)
this:
vec.dim (left_null_space A) \<le> card (basis_left_null_space A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
vec.dim (left_null_space A) \<le> card (basis_left_null_space A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma p_mono: "x \<le> y \<Longrightarrow> y \<le> t_stop \<Longrightarrow> p x \<le> p y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
using decel
[PROOF STATE]
proof (prove)
using this:
a < 0

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
assume "x \<le> y" and "y \<le> t_stop" and "a < 0"
[PROOF STATE]
proof (state)
this:
x \<le> y
y \<le> t_stop
a < 0

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
hence "x + y \<le> - 2 * v / a"
[PROOF STATE]
proof (prove)
using this:
x \<le> y
y \<le> t_stop
a < 0

goal (1 subgoal):
 1. x + y \<le> - 2 * v / a
[PROOF STEP]
unfolding t_stop_def
[PROOF STATE]
proof (prove)
using this:
x \<le> y
y \<le> - v / a
a < 0

goal (1 subgoal):
 1. x + y \<le> - 2 * v / a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x + y \<le> - 2 * v / a

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
hence "-1 / 2 * a * (x + y) \<le> v" (is "?lhs0 \<le> ?rhs0")
[PROOF STATE]
proof (prove)
using this:
x + y \<le> - 2 * v / a

goal (1 subgoal):
 1. - 1 / 2 * a * (x + y) \<le> v
[PROOF STEP]
using \<open>a < 0\<close>
[PROOF STATE]
proof (prove)
using this:
x + y \<le> - 2 * v / a
a < 0

goal (1 subgoal):
 1. - 1 / 2 * a * (x + y) \<le> v
[PROOF STEP]
by (auto simp add: field_simps)
[PROOF STATE]
proof (state)
this:
- 1 / 2 * a * (x + y) \<le> v

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
hence "?lhs0 * (x- y) \<ge> ?rhs0 * (x - y)"
[PROOF STATE]
proof (prove)
using this:
- 1 / 2 * a * (x + y) \<le> v

goal (1 subgoal):
 1. v * (x - y) \<le> - 1 / 2 * a * (x + y) * (x - y)
[PROOF STEP]
using \<open>x \<le> y\<close>
[PROOF STATE]
proof (prove)
using this:
- 1 / 2 * a * (x + y) \<le> v
x \<le> y

goal (1 subgoal):
 1. v * (x - y) \<le> - 1 / 2 * a * (x + y) * (x - y)
[PROOF STEP]
by sos
[PROOF STATE]
proof (state)
this:
v * (x - y) \<le> - 1 / 2 * a * (x + y) * (x - y)

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
hence "v * x + 1 / 2 * a * x\<^sup>2 \<le> v * y + 1 / 2 * a * y\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
v * (x - y) \<le> - 1 / 2 * a * (x + y) * (x - y)

goal (1 subgoal):
 1. v * x + 1 / 2 * a * x\<^sup>2 \<le> v * y + 1 / 2 * a * y\<^sup>2
[PROOF STEP]
by (auto simp add: field_simps power_def)
[PROOF STATE]
proof (state)
this:
v * x + 1 / 2 * a * x\<^sup>2 \<le> v * y + 1 / 2 * a * y\<^sup>2

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; y \<le> t_stop; a < 0\<rbrakk> \<Longrightarrow> p x \<le> p y
[PROOF STEP]
thus " p x \<le> p y"
[PROOF STATE]
proof (prove)
using this:
v * x + 1 / 2 * a * x\<^sup>2 \<le> v * y + 1 / 2 * a * y\<^sup>2

goal (1 subgoal):
 1. p x \<le> p y
[PROOF STEP]
unfolding p_max_def p_def t_stop_def
[PROOF STATE]
proof (prove)
using this:
v * x + 1 / 2 * a * x\<^sup>2 \<le> v * y + 1 / 2 * a * y\<^sup>2

goal (1 subgoal):
 1. s0 + v * x + 1 / 2 * a * x\<^sup>2 \<le> s0 + v * y + 1 / 2 * a * y\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p x \<le> p y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gauss_int_norm_eq_0_iff [simp]: "gauss_int_norm z = 0 \<longleftrightarrow> z = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (gauss_int_norm z = 0) = (z = 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
assume "gauss_int_norm z = 0"
[PROOF STATE]
proof (state)
this:
gauss_int_norm z = 0

goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
hence "ReZ z ^ 2 + ImZ z ^ 2 \<le> 0"
[PROOF STATE]
proof (prove)
using this:
gauss_int_norm z = 0

goal (1 subgoal):
 1. (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 \<le> 0
[PROOF STEP]
by (simp add: gauss_int_norm_def)
[PROOF STATE]
proof (state)
this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 \<le> 0

goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 \<le> 0

goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
have "ReZ z ^ 2 + ImZ z ^ 2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2

goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 \<le> 0
0 \<le> (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2
[PROOF STEP]
have "ReZ z ^ 2 + ImZ z ^ 2 = 0"
[PROOF STATE]
proof (prove)
using this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 \<le> 0
0 \<le> (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2

goal (1 subgoal):
 1. (ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 = 0
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 = 0

goal (2 subgoals):
 1. gauss_int_norm z = 0 \<Longrightarrow> z = 0
 2. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
thus "z = 0"
[PROOF STATE]
proof (prove)
using this:
(ReZ z)\<^sup>2 + (ImZ z)\<^sup>2 = 0

goal (1 subgoal):
 1. z = 0
[PROOF STEP]
by (auto simp: gauss_int_eq_iff)
[PROOF STATE]
proof (state)
this:
z = 0

goal (1 subgoal):
 1. z = 0 \<Longrightarrow> gauss_int_norm z = 0
[PROOF STEP]
qed auto


[STATEMENT]
lemma monom_deg_mult:
  assumes f_in_P: "f \<in> carrier P" and g_in_P: "g \<in> carrier P" and deg_le: "deg R g \<le> deg R f"
  and a_in_R: "a \<in> carrier R"
  shows "deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
using deg_mult_ring [OF g_in_P monom_closed [OF a_in_R, of "deg R f - deg R g"]]
[PROOF STATE]
proof (prove)
using this:
deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g))

goal (1 subgoal):
 1. deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
apply (cases "a = \<zero>")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a = \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
 2. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
using g_in_P
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier P

goal (2 subgoals):
 1. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a = \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
 2. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
using deg_monom [OF _ a_in_R, of "deg R f - deg R g"]
[PROOF STATE]
proof (prove)
using this:
a \<noteq> \<zero> \<Longrightarrow> deg R (monom P a (deg R f - deg R g)) = deg R f - deg R g

goal (1 subgoal):
 1. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
using deg_le
[PROOF STATE]
proof (prove)
using this:
a \<noteq> \<zero> \<Longrightarrow> deg R (monom P a (deg R f - deg R g)) = deg R f - deg R g
deg R g \<le> deg R f

goal (1 subgoal):
 1. \<lbrakk>deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R g + deg R (monom P a (deg R f - deg R g)); a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> deg R (g \<otimes>\<^bsub>P\<^esub> monom P a (deg R f - deg R g)) \<le> deg R f
[PROOF STEP]
by simp


[STATEMENT]
lemma cmod_power2: "(cmod z)\<^sup>2 = (Re z)\<^sup>2 + (Im z)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod z)\<^sup>2 = (Re z)\<^sup>2 + (Im z)\<^sup>2
[PROOF STEP]
by (simp add: norm_complex_def)


[STATEMENT]
lemma Pow_subset_Pow: "Pow a \<subseteq> Pow b = (a \<subseteq> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Pow a \<subseteq> Pow b) = (a \<subseteq> b)
[PROOF STEP]
by blast


[STATEMENT]
lemma hull_Un_subset: "(S hull s) \<union> (S hull t) \<subseteq> (S hull (s \<union> t))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S hull s \<union> S hull t \<subseteq> S hull (s \<union> t)
[PROOF STEP]
unfolding Un_subset_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S hull s \<subseteq> S hull (s \<union> t) \<and> S hull t \<subseteq> S hull (s \<union> t)
[PROOF STEP]
by (metis hull_mono Un_upper1 Un_upper2)


[STATEMENT]
lemma fls_deriv_X_inv_power:
  "fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
n = Suc m

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
define iX :: "'a fls" where "iX \<equiv> fls_X_inv"
[PROOF STATE]
proof (state)
this:
iX \<equiv> fls_X_inv

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
have "fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ (Suc (Suc m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)
[PROOF STEP]
proof (induct m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fls_deriv (iX ^ Suc 0) = - of_nat (Suc 0) * iX ^ Suc (Suc 0)
 2. \<And>m. fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m) \<Longrightarrow> fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)

goal (2 subgoals):
 1. fls_deriv (iX ^ Suc 0) = - of_nat (Suc 0) * iX ^ Suc (Suc 0)
 2. \<And>m. fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m) \<Longrightarrow> fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))
[PROOF STEP]
have "- of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) =
            iX * (-of_nat (Suc m) * iX ^ Suc (Suc m)) +
                  - (iX ^ 2 * iX ^ Suc m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) = iX * (- of_nat (Suc m) * iX ^ Suc (Suc m)) + - (iX\<^sup>2 * iX ^ Suc m)
[PROOF STEP]
using distrib_right[of "-of_nat (Suc m)" "-(1::'a fls)" "fls_X_inv ^ Suc (Suc (Suc m))"]
[PROOF STATE]
proof (prove)
using this:
(- of_nat (Suc m) + - 1) * fls_X_inv ^ Suc (Suc (Suc m)) = - of_nat (Suc m) * fls_X_inv ^ Suc (Suc (Suc m)) + - 1 * fls_X_inv ^ Suc (Suc (Suc m))

goal (1 subgoal):
 1. - of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) = iX * (- of_nat (Suc m) * iX ^ Suc (Suc m)) + - (iX\<^sup>2 * iX ^ Suc m)
[PROOF STEP]
by (simp add: algebra_simps mult_of_nat_commute power2_eq_square Suc iX_def)
[PROOF STATE]
proof (state)
this:
- of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) = iX * (- of_nat (Suc m) * iX ^ Suc (Suc m)) + - (iX\<^sup>2 * iX ^ Suc m)

goal (2 subgoals):
 1. fls_deriv (iX ^ Suc 0) = - of_nat (Suc 0) * iX ^ Suc (Suc 0)
 2. \<And>m. fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m) \<Longrightarrow> fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
- of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) = iX * (- of_nat (Suc m) * iX ^ Suc (Suc m)) + - (iX\<^sup>2 * iX ^ Suc m)

goal (1 subgoal):
 1. fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
- of_nat (Suc m + 1) * iX ^ Suc (Suc (Suc m)) = iX * (- of_nat (Suc m) * iX ^ Suc (Suc m)) + - (iX\<^sup>2 * iX ^ Suc m)
fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)

goal (1 subgoal):
 1. fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))
[PROOF STEP]
by (simp add: iX_def)
[PROOF STATE]
proof (state)
this:
fls_deriv (iX ^ Suc (Suc m)) = - of_nat (Suc (Suc m)) * iX ^ Suc (Suc (Suc m))

goal (1 subgoal):
 1. fls_deriv (iX ^ Suc 0) = - of_nat (Suc 0) * iX ^ Suc (Suc 0)
[PROOF STEP]
qed (simp add: numeral_2_eq_2 iX_def)
[PROOF STATE]
proof (state)
this:
fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
 2. \<And>nat. n = Suc nat \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
with Suc
[PROOF STATE]
proof (chain)
picking this:
n = Suc m
fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = Suc m
fls_deriv (iX ^ Suc m) = - of_nat (Suc m) * iX ^ Suc (Suc m)

goal (1 subgoal):
 1. fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
by (simp add: iX_def)
[PROOF STATE]
proof (state)
this:
fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> fls_deriv (fls_X_inv ^ n) = - of_nat n * fls_X_inv ^ Suc n
[PROOF STEP]
qed simp


[STATEMENT]
lemma F_eq: "F = {x. \<exists>y \<in> A. (x = p - ((y * a) mod p) \<and> (int p - 1) div 2 < (y * a) mod p)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F = {x. \<exists>y\<in>A. x = int p - y * a mod int p \<and> (int p - 1) div 2 < y * a mod int p}
[PROOF STEP]
by (auto simp add: F_def E_def D_def C_def B_def A_def)


[STATEMENT]
lemma card_cartesian_product3: "card (X \<times> Y \<times> Z) = card X * card Y * card Z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (X \<times> Y \<times> Z) = card X * card Y * card Z
[PROOF STEP]
using card_cartesian_product
[PROOF STATE]
proof (prove)
using this:
card (?A \<times> ?B) = card ?A * card ?B

goal (1 subgoal):
 1. card (X \<times> Y \<times> Z) = card X * card Y * card Z
[PROOF STEP]
by (metis mult.commute mult.left_commute)


[STATEMENT]
lemma (in prob_space) sum_measure_le_measure_inter3:
  assumes [measurable]: "A \<in> sets M" "B \<in> sets M" "C \<in> sets M"
  shows "prob A + prob B + prob C \<le> 2 + prob (A \<inter> B \<inter> C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob A + prob B + prob C \<le> 2 + prob (A \<inter> B \<inter> C)
[PROOF STEP]
using sum_measure_le_measure_inter[of B C] sum_measure_le_measure_inter[of A "B \<inter> C"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>B \<in> events; C \<in> events\<rbrakk> \<Longrightarrow> prob B + prob C \<le> 1 + prob (B \<inter> C)
\<lbrakk>A \<in> events; B \<inter> C \<in> events\<rbrakk> \<Longrightarrow> prob A + prob (B \<inter> C) \<le> 1 + prob (A \<inter> (B \<inter> C))

goal (1 subgoal):
 1. prob A + prob B + prob C \<le> 2 + prob (A \<inter> B \<inter> C)
[PROOF STEP]
by (auto simp add: inf_assoc)


[STATEMENT]
lemma distinct_mset_count_less_1: "distinct_mset S \<longleftrightarrow> (\<forall>a. count S a \<le> 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct_mset S = (\<forall>a. count S a \<le> 1)
[PROOF STEP]
using eq_iff nat_le_linear
[PROOF STATE]
proof (prove)
using this:
(?a = ?b) = (?a \<le> ?b \<and> ?b \<le> ?a)
?m \<le> ?n \<or> ?n \<le> ?m

goal (1 subgoal):
 1. distinct_mset S = (\<forall>a. count S a \<le> 1)
[PROOF STEP]
unfolding distinct_mset_def
[PROOF STATE]
proof (prove)
using this:
(?a = ?b) = (?a \<le> ?b \<and> ?b \<le> ?a)
?m \<le> ?n \<or> ?n \<le> ?m

goal (1 subgoal):
 1. (\<forall>a. a \<in># S \<longrightarrow> count S a = 1) = (\<forall>a. count S a \<le> 1)
[PROOF STEP]
by fastforce


[STATEMENT]
theorem exp_cf4_lower_bound_pos: "0\<le>x \<Longrightarrow> exp_cf4 x \<le> exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> exp_cf4 x \<le> exp x
[PROOF STEP]
by (metis exp_cf4_pos exp_le_cancel_iff exp_ln ln_exp_cf4_lower_bound_pos)


[STATEMENT]
lemma is_unit_Jacobi_aux: "is_unit x \<Longrightarrow> Jacobi a x = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_unit x \<Longrightarrow> Jacobi a x = 1
[PROOF STEP]
unfolding Jacobi_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_unit x \<Longrightarrow> (if x = 0 then 0 else \<Prod>\<^sub># (image_mset (Legendre a) (prime_factorization x))) = 1
[PROOF STEP]
using prime_factorization_empty_iff[of x]
[PROOF STATE]
proof (prove)
using this:
(prime_factorization x = {#}) = (x = 0 \<or> is_unit x)

goal (1 subgoal):
 1. is_unit x \<Longrightarrow> (if x = 0 then 0 else \<Prod>\<^sub># (image_mset (Legendre a) (prime_factorization x))) = 1
[PROOF STEP]
by auto


[STATEMENT]
lemma MSB_mono: "set I1 \<subseteq> set I2 \<Longrightarrow> MSB I1 \<le> MSB I2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set I1 \<subseteq> set I2 \<Longrightarrow> MSB I1 \<le> MSB I2
[PROOF STEP]
unfolding MSB_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set I1 \<subseteq> set I2 \<Longrightarrow> (if \<forall>P\<in>set I1. P = {||} then 0 else Suc (Max (\<Union> (fset ` set I1)))) \<le> (if \<forall>P\<in>set I2. P = {||} then 0 else Suc (Max (\<Union> (fset ` set I2))))
[PROOF STEP]
including fset.lifting
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set I1 \<subseteq> set I2 \<Longrightarrow> (if \<forall>P\<in>set I1. P = {||} then 0 else Suc (Max (\<Union> (fset ` set I1)))) \<le> (if \<forall>P\<in>set I2. P = {||} then 0 else Suc (Max (\<Union> (fset ` set I2))))
[PROOF STEP]
by transfer (auto simp: list_all_iff intro!: Max_ge)


[STATEMENT]
lemma norm_real: "norm(x::real ^ 1) = \<bar>x$1\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm x = \<bar>x $ 1\<bar>
[PROOF STEP]
by (simp add: norm_vector_1)


[STATEMENT]
lemma OpCatOpCat: "Op (Op C) = C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Op Op C = C
[PROOF STEP]
by (simp add: OppositeCategory_def)


[STATEMENT]
theorem exp_cf7_upper_bound_pos: "0 \<le> x \<Longrightarrow> numer_cf7 (-x) > 0 \<Longrightarrow> exp x \<le> exp_cf7 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; 0 < numer_cf7 (- x)\<rbrakk> \<Longrightarrow> exp x \<le> exp_cf7 x
[PROOF STEP]
using ln_exp_cf7_upper_bound_nonneg [of x] exp_cf7_pos [of x] numer_cf7_pos [of x]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> x; 0 < numer_cf7 (- x)\<rbrakk> \<Longrightarrow> x \<le> ln (exp_cf7 x)
\<lbrakk>0 < numer_cf7 x; 0 < numer_cf7 (- x)\<rbrakk> \<Longrightarrow> 0 < exp_cf7 x
- (9943 / 10 ^ 3) \<le> x \<Longrightarrow> 0 < numer_cf7 x

goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; 0 < numer_cf7 (- x)\<rbrakk> \<Longrightarrow> exp x \<le> exp_cf7 x
[PROOF STEP]
by auto (metis exp_le_cancel_iff exp_ln_iff)


[STATEMENT]
lemma Least_le_imp_le: "
  \<lbrakk> \<exists>x. P x; \<exists>x. Q x; \<And>x y. \<lbrakk> P x; Q y \<rbrakk> \<Longrightarrow> x \<le> y \<rbrakk> \<Longrightarrow>
  (LEAST (x::'a::wellorder). P x) \<le> (LEAST (x::'a::wellorder). Q x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>x. P x; \<exists>x. Q x; \<And>x y. \<lbrakk>P x; Q y\<rbrakk> \<Longrightarrow> x \<le> y\<rbrakk> \<Longrightarrow> (LEAST x. P x) \<le> (LEAST x. Q x)
[PROOF STEP]
by (blast intro: LeastI)


[STATEMENT]
lemma infsum_mono2:
  fixes f :: "'a \<Rightarrow> 'b::{topological_ab_group_add, ordered_comm_monoid_add,linorder_topology}"
  assumes "f summable_on A" "f summable_on B" "A \<subseteq> B"
  assumes "\<And>x. x \<in> B - A \<Longrightarrow> f x \<ge> 0"
  shows   "infsum f A \<le> infsum f B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f A \<le> infsum f B
[PROOF STEP]
by (rule has_sum_mono2[OF has_sum_infsum has_sum_infsum]) (use assms in auto)


[STATEMENT]
lemma polyexp_fps_Cons:
  "polyexp_fps (x#xs) = (case x of (a,k,b) \<Rightarrow>
     fps_of_poly (Polynomial.smult a (fps_monom_poly b k)) / (1 - fps_const b * fps_X) ^ (k + 1)) +
     polyexp_fps xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polyexp_fps (x # xs) = (case x of (a, k, b) \<Rightarrow> fps_of_poly (smult a (fps_monom_poly b k)) / (1 - fps_const b * fps_X) ^ (k + 1)) + polyexp_fps xs
[PROOF STEP]
by (simp add: polyexp_fps_def)


[STATEMENT]
lemma sum_basis_eq:
  fixes X::"'a::{field}^'n^'n"
  assumes is_basis:"is_basis  (set_of_vector X)"
  shows "sum (\<lambda>x. f x *s x) (set_of_vector X) = sum (\<lambda>i. f (X$i) *s (X$i)) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
have card_set_of_vector:"card(set_of_vector X) = CARD('n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set_of_vector X) = CARD('n)
[PROOF STEP]
using independent_is_basis[of "set_of_vector X"]
[PROOF STATE]
proof (prove)
using this:
(vec.independent (set_of_vector X) \<and> card (set_of_vector X) = CARD('n)) = is_basis (set_of_vector X)

goal (1 subgoal):
 1. card (set_of_vector X) = CARD('n)
[PROOF STEP]
using is_basis
[PROOF STATE]
proof (prove)
using this:
(vec.independent (set_of_vector X) \<and> card (set_of_vector X) = CARD('n)) = is_basis (set_of_vector X)
is_basis (set_of_vector X)

goal (1 subgoal):
 1. card (set_of_vector X) = CARD('n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (set_of_vector X) = CARD('n)

goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
have fact_1: "set_of_vector X = range (($) X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of_vector X = range (($) X)
[PROOF STEP]
unfolding set_of_vector_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {X $ i |i. i \<in> UNIV} = range (($) X)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_of_vector X = range (($) X)

goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
have inj: "inj (($) X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj (($) X)
[PROOF STEP]
proof (rule eq_card_imp_inj_on)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite UNIV
 2. card (range (($) X)) = CARD('n)
[PROOF STEP]
show "finite (UNIV::'n set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite UNIV
[PROOF STEP]
using finite_class.finite_UNIV
[PROOF STATE]
proof (prove)
using this:
finite UNIV

goal (1 subgoal):
 1. finite UNIV
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
finite UNIV

goal (1 subgoal):
 1. card (range (($) X)) = CARD('n)
[PROOF STEP]
show "card (range (($) X)) = card (UNIV::'n set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (range (($) X)) = CARD('n)
[PROOF STEP]
using card_set_of_vector
[PROOF STATE]
proof (prove)
using this:
card (set_of_vector X) = CARD('n)

goal (1 subgoal):
 1. card (range (($) X)) = CARD('n)
[PROOF STEP]
using fact_1
[PROOF STATE]
proof (prove)
using this:
card (set_of_vector X) = CARD('n)
set_of_vector X = range (($) X)

goal (1 subgoal):
 1. card (range (($) X)) = CARD('n)
[PROOF STEP]
unfolding set_of_vector_def
[PROOF STATE]
proof (prove)
using this:
card {X $ i |i. i \<in> UNIV} = CARD('n)
{X $ i |i. i \<in> UNIV} = range (($) X)

goal (1 subgoal):
 1. card (range (($) X)) = CARD('n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (range (($) X)) = CARD('n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj (($) X)

goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
using sum.reindex[OF inj, of "(\<lambda>x. f x *s x)", unfolded o_def]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>range (($) X). f x *s x) = (\<Sum>x\<in>UNIV. f (X $ x) *s X $ x)

goal (1 subgoal):
 1. (\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
unfolding fact_1
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>range (($) X). f x *s x) = (\<Sum>x\<in>UNIV. f (X $ x) *s X $ x)

goal (1 subgoal):
 1. (\<Sum>x\<in>range (($) X). f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_of_vector X. f x *s x) = (\<Sum>i\<in>UNIV. f (X $ i) *s X $ i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hom_in_carr:
  assumes "f \<in> hom G H"
  shows "\<And>x. x \<in> carrier G \<Longrightarrow> f x \<in> carrier H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> carrier G \<Longrightarrow> f x \<in> carrier H
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> hom G H

goal (1 subgoal):
 1. \<And>x. x \<in> carrier G \<Longrightarrow> f x \<in> carrier H
[PROOF STEP]
unfolding hom_def bij_betw_def
[PROOF STATE]
proof (prove)
using this:
f \<in> {h \<in> carrier G \<rightarrow> carrier H. \<forall>x\<in>carrier G. \<forall>y\<in>carrier G. h (x \<otimes>\<^bsub>G\<^esub> y) = h x \<otimes>\<^bsub>H\<^esub> h y}

goal (1 subgoal):
 1. \<And>x. x \<in> carrier G \<Longrightarrow> f x \<in> carrier H
[PROOF STEP]
by blast


[STATEMENT]
lemma ah_update_mono2: "\<lbrakk>h \<le> h'; U\<subseteq>U'; M\<subseteq>M'\<rbrakk>
  \<Longrightarrow> ah_update h (E,U) M \<le> ah_update h' (E,U') M'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>h \<le> h'; U \<subseteq> U'; M \<subseteq> M'\<rbrakk> \<Longrightarrow> ah_update h (E, U) M \<le> ah_update h' (E, U') M'
[PROOF STEP]
by (auto simp add: ah_update_def le_fun_def [where 'b="'a set"])


[STATEMENT]
lemma matrix_to_iarray_fst_solve_system: "matrix_to_iarray (fst (solve_system A b)) = fst (solve_system_iarrays (matrix_to_iarray A) (vec_to_iarray b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (fst (solve_system A b)) = fst (solve_system_iarrays (matrix_to_iarray A) (vec_to_iarray b))
[PROOF STEP]
unfolding solve_system_def solve_system_iarrays_def Let_def fst_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_iarray (snd (Gauss_Jordan_PA A)) = snd (Gauss_Jordan_iarrays_PA (matrix_to_iarray A))
[PROOF STEP]
by (metis matrix_to_iarray_snd_Gauss_Jordan_PA)


[STATEMENT]
lemma vproduct_vdoubleton_iff:
  "f \<in>\<^sub>\<circ> (\<Prod>\<^sub>\<circ>i\<in>\<^sub>\<circ>set {a, b}. A i) \<longleftrightarrow>
    vsv f \<and>
    f\<lparr>a\<rparr> \<in>\<^sub>\<circ> A a \<and>
    f\<lparr>b\<rparr> \<in>\<^sub>\<circ> A b \<and>
    \<D>\<^sub>\<circ> f = set {a, b} \<and>
    f = set {\<langle>a, f\<lparr>a\<rparr>\<rangle>, \<langle>b, f\<lparr>b\<rparr>\<rangle>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in>\<^sub>\<circ> vproduct (set {a, b}) A) = (vsv f \<and> f\<lparr>a\<rparr> \<in>\<^sub>\<circ> A a \<and> f\<lparr>b\<rparr> \<in>\<^sub>\<circ> A b \<and> \<D>\<^sub>\<circ> f = set {a, b} \<and> f = set {\<langle>a, f\<lparr>a\<rparr>\<rangle>, \<langle>b, f\<lparr>b\<rparr>\<rangle>})
[PROOF STEP]
by (force elim!: vproduct_vdoubletonE)+


[STATEMENT]
lemma finite_t1_space_imp_discrete_topology:
   "\<lbrakk>topspace X = U; finite U; t1_space X\<rbrakk> \<Longrightarrow> X = discrete_topology U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>topspace X = U; finite U; t1_space X\<rbrakk> \<Longrightarrow> X = discrete_topology U
[PROOF STEP]
by (metis discrete_topology_unique_derived_set t1_space_derived_set_of_finite)


[STATEMENT]
lemma minus_one_power_iff: "(- (1::'a::ring_1)) ^ n = (if even n then 1 else - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- (1::'a)) ^ n = (if even n then 1::'a else - (1::'a))
[PROOF STEP]
by (induct n) auto


[STATEMENT]
lemma finite_count_ne: "finite {x. count M x \<noteq> count N x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
have "{x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N
[PROOF STEP]
by (auto simp: not_in_iff)
[PROOF STATE]
proof (state)
this:
{x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N

goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N

goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
have "finite (set_mset M \<union> set_mset N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (set_mset M \<union> set_mset N)
[PROOF STEP]
by (rule finite_UnI[OF finite_set_mset finite_set_mset])
[PROOF STATE]
proof (state)
this:
finite (set_mset M \<union> set_mset N)

goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N
finite (set_mset M \<union> set_mset N)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x. count M x \<noteq> count N x} \<subseteq> set_mset M \<union> set_mset N
finite (set_mset M \<union> set_mset N)

goal (1 subgoal):
 1. finite {x. count M x \<noteq> count N x}
[PROOF STEP]
by (rule finite_subset)
[PROOF STATE]
proof (state)
this:
finite {x. count M x \<noteq> count N x}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma right_zero [simp]:
  assumes [simp]: "a \<in> R" shows "a \<cdot> \<zero> = \<zero>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
have "a \<cdot> \<zero> = a \<cdot> (\<zero> + \<zero>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<cdot> \<zero> = a \<cdot> (\<zero> + \<zero>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<cdot> \<zero> = a \<cdot> (\<zero> + \<zero>)

goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a \<cdot> \<zero> = a \<cdot> (\<zero> + \<zero>)

goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
have "\<dots> = a \<cdot> \<zero> + a \<cdot> \<zero>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<cdot> (\<zero> + \<zero>) = a \<cdot> \<zero> + a \<cdot> \<zero>
[PROOF STEP]
by (simp add: distributive del: additive.left_unit additive.right_unit)
[PROOF STATE]
proof (state)
this:
a \<cdot> (\<zero> + \<zero>) = a \<cdot> \<zero> + a \<cdot> \<zero>

goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero>
[PROOF STEP]
have "a \<cdot> \<zero> - a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero> - a \<cdot> \<zero>"
[PROOF STATE]
proof (prove)
using this:
a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero>

goal (1 subgoal):
 1. a \<cdot> \<zero> - a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero> - a \<cdot> \<zero>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<cdot> \<zero> - a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero> - a \<cdot> \<zero>

goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<cdot> \<zero> - a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero> - a \<cdot> \<zero>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<cdot> \<zero> - a \<cdot> \<zero> = a \<cdot> \<zero> + a \<cdot> \<zero> - a \<cdot> \<zero>

goal (1 subgoal):
 1. a \<cdot> \<zero> = \<zero>
[PROOF STEP]
by (simp add: additive.associative del: additive.invertible_left_cancel)
[PROOF STATE]
proof (state)
this:
a \<cdot> \<zero> = \<zero>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma icard_empty[simp]: "icard {} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. icard {} = 0
[PROOF STEP]
by (simp add: icard_finite[OF finite.emptyI])


[STATEMENT]
lemma powreal_ex1_eq:
  assumes "a > 0"
  and "a \<noteq> 1"
  and "x > 0"
  shows "\<exists>! y. a pow\<^sub>\<real> y = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
proof (cases "a < 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
 2. \<not> a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a < 1

goal (2 subgoals):
 1. a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
 2. \<not> a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a < 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a < 1

goal (1 subgoal):
 1. \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
using assms powreal_inject powreal_surj2
[PROOF STATE]
proof (prove)
using this:
a < 1
0 < a
a \<noteq> 1
0 < x
\<lbrakk>0 < ?a; ?a \<noteq> 1\<rbrakk> \<Longrightarrow> (?a pow\<^sub>\<real> ?r = ?a pow\<^sub>\<real> ?s) = (?s = ?r)
\<lbrakk>0 < ?a; ?a < 1; 0 < ?x\<rbrakk> \<Longrightarrow> \<exists>y. ?a pow\<^sub>\<real> y = ?x

goal (1 subgoal):
 1. \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>!y. a pow\<^sub>\<real> y = x

goal (1 subgoal):
 1. \<not> a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> a < 1

goal (1 subgoal):
 1. \<not> a < 1 \<Longrightarrow> \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> a < 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> a < 1

goal (1 subgoal):
 1. \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
using assms(2) assms(3) powreal_surj
[PROOF STATE]
proof (prove)
using this:
\<not> a < 1
a \<noteq> 1
0 < x
\<lbrakk>1 < ?a; 0 < ?x\<rbrakk> \<Longrightarrow> \<exists>y. ?a pow\<^sub>\<real> y = ?x

goal (1 subgoal):
 1. \<exists>!y. a pow\<^sub>\<real> y = x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>!y. a pow\<^sub>\<real> y = x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iT_Plus_iAll_conv: "(\<box> t I \<oplus> k. P t) = (\<box> t I. P (t + k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<box> t I \<oplus> k. P t) = (\<box> t I. P (t + k))
[PROOF STEP]
apply (unfold iAll_def Ball_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x) = (\<forall>x. x \<in> I \<longrightarrow> P (x + k))
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x \<Longrightarrow> \<forall>x. x \<in> I \<longrightarrow> P (x + k)
 2. \<forall>x. x \<in> I \<longrightarrow> P (x + k) \<Longrightarrow> \<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x
[PROOF STEP]
apply (clarify, rename_tac x)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>\<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x; x \<in> I\<rbrakk> \<Longrightarrow> P (x + k)
 2. \<forall>x. x \<in> I \<longrightarrow> P (x + k) \<Longrightarrow> \<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x
[PROOF STEP]
apply (drule_tac x="x + k" in spec)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>x \<in> I; x + k \<in> I \<oplus> k \<longrightarrow> P (x + k)\<rbrakk> \<Longrightarrow> P (x + k)
 2. \<forall>x. x \<in> I \<longrightarrow> P (x + k) \<Longrightarrow> \<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x
[PROOF STEP]
apply (simp add: iT_Plus_mem_iff2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. x \<in> I \<longrightarrow> P (x + k) \<Longrightarrow> \<forall>x. x \<in> I \<oplus> k \<longrightarrow> P x
[PROOF STEP]
apply (clarify, rename_tac x)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. x \<in> I \<longrightarrow> P (x + k); x \<in> I \<oplus> k\<rbrakk> \<Longrightarrow> P x
[PROOF STEP]
apply (drule_tac x="x - k" in spec)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<in> I \<oplus> k; x - k \<in> I \<longrightarrow> P (x - k + k)\<rbrakk> \<Longrightarrow> P x
[PROOF STEP]
apply (simp add: iT_Plus_mem_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma vector_differentiable_bound_linearization:
  fixes f::"real \<Rightarrow> 'b::real_normed_vector"
  assumes f': "\<And>x. x \<in> S \<Longrightarrow> (f has_vector_derivative f' x) (at x within S)"
  assumes "closed_segment a b \<subseteq> S"
  assumes B: "\<And>x. x \<in> S \<Longrightarrow> norm (f' x - f' x0) \<le> B"
  assumes "x0 \<in> S"
  shows "norm (f b - f a - (b - a) *\<^sub>R f' x0) \<le> norm (b - a) * B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (f b - f a - (b - a) *\<^sub>R f' x0) \<le> norm (b - a) * B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?x \<in> S \<Longrightarrow> (f has_vector_derivative f' ?x) (at ?x within S)
closed_segment a b \<subseteq> S
?x \<in> S \<Longrightarrow> norm (f' ?x - f' x0) \<le> B
x0 \<in> S

goal (1 subgoal):
 1. norm (f b - f a - (b - a) *\<^sub>R f' x0) \<le> norm (b - a) * B
[PROOF STEP]
by (intro differentiable_bound_linearization[of a b S f "\<lambda>x h. h *\<^sub>R f' x" x0 B])
    (force simp: closed_segment_real_eq has_vector_derivative_def
      scaleR_diff_right[symmetric] mult.commute[of B]
      intro!: onorm_le mult_left_mono)+


[STATEMENT]
lemma bt_dfs_Min_priority:
  assumes "is_heap t"
  shows "priority t = Min (set (bt_dfs priority t))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. priority t = Min (set (bt_dfs priority t))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_heap_list (priority t) (children t)

goal (1 subgoal):
 1. priority t = Min (set (bt_dfs priority t))
[PROOF STEP]
proof (induct "priority t" "children t" arbitrary: t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. [] = children t \<Longrightarrow> priority t = Min (set (bt_dfs priority t))
 2. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
case is_heap_list_Nil
[PROOF STATE]
proof (state)
this:
[] = children t

goal (2 subgoals):
 1. \<And>t. [] = children t \<Longrightarrow> priority t = Min (set (bt_dfs priority t))
 2. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[] = children t
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[] = children t

goal (1 subgoal):
 1. priority t = Min (set (bt_dfs priority t))
[PROOF STEP]
by (simp add: bt_dfs_simp)
[PROOF STATE]
proof (state)
this:
priority t = Min (set (bt_dfs priority t))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
case (is_heap_list_Cons rs r t)
[PROOF STATE]
proof (state)
this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
note cons = this
[PROOF STATE]
proof (state)
this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
let ?M = "Min (set (bt_dfs priority t))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
obtain t' where "t' = Node (priority t) (val t) rs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t'. t' = Node (priority t) (val t) rs \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
t' = Node (priority t) (val t) rs

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
hence ot: "rs = children t'" "priority t' = priority t"
[PROOF STATE]
proof (prove)
using this:
t' = Node (priority t) (val t) rs

goal (1 subgoal):
 1. rs = children t' &&& priority t' = priority t
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
rs = children t'
priority t' = priority t

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
with is_heap_list_Cons
[PROOF STATE]
proof (chain)
picking this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t
rs = children t'
priority t' = priority t
[PROOF STEP]
have "priority t = Min (set (bt_dfs priority t'))"
[PROOF STATE]
proof (prove)
using this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t
rs = children t'
priority t' = priority t

goal (1 subgoal):
 1. priority t = Min (set (bt_dfs priority t'))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
priority t = Min (set (bt_dfs priority t'))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
with ot
[PROOF STATE]
proof (chain)
picking this:
rs = children t'
priority t' = priority t
priority t = Min (set (bt_dfs priority t'))
[PROOF STEP]
have "priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))"
[PROOF STATE]
proof (prove)
using this:
rs = children t'
priority t' = priority t
priority t = Min (set (bt_dfs priority t'))

goal (1 subgoal):
 1. priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))
[PROOF STEP]
by (simp add: bt_dfs_simp)
[PROOF STATE]
proof (state)
this:
priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
from cons
[PROOF STATE]
proof (chain)
picking this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t
[PROOF STEP]
have "priority r = Min (set (bt_dfs priority r))"
[PROOF STATE]
proof (prove)
using this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t

goal (1 subgoal):
 1. priority r = Min (set (bt_dfs priority r))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
priority r = Min (set (bt_dfs priority r))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
priority r = Min (set (bt_dfs priority r))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
from cons
[PROOF STATE]
proof (chain)
picking this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t
[PROOF STEP]
have "children t = r # rs"
[PROOF STATE]
proof (prove)
using this:
is_heap_list (priority t) rs
\<lbrakk>priority t = priority ?t; rs = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
is_heap_list (priority r) (children r)
\<lbrakk>priority r = priority ?t; children r = children ?t\<rbrakk> \<Longrightarrow> priority ?t = Min (set (bt_dfs priority ?t))
priority t \<le> priority r
r # rs = children t

goal (1 subgoal):
 1. children t = r # rs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
children t = r # rs

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
children t = r # rs
[PROOF STEP]
have "bts_dfs priority (children t) =
    (bt_dfs priority r) @ (bts_dfs priority rs)"
[PROOF STATE]
proof (prove)
using this:
children t = r # rs

goal (1 subgoal):
 1. bts_dfs priority (children t) = bt_dfs priority r @ bts_dfs priority rs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bts_dfs priority (children t) = bt_dfs priority r @ bts_dfs priority rs

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
hence "bt_dfs priority t =
    priority t # (bt_dfs priority r @ bts_dfs priority rs)"
[PROOF STATE]
proof (prove)
using this:
bts_dfs priority (children t) = bt_dfs priority r @ bts_dfs priority rs

goal (1 subgoal):
 1. bt_dfs priority t = priority t # bt_dfs priority r @ bts_dfs priority rs
[PROOF STEP]
by (simp add: bt_dfs_simp)
[PROOF STATE]
proof (state)
this:
bt_dfs priority t = priority t # bt_dfs priority r @ bts_dfs priority rs

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
hence A: "?M = Min
    (Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)))"
[PROOF STATE]
proof (prove)
using this:
bt_dfs priority t = priority t # bt_dfs priority r @ bts_dfs priority rs

goal (1 subgoal):
 1. Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
have "Set.insert (priority t) (set (bt_dfs priority r)
    \<union> set (bts_dfs priority rs)) =
    Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)) = Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)) = Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
with A
[PROOF STATE]
proof (chain)
picking this:
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)))
Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)) = Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)
[PROOF STEP]
have "?M = Min
    (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r))"
[PROOF STATE]
proof (prove)
using this:
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)))
Set.insert (priority t) (set (bt_dfs priority r) \<union> set (bts_dfs priority rs)) = Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)

goal (1 subgoal):
 1. Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
with Min_Un
    [of "Set.insert (priority t) (set (bts_dfs priority rs))" "set (bt_dfs priority r)"]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>finite (Set.insert (priority t) (set (bts_dfs priority rs))); Set.insert (priority t) (set (bts_dfs priority rs)) \<noteq> {}; finite (set (bt_dfs priority r)); set (bt_dfs priority r) \<noteq> {}\<rbrakk> \<Longrightarrow> Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r))
[PROOF STEP]
have "?M =
    ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs))))
      (Min (set (bt_dfs priority r)))"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (Set.insert (priority t) (set (bts_dfs priority rs))); Set.insert (priority t) (set (bts_dfs priority rs)) \<noteq> {}; finite (set (bt_dfs priority r)); set (bt_dfs priority r) \<noteq> {}\<rbrakk> \<Longrightarrow> Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))
Min (set (bt_dfs priority t)) = Min (Set.insert (priority t) (set (bts_dfs priority rs)) \<union> set (bt_dfs priority r))

goal (1 subgoal):
 1. Min (set (bt_dfs priority t)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))
[PROOF STEP]
by (auto simp add: bt_dfs_simp)
[PROOF STATE]
proof (state)
this:
Min (set (bt_dfs priority t)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))
priority r = Min (set (bt_dfs priority r))
Min (set (bt_dfs priority t)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))
[PROOF STEP]
have "?M = ord_class.min (priority t) (priority r)"
[PROOF STATE]
proof (prove)
using this:
priority t = Min (Set.insert (priority t) (set (bts_dfs priority rs)))
priority r = Min (set (bt_dfs priority r))
Min (set (bt_dfs priority t)) = ord_class.min (Min (Set.insert (priority t) (set (bts_dfs priority rs)))) (Min (set (bt_dfs priority r)))

goal (1 subgoal):
 1. Min (set (bt_dfs priority t)) = ord_class.min (priority t) (priority r)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Min (set (bt_dfs priority t)) = ord_class.min (priority t) (priority r)

goal (1 subgoal):
 1. \<And>ts t ta. \<lbrakk>is_heap_list (priority ta) ts; \<And>t. \<lbrakk>priority ta = priority t; ts = children t\<rbrakk> \<Longrightarrow> priority t = Min (set (bt_dfs priority t)); is_heap_list (priority t) (children t); \<And>ta. \<lbrakk>priority t = priority ta; children t = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta)); priority ta \<le> priority t; t # ts = children ta\<rbrakk> \<Longrightarrow> priority ta = Min (set (bt_dfs priority ta))
[PROOF STEP]
with \<open>priority t \<le> priority r\<close>
[PROOF STATE]
proof (chain)
picking this:
priority t \<le> priority r
Min (set (bt_dfs priority t)) = ord_class.min (priority t) (priority r)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
priority t \<le> priority r
Min (set (bt_dfs priority t)) = ord_class.min (priority t) (priority r)

goal (1 subgoal):
 1. priority t = Min (set (bt_dfs priority t))
[PROOF STEP]
by (auto simp add: ord_class.min_def)
[PROOF STATE]
proof (state)
this:
priority t = Min (set (bt_dfs priority t))

goal:
No subgoals!
[PROOF STEP]
qed