[STATEMENT]
lemma mod_hit:
  fixes k :: nat
  assumes \<open>0 < k\<close>
  shows \<open>\<forall>i < k. \<exists>n > m. n mod k = i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<k. \<exists>n>m. n mod k = i
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
let ?n = \<open>(1 + m) * k + i\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
assume \<open>i < k\<close>
[PROOF STATE]
proof (state)
this:
i < k

goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < k
[PROOF STEP]
have \<open>?n mod k = i\<close>
[PROOF STATE]
proof (prove)
using this:
i < k

goal (1 subgoal):
 1. ((1 + m) * k + i) mod k = i
[PROOF STEP]
by (metis mod_less mod_mult_self3)
[PROOF STATE]
proof (state)
this:
((1 + m) * k + i) mod k = i

goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((1 + m) * k + i) mod k = i

goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
have \<open>?n > m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < (1 + m) * k + i
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < k

goal (1 subgoal):
 1. m < (1 + m) * k + i
[PROOF STEP]
by (metis One_nat_def Suc_eq_plus1_left Suc_leI add.commute add_lessD1 less_add_one
        mult.right_neutral nat_mult_less_cancel1 order_le_less trans_less_add1 zero_less_one)
[PROOF STATE]
proof (state)
this:
m < (1 + m) * k + i

goal (1 subgoal):
 1. \<And>i. i < k \<Longrightarrow> \<exists>n>m. n mod k = i
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((1 + m) * k + i) mod k = i
m < (1 + m) * k + i
[PROOF STEP]
show \<open>\<exists>n > m. n mod k = i\<close>
[PROOF STATE]
proof (prove)
using this:
((1 + m) * k + i) mod k = i
m < (1 + m) * k + i

goal (1 subgoal):
 1. \<exists>n>m. n mod k = i
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
\<exists>n>m. n mod k = i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in module) span_union_is_sum:
  fixes A B
  assumes  h2: "A\<subseteq>carrier M" and h3: "B\<subseteq>carrier M"
  shows "span (A\<union> B) = submodule_sum (span A) (span B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
let ?AplusB="submodule_sum (span A) (span B)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from  h2
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> carrier M
[PROOF STEP]
have s0: "submodule R (span A) M"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> carrier M

goal (1 subgoal):
 1. LinearCombinations.submodule R (span A) M
[PROOF STEP]
by (rule span_is_submodule)
[PROOF STATE]
proof (state)
this:
LinearCombinations.submodule R (span A) M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from  h3
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> carrier M
[PROOF STEP]
have s1: "submodule R (span B) M"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> carrier M

goal (1 subgoal):
 1. LinearCombinations.submodule R (span B) M
[PROOF STEP]
by (rule span_is_submodule)
[PROOF STATE]
proof (state)
this:
LinearCombinations.submodule R (span B) M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from s0
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span A) M
[PROOF STEP]
have s0_1: "(span A)\<subseteq>carrier M"
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span A) M

goal (1 subgoal):
 1. span A \<subseteq> carrier M
[PROOF STEP]
by (unfold submodule_def, auto)
[PROOF STATE]
proof (state)
this:
span A \<subseteq> carrier M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from s1
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span B) M
[PROOF STEP]
have s1_1: "(span B)\<subseteq>carrier M"
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span B) M

goal (1 subgoal):
 1. span B \<subseteq> carrier M
[PROOF STEP]
by (unfold submodule_def, auto)
[PROOF STATE]
proof (state)
this:
span B \<subseteq> carrier M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from h2 h3
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> carrier M
B \<subseteq> carrier M
[PROOF STEP]
have 1: "A\<union>B\<subseteq>carrier M"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> carrier M
B \<subseteq> carrier M

goal (1 subgoal):
 1. A \<union> B \<subseteq> carrier M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<union> B \<subseteq> carrier M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from  1
[PROOF STATE]
proof (chain)
picking this:
A \<union> B \<subseteq> carrier M
[PROOF STEP]
have 2: "submodule R (span (A\<union>B)) M"
[PROOF STATE]
proof (prove)
using this:
A \<union> B \<subseteq> carrier M

goal (1 subgoal):
 1. LinearCombinations.submodule R (span (A \<union> B)) M
[PROOF STEP]
by (rule span_is_submodule)
[PROOF STATE]
proof (state)
this:
LinearCombinations.submodule R (span (A \<union> B)) M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from s0 s1
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M
[PROOF STEP]
have 3: "submodule R ?AplusB M"
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M

goal (1 subgoal):
 1. LinearCombinations.submodule R (submodule_sum (span A) (span B)) M
[PROOF STEP]
by (rule sum_is_submodule)
[PROOF STATE]
proof (state)
this:
LinearCombinations.submodule R (submodule_sum (span A) (span B)) M

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
have c1: "span (A\<union>B) \<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
(*span(A\<union>B) \<subseteq> span(A) + span(B) *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from  h2
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> carrier M
[PROOF STEP]
have a1: "A\<subseteq>span A"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> carrier M

goal (1 subgoal):
 1. A \<subseteq> span A
[PROOF STEP]
by (rule in_own_span)
[PROOF STATE]
proof (state)
this:
A \<subseteq> span A

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from s0 s1
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M
[PROOF STEP]
have a2: "span A \<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M

goal (1 subgoal):
 1. span A \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by (rule in_sum)
[PROOF STATE]
proof (state)
this:
span A \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
(*M\<subseteq>M+N*)
[PROOF STATE]
proof (state)
this:
span A \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from a1 a2
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> span A
span A \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
have a3: "A\<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> span A
span A \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. A \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
(*similarly*)
[PROOF STATE]
proof (state)
this:
A \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from  h3
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> carrier M
[PROOF STEP]
have b1: "B\<subseteq>span B"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> carrier M

goal (1 subgoal):
 1. B \<subseteq> span B
[PROOF STEP]
by (rule in_own_span)
[PROOF STATE]
proof (state)
this:
B \<subseteq> span B

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from s1 s0
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span B) M
LinearCombinations.submodule R (span A) M
[PROOF STEP]
have b2: "span B \<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span B) M
LinearCombinations.submodule R (span A) M

goal (1 subgoal):
 1. span B \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by (metis in_sum msum_comm)
[PROOF STATE]
proof (state)
this:
span B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
(*M\<subseteq>M+N*)
[PROOF STATE]
proof (state)
this:
span B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from b1 b2
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> span B
span B \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
have b3: "B\<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> span B
span B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. B \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from a3 b3
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> submodule_sum (span A) (span B)
B \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
have 5: "A\<union>B\<subseteq> ?AplusB"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> submodule_sum (span A) (span B)
B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. A \<union> B \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<union> B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
(*by default simp *)
[PROOF STATE]
proof (state)
this:
A \<union> B \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
from 5 3
[PROOF STATE]
proof (chain)
picking this:
A \<union> B \<subseteq> submodule_sum (span A) (span B)
LinearCombinations.submodule R (submodule_sum (span A) (span B)) M
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A \<union> B \<subseteq> submodule_sum (span A) (span B)
LinearCombinations.submodule R (submodule_sum (span A) (span B)) M

goal (1 subgoal):
 1. span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
[PROOF STEP]
by (rule span_is_subset)
[PROOF STATE]
proof (state)
this:
span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
have c2: "?AplusB \<subseteq> span (A\<union>B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
have 11: "A\<subseteq>A\<union>B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> A \<union> B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<subseteq> A \<union> B

goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
have 12: "B\<subseteq>A\<union>B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<subseteq> A \<union> B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B \<subseteq> A \<union> B

goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
from  11
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> A \<union> B
[PROOF STEP]
have 21:"span A \<subseteq>span (A\<union>B)"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> A \<union> B

goal (1 subgoal):
 1. span A \<subseteq> span (A \<union> B)
[PROOF STEP]
by (rule span_is_monotone)
[PROOF STATE]
proof (state)
this:
span A \<subseteq> span (A \<union> B)

goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
from  12
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> A \<union> B
[PROOF STEP]
have 22:"span B \<subseteq>span (A\<union>B)"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> A \<union> B

goal (1 subgoal):
 1. span B \<subseteq> span (A \<union> B)
[PROOF STEP]
by (rule span_is_monotone)
[PROOF STATE]
proof (state)
this:
span B \<subseteq> span (A \<union> B)

goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
from s0 s1 2 21 22
[PROOF STATE]
proof (chain)
picking this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M
LinearCombinations.submodule R (span (A \<union> B)) M
span A \<subseteq> span (A \<union> B)
span B \<subseteq> span (A \<union> B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
LinearCombinations.submodule R (span A) M
LinearCombinations.submodule R (span B) M
LinearCombinations.submodule R (span (A \<union> B)) M
span A \<subseteq> span (A \<union> B)
span B \<subseteq> span (A \<union> B)

goal (1 subgoal):
 1. submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
by (auto simp add: sum_is_minimal)
[PROOF STATE]
proof (state)
this:
submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
from c1 c2
[PROOF STATE]
proof (chain)
picking this:
span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
span (A \<union> B) \<subseteq> submodule_sum (span A) (span B)
submodule_sum (span A) (span B) \<subseteq> span (A \<union> B)

goal (1 subgoal):
 1. span (A \<union> B) = submodule_sum (span A) (span B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
span (A \<union> B) = submodule_sum (span A) (span B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integral_mono_AE:
  fixes f :: "'a \<Rightarrow> real"
  assumes "integrable M f" "integrable M g" "AE x in M. f x \<le> g x"
  shows "integral\<^sup>L M f \<le> integral\<^sup>L M g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
have "0 \<le> integral\<^sup>L M (\<lambda>x. g x - f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> LINT x|M. g x - f x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
integrable M f
integrable M g
AE x in M. f x \<le> g x

goal (1 subgoal):
 1. 0 \<le> LINT x|M. g x - f x
[PROOF STEP]
by (intro integral_nonneg_AE integrable_diff assms) auto
[PROOF STATE]
proof (state)
this:
0 \<le> LINT x|M. g x - f x

goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 \<le> LINT x|M. g x - f x

goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
have "\<dots> = integral\<^sup>L M g - integral\<^sup>L M f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|M. g x - f x = integral\<^sup>L M g - integral\<^sup>L M f
[PROOF STEP]
by (intro integral_diff assms)
[PROOF STATE]
proof (state)
this:
LINT x|M. g x - f x = integral\<^sup>L M g - integral\<^sup>L M f

goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 \<le> integral\<^sup>L M g - integral\<^sup>L M f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> integral\<^sup>L M g - integral\<^sup>L M f

goal (1 subgoal):
 1. integral\<^sup>L M f \<le> integral\<^sup>L M g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
integral\<^sup>L M f \<le> integral\<^sup>L M g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Re_Im_le_cmod: "Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w
[PROOF STEP]
proof (cases w rule: complex_split_polar)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>r a. \<lbrakk>w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a)); 0 \<le> r; 0 \<le> a; a < 2 * pi\<rbrakk> \<Longrightarrow> Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w
[PROOF STEP]
case (1 r a)
[PROOF STATE]
proof (state)
this:
w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a))
0 \<le> r
0 \<le> a
a < 2 * pi

goal (1 subgoal):
 1. \<And>r a. \<lbrakk>w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a)); 0 \<le> r; 0 \<le> a; a < 2 * pi\<rbrakk> \<Longrightarrow> Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w
[PROOF STEP]
with sin_cos_le1 [of a \<phi>]
[PROOF STATE]
proof (chain)
picking this:
\<bar>sin a * sin \<phi> + cos a * cos \<phi>\<bar> \<le> 1
w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a))
0 \<le> r
0 \<le> a
a < 2 * pi
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>sin a * sin \<phi> + cos a * cos \<phi>\<bar> \<le> 1
w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a))
0 \<le> r
0 \<le> a
a < 2 * pi

goal (1 subgoal):
 1. Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w
[PROOF STEP]
apply (simp add: norm_mult cmod_unit_one)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<bar>sin a * sin \<phi> + cos a * cos \<phi>\<bar> \<le> 1; w = complex_of_real r * (complex_of_real (cos a) + \<i> * complex_of_real (sin a)); 0 \<le> r; 0 \<le> a; a < 2 * pi\<rbrakk> \<Longrightarrow> r * sin a * sin \<phi> + r * cos a * cos \<phi> \<le> r
[PROOF STEP]
by (metis (no_types, opaque_lifting) abs_le_D1 distrib_left mult.commute mult.left_commute mult_left_le)
[PROOF STATE]
proof (state)
this:
Im w * sin \<phi> + Re w * cos \<phi> \<le> cmod w

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lepoll_antisym:
  assumes "A \<lesssim> B" "B \<lesssim> A" shows "A \<approx> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<approx> B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<lesssim> B
B \<lesssim> A

goal (1 subgoal):
 1. A \<approx> B
[PROOF STEP]
unfolding eqpoll_def lepoll_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f. inj_on f A \<and> f ` A \<subseteq> B
\<exists>f. inj_on f B \<and> f ` B \<subseteq> A

goal (1 subgoal):
 1. \<exists>f. bij_betw f A B
[PROOF STEP]
by (metis Schroeder_Bernstein)


[STATEMENT]
lemma imult_iless_mono2: "\<lbrakk> (i::enat) < j; 0 < k; k \<noteq> \<infinity> \<rbrakk> \<Longrightarrow> k * i \<le> k * j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < j; 0 < k; k \<noteq> \<infinity>\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
by (simp only: mult.commute[of k], rule imult_iless_mono1)


[STATEMENT]
lemma cblinfun_apply_code[code]:
  \<comment> \<open>Code equation for \<^term>\<open>cblinfun_apply_code\<close>, i.e., for applying an operator
     to an \<^type>\<open>ell2\<close> vector\<close>
  "vec_of_ell2 (cblinfun_apply_code M x) = (mult_mat_vec (mat_of_cblinfun M) (vec_of_ell2 x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_ell2 (cblinfun_apply_code M x) = mat_of_cblinfun M *\<^sub>v vec_of_ell2 x
[PROOF STEP]
by (simp add: cblinfun_apply_code_def mat_of_cblinfun_cblinfun_apply vec_of_ell2_def)


[STATEMENT]
lemma lower_triangular_suminf:
  assumes "\<And>i. lower_triangular_mat (f i)" "summable (f :: nat \<Rightarrow> 'b::real_normed_vector^_^_)"
  shows "lower_triangular_mat (\<Sum>i. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_triangular_mat (\<Sum>i. f i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
lower_triangular_mat (f ?i)
summable f

goal (1 subgoal):
 1. lower_triangular_mat (\<Sum>i. f i)
[PROOF STEP]
unfolding lower_triangular_mat_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i j. i < j \<longrightarrow> f ?i $ i $ j = (0::'b)
summable f

goal (1 subgoal):
 1. \<forall>i j. i < j \<longrightarrow> suminf f $ i $ j = (0::'b)
[PROOF STEP]
by (subst bounded_linear.suminf) (auto intro: bounded_linear_compose)


[STATEMENT]
lemma (in poly_mod) inverse_mod_coprime:
  assumes p: "prime m"
  and cop: "coprime x m" shows "M (inverse_mod x m * x) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M (inverse_mod x m * x) = 1
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse_mod x m * x mod m = 1
[PROOF STEP]
using inverse_mod_pow[OF cop, of 1] p
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>1 < m; 1 \<noteq> 0\<rbrakk> \<Longrightarrow> inverse_mod x (m ^ 1) * x mod m ^ 1 = 1
prime m

goal (1 subgoal):
 1. inverse_mod x m * x mod m = 1
[PROOF STEP]
by (auto simp: prime_int_iff)


[STATEMENT]
lemma euclid:
  "rel_nabla (
    \<lceil>\<lambda>s::nat store. 0 < s ''y''\<rceil> ;
      ((''z'' ::= (\<lambda>s. s ''y'')) ;
      (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ;
      (''x'' ::= (\<lambda>s. s ''z''))))
    = {}
    \<Longrightarrow>
  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. rel_nabla (\<lceil>\<lambda>s. 0 < s ''y''\<rceil> ; ((''z'' ::= (\<lambda>s. s ''y'')) ; (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ; (''x'' ::= (\<lambda>s. s ''z'')))) = {} \<Longrightarrow> rdom \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> wp (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) \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
[PROOF STEP]
apply (subst rel_fdivka.fbox_arden_whilei[symmetric], simp_all)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_nabla (\<lceil>\<lambda>s. 0 < s ''y''\<rceil> ; ((''z'' ::= (\<lambda>s. s ''y'')) ; (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ; (''x'' ::= (\<lambda>s. s ''z'')))) = {} \<Longrightarrow> \<forall>s. (gcd (s ''x'') (s ''y'') = gcd x y) = ((0 < s ''y'' \<or> s ''x'' = gcd x y) \<and> (s ''y'' = 0 \<or> gcd (s ''y'') (s ''x'' mod s ''y'') = gcd x y))
[PROOF STEP]
using gcd_red_nat gr0I
[PROOF STATE]
proof (prove)
using this:
gcd ?x ?y = gcd ?y (?x mod ?y)
(?n = 0 \<Longrightarrow> False) \<Longrightarrow> 0 < ?n

goal (1 subgoal):
 1. rel_nabla (\<lceil>\<lambda>s. 0 < s ''y''\<rceil> ; ((''z'' ::= (\<lambda>s. s ''y'')) ; (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ; (''x'' ::= (\<lambda>s. s ''z'')))) = {} \<Longrightarrow> \<forall>s. (gcd (s ''x'') (s ''y'') = gcd x y) = ((0 < s ''y'' \<or> s ''x'' = gcd x y) \<and> (s ''y'' = 0 \<or> gcd (s ''y'') (s ''x'' mod s ''y'') = gcd x y))
[PROOF STEP]
by force


[STATEMENT]
lemma cosh_plus_sinh: "cosh x + sinh x = exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cosh x + sinh x = exp x
[PROOF STEP]
by (subst add.commute) (rule sinh_plus_cosh)


[STATEMENT]
lemma pi_approx_54_decimals:
  "abs (pi - 3.141592653589793238462643383279502884197169399375105821 :: real) \<le> inverse (10^54)"
  (is "abs (pi - ?pi') \<le> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
define a :: real
    where "a = 2829469759662002867886529831139137601191652261996513014734415222704732791803 /
           1062141879292765061960538947347721564047051545995266466660439319087625011200"
[PROOF STATE]
proof (state)
this:
a = 2829469759662002867886529831139137601191652261996513014734415222704732791803 / 1062141879292765061960538947347721564047051545995266466660439319087625011200

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
define b :: real
    where "b = 13355545553549848714922837267299490903143206628621657811747118592 /
           23792006023392488526789546722992491355941103837356113731091180925"
[PROOF STATE]
proof (state)
this:
b = 13355545553549848714922837267299490903143206628621657811747118592 / 23792006023392488526789546722992491355941103837356113731091180925

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
define c :: real
    where "c = 28274063397213534906669125255762067746830085389618481175335056 /
           337877029279505250241149903214554249587517250716358486542628059"
[PROOF STATE]
proof (state)
this:
c = 28274063397213534906669125255762067746830085389618481175335056 / 337877029279505250241149903214554249587517250716358486542628059

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
let ?pi'' = "3882327391761098513316067116522233897127356523627918964967729040413954225768920394233198626889767468122598417405434625348404038165437924058179155035564590497837027530349 /
               1235783190199688165469648572769847552336447197542738425378629633275352407743112409829873464564018488572820294102599160968781449606552922108667790799771278860366957772800"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
define eq :: "real \<Rightarrow> real \<Rightarrow> bool" where "eq = (=)"
[PROOF STATE]
proof (state)
this:
eq = (=)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have "abs (pi - pi_approx2 4) \<le> inverse (2^183)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - pi_approx2 4\<bar> \<le> inverse (2 ^ 183)
[PROOF STEP]
by (rule pi_approx2') simp_all
[PROOF STATE]
proof (state)
this:
\<bar>pi - pi_approx2 4\<bar> \<le> inverse (2 ^ 183)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>pi - pi_approx2 4\<bar> \<le> inverse (2 ^ 183)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have "pi_approx2 4 = 48 * arctan_approx 24 (1 / 18) +
                            32 * arctan_approx 16 (1 / 57) -
                            20 * arctan_approx 12 (1 / 239)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pi_approx2 4 = 48 * arctan_approx 24 (1 / 18) + 32 * arctan_approx 16 (1 / 57) - 20 * arctan_approx 12 (1 / 239)
[PROOF STEP]
unfolding pi_approx2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 48 * arctan_approx (6 * 4) (1 / 18) + 32 * arctan_approx (4 * 4) (1 / 57) - 20 * arctan_approx (3 * 4) (1 / 239) = 48 * arctan_approx 24 (1 / 18) + 32 * arctan_approx 16 (1 / 57) - 20 * arctan_approx 12 (1 / 239)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
pi_approx2 4 = 48 * arctan_approx 24 (1 / 18) + 32 * arctan_approx 16 (1 / 57) - 20 * arctan_approx 12 (1 / 239)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pi_approx2 4 = 48 * arctan_approx 24 (1 / 18) + 32 * arctan_approx 16 (1 / 57) - 20 * arctan_approx 12 (1 / 239)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have [unfolded eq_def]: "eq (48 * arctan_approx 24 (1 / 18)) a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (48 * arctan_approx 24 (1 / 18)) a
[PROOF STEP]
by (simp add: arctan_approx_def' power2_eq_square,
        simp add: expand_arctan_approx, unfold a_def eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
48 * arctan_approx 24 (1 / 18) = a

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
48 * arctan_approx 24 (1 / 18) = a

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have [unfolded eq_def]: "eq (32 * arctan_approx 16 (1 / 57::real)) b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (32 * arctan_approx 16 (1 / 57)) b
[PROOF STEP]
by (simp add: arctan_approx_def' power2_eq_square,
        simp add: expand_arctan_approx, unfold b_def eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
32 * arctan_approx 16 (1 / 57) = b

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
32 * arctan_approx 16 (1 / 57) = b

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have [unfolded eq_def]: "eq (20 * arctan_approx 12 (1 / 239::real)) c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (20 * arctan_approx 12 (1 / 239)) c
[PROOF STEP]
by (simp add: arctan_approx_def' power2_eq_square,
        simp add: expand_arctan_approx, unfold c_def eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
20 * arctan_approx 12 (1 / 239) = c

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
20 * arctan_approx 12 (1 / 239) = c

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have [unfolded eq_def]:
    "eq (a + b) (34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 /
                 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (a + b) (34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 / 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400)
[PROOF STEP]
by (unfold a_def b_def c_def, simp, unfold eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
a + b = 34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 / 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a + b = 34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 / 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
have [unfolded eq_def]: "eq (\<dots> - c) ?pi''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 / 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400 - c) (3882327391761098513316067116522233897127356523627918964967729040413954225768920394233198626889767468122598417405434625348404038165437924058179155035564590497837027530349 / 1235783190199688165469648572769847552336447197542738425378629633275352407743112409829873464564018488572820294102599160968781449606552922108667790799771278860366957772800)
[PROOF STEP]
by (unfold a_def b_def c_def, simp, unfold eq_def, rule refl)
  \<comment> \<open>This is incredibly slow because the numerators and denominators are huge.\<close>
[PROOF STATE]
proof (state)
this:
34326487387865555303797183505809267914709125998469664969258315922216638779011304447624792548723974104030355722677 / 10642967245546718617684989689985787964158885991018703366677373121531695267093031090059801733340658960857196134400 - c = 3882327391761098513316067116522233897127356523627918964967729040413954225768920394233198626889767468122598417405434625348404038165437924058179155035564590497837027530349 / 1235783190199688165469648572769847552336447197542738425378629633275352407743112409829873464564018488572820294102599160968781449606552922108667790799771278860366957772800

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>pi - 3882327391761098513316067116522233897127356523627918964967729040413954225768920394233198626889767468122598417405434625348404038165437924058179155035564590497837027530349 / 1235783190199688165469648572769847552336447197542738425378629633275352407743112409829873464564018488572820294102599160968781449606552922108667790799771278860366957772800\<bar> \<le> inverse (2 ^ 183)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>pi - 3882327391761098513316067116522233897127356523627918964967729040413954225768920394233198626889767468122598417405434625348404038165437924058179155035564590497837027530349 / 1235783190199688165469648572769847552336447197542738425378629633275352407743112409829873464564018488572820294102599160968781449606552922108667790799771278860366957772800\<bar> \<le> inverse (2 ^ 183)

goal (1 subgoal):
 1. \<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)
[PROOF STEP]
by (rule approx_coarsen) simp
[PROOF STATE]
proof (state)
this:
\<bar>pi - 3141592653589793238462643383279502884197169399375105821 / 10 ^ 54\<bar> \<le> inverse (10 ^ 54)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ivl_integral_minus_sets:
  fixes f::"real \<Rightarrow> 'a::banach"
  shows "f integrable_on (closed_segment c a) \<Longrightarrow> f integrable_on (closed_segment c b) \<Longrightarrow> f integrable_on (closed_segment a b) \<Longrightarrow>
    ivl_integral c a f - ivl_integral c b f = ivl_integral b a f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f integrable_on closed_segment c a; f integrable_on closed_segment c b; f integrable_on closed_segment a b\<rbrakk> \<Longrightarrow> ivl_integral c a f - ivl_integral c b f = ivl_integral b a f
[PROOF STEP]
using ivl_integral_combine[of f c b a]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f integrable_on closed_segment c b; f integrable_on closed_segment b a; f integrable_on closed_segment c a\<rbrakk> \<Longrightarrow> ivl_integral c b f + ivl_integral b a f = ivl_integral c a f

goal (1 subgoal):
 1. \<lbrakk>f integrable_on closed_segment c a; f integrable_on closed_segment c b; f integrable_on closed_segment a b\<rbrakk> \<Longrightarrow> ivl_integral c a f - ivl_integral c b f = ivl_integral b a f
[PROOF STEP]
by (auto simp: algebra_simps closed_segment_commute)


[STATEMENT]
lemma continuous_log:
  assumes "continuous F f"
    and "continuous F g"
    and "0 < f (Lim F (\<lambda>x. x))"
    and "f (Lim F (\<lambda>x. x)) \<noteq> 1"
    and "0 < g (Lim F (\<lambda>x. x))"
  shows "continuous F (\<lambda>x. log (f x) (g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous F (\<lambda>x. log (f x) (g x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous F f
continuous F g
0 < f (Lim F (\<lambda>x. x))
f (Lim F (\<lambda>x. x)) \<noteq> 1
0 < g (Lim F (\<lambda>x. x))

goal (1 subgoal):
 1. continuous F (\<lambda>x. log (f x) (g x))
[PROOF STEP]
unfolding continuous_def
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> f (Lim F (\<lambda>x. x))) F
(g \<longlongrightarrow> g (Lim F (\<lambda>x. x))) F
0 < f (Lim F (\<lambda>x. x))
f (Lim F (\<lambda>x. x)) \<noteq> 1
0 < g (Lim F (\<lambda>x. x))

goal (1 subgoal):
 1. ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log (f (Lim F (\<lambda>x. x))) (g (Lim F (\<lambda>x. x)))) F
[PROOF STEP]
by (rule tendsto_log)


[STATEMENT]
lemma square_ccsqrt [simp]:
  shows "(ccsqrt x)\<^sup>2 = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ccsqrt x)\<^sup>2 = x
[PROOF STEP]
unfolding ccsqrt_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (rcis (sqrt (cmod x)) (Arg x / 2))\<^sup>2 = x
[PROOF STEP]
by (subst DeMoivre2) (simp add: rcis_cmod_Arg)


[STATEMENT]
lemma degeneralize_simps[simp]:
      "alphabet\<^sub>2 (degeneralize A) = alphabet\<^sub>1 A"
      "initial\<^sub>2 (degeneralize A) = (initial\<^sub>1 A, 0)"
      "transition\<^sub>2 (degeneralize A) a (p, k) =
        (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k)"
      "condition\<^sub>2 (degeneralize A) = degen (condition\<^sub>1 A) \<circ> translate"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (alphabet\<^sub>2 (degeneralize A) = alphabet\<^sub>1 A &&& initial\<^sub>2 (degeneralize A) = (initial\<^sub>1 A, 0)) &&& transition\<^sub>2 (degeneralize A) a (p, k) = (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k) &&& condition\<^sub>2 (degeneralize A) = degen (condition\<^sub>1 A) \<circ> translate
[PROOF STEP]
unfolding degeneralize_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (alphabet\<^sub>2 (automaton\<^sub>2 (alphabet\<^sub>1 A) (initial\<^sub>1 A, 0) (\<lambda>a (p, k). (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k)) (degen (condition\<^sub>1 A) \<circ> translate)) = alphabet\<^sub>1 A &&& initial\<^sub>2 (automaton\<^sub>2 (alphabet\<^sub>1 A) (initial\<^sub>1 A, 0) (\<lambda>a (p, k). (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k)) (degen (condition\<^sub>1 A) \<circ> translate)) = (initial\<^sub>1 A, 0)) &&& transition\<^sub>2 (automaton\<^sub>2 (alphabet\<^sub>1 A) (initial\<^sub>1 A, 0) (\<lambda>a (p, k). (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k)) (degen (condition\<^sub>1 A) \<circ> translate)) a (p, k) = (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k) &&& condition\<^sub>2 (automaton\<^sub>2 (alphabet\<^sub>1 A) (initial\<^sub>1 A, 0) (\<lambda>a (p, k). (transition\<^sub>1 A a p, count (condition\<^sub>1 A) (item (p, a, transition\<^sub>1 A a p)) k)) (degen (condition\<^sub>1 A) \<circ> translate)) = degen (condition\<^sub>1 A) \<circ> translate
[PROOF STEP]
by auto


[STATEMENT]
lemma comm_monoid_set_and: "comm_monoid_set HOL.conj True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comm_monoid_set (\<and>) True
[PROOF STEP]
by (rule comm_monoid_set.intro) (fact comm_monoid_and)


[STATEMENT]
lemma CSP1_is_R1_H1_b:
"(P = (R \<circ> R1 \<circ> H1 \<circ> H2) P) = (P = (R \<circ> CSP1 \<circ> H2) P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P = (R \<circ> R1 \<circ> H1 \<circ> H2) P) = (P = (R \<circ> CSP1 \<circ> H2) P)
[PROOF STEP]
apply (simp add: fun_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (R1 (H1 (H2 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst H1_H2_commute2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (R1 (H2 (H1 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst R1_H2_commute2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (H2 (R1 (H1 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst CSP1_is_R1_H1_2[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (H2 (CSP1 (R1 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst H2_CSP1_commute2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (CSP1 (H2 (R1 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst R1_H2_commute2[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (CSP1 (R1 (H2 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst CSP1_R1_commute2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (R1 (CSP1 (H2 P))) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (subst R_abs_R1[simplified Fun.comp_def fun_eq_iff])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b)) = (\<forall>a b. P (a, b) = R (CSP1 (H2 P)) (a, b))
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma eval_poly_sum: "eval_poly hom (\<Sum>k\<in>A. p k) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_poly hom (sum p A) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)
[PROOF STEP]
proof (induct A rule: infinite_finite_induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> eval_poly hom (sum p A) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)
 2. eval_poly hom (sum p {}) x = (\<Sum>k\<in>{}. eval_poly hom (p k) x)
 3. \<And>xa F. \<lbrakk>finite F; xa \<notin> F; eval_poly hom (sum p F) x = (\<Sum>k\<in>F. eval_poly hom (p k) x)\<rbrakk> \<Longrightarrow> eval_poly hom (sum p (insert xa F)) x = (\<Sum>k\<in>insert xa F. eval_poly hom (p k) x)
[PROOF STEP]
case (insert a A)
[PROOF STATE]
proof (state)
this:
finite A
a \<notin> A
eval_poly hom (sum p A) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)

goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> eval_poly hom (sum p A) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)
 2. eval_poly hom (sum p {}) x = (\<Sum>k\<in>{}. eval_poly hom (p k) x)
 3. \<And>xa F. \<lbrakk>finite F; xa \<notin> F; eval_poly hom (sum p F) x = (\<Sum>k\<in>F. eval_poly hom (p k) x)\<rbrakk> \<Longrightarrow> eval_poly hom (sum p (insert xa F)) x = (\<Sum>k\<in>insert xa F. eval_poly hom (p k) x)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_poly hom (sum p (insert a A)) x = (\<Sum>k\<in>insert a A. eval_poly hom (p k) x)
[PROOF STEP]
unfolding sum.insert[OF insert(1-2)] insert(3)[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_poly hom (p a + sum p A) x = eval_poly hom (p a) x + eval_poly hom (sum p A) x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
eval_poly hom (sum p (insert a A)) x = (\<Sum>k\<in>insert a A. eval_poly hom (p k) x)

goal (2 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> eval_poly hom (sum p A) x = (\<Sum>k\<in>A. eval_poly hom (p k) x)
 2. eval_poly hom (sum p {}) x = (\<Sum>k\<in>{}. eval_poly hom (p k) x)
[PROOF STEP]
qed (auto simp: eval_poly_def)


[STATEMENT]
lemma Cauchy_theorem_starlike_simple:
  "\<lbrakk>open S; starlike S; f holomorphic_on S; valid_path g; path_image g \<subseteq> S; pathfinish g = pathstart g\<rbrakk>
   \<Longrightarrow> (f has_contour_integral 0) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>open S; starlike S; f holomorphic_on S; valid_path g; path_image g \<subseteq> S; pathfinish g = pathstart g\<rbrakk> \<Longrightarrow> (f has_contour_integral 0) g
[PROOF STEP]
using Cauchy_theorem_starlike [OF _ _ finite.emptyI]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>open ?S; starlike ?S; continuous_on ?S ?f; \<And>x. x \<in> ?S - {} \<Longrightarrow> ?f field_differentiable at x; valid_path ?g; path_image ?g \<subseteq> ?S; pathfinish ?g = pathstart ?g\<rbrakk> \<Longrightarrow> (?f has_contour_integral 0) ?g

goal (1 subgoal):
 1. \<lbrakk>open S; starlike S; f holomorphic_on S; valid_path g; path_image g \<subseteq> S; pathfinish g = pathstart g\<rbrakk> \<Longrightarrow> (f has_contour_integral 0) g
[PROOF STEP]
by (simp add: holomorphic_on_imp_continuous_on holomorphic_on_imp_differentiable_at)


[STATEMENT]
lemma Complex_Re_express_cnj:
  shows "Complex (Re z) 0 = (z + cnj z) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex (Re z) 0 = (z + cnj z) / 2
[PROOF STEP]
by (cases z) (simp add: Complex_eq)


[STATEMENT]
lemma moebius_translation_inv [simp]:
  shows "moebius_inv (moebius_translation v1) = moebius_translation (-v1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. moebius_inv (moebius_translation v1) = moebius_translation (- v1)
[PROOF STEP]
using moebius_translation_comp[of v1 "-v1"] moebius_translation_zero
[PROOF STATE]
proof (prove)
using this:
moebius_comp (moebius_translation v1) (moebius_translation (- v1)) = moebius_translation (v1 + - v1)
moebius_translation 0 = id_moebius

goal (1 subgoal):
 1. moebius_inv (moebius_translation v1) = moebius_translation (- v1)
[PROOF STEP]
using minus_unique[of "moebius_translation v1" "moebius_translation (-v1)"]
[PROOF STATE]
proof (prove)
using this:
moebius_comp (moebius_translation v1) (moebius_translation (- v1)) = moebius_translation (v1 + - v1)
moebius_translation 0 = id_moebius
moebius_translation v1 + moebius_translation (- v1) = 0 \<Longrightarrow> - moebius_translation v1 = moebius_translation (- v1)

goal (1 subgoal):
 1. moebius_inv (moebius_translation v1) = moebius_translation (- v1)
[PROOF STEP]
by simp


[STATEMENT]
lemma (in PolynRg) polyn_exprs_eq:"\<lbrakk>pol_coeff S c; pol_coeff S d;
         k \<le> (min (fst c) (fst d)); \<forall>j \<le> k. (snd c) j = (snd d) j\<rbrakk> \<Longrightarrow>
                     polyn_expr R X k c = polyn_expr R X k d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>pol_coeff S c; pol_coeff S d; k \<le> min (fst c) (fst d); \<forall>j\<le>k. snd c j = snd d j\<rbrakk> \<Longrightarrow> polyn_expr R X k c = polyn_expr R X k d
[PROOF STEP]
apply (cut_tac ring_is_ag,
       simp add:polyn_expr_def,
       cut_tac subring,
       cut_tac X_mem_R)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>pol_coeff S c; pol_coeff S d; k \<le> fst c \<and> k \<le> fst d; \<forall>j\<le>k. snd c j = snd d j; aGroup R; Subring R S; X \<in> carrier R\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e R (\<lambda>j. snd c j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup>) k = \<Sigma>\<^sub>e R (\<lambda>j. snd d j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup>) k
[PROOF STEP]
apply (rule aGroup.nsum_eq[of R k "\<lambda>j. (snd c) j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup>"
                                   "\<lambda>j. (snd d) j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup>"], assumption)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>pol_coeff S c; pol_coeff S d; k \<le> fst c \<and> k \<le> fst d; \<forall>j\<le>k. snd c j = snd d j; aGroup R; Subring R S; X \<in> carrier R\<rbrakk> \<Longrightarrow> \<forall>j\<le>k. snd c j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup> \<in> carrier R
 2. \<lbrakk>pol_coeff S c; pol_coeff S d; k \<le> fst c \<and> k \<le> fst d; \<forall>j\<le>k. snd c j = snd d j; aGroup R; Subring R S; X \<in> carrier R\<rbrakk> \<Longrightarrow> \<forall>j\<le>k. snd d j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup> \<in> carrier R
 3. \<lbrakk>pol_coeff S c; pol_coeff S d; k \<le> fst c \<and> k \<le> fst d; \<forall>j\<le>k. snd c j = snd d j; aGroup R; Subring R S; X \<in> carrier R\<rbrakk> \<Longrightarrow> \<forall>j\<le>k. snd c j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup> = snd d j \<cdot>\<^sub>r X^\<^bsup>R j\<^esup>
[PROOF STEP]
apply (simp add:monomial_mem)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sum_list_tl_leq:
  assumes "sum_list l \<le> (n::nat)"
  and "l\<noteq> []"
  and "hd l \<le> n"
  shows "sum_list (tl l) \<le> n - hd l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
have "hd l + sum_list (tl l) = sum_list l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd l + sum_list (tl l) = sum_list l
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sum_list l \<le> n
l \<noteq> []
hd l \<le> n

goal (1 subgoal):
 1. hd l + sum_list (tl l) = sum_list l
[PROOF STEP]
by (metis list.exhaust_sel sum_list_simps(2))
[PROOF STATE]
proof (state)
this:
hd l + sum_list (tl l) = sum_list l

goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
hd l + sum_list (tl l) = sum_list l

goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
have "... \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list l \<le> n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
sum_list l \<le> n
l \<noteq> []
hd l \<le> n

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

goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
hd l + sum_list (tl l) \<le> n
[PROOF STEP]
have "hd l + sum_list (tl l) \<le> n"
[PROOF STATE]
proof (prove)
using this:
hd l + sum_list (tl l) \<le> n

goal (1 subgoal):
 1. hd l + sum_list (tl l) \<le> n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
hd l + sum_list (tl l) \<le> n

goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
hd l + sum_list (tl l) \<le> n

goal (1 subgoal):
 1. sum_list (tl l) \<le> n - hd l
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list (tl l) \<le> n - hd l

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma frontier_eq_empty:
  fixes S :: "'a :: real_normed_vector set"
  shows "frontier S = {} \<longleftrightarrow> S = {} \<or> S = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (frontier S = {}) = (S = {} \<or> S = UNIV)
[PROOF STEP]
using frontier_UNIV frontier_empty frontier_not_empty
[PROOF STATE]
proof (prove)
using this:
frontier UNIV = {}
frontier {} = {}
\<lbrakk>?S \<noteq> {}; ?S \<noteq> UNIV\<rbrakk> \<Longrightarrow> frontier ?S \<noteq> {}

goal (1 subgoal):
 1. (frontier S = {}) = (S = {} \<or> S = UNIV)
[PROOF STEP]
by blast


[STATEMENT]
lemma changes_scale_const: fixes xs::"'a::linordered_idom list"
  assumes hs: "s \<noteq> 0"
  shows "changes (map ((*) s) xs) = changes xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes (map ((*) s) xs) = changes xs
[PROOF STEP]
apply (induction xs rule: changes.induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. changes (map ((*) s) []) = changes []
 2. \<And>uu_. changes (map ((*) s) [uu_]) = changes [uu_]
 3. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # xs)) = changes (x1 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # x2 # xs)) = changes (x1 # x2 # xs)
[PROOF STEP]
apply (simp, force)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # xs)) = changes (x1 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # x2 # xs)) = changes (x1 # x2 # xs)
[PROOF STEP]
using hs
[PROOF STATE]
proof (prove)
using this:
s \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>x1 x2 xs. \<lbrakk>x1 * x2 < (0::'a) \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 = (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # xs)) = changes (x1 # xs); \<lbrakk>\<not> x1 * x2 < (0::'a); x2 \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x2 # xs)) = changes (x2 # xs)\<rbrakk> \<Longrightarrow> changes (map ((*) s) (x1 # x2 # xs)) = changes (x1 # x2 # xs)
[PROOF STEP]
by (auto simp: mult_less_0_iff zero_less_mult_iff)


[STATEMENT]
lemma abs_Max_sum2:
  fixes f::"_ \<Rightarrow> real"
  assumes "finite A" "A \<noteq> {}"
  shows "abs(Max (f`A)) \<le> (\<Sum>a\<in>A. abs(f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>Max (f ` A)\<bar> \<le> (\<Sum>a\<in>A. \<bar>f a\<bar>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. \<bar>Max (f ` A)\<bar> \<le> (\<Sum>a\<in>A. \<bar>f a\<bar>)
[PROOF STEP]
by (induct rule: finite_ne_induct, auto)


[STATEMENT]
lemma permutation_mat_col[simp]: "p permutes {..<n} \<Longrightarrow> i < n \<Longrightarrow>
  Matrix.col (permutation_mat n p) i = unit_vec n (p i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p permutes {..<n}; i < n\<rbrakk> \<Longrightarrow> col (permutation_mat n p) i = unit_vec n (p i)
[PROOF STEP]
unfolding permutation_mat_def unit_vec_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p permutes {..<n}; i < n\<rbrakk> \<Longrightarrow> col (Matrix.mat n n (\<lambda>(i, j). if i = p j then 1::'a else (0::'a))) i = Matrix.vec n (\<lambda>j. if j = p i then 1::'a else (0::'a))
[PROOF STEP]
by (intro eq_vecI, auto simp: permutes_inverses)


[STATEMENT]
lemma upt_enum_offset_trivial:
  "\<lbrakk> x < 2 ^ LENGTH('a) - 1 ; n \<le> unat x \<rbrakk>
   \<Longrightarrow> ([(0 :: 'a :: len word) .e. x] ! n) = of_nat n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < 2 ^ LENGTH('a) - 1; n \<le> unat x\<rbrakk> \<Longrightarrow> [0 .e. x] ! n = word_of_nat n
[PROOF STEP]
apply (induct x arbitrary: n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>0 < 2 ^ LENGTH('a) - 1; n \<le> unat 0\<rbrakk> \<Longrightarrow> [0 .e. 0] ! n = word_of_nat n
 2. \<And>x n. \<lbrakk>1 + x \<noteq> 0; \<And>n. \<lbrakk>x < 2 ^ LENGTH('a) - 1; n \<le> unat x\<rbrakk> \<Longrightarrow> [0 .e. x] ! n = word_of_nat n; 1 + x < 2 ^ LENGTH('a) - 1; n \<le> unat (1 + x)\<rbrakk> \<Longrightarrow> [0 .e. 1 + x] ! n = word_of_nat n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x n. \<lbrakk>1 + x \<noteq> 0; \<And>n. \<lbrakk>x < 2 ^ LENGTH('a) - 1; n \<le> unat x\<rbrakk> \<Longrightarrow> [0 .e. x] ! n = word_of_nat n; 1 + x < 2 ^ LENGTH('a) - 1; n \<le> unat (1 + x)\<rbrakk> \<Longrightarrow> [0 .e. 1 + x] ! n = word_of_nat n
[PROOF STEP]
by (simp add: upto_enum_word_nth)


[STATEMENT]
lemma machin_Euler: "5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have 17: "\<bar>1 / 7\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>1 / 7\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>1 / 7\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
with arctan_double
[PROOF STATE]
proof (chain)
picking this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>1 / 7\<bar> < 1
[PROOF STEP]
have "2 * arctan (1 / 7) = arctan (7 / 24)"
[PROOF STATE]
proof (prove)
using this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>1 / 7\<bar> < 1

goal (1 subgoal):
 1. 2 * arctan (1 / 7) = arctan (7 / 24)
[PROOF STEP]
by simp (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
2 * arctan (1 / 7) = arctan (7 / 24)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 * arctan (1 / 7) = arctan (7 / 24)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have "\<bar>7 / 24\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>7 / 24\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>7 / 24\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
with arctan_double
[PROOF STATE]
proof (chain)
picking this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>7 / 24\<bar> < 1
[PROOF STEP]
have "2 * arctan (7 / 24) = arctan (336 / 527)"
[PROOF STATE]
proof (prove)
using this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>7 / 24\<bar> < 1

goal (1 subgoal):
 1. 2 * arctan (7 / 24) = arctan (336 / 527)
[PROOF STEP]
by simp (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
2 * arctan (7 / 24) = arctan (336 / 527)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 * arctan (7 / 24) = arctan (336 / 527)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have "\<bar>336 / 527\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>336 / 527\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>336 / 527\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
from arctan_add[OF less_imp_le[OF 17] this]
[PROOF STATE]
proof (chain)
picking this:
arctan (1 / 7) + arctan (336 / 527) = arctan ((1 / 7 + 336 / 527) / (1 - 1 / 7 * (336 / 527)))
[PROOF STEP]
have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)"
[PROOF STATE]
proof (prove)
using this:
arctan (1 / 7) + arctan (336 / 527) = arctan ((1 / 7 + 336 / 527) / (1 - 1 / 7 * (336 / 527)))

goal (1 subgoal):
 1. arctan (1 / 7) + arctan (336 / 527) = arctan (2879 / 3353)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
arctan (1 / 7) + arctan (336 / 527) = arctan (2879 / 3353)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
2 * arctan (1 / 7) = arctan (7 / 24)
2 * arctan (7 / 24) = arctan (336 / 527)
arctan (1 / 7) + arctan (336 / 527) = arctan (2879 / 3353)
[PROOF STEP]
have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)"
[PROOF STATE]
proof (prove)
using this:
2 * arctan (1 / 7) = arctan (7 / 24)
2 * arctan (7 / 24) = arctan (336 / 527)
arctan (1 / 7) + arctan (336 / 527) = arctan (2879 / 3353)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) = arctan (2879 / 3353)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
5 * arctan (1 / 7) = arctan (2879 / 3353)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have 379: "\<bar>3 / 79\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>3 / 79\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>3 / 79\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
with arctan_double
[PROOF STATE]
proof (chain)
picking this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>3 / 79\<bar> < 1
[PROOF STEP]
have II: "2 * arctan (3 / 79) = arctan (237 / 3116)"
[PROOF STATE]
proof (prove)
using this:
\<bar>?x\<bar> < 1 \<Longrightarrow> 2 * arctan ?x = arctan (2 * ?x / (1 - ?x\<^sup>2))
\<bar>3 / 79\<bar> < 1

goal (1 subgoal):
 1. 2 * arctan (3 / 79) = arctan (237 / 3116)
[PROOF STEP]
by simp (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
2 * arctan (3 / 79) = arctan (237 / 3116)

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have *: "\<bar>2879 / 3353\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>2879 / 3353\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>2879 / 3353\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
have "\<bar>237 / 3116\<bar> < (1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>237 / 3116\<bar> < 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>237 / 3116\<bar> < 1

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
from arctan_add[OF less_imp_le[OF *] this]
[PROOF STATE]
proof (chain)
picking this:
arctan (2879 / 3353) + arctan (237 / 3116) = arctan ((2879 / 3353 + 237 / 3116) / (1 - 2879 / 3353 * (237 / 3116)))
[PROOF STEP]
have "arctan (2879/3353) + arctan (237/3116) = pi/4"
[PROOF STATE]
proof (prove)
using this:
arctan (2879 / 3353) + arctan (237 / 3116) = arctan ((2879 / 3353 + 237 / 3116) / (1 - 2879 / 3353 * (237 / 3116)))

goal (1 subgoal):
 1. arctan (2879 / 3353) + arctan (237 / 3116) = pi / 4
[PROOF STEP]
by (simp add: arctan_one)
[PROOF STATE]
proof (state)
this:
arctan (2879 / 3353) + arctan (237 / 3116) = pi / 4

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
with I II
[PROOF STATE]
proof (chain)
picking this:
5 * arctan (1 / 7) = arctan (2879 / 3353)
2 * arctan (3 / 79) = arctan (237 / 3116)
arctan (2879 / 3353) + arctan (237 / 3116) = pi / 4
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
5 * arctan (1 / 7) = arctan (2879 / 3353)
2 * arctan (3 / 79) = arctan (237 / 3116)
arctan (2879 / 3353) + arctan (237 / 3116) = pi / 4

goal (1 subgoal):
 1. 5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dim_col_tensor_mat [simp]:
  "dim_col (A \<Otimes> B) = dim_col A * dim_col B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (A \<Otimes> B) = dim_col A * dim_col B
[PROOF STEP]
using tensor_mat_def mat_of_cols_list_def mult.length_Tensor[of "1" "(*)"]
[PROOF STATE]
proof (prove)
using this:
?A \<Otimes> ?B \<equiv> Tensor.mat_of_cols_list (dim_row ?A * dim_row ?B) (mult.Tensor (*) (mat_to_cols_list ?A) (mat_to_cols_list ?B))
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)
Matrix_Tensor.mult (1::?'a1) (*) \<Longrightarrow> length (mult.Tensor (*) ?M1.0 ?M2.0) = length ?M1.0 * length ?M2.0

goal (1 subgoal):
 1. dim_col (A \<Otimes> B) = dim_col A * dim_col B
[PROOF STEP]
by(simp add: \<open>\<And>M2 M1. Matrix_Tensor.mult 1 (*) \<Longrightarrow> length (mult.Tensor (*) M1 M2) = length M1 * length M2\<close> mult.intro)


[STATEMENT]
lemma invertible_lf_imp_invertible_matrix:
  fixes f::"'a::{field}^'n\<Rightarrow>'a^'n"
  assumes invertible_f: "invertible_lf ((*s)) ((*s)) f"
  shows "invertible (matrix f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
interpret i: invertible_lf "((*s))" "((*s))" f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible_lf (*s) (*s) f
[PROOF STEP]
using invertible_f
[PROOF STATE]
proof (prove)
using this:
invertible_lf (*s) (*s) f

goal (1 subgoal):
 1. invertible_lf (*s) (*s) f
[PROOF STEP]
.
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
obtain g where linear_g: "linear ((*s)) ((*s))  g" and gf: "(g \<circ> f = id)" and fg: "(f \<circ> g = id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<lbrakk>linear (*s) (*s) g; g \<circ> f = id; f \<circ> g = id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis invertible_f invertible_lf.invertible_lf)
[PROOF STATE]
proof (state)
this:
linear (*s) (*s) g
g \<circ> f = id
f \<circ> g = id

goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (matrix f)
[PROOF STEP]
proof (unfold invertible_def, rule exI[of _ "matrix g"], rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. matrix f ** matrix g = mat (1::'a)
 2. matrix g ** matrix f = mat (1::'a)
[PROOF STEP]
show "matrix f ** matrix g = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix f ** matrix g = mat (1::'a)
[PROOF STEP]
unfolding matrix_eq matrix_vector_mul_assoc[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. matrix f *v (matrix g *v x) = mat (1::'a) *v x
[PROOF STEP]
by (metis i.linear_axioms matrix_vector_mul_lid pointfree_idE fg linear_g matrix_vector_mul)
[PROOF STATE]
proof (state)
this:
matrix f ** matrix g = mat (1::'a)

goal (1 subgoal):
 1. matrix g ** matrix f = mat (1::'a)
[PROOF STEP]
show "matrix g ** matrix f = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix g ** matrix f = mat (1::'a)
[PROOF STEP]
by (metis \<open>matrix f ** matrix g = mat 1\<close> matrix_left_right_inverse)
[PROOF STATE]
proof (state)
this:
matrix g ** matrix f = mat (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (matrix f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma weight_scale_spmf: "weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)
[PROOF STEP]
have "ennreal (weight_spmf (scale_spmf r p)) = min 1 (max 0 r * ennreal (weight_spmf p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (weight_spmf (scale_spmf r p)) = min 1 (ennreal (max 0 r) * ennreal (weight_spmf p))
[PROOF STEP]
unfolding weight_spmf_eq_nn_integral_spmf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (spmf (scale_spmf r p) x) \<partial>count_space UNIV = min 1 (ennreal (max 0 r) * \<integral>\<^sup>+ x. ennreal (spmf p x) \<partial>count_space UNIV)
[PROOF STEP]
apply(simp add: spmf_scale_spmf ennreal_mult zero_ereal_def[symmetric] nn_integral_cmult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (min (inverse (weight_spmf p)) r) * \<integral>\<^sup>+ x. ennreal (spmf p x) \<partial>count_space UNIV = min 1 (ennreal r * \<integral>\<^sup>+ x. ennreal (spmf p x) \<partial>count_space UNIV)
[PROOF STEP]
apply(auto simp add: weight_spmf_eq_nn_integral_spmf[symmetric] field_simps min_def max_def not_le weight_spmf_lt_0 ennreal_mult[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>weight_spmf p \<noteq> 0; 1 / weight_spmf p \<le> r; ennreal r * ennreal (weight_spmf p) < 1\<rbrakk> \<Longrightarrow> ennreal r * ennreal (weight_spmf p) = 1
 2. \<lbrakk>weight_spmf p \<noteq> 0; r < 1 / weight_spmf p; 1 \<le> ennreal r * ennreal (weight_spmf p)\<rbrakk> \<Longrightarrow> ennreal r * ennreal (weight_spmf p) = 1
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>weight_spmf p \<noteq> 0; 1 / weight_spmf p \<le> r; ennreal r * ennreal (weight_spmf p) < 1\<rbrakk> \<Longrightarrow> ennreal r * ennreal (weight_spmf p) = 1
[PROOF STEP]
by(subst (asm) ennreal_mult[symmetric], meson divide_less_0_1_iff le_less_trans not_le weight_spmf_lt_0, simp+, meson not_le pos_divide_le_eq weight_spmf_le_0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>weight_spmf p \<noteq> 0; r < 1 / weight_spmf p; 1 \<le> ennreal r * ennreal (weight_spmf p)\<rbrakk> \<Longrightarrow> ennreal r * ennreal (weight_spmf p) = 1
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>weight_spmf p \<noteq> 0; r < 1 / weight_spmf p; 1 \<le> ennreal r * ennreal (weight_spmf p)\<rbrakk> \<Longrightarrow> ennreal r * ennreal (weight_spmf p) = 1
[PROOF STEP]
by(cases "r \<ge> 0")(simp_all add: ennreal_mult[symmetric] weight_spmf_nonneg ennreal_lt_0, meson le_less_trans not_le pos_divide_le_eq zero_less_divide_1_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
ennreal (weight_spmf (scale_spmf r p)) = min 1 (ennreal (max 0 r) * ennreal (weight_spmf p))

goal (1 subgoal):
 1. weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ennreal (weight_spmf (scale_spmf r p)) = min 1 (ennreal (max 0 r) * ennreal (weight_spmf p))

goal (1 subgoal):
 1. weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)
[PROOF STEP]
by(auto simp add: min_def max_def ennreal_mult[symmetric] split: if_split_asm)
[PROOF STATE]
proof (state)
this:
weight_spmf (scale_spmf r p) = min 1 (max 0 r * weight_spmf p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_row_0: assumes k: "k < n"
  and c: "c \<in> {0 ..< n} \<rightarrow> carrier_vec n"
  shows "det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
assume p: "p permutes {0 ..< n}"
[PROOF STATE]
proof (state)
this:
p permutes {0..<n}

goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
have "(\<Prod>i\<in>{0..<n}. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, p i)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..<n. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, p i)) = (0::'a)
[PROOF STEP]
by (rule prod_zero[OF _ bexI[of _ k]],
      insert k p c[unfolded carrier_vec_def], auto)
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 0..<n. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, p i)) = (0::'a)

goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?p2 permutes {0..<n} \<Longrightarrow> (\<Prod>i = 0..<n. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, ?p2 i)) = (0::'a)

goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?p2 permutes {0..<n} \<Longrightarrow> (\<Prod>i = 0..<n. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, ?p2 i)) = (0::'a)

goal (1 subgoal):
 1. det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)
[PROOF STEP]
unfolding det_def
[PROOF STATE]
proof (prove)
using this:
?p2 permutes {0..<n} \<Longrightarrow> (\<Prod>i = 0..<n. mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, ?p2 i)) = (0::'a)

goal (1 subgoal):
 1. (if dim_row (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = dim_col (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) then \<Sum>p | p permutes {0..<dim_row (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i))}. of_int (sign p) * (\<Prod>i = 0..<dim_row (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)). mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i) $$ (i, p i)) else (0::'a)) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det (mat\<^sub>r n n (\<lambda>i. if i = k then 0\<^sub>v n else c i)) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma contour_integral_linepath_Reals_eq:
  fixes a b :: complex and f :: "complex \<Rightarrow> complex"
  assumes "a \<in> Reals" "b \<in> Reals" "Re a < Re b"
  shows   "contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (of_real x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
proof (cases "f contour_integrable_on linepath a b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
 2. \<not> f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
f contour_integrable_on linepath a b

goal (2 subgoals):
 1. f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
 2. \<not> f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f contour_integrable_on linepath a b

goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
using has_contour_integral_linepath_Reals_iff[OF assms, of f]
[PROOF STATE]
proof (prove)
using this:
f contour_integrable_on linepath a b
(f has_contour_integral ?I) (linepath a b) = ((\<lambda>x. f (complex_of_real x)) has_integral ?I) {Re a..Re b}

goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
using has_contour_integral_integral has_contour_integral_unique
[PROOF STATE]
proof (prove)
using this:
f contour_integrable_on linepath a b
(f has_contour_integral ?I) (linepath a b) = ((\<lambda>x. f (complex_of_real x)) has_integral ?I) {Re a..Re b}
?f contour_integrable_on ?i \<Longrightarrow> (?f has_contour_integral contour_integral ?i ?f) ?i
\<lbrakk>(?f has_contour_integral ?i) ?g; (?f has_contour_integral ?j) ?g\<rbrakk> \<Longrightarrow> ?i = ?j

goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))

goal (1 subgoal):
 1. \<not> f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> f contour_integrable_on linepath a b

goal (1 subgoal):
 1. \<not> f contour_integrable_on linepath a b \<Longrightarrow> contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> f contour_integrable_on linepath a b

goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
using contour_integrable_linepath_Reals_iff[OF assms, of f]
[PROOF STATE]
proof (prove)
using this:
\<not> f contour_integrable_on linepath a b
(f contour_integrable_on linepath a b) = ((\<lambda>x. f (complex_of_real x)) integrable_on {Re a..Re b})

goal (1 subgoal):
 1. contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))
[PROOF STEP]
by (simp add: not_integrable_contour_integral not_integrable_integral)
[PROOF STATE]
proof (state)
this:
contour_integral (linepath a b) f = integral {Re a..Re b} (\<lambda>x. f (complex_of_real x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma space_subgroup_props:
  assumes "dimension n K E"
  shows "E \<subseteq> carrier R"
    and "\<zero> \<in> E"
    and "\<And>v1 v2. \<lbrakk> v1 \<in> E; v2 \<in> E \<rbrakk> \<Longrightarrow> (v1 \<oplus> v2) \<in> E"
    and "\<And>v. v \<in> E \<Longrightarrow> (\<ominus> v) \<in> E"
    and "\<And>k v. \<lbrakk> k \<in> K; v \<in> E \<rbrakk> \<Longrightarrow> k \<otimes> v \<in> E"
    and "\<lbrakk> k \<in> K - { \<zero> }; a \<in> carrier R \<rbrakk> \<Longrightarrow> k \<otimes> a \<in> E \<Longrightarrow> a \<in> E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (E \<subseteq> carrier R &&& \<zero> \<in> E &&& (\<And>v1 v2. \<lbrakk>v1 \<in> E; v2 \<in> E\<rbrakk> \<Longrightarrow> v1 \<oplus> v2 \<in> E)) &&& (\<And>v. v \<in> E \<Longrightarrow> \<ominus> v \<in> E) &&& (\<And>k v. \<lbrakk>k \<in> K; v \<in> E\<rbrakk> \<Longrightarrow> k \<otimes> v \<in> E) &&& (\<lbrakk>k \<in> K - {\<zero>}; a \<in> carrier R; k \<otimes> a \<in> E\<rbrakk> \<Longrightarrow> a \<in> E)
[PROOF STEP]
using exists_base[OF assms] Span_subgroup_props Span_smult_closed Span_m_inv_simprule
[PROOF STATE]
proof (prove)
using this:
\<exists>Vs. set Vs \<subseteq> carrier R \<and> local.independent K Vs \<and> length Vs = n \<and> Span K Vs = E
set ?Us \<subseteq> carrier R \<Longrightarrow> Span K ?Us \<subseteq> carrier R
set ?Us \<subseteq> carrier R \<Longrightarrow> \<zero> \<in> Span K ?Us
\<lbrakk>set ?Us \<subseteq> carrier R; ?v1.0 \<in> Span K ?Us; ?v2.0 \<in> Span K ?Us\<rbrakk> \<Longrightarrow> ?v1.0 \<oplus> ?v2.0 \<in> Span K ?Us
\<lbrakk>set ?Us \<subseteq> carrier R; ?v \<in> Span K ?Us\<rbrakk> \<Longrightarrow> \<ominus> ?v \<in> Span K ?Us
\<lbrakk>set ?Us \<subseteq> carrier R; ?k \<in> K; ?v \<in> Span K ?Us\<rbrakk> \<Longrightarrow> ?k \<otimes> ?v \<in> Span K ?Us
\<lbrakk>set ?Us \<subseteq> carrier R; ?k \<in> K - {\<zero>}; ?a \<in> carrier R; ?k \<otimes> ?a \<in> Span K ?Us\<rbrakk> \<Longrightarrow> ?a \<in> Span K ?Us

goal (1 subgoal):
 1. (E \<subseteq> carrier R &&& \<zero> \<in> E &&& (\<And>v1 v2. \<lbrakk>v1 \<in> E; v2 \<in> E\<rbrakk> \<Longrightarrow> v1 \<oplus> v2 \<in> E)) &&& (\<And>v. v \<in> E \<Longrightarrow> \<ominus> v \<in> E) &&& (\<And>k v. \<lbrakk>k \<in> K; v \<in> E\<rbrakk> \<Longrightarrow> k \<otimes> v \<in> E) &&& (\<lbrakk>k \<in> K - {\<zero>}; a \<in> carrier R; k \<otimes> a \<in> E\<rbrakk> \<Longrightarrow> a \<in> E)
[PROOF STEP]
by auto


[STATEMENT]
lemma dtree_from_list_fcard0_iff_empty: "fcard (sucs (dtree_from_list r xs)) = 0 \<longleftrightarrow> xs = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fcard (sucs (dtree_from_list r xs)) = 0) = (xs = [])
[PROOF STEP]
by(induction xs) auto


[STATEMENT]
lemma bex_nonempty_subset:"\<exists>a. a \<in> A \<and> P a \<Longrightarrow>
               {x. x \<in> A \<and> P x} \<subseteq> A \<and> {x. x \<in> A \<and> P x} \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. a \<in> A \<and> P a \<Longrightarrow> {x \<in> A. P x} \<subseteq> A \<and> {x \<in> A. P x} \<noteq> {}
[PROOF STEP]
apply (erule exE, rule conjI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a. a \<in> A \<and> P a \<Longrightarrow> {x \<in> A. P x} \<subseteq> A
 2. \<And>a. a \<in> A \<and> P a \<Longrightarrow> {x \<in> A. P x} \<noteq> {}
[PROOF STEP]
apply (rule subsetI, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. a \<in> A \<and> P a \<Longrightarrow> {x \<in> A. P x} \<noteq> {}
[PROOF STEP]
apply (rule_tac A = "{x \<in> A. P x}" in nonempty, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma cspan_range_ket_finite[simp]: "cspan (range ket :: 'a::finite ell2 set) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cspan (range ket) = UNIV
[PROOF STEP]
by (metis closed_cspan_range_ket closure_finite_cspan finite_class.finite_UNIV finite_imageI)


[STATEMENT]
lemma monic_poly_min_degree:
  assumes "monic_irreducible_poly R f"
  shows  "degree f \<ge> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> degree f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m_i_p R f

goal (1 subgoal):
 1. 1 \<le> degree f
[PROOF STEP]
unfolding monic_irreducible_poly_def monic_poly_def
[PROOF STATE]
proof (prove)
using this:
(f \<noteq> [] \<and> lead_coeff f = \<one> \<and> f \<in> carrier P) \<and> pirreducible (carrier R) f

goal (1 subgoal):
 1. 1 \<le> degree f
[PROOF STEP]
by (intro pirreducible_degree) auto


[STATEMENT]
theorem backward_conv: "(A \<Longrightarrow> B) \<equiv> (\<not>B \<Longrightarrow> \<not>A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<Longrightarrow> B) \<equiv> (\<not> B \<Longrightarrow> \<not> A)
[PROOF STEP]
by (rule equal_intr_rule) auto


[STATEMENT]
lemma Im_cos: "Im(cos z) = sin(Re z) * (exp(-(Im z)) - exp(Im z)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Im (cos z) = sin (Re z) * (exp (- Im z) - exp (Im z)) / 2
[PROOF STEP]
by (simp add: cos_exp_eq field_simps Im_divide Im_exp)


[STATEMENT]
lemma varsSubsetFormula:
  fixes F :: Formula and F' :: Formula
  assumes "\<forall> c::Clause. c el F \<longrightarrow> c el F'"
  shows "vars F \<subseteq> vars F'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars F \<subseteq> vars F'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>c. c el F \<longrightarrow> c el F'

goal (1 subgoal):
 1. vars F \<subseteq> vars F'
[PROOF STEP]
proof (induct F)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>c. c el [] \<longrightarrow> c el F' \<Longrightarrow> vars [] \<subseteq> vars F'
 2. \<And>a F. \<lbrakk>\<forall>c. c el F \<longrightarrow> c el F' \<Longrightarrow> vars F \<subseteq> vars F'; \<forall>c. c el a # F \<longrightarrow> c el F'\<rbrakk> \<Longrightarrow> vars (a # F) \<subseteq> vars F'
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
\<forall>c. c el [] \<longrightarrow> c el F'

goal (2 subgoals):
 1. \<forall>c. c el [] \<longrightarrow> c el F' \<Longrightarrow> vars [] \<subseteq> vars F'
 2. \<And>a F. \<lbrakk>\<forall>c. c el F \<longrightarrow> c el F' \<Longrightarrow> vars F \<subseteq> vars F'; \<forall>c. c el a # F \<longrightarrow> c el F'\<rbrakk> \<Longrightarrow> vars (a # F) \<subseteq> vars F'
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<forall>c. c el [] \<longrightarrow> c el F'

goal (1 subgoal):
 1. vars [] \<subseteq> vars F'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vars [] \<subseteq> vars F'

goal (1 subgoal):
 1. \<And>a F. \<lbrakk>\<forall>c. c el F \<longrightarrow> c el F' \<Longrightarrow> vars F \<subseteq> vars F'; \<forall>c. c el a # F \<longrightarrow> c el F'\<rbrakk> \<Longrightarrow> vars (a # F) \<subseteq> vars F'
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a F. \<lbrakk>\<forall>c. c el F \<longrightarrow> c el F' \<Longrightarrow> vars F \<subseteq> vars F'; \<forall>c. c el a # F \<longrightarrow> c el F'\<rbrakk> \<Longrightarrow> vars (a # F) \<subseteq> vars F'
[PROOF STEP]
case (Cons c' F'')
[PROOF STATE]
proof (state)
this:
\<forall>c. c el F'' \<longrightarrow> c el F' \<Longrightarrow> vars F'' \<subseteq> vars F'
\<forall>c. c el c' # F'' \<longrightarrow> c el F'

goal (1 subgoal):
 1. \<And>a F. \<lbrakk>\<forall>c. c el F \<longrightarrow> c el F' \<Longrightarrow> vars F \<subseteq> vars F'; \<forall>c. c el a # F \<longrightarrow> c el F'\<rbrakk> \<Longrightarrow> vars (a # F) \<subseteq> vars F'
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<forall>c. c el F'' \<longrightarrow> c el F' \<Longrightarrow> vars F'' \<subseteq> vars F'
\<forall>c. c el c' # F'' \<longrightarrow> c el F'

goal (1 subgoal):
 1. vars (c' # F'') \<subseteq> vars F'
[PROOF STEP]
using formulaContainsItsClausesVariables[of "c'" "F'"]
[PROOF STATE]
proof (prove)
using this:
\<forall>c. c el F'' \<longrightarrow> c el F' \<Longrightarrow> vars F'' \<subseteq> vars F'
\<forall>c. c el c' # F'' \<longrightarrow> c el F'
c' el F' \<Longrightarrow> vars c' \<subseteq> vars F'

goal (1 subgoal):
 1. vars (c' # F'') \<subseteq> vars F'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vars (c' # F'') \<subseteq> vars F'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eq_opp_is_zero: "((x::'a::ell_field) = - x) = (x = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x = - x) = (x = (0::'a))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
assume "x = - x"
[PROOF STATE]
proof (state)
this:
x = - x

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
have "2 * x = x + x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2::'a) * x = x + x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(2::'a) * x = x + x

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(2::'a) * x = x + x

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
from \<open>x = - x\<close>
[PROOF STATE]
proof (chain)
picking this:
x = - x
[PROOF STEP]
have "\<dots> = - x + x"
[PROOF STATE]
proof (prove)
using this:
x = - x

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

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x + x = - x + x

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
have "\<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - x + x = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- x + x = (0::'a)

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(2::'a) * x = (0::'a)
[PROOF STEP]
have "2 * x = 0"
[PROOF STATE]
proof (prove)
using this:
(2::'a) * x = (0::'a)

goal (1 subgoal):
 1. (2::'a) * x = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(2::'a) * x = (0::'a)

goal (2 subgoals):
 1. x = - x \<Longrightarrow> x = (0::'a)
 2. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
with two_not_zero [where 'a='a]
[PROOF STATE]
proof (chain)
picking this:
(2::'a) \<noteq> (0::'a)
(2::'a) * x = (0::'a)
[PROOF STEP]
show "x = 0"
[PROOF STATE]
proof (prove)
using this:
(2::'a) \<noteq> (0::'a)
(2::'a) * x = (0::'a)

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

goal (1 subgoal):
 1. x = (0::'a) \<Longrightarrow> x = - x
[PROOF STEP]
qed simp


[STATEMENT]
lemma even_square_cong_4_nat: "even (x::nat) \<Longrightarrow> [x ^ 2 = 0] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even x \<Longrightarrow> [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
using even_square_cong_4_int[of "int x"]
[PROOF STATE]
proof (prove)
using this:
even (int x) \<Longrightarrow> [(int x)\<^sup>2 = 0] (mod 4)

goal (1 subgoal):
 1. even x \<Longrightarrow> [x\<^sup>2 = 0] (mod 4)
[PROOF STEP]
by (auto simp flip: cong_int_iff)


[STATEMENT]
lemma STAR_exp_add:
  "\<And>(x::'a:: {banach,real_normed_field} star) y. ( *f* exp)(x + y) = ( *f* exp) x * ( *f* exp) y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. (*f* exp) (x + y) = (*f* exp) x * (*f* exp) y
[PROOF STEP]
by transfer (rule exp_add)


[STATEMENT]
lemma setsum_one_le:
  fixes n::nat
  assumes "\<forall>i \<le> n. f i \<le> 1"
  shows "(\<Sum>i \<le> n. f i) \<le> Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..n} \<le> Suc n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<le>n. f i \<le> 1

goal (1 subgoal):
 1. sum f {..n} \<le> Suc n
[PROOF STEP]
by (induct n) (auto)


[STATEMENT]
lemma nodes_edges_graph_presentation: "\<lbrakk>finite V; finite E\<rbrakk>
    \<Longrightarrow> nodes (graph V E) = V \<union> fst`E \<union> snd`E \<and> edges (graph V E) = E\<union>E\<inverse> - Id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite V; finite E\<rbrakk> \<Longrightarrow> nodes (graph V E) = V \<union> fst ` E \<union> snd ` E \<and> edges (graph V E) = E \<union> E\<inverse> - Id
[PROOF STEP]
by (simp add: graph_accs)


[STATEMENT]
lemma lm140:
  assumes "runiq R" "runiq (R^-1)"
  shows "(R``A) \<inter> (R``B) = R``(A\<inter>B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R `` A \<inter> R `` B = R `` (A \<inter> B)
[PROOF STEP]
using assms rightUniqueInjectiveOnFirst converse_Image
[PROOF STATE]
proof (prove)
using this:
runiq R
runiq (R\<inverse>)
runiq ?P = inj_on fst ?P
\<lbrakk>runiq ?R; runiq (?R\<inverse>)\<rbrakk> \<Longrightarrow> ?R\<inverse> `` ?R `` ?X \<subseteq> ?X

goal (1 subgoal):
 1. R `` A \<inter> R `` B = R `` (A \<inter> B)
[PROOF STEP]
by force


[STATEMENT]
lemma regularAmicPair_sym:
  assumes "regularAmicPair n m" shows "regularAmicPair m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. regularAmicPair m n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. regularAmicPair m n
[PROOF STEP]
have "gcd m n = gcd n m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd m n = gcd n m
[PROOF STEP]
by (metis (no_types) gcd.commute)
[PROOF STATE]
proof (state)
this:
gcd m n = gcd n m

goal (1 subgoal):
 1. regularAmicPair m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
gcd m n = gcd n m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
gcd m n = gcd n m

goal (1 subgoal):
 1. regularAmicPair m n
[PROOF STEP]
using Amicable_pair_sym assms regularAmicPair_def
[PROOF STATE]
proof (prove)
using this:
gcd m n = gcd n m
?m Amic ?n \<Longrightarrow> ?n Amic ?m
regularAmicPair n m
regularAmicPair ?n ?m = (?n Amic ?m \<and> (\<exists>M N g. g = gcd ?m ?n \<and> ?m = M * g \<and> ?n = N * g \<and> squarefree M \<and> squarefree N \<and> gcd g M = 1 \<and> gcd g N = 1))

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma expectation_prod_Pi_pmf:
  fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> ('c :: {second_countable_topology,banach,real_normed_field})"
  assumes "finite I"
  assumes "\<And>i. i \<in> I \<Longrightarrow> integrable (measure_pmf (M i)) (f i)"
  shows   "integral\<^sup>L (Pi_pmf I d M) (\<lambda>x. (\<Prod>i \<in> I. f i (x i))) = (\<Prod> i \<in> I. integral\<^sup>L (M i) (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
have a: "prob_space.indep_vars (measure_pmf (Pi_pmf I d M)) (\<lambda>_. borel) (\<lambda>i \<omega>. f i (\<omega> i)) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space.indep_vars (measure_pmf (Pi_pmf I d M)) (\<lambda>_. borel) (\<lambda>i \<omega>. f i (\<omega> i)) I
[PROOF STEP]
by (intro prob_space.indep_vars_compose2[where Y="f" and M'="\<lambda>_. discrete"]
        prob_space_measure_pmf indep_vars_Pi_pmf assms(1)) auto
[PROOF STATE]
proof (state)
this:
prob_space.indep_vars (measure_pmf (Pi_pmf I d M)) (\<lambda>_. borel) (\<lambda>i \<omega>. f i (\<omega> i)) I

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
have "integral\<^sup>L (Pi_pmf I d M) (\<lambda>x. (\<Prod>i \<in> I. f i (x i))) = (\<Prod> i \<in> I. integral\<^sup>L (Pi_pmf I d M) (\<lambda>x. f i (x i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f i (x i)))
[PROOF STEP]
by (intro prob_space.indep_vars_lebesgue_integral prob_space_measure_pmf assms(1,2)
        a integrable_Pi_pmf_slice) auto
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f i (x i)))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f i (x i)))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
have "... = (\<Prod> i \<in> I. integral\<^sup>L (M i) (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>I. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f i (x i))) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
by (intro prod.cong expectation_Pi_pmf_slice assms(1,2)) auto
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>I. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. f i (x i))) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))

goal (1 subgoal):
 1. measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (Pi_pmf I d M) (\<lambda>x. \<Prod>i\<in>I. f i (x i)) = (\<Prod>i\<in>I. measure_pmf.expectation (M i) (f i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in Ring) surjec_right_exact:"\<lbrakk>R module M; R module N; f \<in> mHom R M N;
 p \<in> mHom R N (Zm R e); surjec\<^bsub>M,N\<^esub> f\<rbrakk> \<Longrightarrow> exact3 R M f N p (Zm R e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); surjec\<^bsub>M,N\<^esub> f\<rbrakk> \<Longrightarrow> exact3 R M f N p (Zm R e)
[PROOF STEP]
apply (simp add:exact3_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); surjec\<^bsub>M,N\<^esub> f\<rbrakk> \<Longrightarrow> f ` carrier M = ker\<^bsub>N,Zm R e\<^esub> p
[PROOF STEP]
apply (simp add:ker_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); surjec\<^bsub>M,N\<^esub> f\<rbrakk> \<Longrightarrow> f ` carrier M = {a \<in> carrier N. p a = \<zero>\<^bsub>Zm R e\<^esub>}
[PROOF STEP]
apply (frule_tac f = p and M = N and N = "Zm R e" in mHom_func,
        simp add:Zm_carrier)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); surjec\<^bsub>M,N\<^esub> f; p \<in> carrier N \<rightarrow> {e}\<rbrakk> \<Longrightarrow> f ` carrier M = {a \<in> carrier N. p a = \<zero>\<^bsub>Zm R e\<^esub>}
[PROOF STEP]
apply (simp add:surjec_def surj_to_def,
        thin_tac "f \<in> aHom M N \<and> f ` carrier M = carrier N")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); p \<in> carrier N \<rightarrow> {e}\<rbrakk> \<Longrightarrow> carrier N = {a \<in> carrier N. p a = \<zero>\<^bsub>Zm R e\<^esub>}
[PROOF STEP]
apply (subst Zm_def, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); p \<in> carrier N \<rightarrow> {e}\<rbrakk> \<Longrightarrow> carrier N = {a \<in> carrier N. p a = e}
[PROOF STEP]
apply (rule equalityI, rule subsetI, simp,
        frule funcset_mem[of p "carrier N" "{e}"], assumption, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M; R module N; f \<in> mHom R M N; p \<in> mHom R N (Zm R e); p \<in> carrier N \<rightarrow> {e}\<rbrakk> \<Longrightarrow> {a \<in> carrier N. p a = e} \<subseteq> carrier N
[PROOF STEP]
apply (rule subsetI, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in monoid_mult) interv_prod_list_conv_prod_set_nat:
  "prod_list (map f [m..<n]) = prod f (set [m..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (map f [m..<n]) = prod f (set [m..<n])
[PROOF STEP]
by (simp add: prod_list_distinct_conv_prod_set)