[STATEMENT]
theorem Stone_Weierstrass_polynomial_function:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  assumes S: "compact S"
      and f: "continuous_on S f"
      and e: "0 < e"
    shows "\<exists>g. polynomial_function g \<and> (\<forall>x \<in> S. norm(f x - g x) < e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
fix b :: 'b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
assume "b \<in> Basis"
[PROOF STATE]
proof (state)
this:
b \<in> Basis

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
have "\<exists>p. real_polynomial_function p \<and> (\<forall>x \<in> S. \<bar>f x \<bullet> b - p x\<bar> < e / DIM('b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> b - p x\<bar> < e / real DIM('b))
[PROOF STEP]
proof (rule Stone_Weierstrass_real_polynomial_function [OF S _, of "\<lambda>x. f x \<bullet> b" "e / card Basis"])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. continuous_on S (\<lambda>x. f x \<bullet> b)
 2. 0 < e / real DIM(?'c1)
 3. \<And>g. \<lbrakk>real_polynomial_function g; \<And>x. x \<in> S \<Longrightarrow> \<bar>f x \<bullet> b - g x\<bar> < e / real DIM(?'c1)\<rbrakk> \<Longrightarrow> \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> b - p x\<bar> < e / real DIM('b))
[PROOF STEP]
show "continuous_on S (\<lambda>x. f x \<bullet> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on S (\<lambda>x. f x \<bullet> b)
[PROOF STEP]
using f
[PROOF STATE]
proof (prove)
using this:
continuous_on S f

goal (1 subgoal):
 1. continuous_on S (\<lambda>x. f x \<bullet> b)
[PROOF STEP]
by (auto intro: continuous_intros)
[PROOF STATE]
proof (state)
this:
continuous_on S (\<lambda>x. f x \<bullet> b)

goal (2 subgoals):
 1. 0 < e / real DIM(?'c1)
 2. \<And>g. \<lbrakk>real_polynomial_function g; \<And>x. x \<in> S \<Longrightarrow> \<bar>f x \<bullet> b - g x\<bar> < e / real DIM(?'c1)\<rbrakk> \<Longrightarrow> \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> b - p x\<bar> < e / real DIM('b))
[PROOF STEP]
qed (use e in auto)
[PROOF STATE]
proof (state)
this:
\<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> b - p x\<bar> < e / real DIM('b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?b2 \<in> Basis \<Longrightarrow> \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> ?b2 - p x\<bar> < e / real DIM('b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?b2 \<in> Basis \<Longrightarrow> \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> ?b2 - p x\<bar> < e / real DIM('b))
[PROOF STEP]
obtain pf where pf:
      "\<And>b. b \<in> Basis \<Longrightarrow> real_polynomial_function (pf b) \<and> (\<forall>x \<in> S. \<bar>f x \<bullet> b - pf b x\<bar> < e / DIM('b))"
[PROOF STATE]
proof (prove)
using this:
?b2 \<in> Basis \<Longrightarrow> \<exists>p. real_polynomial_function p \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> ?b2 - p x\<bar> < e / real DIM('b))

goal (1 subgoal):
 1. (\<And>pf. (\<And>b. b \<in> Basis \<Longrightarrow> real_polynomial_function (pf b) \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> b - pf b x\<bar> < e / real DIM('b))) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
?b \<in> Basis \<Longrightarrow> real_polynomial_function (pf ?b) \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> ?b - pf ?b x\<bar> < e / real DIM('b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
let ?g = "\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
assume "x \<in> S"
[PROOF STATE]
proof (state)
this:
x \<in> S

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
have "norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) \<le> (\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) \<le> (\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b))
[PROOF STEP]
by (rule norm_sum)
[PROOF STATE]
proof (state)
this:
norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) \<le> (\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) \<le> (\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
have "... < of_nat DIM('b) * (e / DIM('b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b)) < real DIM('b) * (e / real DIM('b))
[PROOF STEP]
proof (rule sum_bounded_above_strict)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i \<in> Basis \<Longrightarrow> norm ((f x \<bullet> i) *\<^sub>R i - pf i x *\<^sub>R i) < e / real DIM('b)
 2. 0 < DIM('b)
[PROOF STEP]
show "\<And>i. i \<in> Basis \<Longrightarrow> norm ((f x \<bullet> i) *\<^sub>R i - pf i x *\<^sub>R i) < e / real DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> Basis \<Longrightarrow> norm ((f x \<bullet> i) *\<^sub>R i - pf i x *\<^sub>R i) < e / real DIM('b)
[PROOF STEP]
by (simp add: Real_Vector_Spaces.scaleR_diff_left [symmetric] pf \<open>x \<in> S\<close>)
[PROOF STATE]
proof (state)
this:
?i \<in> Basis \<Longrightarrow> norm ((f x \<bullet> ?i) *\<^sub>R ?i - pf ?i x *\<^sub>R ?i) < e / real DIM('b)

goal (1 subgoal):
 1. 0 < DIM('b)
[PROOF STEP]
qed (rule DIM_positive)
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b)) < real DIM('b) * (e / real DIM('b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>Basis. norm ((f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b)) < real DIM('b) * (e / real DIM('b))

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
have "... = e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real DIM('b) * (e / real DIM('b)) = e
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
real DIM('b) * (e / real DIM('b)) = e

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) < e
[PROOF STEP]
have "norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) < e"
[PROOF STATE]
proof (prove)
using this:
norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) < e

goal (1 subgoal):
 1. norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) < e
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b - pf b x *\<^sub>R b) < e

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 \<in> S \<Longrightarrow> norm (\<Sum>b\<in>Basis. (f ?x2 \<bullet> b) *\<^sub>R b - pf b ?x2 *\<^sub>R b) < e

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?x2 \<in> S \<Longrightarrow> norm (\<Sum>b\<in>Basis. (f ?x2 \<bullet> b) *\<^sub>R b - pf b ?x2 *\<^sub>R b) < e
[PROOF STEP]
have "\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - ?g x) < e"
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> S \<Longrightarrow> norm (\<Sum>b\<in>Basis. (f ?x2 \<bullet> b) *\<^sub>R b - pf b ?x2 *\<^sub>R b) < e

goal (1 subgoal):
 1. \<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e
[PROOF STEP]
by (auto simp flip: sum_subtractf)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
have "polynomial_function ?g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)
[PROOF STEP]
using pf
[PROOF STATE]
proof (prove)
using this:
?b \<in> Basis \<Longrightarrow> real_polynomial_function (pf ?b) \<and> (\<forall>x\<in>S. \<bar>f x \<bullet> ?b - pf ?b x\<bar> < e / real DIM('b))

goal (1 subgoal):
 1. polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)
[PROOF STEP]
by (simp add: polynomial_function_sum polynomial_function_mult real_polynomial_function_eq)
[PROOF STATE]
proof (state)
this:
polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e
polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e
polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
using euclidean_representation_sum_fun [of f]
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. norm ((\<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) - (\<Sum>b\<in>Basis. pf b x *\<^sub>R b)) < e
polynomial_function (\<lambda>x. \<Sum>b\<in>Basis. pf b x *\<^sub>R b)
(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f

goal (1 subgoal):
 1. \<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)
[PROOF STEP]
by (metis (no_types, lifting))
[PROOF STATE]
proof (state)
this:
\<exists>g. polynomial_function g \<and> (\<forall>x\<in>S. norm (f x - g x) < e)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma forall_vector_3: "(\<forall>v::'a::zero^3. P v) \<longleftrightarrow> (\<forall>x y z. P(vector[x, y, z]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>v. P v) = (\<forall>x y z. P (vector [x, y, z]))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<forall>x y z. P (vector [x, y, z]) \<Longrightarrow> P v
[PROOF STEP]
apply (erule_tac x="v$1" in allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<forall>y z. P (vector [v $ 1, y, z]) \<Longrightarrow> P v
[PROOF STEP]
apply (erule_tac x="v$2" in allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<forall>z. P (vector [v $ 1, v $ 2, z]) \<Longrightarrow> P v
[PROOF STEP]
apply (erule_tac x="v$3" in allE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. P (vector [v $ 1, v $ 2, v $ 3]) \<Longrightarrow> P v
[PROOF STEP]
apply (subgoal_tac "vector [v$1, v$2, v$3] = v")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>v. \<lbrakk>P (vector [v $ 1, v $ 2, v $ 3]); vector [v $ 1, v $ 2, v $ 3] = v\<rbrakk> \<Longrightarrow> P v
 2. \<And>v. P (vector [v $ 1, v $ 2, v $ 3]) \<Longrightarrow> vector [v $ 1, v $ 2, v $ 3] = v
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. P (vector [v $ 1, v $ 2, v $ 3]) \<Longrightarrow> vector [v $ 1, v $ 2, v $ 3] = v
[PROOF STEP]
apply (vector vector_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. P (\<chi>i. if i = 1 then v $ 1 else ((\<lambda>x. 0::'a)(3 := v $ 3, 2 := v $ 2)) i) \<Longrightarrow> \<forall>i. i \<noteq> 3 \<longrightarrow> i \<noteq> 2 \<longrightarrow> i \<noteq> 1 \<longrightarrow> v $ i = (0::'a)
[PROOF STEP]
apply (simp add: forall_3)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Times_insert_left: "A \<times># add_mset x B = A \<times># B + image_mset (\<lambda>a. Pair a x) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<times># add_mset x B = A \<times># B + {#(a, x). a \<in># A#}
[PROOF STEP]
unfolding add_mset_add_single[of x B] Sigma_mset_plus_distrib2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<times># B + A \<times># {#x#} = A \<times># B + {#(a, x). a \<in># A#}
[PROOF STEP]
by (simp add: Times_mset_single_right)


[STATEMENT]
lemma poly_monom_mult:
  fixes p :: "'a :: comm_semiring_1"
  shows "poly (monom p i * q ^ j) y = poly (monom p j * [:y:] ^ i) (poly q y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (monom p i * q ^ j) y = poly (monom p j * [:y:] ^ i) (poly q y)
[PROOF STEP]
unfolding poly_hom.hom_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (monom p i) y * poly (q ^ j) y = poly (monom p j) (poly q y) * poly ([:y:] ^ i) (poly q y)
[PROOF STEP]
unfolding poly_monom
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * y ^ i * poly (q ^ j) y = p * poly q y ^ j * poly ([:y:] ^ i) (poly q y)
[PROOF STEP]
apply(subst mult.assoc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * (y ^ i * poly (q ^ j) y) = p * poly q y ^ j * poly ([:y:] ^ i) (poly q y)
[PROOF STEP]
apply(subst(2) mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * (poly (q ^ j) y * y ^ i) = p * poly q y ^ j * poly ([:y:] ^ i) (poly q y)
[PROOF STEP]
by (auto simp: mult.assoc)


[STATEMENT]
lemma unat_minus:
  "unat (- (x :: 'a :: len word)) = (if x = 0 then 0 else 2 ^ size x - unat x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unat (- x) = (if x = 0 then 0 else 2 ^ size x - unat x)
[PROOF STEP]
using unat_sub_if_size[where x="2 ^ size x" and y=x]
[PROOF STATE]
proof (prove)
using this:
unat (2 ^ size x - x) = (if unat x \<le> unat (2 ^ size x) then unat (2 ^ size x) - unat x else unat (2 ^ size x) + 2 ^ size (2 ^ size x) - unat x)

goal (1 subgoal):
 1. unat (- x) = (if x = 0 then 0 else 2 ^ size x - unat x)
[PROOF STEP]
by (simp add: unat_eq_0 word_size)


[STATEMENT]
lemma matches_alist_and: "matches \<gamma> (alist_and l) a p \<longleftrightarrow> (\<forall>m \<in> set (getPos l). matches \<gamma> (Match m) a p) \<and> (\<forall>m \<in> set (getNeg l). matches \<gamma> (MatchNot (Match m)) a p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matches \<gamma> (alist_and l) a p = ((\<forall>m\<in>set (getPos l). matches \<gamma> (Match m) a p) \<and> (\<forall>m\<in>set (getNeg l). matches \<gamma> (MatchNot (Match m)) a p))
[PROOF STEP]
using nt_match_list_matches nt_match_list_simp
[PROOF STATE]
proof (prove)
using this:
nt_match_list ?\<gamma> ?a ?p ?l = matches ?\<gamma> (alist_and ?l) ?a ?p
nt_match_list ?\<gamma> ?a ?p ?ms = ((\<forall>m\<in>set (getPos ?ms). matches ?\<gamma> (Match m) ?a ?p) \<and> (\<forall>m\<in>set (getNeg ?ms). matches ?\<gamma> (MatchNot (Match m)) ?a ?p))

goal (1 subgoal):
 1. matches \<gamma> (alist_and l) a p = ((\<forall>m\<in>set (getPos l). matches \<gamma> (Match m) a p) \<and> (\<forall>m\<in>set (getNeg l). matches \<gamma> (MatchNot (Match m)) a p))
[PROOF STEP]
by fast


[STATEMENT]
lemma bv_to_nat_emsapss_encode_le: "emsapss_encode m x \<noteq> [] \<Longrightarrow> bv_to_nat (emsapss_encode m x) < 2^(roundup x 8 * 8)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emsapss_encode m x \<noteq> [] \<Longrightarrow> bv_to_nat (emsapss_encode m x) < 2 ^ (roundup x 8 * 8)
[PROOF STEP]
apply (insert length_emsapss_encode [of m x])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>emsapss_encode m x \<noteq> []; emsapss_encode m x \<noteq> [] \<Longrightarrow> length (emsapss_encode m x) = roundup x 8 * 8\<rbrakk> \<Longrightarrow> bv_to_nat (emsapss_encode m x) < 2 ^ (roundup x 8 * 8)
[PROOF STEP]
apply (insert bv_to_nat_upper_range [of "emsapss_encode m x"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>emsapss_encode m x \<noteq> []; emsapss_encode m x \<noteq> [] \<Longrightarrow> length (emsapss_encode m x) = roundup x 8 * 8; bv_to_nat (emsapss_encode m x) < 2 ^ length (emsapss_encode m x)\<rbrakk> \<Longrightarrow> bv_to_nat (emsapss_encode m x) < 2 ^ (roundup x 8 * 8)
[PROOF STEP]
by (simp)


[STATEMENT]
lemma string_to_nat_inv :
assumes strong_nat_s: "is_strong_nat_string s"
assumes s2n_s: "string_to_nat s = Some n"
shows "nat_to_string n = s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_to_string n = s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nat_to_string n = s
[PROOF STEP]
from strong_nat_s
[PROOF STATE]
proof (chain)
picking this:
is_strong_nat_string s
[PROOF STEP]
have nat_s: "is_nat_string s"
[PROOF STATE]
proof (prove)
using this:
is_strong_nat_string s

goal (1 subgoal):
 1. is_nat_string s
[PROOF STEP]
unfolding is_strong_nat_string_def
[PROOF STATE]
proof (prove)
using this:
is_nat_string s \<and> s \<noteq> [] \<and> (hd s = CHR ''0'' \<longrightarrow> length s = 1)

goal (1 subgoal):
 1. is_nat_string s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
is_nat_string s

goal (1 subgoal):
 1. nat_to_string n = s
[PROOF STEP]
with s2n_s
[PROOF STATE]
proof (chain)
picking this:
string_to_nat s = Some n
is_nat_string s
[PROOF STEP]
have n_eq: "n = string_to_nat_aux 0 s"
[PROOF STATE]
proof (prove)
using this:
string_to_nat s = Some n
is_nat_string s

goal (1 subgoal):
 1. n = string_to_nat_aux 0 s
[PROOF STEP]
unfolding string_to_nat_def
[PROOF STATE]
proof (prove)
using this:
(if is_nat_string s then Some (string_to_nat_aux 0 s) else None) = Some n
is_nat_string s

goal (1 subgoal):
 1. n = string_to_nat_aux 0 s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n = string_to_nat_aux 0 s

goal (1 subgoal):
 1. nat_to_string n = s
[PROOF STEP]
from string_to_nat_aux_inv[of s 0, folded n_eq] nat_s strong_nat_s
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>is_nat_string s; 0 < 0 \<or> is_strong_nat_string s\<rbrakk> \<Longrightarrow> nat_to_string n = (if 0 = 0 then [] else nat_to_string 0) @ s
is_nat_string s
is_strong_nat_string s
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_nat_string s; 0 < 0 \<or> is_strong_nat_string s\<rbrakk> \<Longrightarrow> nat_to_string n = (if 0 = 0 then [] else nat_to_string 0) @ s
is_nat_string s
is_strong_nat_string s

goal (1 subgoal):
 1. nat_to_string n = s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nat_to_string n = s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linord_of_list_empty[iff]:
  "linord_of_list [] = {}"
  "linord_of_list xs = {} \<longleftrightarrow> xs = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linord_of_list [] = {} &&& (linord_of_list xs = {}) = (xs = [])
[PROOF STEP]
unfolding linord_of_list_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). linord_of_listP x y []} = {} &&& ({(x, y). linord_of_listP x y xs} = {}) = (xs = [])
[PROOF STEP]
by (simp_all add: linord_of_listP_empty)


[STATEMENT]
lemma (in group) (* Manuel Eberl *)
  assumes "x \<in> carrier G" and "x [^] n = \<one>" and "n > 0"
  shows   ord_le: "ord x \<le> n" and ord_pos: "ord x > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord x \<le> n &&& 0 < ord x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ord x \<le> n
 2. 0 < ord x
[PROOF STEP]
have "ord x dvd n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord x dvd n
[PROOF STEP]
using pow_eq_id[of x n] assms
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier G \<Longrightarrow> (x [^] n = \<one>) = (ord x dvd n)
x \<in> carrier G
x [^] n = \<one>
0 < n

goal (1 subgoal):
 1. ord x dvd n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ord x dvd n

goal (2 subgoals):
 1. ord x \<le> n
 2. 0 < ord x
[PROOF STEP]
thus "ord x \<le> n" "ord x > 0"
[PROOF STATE]
proof (prove)
using this:
ord x dvd n

goal (1 subgoal):
 1. ord x \<le> n &&& 0 < ord x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ord x dvd n
x \<in> carrier G
x [^] n = \<one>
0 < n

goal (1 subgoal):
 1. ord x \<le> n &&& 0 < ord x
[PROOF STEP]
by (auto intro: dvd_imp_le)
[PROOF STATE]
proof (state)
this:
ord x \<le> n
0 < ord x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_mult_rat_0[simp]: assumes r0: "r \<noteq> 0" shows "poly_mult_rat r p = 0 \<longleftrightarrow> p = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
obtain n d where quot: "quotient_of r = (n,d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n d. quotient_of r = (n, d) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
quotient_of r = (n, d)

goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
from quotient_of_div[OF quot]
[PROOF STATE]
proof (chain)
picking this:
r = rat_of_int n / rat_of_int d
[PROOF STEP]
have r: "r = of_int n / of_int d"
[PROOF STATE]
proof (prove)
using this:
r = rat_of_int n / rat_of_int d

goal (1 subgoal):
 1. r = rat_of_int n / rat_of_int d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r = rat_of_int n / rat_of_int d

goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
from quotient_of_denom_pos[OF quot]
[PROOF STATE]
proof (chain)
picking this:
0 < d
[PROOF STEP]
have d: "d \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
0 < d

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

goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
from r r0
[PROOF STATE]
proof (chain)
picking this:
r = rat_of_int n / rat_of_int d
r \<noteq> 0
[PROOF STEP]
have n: "n \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
r = rat_of_int n / rat_of_int d
r \<noteq> 0

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

goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
from quot
[PROOF STATE]
proof (chain)
picking this:
quotient_of r = (n, d)
[PROOF STEP]
have id: "poly_mult_rat r p = poly_mult_rat_main n d p"
[PROOF STATE]
proof (prove)
using this:
quotient_of r = (n, d)

goal (1 subgoal):
 1. poly_mult_rat r p = poly_mult_rat_main n d p
[PROOF STEP]
unfolding poly_mult_rat_def
[PROOF STATE]
proof (prove)
using this:
quotient_of r = (n, d)

goal (1 subgoal):
 1. (case quotient_of r of (n, d) \<Rightarrow> poly_mult_rat_main n d p) = poly_mult_rat_main n d p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly_mult_rat r p = poly_mult_rat_main n d p

goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly_mult_rat r p = 0) = (p = 0)
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly_mult_rat_main n d p = 0) = (p = 0)
[PROOF STEP]
using n d
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0
d \<noteq> 0

goal (1 subgoal):
 1. (poly_mult_rat_main n d p = 0) = (p = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(poly_mult_rat r p = 0) = (p = 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcard_empty_0 [simp]: "gcard {} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcard {} = 0
[PROOF STEP]
by (simp add: gcard_eq_card)


[STATEMENT]
lemma norm_eq_1_iff_in_S:
  shows "norm v = 1 \<longleftrightarrow> proj2_pt v \<in> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
let ?v' = "vector2_append1 v"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
have "?v' \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector2_append1 v \<noteq> 0
[PROOF STEP]
by (rule vector2_append1_non_zero)
[PROOF STATE]
proof (state)
this:
vector2_append1 v \<noteq> 0

goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
from real_sqrt_unique [of "norm v" 1]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>(norm v)\<^sup>2 = 1; 0 \<le> norm v\<rbrakk> \<Longrightarrow> sqrt 1 = norm v
[PROOF STEP]
have "norm v = 1 \<longleftrightarrow> (norm v)\<^sup>2 = 1"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(norm v)\<^sup>2 = 1; 0 \<le> norm v\<rbrakk> \<Longrightarrow> sqrt 1 = norm v

goal (1 subgoal):
 1. (norm v = 1) = ((norm v)\<^sup>2 = 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(norm v = 1) = ((norm v)\<^sup>2 = 1)

goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
hence "norm v = 1 \<longleftrightarrow> ?v' \<bullet> (M *v ?v') = 0"
[PROOF STATE]
proof (prove)
using this:
(norm v = 1) = ((norm v)\<^sup>2 = 1)

goal (1 subgoal):
 1. (norm v = 1) = (vector2_append1 v \<bullet> (M *v vector2_append1 v) = 0)
[PROOF STEP]
by (simp add: norm_M)
[PROOF STATE]
proof (state)
this:
(norm v = 1) = (vector2_append1 v \<bullet> (M *v vector2_append1 v) = 0)

goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
with \<open>?v' \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
vector2_append1 v \<noteq> 0
(norm v = 1) = (vector2_append1 v \<bullet> (M *v vector2_append1 v) = 0)
[PROOF STEP]
have "norm v = 1 \<longleftrightarrow> proj2_abs ?v' \<in> S"
[PROOF STATE]
proof (prove)
using this:
vector2_append1 v \<noteq> 0
(norm v = 1) = (vector2_append1 v \<bullet> (M *v vector2_append1 v) = 0)

goal (1 subgoal):
 1. (norm v = 1) = (proj2_abs (vector2_append1 v) \<in> S)
[PROOF STEP]
by (subst S_abs)
[PROOF STATE]
proof (state)
this:
(norm v = 1) = (proj2_abs (vector2_append1 v) \<in> S)

goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
thus "norm v = 1 \<longleftrightarrow> proj2_pt v \<in> S"
[PROOF STATE]
proof (prove)
using this:
(norm v = 1) = (proj2_abs (vector2_append1 v) \<in> S)

goal (1 subgoal):
 1. (norm v = 1) = (proj2_pt v \<in> S)
[PROOF STEP]
by (unfold proj2_pt_def)
[PROOF STATE]
proof (state)
this:
(norm v = 1) = (proj2_pt v \<in> S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "\<exists>(x::'a::linordered_field) y. \<forall>z<0. (z < x \<longrightarrow> z \<le> y) \<and> (z > y \<longrightarrow> z \<ge> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x y. \<forall>z<0::'a. (z < x \<longrightarrow> z \<le> y) \<and> (y < z \<longrightarrow> x \<le> z)
[PROOF STEP]
by ferrack


[STATEMENT]
theorem wls_vsubstAbs_substAbs_compose1:
assumes "wlsAbs (us,s) A" and "wls (asSort ys) Y"
shows "((A $[Y / y]_ys) $[y1 // y]_ys) = (A $[(Y #[y1 // y]_ys) / y]_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $[Y / y]_ys $[y1 // y]_ys = A $[Y #[y1 // y]_ys / y]_ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wlsAbs (us, s) A
wls (asSort ys) Y

goal (1 subgoal):
 1. A $[Y / y]_ys $[y1 // y]_ys = A $[Y #[y1 // y]_ys / y]_ys
[PROOF STEP]
by(simp add: vsubstAbs_substAbs_compose1)


[STATEMENT]
lemma SUP_ereal_add_pos:
  fixes f g :: "nat \<Rightarrow> ereal"
  assumes inc: "incseq f" "incseq g"
    and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i"
  shows "(SUP i. f i + g i) = Sup (f ` UNIV) + Sup (g ` UNIV)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP i. f i + g i) = Sup (range f) + Sup (range g)
[PROOF STEP]
proof (intro SUP_ereal_add inc)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. f i \<noteq> - \<infinity>
 2. \<And>i. g i \<noteq> - \<infinity>
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. f i \<noteq> - \<infinity>
 2. \<And>i. g i \<noteq> - \<infinity>
[PROOF STEP]
show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f i \<noteq> - \<infinity> &&& g i \<noteq> - \<infinity>
[PROOF STEP]
using pos[of i]
[PROOF STATE]
proof (prove)
using this:
0 \<le> f i
0 \<le> g i

goal (1 subgoal):
 1. f i \<noteq> - \<infinity> &&& g i \<noteq> - \<infinity>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i \<noteq> - \<infinity>
g i \<noteq> - \<infinity>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem snd_sort_and_count_inversions [simp]:
  "snd (sort_and_count_inversions xs) = inversion_number xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
proof (induction xs rule: length_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> snd (sort_and_count_inversions ys) = inversion_number ys \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
case (1 xs)
[PROOF STATE]
proof (state)
this:
\<forall>ys. length ys < length xs \<longrightarrow> snd (sort_and_count_inversions ys) = inversion_number ys

goal (1 subgoal):
 1. \<And>xs. \<forall>ys. length ys < length xs \<longrightarrow> snd (sort_and_count_inversions ys) = inversion_number ys \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
proof (cases "length xs \<le> 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
 2. \<not> length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> length xs \<le> 1

goal (2 subgoals):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
 2. \<not> length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
have "xs = take (length xs div 2) xs @ drop (length xs div 2) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs = take (length xs div 2) xs @ drop (length xs div 2) xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
xs = take (length xs div 2) xs @ drop (length xs div 2) xs

goal (2 subgoals):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
 2. \<not> length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
xs = take (length xs div 2) xs @ drop (length xs div 2) xs

goal (2 subgoals):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
 2. \<not> length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
have "inversion_number \<dots> = snd (sort_and_count_inversions xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inversion_number (take (length xs div 2) xs @ drop (length xs div 2) xs) = snd (sort_and_count_inversions xs)
[PROOF STEP]
by (subst inversion_number_append, subst sort_and_count_inversions.simps)
         (use False 1 in \<open>auto simp: Let_def split_list_def case_prod_unfold
                                     inversion_number_between_sorted_correct
                               cong: inversion_number_between_cong_mset\<close>)
[PROOF STATE]
proof (state)
this:
inversion_number (take (length xs div 2) xs @ drop (length xs div 2) xs) = snd (sort_and_count_inversions xs)

goal (2 subgoals):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
 2. \<not> length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
inversion_number xs = snd (sort_and_count_inversions xs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inversion_number xs = snd (sort_and_count_inversions xs)

goal (1 subgoal):
 1. snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
snd (sort_and_count_inversions xs) = inversion_number xs

goal (1 subgoal):
 1. length xs \<le> 1 \<Longrightarrow> snd (sort_and_count_inversions xs) = inversion_number xs
[PROOF STEP]
qed (auto simp: sort_and_count_inversions.simps)
[PROOF STATE]
proof (state)
this:
snd (sort_and_count_inversions xs) = inversion_number xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma contour_integral_integral:
     "contour_integral g f = integral {0..1} (\<lambda>x. f (g x) * vector_derivative g (at x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral g f = integral {0..1} (\<lambda>x. f (g x) * vector_derivative g (at x))
[PROOF STEP]
by (simp add: contour_integral_def integral_def has_contour_integral contour_integrable_on)


[STATEMENT]
lemma distributed_integral:
  "distributed M N X f \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow> (\<And>x. x \<in> space N \<Longrightarrow> 0 \<le> f x) \<Longrightarrow>
    (\<integral>x. f x * g x \<partial>N) = (\<integral>x. g (X x) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distributed M N X (\<lambda>x. ennreal (f x)); g \<in> borel_measurable N; \<And>x. x \<in> space N \<Longrightarrow> 0 \<le> f x\<rbrakk> \<Longrightarrow> LINT x|N. f x * g x = LINT x|M. g (X x)
[PROOF STEP]
supply distributed_real_measurable[measurable]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distributed M N X (\<lambda>x. ennreal (f x)); g \<in> borel_measurable N; \<And>x. x \<in> space N \<Longrightarrow> 0 \<le> f x\<rbrakk> \<Longrightarrow> LINT x|N. f x * g x = LINT x|M. g (X x)
[PROOF STEP]
by (auto simp: distributed_distr_eq_density[symmetric] integral_real_density[symmetric] integral_distr)


[STATEMENT]
lemma independent_explicit:
  shows "independent B \<longleftrightarrow> finite B \<and> (\<forall>c. (\<Sum>v\<in>B. c v *s v) = 0 \<longrightarrow> (\<forall>v \<in> B. c v = 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. independent B = (finite B \<and> (\<forall>c. (\<Sum>v\<in>B. c v *s v) = (0::'b) \<longrightarrow> (\<forall>v\<in>B. c v = (0::'a))))
[PROOF STEP]
using independent_bound_general
[PROOF STATE]
proof (prove)
using this:
independent ?S \<Longrightarrow> finite ?S \<and> card ?S \<le> dim ?S

goal (1 subgoal):
 1. independent B = (finite B \<and> (\<forall>c. (\<Sum>v\<in>B. c v *s v) = (0::'b) \<longrightarrow> (\<forall>v\<in>B. c v = (0::'a))))
[PROOF STEP]
by (fastforce simp: dependent_finite)


[STATEMENT]
lemma Always_union:
     "[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |]
      ==> F \<in> Always {s. f' s + g' s \<le> f s + (g s :: ('a::order) multiset)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s}\<rbrakk> \<Longrightarrow> F \<in> Always {s. f' s + g' s \<le> f s + g s}
[PROOF STEP]
apply (simp add: Always_eq_includes_reachable)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>reachable F \<subseteq> {s. f' s \<le> f s}; reachable F \<subseteq> {s. g' s \<le> g s}\<rbrakk> \<Longrightarrow> reachable F \<subseteq> {s. f' s + g' s \<le> f s + g s}
[PROOF STEP]
apply (blast intro: add_mono)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma connected_ivt_component:
  fixes x::"'a::euclidean_space"
  shows "connected S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x\<bullet>k \<le> a \<Longrightarrow> a \<le> y\<bullet>k \<Longrightarrow> (\<exists>z\<in>S.  z\<bullet>k = a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>connected S; x \<in> S; y \<in> S; x \<bullet> k \<le> a; a \<le> y \<bullet> k\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. z \<bullet> k = a
[PROOF STEP]
using connected_ivt_hyperplane[of S x y "k::'a" a]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>connected S; x \<in> S; y \<in> S; k \<bullet> x \<le> a; a \<le> k \<bullet> y\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. k \<bullet> z = a

goal (1 subgoal):
 1. \<lbrakk>connected S; x \<in> S; y \<in> S; x \<bullet> k \<le> a; a \<le> y \<bullet> k\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. z \<bullet> k = a
[PROOF STEP]
by (auto simp: inner_commute)


[STATEMENT]
theorem wls_substAbs_compose1:
assumes "wlsAbs (us,s) A" and "wls (asSort ys) Y1" and "wls (asSort ys) Y2"
shows "((A $[Y1 / y]_ys) $[Y2 / y]_ys) = (A $[(Y1 #[Y2 / y]_ys) / y]_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $[Y1 / y]_ys $[Y2 / y]_ys = A $[Y1 #[Y2 / y]_ys / y]_ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wlsAbs (us, s) A
wls (asSort ys) Y1
wls (asSort ys) Y2

goal (1 subgoal):
 1. A $[Y1 / y]_ys $[Y2 / y]_ys = A $[Y1 #[Y2 / y]_ys / y]_ys
[PROOF STEP]
by(simp add: substAbs_compose1)


[STATEMENT]
lemma of_nat_diff_real: "of_nat (a - b) = max (0::real) (of_nat a - of_nat b)"
  and of_nat_max_real: "of_nat (max a b) = max (of_nat a) (of_nat b :: real)"
  and of_nat_min_real: "of_nat (min a b) = min (of_nat a) (of_nat b :: real)"
  and of_int_max_real: "of_int (max c d) = max (of_int c) (of_int d :: real)"
  and of_int_min_real: "of_int (min c d) = min (of_int c) (of_int d :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real (a - b) = max 0 (real a - real b) &&& real (max a b) = max (real a) (real b)) &&& real (min a b) = min (real a) (real b) &&& real_of_int (max c d) = max (real_of_int c) (real_of_int d) &&& real_of_int (min c d) = min (real_of_int c) (real_of_int d)
[PROOF STEP]
by simp_all


[STATEMENT]
lemma divide_non_zero:
  fixes x y z :: real
  assumes "x \<noteq> 0"
  shows "x * y = z \<longleftrightarrow> y = z / x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x * y = z) = (y = z / x)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x * y = z \<Longrightarrow> y = z / x
 2. y = z / x \<Longrightarrow> x * y = z
[PROOF STEP]
show "y = z / x" if "x * y = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y = z / x
[PROOF STEP]
using \<open>x \<noteq> 0\<close> that
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0
x * y = z

goal (1 subgoal):
 1. y = z / x
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
x * y = z \<Longrightarrow> y = z / x

goal (1 subgoal):
 1. y = z / x \<Longrightarrow> x * y = z
[PROOF STEP]
show "x * y = z" if "y = z / x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * y = z
[PROOF STEP]
using \<open>x \<noteq> 0\<close> that
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0
y = z / x

goal (1 subgoal):
 1. x * y = z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y = z / x \<Longrightarrow> x * y = z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma metric_tendsto_imp_tendsto:
  fixes a :: "'a :: metric_space"
    and b :: "'b :: metric_space"
  assumes f: "(f \<longlongrightarrow> a) F"
    and le: "eventually (\<lambda>x. dist (g x) b \<le> dist (f x) a) F"
  shows "(g \<longlongrightarrow> b) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g \<longlongrightarrow> b) F
[PROOF STEP]
proof (rule tendstoI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
fix e :: real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
assume "0 < e"
[PROOF STATE]
proof (state)
this:
0 < e

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
with f
[PROOF STATE]
proof (chain)
picking this:
(f \<longlongrightarrow> a) F
0 < e
[PROOF STEP]
have "eventually (\<lambda>x. dist (f x) a < e) F"
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> a) F
0 < e

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (f x) a < e
[PROOF STEP]
by (rule tendstoD)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. dist (f x) a < e

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
with le
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in F. dist (g x) b \<le> dist (f x) a
\<forall>\<^sub>F x in F. dist (f x) a < e
[PROOF STEP]
show "eventually (\<lambda>x. dist (g x) b < e) F"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. dist (g x) b \<le> dist (f x) a
\<forall>\<^sub>F x in F. dist (f x) a < e

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
using le_less_trans
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. dist (g x) b \<le> dist (f x) a
\<forall>\<^sub>F x in F. dist (f x) a < e
\<lbrakk>?x \<le> ?y; ?y < ?z\<rbrakk> \<Longrightarrow> ?x < ?z

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. dist (g x) b < e
[PROOF STEP]
by (rule eventually_elim2)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. dist (g x) b < e

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma le_arcsin_iff:
  assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2"
  shows   "arcsin x \<ge> y \<longleftrightarrow> x \<ge> sin y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
have "arcsin x \<ge> y \<longleftrightarrow> sin (arcsin x) \<ge> sin y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> sin (arcsin x))
[PROOF STEP]
using arcsin_bounded[of x] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>- 1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> arcsin x \<and> arcsin x \<le> pi / 2
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2

goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> sin (arcsin x))
[PROOF STEP]
by (subst sin_mono_le_eq) auto
[PROOF STATE]
proof (state)
this:
(y \<le> arcsin x) = (sin y \<le> sin (arcsin x))

goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(y \<le> arcsin x) = (sin y \<le> sin (arcsin x))

goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2
[PROOF STEP]
have "sin (arcsin x) = x"
[PROOF STATE]
proof (prove)
using this:
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2

goal (1 subgoal):
 1. sin (arcsin x) = x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sin (arcsin x) = x

goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(y \<le> arcsin x) = (sin y \<le> x)

goal (1 subgoal):
 1. (y \<le> arcsin x) = (sin y \<le> x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(y \<le> arcsin x) = (sin y \<le> x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fcard_fminus_finsert[simp]:
  assumes "a |\<in>| A" and "a |\<notin>| B"
  shows "fcard (A |-| finsert a B) = fcard (A |-| B) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcard (A |-| finsert a B) = fcard (A |-| B) - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a |\<in>| A
a |\<notin>| B

goal (1 subgoal):
 1. fcard (A |-| finsert a B) = fcard (A |-| B) - 1
[PROOF STEP]
by transfer (rule card_Diff_insert)


[STATEMENT]
lemma finite_inverse_real_of_posnat_ge_real:
  assumes "0 < u"
  shows "finite {n. u \<le> inverse (real (Suc n))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {n. u \<le> inverse (real (Suc n))}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {n. u \<le> inverse (real (Suc n))}
[PROOF STEP]
have "\<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> na \<le> ceiling (inverse u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> int na \<le> \<lceil>inverse u\<rceil>
[PROOF STEP]
by (smt (verit, best) assms ceiling_less_cancel ceiling_of_nat inverse_inverse_eq inverse_le_iff_le)
[PROOF STATE]
proof (state)
this:
\<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> int na \<le> \<lceil>inverse u\<rceil>

goal (1 subgoal):
 1. finite {n. u \<le> inverse (real (Suc n))}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> int na \<le> \<lceil>inverse u\<rceil>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> int na \<le> \<lceil>inverse u\<rceil>

goal (1 subgoal):
 1. finite {n. u \<le> inverse (real (Suc n))}
[PROOF STEP]
apply (auto simp add: finite_nat_set_iff_bounded_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>na. u \<le> inverse (1 + real na) \<longrightarrow> int na \<le> \<lceil>inverse u\<rceil> \<Longrightarrow> \<exists>m. \<forall>n. u \<le> inverse (1 + real n) \<longrightarrow> n \<le> m
[PROOF STEP]
by (meson assms inverse_positive_iff_positive le_nat_iff less_imp_le zero_less_ceiling)
[PROOF STATE]
proof (state)
this:
finite {n. u \<le> inverse (real (Suc n))}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma length_greaters_le_sorted:
  assumes "sorted_wrt R xs" "i < length xs"
  shows   "length (greaters R (xs ! i) xs) \<le> length xs - i - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (greaters R (xs ! i) xs) \<le> length xs - i - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Linorder_Relations.sorted_wrt R xs
i < length xs

goal (1 subgoal):
 1. length (greaters R (xs ! i) xs) \<le> length xs - i - 1
[PROOF STEP]
by (induction arbitrary: i rule: sorted_wrt.induct)
     (force simp: greaters_def nth_Cons le_Suc_eq split: nat.splits)+


[STATEMENT]
lemma gfinprod_mono_neutral_cong_right:
  assumes "A \<subseteq> B" "\<And>i. i \<in> B - A \<Longrightarrow> g i = \<one>" "\<And>x. x \<in> A \<Longrightarrow> g x = h x" "g \<in> B \<rightarrow> carrier G"
  shows "gfinprod G g B = gfinprod G h A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gfinprod G g B = gfinprod G h A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> B
?i \<in> B - A \<Longrightarrow> g ?i = \<one>
?x \<in> A \<Longrightarrow> g ?x = h ?x
g \<in> B \<rightarrow> carrier G

goal (1 subgoal):
 1. gfinprod G g B = gfinprod G h A
[PROOF STEP]
by (auto intro!: gfinprod_mono_neutral_cong_left [symmetric])


[STATEMENT]
lemma col_nth_0_or_1_iff:
  assumes "j < dim_col M"
  assumes "i < dim_row M"
  shows "col M j $ i = 0 \<longleftrightarrow> col M j $ i \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (col M j $ i = (0::'b)) = (col M j $ i \<noteq> (1::'b))
[PROOF STEP]
proof (intro iffI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)
 2. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
have dv: "i < dim_vec (col M j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < dim_vec (col M j)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
j < dim_col M
i < dim_row M

goal (1 subgoal):
 1. i < dim_vec (col M j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < dim_vec (col M j)

goal (2 subgoals):
 1. col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)
 2. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
have sv: "set\<^sub>v (col M j) \<subseteq> {0, 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}
[PROOF STEP]
using col_elems_ss01 assms
[PROOF STATE]
proof (prove)
using this:
?j < dim_col M \<Longrightarrow> set\<^sub>v (col M ?j) \<subseteq> {0::'b, 1::'b}
j < dim_col M
i < dim_row M

goal (1 subgoal):
 1. set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}

goal (2 subgoals):
 1. col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)
 2. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}
[PROOF STEP]
show "col M j $ i = 0 \<Longrightarrow> col M j $ i \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}

goal (1 subgoal):
 1. col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)
[PROOF STEP]
using dv
[PROOF STATE]
proof (prove)
using this:
set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}
i < dim_vec (col M j)

goal (1 subgoal):
 1. col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
col M j $ i = (0::'b) \<Longrightarrow> col M j $ i \<noteq> (1::'b)

goal (1 subgoal):
 1. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
show "col M j $ i \<noteq> 1 \<Longrightarrow> col M j $ i = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
using dv sv
[PROOF STATE]
proof (prove)
using this:
i < dim_vec (col M j)
set\<^sub>v (col M j) \<subseteq> {0::'b, 1::'b}

goal (1 subgoal):
 1. col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)
[PROOF STEP]
by (meson insertE singletonD subset_eq vec_setI)
[PROOF STATE]
proof (state)
this:
col M j $ i \<noteq> (1::'b) \<Longrightarrow> col M j $ i = (0::'b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma find_non0'_LEAST:
  assumes A: "A \<in> carrier_mat m n"
  and res: "find_non0' i k A = Some j"
shows "j = (LEAST n. A $$ (n,k) \<noteq> 0 \<and> i\<le>n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j = (LEAST n. A $$ (n, k) \<noteq> (0::'a) \<and> i \<le> n)
[PROOF STEP]
proof (rule Least_equality[symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A $$ (j, k) \<noteq> (0::'a) \<and> i \<le> j
 2. \<And>y. A $$ (y, k) \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> j \<le> y
[PROOF STEP]
show " A $$ (j, k) \<noteq> 0 \<and> i \<le> j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (j, k) \<noteq> (0::'a) \<and> i \<le> j
[PROOF STEP]
using A res find_non0'[OF A]
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n
find_non0' i k A = Some j
find_non0' ?i ?k A = Some ?j \<Longrightarrow> A $$ (?j, ?k) \<noteq> (0::'a)
find_non0' ?i ?k A = Some ?j \<Longrightarrow> ?i \<le> ?j
find_non0' ?i ?k A = Some ?j \<Longrightarrow> ?j < dim_row A

goal (1 subgoal):
 1. A $$ (j, k) \<noteq> (0::'a) \<and> i \<le> j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (j, k) \<noteq> (0::'a) \<and> i \<le> j

goal (1 subgoal):
 1. \<And>y. A $$ (y, k) \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> j \<le> y
[PROOF STEP]
show " \<And>y. A $$ (y, k) \<noteq> 0 \<and> i \<le> y \<Longrightarrow> j \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. A $$ (y, k) \<noteq> (0::'a) \<and> i \<le> y \<Longrightarrow> j \<le> y
[PROOF STEP]
by (meson A res atLeastLessThan_iff find_non0'_w_zero_before linorder_not_le)
[PROOF STATE]
proof (state)
this:
A $$ (?y, k) \<noteq> (0::'a) \<and> i \<le> ?y \<Longrightarrow> j \<le> ?y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in comm_monoid) multlist_perm_cong:
  assumes prm: "as <~~> bs"
    and ascarr: "set as \<subseteq> carrier G"
  shows "foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
from prm
[PROOF STATE]
proof (chain)
picking this:
mset as = mset bs
[PROOF STEP]
have \<open>mset (rev as) = mset (rev bs)\<close>
[PROOF STATE]
proof (prove)
using this:
mset as = mset bs

goal (1 subgoal):
 1. mset (rev as) = mset (rev bs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mset (rev as) = mset (rev bs)

goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
mset (rev as) = mset (rev bs)

goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
note one_closed
[PROOF STATE]
proof (state)
this:
\<one> \<in> carrier G

goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
mset (rev as) = mset (rev bs)
\<one> \<in> carrier G
[PROOF STEP]
have \<open>fold (\<otimes>) (rev as) \<one> = fold (\<otimes>) (rev bs) \<one>\<close>
[PROOF STATE]
proof (prove)
using this:
mset (rev as) = mset (rev bs)
\<one> \<in> carrier G

goal (1 subgoal):
 1. fold (\<otimes>) (rev as) \<one> = fold (\<otimes>) (rev bs) \<one>
[PROOF STEP]
by (rule fold_permuted_eq) (use ascarr in \<open>auto intro: m_lcomm\<close>)
[PROOF STATE]
proof (state)
this:
fold (\<otimes>) (rev as) \<one> = fold (\<otimes>) (rev bs) \<one>

goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
fold (\<otimes>) (rev as) \<one> = fold (\<otimes>) (rev bs) \<one>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fold (\<otimes>) (rev as) \<one> = fold (\<otimes>) (rev bs) \<one>

goal (1 subgoal):
 1. foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>
[PROOF STEP]
by (simp add: foldr_conv_fold)
[PROOF STATE]
proof (state)
this:
foldr (\<otimes>) as \<one> = foldr (\<otimes>) bs \<one>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fds_converges_uminus:
  assumes "fds_converges f s"
  shows   "fds_converges (-f) s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_converges (- f) s
[PROOF STEP]
using summable_minus[OF assms[unfolded fds_converges_def]]
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. - (fds_nth f n / nat_power n s))

goal (1 subgoal):
 1. fds_converges (- f) s
[PROOF STEP]
by (simp add: fds_converges_def add_divide_distrib)


[STATEMENT]
lemma compactin_subspace: "compactin X S \<longleftrightarrow> S \<subseteq> topspace X \<and> compact_space (subtopology X S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compactin X S = (S \<subseteq> topspace X \<and> compact_space (subtopology X S))
[PROOF STEP]
unfolding compact_space_def topspace_subtopology
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compactin X S = (S \<subseteq> topspace X \<and> compactin (subtopology X S) (topspace X \<inter> S))
[PROOF STEP]
by (metis compactin_absolute compactin_def inf.absorb2)


[STATEMENT]
lemma det_addcol[simp]:
  assumes l: "l < n" and k: "k \<noteq> l" and A: "A \<in> carrier_mat n n"
  shows "det (addcol a k l A) = det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
have "addcol a k l A = A * addrow_mat n a l k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. addcol a k l A = A * addrow_mat n a l k
[PROOF STEP]
using addcol_mat[OF A l]
[PROOF STATE]
proof (prove)
using this:
addcol ?a ?l l A = A * addrow_mat n ?a l ?l

goal (1 subgoal):
 1. addcol a k l A = A * addrow_mat n a l k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
addcol a k l A = A * addrow_mat n a l k

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
addcol a k l A = A * addrow_mat n a l k

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
have "det (A * addrow_mat n a l k) = det A * det (addrow_mat n a l k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (A * addrow_mat n a l k) = det A * det (addrow_mat n a l k)
[PROOF STEP]
by(rule det_mult[OF A], auto)
[PROOF STATE]
proof (state)
this:
det (A * addrow_mat n a l k) = det A * det (addrow_mat n a l k)

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (A * addrow_mat n a l k) = det A * det (addrow_mat n a l k)

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
have "det (addrow_mat n a l k) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (addrow_mat n a l k) = (1::'a)
[PROOF STEP]
using det_addrow_mat[OF k[symmetric]]
[PROOF STATE]
proof (prove)
using this:
det (addrow_mat ?n ?a l k) = (1::?'a)

goal (1 subgoal):
 1. det (addrow_mat n a l k) = (1::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
det (addrow_mat n a l k) = (1::'a)

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
det (addcol a k l A) = det A * (1::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
det (addcol a k l A) = det A * (1::'a)

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
det (addcol a k l A) = det A * (1::'a)
A \<in> carrier_mat n n

goal (1 subgoal):
 1. det (addcol a k l A) = det A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det (addcol a k l A) = det A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ccSUP_least: "countable A \<Longrightarrow> (\<And>i. i \<in> A \<Longrightarrow> f i \<le> u) \<Longrightarrow> (SUP i \<in> A. f i) \<le> u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; \<And>i. i \<in> A \<Longrightarrow> f i \<le> u\<rbrakk> \<Longrightarrow> Sup (f ` A) \<le> u
[PROOF STEP]
using ccSup_least [of "f ` A"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>countable (f ` A); \<And>x. x \<in> f ` A \<Longrightarrow> x \<le> ?z\<rbrakk> \<Longrightarrow> Sup (f ` A) \<le> ?z

goal (1 subgoal):
 1. \<lbrakk>countable A; \<And>i. i \<in> A \<Longrightarrow> f i \<le> u\<rbrakk> \<Longrightarrow> Sup (f ` A) \<le> u
[PROOF STEP]
by auto


[STATEMENT]
lemma "eupdate (PLUS (UINT 8 257) (UINT 16 100))
      = UINT 16 101"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eupdate (PLUS (UINT 8 257) (UINT 16 100)) = UINT 16 101
[PROOF STEP]
by(simp)


[STATEMENT]
lemma gcd_add_mult_commute: "gcd (m::'a::semiring_gcd) (n + k * m) = gcd m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd m (n + k * m) = gcd m n
[PROOF STEP]
by (metis add.commute gcd_add_mult)


[STATEMENT]
lemma dyad_rec_43 [simp]: "dyad_rec b l r ((4 * real m + 3) / 2 ^ (Suc n)) = r (dyad_rec b l r ((2*m + 1) / 2^n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dyad_rec b l r ((4 * real m + 3) / 2 ^ Suc n) = r (dyad_rec b l r ((2 * real m + 1) / 2 ^ n))
[PROOF STEP]
proof (rule dyad_rec.psimps)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dyad_rec_dom (b, l, r, (4 * real m + 3) / 2 ^ Suc n)
[PROOF STEP]
show "dyad_rec_dom (b, l, r, (4 * real m + 3) / 2 ^ Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dyad_rec_dom (b, l, r, (4 * real m + 3) / 2 ^ Suc n)
[PROOF STEP]
by (metis dyad_rec_level_termination lessI of_nat_add of_nat_mult of_nat_numeral)
[PROOF STATE]
proof (state)
this:
dyad_rec_dom (b, l, r, (4 * real m + 3) / 2 ^ Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem ltl_to_dra_size:
  "card (DRA.nodes (ltl_to_dra \<phi>)) \<le> 2 ^ 2 ^ (2 * size \<phi> + floorlog 2 (size \<phi>) + 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (DRA.nodes (ltl_to_dra \<phi>)) \<le> 2 ^ 2 ^ (2 * size \<phi> + floorlog 2 (size \<phi>) + 4)
[PROOF STEP]
using ltl_to_dra_nodes_card subfrmlsn_card
[PROOF STATE]
proof (prove)
using this:
card (subfrmlsn ?\<phi>) \<le> ?n \<Longrightarrow> card (DRA.nodes (ltl_to_dra ?\<phi>)) \<le> 2 ^ 2 ^ (2 * ?n + floorlog 2 ?n + 4)
card (subfrmlsn ?\<phi>) \<le> size ?\<phi>

goal (1 subgoal):
 1. card (DRA.nodes (ltl_to_dra \<phi>)) \<le> 2 ^ 2 ^ (2 * size \<phi> + floorlog 2 (size \<phi>) + 4)
[PROOF STEP]
by blast


[STATEMENT]
lemma len_Suc_mult2[simp]: "len (Suc (2 * x)) = Suc (len x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. len (Suc (2 * x)) = Suc (len x)
[PROOF STEP]
proof (induct x rule: len.induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. len (Suc (2 * 0)) = Suc (len 0)
 2. len (Suc (2 * Suc 0)) = Suc (len (Suc 0))
 3. \<And>va. len (Suc (2 * (Suc (Suc va) div 2))) = Suc (len (Suc (Suc va) div 2)) \<Longrightarrow> len (Suc (2 * Suc (Suc va))) = Suc (len (Suc (Suc va)))
[PROOF STEP]
show "len (Suc (2 * Suc 0)) = Suc (len (Suc 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. len (Suc (2 * Suc 0)) = Suc (len (Suc 0))
[PROOF STEP]
by (metis div_less One_nat_def div2_Suc_Suc len.simps(3) lessI mult.right_neutral numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
len (Suc (2 * Suc 0)) = Suc (len (Suc 0))

goal (2 subgoals):
 1. len (Suc (2 * 0)) = Suc (len 0)
 2. \<And>va. len (Suc (2 * (Suc (Suc va) div 2))) = Suc (len (Suc (Suc va) div 2)) \<Longrightarrow> len (Suc (2 * Suc (Suc va))) = Suc (len (Suc (Suc va)))
[PROOF STEP]
qed auto


[STATEMENT]
lemma poly_sum_list: "poly (sum_list ps) x = sum_list (map (\<lambda> p. poly p x) ps)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (sum_list ps) x = (\<Sum>p\<leftarrow>ps. poly p x)
[PROOF STEP]
by (induct ps, auto)


[STATEMENT]
lemma set_list_bind: "set (List.bind xs f) = (\<Union>x\<in>set xs. set (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (List.bind xs f) = (\<Union>x\<in>set xs. set (f x))
[PROOF STEP]
by (induction xs) simp_all


[STATEMENT]
lemma "\<forall>(x::'a::linordered_field) y z w.
  7 * x < 3 * y \<longrightarrow> 5 * y < 7 * z \<longrightarrow> z < 2 * w \<longrightarrow> 7 * (2 * w - x) > 2 * y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y z w. (7::'a) * x < (3::'a) * y \<longrightarrow> (5::'a) * y < (7::'a) * z \<longrightarrow> z < (2::'a) * w \<longrightarrow> (2::'a) * y < (7::'a) * ((2::'a) * w - x)
[PROOF STEP]
by ferrack


[STATEMENT]
lemma changes_snoc: fixes xs::"'a::linordered_idom list"
  shows "changes (xs @ [b, a]) = (if a * b < 0 then 1 + changes (xs @ [b])
         else if b = 0 then changes (xs @ [a]) else changes (xs @ [b]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes (xs @ [b, a]) = (if a * b < (0::'a) then 1 + changes (xs @ [b]) else if b = (0::'a) then changes (xs @ [a]) else changes (xs @ [b]))
[PROOF STEP]
apply (induction xs rule: changes.induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. changes ([] @ [b, a]) = (if a * b < (0::'a) then 1 + changes ([] @ [b]) else if b = (0::'a) then changes ([] @ [a]) else changes ([] @ [b]))
 2. \<And>uu_. changes ([uu_] @ [b, a]) = (if a * b < (0::'a) then 1 + changes ([uu_] @ [b]) else if b = (0::'a) then changes ([uu_] @ [a]) else changes ([uu_] @ [b]))
 3. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes ((x1 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # xs) @ [a]) else changes ((x1 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b]))\<rbrakk> \<Longrightarrow> changes ((x1 # x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # x2 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # x2 # xs) @ [a]) else changes ((x1 # x2 # xs) @ [b]))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes ([] @ [b, a]) = (if a * b < (0::'a) then 1 + changes ([] @ [b]) else if b = (0::'a) then changes ([] @ [a]) else changes ([] @ [b]))
[PROOF STEP]
by (force simp: mult_less_0_iff)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>uu_. changes ([uu_] @ [b, a]) = (if a * b < (0::'a) then 1 + changes ([uu_] @ [b]) else if b = (0::'a) then changes ([uu_] @ [a]) else changes ([uu_] @ [b]))
 2. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes ((x1 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # xs) @ [a]) else changes ((x1 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b]))\<rbrakk> \<Longrightarrow> changes ((x1 # x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # x2 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # x2 # xs) @ [a]) else changes ((x1 # x2 # xs) @ [b]))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes ([uu_] @ [b, a]) = (if a * b < (0::'a) then 1 + changes ([uu_] @ [b]) else if b = (0::'a) then changes ([uu_] @ [a]) else changes ([uu_] @ [b]))
[PROOF STEP]
by (force simp: mult_less_0_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes ((x1 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # xs) @ [a]) else changes ((x1 # xs) @ [b])); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes ((x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2 # xs) @ [b]) else if b = (0::'a) then changes ((x2 # xs) @ [a]) else changes ((x2 # xs) @ [b]))\<rbrakk> \<Longrightarrow> changes ((x1 # x2 # xs) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1 # x2 # xs) @ [b]) else if b = (0::'a) then changes ((x1 # x2 # xs) @ [a]) else changes ((x1 # x2 # xs) @ [b]))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x1_ * x2_ < (0::'a) \<Longrightarrow> changes ((x2_ # xs_) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2_ # xs_) @ [b]) else if b = (0::'a) then changes ((x2_ # xs_) @ [a]) else changes ((x2_ # xs_) @ [b])); \<lbrakk>\<not> x1_ * x2_ < (0::'a); x2_ = (0::'a)\<rbrakk> \<Longrightarrow> changes ((x1_ # xs_) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1_ # xs_) @ [b]) else if b = (0::'a) then changes ((x1_ # xs_) @ [a]) else changes ((x1_ # xs_) @ [b])); \<lbrakk>\<not> x1_ * x2_ < (0::'a); x2_ \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes ((x2_ # xs_) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x2_ # xs_) @ [b]) else if b = (0::'a) then changes ((x2_ # xs_) @ [a]) else changes ((x2_ # xs_) @ [b]))\<rbrakk> \<Longrightarrow> changes ((x1_ # x2_ # xs_) @ [b, a]) = (if a * b < (0::'a) then 1 + changes ((x1_ # x2_ # xs_) @ [b]) else if b = (0::'a) then changes ((x1_ # x2_ # xs_) @ [a]) else changes ((x1_ # x2_ # xs_) @ [b]))
[PROOF STEP]
by force
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ex_k1_k2:
  assumes coprime: "coprime (e :: nat) ((P-1)*(Q-1))"
    and " [e*d = 1] (mod (P-1))"
  shows "\<exists> k1 k2. e*d + k1*(P-1) = 1 + k2*(P-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k1 k2. e * d + k1 * (P - 1) = 1 + k2 * (P - 1)
[PROOF STEP]
by (metis assms(2) cong_iff_lin_nat)


[STATEMENT]
lemma dvd_imp_gcd_dvd_gcd: "b dvd c \<Longrightarrow> gcd a b dvd gcd a c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b dvd c \<Longrightarrow> gcd a b dvd gcd a c
[PROOF STEP]
by (meson gcd_dvd1 gcd_dvd2 gcd_greatest dvd_trans)


[STATEMENT]
lemma  orthogonal_matrix: "orthogonal_matrix (Q:: real ^'n^'n) \<longleftrightarrow> transpose Q ** Q = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_matrix Q = (Finite_Cartesian_Product.transpose Q ** Q = mat 1)
[PROOF STEP]
by (metis matrix_left_right_inverse orthogonal_matrix_def)


[STATEMENT]
lemma divisibility_equations:
  assumes 0: "m = k*l" and "b>2" "m>0"
  shows  "A b m = mat_pow l (mat_minus (mat_scalar_mult (\<alpha> b k) (B b))
                                        (mat_scalar_mult (\<alpha> b (k-1)) ID))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A b m = mat_pow l (mat_minus (mat_scalar_mult (\<alpha> b k) (B b)) (mat_scalar_mult (\<alpha> b (k - 1)) ID))
[PROOF STEP]
apply (auto simp del: mat_pow.simps mat_mul.simps mat_minus.simps mat_scalar_mult.simps
                simp add: A_pow mult.commute[of k l] assms mat_exp_law_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_pow l (mat_pow k (B b)) = mat_pow l (mat_minus (mat_scalar_mult (\<alpha> b k) (B b)) (mat_scalar_mult (\<alpha> b (k - Suc 0)) ID))
[PROOF STEP]
using A_pow[of b k] \<open>m>0\<close>
[PROOF STATE]
proof (prove)
using this:
2 < b \<Longrightarrow> A b k = mat_pow k (B b)
0 < m

goal (1 subgoal):
 1. mat_pow l (mat_pow k (B b)) = mat_pow l (mat_minus (mat_scalar_mult (\<alpha> b k) (B b)) (mat_scalar_mult (\<alpha> b (k - Suc 0)) ID))
[PROOF STEP]
apply (auto simp: A.simps \<open>m>0\<close> ID_def B.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 < b \<Longrightarrow> A b k = mat_pow k (mat (int b) (- 1) 1 0)) \<Longrightarrow> mat_pow l (mat_pow k (mat (int b) (- 1) 1 0)) = mat_pow l (mat (\<alpha> b k * int b - \<alpha> b (k - Suc 0)) (- \<alpha> b k) (\<alpha> b k) (- \<alpha> b (k - Suc 0)))
[PROOF STEP]
using A.simps(2) alpha_n One_nat_def Suc_eq_plus1 Suc_pred assms \<open>m>0\<close> assms
        mult.commute nat_0_less_mult_iff
[PROOF STATE]
proof (prove)
using this:
A ?b (Suc ?v) = mat (\<alpha> ?b (Suc ?v + 1)) (- \<alpha> ?b (Suc ?v)) (\<alpha> ?b (Suc ?v)) (- \<alpha> ?b (Suc ?v - 1))
\<alpha> ?b (Suc (Suc ?n)) = int ?b * \<alpha> ?b (Suc ?n) - \<alpha> ?b ?n
1 = Suc 0
Suc ?n = ?n + 1
0 < ?n \<Longrightarrow> Suc (?n - Suc 0) = ?n
m = k * l
2 < b
0 < m
0 < m
m = k * l
2 < b
0 < m
?a * ?b = ?b * ?a
(0 < ?m * ?n) = (0 < ?m \<and> 0 < ?n)

goal (1 subgoal):
 1. (2 < b \<Longrightarrow> A b k = mat_pow k (mat (int b) (- 1) 1 0)) \<Longrightarrow> mat_pow l (mat_pow k (mat (int b) (- 1) 1 0)) = mat_pow l (mat (\<alpha> b k * int b - \<alpha> b (k - Suc 0)) (- \<alpha> b k) (\<alpha> b k) (- \<alpha> b (k - Suc 0)))
[PROOF STEP]
by (smt mat_exp_law_mult)


[STATEMENT]
lemma euler_mascheroni_sequence_decreasing:
  "m > 0 \<Longrightarrow> m \<le> n \<Longrightarrow> harm n - ln (of_nat n) \<le> harm m - ln (of_nat m :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; m \<le> n\<rbrakk> \<Longrightarrow> harm n - ln (real n) \<le> harm m - ln (real m)
[PROOF STEP]
using decseqD[OF decseq_harm_diff_ln, of "m - 1" "n - 1"]
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> n - 1 \<Longrightarrow> harm (Suc (n - 1)) - ln (real (Suc (n - 1))) \<le> harm (Suc (m - 1)) - ln (real (Suc (m - 1)))

goal (1 subgoal):
 1. \<lbrakk>0 < m; m \<le> n\<rbrakk> \<Longrightarrow> harm n - ln (real n) \<le> harm m - ln (real m)
[PROOF STEP]
by simp


[STATEMENT]
lemma ennreal_spmf_lub_spmf: "Y \<noteq> {} \<Longrightarrow> ennreal (spmf lub_spmf x) = (SUP p\<in>Y. ennreal (spmf p x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Y \<noteq> {} \<Longrightarrow> ennreal (spmf local.lub_spmf x) = (\<Squnion>p\<in>Y. ennreal (spmf p x))
[PROOF STEP]
unfolding spmf_lub_spmf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Y \<noteq> {} \<Longrightarrow> ennreal (\<Squnion>p\<in>Y. spmf p x) = (\<Squnion>p\<in>Y. ennreal (spmf p x))
[PROOF STEP]
by(subst ennreal_SUP)(simp_all add: SUP_spmf_neq_top' del: SUP_eq_top_iff Sup_eq_top_iff)


[STATEMENT]
lemma neglD: "negl f \<Longrightarrow> c > 0 \<Longrightarrow> eventually (\<lambda>x. \<bar>f x\<bar> \<le> c / ln (b*x) powr (e/2+1)) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> o(\<lambda>x. ln (b * x) powr - (e / 2 + 1)); 0 < c\<rbrakk> \<Longrightarrow> \<forall>\<^sub>F x in at_top. \<bar>f x\<bar> \<le> c / ln (b * x) powr (e / 2 + 1)
[PROOF STEP]
by (drule (1) landau_o.smallD, subst (asm) powr_minus) (simp add: field_simps)


[STATEMENT]
lemma ternary_eval: "eval (TERNARY R P\<^sub>1 P\<^sub>2 P\<^sub>3) a = R (peval P\<^sub>1 a) (peval P\<^sub>2 a) (peval P\<^sub>3 a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval (TERNARY R P\<^sub>1 P\<^sub>2 P\<^sub>3) a = R (peval P\<^sub>1 a) (peval P\<^sub>2 a) (peval P\<^sub>3 a)
[PROOF STEP]
unfolding TERNARY_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval (NARY (\<lambda>l. R (l ! 0) (l ! 1) (l ! 2)) [P\<^sub>1, P\<^sub>2, P\<^sub>3]) a = R (peval P\<^sub>1 a) (peval P\<^sub>2 a) (peval P\<^sub>3 a)
[PROOF STEP]
by simp


[STATEMENT]
lemma integral_restrict:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  assumes "S \<subseteq> T" "S \<in> sets lebesgue" "T \<in> sets lebesgue"
  shows "integral\<^sup>L (lebesgue_on T) (\<lambda>x. if x \<in> S then f x else 0) = integral\<^sup>L (lebesgue_on S) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|lebesgue_on T. (if x \<in> S then f x else (0::'b)) = integral\<^sup>L (lebesgue_on S) f
[PROOF STEP]
using integral_restrict_Int [of S T f] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>S \<in> sets lebesgue; T \<in> sets lebesgue\<rbrakk> \<Longrightarrow> LINT x|lebesgue_on T. (if x \<in> S then f x else (0::'b)) = integral\<^sup>L (lebesgue_on (S \<inter> T)) f
S \<subseteq> T
S \<in> sets lebesgue
T \<in> sets lebesgue

goal (1 subgoal):
 1. LINT x|lebesgue_on T. (if x \<in> S then f x else (0::'b)) = integral\<^sup>L (lebesgue_on S) f
[PROOF STEP]
by (simp add: Int_absorb2)


[STATEMENT]
lemma freq_mergeSibling:
"\<lbrakk>consistent t; a \<in> alphabet t; sibling t a \<noteq> a\<rbrakk> \<Longrightarrow>
 freq (mergeSibling t a) =
     (\<lambda>c. if c = a then freq t a + freq t (sibling t a)
          else if c = sibling t a then 0
          else freq t c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>consistent t; a \<in> alphabet t; sibling t a \<noteq> a\<rbrakk> \<Longrightarrow> freq (mergeSibling t a) = (\<lambda>c. if c = a then freq t a + freq t (sibling t a) else if c = sibling t a then 0 else freq t c)
[PROOF STEP]
by (induct t a rule: mergeSibling_induct_consistent) (auto simp: fun_eq_iff)


[STATEMENT]
lemma set_sel'_eq_set_sel: "set_sel' f X Y = set_sel f X Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_sel' f X Y = set_sel f X Y
[PROOF STEP]
unfolding set_sel_def set_sel_aux_def set_sel'_def set_sel_aux'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>y\<in>Y. \<Prod>x\<in>X. f x y) = (\<Prod>x\<in>X. prod (f x) Y)
[PROOF STEP]
using prod.swap
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i\<in>?A. prod (?g i) ?B) = (\<Prod>j\<in>?B. \<Prod>i\<in>?A. ?g i j)

goal (1 subgoal):
 1. (\<Prod>y\<in>Y. \<Prod>x\<in>X. f x y) = (\<Prod>x\<in>X. prod (f x) Y)
[PROOF STEP]
by fast