[STATEMENT]
lemma box_midpoint:
  fixes a :: "'a::euclidean_space"
  assumes "box a b \<noteq> {}"
  shows "((1/2) *\<^sub>R (a + b)) \<in> box a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 / 2) *\<^sub>R (a + b) \<in> box a b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (1 / 2) *\<^sub>R (a + b) \<in> box a b
[PROOF STEP]
have "a \<bullet> i < ((1 / 2) *\<^sub>R (a + b)) \<bullet> i \<and> ((1 / 2) *\<^sub>R (a + b)) \<bullet> i < b \<bullet> i" if "i \<in> Basis" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<bullet> i < (1 / 2) *\<^sub>R (a + b) \<bullet> i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> i < b \<bullet> i
[PROOF STEP]
using assms that
[PROOF STATE]
proof (prove)
using this:
box a b \<noteq> {}
i \<in> Basis

goal (1 subgoal):
 1. a \<bullet> i < (1 / 2) *\<^sub>R (a + b) \<bullet> i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> i < b \<bullet> i
[PROOF STEP]
by (auto simp: inner_add_left box_ne_empty)
[PROOF STATE]
proof (state)
this:
?i \<in> Basis \<Longrightarrow> a \<bullet> ?i < (1 / 2) *\<^sub>R (a + b) \<bullet> ?i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> ?i < b \<bullet> ?i

goal (1 subgoal):
 1. (1 / 2) *\<^sub>R (a + b) \<in> box a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i \<in> Basis \<Longrightarrow> a \<bullet> ?i < (1 / 2) *\<^sub>R (a + b) \<bullet> ?i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> ?i < b \<bullet> ?i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?i \<in> Basis \<Longrightarrow> a \<bullet> ?i < (1 / 2) *\<^sub>R (a + b) \<bullet> ?i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> ?i < b \<bullet> ?i

goal (1 subgoal):
 1. (1 / 2) *\<^sub>R (a + b) \<in> box a b
[PROOF STEP]
unfolding mem_box
[PROOF STATE]
proof (prove)
using this:
?i \<in> Basis \<Longrightarrow> a \<bullet> ?i < (1 / 2) *\<^sub>R (a + b) \<bullet> ?i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> ?i < b \<bullet> ?i

goal (1 subgoal):
 1. \<forall>i\<in>Basis. a \<bullet> i < (1 / 2) *\<^sub>R (a + b) \<bullet> i \<and> (1 / 2) *\<^sub>R (a + b) \<bullet> i < b \<bullet> i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(1 / 2) *\<^sub>R (a + b) \<in> box a b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_of_bool_eq_card:
  assumes "finite S"
  shows "(\<Sum>a \<in> S. of_bool (P a)) = real (card {a \<in> S . P a })"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = real (card {a \<in> S. P a})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = real (card {a \<in> S. P a})
[PROOF STEP]
have "(\<Sum>a \<in> S. of_bool (P a) :: real) = (\<Sum>a \<in> {x\<in>S. P x}. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = (\<Sum>a\<in>{x \<in> S. P x}. 1)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite S

goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = (\<Sum>a\<in>{x \<in> S. P x}. 1)
[PROOF STEP]
by (intro sum.mono_neutral_cong_right) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<in>S. of_bool (P a)) = (\<Sum>a\<in>{x \<in> S. P x}. 1)

goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = real (card {a \<in> S. P a})
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>a\<in>S. of_bool (P a)) = (\<Sum>a\<in>{x \<in> S. P x}. 1)

goal (1 subgoal):
 1. (\<Sum>a\<in>S. of_bool (P a)) = real (card {a \<in> S. P a})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<in>S. of_bool (P a)) = real (card {a \<in> S. P a})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Sup_downset_adj_var: "(Sup (X::'a::complete_lattice set) \<le> y) = (X \<subseteq> \<down>y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Squnion> X \<le> y) = (X \<subseteq> \<down> y)
[PROOF STEP]
using Sup_downset_adj adj_def
[PROOF STATE]
proof (prove)
using this:
Sup \<stileturn> \<down>
?f \<stileturn> ?g = (\<forall>x y. (?f x \<le> y) = (x \<le> ?g y))

goal (1 subgoal):
 1. (\<Squnion> X \<le> y) = (X \<subseteq> \<down> y)
[PROOF STEP]
by auto


[STATEMENT]
lemma hyperbola_method_sqrt:
  fixes f g :: "nat \<Rightarrow> 'a :: comm_ring"
  assumes "x \<ge> 0"
  shows   "sum_upto (dirichlet_prod f g) x =
             sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) +
             sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x) -
             sum_upto f (sqrt x) * sum_upto g (sqrt x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_upto (dirichlet_prod f g) x = sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x) - sum_upto f (sqrt x) * sum_upto g (sqrt x)
[PROOF STEP]
using assms hyperbola_method[of "sqrt x" "sqrt x" x]
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
\<lbrakk>0 \<le> sqrt x; 0 \<le> sqrt x; sqrt x * sqrt x = x\<rbrakk> \<Longrightarrow> sum_upto (dirichlet_prod ?f ?g) x = sum_upto (\<lambda>n. ?f n * sum_upto ?g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto ?f (x / real n) * ?g n) (sqrt x) - sum_upto ?f (sqrt x) * sum_upto ?g (sqrt x)

goal (1 subgoal):
 1. sum_upto (dirichlet_prod f g) x = sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x) - sum_upto f (sqrt x) * sum_upto g (sqrt x)
[PROOF STEP]
by simp


[STATEMENT]
lemma connected_component_intermediate_subset:
        "\<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U\<rbrakk>
        \<Longrightarrow> connected_component_set T a = connected_component_set U a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U\<rbrakk> \<Longrightarrow> connected_component_set T a = connected_component_set U a
[PROOF STEP]
apply (case_tac "a \<in> U")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U; a \<in> U\<rbrakk> \<Longrightarrow> connected_component_set T a = connected_component_set U a
 2. \<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U; a \<notin> U\<rbrakk> \<Longrightarrow> connected_component_set T a = connected_component_set U a
[PROOF STEP]
apply (simp add: connected_component_maximal connected_component_mono subset_antisym)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U; a \<notin> U\<rbrakk> \<Longrightarrow> connected_component_set T a = connected_component_set U a
[PROOF STEP]
using connected_component_eq_empty
[PROOF STATE]
proof (prove)
using this:
(connected_component_set ?S ?x = {}) = (?x \<notin> ?S)

goal (1 subgoal):
 1. \<lbrakk>connected_component_set U a \<subseteq> T; T \<subseteq> U; a \<notin> U\<rbrakk> \<Longrightarrow> connected_component_set T a = connected_component_set U a
[PROOF STEP]
by blast


[STATEMENT]
lemma scalar_prod_minus_distrib: fixes v\<^sub>1 :: "'a :: ring vec"
  assumes v: "v\<^sub>1 \<in> carrier_vec n" "v\<^sub>2 \<in> carrier_vec n" "v\<^sub>3 \<in> carrier_vec n"
  shows "v\<^sub>1 \<bullet> (v\<^sub>2 - v\<^sub>3) = v\<^sub>1 \<bullet> v\<^sub>2 - v\<^sub>1 \<bullet> v\<^sub>3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v\<^sub>1 \<bullet> (v\<^sub>2 - v\<^sub>3) = v\<^sub>1 \<bullet> v\<^sub>2 - v\<^sub>1 \<bullet> v\<^sub>3
[PROOF STEP]
unfolding minus_add_uminus_vec[OF v(2-3)]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v\<^sub>1 \<bullet> (v\<^sub>2 + - v\<^sub>3) = v\<^sub>1 \<bullet> v\<^sub>2 - v\<^sub>1 \<bullet> v\<^sub>3
[PROOF STEP]
by (subst scalar_prod_add_distrib[OF v(1)], insert v, auto)


[STATEMENT]
lemma permutation_mat_dim[simp]: "permutation_mat n p \<in> carrier_mat n n"
  "dim_row (permutation_mat n p) = n"
  "dim_col (permutation_mat n p) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. permutation_mat n p \<in> carrier_mat n n &&& dim_row (permutation_mat n p) = n &&& dim_col (permutation_mat n p) = n
[PROOF STEP]
unfolding permutation_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat n n (\<lambda>(i, j). if i = p j then 1::'a else (0::'a)) \<in> carrier_mat n n &&& dim_row (Matrix.mat n n (\<lambda>(i, j). if i = p j then 1::'b else (0::'b))) = n &&& dim_col (Matrix.mat n n (\<lambda>(i, j). if i = p j then 1::'c else (0::'c))) = n
[PROOF STEP]
by auto


[STATEMENT]
lemma card_remove_fset_less1:
  shows "x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs
[PROOF STEP]
unfolding card_fset in_fset remove_fset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> fset xs \<Longrightarrow> card (fset xs - {x}) < card (fset xs)
[PROOF STEP]
by (rule card_Diff1_less[OF finite_fset])


[STATEMENT]
lemma star_power_slide:
  assumes "k \<le> n"
  shows "x\<^bsup>k \<^esup>\<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
k \<le> n
[PROOF STEP]
have "x\<^bsup>k \<^esup>\<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>k \<^esup>\<cdot> x\<^bsup>n-k\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>"
[PROOF STATE]
proof (prove)
using this:
k \<le> n

goal (1 subgoal):
 1. x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>k\<^esup> \<cdot> x\<^bsup>n - k\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
by (metis (full_types) le_add_diff_inverse2 power_add star_slide)
[PROOF STATE]
proof (state)
this:
x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>k\<^esup> \<cdot> x\<^bsup>n - k\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>

goal (1 subgoal):
 1. x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
k \<le> n
x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>k\<^esup> \<cdot> x\<^bsup>n - k\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k \<le> n
x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>k\<^esup> \<cdot> x\<^bsup>n - k\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>

goal (1 subgoal):
 1. x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>
[PROOF STEP]
by (metis (full_types) le_add_diff_inverse2 ab_semigroup_add_class.add.commute power_add)
[PROOF STATE]
proof (state)
this:
x\<^bsup>k\<^esup> \<cdot> (x\<^bsup>n\<^esup>)\<^sup>\<star> = (x\<^bsup>n\<^esup>)\<^sup>\<star> \<cdot> x\<^bsup>k\<^esup>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complement_4_language: "language (complement_3 A) = language (complement_4 A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. language (complement_3 A) = language (complement_4 A)
[PROOF STEP]
using complement_4_language_1 complement_4_language_2
[PROOF STATE]
proof (prove)
using this:
language (complement_3 ?A) \<subseteq> language (complement_4 ?A)
language (complement_4 ?A) \<subseteq> language (complement_3 ?A)

goal (1 subgoal):
 1. language (complement_3 A) = language (complement_4 A)
[PROOF STEP]
by blast


[STATEMENT]
lemma strict_dominate_trans:
  assumes "strict_dominate n1 n2"
      and "strict_dominate n2 n3"
    shows "strict_dominate n1 n3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_dominate n1 n3
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
strict_dominate n1 n2
strict_dominate n2 n3

goal (1 subgoal):
 1. strict_dominate n1 n3
[PROOF STEP]
apply(subgoal_tac "dominate n2 n3")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>strict_dominate n1 n2; strict_dominate n2 n3; dominate n2 n3\<rbrakk> \<Longrightarrow> strict_dominate n1 n3
 2. \<lbrakk>strict_dominate n1 n2; strict_dominate n2 n3\<rbrakk> \<Longrightarrow> dominate n2 n3
[PROOF STEP]
apply(rule strict_dominate_trans1)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>strict_dominate n1 n2; strict_dominate n2 n3; dominate n2 n3\<rbrakk> \<Longrightarrow> strict_dominate n1 ?n2.3
 2. \<lbrakk>strict_dominate n1 n2; strict_dominate n2 n3; dominate n2 n3\<rbrakk> \<Longrightarrow> dominate ?n2.3 n3
 3. \<lbrakk>strict_dominate n1 n2; strict_dominate n2 n3\<rbrakk> \<Longrightarrow> dominate n2 n3
[PROOF STEP]
apply (auto simp add: strict_dominate_def dominate_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma euclid_diff:
   "PRE (\<lambda>s::nat store. s ''x'' = x \<and> s ''y'' = y \<and> x > 0 \<and> y > 0)
    (WHILE (\<lambda>s. s ''x''\<noteq> s ''y'') INV (\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y)
     DO
        (IF (\<lambda>s. s ''x'' >  s ''y'')
         THEN (''x'' ::= (\<lambda>s. s ''x'' - s ''y''))
         ELSE (''y'' ::= (\<lambda>s. s ''y'' - s ''x''))
         FI)
    OD)
    POST (\<lambda>s. s ''x'' = gcd x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rdom \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y \<and> 0 < x \<and> 0 < y\<rceil> \<subseteq> wp (WHILE (\<lambda>s. s ''x'' \<noteq> s ''y'') INV (\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y) DO (IF (\<lambda>s. s ''y'' < s ''x'') THEN (''x'' ::= (\<lambda>s. s ''x'' - s ''y'')) ELSE (''y'' ::= (\<lambda>s. s ''y'' - s ''x'')) FI) OD) \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
[PROOF STEP]
apply (rule rel_antidomain_kleene_algebra.fbox_whilei, simp_all)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> s ''x'' = s ''y'' \<longrightarrow> s ''y'' = gcd x y
 2. \<forall>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> s ''x'' \<noteq> s ''y'' \<longrightarrow> (s ''y'' < s ''x'' \<longrightarrow> gcd (s ''x'' - s ''y'') (s ''y'') = gcd x y) \<and> (s ''y'' < s ''x'' \<or> gcd (s ''x'') (s ''y'' - s ''x'') = gcd x y)
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> s ''x'' \<noteq> s ''y'' \<longrightarrow> (s ''y'' < s ''x'' \<longrightarrow> gcd (s ''x'' - s ''y'') (s ''y'') = gcd x y) \<and> (s ''y'' < s ''x'' \<or> gcd (s ''x'') (s ''y'' - s ''x'') = gcd x y)
[PROOF STEP]
by (metis gcd.commute gcd_diff1_nat le_cases nat_less_le)


[STATEMENT]
lemma scaleC_cadjoint:
  fixes A::"'a::chilbert_space \<Rightarrow> 'b::complex_inner"
  assumes "bounded_clinear A"
  shows \<open>(\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)
[PROOF STEP]
have b3: \<open>((\<lambda> s. (cnj a) *\<^sub>C ((A\<^sup>\<dagger>) s)) x \<bullet>\<^sub>C y) = (x \<bullet>\<^sub>C (\<lambda> t. a *\<^sub>C (A t)) y)\<close>
    for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnj a *\<^sub>C (A\<^sup>\<dagger>) x \<bullet>\<^sub>C y = x \<bullet>\<^sub>C a *\<^sub>C A y
[PROOF STEP]
by (simp add: assms cadjoint_univ_prop)
[PROOF STATE]
proof (state)
this:
cnj a *\<^sub>C (A\<^sup>\<dagger>) ?x \<bullet>\<^sub>C ?y = ?x \<bullet>\<^sub>C a *\<^sub>C A ?y

goal (1 subgoal):
 1. (\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)
[PROOF STEP]
have "((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b"
    for b::'b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b
[PROOF STEP]
have "bounded_clinear (\<lambda>t. a *\<^sub>C A t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded_clinear (\<lambda>t. a *\<^sub>C A t)
[PROOF STEP]
by (simp add: assms bounded_clinear_const_scaleC)
[PROOF STATE]
proof (state)
this:
bounded_clinear (\<lambda>t. a *\<^sub>C A t)

goal (1 subgoal):
 1. ((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
bounded_clinear (\<lambda>t. a *\<^sub>C A t)

goal (1 subgoal):
 1. ((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b
[PROOF STEP]
by (metis (no_types) cadjoint_eqI b3)
[PROOF STATE]
proof (state)
this:
((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) b = cnj a *\<^sub>C (A\<^sup>\<dagger>) b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) ?b = cnj a *\<^sub>C (A\<^sup>\<dagger>) ?b

goal (1 subgoal):
 1. (\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger>) ?b = cnj a *\<^sub>C (A\<^sup>\<dagger>) ?b

goal (1 subgoal):
 1. (\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>t. a *\<^sub>C A t)\<^sup>\<dagger> = (\<lambda>s. cnj a *\<^sub>C (A\<^sup>\<dagger>) s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma length_strict_mono: "strict_mono (f::nat \<Rightarrow> 'a list) \<Longrightarrow> length (f i) \<ge> i + length (f 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_mono f \<Longrightarrow> i + length (f 0) \<le> length (f i)
[PROOF STEP]
apply(induct i, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>strict_mono f \<Longrightarrow> i + length (f 0) \<le> length (f i); strict_mono f\<rbrakk> \<Longrightarrow> Suc i + length (f 0) \<le> length (f (Suc i))
[PROOF STEP]
by (metis dual_order.trans lessI less_length_mono not_less not_less_eq_eq plus_nat.simps(2) strict_mono_def)


[STATEMENT]
lemma Inf_pres_downset_var: "(\<Inter>x \<in> X. \<down>x) = \<down>(\<Sqinter>X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> (\<down> ` X) = \<down> (\<Sqinter> X)
[PROOF STEP]
unfolding downset_prop
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Inter>x\<in>X. {y. y \<le> x}) = {y. y \<le> \<Sqinter> X}
[PROOF STEP]
by (safe, simp_all add: le_Inf_iff)


[STATEMENT]
lemma line_equation:
  assumes "z1 \<noteq> z2" and "\<mu> = rot90 (z2 - z1)"
  shows "line z1 z2 = {z. cnj \<mu>*z + \<mu>*cnj z - (cnj \<mu> * z1 + \<mu> * cnj z1)  = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
have "z \<in> line z1 z2 \<longleftrightarrow> Im ((z - z1)/(z2 - z1)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
z1 \<noteq> z2
\<mu> = rot90 (z2 - z1)

goal (1 subgoal):
 1. (z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))
[PROOF STEP]
by (simp add: line_def collinear_def)
[PROOF STATE]
proof (state)
this:
(z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
have "... \<longleftrightarrow> (z - z1)/(z2 - z1) = cnj ((z - z1)/(z2 - z1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_real ((z - z1) / (z2 - z1)) = ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1)))
[PROOF STEP]
using complex_diff_cnj[of "(z - z1)/(z2 - z1)"]
[PROOF STATE]
proof (prove)
using this:
(z - z1) / (z2 - z1) - cnj ((z - z1) / (z2 - z1)) = cor (2 * Im ((z - z1) / (z2 - z1))) * \<i>

goal (1 subgoal):
 1. is_real ((z - z1) / (z2 - z1)) = ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_real ((z - z1) / (z2 - z1)) = ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1)))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
is_real ((z - z1) / (z2 - z1)) = ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1)))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
have "... \<longleftrightarrow> (z - z1)*(cnj z2 - cnj z1) = (cnj z - cnj z1)*(z2 - z1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1))) = ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1))
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
z1 \<noteq> z2

goal (1 subgoal):
 1. ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1))) = ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1))
[PROOF STEP]
using \<open>(z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))\<close> calculation is_real_div
[PROOF STATE]
proof (prove)
using this:
z1 \<noteq> z2
(z \<in> line z1 z2) = is_real ((z - z1) / (z2 - z1))
(z \<in> line z1 z2) = ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1)))
?b \<noteq> 0 \<Longrightarrow> is_real (?a / ?b) = (?a * cnj ?b = ?b * cnj ?a)

goal (1 subgoal):
 1. ((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1))) = ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1))) = ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((z - z1) / (z2 - z1) = cnj ((z - z1) / (z2 - z1))) = ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1))

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
have "... \<longleftrightarrow> cnj(z2 - z1)*z - (z2 - z1)*cnj z - (cnj(z2 - z1)*z1 - (z2 - z1)*cnj z1) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1)) = (cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1)) = (cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((z - z1) * (cnj z2 - cnj z1) = (cnj z - cnj z1) * (z2 - z1)) = (cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
have "... \<longleftrightarrow> cnj \<mu> * z + \<mu> * cnj z  - (cnj \<mu> * z1 + \<mu> * cnj z1) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)
[PROOF STEP]
apply (subst assms)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0) = (cnj_mix (rot90 (z2 - z1)) z - cnj_mix (rot90 (z2 - z1)) z1 = 0)
[PROOF STEP]
apply (subst cnj_mix_minus)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<i> * cnj_mix (rot90 (z2 - z1)) z - \<i> * cnj_mix (rot90 (z2 - z1)) z1 = 0) = (cnj_mix (rot90 (z2 - z1)) z - cnj_mix (rot90 (z2 - z1)) z1 = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(cnj (z2 - z1) * z - (z2 - z1) * cnj z - (cnj (z2 - z1) * z1 - (z2 - z1) * cnj z1) = 0) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(z \<in> line z1 z2) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)
[PROOF STEP]
have "z \<in> line z1 z2 \<longleftrightarrow> cnj \<mu> * z + \<mu> * cnj z  - (cnj \<mu> * z1 + \<mu> * cnj z1) = 0"
[PROOF STATE]
proof (prove)
using this:
(z \<in> line z1 z2) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)

goal (1 subgoal):
 1. (z \<in> line z1 z2) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(z \<in> line z1 z2) = (cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(?z2 \<in> line z1 z2) = (cnj_mix \<mu> ?z2 - cnj_mix \<mu> z1 = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(?z2 \<in> line z1 z2) = (cnj_mix \<mu> ?z2 - cnj_mix \<mu> z1 = 0)

goal (1 subgoal):
 1. line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
line z1 z2 = {z. cnj_mix \<mu> z - cnj_mix \<mu> z1 = 0}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_coeffs_map_poly:
  "(\<And>x. f x = 0 \<longleftrightarrow> x = 0) \<Longrightarrow> set (coeffs (map_poly f p)) = f ` set (coeffs p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. (f x = (0::'b)) = (x = (0::'a))) \<Longrightarrow> set (coeffs (map_poly f p)) = f ` set (coeffs p)
[PROOF STEP]
by (simp add: coeffs_map_poly')


[STATEMENT]
lemma heron_step_real: "\<lbrakk>t > 0; n \<ge> 0\<rbrakk> \<Longrightarrow> (t + n/t) / 2 \<ge> sqrt n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < t; 0 \<le> n\<rbrakk> \<Longrightarrow> sqrt n \<le> (t + n / t) / 2
[PROOF STEP]
using arith_geo_mean_sqrt[of t "n/t"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> t; 0 \<le> n / t\<rbrakk> \<Longrightarrow> sqrt (t * (n / t)) \<le> (t + n / t) / 2

goal (1 subgoal):
 1. \<lbrakk>0 < t; 0 \<le> n\<rbrakk> \<Longrightarrow> sqrt n \<le> (t + n / t) / 2
[PROOF STEP]
by simp


[STATEMENT]
lemma iMin_subset_idem: "\<lbrakk> B \<noteq> {}; B \<subseteq> A \<rbrakk> \<Longrightarrow> min (iMin B) (iMin A) = iMin A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B \<noteq> {}; B \<subseteq> A\<rbrakk> \<Longrightarrow> min (iMin B) (iMin A) = iMin A
[PROOF STEP]
by (metis iMin_subset min.absorb2)


[STATEMENT]
lemma poly_cpoly_of_real_iff:
  shows "poly (cpoly_of pR pI) (of_real t) =0 \<longleftrightarrow> poly pR t = 0 \<and> poly pI t=0 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly (cpoly_of pR pI) (complex_of_real t) = 0) = (poly pR t = 0 \<and> poly pI t = 0)
[PROOF STEP]
unfolding  poly_cpoly_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Complex (poly pR t) (poly pI t) = 0) = (poly pR t = 0 \<and> poly pI t = 0)
[PROOF STEP]
using Complex_eq_0
[PROOF STATE]
proof (prove)
using this:
(Complex ?a ?b = 0) = (?a = 0 \<and> ?b = 0)

goal (1 subgoal):
 1. (Complex (poly pR t) (poly pI t) = 0) = (poly pR t = 0 \<and> poly pI t = 0)
[PROOF STEP]
by blast


[STATEMENT]
lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)"
  for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. (\<Sum>i\<le>n. c i * x ^ i) = (0::'a)) = (\<forall>i\<le>n. c i = (0::'a))
[PROOF STEP]
using zero_polynom_imp_zero_coeffs
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>w. (\<Sum>i\<le>?n. ?c i * w ^ i) = (0::?'a); ?k \<le> ?n\<rbrakk> \<Longrightarrow> ?c ?k = (0::?'a)

goal (1 subgoal):
 1. (\<forall>x. (\<Sum>i\<le>n. c i * x ^ i) = (0::'a)) = (\<forall>i\<le>n. c i = (0::'a))
[PROOF STEP]
by auto


[STATEMENT]
lemma card_injective_functions_domain_and_range_permutation:
  assumes "finite A" "finite B"
  shows "card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
have "bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
by (rule bij_betw_number_partition_of)
[PROOF STATE]
proof (state)
this:
bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
have "card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = card {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}"
[PROOF STATE]
proof (prove)
using this:
bij_betw (number_partition_of A B) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
have "card {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} = iverson (card A \<le> card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} = iverson (card A \<le> card B)
[PROOF STEP]
by (rule card_number_partitions_with_only_parts_1)
[PROOF STATE]
proof (state)
this:
card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition (card A) N \<and> size N \<le> card B} = iverson (card A \<le> card B)

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_and_range_permutation A B) = iverson (card A \<le> card B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prob_space_erlang_density:
  assumes l[arith]: "0 < l"
  shows "prob_space (density lborel (erlang_density k l))" (is "prob_space ?D")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (density lborel (\<lambda>x. ennreal (erlang_density k l x)))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. emeasure (density lborel (\<lambda>x. ennreal (erlang_density k l x))) (space (density lborel (\<lambda>x. ennreal (erlang_density k l x)))) = 1
[PROOF STEP]
show "emeasure ?D (space ?D) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (density lborel (\<lambda>x. ennreal (erlang_density k l x))) (space (density lborel (\<lambda>x. ennreal (erlang_density k l x)))) = 1
[PROOF STEP]
using nn_integral_erlang_ith_moment[OF l, where k=k and i=0]
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ 0) \<partial>lborel = ennreal (fact (k + 0) / (fact k * l ^ 0))

goal (1 subgoal):
 1. emeasure (density lborel (\<lambda>x. ennreal (erlang_density k l x))) (space (density lborel (\<lambda>x. ennreal (erlang_density k l x)))) = 1
[PROOF STEP]
by (simp add: emeasure_density)
[PROOF STATE]
proof (state)
this:
emeasure (density lborel (\<lambda>x. ennreal (erlang_density k l x))) (space (density lborel (\<lambda>x. ennreal (erlang_density k l x)))) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem Ball_def': "(\<forall>x\<in>S. P x) \<longleftrightarrow> (\<forall>x. x \<in> S \<longrightarrow> P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>S. P x) = (\<forall>x. x \<in> S \<longrightarrow> P x)
[PROOF STEP]
by auto


[STATEMENT]
theorem effective_matrix_Tensor_elements:
 fixes M1 M2 i j
 assumes "i<((row_length M1)*(row_length M2))"
     and "j < (length M1)*(length M2)"
     and "mat (row_length M1) (length M1) M1"
     and "mat (row_length M2) (length M2) M2"
 shows
 "((M1 \<otimes> M2)!j!i) = f (M1!(j div (length M2))!(i div (row_length M2)))
(M2!(j mod length M2)!(i mod (row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using matrix_Tensor_elements assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i j. (i < row_length ?M1.0 * row_length ?M2.0 \<and> j < length ?M1.0 * length ?M2.0) \<and> mat (row_length ?M1.0) (length ?M1.0) ?M1.0 \<and> mat (row_length ?M2.0) (length ?M2.0) ?M2.0 \<longrightarrow> (?M1.0 \<otimes> ?M2.0) ! j ! i = ?M1.0 ! (j div length ?M2.0) ! (i div row_length ?M2.0) * ?M2.0 ! (j mod length ?M2.0) ! (i mod row_length ?M2.0)
i < row_length M1 * row_length M2
j < length M1 * length M2
mat (row_length M1) (length M1) M1
mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
by auto


[STATEMENT]
lemma to_bl_plus_carry:
  "to_bl (x + y) =
    rev (foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car))
      (rev (zip (to_bl x) (to_bl y))) (\<lambda>_. []) False)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_bl (x + y) = rev (foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (rev (zip (to_bl x) (to_bl y))) (\<lambda>_. []) False)
[PROOF STEP]
using rbl_add_suc_carry_fold[where xs="rev (to_bl x)" and ys="rev (to_bl y)"]
[PROOF STATE]
proof (prove)
using this:
length (rev (to_bl x)) = length (rev (to_bl y)) \<Longrightarrow> \<forall>car. (if car then rbl_succ else id) (rbl_add (rev (to_bl x)) (rev (to_bl y))) = foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (zip (rev (to_bl x)) (rev (to_bl y))) (\<lambda>_. []) car

goal (1 subgoal):
 1. to_bl (x + y) = rev (foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (rev (zip (to_bl x) (to_bl y))) (\<lambda>_. []) False)
[PROOF STEP]
apply (simp add: word_add_rbl[OF refl refl])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>car. (if car then rbl_succ else id) (rbl_add (rev (to_bl x)) (rev (to_bl y))) = foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (zip (rev (to_bl x)) (rev (to_bl y))) (\<lambda>_. []) car \<Longrightarrow> rbl_add (rev (to_bl x)) (rev (to_bl y)) = foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (rev (zip (to_bl x) (to_bl y))) (\<lambda>_. []) False
[PROOF STEP]
apply (drule_tac x=False in spec)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if False then rbl_succ else id) (rbl_add (rev (to_bl x)) (rev (to_bl y))) = foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (zip (rev (to_bl x)) (rev (to_bl y))) (\<lambda>_. []) False \<Longrightarrow> rbl_add (rev (to_bl x)) (rev (to_bl y)) = foldr (\<lambda>(x, y) res car. xor3 x y car # res (carry x y car)) (rev (zip (to_bl x) (to_bl y))) (\<lambda>_. []) False
[PROOF STEP]
apply (simp add: zip_rev)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma has_integral_cmul_iff:
  assumes "c \<noteq> 0"
  shows   "((\<lambda>x. c *\<^sub>R f x) has_integral (c *\<^sub>R I)) A \<longleftrightarrow> (f has_integral I) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A = (f has_integral I) A
[PROOF STEP]
using assms has_integral_cmul[of f I A c]
        has_integral_cmul[of "\<lambda>x. c *\<^sub>R f x" "c *\<^sub>R I" A "inverse c"]
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0
(f has_integral I) A \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A
((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x /\<^sub>R c) has_integral c *\<^sub>R I /\<^sub>R c) A

goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A = (f has_integral I) A
[PROOF STEP]
by (auto simp: field_simps)


[STATEMENT]
lemma rel_interior_mono:
   "\<lbrakk>S \<subseteq> T; affine hull S = affine hull T\<rbrakk>
   \<Longrightarrow> (rel_interior S) \<subseteq> (rel_interior T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>S \<subseteq> T; affine hull S = affine hull T\<rbrakk> \<Longrightarrow> rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
by (auto simp: rel_interior_def)


[STATEMENT]
lemma homeomorphicI [intro?]:
   "\<lbrakk>f ` S = T; g ` T = S;
     continuous_on S f; continuous_on T g;
     \<And>x. x \<in> S \<Longrightarrow> g(f(x)) = x;
     \<And>y. y \<in> T \<Longrightarrow> f(g(y)) = y\<rbrakk> \<Longrightarrow> S homeomorphic T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f ` S = T; g ` T = S; continuous_on S f; continuous_on T g; \<And>x. x \<in> S \<Longrightarrow> g (f x) = x; \<And>y. y \<in> T \<Longrightarrow> f (g y) = y\<rbrakk> \<Longrightarrow> S homeomorphic T
[PROOF STEP]
unfolding homeomorphic_def homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f ` S = T; g ` T = S; continuous_on S f; continuous_on T g; \<And>x. x \<in> S \<Longrightarrow> g (f x) = x; \<And>y. y \<in> T \<Longrightarrow> f (g y) = y\<rbrakk> \<Longrightarrow> \<exists>f g. (\<forall>x\<in>S. g (f x) = x) \<and> f ` S = T \<and> continuous_on S f \<and> (\<forall>y\<in>T. f (g y) = y) \<and> g ` T = S \<and> continuous_on T g
[PROOF STEP]
by metis


[STATEMENT]
lemma integrable_stretch:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
  assumes "f integrable_on cbox a b"
    and "\<forall>k\<in>Basis. m k \<noteq> 0"
  shows "(\<lambda>x::'a. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) integrable_on
    ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k) ` cbox a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x \<bullet> k)) *\<^sub>R k)) integrable_on (\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x \<bullet> k)) *\<^sub>R k) ` cbox a b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f integrable_on cbox a b
\<forall>k\<in>Basis. m k \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x \<bullet> k)) *\<^sub>R k)) integrable_on (\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x \<bullet> k)) *\<^sub>R k) ` cbox a b
[PROOF STEP]
unfolding integrable_on_def
[PROOF STATE]
proof (prove)
using this:
\<exists>y. (f has_integral y) (cbox a b)
\<forall>k\<in>Basis. m k \<noteq> 0

goal (1 subgoal):
 1. \<exists>y. ((\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x \<bullet> k)) *\<^sub>R k)) has_integral y) ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x \<bullet> k)) *\<^sub>R k) ` cbox a b)
[PROOF STEP]
by (force dest: has_integral_stretch)


[STATEMENT]
lemma cong_mersenne_mod: "[mersenne_mod k n = k] (mod (2 ^ n - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [mersenne_mod k n = k] (mod 2 ^ n - 1)
[PROOF STEP]
unfolding mersenne_mod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [k mod 2 ^ n + k div 2 ^ n = k] (mod 2 ^ n - 1)
[PROOF STEP]
by (rule cong_mersenne_number_int)


[STATEMENT]
lemma has_field_derivative_linepath_within [derivative_intros]:
  assumes [derivative_intros]:
    "(f has_field_derivative f') (at x within S)" "(g has_field_derivative g') (at x within S)"
    "(h has_real_derivative h') (at x within S)"
  shows "((\<lambda>x. linepath (f x) (g x) (h x)) has_field_derivative
           (1 - h x) *\<^sub>R f' + h x *\<^sub>R g' - h' *\<^sub>R (f x - g x)) (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. linepath (f x) (g x) (h x)) has_real_derivative (1 - h x) *\<^sub>R f' + h x *\<^sub>R g' - h' *\<^sub>R (f x - g x)) (at x within S)
[PROOF STEP]
unfolding linepath_def [abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. (1 - h x) *\<^sub>R f x + h x *\<^sub>R g x) has_real_derivative (1 - h x) *\<^sub>R f' + h x *\<^sub>R g' - h' *\<^sub>R (f x - g x)) (at x within S)
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp: field_simps scaleR_diff_right)


[STATEMENT]
lemma winding_number_split_linepath:
  assumes "c \<in> closed_segment a b" "z \<notin> closed_segment a b"
    shows "winding_number(linepath a b) z = winding_number(linepath a c) z + winding_number(linepath c b) z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z
[PROOF STEP]
have "z \<notin> closed_segment a c" "z \<notin> closed_segment c b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<notin> closed_segment a c &&& z \<notin> closed_segment c b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
c \<in> closed_segment a b
z \<notin> closed_segment a b

goal (1 subgoal):
 1. z \<notin> closed_segment a c &&& z \<notin> closed_segment c b
[PROOF STEP]
by (meson convex_contains_segment convex_segment ends_in_segment subsetCE)+
[PROOF STATE]
proof (state)
this:
z \<notin> closed_segment a c
z \<notin> closed_segment c b

goal (1 subgoal):
 1. winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<notin> closed_segment a c
z \<notin> closed_segment c b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
z \<notin> closed_segment a c
z \<notin> closed_segment c b

goal (1 subgoal):
 1. winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
z \<notin> closed_segment a c
z \<notin> closed_segment c b
c \<in> closed_segment a b
z \<notin> closed_segment a b

goal (1 subgoal):
 1. winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z
[PROOF STEP]
by (simp add: winding_number_valid_path contour_integral_split_linepath [symmetric] continuous_on_inversediff field_simps)
[PROOF STATE]
proof (state)
this:
winding_number (linepath a b) z = winding_number (linepath a c) z + winding_number (linepath c b) z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fib_rec_even: "fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. fib (2 * 0) = (fib (0 - 1) + fib (0 + 1)) * fib 0
 2. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. fib (2 * 0) = (fib (0 - 1) + fib (0 + 1)) * fib 0
 2. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fib (2 * 0) = (fib (0 - 1) + fib (0 + 1)) * fib 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fib (2 * 0) = (fib (0 - 1) + fib (0 + 1)) * fib 0

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
let ?rfib = "\<lambda>x. real (fib x)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
have "2 * (Suc n) = Suc (Suc (2 * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * Suc n = Suc (Suc (2 * n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * Suc n = Suc (Suc (2 * n))

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * Suc n = Suc (Suc (2 * n))

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
have "real (fib \<dots>) = ?rfib n^2 + ?rfib (Suc n)^2 + (?rfib (n - 1) + ?rfib (n + 1)) * ?rfib n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (fib (Suc (Suc (2 * n)))) = (real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (real (fib (n - 1)) + real (fib (n + 1))) * real (fib n)
[PROOF STEP]
by (simp add: fib_rec_odd Suc)
[PROOF STATE]
proof (state)
this:
real (fib (Suc (Suc (2 * n)))) = (real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (real (fib (n - 1)) + real (fib (n + 1))) * real (fib n)

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (fib (Suc (Suc (2 * n)))) = (real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (real (fib (n - 1)) + real (fib (n + 1))) * real (fib n)

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
have "(?rfib (n - 1) + ?rfib (n + 1)) * ?rfib n = (2 * ?rfib (n + 1) - ?rfib n) * ?rfib n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real (fib (n - 1)) + real (fib (n + 1))) * real (fib n) = (2 * real (fib (n + 1)) - real (fib n)) * real (fib n)
[PROOF STEP]
by (cases n) simp_all
[PROOF STATE]
proof (state)
this:
(real (fib (n - 1)) + real (fib (n + 1))) * real (fib n) = (2 * real (fib (n + 1)) - real (fib n)) * real (fib n)

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(real (fib (n - 1)) + real (fib (n + 1))) * real (fib n) = (2 * real (fib (n + 1)) - real (fib n)) * real (fib n)

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
have "?rfib n^2 + ?rfib (Suc n)^2 + \<dots> = (?rfib (Suc n) + 2 * ?rfib n) * ?rfib (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (2 * real (fib (n + 1)) - real (fib n)) * real (fib n) = (real (fib (Suc n)) + 2 * real (fib n)) * real (fib (Suc n))
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
(real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (2 * real (fib (n + 1)) - real (fib n)) * real (fib n) = (real (fib (Suc n)) + 2 * real (fib n)) * real (fib (Suc n))

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(real (fib n))\<^sup>2 + (real (fib (Suc n)))\<^sup>2 + (2 * real (fib (n + 1)) - real (fib n)) * real (fib n) = (real (fib (Suc n)) + 2 * real (fib n)) * real (fib (Suc n))

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
have "\<dots> = real ((fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real (fib (Suc n)) + 2 * real (fib n)) * real (fib (Suc n)) = real ((fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(real (fib (Suc n)) + 2 * real (fib n)) * real (fib (Suc n)) = real ((fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n))

goal (1 subgoal):
 1. \<And>n. fib (2 * n) = (fib (n - 1) + fib (n + 1)) * fib n \<Longrightarrow> fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (fib (2 * Suc n)) = real ((fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
real (fib (2 * Suc n)) = real ((fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n))

goal (1 subgoal):
 1. fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)
[PROOF STEP]
by (simp only: of_nat_eq_iff)
[PROOF STATE]
proof (state)
this:
fib (2 * Suc n) = (fib (Suc n - 1) + fib (Suc n + 1)) * fib (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem sum_of_cubes: "real (\<Sum>k\<le>n::nat. k ^ 3) = real (n ^ 2 + n) ^ 2 / 4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (\<Sum>k\<le>n. k ^ 3) = (real (n\<^sup>2 + n))\<^sup>2 / 4
[PROOF STEP]
by (simp only: of_nat_sum of_nat_power sum_of_powers)
     (simp add: bernoulli_unroll_all field_simps power2_eq_square power_numeral_reduce)


[STATEMENT]
theorem nn_integral_liminf:
  fixes u :: "nat \<Rightarrow> 'a \<Rightarrow> ennreal"
  assumes u: "\<And>i. u i \<in> borel_measurable M"
  shows "(\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M) \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
have "(\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M) = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)
[PROOF STEP]
unfolding liminf_SUP_INF
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. (SUP n. INF n\<in>{n..}. u n x) \<partial>M = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)
[PROOF STEP]
using u
[PROOF STATE]
proof (prove)
using this:
u ?i \<in> borel_measurable M

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. (SUP n. INF n\<in>{n..}. u n x) \<partial>M = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)
[PROOF STEP]
by (intro nn_integral_monotone_convergence_SUP_AE)
       (auto intro!: AE_I2 intro: INF_greatest INF_superset_mono)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M = (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
have "\<dots> \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M) \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
by (auto simp: liminf_SUP_INF intro!: SUP_mono INF_greatest nn_integral_mono INF_lower)
[PROOF STATE]
proof (state)
this:
(SUP n. \<integral>\<^sup>+ x. (INF i\<in>{n..}. u i x) \<partial>M) \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. liminf (\<lambda>n. u n x) \<partial>M \<le> liminf (\<lambda>n. integral\<^sup>N M (u n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_Int_conv: "
  \<lbrakk> finite A; finite B \<rbrakk> \<Longrightarrow>
  card (A \<inter> B) = card A + card B - card (A \<union> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> card (A \<inter> B) = card A + card B - card (A \<union> B)
[PROOF STEP]
by (simp only: card_Un_Int diff_add_inverse)


[STATEMENT]
theorem meld_correct:
  assumes I: "invar q" "invar q'"
  shows
  "invar (meld q q')"
  "queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar (meld q q') &&& queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'
[PROOF STEP]
using meld_invar[of q q'] meld_mset[of q q'] I
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>invar q; invar q'\<rbrakk> \<Longrightarrow> invar (meld q q')
\<lbrakk>queue_invar q; queue_invar q'\<rbrakk> \<Longrightarrow> queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'
invar q
invar q'

goal (1 subgoal):
 1. invar (meld q q') &&& queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'
[PROOF STEP]
unfolding invar_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>queue_invar q \<and> rank_skew_invar q; queue_invar q' \<and> rank_skew_invar q'\<rbrakk> \<Longrightarrow> queue_invar (meld q q') \<and> rank_skew_invar (meld q q')
\<lbrakk>queue_invar q; queue_invar q'\<rbrakk> \<Longrightarrow> queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'
queue_invar q \<and> rank_skew_invar q
queue_invar q' \<and> rank_skew_invar q'

goal (1 subgoal):
 1. queue_invar (meld q q') \<and> rank_skew_invar (meld q q') &&& queue_to_multiset (meld q q') = queue_to_multiset q + queue_to_multiset q'
[PROOF STEP]
by simp_all


[STATEMENT]
lemma lubmap_below_cong:
  assumes "\<And> k v. m k = Some v \<Longrightarrow> f1 k v \<sqsubseteq> (f2 k v :: 'a :: Join_cpo)"
  shows "(\<Squnion> k\<mapsto>v\<in>m. f1 k v) \<sqsubseteq> (\<Squnion> k\<mapsto>v\<in>m. f2 k v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lub (mapCollect f1 m) \<sqsubseteq> lub (mapCollect f2 m)
[PROOF STEP]
apply (rule lubmap_belowI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k v. m k = Some v \<Longrightarrow> f1 k v \<sqsubseteq> lub (mapCollect f2 m)
[PROOF STEP]
apply (rule below_trans[OF assms], assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k v. m k = Some v \<Longrightarrow> f2 k v \<sqsubseteq> lub (mapCollect f2 m)
[PROOF STEP]
apply (rule below_lubmapI, assumption)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma eventually_powr_const_mono_nonpos:
  assumes "p \<le> (0 :: real)" "eventually (\<lambda>x. l x > 0) at_top" "eventually (\<lambda>x. l x \<le> f x) at_top"
          "eventually (\<lambda>x. f x \<le> g x) at_top"
  shows   "eventually (\<lambda>x. f x powr p \<ge> g x powr p) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. g x powr p \<le> f x powr p
[PROOF STEP]
using assms(2-4)
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. 0 < l x
\<forall>\<^sub>F x in at_top. l x \<le> f x
\<forall>\<^sub>F x in at_top. f x \<le> g x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. g x powr p \<le> f x powr p
[PROOF STEP]
by eventually_elim (auto simp: assms(1) intro!: powr_mono2')


[STATEMENT]
lemma multiplicity_power_nat:
  "prime p \<Longrightarrow> n > 0 \<Longrightarrow> multiplicity p (n ^ k :: nat) = k * multiplicity p n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; 0 < n\<rbrakk> \<Longrightarrow> multiplicity p (n ^ k) = k * multiplicity p n
[PROOF STEP]
by (induction k) (simp_all add: prime_elem_multiplicity_mult_distrib)


[STATEMENT]
lemma  matrix_invertible_gen:
  fixes f :: "'a::field^'m \<Rightarrow> 'a::field^'n"
  assumes "Vector_Spaces.linear (*s) (*s) f"
  shows  "invertible (matrix f) \<longleftrightarrow> (\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id)"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (matrix f) = (\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. invertible (matrix f) \<Longrightarrow> \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id
 2. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id \<Longrightarrow> invertible (matrix f)
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
invertible (matrix f)

goal (2 subgoals):
 1. invertible (matrix f) \<Longrightarrow> \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id
 2. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id \<Longrightarrow> invertible (matrix f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
invertible (matrix f)
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
invertible (matrix f)

goal (1 subgoal):
 1. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id
[PROOF STEP]
by (metis assms invertible_def left_right_inverse_eq matrix_left_invertible_gen matrix_right_invertible_gen)
[PROOF STATE]
proof (state)
this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id

goal (1 subgoal):
 1. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id \<Longrightarrow> invertible (matrix f)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id \<Longrightarrow> invertible (matrix f)
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id

goal (1 subgoal):
 1. \<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id \<Longrightarrow> invertible (matrix f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
\<exists>g. Vector_Spaces.linear (*s) (*s) g \<and> f \<circ> g = id \<and> g \<circ> f = id

goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
by (metis assms invertible_def matrix_compose_gen matrix_id_mat_1)
[PROOF STATE]
proof (state)
this:
invertible (matrix f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_sin_squared_add_cpx:
  "complex_of_real (cos (\<gamma>/2)) * complex_of_real (cos (\<gamma>/2)) -
   \<i>*complex_of_real (sin (\<gamma>/2)) * (\<i>*complex_of_real (sin (\<gamma>/2))) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (cos (\<gamma> / 2)) * complex_of_real (cos (\<gamma> / 2)) - \<i> * complex_of_real (sin (\<gamma> / 2)) * (\<i> * complex_of_real (sin (\<gamma> / 2))) = 1
[PROOF STEP]
apply (auto simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (cos (\<gamma> / 2)) * complex_of_real (cos (\<gamma> / 2)) + complex_of_real (sin (\<gamma> / 2)) * complex_of_real (sin (\<gamma> / 2)) = 1
[PROOF STEP]
by (metis of_real_add of_real_hom.hom_one of_real_mult sin_cos_squared_add3)


[STATEMENT]
lemma ZmX_inv:
  "ZmX * ZmX = 1\<^sub>m 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ZmX * ZmX = 1\<^sub>m 2
[PROOF STEP]
unfolding ZmX_def X_def Z_def times_mat_def one_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row (complex_of_real (1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)))) (dim_col (complex_of_real (1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)))) (\<lambda>(i, j). Matrix.row (complex_of_real (1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1))) i \<bullet> Matrix.col (complex_of_real (1 / sqrt 2) \<cdot>\<^sub>m (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1))) j) = Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 1 else 0)
[PROOF STEP]
apply (rule cong_mat, simp+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < 2; j < 2\<rbrakk> \<Longrightarrow> (i = j \<longrightarrow> Matrix.row (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) j \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) j = complex_of_real (sqrt 2) * complex_of_real (sqrt 2)) \<and> (i \<noteq> j \<longrightarrow> Matrix.row (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) i \<bullet> Matrix.col (Matrix.mat 2 2 (\<lambda>(i, j). if i \<noteq> j then 0 else if i = 0 then 1 else - 1) - Matrix.mat 2 2 (\<lambda>(i, j). if i = j then 0 else 1)) j = 0)
[PROOF STEP]
apply (auto simp add: Matrix.scalar_prod_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j < 2 \<Longrightarrow> complex_of_real (sqrt 2) * complex_of_real (sqrt 2) = 2
[PROOF STEP]
apply (auto simp add: Gates.csqrt_2_sq)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma dyadics_levels: "dyadics = (\<Union>K. \<Union>k<K. \<Union> m. {of_nat m / 2^k})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dyadics = (\<Union>K. \<Union>k<K. \<Union>m. {of_nat m / (2::'a) ^ k})
[PROOF STEP]
unfolding dyadics_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>k m. {of_nat m / (2::'a) ^ k}) = (\<Union>K. \<Union>k<K. \<Union>m. {of_nat m / (2::'a) ^ k})
[PROOF STEP]
by auto


[STATEMENT]
lemma contour_integral_circlepath:
  assumes "r > 0"
  shows "contour_integral (circlepath z r) (\<lambda>w. 1 / (w - z)) = 2 * complex_of_real pi * \<i>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral (circlepath z r) (\<lambda>w. 1 / (w - z)) = 2 * complex_of_real pi * \<i>
[PROOF STEP]
proof (rule contour_integral_unique)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \<i>) (circlepath z r)
[PROOF STEP]
show "((\<lambda>w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \<i>) (circlepath z r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \<i>) (circlepath z r)
[PROOF STEP]
unfolding has_contour_integral_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. 1 / (circlepath z r x - z) * vector_derivative (circlepath z r) (at x within {0..1})) has_integral 2 * complex_of_real pi * \<i>) {0..1}
[PROOF STEP]
using assms has_integral_const_real [of _ 0 1]
[PROOF STATE]
proof (prove)
using this:
0 < r
((\<lambda>x. ?c) has_integral content {0..1} *\<^sub>R ?c) {0..1}

goal (1 subgoal):
 1. ((\<lambda>x. 1 / (circlepath z r x - z) * vector_derivative (circlepath z r) (at x within {0..1})) has_integral 2 * complex_of_real pi * \<i>) {0..1}
[PROOF STEP]
apply (subst has_integral_cong)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>0 < r; \<And>c. ((\<lambda>x. c) has_integral content {0..1} *\<^sub>R c) {0..1}; x \<in> {0..1}\<rbrakk> \<Longrightarrow> 1 / (circlepath z r x - z) * vector_derivative (circlepath z r) (at x within {0..1}) = ?g3 x
 2. \<lbrakk>0 < r; \<And>c. ((\<lambda>x. c) has_integral content {0..1} *\<^sub>R c) {0..1}\<rbrakk> \<Longrightarrow> (?g3 has_integral 2 * complex_of_real pi * \<i>) {0..1}
[PROOF STEP]
apply (simp add: vector_derivative_circlepath01)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; \<And>c. ((\<lambda>x. c) has_integral content {0..1} *\<^sub>R c) {0..1}\<rbrakk> \<Longrightarrow> ((\<lambda>x. 2 * complex_of_real pi * \<i> * complex_of_real r * exp (2 * complex_of_real pi * \<i> * complex_of_real x) / (circlepath z r x - z)) has_integral 2 * complex_of_real pi * \<i>) {0..1}
[PROOF STEP]
apply (force simp: circlepath)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
((\<lambda>w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \<i>) (circlepath z r)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma left_invertible_iff_invertible:
  fixes M :: "real^'n^'n"
  shows "(\<exists> N. N ** M = mat 1) \<longleftrightarrow> invertible M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>N. N ** M = mat 1) = invertible M
[PROOF STEP]
by (simp add: invertible_def matrix_left_right_inverse)


[STATEMENT]
lemma connectedin_Un:
     "\<lbrakk>connectedin X S; connectedin X T; S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> connectedin X (S \<union> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>connectedin X S; connectedin X T; S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> connectedin X (S \<union> T)
[PROOF STEP]
using connectedin_Union [of "{S,T}"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>Sa. Sa \<in> {S, T} \<Longrightarrow> connectedin ?X Sa; \<Inter> {S, T} \<noteq> {}\<rbrakk> \<Longrightarrow> connectedin ?X (\<Union> {S, T})

goal (1 subgoal):
 1. \<lbrakk>connectedin X S; connectedin X T; S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> connectedin X (S \<union> T)
[PROOF STEP]
by auto


[STATEMENT]
lemma abs_non_negative_sum:  assumes " abs x + abs y = 0"
shows "abs x= 0" and "abs y = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Preliminaries.abs x = 0 &&& Preliminaries.abs y = 0
[PROOF STEP]
using abs_def diff_0 abs_non_negative  neg_0_le_iff_le
 add_nonneg_eq_0_iff assms
[PROOF STATE]
proof (prove)
using this:
Preliminaries.abs ?x \<equiv> if 0 \<le> ?x then ?x else 0 - ?x
(0::?'a) - ?a = - ?a
0 \<le> Preliminaries.abs ?x
((0::?'a) \<le> - ?a) = (?a \<le> (0::?'a))
\<lbrakk>(0::?'a) \<le> ?x; (0::?'a) \<le> ?y\<rbrakk> \<Longrightarrow> (?x + ?y = (0::?'a)) = (?x = (0::?'a) \<and> ?y = (0::?'a))
Preliminaries.abs x + Preliminaries.abs y = 0

goal (1 subgoal):
 1. Preliminaries.abs x = 0 &&& Preliminaries.abs y = 0
[PROOF STEP]
apply (metis)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Preliminaries.abs y = 0
[PROOF STEP]
by (metis abs_non_negative add_nonneg_eq_0_iff assms)


[STATEMENT]
lemma split_sum_first_elt_less: assumes "n<m"
  shows "(\<Sum>i\<in>{n..<m}. f i) = f n + (\<Sum>i\<in>{Suc n ..<m}. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {n..<m} = f n + sum f {Suc n..<m}
[PROOF STEP]
using sum.atLeast_Suc_lessThan assms
[PROOF STATE]
proof (prove)
using this:
?m < ?n \<Longrightarrow> sum ?g {?m..<?n} = ?g ?m + sum ?g {Suc ?m..<?n}
n < m

goal (1 subgoal):
 1. sum f {n..<m} = f n + sum f {Suc n..<m}
[PROOF STEP]
by blast


[STATEMENT]
lemma rank_transpose:
  fixes A :: "real^'n^'m"
  shows "rank(transpose A) = rank A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank (Finite_Cartesian_Product.transpose A) = rank A
[PROOF STEP]
by (metis column_rank_def row_rank_def rows_transpose)


[STATEMENT]
lemma euclid:
  "PRE (\<lambda>s::nat store. s ''x'' = x \<and> s ''y'' = y)
   (WHILE (\<lambda>s. s ''y'' \<noteq> 0) INV (\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y)
    DO
     (''z'' ::= (\<lambda>s. s ''y''));
     (''y'' ::= (\<lambda>s. s ''x'' mod s ''y''));
     (''x'' ::= (\<lambda>s. s ''z''))
    OD)
   POST (\<lambda>s. s ''x'' = gcd x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. PRE (\<lambda>s. s ''x'' = x \<and> s ''y'' = y) (WHILE (\<lambda>s. s ''y'' \<noteq> 0) INV (\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y) DO (''z'' ::= (\<lambda>s. s ''y'')) ; (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ; (''x'' ::= (\<lambda>s. s ''z'')) OD) POST (\<lambda>s. s ''x'' = gcd x y)
[PROOF STEP]
apply hoare
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. \<forall>s. s ''x'' = x \<and> s ''y'' = y \<longrightarrow> gcd (s ''x'') (s ''y'') = gcd x y
 2. \<forall>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> \<not> s ''y'' \<noteq> 0 \<longrightarrow> s ''x'' = gcd x y
 3. \<forall>s. ?Q28 s \<longrightarrow> gcd ((s(''x'' := s ''z'')) ''x'') ((s(''x'' := s ''z'')) ''y'') = gcd x y
 4. \<forall>s. ?Q20 s \<longrightarrow> ?Q28 (s(''y'' := s ''x'' mod s ''y''))
 5. \<forall>s. ((\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y) \<sqinter> (\<lambda>s. s ''y'' \<noteq> 0)) s \<longrightarrow> ?Q20 (s(''z'' := s ''y''))
[PROOF STEP]
using gcd_red_nat
[PROOF STATE]
proof (prove)
using this:
gcd ?x ?y = gcd ?y (?x mod ?y)

goal (5 subgoals):
 1. \<forall>s. s ''x'' = x \<and> s ''y'' = y \<longrightarrow> gcd (s ''x'') (s ''y'') = gcd x y
 2. \<forall>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> \<not> s ''y'' \<noteq> 0 \<longrightarrow> s ''x'' = gcd x y
 3. \<forall>s. ?Q28 s \<longrightarrow> gcd ((s(''x'' := s ''z'')) ''x'') ((s(''x'' := s ''z'')) ''y'') = gcd x y
 4. \<forall>s. ?Q20 s \<longrightarrow> ?Q28 (s(''y'' := s ''x'' mod s ''y''))
 5. \<forall>s. ((\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y) \<sqinter> (\<lambda>s. s ''y'' \<noteq> 0)) s \<longrightarrow> ?Q20 (s(''z'' := s ''y''))
[PROOF STEP]
by auto