[STATEMENT]
lemma mod_pCons:
  fixes a :: "'a::field"
    and x y :: "'a::field poly"
  assumes y: "y \<noteq> 0"
  defines "b \<equiv> coeff (pCons a (x mod y)) (degree y) / coeff y (degree y)"
  shows "(pCons a x) mod y = pCons a (x mod y) - smult b y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pCons a x mod y = pCons a (x mod y) - smult b y
[PROOF STEP]
unfolding b_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pCons a x mod y = pCons a (x mod y) - smult (coeff (pCons a (x mod y)) (degree y) / lead_coeff y) y
[PROOF STEP]
by (simp add: mod_pCons_eq)


[STATEMENT]
lemma hypext_inverse_extract:
  "x \<noteq> 0 \<Longrightarrow> (*h* inverse) (\<beta> x) = inverse x *\<^sub>H ba - (1 / x\<^sup>2) *\<^sub>H e1 - (1 / x\<^sup>2) *\<^sub>H e2 + (2 / x ^ 3) *\<^sub>H e12"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> (*h* inverse) (\<beta> x) = inverse x *\<^sub>H ba - ((1::'a) / x\<^sup>2) *\<^sub>H e1 - ((1::'a) / x\<^sup>2) *\<^sub>H e2 + ((2::'a) / x ^ 3) *\<^sub>H e12
[PROOF STEP]
by (simp add: hypext_extract_eq divide_inverse of_comp_minus scaleH_times)


[STATEMENT]
lemma set_plus_rearrange: "(a +o C) + (b +o D) = (a + b) +o (C + D)"
  for a b :: "'a::comm_monoid_add"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a +o C + b +o D = (a + b) +o (C + D)
[PROOF STEP]
by (auto simp: elt_set_plus_def set_plus_def; metis group_cancel.add1 group_cancel.add2)


[STATEMENT]
lemma fstar_unfoldr [simp]:
  fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
  shows "Inf_pres f \<Longrightarrow> id \<sqinter> (fstar f \<circ> f) = fstar f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> id \<sqinter> (fstar f \<circ> f) = fstar f
[PROOF STEP]
using fstar_comm fstar_unfoldl
[PROOF STATE]
proof (prove)
using this:
Inf_pres ?f \<Longrightarrow> ?f \<circ> fstar ?f = fstar ?f \<circ> ?f
Inf_pres ?f \<Longrightarrow> id \<sqinter> (?f \<circ> fstar ?f) = fstar ?f

goal (1 subgoal):
 1. Inf_pres f \<Longrightarrow> id \<sqinter> (fstar f \<circ> f) = fstar f
[PROOF STEP]
by fastforce


[STATEMENT]
lemma wfp_on_imp_has_min_elt:
  assumes "wfp_on P A" and "A \<noteq> {}"
  shows "\<exists>x\<in>A. \<forall>y\<in>A. \<not> P y x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>A. \<forall>y\<in>A. \<not> P y x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wfp_on P A
A \<noteq> {}

goal (1 subgoal):
 1. \<exists>x\<in>A. \<forall>y\<in>A. \<not> P y x
[PROOF STEP]
unfolding wfp_on_iff_minimal
[PROOF STATE]
proof (prove)
using this:
\<forall>Q x. x \<in> Q \<and> Q \<subseteq> A \<longrightarrow> (\<exists>z\<in>Q. \<forall>y. P y z \<longrightarrow> y \<notin> Q)
A \<noteq> {}

goal (1 subgoal):
 1. \<exists>x\<in>A. \<forall>y\<in>A. \<not> P y x
[PROOF STEP]
by force


[STATEMENT]
lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
  for w :: "'a::order"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SIGMA i:A. {..v i}) \<inter> (SIGMA i:A. {v i<..w}) = {}
[PROOF STEP]
by auto


[STATEMENT]
lemma content_0_subset: "content(cbox a b) = 0 \<Longrightarrow> s \<subseteq> cbox a b \<Longrightarrow> content s = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>content (cbox a b) = 0; s \<subseteq> cbox a b\<rbrakk> \<Longrightarrow> content s = 0
[PROOF STEP]
using emeasure_mono[of s "cbox a b" lborel]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>s \<subseteq> cbox a b; cbox a b \<in> sets lborel\<rbrakk> \<Longrightarrow> emeasure lborel s \<le> emeasure lborel (cbox a b)

goal (1 subgoal):
 1. \<lbrakk>content (cbox a b) = 0; s \<subseteq> cbox a b\<rbrakk> \<Longrightarrow> content s = 0
[PROOF STEP]
by (auto simp: measure_def enn2real_eq_0_iff emeasure_lborel_cbox_eq)


[STATEMENT]
lemma ennreal_mult_top: "a * top = (if a = 0 then 0 else top :: ennreal)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * top = (if a = 0 then 0 else top)
[PROOF STEP]
by (simp add: ennreal_mult_eq_top_iff)


[STATEMENT]
lemma pmf_expectation_bind_pmf_of_set:
  fixes A :: "'a set" and f :: "'a \<Rightarrow> 'b pmf"
    and  h :: "'b \<Rightarrow> 'c::{banach, second_countable_topology}"
  assumes "A \<noteq> {}" "finite A" "\<And>x. x \<in> A \<Longrightarrow> finite (set_pmf (f x))"
  shows "measure_pmf.expectation (pmf_of_set A \<bind> f) h =
           (\<Sum>a\<in>A. measure_pmf.expectation (f a) h /\<^sub>R real (card A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (local.pmf_of_set A \<bind> f) h = (\<Sum>a\<in>A. measure_pmf.expectation (f a) h /\<^sub>R real (card A))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {}
finite A
?x2 \<in> A \<Longrightarrow> finite (set_pmf (f ?x2))

goal (1 subgoal):
 1. measure_pmf.expectation (local.pmf_of_set A \<bind> f) h = (\<Sum>a\<in>A. measure_pmf.expectation (f a) h /\<^sub>R real (card A))
[PROOF STEP]
by (subst pmf_expectation_bind[of A]) (auto simp: field_split_simps)


[STATEMENT]
lemma [code]:
  "lagrange_basis_poly xs xj = (let ys = filter (\<lambda> x. x \<noteq> xj) xs
    in prod_list (map (\<lambda> xi. let ii = inverse (xj - xi) in [: - ii * xi, ii :]) ys))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lagrange_basis_poly xs xj = (let ys = filter (\<lambda>x. x \<noteq> xj) xs in \<Prod>xi\<leftarrow>ys. let ii = inverse (xj - xi) in [:- ii * xi, ii:])
[PROOF STEP]
unfolding lagrange_basis_poly_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>xi\<leftarrow>filter (\<lambda>x. x \<noteq> xj) xs. smult (inverse (xj - xi)) [:- xi, 1::'a:]) = (\<Prod>xi\<leftarrow>filter (\<lambda>x. x \<noteq> xj) xs. [:- inverse (xj - xi) * xi, inverse (xj - xi):])
[PROOF STEP]
by simp


[STATEMENT]
lemma det_linear_row_finsum:
  assumes fS: "finite S" and c: "c \<in> {0..<n} \<rightarrow> carrier_vec n" and k: "k < n"
  and a: "a k \<in> S \<rightarrow> carrier_vec n"
  shows "det (mat\<^sub>r n n (\<lambda> i. if i = k then finsum_vec TYPE('a :: comm_ring_1) n (a i) S else c i)) =
    sum (\<lambda>j. det (mat\<^sub>r n n (\<lambda> i. if i = k then a  i j else c i))) S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
let ?sum = "finsum_vec TYPE('a) n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
a k \<in> S \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
proof (induct rule: finite_induct[OF fS])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a k \<in> {} \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) {} else c i)) = (\<Sum>j\<in>{}. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
a k \<in> {} \<rightarrow> carrier_vec n

goal (2 subgoals):
 1. a k \<in> {} \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) {} else c i)) = (\<Sum>j\<in>{}. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) {} else c i)) = (\<Sum>j\<in>{}. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
by (simp, unfold finsum_vec_empty, rule det_row_0[OF k c])
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) {} else c i)) = (\<Sum>j\<in>{}. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
case (2 x F)
[PROOF STATE]
proof (state)
this:
finite F
x \<notin> F
a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
a k \<in> insert x F \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
from 2(4)
[PROOF STATE]
proof (chain)
picking this:
a k \<in> insert x F \<rightarrow> carrier_vec n
[PROOF STEP]
have ak: "a k \<in> F \<rightarrow> carrier_vec n" and akx: "a k x \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
a k \<in> insert x F \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. a k \<in> F \<rightarrow> carrier_vec n &&& a k x \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a k \<in> F \<rightarrow> carrier_vec n
a k x \<in> carrier_vec n

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
a k \<in> F \<rightarrow> carrier_vec n
a k x \<in> carrier_vec n

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
note if_cong[OF refl finsum_vec_insert[OF 2(1-2)],
        of _ "a i" n "c i" "c i"]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?b \<Longrightarrow> a i \<in> F \<rightarrow> carrier_vec n; ?b \<Longrightarrow> a i x \<in> carrier_vec n; \<not> ?b \<Longrightarrow> c i = c i\<rbrakk> \<Longrightarrow> (if ?b then finsum_vec TYPE('a) n (a i) (insert x F) else c i) = (if ?b then a i x + finsum_vec TYPE('a) n (a i) F else c i)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?b \<Longrightarrow> a ?i3 \<in> F \<rightarrow> carrier_vec n; ?b \<Longrightarrow> a ?i3 x \<in> carrier_vec n; \<not> ?b \<Longrightarrow> c ?i3 = c ?i3\<rbrakk> \<Longrightarrow> (if ?b then finsum_vec TYPE('a) n (a ?i3) (insert x F) else c ?i3) = (if ?b then a ?i3 x + finsum_vec TYPE('a) n (a ?i3) F else c ?i3)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
note * = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?b \<Longrightarrow> a ?i3 \<in> F \<rightarrow> carrier_vec n; ?b \<Longrightarrow> a ?i3 x \<in> carrier_vec n; \<not> ?b \<Longrightarrow> c ?i3 = c ?i3\<rbrakk> \<Longrightarrow> (if ?b then finsum_vec TYPE('a) n (a ?i3) (insert x F) else c ?i3) = (if ?b then a ?i3 x + finsum_vec TYPE('a) n (a ?i3) F else c ?i3)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; a k \<in> F \<rightarrow> carrier_vec n \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))); a k \<in> insert x F \<rightarrow> carrier_vec n\<rbrakk> \<Longrightarrow> det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
proof (subst *)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>i. i = k \<Longrightarrow> a i \<in> F \<rightarrow> carrier_vec n
 2. \<And>i. i = k \<Longrightarrow> a i x \<in> carrier_vec n
 3. \<And>i. i \<noteq> k \<Longrightarrow> c i = c i
 4. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x + finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
show "det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x + ?sum (a i) F else c i)) =
        (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x + finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
proof (subst det_row_add)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. a k x \<in> carrier_vec n
 2. finsum_vec TYPE('a) n (a k) F \<in> carrier_vec n
 3. c \<in> {0..<n} \<rightarrow> carrier_vec n
 4. k < n
 5. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) + det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
show "det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) +
          det (mat\<^sub>r n n (\<lambda>i. if i = k then ?sum (a i) F else c i)) =
        (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) + det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
unfolding 2(3)[OF ak] sum.insert[OF 2(1-2)]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) + (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i))) = det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) + (\<Sum>j\<in>F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x else c i)) + det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))

goal (4 subgoals):
 1. a k x \<in> carrier_vec n
 2. finsum_vec TYPE('a) n (a k) F \<in> carrier_vec n
 3. c \<in> {0..<n} \<rightarrow> carrier_vec n
 4. k < n
[PROOF STEP]
qed (insert c k ak akx 2(1),
        auto intro!: finsum_vec_closed)
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then a i x + finsum_vec TYPE('a) n (a i) F else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))

goal (3 subgoals):
 1. \<And>i. i = k \<Longrightarrow> a i \<in> F \<rightarrow> carrier_vec n
 2. \<And>i. i = k \<Longrightarrow> a i x \<in> carrier_vec n
 3. \<And>i. i \<noteq> k \<Longrightarrow> c i = c i
[PROOF STEP]
qed (insert akx ak, force+)
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) (insert x F) else c i)) = (\<Sum>j\<in>insert x F. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then finsum_vec TYPE('a) n (a i) S else c i)) = (\<Sum>j\<in>S. det (mat\<^sub>r n n (\<lambda>i. if i = k then a i j else c i)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_list_pow_suc: "(\<Prod>x\<leftarrow>bs. (x :: 'a :: comm_monoid_mult) * x ^ i)
  = prod_list bs * prod_list bs ^ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>x\<leftarrow>bs. x * x ^ i) = prod_list bs * prod_list bs ^ i
[PROOF STEP]
by (induct bs, auto simp: field_simps)


[STATEMENT]
lemma span_0_imp_set_empty_or_0:
  assumes "span A = {0}"
  shows "A = {} \<or> A = {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = {} \<or> A = {0::'b}
[PROOF STEP]
by (metis assms span_superset subset_singletonD)


[STATEMENT]
lemma nonzero_fraction_imp_numer_not_zero:
  assumes "a \<in> carrier Z\<^sub>p"
  assumes "b \<in> nonzero Z\<^sub>p"
  assumes "frac a b \<noteq> \<zero>"
  shows "a \<noteq> \<zero>\<^bsub>Z\<^sub>p\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> \<zero>\<^bsub>Z\<^sub>p\<^esub>
[PROOF STEP]
using assms fraction_zero Q\<^sub>p_def
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier Z\<^sub>p
b \<in> nonzero Z\<^sub>p
fraction Z\<^sub>p a b \<noteq> \<zero>
?b \<in> nonzero Z\<^sub>p \<Longrightarrow> fraction Z\<^sub>p \<zero>\<^bsub>Z\<^sub>p\<^esub> ?b = \<zero>\<^bsub>Frac Z\<^sub>p\<^esub>
Q\<^sub>p \<equiv> Frac Z\<^sub>p

goal (1 subgoal):
 1. a \<noteq> \<zero>\<^bsub>Z\<^sub>p\<^esub>
[PROOF STEP]
by blast


[STATEMENT]
lemma count_rem_components_alt:
  "count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) =
    card (component_of_term ` Keys (fst ` set bs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
have eq: "fst ` {x \<in> set bs. fst x \<noteq> 0} = fst ` set bs - {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst ` {x \<in> set bs. fst x \<noteq> 0} = fst ` set bs - {0}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
fst ` {x \<in> set bs. fst x \<noteq> 0} = fst ` set bs - {0}

goal (1 subgoal):
 1. count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
have "card (const_lt_component ` (fst ` set bs - {0}) - {None}) \<le> card (component_of_term ` Keys (fst ` set bs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (const_lt_component ` (fst ` set bs - {0}) - {None}) \<le> card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
by (rule card_const_lt_component_le, rule finite_imageI, fact finite_set)
[PROOF STATE]
proof (state)
this:
card (const_lt_component ` (fst ` set bs - {0}) - {None}) \<le> card (component_of_term ` Keys (fst ` set bs))

goal (1 subgoal):
 1. count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card (const_lt_component ` (fst ` set bs - {0}) - {None}) \<le> card (component_of_term ` Keys (fst ` set bs))

goal (1 subgoal):
 1. count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))
[PROOF STEP]
by (simp add: count_rem_components_def card_set[symmetric] set_Keys_to_list count_const_lt_components_alt eq)
[PROOF STATE]
proof (state)
this:
count_rem_components bs + card (const_lt_component ` (fst ` set bs - {0}) - {None}) = card (component_of_term ` Keys (fst ` set bs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma p_Suc: "ennreal (p x y (Suc n)) = (\<integral>\<^sup>+ w. p w y n \<partial>K x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (p x y (Suc n)) = \<integral>\<^sup>+ x. ennreal (p x y n) \<partial>measure_pmf (K x)
[PROOF STEP]
unfolding p_def T.emeasure_eq_measure[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (T x) {\<omega> \<in> space (T x). (x ## \<omega>) !! Suc n = y} = \<integral>\<^sup>+ x. emeasure (T x) {\<omega> \<in> space (T x). (x ## \<omega>) !! n = y} \<partial>measure_pmf (K x)
[PROOF STEP]
by (subst emeasure_Collect_T) simp_all


[STATEMENT]
lemma homotopy_eqv_cohomotopic_triviality_null:
  fixes S :: "'a::real_normed_vector set"
    and T :: "'b::real_normed_vector set"
    and U :: "'c::real_normed_vector set"
  assumes "S homotopy_eqv T"
    shows "(\<forall>f. continuous_on S f \<and> f ` S \<subseteq> U
                \<longrightarrow> (\<exists>c. homotopic_with_canon (\<lambda>x. True) S U f (\<lambda>x. c))) \<longleftrightarrow>
           (\<forall>f. continuous_on T f \<and> f ` T \<subseteq> U
                \<longrightarrow> (\<exists>c. homotopic_with_canon (\<lambda>x. True) T U f (\<lambda>x. c)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>f. continuous_on S f \<and> f ` S \<subseteq> U \<longrightarrow> (\<exists>c. homotopic_with_canon (\<lambda>x. True) S U f (\<lambda>x. c))) = (\<forall>f. continuous_on T f \<and> f ` T \<subseteq> U \<longrightarrow> (\<exists>c. homotopic_with_canon (\<lambda>x. True) T U f (\<lambda>x. c)))
[PROOF STEP]
by (rule iffI; metis assms homotopy_eqv_cohomotopic_triviality_null_imp homotopy_equivalent_space_sym)


[STATEMENT]
lemma zero_less_iff_1_le_zhmset: "0 < n \<longleftrightarrow> 1 \<le> n" for n :: zhmultiset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < n) = (1 \<le> n)
[PROOF STEP]
by (rule less_iff_add1_le_zhmset[of 0, simplified])


[STATEMENT]
lemma lemma_Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>"
  for x :: hypreal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> Infinitesimal; 0 < N\<rbrakk> \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>
[PROOF STEP]
apply (clarsimp simp: Infinitesimal_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>r\<in>\<real>. 0 < r \<longrightarrow> \<bar>x\<bar> < r; 0 < N\<rbrakk> \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>
[PROOF STEP]
by (metis Reals_1 abs_ge_zero hyperpow_Suc_le_self2 hyperpow_hrabs hypnat_gt_zero_iff2 zero_less_one)


[STATEMENT]
lemma the_br[simp]:
    assumes "single_valued R"
    shows "br (the_br_\<alpha> R) (the_br_invar R) = R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. br (the_br_\<alpha> R) (\<lambda>x. x \<in> Domain R) = R
[PROOF STEP]
unfolding build_rel_def the_br_\<alpha>_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(c, a). a = (SOME y. (c, y) \<in> R) \<and> c \<in> Domain R} = R
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a ba. (a, ba) \<in> R \<Longrightarrow> (a, SOME y. (a, y) \<in> R) \<in> R
 2. \<And>a b. (a, b) \<in> R \<Longrightarrow> b = (SOME y. (a, y) \<in> R)
[PROOF STEP]
apply (metis someI_ex)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> R \<Longrightarrow> b = (SOME y. (a, y) \<in> R)
[PROOF STEP]
apply (metis assms someI_ex single_valuedD)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nat_mirror_add: "
  nat_mirror (n + k) l r = (nat_mirror n l r) - k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_mirror (n + k) l r = nat_mirror n l r - k
[PROOF STEP]
unfolding nat_mirror_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l + r - (n + k) = l + r - n - k
[PROOF STEP]
by simp


[STATEMENT]
lemma enat_add_left_cancel_less: "a + b < a + c \<longleftrightarrow> a \<noteq> (\<infinity>::enat) \<and> b < c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + b < a + c) = (a \<noteq> \<infinity> \<and> b < c)
[PROOF STEP]
unfolding plus_enat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((case a of enat m \<Rightarrow> case b of enat n \<Rightarrow> enat (m + n) | \<infinity> \<Rightarrow> \<infinity> | \<infinity> \<Rightarrow> \<infinity>) < (case a of enat m \<Rightarrow> case c of enat n \<Rightarrow> enat (m + n) | \<infinity> \<Rightarrow> \<infinity> | \<infinity> \<Rightarrow> \<infinity>)) = (a \<noteq> \<infinity> \<and> b < c)
[PROOF STEP]
by (simp split: enat.split)


[STATEMENT]
lemma combine_rabin_pairs:
  "(\<And>x. x \<in> I \<Longrightarrow> accepting_pair\<^sub>R \<delta> q\<^sub>0 (f x, g x) w) \<Longrightarrow> accepting_pair\<^sub>G\<^sub>R \<delta> q\<^sub>0 (\<Union>{f x | x. x \<in> I}, {g x | x. x \<in> I}) w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> I \<Longrightarrow> accepting_pair\<^sub>R \<delta> q\<^sub>0 (f x, g x) w) \<Longrightarrow> accepting_pair\<^sub>G\<^sub>R \<delta> q\<^sub>0 (\<Union> {f x |x. x \<in> I}, {g x |x. x \<in> I}) w
[PROOF STEP]
by auto


[STATEMENT]
lemma valid_fml_equiv: "valid (\<phi> \<leftrightarrow> \<psi>) = fml_equiv \<phi> \<psi>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid (\<phi> \<leftrightarrow> \<psi>) = fml_equiv \<phi> \<psi>
[PROOF STEP]
unfolding valid_def Equiv_def Or_def fml_equiv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>I \<omega>. \<omega> \<in> fml_sem I (! (! (\<phi> && \<psi>) && ! (! \<phi> && ! \<psi>)))) = (\<forall>I. fml_sem I \<phi> = fml_sem I \<psi>)
[PROOF STEP]
by auto


[STATEMENT]
lemma fin_dim_span_rows:
assumes A: "A \<in> carrier_mat nr n"
shows "vectorspace.fin_dim class_ring (vs (span (set (rows A))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vectorspace.fin_dim class_ring (vs (local.span (set (rows A))))
[PROOF STEP]
proof (rule fin_dim_span)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (set (rows A))
 2. set (rows A) \<subseteq> carrier V
[PROOF STEP]
show "set (rows A) \<subseteq> carrier V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (rows A) \<subseteq> carrier V
[PROOF STEP]
using A rows_carrier[of A]
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat nr n
set (rows A) \<subseteq> carrier_vec (dim_col A)

goal (1 subgoal):
 1. set (rows A) \<subseteq> carrier V
[PROOF STEP]
unfolding carrier_mat_def
[PROOF STATE]
proof (prove)
using this:
A \<in> {m. dim_row m = nr \<and> dim_col m = n}
set (rows A) \<subseteq> carrier_vec (dim_col A)

goal (1 subgoal):
 1. set (rows A) \<subseteq> carrier V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (rows A) \<subseteq> carrier V

goal (1 subgoal):
 1. finite (set (rows A))
[PROOF STEP]
show "finite (set (rows A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (set (rows A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (set (rows A))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma reachable_conv:
  "u \<rightarrow>\<^sup>* v \<longleftrightarrow> (u,v) \<in> (arcs_ends G)^* \<inter> (verts G \<times> verts G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u \<rightarrow>\<^sup>* v) = ((u, v) \<in> Restr ((arcs_ends G)\<^sup>*) (verts G))
[PROOF STEP]
apply (auto intro: reachable_in_verts)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(u, v) \<in> (arcs_ends G)\<^sup>*; u \<in> verts G; v \<in> verts G\<rbrakk> \<Longrightarrow> u \<rightarrow>\<^sup>* v
[PROOF STEP]
apply (induct rule: rtrancl_induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>u \<in> verts G; u \<in> verts G\<rbrakk> \<Longrightarrow> u \<rightarrow>\<^sup>* u
 2. \<And>y z. \<lbrakk>(u, y) \<in> (arcs_ends G)\<^sup>*; y \<rightarrow> z; \<lbrakk>u \<in> verts G; y \<in> verts G\<rbrakk> \<Longrightarrow> u \<rightarrow>\<^sup>* y; u \<in> verts G; z \<in> verts G\<rbrakk> \<Longrightarrow> u \<rightarrow>\<^sup>* z
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nn_integral_indicator_finite:
  fixes f :: "'a \<Rightarrow> ennreal"
  assumes f: "finite A" and [measurable]: "\<And>a. a \<in> A \<Longrightarrow> {a} \<in> sets M"
  shows "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = (\<Sum>x\<in>A. f x * emeasure M {x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
from f
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
have "(\<integral>\<^sup>+x. f x * indicator A x \<partial>M) = (\<integral>\<^sup>+x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M)"
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = \<integral>\<^sup>+ x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M
[PROOF STEP]
by (intro nn_integral_cong) (auto simp: indicator_def if_distrib[where f="\<lambda>a. x * a" for x] sum.If_cases)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * indicator A x \<partial>M = \<integral>\<^sup>+ x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * indicator A x \<partial>M = \<integral>\<^sup>+ x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
have "\<dots> = (\<Sum>a\<in>A. f a * emeasure M {a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M = (\<Sum>a\<in>A. f a * emeasure M {a})
[PROOF STEP]
by (subst nn_integral_sum) auto
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. (\<Sum>a\<in>A. f a * indicator {a} x) \<partial>M = (\<Sum>a\<in>A. f a * emeasure M {a})

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>a\<in>A. f a * emeasure M {a})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>a\<in>A. f a * emeasure M {a})

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. f x * indicator A x \<partial>M = (\<Sum>x\<in>A. f x * emeasure M {x})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dg_prod_ArrD:
  assumes "f \<in>\<^sub>\<circ> (\<Prod>\<^sub>D\<^sub>Gi\<in>\<^sub>\<circ>I. \<AA> i)\<lparr>Arr\<rparr>"
  shows "vsv f" and "\<D>\<^sub>\<circ> f = I" and "\<And>i. i \<in>\<^sub>\<circ> I \<Longrightarrow> f\<lparr>i\<rparr> \<in>\<^sub>\<circ> \<AA> i\<lparr>Arr\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vsv f &&& \<D>\<^sub>\<circ> f = I &&& (\<And>i. i \<in>\<^sub>\<circ> I \<Longrightarrow> f\<lparr>i\<rparr> \<in>\<^sub>\<circ> \<AA> i\<lparr>Arr\<rparr>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in>\<^sub>\<circ> dg_prod I \<AA>\<lparr>Arr\<rparr>

goal (1 subgoal):
 1. vsv f &&& \<D>\<^sub>\<circ> f = I &&& (\<And>i. i \<in>\<^sub>\<circ> I \<Longrightarrow> f\<lparr>i\<rparr> \<in>\<^sub>\<circ> \<AA> i\<lparr>Arr\<rparr>)
[PROOF STEP]
unfolding dg_prod_components
[PROOF STATE]
proof (prove)
using this:
f \<in>\<^sub>\<circ> (\<Prod>\<^sub>\<circ>i\<in>\<^sub>\<circ>I. \<AA> i\<lparr>Arr\<rparr>)

goal (1 subgoal):
 1. vsv f &&& \<D>\<^sub>\<circ> f = I &&& (\<And>i. i \<in>\<^sub>\<circ> I \<Longrightarrow> f\<lparr>i\<rparr> \<in>\<^sub>\<circ> \<AA> i\<lparr>Arr\<rparr>)
[PROOF STEP]
by auto


[STATEMENT]
lemma funpow_shift1_degree: "degree (funpow k shift1 p) = k + degree p "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Polynomial_Expression.degree ((shift1 ^^ k) p) = k + Polynomial_Expression.degree p
[PROOF STEP]
by (induct k arbitrary: p) (auto simp add: shift1_degree)


[STATEMENT]
lemma multcol_mat: assumes A: "(A :: 'a :: comm_ring_1 mat) \<in> carrier_mat nr n"
  shows "multcol k a A = A * multrow_mat n k a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multcol k a A = A * multrow_mat n k a
[PROOF STEP]
by (rule eq_matI, insert A, auto simp: col_multrow smult_scalar_prod_distrib[of _ n])


[STATEMENT]
lemma subspace_hyperplane: "subspace {x. a \<bullet> x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subspace {x. a \<bullet> x = 0}
[PROOF STEP]
by (simp add: subspace_def inner_right_distrib)


[STATEMENT]
lemma Collect_minI_cut: "\<lbrakk> k \<in> I; P (k::('a::wellorder)) \<rbrakk> \<Longrightarrow> \<exists>x\<in>I. P x \<and> (\<forall>y\<in>(I \<down>< x). \<not> P y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>k \<in> I; P k\<rbrakk> \<Longrightarrow> \<exists>x\<in>I. P x \<and> (\<forall>y\<in>I \<down>< x. \<not> P y)
[PROOF STEP]
by (drule Collect_minI, assumption, blast)


[STATEMENT]
theorem inorder_update:
  "sorted1(inorder t) \<Longrightarrow> inorder(update x y t) = upd_list x y (inorder t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted1 (Tree2.inorder t) \<Longrightarrow> Tree2.inorder (update x y t) = upd_list x y (Tree2.inorder t)
[PROOF STEP]
by (induct t) (auto simp: upd_list_simps inorder_balL inorder_balR)


[STATEMENT]
lemma Inf_closed_clop_var:
  fixes X :: "'a::complete_lattice set"
  shows "clop f \<Longrightarrow> \<forall>x \<in> X. x \<in> range f \<Longrightarrow> \<Sqinter>X \<in> range f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>clop f; \<forall>x\<in>X. x \<in> range f\<rbrakk> \<Longrightarrow> \<Sqinter> X \<in> range f
[PROOF STEP]
by (metis Inf_closed_set_def clop_Fix_range clop_Inf_closed subsetI)


[STATEMENT]
lemma octo_norm_pow_2_inner: "(norm x) ^ 2 = inner x x " for x::octo
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm x)\<^sup>2 = x \<bullet> x
[PROOF STEP]
by (simp add: dot_square_norm)


[STATEMENT]
lemma set_permutationss:
  assumes "distincts xss"
  shows "set (permutationss xss) = {yss. distincts yss \<and> map set xss = map set yss}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (permutationss xss) = {yss. distincts yss \<and> map set xss = map set yss}
[PROOF STEP]
using in_set_permutationss[OF assms]
[PROOF STATE]
proof (prove)
using this:
(?yss \<in> set (permutationss xss)) = (distincts ?yss \<and> map set xss = map set ?yss)

goal (1 subgoal):
 1. set (permutationss xss) = {yss. distincts yss \<and> map set xss = map set yss}
[PROOF STEP]
by blast


[STATEMENT]
lemma linorder_on_cases:
  assumes "linorder_on A R" "x \<in> A" "y \<in> A"
  shows   "x = y \<or> ((x, y) \<in> R \<and> (y, x) \<notin> R) \<or> ((y, x) \<in> R \<and> (x, y) \<notin> R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y \<or> (x, y) \<in> R \<and> (y, x) \<notin> R \<or> (y, x) \<in> R \<and> (x, y) \<notin> R
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
linorder_on A R
x \<in> A
y \<in> A

goal (1 subgoal):
 1. x = y \<or> (x, y) \<in> R \<and> (y, x) \<notin> R \<or> (y, x) \<in> R \<and> (x, y) \<notin> R
[PROOF STEP]
by (auto simp: linorder_on_def refl_on_def total_on_def antisym_def)


[STATEMENT]
lemma integrable_on_scaleR_iff [simp]:
  fixes c :: real
  assumes "c \<noteq> 0"
  shows "(\<lambda>x. c *\<^sub>R f x) integrable_on S \<longleftrightarrow> f integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) integrable_on S) = (f integrable_on S)
[PROOF STEP]
using integrable_cmul[of "\<lambda>x. c *\<^sub>R f x" S "1 / c"] integrable_cmul[of f S c] \<open>c \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. c *\<^sub>R f x) integrable_on S \<Longrightarrow> (\<lambda>x. (1 / c) *\<^sub>R c *\<^sub>R f x) integrable_on S
f integrable_on S \<Longrightarrow> (\<lambda>x. c *\<^sub>R f x) integrable_on S
c \<noteq> 0

goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) integrable_on S) = (f integrable_on S)
[PROOF STEP]
by auto


[STATEMENT]
lemma real_sqrt_ge_abs2 [simp]: "\<bar>y\<bar> \<le> sqrt (x\<^sup>2 + y\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>y\<bar> \<le> sqrt (x\<^sup>2 + y\<^sup>2)
[PROOF STEP]
by (rule power2_le_imp_le) simp_all


[STATEMENT]
lemma  word_less_power_trans2:
  fixes n :: "'a::len word"
  shows "\<lbrakk>n < 2 ^ (m - k); k \<le> m; m < LENGTH('a)\<rbrakk> \<Longrightarrow> n * 2 ^ k < 2 ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < 2 ^ (m - k); k \<le> m; m < LENGTH('a)\<rbrakk> \<Longrightarrow> n * 2 ^ k < 2 ^ m
[PROOF STEP]
by (subst field_simps, rule word_less_power_trans)


[STATEMENT]
lemma regular_linorder_matrix:
  fixes f :: "('a::finite,'b::linorder_stone_relation_algebra_expansion) square"
  shows "matrix_p_algebra.regular f \<longleftrightarrow> (\<forall>e . f e = bot \<or> f e = top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
have "matrix_p_algebra.regular f \<longleftrightarrow> (\<ominus>\<ominus>f = f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<ominus> \<ominus> f = f)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_p_algebra.regular f = (\<ominus> \<ominus> f = f)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matrix_p_algebra.regular f = (\<ominus> \<ominus> f = f)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
have "... \<longleftrightarrow> (\<forall>e . --f e = f e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<ominus> \<ominus> f = f) = (\<forall>e. - - f e = f e)
[PROOF STEP]
by (metis uminus_matrix_def ext)
[PROOF STATE]
proof (state)
this:
(\<ominus> \<ominus> f = f) = (\<forall>e. - - f e = f e)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<ominus> \<ominus> f = f) = (\<forall>e. - - f e = f e)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
have "... \<longleftrightarrow> (\<forall>e . f e = bot \<or> f e = top)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>e. - - f e = f e) = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<forall>e. - - f e = f e) = (\<forall>e. f e = bot \<or> f e = top)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)

goal (1 subgoal):
 1. matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
matrix_p_algebra.regular f = (\<forall>e. f e = bot \<or> f e = top)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sinh_real_strict_mono: "strict_mono (sinh :: real \<Rightarrow> real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_mono sinh
[PROOF STEP]
by (rule pos_deriv_imp_strict_mono derivative_intros)+ auto


[STATEMENT]
lemma fdomain_vintersection_vsubset: "\<D>\<^sub>\<bullet> (A \<inter>\<^sub>\<circ> B) \<subseteq>\<^sub>\<circ> \<D>\<^sub>\<bullet> A \<inter>\<^sub>\<circ> \<D>\<^sub>\<bullet> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<D>\<^sub>\<bullet> (A \<inter>\<^sub>\<circ> B) \<subseteq>\<^sub>\<circ> \<D>\<^sub>\<bullet> A \<inter>\<^sub>\<circ> \<D>\<^sub>\<bullet> B
[PROOF STEP]
by auto


[STATEMENT]
lemma i_cut_subset_mono_disj: "
  \<lbrakk> cut_op = (\<down><) \<or> cut_op = (\<down>\<le>) \<or>
    cut_op = (\<down>>) \<or> cut_op = (\<down>\<ge>); A \<subseteq> B \<rbrakk>
  \<Longrightarrow> cut_op A t \<subseteq> cut_op B t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>cut_op = (\<down><) \<or> cut_op = (\<down>\<le>) \<or> cut_op = (\<down>>) \<or> cut_op = (\<down>\<ge>); A \<subseteq> B\<rbrakk> \<Longrightarrow> cut_op A t \<subseteq> cut_op B t
[PROOF STEP]
apply (drule i_cut_set_restriction_disj[where f="\<lambda>I. cut_op I t"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> B; set_restriction (\<lambda>I. cut_op I t)\<rbrakk> \<Longrightarrow> cut_op A t \<subseteq> cut_op B t
[PROOF STEP]
by (rule set_restriction_mono[where f="\<lambda>I. cut_op I t"])


[STATEMENT]
lemma finite_monotonic_image_pairs:
  fixes A :: "(nat \<times> nat) set"
  fixes B :: "nat set"
  assumes "\<And>i. i \<in> A \<Longrightarrow> (fst i) \<le> f i + c"
  assumes "\<And>i. i \<in> A \<Longrightarrow> (snd i) \<le> f i + d"
  assumes "f ` A = B"
  shows "finite A \<longleftrightarrow> finite B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A = finite B
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite A \<Longrightarrow> finite B
 2. finite B \<Longrightarrow> finite A
[PROOF STEP]
assume "finite B"
[PROOF STATE]
proof (state)
this:
finite B

goal (2 subgoals):
 1. finite A \<Longrightarrow> finite B
 2. finite B \<Longrightarrow> finite A
[PROOF STEP]
thus "finite A"
[PROOF STATE]
proof (prove)
using this:
finite B

goal (1 subgoal):
 1. finite A
[PROOF STEP]
proof (cases "B \<noteq> {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>finite B; B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
 2. \<lbrakk>finite B; \<not> B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
B \<noteq> {}

goal (2 subgoals):
 1. \<lbrakk>finite B; B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
 2. \<lbrakk>finite B; \<not> B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
[PROOF STEP]
hence "\<And>i. i \<in> A \<Longrightarrow> fst i \<le> Max B + c \<and> snd i \<le> Max B + d"
[PROOF STATE]
proof (prove)
using this:
B \<noteq> {}

goal (1 subgoal):
 1. \<And>i. i \<in> A \<Longrightarrow> fst i \<le> Max B + c \<and> snd i \<le> Max B + d
[PROOF STEP]
by (metis assms Max_ge_iff \<open>finite B\<close> imageI le_diff_conv)
[PROOF STATE]
proof (state)
this:
?i \<in> A \<Longrightarrow> fst ?i \<le> Max B + c \<and> snd ?i \<le> Max B + d

goal (2 subgoals):
 1. \<lbrakk>finite B; B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
 2. \<lbrakk>finite B; \<not> B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
[PROOF STEP]
thus "finite A"
[PROOF STATE]
proof (prove)
using this:
?i \<in> A \<Longrightarrow> fst ?i \<le> Max B + c \<and> snd ?i \<le> Max B + d

goal (1 subgoal):
 1. finite A
[PROOF STEP]
using finite_product[of A]
[PROOF STATE]
proof (prove)
using this:
?i \<in> A \<Longrightarrow> fst ?i \<le> Max B + c \<and> snd ?i \<le> Max B + d
\<lbrakk>finite (fst ` A); finite (snd ` A)\<rbrakk> \<Longrightarrow> finite A

goal (1 subgoal):
 1. finite A
[PROOF STEP]
unfolding finite_nat_set_iff_bounded_le
[PROOF STATE]
proof (prove)
using this:
?i \<in> A \<Longrightarrow> fst ?i \<le> Max B + c \<and> snd ?i \<le> Max B + d
\<lbrakk>\<exists>m. \<forall>n\<in>fst ` A. n \<le> m; \<exists>m. \<forall>n\<in>snd ` A. n \<le> m\<rbrakk> \<Longrightarrow> finite A

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

goal (1 subgoal):
 1. \<lbrakk>finite B; \<not> B \<noteq> {}\<rbrakk> \<Longrightarrow> finite A
[PROOF STEP]
qed (metis assms(3) finite.emptyI image_is_empty)
[PROOF STATE]
proof (state)
this:
finite A

goal (1 subgoal):
 1. finite A \<Longrightarrow> finite B
[PROOF STEP]
qed (metis assms(3) finite_imageI)


[STATEMENT]
lemma transcendental_cos:
  assumes "algebraic z" "z \<noteq> 0"
  shows   "\<not>algebraic (cos z :: complex)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> algebraic (cos z)
[PROOF STEP]
unfolding cos_conv_cosh
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> algebraic (cosh (\<i> * z))
[PROOF STEP]
using transcendental_cosh[of "\<i> * z"] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>algebraic (\<i> * z); \<i> * z \<noteq> 0\<rbrakk> \<Longrightarrow> \<not> algebraic (cosh (\<i> * z))
algebraic z
z \<noteq> 0

goal (1 subgoal):
 1. \<not> algebraic (cosh (\<i> * z))
[PROOF STEP]
by simp


[STATEMENT]
lemma sum_list_map_eq_sum_count:
  "sum_list (map f xs) = sum (\<lambda>x. count_list xs x * f x) (set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map f xs) = (\<Sum>x\<in>set xs. count_list xs x * f x)
[PROOF STEP]
proof(induction xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sum_list (map f []) = (\<Sum>x\<in>set []. count_list [] x * f x)
 2. \<And>a xs. sum_list (map f xs) = (\<Sum>x\<in>set xs. count_list xs x * f x) \<Longrightarrow> sum_list (map f (a # xs)) = (\<Sum>x\<in>set (a # xs). count_list (a # xs) x * f x)
[PROOF STEP]
case (Cons x xs)
[PROOF STATE]
proof (state)
this:
sum_list (map f xs) = (\<Sum>x\<in>set xs. count_list xs x * f x)

goal (2 subgoals):
 1. sum_list (map f []) = (\<Sum>x\<in>set []. count_list [] x * f x)
 2. \<And>a xs. sum_list (map f xs) = (\<Sum>x\<in>set xs. count_list xs x * f x) \<Longrightarrow> sum_list (map f (a # xs)) = (\<Sum>x\<in>set (a # xs). count_list (a # xs) x * f x)
[PROOF STEP]
show ?case (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
assume "x \<in> set xs"
[PROOF STATE]
proof (state)
this:
x \<in> set xs

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
have "?l = f x + (\<Sum>x\<in>set xs. count_list xs x * f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map f (x # xs)) = f x + (\<Sum>x\<in>set xs. count_list xs x * f x)
[PROOF STEP]
by (simp add: Cons.IH)
[PROOF STATE]
proof (state)
this:
sum_list (map f (x # xs)) = f x + (\<Sum>x\<in>set xs. count_list xs x * f x)

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_list (map f (x # xs)) = f x + (\<Sum>x\<in>set xs. count_list xs x * f x)

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
have "set xs = insert x (set xs - {x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set xs = insert x (set xs - {x})
[PROOF STEP]
using \<open>x \<in> set xs\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> set xs

goal (1 subgoal):
 1. set xs = insert x (set xs - {x})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set xs = insert x (set xs - {x})

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set xs = insert x (set xs - {x})

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
have "f x + (\<Sum>x\<in>insert x (set xs - {x}). count_list xs x * f x) = ?r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x + (\<Sum>x\<in>insert x (set xs - {x}). count_list xs x * f x) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
by (simp add: sum.insert_remove eq_commute)
[PROOF STATE]
proof (state)
this:
f x + (\<Sum>x\<in>insert x (set xs - {x}). count_list xs x * f x) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)

goal (2 subgoals):
 1. ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
 2. \<not> ?P \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)

goal (1 subgoal):
 1. sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)

goal (1 subgoal):
 1. x \<notin> set xs \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<notin> set xs \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
assume "x \<notin> set xs"
[PROOF STATE]
proof (state)
this:
x \<notin> set xs

goal (1 subgoal):
 1. x \<notin> set xs \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
hence "\<And>xa. xa \<in> set xs \<Longrightarrow> x \<noteq> xa"
[PROOF STATE]
proof (prove)
using this:
x \<notin> set xs

goal (1 subgoal):
 1. \<And>xa. xa \<in> set xs \<Longrightarrow> x \<noteq> xa
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?xa \<in> set xs \<Longrightarrow> x \<noteq> ?xa

goal (1 subgoal):
 1. x \<notin> set xs \<Longrightarrow> sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?xa \<in> set xs \<Longrightarrow> x \<noteq> ?xa

goal (1 subgoal):
 1. sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)
[PROOF STEP]
by (simp add: Cons.IH \<open>x \<notin> set xs\<close>)
[PROOF STATE]
proof (state)
this:
sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sum_list (map f (x # xs)) = (\<Sum>xa\<in>set (x # xs). count_list (x # xs) xa * f xa)

goal (1 subgoal):
 1. sum_list (map f []) = (\<Sum>x\<in>set []. count_list [] x * f x)
[PROOF STEP]
qed simp


[STATEMENT]
lemma finite_cball_avoid:
  fixes S :: "'a :: euclidean_space set"
  assumes "open S" "finite X" "p \<in> S"
  shows "\<exists>e>0. \<forall>w\<in>cball p e. w\<in>S \<and> (w\<noteq>p \<longrightarrow> w\<notin>X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
obtain e1 where "e1>0" and e1: "\<forall>w\<in>ball p e1. w\<in>S \<and> (w\<noteq>p \<longrightarrow> w\<notin>X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>e1. \<lbrakk>0 < e1; \<forall>w\<in>ball p e1. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using finite_ball_avoid[OF assms]
[PROOF STATE]
proof (prove)
using this:
\<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal (1 subgoal):
 1. (\<And>e1. \<lbrakk>0 < e1; \<forall>w\<in>ball p e1. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < e1
\<forall>w\<in>ball p e1. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
define e2 where "e2 \<equiv> e1/2"
[PROOF STATE]
proof (state)
this:
e2 \<equiv> e1 / 2

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
have "e2>0" and "e2 < e1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < e2 &&& e2 < e1
[PROOF STEP]
unfolding e2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < e1 / 2 &&& e1 / 2 < e1
[PROOF STEP]
using \<open>e1>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < e1

goal (1 subgoal):
 1. 0 < e1 / 2 &&& e1 / 2 < e1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < e2
e2 < e1

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < e2
e2 < e1
[PROOF STEP]
have "cball p e2 \<subseteq> ball p e1"
[PROOF STATE]
proof (prove)
using this:
0 < e2
e2 < e1

goal (1 subgoal):
 1. cball p e2 \<subseteq> ball p e1
[PROOF STEP]
by (subst cball_subset_ball_iff,auto)
[PROOF STATE]
proof (state)
this:
cball p e2 \<subseteq> ball p e1

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cball p e2 \<subseteq> ball p e1
[PROOF STEP]
show "\<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)"
[PROOF STATE]
proof (prove)
using this:
cball p e2 \<subseteq> ball p e1

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
using \<open>e2>0\<close> e1
[PROOF STATE]
proof (prove)
using this:
cball p e2 \<subseteq> ball p e1
0 < e2
\<forall>w\<in>ball p e1. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>e>0. \<forall>w\<in>cball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
have "sin (3/2*pi) = sin (pi + pi/2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (3 / 2 * pi) = sin (pi + pi / 2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sin (3 / 2 * pi) = sin (pi + pi / 2)

goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sin (3 / 2 * pi) = sin (pi + pi / 2)

goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
have "... = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (pi + pi / 2) = - 1
[PROOF STEP]
by (subst sin_add, simp)
[PROOF STATE]
proof (state)
this:
sin (pi + pi / 2) = - 1

goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sin (3 / 2 * pi) = - 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sin (3 / 2 * pi) = - 1

goal (1 subgoal):
 1. sin (3 / 2 * pi) = - 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sin (3 / 2 * pi) = - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_on_imp_set_integrable_cbox:
  fixes h :: "'a :: euclidean_space \<Rightarrow> real"
  assumes "continuous_on (cbox a b) h"
  shows   "set_integrable lborel (cbox a b) h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
continuous_on (cbox a b) h
[PROOF STEP]
have "h absolutely_integrable_on cbox a b"
[PROOF STATE]
proof (prove)
using this:
continuous_on (cbox a b) h

goal (1 subgoal):
 1. h absolutely_integrable_on cbox a b
[PROOF STEP]
by (rule absolutely_integrable_continuous)
[PROOF STATE]
proof (state)
this:
h absolutely_integrable_on cbox a b

goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
h absolutely_integrable_on cbox a b

goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
have "(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel
[PROOF STEP]
by (rule borel_measurable_continuous_on_indicator) (use assms in auto)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel

goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
h absolutely_integrable_on cbox a b
(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
h absolutely_integrable_on cbox a b
(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel

goal (1 subgoal):
 1. set_integrable lborel (cbox a b) h
[PROOF STEP]
unfolding set_integrable_def
[PROOF STATE]
proof (prove)
using this:
integrable lebesgue (\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x)
(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel

goal (1 subgoal):
 1. integrable lborel (\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
integrable lebesgue (\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x)
(\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x) \<in> borel_measurable borel
continuous_on (cbox a b) h

goal (1 subgoal):
 1. integrable lborel (\<lambda>x. indicat_real (cbox a b) x *\<^sub>R h x)
[PROOF STEP]
by (subst (asm) integrable_completion) auto
[PROOF STATE]
proof (state)
this:
set_integrable lborel (cbox a b) h

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ranking_iff_pref:  "\<lbrakk> set P = {<length P}; i < length P; j < length P \<rbrakk>
 \<Longrightarrow> ranking P ! i < ranking P ! j \<longleftrightarrow> P \<turnstile> i < j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>set P = {<length P}; i < length P; j < length P\<rbrakk> \<Longrightarrow> (ranking P ! i < ranking P ! j) = (P \<turnstile> i < j)
[PROOF STEP]
by(simp add: ranking_index prefers_def)


[STATEMENT]
lemma distinct_concat_idx_disjoint:
  assumes xs: "distinct (concat xs)"
    and ij: "i < length xs" "j < length xs" "i < j"
  shows "set (xs ! i) \<inter> set (xs ! j) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (xs ! i) \<inter> set (xs ! j) = {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (xs ! i) \<inter> set (xs ! j) = {}
[PROOF STEP]
obtain ys zs vs where ys: "xs = ys@xs ! i#zs@xs ! j#vs" "length ys = i" "length zs = j - i - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>ys zs vs. \<lbrakk>xs = ys @ xs ! i # zs @ xs ! j # vs; length ys = i; length zs = j - i - 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using length_prefix_ex2[OF ij]
[PROOF STATE]
proof (prove)
using this:
\<exists>ys zs vs. xs = ys @ xs ! i # zs @ xs ! j # vs \<and> length ys = i \<and> length zs = j - i - 1

goal (1 subgoal):
 1. (\<And>ys zs vs. \<lbrakk>xs = ys @ xs ! i # zs @ xs ! j # vs; length ys = i; length zs = j - i - 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by moura
[PROOF STATE]
proof (state)
this:
xs = ys @ xs ! i # zs @ xs ! j # vs
length ys = i
length zs = j - i - 1

goal (1 subgoal):
 1. set (xs ! i) \<inter> set (xs ! j) = {}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
xs = ys @ xs ! i # zs @ xs ! j # vs
length ys = i
length zs = j - i - 1

goal (1 subgoal):
 1. set (xs ! i) \<inter> set (xs ! j) = {}
[PROOF STEP]
using xs concat_append[of "ys@xs ! i#zs" "xs ! j#vs"]
          distinct_append[of "concat (ys@xs ! i#zs)" "concat (xs ! j#vs)"]
[PROOF STATE]
proof (prove)
using this:
xs = ys @ xs ! i # zs @ xs ! j # vs
length ys = i
length zs = j - i - 1
distinct (concat xs)
concat ((ys @ xs ! i # zs) @ xs ! j # vs) = concat (ys @ xs ! i # zs) @ concat (xs ! j # vs)
distinct (concat (ys @ xs ! i # zs) @ concat (xs ! j # vs)) = (distinct (concat (ys @ xs ! i # zs)) \<and> distinct (concat (xs ! j # vs)) \<and> set (concat (ys @ xs ! i # zs)) \<inter> set (concat (xs ! j # vs)) = {})

goal (1 subgoal):
 1. set (xs ! i) \<inter> set (xs ! j) = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (xs ! i) \<inter> set (xs ! j) = {}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma var_sum_2:
  fixes f :: "'b \<Rightarrow> 'a \<Rightarrow> real"
  assumes "finite I"
  assumes "\<And>i. i \<in> I \<Longrightarrow> f i \<in> borel_measurable M"
  assumes "\<And>i. i \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. f i \<omega>^2)"
  shows "variance (\<lambda>\<omega>. (\<Sum>i \<in> I. f i \<omega>)) =
      (\<Sum>i \<in> I. variance (f i)) + (\<Sum>i \<in> I. \<Sum>j \<in> I - {i}. covariance (f i) (f j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
have "variance (\<lambda>\<omega>. (\<Sum>i \<in> I. f i \<omega>)) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
by (simp add: var_sum_1[OF assms(1,2,3)])
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
have "... = (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I-{i}. covariance (f i) (f j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j)) = (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite I
?i12 \<in> I \<Longrightarrow> random_variable borel (f ?i12)
?i12 \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. (f ?i12 \<omega>)\<^sup>2)

goal (1 subgoal):
 1. (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j)) = (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j)))
[PROOF STEP]
by (subst sum.insert[symmetric], auto simp add:insert_absorb)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j)) = (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j)))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j)) = (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j)))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
have "... = (\<Sum>i\<in>I. variance (f i)) +  (\<Sum>i \<in> I. (\<Sum>j\<in>I-{i}. covariance (f i) (f j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j))) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
by (simp add: covar_self_eq[symmetric] sum.distrib)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. covariance (f i) (f i) + (\<Sum>j\<in>I - {i}. covariance (f i) (f j))) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2)) + (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eigen_value_norm_sr: assumes "eigen_value cA \<alpha>"
  shows "norm \<alpha> \<le> sr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod \<alpha> \<le> sr
[PROOF STEP]
using eigen_vector_norm_sr[of _ \<alpha>] assms
[PROOF STATE]
proof (prove)
using this:
eigen_vector cA ?v \<alpha> \<Longrightarrow> cmod \<alpha> \<le> sr
eigen_value cA \<alpha>

goal (1 subgoal):
 1. cmod \<alpha> \<le> sr
[PROOF STEP]
unfolding eigen_value_def
[PROOF STATE]
proof (prove)
using this:
eigen_vector cA ?v \<alpha> \<Longrightarrow> cmod \<alpha> \<le> sr
\<exists>v. eigen_vector cA v \<alpha>

goal (1 subgoal):
 1. cmod \<alpha> \<le> sr
[PROOF STEP]
by auto


[STATEMENT]
lemma splitFace_add_vertices_direct[simp]:
"vertices (snd (snd (splitFace g ram1 ram2 oldF [countVertices g ..< countVertices g + n])))
  = vertices g @ [countVertices g ..< countVertices g + n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vertices (snd (snd (splitFace g ram1 ram2 oldF [countVertices g..<countVertices g + n]))) = vertices g @ [countVertices g..<countVertices g + n]
[PROOF STEP]
apply (auto simp: splitFace_def split_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<countVertices g + n] = vertices g @ [countVertices g..<countVertices g + n]
[PROOF STEP]
apply (cases g)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 x3 x4. g = Graph x1 x2 x3 x4 \<Longrightarrow> [0..<countVertices g + n] = vertices g @ [countVertices g..<countVertices g + n]
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 x3 x4. g = Graph x1 x2 x3 x4 \<Longrightarrow> [0..<x2 + n] = [0..<x2] @ [x2..<x2 + n]
[PROOF STEP]
apply (induct n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x1 x2 x3 x4. g = Graph x1 x2 x3 x4 \<Longrightarrow> [0..<x2 + 0] = [0..<x2] @ [x2..<x2 + 0]
 2. \<And>n x1 x2 x3 x4. \<lbrakk>\<And>x1 x2 x3 x4. g = Graph x1 x2 x3 x4 \<Longrightarrow> [0..<x2 + n] = [0..<x2] @ [x2..<x2 + n]; g = Graph x1 x2 x3 x4\<rbrakk> \<Longrightarrow> [0..<x2 + Suc n] = [0..<x2] @ [x2..<x2 + Suc n]
[PROOF STEP]
by auto


[STATEMENT]
lemma blinfun_apply_integral:
  assumes "f integrable_on s"
  shows "blinfun_apply (integral s f) x = integral s (\<lambda>y. blinfun_apply (f y) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. blinfun_apply (integral s f) x = integral s (\<lambda>y. blinfun_apply (f y) x)
[PROOF STEP]
by (metis (no_types, lifting) assms blinfun.prod_left.rep_eq integral_blinfun_apply integral_cong)


[STATEMENT]
lemma take_bit_not_mask_eq_0:
  \<open>take_bit m (NOT (mask n)) = 0\<close> if \<open>n \<ge> m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_bit m (NOT (mask n)) = (0::'a)
[PROOF STEP]
by (rule bit_eqI) (use that in \<open>simp add: bit_take_bit_iff bit_not_iff bit_mask_iff\<close>)


[STATEMENT]
lemma closed_segment_eq_open: "closed_segment a b = open_segment a b \<union> {a,b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed_segment a b = open_segment a b \<union> {a, b}
[PROOF STEP]
using open_segment_def
[PROOF STATE]
proof (prove)
using this:
open_segment ?a ?b \<equiv> closed_segment ?a ?b - {?a, ?b}

goal (1 subgoal):
 1. closed_segment a b = open_segment a b \<union> {a, b}
[PROOF STEP]
by auto


[STATEMENT]
lemma joinpaths_eq:
  "(\<And>t. t \<in> {0..1} \<Longrightarrow> p t = p' t) \<Longrightarrow>
   (\<And>t. t \<in> {0..1} \<Longrightarrow> q t = q' t)
   \<Longrightarrow>  t \<in> {0..1} \<Longrightarrow> (p +++ q) t = (p' +++ q') t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>t. t \<in> {0..1} \<Longrightarrow> p t = p' t; \<And>t. t \<in> {0..1} \<Longrightarrow> q t = q' t; t \<in> {0..1}\<rbrakk> \<Longrightarrow> (p +++ q) t = (p' +++ q') t
[PROOF STEP]
by (auto simp: joinpaths_def)


[STATEMENT]
lemma (in group) subgroup_int_pow_closed:
  assumes "subgroup H G" "h \<in> H" shows "h [^] (k :: int) \<in> H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h [^] k \<in> H
[PROOF STEP]
using group.int_pow_closed[OF subgroup_imp_group[OF assms(1)]] assms(2)
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier (G\<lparr>carrier := H\<rparr>) \<Longrightarrow> ?x [^]\<^bsub>G\<lparr>carrier := H\<rparr>\<^esub> ?i \<in> carrier (G\<lparr>carrier := H\<rparr>)
h \<in> H

goal (1 subgoal):
 1. h [^] k \<in> H
[PROOF STEP]
unfolding int_pow_consistent[OF assms]
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier (G\<lparr>carrier := H\<rparr>) \<Longrightarrow> ?x [^]\<^bsub>G\<lparr>carrier := H\<rparr>\<^esub> ?i \<in> carrier (G\<lparr>carrier := H\<rparr>)
h \<in> H

goal (1 subgoal):
 1. h [^]\<^bsub>G\<lparr>carrier := H\<rparr>\<^esub> k \<in> H
[PROOF STEP]
by simp


[STATEMENT]
theorem mss_rec_naive: "mss_rec_naive xs = Max {s. \<exists>as bs cs. xs = as @ bs @ cs \<and> s = sum_list bs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mss_rec_naive xs = Max {s. \<exists>as bs cs. xs = as @ bs @ cs \<and> s = sum_list bs}
[PROOF STEP]
unfolding mss_rec_naive_max_mid_sum mid_sums
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {s. \<exists>as bs cs. xs = as @ bs @ cs \<and> s = sum_list bs} = Max {s. \<exists>as bs cs. xs = as @ bs @ cs \<and> s = sum_list bs}
[PROOF STEP]
by simp


[STATEMENT]
lemma subset_atMost_imp_Max_le:"
  \<lbrakk> finite A; A \<noteq> {}; A \<subseteq> {..n} \<rbrakk> \<Longrightarrow> Max A \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; A \<noteq> {}; A \<subseteq> {..n}\<rbrakk> \<Longrightarrow> Max A \<le> n
[PROOF STEP]
by (simp add: subset_iff)


[STATEMENT]
lemma mset_eq_length:
  assumes "mset xs = mset ys"
  shows "length xs = length ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = length ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
mset xs = mset ys

goal (1 subgoal):
 1. length xs = length ys
[PROOF STEP]
by (metis size_mset)


[STATEMENT]
lemma merge_sorted_wrt_partitions_between:
  \<open>(\<And> x y z. \<lbrakk>R x y; R y z\<rbrakk> \<Longrightarrow> R x z) \<Longrightarrow>
    isPartition_wrt R xs lo hi p \<Longrightarrow>
    sorted_sublist_wrt R xs lo (p-1) \<Longrightarrow> sorted_sublist_wrt R xs (p+1) hi \<Longrightarrow>
    lo \<le> hi \<Longrightarrow> hi < length xs \<Longrightarrow> lo < p \<Longrightarrow> p < hi \<Longrightarrow> hi < length xs \<Longrightarrow>
    sorted_sublist_wrt R xs lo hi\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x y z. \<lbrakk>R x y; R y z\<rbrakk> \<Longrightarrow> R x z; isPartition_wrt R xs lo hi p; sorted_sublist_wrt R xs lo (p - 1); sorted_sublist_wrt R xs (p + 1) hi; lo \<le> hi; hi < length xs; lo < p; p < hi; hi < length xs\<rbrakk> \<Longrightarrow> sorted_sublist_wrt R xs lo hi
[PROOF STEP]
by (simp add: merge_sorted_wrt_partitions_between' isPartition_wrt_trans)


[STATEMENT]
lemma admits_diagonal_reduction_imp_exists_algorithm_is_SNF:
  assumes "A \<in> carrier_mat m n"
  and "admits_diagonal_reduction A"
shows "\<exists>algorithm. is_SNF A (algorithm A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>algorithm. is_SNF A (algorithm A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n
admits_diagonal_reduction A

goal (1 subgoal):
 1. \<exists>algorithm. is_SNF A (algorithm A)
[PROOF STEP]
unfolding is_SNF_def admits_diagonal_reduction_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n
\<exists>P Q. P \<in> carrier_mat (dim_row A) (dim_row A) \<and> Q \<in> carrier_mat (dim_col A) (dim_col A) \<and> invertible_mat P \<and> invertible_mat Q \<and> Smith_normal_form_mat (P * A * Q)

goal (1 subgoal):
 1. \<exists>algorithm. case algorithm A of (P, S, Q) \<Rightarrow> P \<in> carrier_mat (dim_row A) (dim_row A) \<and> Q \<in> carrier_mat (dim_col A) (dim_col A) \<and> invertible_mat P \<and> invertible_mat Q \<and> Smith_normal_form_mat S \<and> S = P * A * Q
[PROOF STEP]
by auto


[STATEMENT]
lemma lastMarkedNotInPrefixBeforeLastMarked:
  assumes "uniq (elements M)" and "markedElements M \<noteq> []"
  shows "\<not> (lastMarked M) \<in> set (elements (prefixBeforeLastMarked M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lastMarked M \<notin> set (elements (prefixBeforeLastMarked M))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
uniq (elements M)
markedElements M \<noteq> []

goal (1 subgoal):
 1. lastMarked M \<notin> set (elements (prefixBeforeLastMarked M))
[PROOF STEP]
unfolding lastMarked_def
[PROOF STATE]
proof (prove)
using this:
uniq (elements M)
markedElements M \<noteq> []

goal (1 subgoal):
 1. last (markedElements M) \<notin> set (elements (prefixBeforeLastMarked M))
[PROOF STEP]
by (induct M) (auto split: if_split_asm simp add: markedElementsAreElements)


[STATEMENT]
lemma nfv_And[simp]: "nfv (And \<phi> \<psi>) = max (nfv \<phi>) (nfv \<psi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nfv (And \<phi> \<psi>) = max (nfv \<phi>) (nfv \<psi>)
[PROOF STEP]
unfolding nfv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max (insert 0 (Suc ` fv (And \<phi> \<psi>))) = max (Max (insert 0 (Suc ` fv \<phi>))) (Max (insert 0 (Suc ` fv \<psi>)))
[PROOF STEP]
by (simp add: fvi_And image_Un Max_Un[symmetric])


[STATEMENT]
lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y"
  for x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < x; 0 < y\<rbrakk> \<Longrightarrow> ln (x / y) = ln x - ln y
[PROOF STEP]
by (rule ln_unique) (simp add: exp_diff)


[STATEMENT]
lemma finite_lattice_complete_Inf_insert:
  fixes A :: "'a::finite_lattice_complete set"
  shows "Inf (insert x A) = inf x (Inf A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf (insert x A) = inf x (Inf A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Inf (insert x A) = inf x (Inf A)
[PROOF STEP]
interpret comp_fun_idem "inf :: 'a \<Rightarrow> _"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comp_fun_idem inf
[PROOF STEP]
by (fact comp_fun_idem_inf)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Inf (insert x A) = inf x (Inf A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf (insert x A) = inf x (Inf A)
[PROOF STEP]
by (simp add: Inf_def)
[PROOF STATE]
proof (state)
this:
Inf (insert x A) = inf x (Inf A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma wf_tuple_append: "wf_tuple a {x \<in> A. x < a} xs \<Longrightarrow>
  wf_tuple b {x - a | x. x \<in> A \<and> x \<ge> a} ys \<Longrightarrow>
  wf_tuple (a + b) A (xs @ ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>wf_tuple a {x \<in> A. x < a} xs; wf_tuple b {x - a |x. x \<in> A \<and> a \<le> x} ys\<rbrakk> \<Longrightarrow> wf_tuple (a + b) A (xs @ ys)
[PROOF STEP]
unfolding wf_tuple_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>length xs = a \<and> (\<forall>i<a. (xs ! i = None) = (i \<notin> {x \<in> A. x < a})); length ys = b \<and> (\<forall>i<b. (ys ! i = None) = (i \<notin> {x - a |x. x \<in> A \<and> a \<le> x}))\<rbrakk> \<Longrightarrow> length (xs @ ys) = a + b \<and> (\<forall>i<a + b. ((xs @ ys) ! i = None) = (i \<notin> A))
[PROOF STEP]
by (auto simp: nth_append eq_diff_iff)


[STATEMENT]
lemma DERIV_imp_deriv: "DERIV f x :> f' \<Longrightarrow> deriv f x = f'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_field_derivative f') (at x) \<Longrightarrow> deriv f x = f'
[PROOF STEP]
unfolding deriv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_field_derivative f') (at x) \<Longrightarrow> (SOME D. (f has_field_derivative D) (at x)) = f'
[PROOF STEP]
by (metis some_equality DERIV_unique)


[STATEMENT]
lemma genPrefix_iff_nth:
     "((xs,ys) \<in> genPrefix r) =
      (length xs <= length ys & (\<forall>i. i < length xs \<longrightarrow> (xs!i, ys!i) \<in> r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((xs, ys) \<in> genPrefix r) = (length xs \<le> length ys \<and> (\<forall>i<length xs. (xs ! i, ys ! i) \<in> r))
[PROOF STEP]
apply (blast intro: genPrefix_length_le genPrefix_imp_nth nth_imp_genPrefix)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Units_inverse_Qp:
  assumes "u \<in> Units Q\<^sub>p"
  shows "inv\<^bsub>Q\<^sub>p\<^esub> u \<in> Units Q\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv u \<in> Units Q\<^sub>p
[PROOF STEP]
using Q\<^sub>p_def Units_eq_nonzero assms frac_nonzero_inv_Unit
[PROOF STATE]
proof (prove)
using this:
Q\<^sub>p \<equiv> Frac Z\<^sub>p
Units Q\<^sub>p = nonzero Q\<^sub>p
u \<in> Units Q\<^sub>p
?b \<in> nonzero (Frac Z\<^sub>p) \<Longrightarrow> inv\<^bsub>Frac Z\<^sub>p\<^esub> ?b \<in> Units (Frac Z\<^sub>p)

goal (1 subgoal):
 1. inv u \<in> Units Q\<^sub>p
[PROOF STEP]
by auto


[STATEMENT]
lemma map_dual_invol [simp]: "\<partial>\<^sub>F \<circ> \<partial>\<^sub>F = id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<partial>\<^sub>F \<circ> \<partial>\<^sub>F = id
[PROOF STEP]
unfolding map_dual_def comp_def fun_eq_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x xa. \<partial> (\<partial> (x (\<partial> (\<partial> xa)))) = id x xa
[PROOF STEP]
by simp


[STATEMENT]
lemma quantale_closed_maps_iff: "f \<in> quantale_closed_maps = (\<forall> x y. f x \<cdot> f y \<le> f (x \<cdot> y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in> quantale_closed_maps) = (\<forall>x y. f x \<cdot> f y \<le> f (x \<cdot> y))
[PROOF STEP]
unfolding quantale_closed_maps_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in> {f. \<forall>x y. f x \<cdot> f y \<le> f (x \<cdot> y)}) = (\<forall>x y. f x \<cdot> f y \<le> f (x \<cdot> y))
[PROOF STEP]
by clarsimp


[STATEMENT]
lemma commutesI [intro]: "(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x\<cdot>y = y\<cdot>x) \<Longrightarrow> commutes A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x \<cdot> y = y \<cdot> x) \<Longrightarrow> commutes A
[PROOF STEP]
unfolding commutes_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x \<cdot> y = y \<cdot> x) \<Longrightarrow> \<forall>x y. x \<in> A \<longrightarrow> y \<in> A \<longrightarrow> x \<cdot> y = y \<cdot> x
[PROOF STEP]
by blast


[STATEMENT]
lemma abs_hnorm_cancel [simp]: "\<And>a::'a::real_normed_vector star. \<bar>hnorm a\<bar> = hnorm a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. \<bar>hnorm a\<bar> = hnorm a
[PROOF STEP]
by transfer (rule abs_norm_cancel)


[STATEMENT]
lemma degree_Mp_mult_monic: assumes "monic f" "monic g"
  shows "degree (Mp (f * g)) = degree f + degree g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree_m (f * g) = degree f + degree g
[PROOF STEP]
by (metis zero_neq_one assms degree_monic_mult leading_coeff_0_iff monic_degree_m monic_mult)


[STATEMENT]
lemma summable_zero_on_nonneg:
  fixes f :: "nat \<Rightarrow> 'a :: {ordered_comm_monoid_add,linorder_topology,conditionally_complete_linorder}"
  assumes f: "summable f"
  and nonneg: "\<And>x. 0 \<le> f x"
  shows "summable (zero_on f X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (zero_on f X)
[PROOF STEP]
proof(rule summableI_nonneg_bounded)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. (0::'a) \<le> zero_on f X n
 2. \<And>n. sum (zero_on f X) {..<n} \<le> ?x
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. (0::'a) \<le> zero_on f X n
 2. \<And>n. sum (zero_on f X) {..<n} \<le> ?x
[PROOF STEP]
have "sum (zero_on f X) {..<n} \<le> sum f {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (zero_on f X) {..<n} \<le> sum f {..<n}
[PROOF STEP]
by(rule sum_mono)(simp add: nonneg)
[PROOF STATE]
proof (state)
this:
sum (zero_on f X) {..<n} \<le> sum f {..<n}

goal (2 subgoals):
 1. \<And>n. (0::'a) \<le> zero_on f X n
 2. \<And>n. sum (zero_on f X) {..<n} \<le> ?x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum (zero_on f X) {..<n} \<le> sum f {..<n}

goal (2 subgoals):
 1. \<And>n. (0::'a) \<le> zero_on f X n
 2. \<And>n. sum (zero_on f X) {..<n} \<le> ?x
[PROOF STEP]
have "\<dots> \<le> suminf f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..<n} \<le> suminf f
[PROOF STEP]
using f
[PROOF STATE]
proof (prove)
using this:
summable f

goal (1 subgoal):
 1. sum f {..<n} \<le> suminf f
[PROOF STEP]
by(rule sum_le_suminf)(auto simp add: nonneg)
[PROOF STATE]
proof (state)
this:
sum f {..<n} \<le> suminf f

goal (2 subgoals):
 1. \<And>n. (0::'a) \<le> zero_on f X n
 2. \<And>n. sum (zero_on f X) {..<n} \<le> ?x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum (zero_on f X) {..<n} \<le> suminf f
[PROOF STEP]
show "sum (zero_on f X) {..<n} \<le> suminf f"
[PROOF STATE]
proof (prove)
using this:
sum (zero_on f X) {..<n} \<le> suminf f

goal (1 subgoal):
 1. sum (zero_on f X) {..<n} \<le> suminf f
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum (zero_on f X) {..<n} \<le> suminf f

goal (1 subgoal):
 1. \<And>n. (0::'a) \<le> zero_on f X n
[PROOF STEP]
qed(simp add: zero_on_nonneg nonneg)


[STATEMENT]
lemma filter_exist:
  assumes "s \<in> closed_seqs Zp"
  assumes "\<forall>n::nat. \<exists>m. m > n \<and> P (s m)"
  shows "\<And>m. n\<le>m \<Longrightarrow> P (s (seq_filter s P n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m. n \<le> m \<Longrightarrow> P (s (seq_filter s P n))
[PROOF STEP]
proof(induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. 0 \<le> m \<Longrightarrow> P (s (seq_filter s P 0))
 2. \<And>n m. \<lbrakk>\<And>m. n \<le> m \<Longrightarrow> P (s (seq_filter s P n)); Suc n \<le> m\<rbrakk> \<Longrightarrow> P (s (seq_filter s P (Suc n)))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 \<le> m

goal (2 subgoals):
 1. \<And>m. 0 \<le> m \<Longrightarrow> P (s (seq_filter s P 0))
 2. \<And>n m. \<lbrakk>\<And>m. n \<le> m \<Longrightarrow> P (s (seq_filter s P n)); Suc n \<le> m\<rbrakk> \<Longrightarrow> P (s (seq_filter s P (Suc n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> m
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 \<le> m

goal (1 subgoal):
 1. P (s (seq_filter s P 0))
[PROOF STEP]
using LeastI assms(2)
[PROOF STATE]
proof (prove)
using this:
0 \<le> m
?P ?k \<Longrightarrow> ?P (LEAST x. ?P x)
\<forall>n. \<exists>m>n. P (s m)

goal (1 subgoal):
 1. P (s (seq_filter s P 0))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
P (s (seq_filter s P 0))

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

goal (1 subgoal):
 1. \<And>n m. \<lbrakk>\<And>m. n \<le> m \<Longrightarrow> P (s (seq_filter s P n)); Suc n \<le> m\<rbrakk> \<Longrightarrow> P (s (seq_filter s P (Suc n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<le> ?m2 \<Longrightarrow> P (s (seq_filter s P n))
Suc n \<le> m
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
n \<le> ?m2 \<Longrightarrow> P (s (seq_filter s P n))
Suc n \<le> m

goal (1 subgoal):
 1. P (s (seq_filter s P (Suc n)))
[PROOF STEP]
by (smt LeastI assms(2) seq_filter.simps(2))
[PROOF STATE]
proof (state)
this:
P (s (seq_filter s P (Suc n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Si_neg:
  assumes "T \<ge> 0" shows "Si (- T) = - Si T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
have "LBINT x=ereal 0..T. -1 *\<^sub>R sinc (- x) = LBINT y= ereal (- 0)..ereal (- T). sinc y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LBINT x=ereal 0..ereal T. - 1 *\<^sub>R sinc (- x) = interval_lebesgue_integral lborel (ereal (- 0)) (ereal (- T)) sinc
[PROOF STEP]
by (rule interval_integral_substitution_finite [OF assms])
       (auto intro: derivative_intros continuous_at_imp_continuous_on isCont_sinc)
[PROOF STATE]
proof (state)
this:
LBINT x=ereal 0..ereal T. - 1 *\<^sub>R sinc (- x) = interval_lebesgue_integral lborel (ereal (- 0)) (ereal (- T)) sinc

goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
LBINT x=ereal 0..ereal T. - 1 *\<^sub>R sinc (- x) = interval_lebesgue_integral lborel (ereal (- 0)) (ereal (- T)) sinc

goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
have "(LBINT x=ereal 0..T. -1 *\<^sub>R sinc (- x)) = -(LBINT x=ereal 0..T. sinc x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LBINT x=ereal 0..ereal T. - 1 *\<^sub>R sinc (- x) = - interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc
[PROOF STEP]
by (subst sinc_neg) (simp_all add: interval_lebesgue_integral_uminus)
[PROOF STATE]
proof (state)
this:
LBINT x=ereal 0..ereal T. - 1 *\<^sub>R sinc (- x) = - interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc

goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
- interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc = interval_lebesgue_integral lborel (ereal (- 0)) (ereal (- T)) sinc
[PROOF STEP]
have *: "-(LBINT x=ereal 0..T. sinc x) = LBINT y= ereal 0..ereal (- T). sinc y"
[PROOF STATE]
proof (prove)
using this:
- interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc = interval_lebesgue_integral lborel (ereal (- 0)) (ereal (- T)) sinc

goal (1 subgoal):
 1. - interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc = interval_lebesgue_integral lborel (ereal 0) (ereal (- T)) sinc
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- interval_lebesgue_integral lborel (ereal 0) (ereal T) sinc = interval_lebesgue_integral lborel (ereal 0) (ereal (- T)) sinc

goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> T

goal (1 subgoal):
 1. Si (- T) = - Si T
[PROOF STEP]
unfolding Si_alt_def
[PROOF STATE]
proof (prove)
using this:
0 \<le> T

goal (1 subgoal):
 1. interval_lebesgue_integral lborel 0 (ereal (- T)) sinc = - interval_lebesgue_integral lborel 0 (ereal T) sinc
[PROOF STEP]
by (subst zero_ereal_def)+ (auto simp add: * [symmetric])
[PROOF STATE]
proof (state)
this:
Si (- T) = - Si T

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma row_matrix_matrix_mult:
  fixes A::"'a::{comm_ring_1}^'n^'m"
  shows "(P $ i) v* A = (P ** A) $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P $ i v* A = (P ** A) $ i
[PROOF STEP]
unfolding vec_eq_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>ia. (P $ i v* A) $ ia = (P ** A) $ i $ ia
[PROOF STEP]
unfolding vector_matrix_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>ia. (\<chi>j. \<Sum>ia\<in>UNIV. A $ ia $ j * P $ i $ ia) $ ia = (P ** A) $ i $ ia
[PROOF STEP]
unfolding matrix_matrix_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>ia. (\<chi>j. \<Sum>ia\<in>UNIV. A $ ia $ j * P $ i $ ia) $ ia = (\<chi>i j. \<Sum>k\<in>UNIV. P $ i $ k * A $ k $ j) $ i $ ia
[PROOF STEP]
by (auto intro!: sum.cong)