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

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


[STATEMENT]
lemma length_around_zero:
  assumes "i >= 0"
  shows "length (around_zero i) = 2 * nat i + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (around_zero i) = 2 * nat i + 1
[PROOF STEP]
proof (induct rule: int_ge_induct [OF assms])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (around_zero 0) = 2 * nat 0 + 1
 2. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. length (around_zero 0) = 2 * nat 0 + 1
 2. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
from 1
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (around_zero 0) = 2 * nat 0 + 1
[PROOF STEP]
by (simp add: around_zero.simps)
[PROOF STATE]
proof (state)
this:
length (around_zero 0) = 2 * nat 0 + 1

goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
case (2 i)
[PROOF STATE]
proof (state)
this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1

goal (1 subgoal):
 1. \<And>i. \<lbrakk>0 \<le> i; length (around_zero i) = 2 * nat i + 1\<rbrakk> \<Longrightarrow> length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
from 2
[PROOF STATE]
proof (chain)
picking this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 \<le> i
length (around_zero i) = 2 * nat i + 1

goal (1 subgoal):
 1. length (around_zero (i + 1)) = 2 * nat (i + 1) + 1
[PROOF STEP]
by (simp add: around_zero.simps [of "i + 1"])
[PROOF STATE]
proof (state)
this:
length (around_zero (i + 1)) = 2 * nat (i + 1) + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iso_paired2:
  assumes "group G" "group H"
  shows "(\<lambda>(x,y). (f x,g y)) \<in> iso (DirProd G H) (DirProd G' H') \<longleftrightarrow> f \<in> iso G G' \<and> g \<in> iso H H'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>(x, y). (f x, g y)) \<in> Group.iso (G \<times>\<times> H) (G' \<times>\<times> H')) = (f \<in> Group.iso G G' \<and> g \<in> Group.iso H H')
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Group.group G
Group.group H

goal (1 subgoal):
 1. ((\<lambda>(x, y). (f x, g y)) \<in> Group.iso (G \<times>\<times> H) (G' \<times>\<times> H')) = (f \<in> Group.iso G G' \<and> g \<in> Group.iso H H')
[PROOF STEP]
by (fastforce simp add: iso_def inj_on_def bij_betw_def hom_paired2 image_paired_Times
      times_eq_iff group_def monoid.carrier_not_empty)


[STATEMENT]
lemma euclid:
  "PRE (\<lambda>s::nat store. s ''x'' = x \<and> s ''y'' = y)
   (WHILE (\<lambda>s. s ''y'' \<noteq> 0) INV (\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y)
    DO
     (''z'' ::= (\<lambda>s. s ''y''));
     (''y'' ::= (\<lambda>s. s ''x'' mod s ''y''));
     (''x'' ::= (\<lambda>s. s ''z''))
    OD)
   POST (\<lambda>s. s ''x'' = gcd x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_aka.dom_op \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> rel_aka.wp (rel_aka.while_inv \<lceil>\<lambda>s. s ''y'' \<noteq> 0\<rceil> \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil> ((''z'' ::= (\<lambda>s. s ''y'')) ; (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) ; (''x'' ::= (\<lambda>s. s ''z'')))) \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
[PROOF STEP]
apply (rule rel_aka.wp_while_inv, simp_all)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>
 2. \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> s ''y'' = 0\<rceil> \<subseteq> \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
 3. \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> 0 < s ''y''\<rceil> \<subseteq> \<lceil>\<lambda>s. gcd (s ''y'') (s ''x'' mod s ''y'') = gcd x y\<rceil>
[PROOF STEP]
using gcd_red_nat
[PROOF STATE]
proof (prove)
using this:
gcd ?x ?y = gcd ?y (?x mod ?y)

goal (3 subgoals):
 1. \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>
 2. \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> s ''y'' = 0\<rceil> \<subseteq> \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
 3. \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y \<and> 0 < s ''y''\<rceil> \<subseteq> \<lceil>\<lambda>s. gcd (s ''y'') (s ''x'' mod s ''y'') = gcd x y\<rceil>
[PROOF STEP]
by auto


[STATEMENT]
lemma infsetsum_add:
  assumes "f abs_summable_on A" and "g abs_summable_on A"
  shows   "infsetsum (\<lambda>x. f x + g x) A = infsetsum f A + infsetsum g A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sub>ax\<in>A. f x + g x) = infsetsum f A + infsetsum g A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f abs_summable_on A
g abs_summable_on A

goal (1 subgoal):
 1. (\<Sum>\<^sub>ax\<in>A. f x + g x) = infsetsum f A + infsetsum g A
[PROOF STEP]
unfolding infsetsum_def abs_summable_on_def
[PROOF STATE]
proof (prove)
using this:
integrable (count_space A) f
integrable (count_space A) g

goal (1 subgoal):
 1. LINT x|count_space A. f x + g x = integral\<^sup>L (count_space A) f + integral\<^sup>L (count_space A) g
[PROOF STEP]
by (rule Bochner_Integration.integral_add)


[STATEMENT]
lemma Un_card1: "\<lbrakk> finite A; finite B \<rbrakk> \<Longrightarrow> card A \<le> card (A \<union> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> card A \<le> card (A \<union> B)
[PROOF STEP]
by (rule card_mono, simp_all)


[STATEMENT]
lemma L2_set_mult_ineq_lemma:
  fixes a b c d :: real
  shows "2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
have "0 \<le> (a * d - b * c)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (a * d - b * c)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (a * d - b * c)\<^sup>2

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 \<le> (a * d - b * c)\<^sup>2

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
have "\<dots> = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * d - b * c)\<^sup>2 = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c)
[PROOF STEP]
by (simp only: power2_diff power_mult_distrib)
[PROOF STATE]
proof (state)
this:
(a * d - b * c)\<^sup>2 = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c)

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a * d - b * c)\<^sup>2 = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c)

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
have "\<dots> = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c) = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c) = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)
[PROOF STEP]
show "2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
0 \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)

goal (1 subgoal):
 1. 2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma euclid2:
  "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. rdom \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> wp (WHILE (\<lambda>s. s ''y'' \<noteq> zero_class.zero) 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 hoare
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. rdom \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>
 2. rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil> ; pp_a \<lceil>\<lambda>s. s ''y'' \<noteq> zero_class.zero\<rceil> \<subseteq> rdom \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
 3. rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil> ; rdom \<lceil>\<lambda>s. s ''y'' \<noteq> zero_class.zero\<rceil> \<subseteq> wp (''z'' ::= (\<lambda>s. s ''y'')) (wp (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) (wp (''x'' ::= (\<lambda>s. s ''z'')) \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>))
[PROOF STEP]
using gcd_red_nat
[PROOF STATE]
proof (prove)
using this:
gcd ?x ?y = gcd ?y (?x mod ?y)

goal (3 subgoals):
 1. rdom \<lceil>\<lambda>s. s ''x'' = x \<and> s ''y'' = y\<rceil> \<subseteq> rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>
 2. rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil> ; pp_a \<lceil>\<lambda>s. s ''y'' \<noteq> zero_class.zero\<rceil> \<subseteq> rdom \<lceil>\<lambda>s. s ''x'' = gcd x y\<rceil>
 3. rdom \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil> ; rdom \<lceil>\<lambda>s. s ''y'' \<noteq> zero_class.zero\<rceil> \<subseteq> wp (''z'' ::= (\<lambda>s. s ''y'')) (wp (''y'' ::= (\<lambda>s. s ''x'' mod s ''y'')) (wp (''x'' ::= (\<lambda>s. s ''z'')) \<lceil>\<lambda>s. gcd (s ''x'') (s ''y'') = gcd x y\<rceil>))
[PROOF STEP]
by auto


[STATEMENT]
lemma card_Collect_nat:
  assumes "(j::nat)>i"
  shows "card {i..j} = j-i+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {i..j} = j - i + 1
[PROOF STEP]
using card_atLeastAtMost
[PROOF STATE]
proof (prove)
using this:
card {?l..?u} = Suc ?u - ?l

goal (1 subgoal):
 1. card {i..j} = j - i + 1
[PROOF STEP]
using Suc_diff_le assms le_eq_less_or_eq
[PROOF STATE]
proof (prove)
using this:
card {?l..?u} = Suc ?u - ?l
?n \<le> ?m \<Longrightarrow> Suc ?m - ?n = Suc (?m - ?n)
i < j
(?m \<le> ?n) = (?m < ?n \<or> ?m = ?n)

goal (1 subgoal):
 1. card {i..j} = j - i + 1
[PROOF STEP]
by presburger


[STATEMENT]
lemma nat_minus_mod: "(n - n mod m) mod m = 0"
  for m n :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n - n mod m) mod m = 0
[PROOF STEP]
by (induct n) (simp_all add: mod_Suc)


[STATEMENT]
lemma M_cong_7_mod_12: "[M = 7] (mod 12)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [M = 7] (mod 12)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [M = 7] (mod 12)
[PROOF STEP]
have "[M = 8 - 1] (mod 12)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [M = 8 - 1] (mod 12)
[PROOF STEP]
using p_gt_2 p_odd
[PROOF STATE]
proof (prove)
using this:
2 < p
odd p

goal (1 subgoal):
 1. [M = 8 - 1] (mod 12)
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
using this:
2 < p
odd p

goal (1 subgoal):
 1. [2 ^ p - 1 = 8 - 1] (mod 12)
[PROOF STEP]
by (intro cong_diff_nat two_power_odd_mod_12) auto
[PROOF STATE]
proof (state)
this:
[M = 8 - 1] (mod 12)

goal (1 subgoal):
 1. [M = 7] (mod 12)
[PROOF STEP]
thus "[M = 7] (mod 12)"
[PROOF STATE]
proof (prove)
using this:
[M = 8 - 1] (mod 12)

goal (1 subgoal):
 1. [M = 7] (mod 12)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[M = 7] (mod 12)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem equiv_msgrel: "equivp msgrel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. equivp (\<sim>)
[PROOF STEP]
proof (rule equivpI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. reflp (\<sim>)
 2. symp (\<sim>)
 3. transp (\<sim>)
[PROOF STEP]
show "reflp msgrel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reflp (\<sim>)
[PROOF STEP]
by (rule reflpI) (simp add: msgrel_refl)
[PROOF STATE]
proof (state)
this:
reflp (\<sim>)

goal (2 subgoals):
 1. symp (\<sim>)
 2. transp (\<sim>)
[PROOF STEP]
show "symp msgrel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. symp (\<sim>)
[PROOF STEP]
by (rule sympI) (blast intro: msgrel.SYM)
[PROOF STATE]
proof (state)
this:
symp (\<sim>)

goal (1 subgoal):
 1. transp (\<sim>)
[PROOF STEP]
show "transp msgrel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transp (\<sim>)
[PROOF STEP]
by (rule transpI) (blast intro: msgrel.TRANS)
[PROOF STATE]
proof (state)
this:
transp (\<sim>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_power_diff:
  fixes z w :: "'a::{real_normed_algebra_1, comm_monoid_mult}"
  assumes "norm z \<le> 1" "norm w \<le> 1"
  shows "norm (z^m - w^m) \<le> m * norm (z - w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
have "norm (z^m - w^m) = norm ((\<Prod> i < m. z) - (\<Prod> i < m. w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (z ^ m - w ^ m) = norm ((\<Prod>i<m. z) - (\<Prod>i<m. w))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm (z ^ m - w ^ m) = norm ((\<Prod>i<m. z) - (\<Prod>i<m. w))

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (z ^ m - w ^ m) = norm ((\<Prod>i<m. z) - (\<Prod>i<m. w))

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
have "\<dots> \<le> (\<Sum>i<m. norm (z - w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm ((\<Prod>i<m. z) - (\<Prod>i<m. w)) \<le> (\<Sum>i<m. norm (z - w))
[PROOF STEP]
by (intro norm_prod_diff) (auto simp: assms)
[PROOF STATE]
proof (state)
this:
norm ((\<Prod>i<m. z) - (\<Prod>i<m. w)) \<le> (\<Sum>i<m. norm (z - w))

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm ((\<Prod>i<m. z) - (\<Prod>i<m. w)) \<le> (\<Sum>i<m. norm (z - w))

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
have "\<dots> = m * norm (z - w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<m. norm (z - w)) = real m * norm (z - w)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i<m. norm (z - w)) = real m * norm (z - w)

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (z ^ m - w ^ m) \<le> real m * norm (z - w)

goal (1 subgoal):
 1. norm (z ^ m - w ^ m) \<le> real m * norm (z - w)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
norm (z ^ m - w ^ m) \<le> real m * norm (z - w)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma trigonometric_set_even:
   "trigonometric_set(2*k) = (if k = 0 then (\<lambda>x. 1 / sqrt(2 * pi)) else (\<lambda>x. cos(k * x) / sqrt pi))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trigonometric_set (2 * k) = (if k = 0 then \<lambda>x. 1 / sqrt (2 * pi) else (\<lambda>x. cos (real k * x) / sqrt pi))
[PROOF STEP]
by (induction k) (auto simp: trigonometric_set_def add_divide_distrib split: if_split_asm)


[STATEMENT]
lemma deriv_mult [simp]:
  "\<lbrakk>f field_differentiable at z; g field_differentiable at z\<rbrakk>
   \<Longrightarrow> deriv (\<lambda>w. f w * g w) z = f z * deriv g z + deriv f z * g z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f field_differentiable at z; g field_differentiable at z\<rbrakk> \<Longrightarrow> deriv (\<lambda>w. f w * g w) z = f z * deriv g z + deriv f z * g z
[PROOF STEP]
unfolding DERIV_deriv_iff_field_differentiable[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f has_field_derivative deriv f z) (at z); (g has_field_derivative deriv g z) (at z)\<rbrakk> \<Longrightarrow> deriv (\<lambda>w. f w * g w) z = f z * deriv g z + deriv f z * g z
[PROOF STEP]
by (auto intro!: DERIV_imp_deriv derivative_eq_intros)


[STATEMENT]
lemma multipl_div:
  fixes m k d1 d2 :: nat and f :: "nat \<Rightarrow> complex"
  assumes "multiplicative_function f" "d1 dvd m" "d2 dvd k" "coprime m k"
  shows "f ((m*k) div (d1*d2)) = f(m div d1) * f(k div d2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (m * k div (d1 * d2)) = f (m div d1) * f (k div d2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
multiplicative_function f
d1 dvd m
d2 dvd k
coprime m k

goal (1 subgoal):
 1. f (m * k div (d1 * d2)) = f (m div d1) * f (k div d2)
[PROOF STEP]
unfolding multiplicative_function_def
[PROOF STATE]
proof (prove)
using this:
f 0 = 0 \<and> f 1 = 1 \<and> (\<forall>a b. 1 < a \<longrightarrow> 1 < b \<longrightarrow> coprime a b \<longrightarrow> f (a * b) = f a * f b)
d1 dvd m
d2 dvd k
coprime m k

goal (1 subgoal):
 1. f (m * k div (d1 * d2)) = f (m div d1) * f (k div d2)
[PROOF STEP]
using assms(1) multiplicative_function.mult_coprime
[PROOF STATE]
proof (prove)
using this:
f 0 = 0 \<and> f 1 = 1 \<and> (\<forall>a b. 1 < a \<longrightarrow> 1 < b \<longrightarrow> coprime a b \<longrightarrow> f (a * b) = f a * f b)
d1 dvd m
d2 dvd k
coprime m k
multiplicative_function f
\<lbrakk>multiplicative_function ?f; coprime ?a ?b\<rbrakk> \<Longrightarrow> ?f (?a * ?b) = ?f ?a * ?f ?b

goal (1 subgoal):
 1. f (m * k div (d1 * d2)) = f (m div d1) * f (k div d2)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma linear_enclosure:
  fixes x::real
  assumes "\<And>x. x \<in> {a .. b} \<Longrightarrow> (f has_field_derivative f' x) (at x within {a .. b})"
  assumes "\<And>x. x \<in> {a .. b} \<Longrightarrow> f' x \<le> u"
  assumes "x \<in> {a .. b}"
  shows "f x \<in> {f b + u * (x - b) .. f a + u * (x - a)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<in> {f b + u * (x - b)..f a + u * (x - a)}
[PROOF STEP]
using linear_lower[OF assms] linear_upper[OF assms]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x. x \<in> {a..b} \<Longrightarrow> x \<in> {a..b}; \<And>x. x \<in> {a..b} \<Longrightarrow> x \<in> {a..b}\<rbrakk> \<Longrightarrow> f b + u * (x - b) \<le> f x
\<lbrakk>\<And>x. x \<in> {a..b} \<Longrightarrow> x \<in> {a..b}; \<And>x. x \<in> {a..b} \<Longrightarrow> x \<in> {a..b}\<rbrakk> \<Longrightarrow> f x \<le> f a + u * (x - a)

goal (1 subgoal):
 1. f x \<in> {f b + u * (x - b)..f a + u * (x - a)}
[PROOF STEP]
by auto


[STATEMENT]
theorem card_trees_of_size: "card (trees_of_size n) = catalan n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (trees_of_size n) = catalan n
[PROOF STEP]
by (induction n rule: catalan.induct)
     (simp_all add: catalan_Suc trees_of_size_Suc card_image inj_on_def
        trees_of_size_disjoint Times_Int_Times catalan_Suc card_UN_disjoint)


[STATEMENT]
lemma find_zeros_from_vec_prop:
  fixes input_vec :: "rat vec"
  shows "\<forall>n < (dim_vec input_vec). ((input_vec $ n \<noteq> 0) \<longleftrightarrow>
         List.member (find_nonzeros_from_input_vec input_vec) n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
have h1: "\<forall>n < (dim_vec input_vec). ((input_vec $ n \<noteq> 0) \<longrightarrow>  List.member (find_nonzeros_from_input_vec input_vec) n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. input_vec $ n \<noteq> 0 \<longrightarrow> List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
unfolding find_nonzeros_from_input_vec_def List.member_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. input_vec $ n \<noteq> 0 \<longrightarrow> n \<in> set (filter (\<lambda>i. input_vec $ i \<noteq> 0) [0..<dim_vec input_vec])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>n<dim_vec input_vec. input_vec $ n \<noteq> 0 \<longrightarrow> List.member (find_nonzeros_from_input_vec input_vec) n

goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
have h2: "\<forall>n < (dim_vec input_vec). (List.member (find_nonzeros_from_input_vec input_vec) n \<longrightarrow> (input_vec $ n \<noteq> 0) )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. List.member (find_nonzeros_from_input_vec input_vec) n \<longrightarrow> input_vec $ n \<noteq> 0
[PROOF STEP]
unfolding find_nonzeros_from_input_vec_def List.member_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. n \<in> set (filter (\<lambda>i. input_vec $ i \<noteq> 0) [0..<dim_vec input_vec]) \<longrightarrow> input_vec $ n \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>n<dim_vec input_vec. List.member (find_nonzeros_from_input_vec input_vec) n \<longrightarrow> input_vec $ n \<noteq> 0

goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
using h1 h2
[PROOF STATE]
proof (prove)
using this:
\<forall>n<dim_vec input_vec. input_vec $ n \<noteq> 0 \<longrightarrow> List.member (find_nonzeros_from_input_vec input_vec) n
\<forall>n<dim_vec input_vec. List.member (find_nonzeros_from_input_vec input_vec) n \<longrightarrow> input_vec $ n \<noteq> 0

goal (1 subgoal):
 1. \<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>n<dim_vec input_vec. (input_vec $ n \<noteq> 0) = List.member (find_nonzeros_from_input_vec input_vec) n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integral_norm_bound_integral:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::{banach,second_countable_topology}"
  assumes "integrable M f" "integrable M g" "\<And>x. x \<in> space M \<Longrightarrow> norm(f x) \<le> g x"
  shows "norm (\<integral>x. f x \<partial>M) \<le> (\<integral>x. g x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (integral\<^sup>L M f) \<le> integral\<^sup>L M g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (integral\<^sup>L M f) \<le> integral\<^sup>L M g
[PROOF STEP]
have "norm (\<integral>x. f x \<partial>M) \<le> (\<integral>x. norm (f x) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (integral\<^sup>L M f) \<le> LINT x|M. norm (f x)
[PROOF STEP]
by (rule integral_norm_bound)
[PROOF STATE]
proof (state)
this:
norm (integral\<^sup>L M f) \<le> LINT x|M. norm (f x)

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

goal (1 subgoal):
 1. norm (integral\<^sup>L M f) \<le> integral\<^sup>L M g
[PROOF STEP]
have "... \<le> (\<integral>x. g x \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LINT x|M. norm (f x) \<le> integral\<^sup>L M g
[PROOF STEP]
using assms integrable_norm integral_mono
[PROOF STATE]
proof (prove)
using this:
integrable M f
integrable M g
?x \<in> space M \<Longrightarrow> norm (f ?x) \<le> g ?x
integrable ?M ?f \<Longrightarrow> integrable ?M (\<lambda>x. norm (?f x))
\<lbrakk>integrable ?M ?f; integrable ?M ?g; \<And>x. x \<in> space ?M \<Longrightarrow> ?f x \<le> ?g x\<rbrakk> \<Longrightarrow> integral\<^sup>L ?M ?f \<le> integral\<^sup>L ?M ?g

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem M8: "\<turnstile> \<box>[F \<and> G]_v = (\<box>[F]_v \<and> \<box>[G]_v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<turnstile> \<box>[F \<and> G]_v = (\<box>[F]_v \<and> \<box>[G]_v)
[PROOF STEP]
by (rule int_iffI[OF M6 M7])


[STATEMENT]
lemma op_norm_le_max_norm:
  fixes A :: "real^('n::finite)^('m::finite)"
  shows "\<parallel>A\<parallel>\<^sub>o\<^sub>p \<le> real CARD('m) * real CARD('n) * (\<parallel>A\<parallel>\<^sub>m\<^sub>a\<^sub>x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>A\<parallel>\<^sub>o\<^sub>p \<le> real CARD('m) * real CARD('n) * (\<parallel>A\<parallel>\<^sub>m\<^sub>a\<^sub>x)
[PROOF STEP]
apply(rule onorm_le_matrix_component)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<bar>A $ i $ j\<bar> \<le> \<parallel>A\<parallel>\<^sub>m\<^sub>a\<^sub>x
[PROOF STEP]
unfolding max_norm_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<bar>A $ i $ j\<bar> \<le> Max {\<bar>A $ i $ j\<bar> |i j. i \<in> UNIV \<and> j \<in> UNIV}
[PROOF STEP]
by(rule Max_ge[OF max_norm_set_proptys]) force


[STATEMENT]
lemma onorm_scaleC_left_lemma:
  fixes f :: "'a::complex_normed_vector"
  assumes r: "bounded_clinear r"
  shows "onorm (\<lambda>x. r x *\<^sub>C f) \<le> onorm r * norm f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. onorm (\<lambda>x. r x *\<^sub>C f) \<le> onorm r * norm f
[PROOF STEP]
proof (rule onorm_bound)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> onorm r * norm f
 2. \<And>x. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> onorm r * norm f
 2. \<And>x. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
have "norm (r x *\<^sub>C f) = norm (r x) * norm f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (r x *\<^sub>C f) = cmod (r x) * norm f
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm (r x *\<^sub>C f) = cmod (r x) * norm f

goal (2 subgoals):
 1. 0 \<le> onorm r * norm f
 2. \<And>x. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm (r x *\<^sub>C f) = cmod (r x) * norm f

goal (2 subgoals):
 1. 0 \<le> onorm r * norm f
 2. \<And>x. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
have "\<dots> \<le> onorm r * norm x * norm f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (r x) * norm f \<le> onorm r * norm x * norm f
[PROOF STEP]
by (simp add: bounded_clinear.bounded_linear mult.commute mult_left_mono onorm r)
[PROOF STATE]
proof (state)
this:
cmod (r x) * norm f \<le> onorm r * norm x * norm f

goal (2 subgoals):
 1. 0 \<le> onorm r * norm f
 2. \<And>x. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm (r x *\<^sub>C f) \<le> onorm r * norm x * norm f
[PROOF STEP]
show "norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x"
[PROOF STATE]
proof (prove)
using this:
norm (r x *\<^sub>C f) \<le> onorm r * norm x * norm f

goal (1 subgoal):
 1. norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
norm (r x *\<^sub>C f) \<le> onorm r * norm f * norm x

goal (1 subgoal):
 1. 0 \<le> onorm r * norm f
[PROOF STEP]
show "0 \<le> onorm r * norm f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> onorm r * norm f
[PROOF STEP]
by (simp add: bounded_clinear.bounded_linear onorm_pos_le r)
[PROOF STATE]
proof (state)
this:
0 \<le> onorm r * norm f

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcd_lcm_distrib:
  "gcd x (lcm y z) = lcm (gcd x y) (gcd x z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
proof (cases "x = 0 \<or> y = 0 \<or> z = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
 2. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)

goal (2 subgoals):
 1. x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
 2. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)

goal (1 subgoal):
 1. gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
by (auto simp: lcm_proj1_if_dvd lcm_proj2_if_dvd)
[PROOF STATE]
proof (state)
this:
gcd x (lcm y z) = lcm (gcd x y) (gcd x z)

goal (1 subgoal):
 1. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a))

goal (1 subgoal):
 1. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
hence "normalize (gcd x (lcm y z)) = normalize (lcm (gcd x y) (gcd x z))"
[PROOF STATE]
proof (prove)
using this:
\<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a))

goal (1 subgoal):
 1. normalize (gcd x (lcm y z)) = normalize (lcm (gcd x y) (gcd x z))
[PROOF STEP]
by (intro associatedI prime_factorization_subset_imp_dvd)
       (auto simp: lcm_eq_0_iff prime_factorization_gcd prime_factorization_lcm
          subset_mset.inf_sup_distrib1)
[PROOF STATE]
proof (state)
this:
normalize (gcd x (lcm y z)) = normalize (lcm (gcd x y) (gcd x z))

goal (1 subgoal):
 1. \<not> (x = (0::'a) \<or> y = (0::'a) \<or> z = (0::'a)) \<Longrightarrow> gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
normalize (gcd x (lcm y z)) = normalize (lcm (gcd x y) (gcd x z))

goal (1 subgoal):
 1. gcd x (lcm y z) = lcm (gcd x y) (gcd x z)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd x (lcm y z) = lcm (gcd x y) (gcd x z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma imirror_bounds_Int: "
  \<lbrakk> A \<subseteq> {..l + r}; B \<subseteq> {..l + r} \<rbrakk> \<Longrightarrow>
  imirror_bounds (A \<inter> B) l r =
  imirror_bounds A l r \<inter> imirror_bounds B l r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..l + r}; B \<subseteq> {..l + r}\<rbrakk> \<Longrightarrow> imirror_bounds (A \<inter> B) l r = imirror_bounds A l r \<inter> imirror_bounds B l r
[PROOF STEP]
apply (unfold imirror_bounds_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..l + r}; B \<subseteq> {..l + r}\<rbrakk> \<Longrightarrow> (\<lambda>x. nat_mirror x l r) ` (A \<inter> B) = (\<lambda>x. nat_mirror x l r) ` A \<inter> (\<lambda>x. nat_mirror x l r) ` B
[PROOF STEP]
apply (rule inj_on_image_Int[OF _ Un_upper1 Un_upper2])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..l + r}; B \<subseteq> {..l + r}\<rbrakk> \<Longrightarrow> inj_on (\<lambda>x. nat_mirror x l r) (A \<union> B)
[PROOF STEP]
apply (rule subset_inj_on[OF nat_mirror_inj_on])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> {..l + r}; B \<subseteq> {..l + r}\<rbrakk> \<Longrightarrow> A \<union> B \<subseteq> {..l + r}
[PROOF STEP]
apply (rule Un_least[of A _ B], assumption+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma matrix_match_condn_2:
"matrix_match A1 A2 B1 B2
 \<and>((i<(row_length A1)*(row_length B1))
 \<and>(j<(length A2)*(length B2)))
  \<Longrightarrow> ((A1 \<otimes> B1)\<circ>(A2 \<otimes> B2))!j!i
          =  scalar_product
                (vec_vec_Tensor
                        (row A1 (i div row_length B1))
                        (row B1 (i mod row_length B1)))
                (vec_vec_Tensor
                        (col A2 (j div length B2))
                        (col B2 (j mod length B2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_match A1 A2 B1 B2 \<and> i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<Longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
using elements_matrix_distribution2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>mat (row_length ?A1.0) (length ?A1.0) ?A1.0; mat (row_length ?A2.0) (length ?A2.0) ?A2.0; mat (row_length ?B1.0) (length ?B1.0) ?B1.0; mat (row_length ?B2.0) (length ?B2.0) ?B2.0; length ?A1.0 = row_length ?A2.0; length ?B1.0 = row_length ?B2.0; ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> []; ?i < row_length ?A1.0 * row_length ?B1.0; ?j < length ?A2.0 * length ?B2.0\<rbrakk> \<Longrightarrow> ((?A1.0 \<otimes> ?B1.0) \<circ> (?A2.0 \<otimes> ?B2.0)) ! ?j ! ?i = scalar_product (vec_vec_Tensor (row ?A1.0 (?i div row_length ?B1.0)) (row ?B1.0 (?i mod row_length ?B1.0))) (vec_vec_Tensor (col ?A2.0 (?j div length ?B2.0)) (col ?B2.0 (?j mod length ?B2.0)))

goal (1 subgoal):
 1. matrix_match A1 A2 B1 B2 \<and> i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<Longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
unfolding matrix_match_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>mat (row_length ?A1.0) (length ?A1.0) ?A1.0; mat (row_length ?A2.0) (length ?A2.0) ?A2.0; mat (row_length ?B1.0) (length ?B1.0) ?B1.0; mat (row_length ?B2.0) (length ?B2.0) ?B2.0; length ?A1.0 = row_length ?A2.0; length ?B1.0 = row_length ?B2.0; ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> []; ?i < row_length ?A1.0 * row_length ?B1.0; ?j < length ?A2.0 * length ?B2.0\<rbrakk> \<Longrightarrow> ((?A1.0 \<otimes> ?B1.0) \<circ> (?A2.0 \<otimes> ?B2.0)) ! ?j ! ?i = scalar_product (vec_vec_Tensor (row ?A1.0 (?i div row_length ?B1.0)) (row ?B1.0 (?i mod row_length ?B1.0))) (vec_vec_Tensor (col ?A2.0 (?j div length ?B2.0)) (col ?B2.0 (?j mod length ?B2.0)))

goal (1 subgoal):
 1. (mat (row_length A1) (length A1) A1 \<and> mat (row_length A2) (length A2) A2 \<and> mat (row_length B1) (length B1) B1 \<and> mat (row_length B2) (length B2) B2 \<and> length A1 = row_length A2 \<and> length B1 = row_length B2 \<and> A1 \<noteq> [] \<and> A2 \<noteq> [] \<and> B1 \<noteq> [] \<and> B2 \<noteq> []) \<and> i < row_length A1 * row_length B1 \<and> j < length A2 * length B2 \<Longrightarrow> ((A1 \<otimes> B1) \<circ> (A2 \<otimes> B2)) ! j ! i = scalar_product (vec_vec_Tensor (row A1 (i div row_length B1)) (row B1 (i mod row_length B1))) (vec_vec_Tensor (col A2 (j div length B2)) (col B2 (j mod length B2)))
[PROOF STEP]
by auto


[STATEMENT]
lemma triangle_lemma:
  fixes x y z :: real
  assumes x: "0 \<le> x"
    and y: "0 \<le> y"
    and z: "0 \<le> z"
    and xy: "x\<^sup>2 \<le> y\<^sup>2 + z\<^sup>2"
  shows "x \<le> y + z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y + z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<le> y + z
[PROOF STEP]
have "y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2
[PROOF STEP]
using z y
[PROOF STATE]
proof (prove)
using this:
0 \<le> z
0 \<le> y

goal (1 subgoal):
 1. y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2

goal (1 subgoal):
 1. x \<le> y + z
[PROOF STEP]
with xy
[PROOF STATE]
proof (chain)
picking this:
x\<^sup>2 \<le> y\<^sup>2 + z\<^sup>2
y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2
[PROOF STEP]
have th: "x\<^sup>2 \<le> (y + z)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>2 \<le> y\<^sup>2 + z\<^sup>2
y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2

goal (1 subgoal):
 1. x\<^sup>2 \<le> (y + z)\<^sup>2
[PROOF STEP]
by (simp add: power2_eq_square field_simps)
[PROOF STATE]
proof (state)
this:
x\<^sup>2 \<le> (y + z)\<^sup>2

goal (1 subgoal):
 1. x \<le> y + z
[PROOF STEP]
from y z
[PROOF STATE]
proof (chain)
picking this:
0 \<le> y
0 \<le> z
[PROOF STEP]
have yz: "y + z \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> y
0 \<le> z

goal (1 subgoal):
 1. 0 \<le> y + z
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
0 \<le> y + z

goal (1 subgoal):
 1. x \<le> y + z
[PROOF STEP]
from power2_le_imp_le[OF th yz]
[PROOF STATE]
proof (chain)
picking this:
x \<le> y + z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<le> y + z

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma in_set_least_squares_approximation_eq_full_rank_QR:
  fixes A::"real^'cols::{mod_type}^'rows::{mod_type}"
  assumes r: "rank A = ncols A"
  shows "(x \<in> set_least_squares_approximation A b) = ((snd (QR_decomposition A)) *v x = transpose (fst (QR_decomposition A)) *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
let ?Q = "fst (QR_decomposition A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
let ?R = "snd (QR_decomposition A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have inv_tR: "invertible (transpose ?R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)))
[PROOF STEP]
by (metis invertible_snd_QR_decomposition invertible_transpose r)
[PROOF STATE]
proof (state)
this:
invertible (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have inv_inv_tR: "invertible (matrix_inv (transpose ?R))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))))
[PROOF STEP]
by (metis inv_tR invertible_fst_Gauss_Jordan_PA matrix_inv_Gauss_Jordan_PA)
[PROOF STATE]
proof (state)
this:
invertible (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "(x \<in> set_least_squares_approximation A b) = (transpose A ** A *v x = transpose A *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b)
[PROOF STEP]
using in_set_least_squares_approximation_eq
[PROOF STATE]
proof (prove)
using this:
(?x \<in> set_least_squares_approximation ?A ?b) = (Finite_Cartesian_Product.transpose ?A ** ?A *v ?x = Finite_Cartesian_Product.transpose ?A *v ?b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(x \<in> set_least_squares_approximation A b) = (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x \<in> set_least_squares_approximation A b) = (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (transpose (?Q ** ?R) ** (?Q ** ?R) *v x = transpose (?Q ** ?R) *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b)
[PROOF STEP]
using QR_decomposition_mult[OF r]
[PROOF STATE]
proof (prove)
using this:
A = fst (QR_decomposition A) ** snd (QR_decomposition A)

goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose A ** A *v x = Finite_Cartesian_Product.transpose A *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (transpose ?R ** transpose ?Q **  (?Q ** ?R) *v x  = transpose ?R ** transpose ?Q *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
by (metis (opaque_lifting, no_types) matrix_transpose_mul)
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (transpose ?R *v (transpose ?Q ** (?Q ** ?R) *v x)  = transpose ?R *v (transpose ?Q *v b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))
[PROOF STEP]
by (metis (opaque_lifting, no_types) matrix_vector_mul_assoc)
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) ** Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (matrix_inv (transpose ?R) *v (transpose ?R *v (transpose ?Q ** (?Q ** ?R) *v x))
    = matrix_inv (transpose ?R) *v (transpose ?R *v (transpose ?Q *v b)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)))
[PROOF STEP]
using inv_matrix_vector_mul_left[OF inv_inv_tR]
[PROOF STATE]
proof (prove)
using this:
(matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v ?x = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v ?y) = (?x = ?y)

goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = ((matrix_inv (transpose ?R) ** transpose ?R) *v (transpose ?Q ** (?Q ** ?R) *v x)
    = (matrix_inv (transpose ?R) ** transpose ?R) *v (transpose ?Q *v b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))
[PROOF STEP]
by (metis (opaque_lifting, no_types) matrix_vector_mul_assoc)
[PROOF STATE]
proof (state)
this:
(matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x)) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) *v (Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))) = (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b))

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (transpose ?Q ** (?Q ** ?R) *v x = transpose ?Q *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
unfolding matrix_inv_left[OF inv_tR]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat 1 *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = mat 1 *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
unfolding matrix_vector_mul_lid
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x) = matrix_inv (Finite_Cartesian_Product.transpose (snd (QR_decomposition A))) ** Finite_Cartesian_Product.transpose (snd (QR_decomposition A)) *v (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = ((transpose ?Q ** ?Q) ** ?R *v x = transpose ?Q *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
by (metis (opaque_lifting, no_types) matrix_mul_assoc)
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** (fst (QR_decomposition A) ** snd (QR_decomposition A)) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
have "... = (?R *v x = transpose ?Q *v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
unfolding orthogonal_matrix_fst_QR_decomposition[OF r]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat 1 ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
unfolding matrix_mul_lid
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) ** fst (QR_decomposition A) ** snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
show "(x \<in> set_least_squares_approximation A b) = (?R *v x = (transpose ?Q) *v b)"
[PROOF STATE]
proof (prove)
using this:
(x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal (1 subgoal):
 1. (x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(x \<in> set_least_squares_approximation A b) = (snd (QR_decomposition A) *v x = Finite_Cartesian_Product.transpose (fst (QR_decomposition A)) *v b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem eval_negation:
  "eval i (Neg' p) =
    (
      if eval i p = Det False then Det True else
      if eval i p = Det True then Det False else
      eval i p
    )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval i (Neg' p) = (if eval i p = Det False then Det True else if eval i p = Det True then Det False else eval i p)
[PROOF STEP]
by (cases "eval i p") simp_all


[STATEMENT]
lemma linear_singular_into_hyperplane:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
  assumes "linear f"
  shows "\<not> inj f \<longleftrightarrow> (\<exists>a. a \<noteq> 0 \<and> (\<forall>x. a \<bullet> f x = 0))" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> inj f) = (\<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<not> inj f \<Longrightarrow> \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)
 2. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0) \<Longrightarrow> \<not> inj f
[PROOF STEP]
assume "\<not>inj f"
[PROOF STATE]
proof (state)
this:
\<not> inj f

goal (2 subgoals):
 1. \<not> inj f \<Longrightarrow> \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)
 2. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0) \<Longrightarrow> \<not> inj f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> inj f
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
\<not> inj f

goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)
[PROOF STEP]
using all_zero_iff
[PROOF STATE]
proof (prove)
using this:
\<not> inj f
(\<forall>u. ?x \<bullet> u = 0) = (?x = (0::?'a))

goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)
[PROOF STEP]
by (metis (no_types, opaque_lifting) adjoint_clauses(2) adjoint_linear assms
        linear_injective_0 linear_injective_imp_surjective linear_surj_adj_imp_inj)
[PROOF STATE]
proof (state)
this:
\<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)

goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0) \<Longrightarrow> \<not> inj f
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0) \<Longrightarrow> \<not> inj f
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)

goal (1 subgoal):
 1. \<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0) \<Longrightarrow> \<not> inj f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)
[PROOF STEP]
show "\<not>inj f"
[PROOF STATE]
proof (prove)
using this:
\<exists>a. a \<noteq> (0::'n) \<and> (\<forall>x. a \<bullet> f x = 0)

goal (1 subgoal):
 1. \<not> inj f
[PROOF STEP]
by (metis assms linear_injective_isomorphism all_zero_iff)
[PROOF STATE]
proof (state)
this:
\<not> inj f

goal:
No subgoals!
[PROOF STEP]
qed


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

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


[STATEMENT]
lemma sqr_of_cmod_of_prod:
  shows "(cmod (z1 * z2))\<^sup>2 = (cmod z1)\<^sup>2 * (cmod z2)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod (z1 * z2))\<^sup>2 = (cmod z1)\<^sup>2 * (cmod z2)\<^sup>2
[PROOF STEP]
by (simp add: norm_mult power_mult_distrib)


[STATEMENT]
theorem weak_integer_compositions_cardinality: "card (weak_integer_compositions n k) = k multichoose n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (weak_integer_compositions n k) = k multichoose n
[PROOF STEP]
using weak_integer_composition_enum_correct weak_integer_composition_enum_distinct composition_enum_length
  distinct_card
[PROOF STATE]
proof (prove)
using this:
set (weak_integer_composition_enum ?i ?l) = weak_integer_compositions ?i ?l
distinct (weak_integer_composition_enum ?i ?l)
length (weak_integer_composition_enum ?i ?n) = ?n multichoose ?i
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (weak_integer_compositions n k) = k multichoose n
[PROOF STEP]
by metis


[STATEMENT]
lemma vec_norm_triangle_sq:
  fixes u::"complex Matrix.vec"
  assumes "dim_vec u = dim_vec v"
  shows "(vec_norm (u+ v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "(vec_norm (u+v))\<^sup>2 = inner_prod (u+v) (u+v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 = Complex_Matrix.inner_prod (u + v) (u + v)
[PROOF STEP]
by (simp add: inner_prod_vec_norm_pow2)
[PROOF STATE]
proof (state)
this:
(vec_norm (u + v))\<^sup>2 = Complex_Matrix.inner_prod (u + v) (u + v)

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(vec_norm (u + v))\<^sup>2 = Complex_Matrix.inner_prod (u + v) (u + v)

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "... = inner_prod u u + inner_prod u v + inner_prod v u +
    inner_prod v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod (u + v) (u + v) = Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v
[PROOF STEP]
using assms add_scalar_prod_distrib conjugate_add_vec
[PROOF STATE]
proof (prove)
using this:
dim_vec u = dim_vec v
\<lbrakk>?v\<^sub>1 \<in> carrier_vec ?n; ?v\<^sub>2 \<in> carrier_vec ?n; ?v\<^sub>3 \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> (?v\<^sub>1 + ?v\<^sub>2) \<bullet> ?v\<^sub>3 = ?v\<^sub>1 \<bullet> ?v\<^sub>3 + ?v\<^sub>2 \<bullet> ?v\<^sub>3
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> conjugate (?v + ?w) = conjugate ?v + conjugate ?w

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (u + v) (u + v) = Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v
[PROOF STEP]
by (smt (z3) ab_semigroup_add_class.add_ac(1) carrier_vec_dim_vec
        dim_vec_conjugate index_add_vec(2) scalar_prod_add_distrib)
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod (u + v) (u + v) = Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod (u + v) (u + v) = Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "... = (vec_norm u)^2 + inner_prod u v + inner_prod v u +
    (vec_norm v)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v = (vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2
[PROOF STEP]
by (simp add: inner_prod_vec_norm_pow2)
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v = (vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod u u + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + Complex_Matrix.inner_prod v v = (vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "... \<le> (vec_norm u)^2 + 2 * cmod (inner_prod u v) + (vec_norm v)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2
[PROOF STEP]
by (metis add_conj_le add_left_mono add_right_mono assms
        carrier_vec_dim_vec conjugate_complex_def inner_prod_swap
        is_num_normalize(1))
[PROOF STATE]
proof (state)
this:
(vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(vec_norm u)\<^sup>2 + Complex_Matrix.inner_prod u v + Complex_Matrix.inner_prod v u + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "... \<le> (vec_norm u)^2 + 2 * ((vec_norm u)*(vec_norm v)) +
    (vec_norm v)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2
[PROOF STEP]
using Cauchy_Schwarz_complex_vec_norm[of u  v] assms less_eq_complex_def
[PROOF STATE]
proof (prove)
using this:
dim_vec u = dim_vec v \<Longrightarrow> complex_of_real (cmod (Complex_Matrix.inner_prod u v)) \<le> vec_norm u * vec_norm v
dim_vec u = dim_vec v
(?x \<le> ?y) = (Re ?x \<le> Re ?y \<and> Im ?x = Im ?y)

goal (1 subgoal):
 1. (vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(vec_norm u)\<^sup>2 + complex_of_real (2 * cmod (Complex_Matrix.inner_prod u v)) + (vec_norm v)\<^sup>2 \<le> (vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
have "... = (vec_norm u + vec_norm v)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2 = (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
by (simp add: power2_sum)
[PROOF STATE]
proof (state)
this:
(vec_norm u)\<^sup>2 + 2 * (vec_norm u * vec_norm v) + (vec_norm v)\<^sup>2 = (vec_norm u + vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2

goal (1 subgoal):
 1. (vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(vec_norm (u + v))\<^sup>2 \<le> (vec_norm u + vec_norm v)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_integral_implies_lebesgue_measurable:
  fixes f :: "'a :: euclidean_space \<Rightarrow> 'b :: euclidean_space"
  assumes f: "(f has_integral I) \<Omega>"
  shows "(\<lambda>x. indicator \<Omega> x *\<^sub>R f x) \<in> lebesgue \<rightarrow>\<^sub>M borel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x) \<in> borel_measurable lebesgue
[PROOF STEP]
proof (intro borel_measurable_euclidean_space[where 'c='b, THEN iffD2] ballI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> Basis \<Longrightarrow> (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue
[PROOF STEP]
fix i :: "'b"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> Basis \<Longrightarrow> (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue
[PROOF STEP]
assume "i \<in> Basis"
[PROOF STATE]
proof (state)
this:
i \<in> Basis

goal (1 subgoal):
 1. \<And>i. i \<in> Basis \<Longrightarrow> (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue
[PROOF STEP]
have "(\<lambda>x. (f x \<bullet> i) * indicator \<Omega> x) \<in> borel_measurable (completion lborel)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x \<bullet> i * indicat_real \<Omega> x) \<in> borel_measurable lebesgue
[PROOF STEP]
using has_integral_linear[OF f bounded_linear_inner_left, of i]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>a. a \<bullet> i) \<circ> f has_integral I \<bullet> i) \<Omega>

goal (1 subgoal):
 1. (\<lambda>x. f x \<bullet> i * indicat_real \<Omega> x) \<in> borel_measurable lebesgue
[PROOF STEP]
by (intro has_integral_implies_lebesgue_measurable_real) (auto simp: comp_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x \<bullet> i * indicat_real \<Omega> x) \<in> borel_measurable lebesgue

goal (1 subgoal):
 1. \<And>i. i \<in> Basis \<Longrightarrow> (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. f x \<bullet> i * indicat_real \<Omega> x) \<in> borel_measurable lebesgue
[PROOF STEP]
show "(\<lambda>x. indicator \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable (completion lborel)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x \<bullet> i * indicat_real \<Omega> x) \<in> borel_measurable lebesgue

goal (1 subgoal):
 1. (\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. indicat_real \<Omega> x *\<^sub>R f x \<bullet> i) \<in> borel_measurable lebesgue

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem smallest_dist_unique:
  \<comment> \<open>Theorem 2.5 in @{cite conway2013course}\<close>
  fixes M::\<open>'a::complex_inner set\<close> and h
  assumes a1: \<open>convex M\<close>
  assumes \<open>is_arg_min (\<lambda> x. dist x h) (\<lambda> x. x \<in> M) r\<close>
  assumes \<open>is_arg_min (\<lambda> x. dist x h) (\<lambda> x. x \<in> M) s\<close>
  shows  \<open>r = s\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = s
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r = s
[PROOF STEP]
have *: "is_arg_min (\<lambda>x. dist x h) (\<lambda>x. x\<in>M) k \<longleftrightarrow> is_arg_min (\<lambda>x. norm x) (\<lambda>x. x\<in>(\<lambda>x. x-h) ` M) (k-h)" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_arg_min (\<lambda>x. dist x h) (\<lambda>x. x \<in> M) k = is_arg_min norm (\<lambda>x. x \<in> (\<lambda>x. x - h) ` M) (k - h)
[PROOF STEP]
unfolding dist_norm is_arg_min_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (k \<in> M \<and> (\<nexists>y. y \<in> M \<and> norm (y - h) < norm (k - h))) = (k - h \<in> (\<lambda>x. x - h) ` M \<and> (\<nexists>y. y \<in> (\<lambda>x. x - h) ` M \<and> norm y < norm (k - h)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_arg_min (\<lambda>x. dist x h) (\<lambda>x. x \<in> M) ?k = is_arg_min norm (\<lambda>x. x \<in> (\<lambda>x. x - h) ` M) (?k - h)

goal (1 subgoal):
 1. r = s
[PROOF STEP]
have \<open>r - h = s - h\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r - h = s - h
[PROOF STEP]
using _ assms(2,3)[unfolded *]
[PROOF STATE]
proof (prove)
using this:
PROP ?psi \<Longrightarrow> PROP ?psi
is_arg_min norm (\<lambda>x. x \<in> (\<lambda>x. x - h) ` M) (r - h)
is_arg_min norm (\<lambda>x. x \<in> (\<lambda>x. x - h) ` M) (s - h)

goal (1 subgoal):
 1. r - h = s - h
[PROOF STEP]
apply (rule smallest_norm_unique)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex ((\<lambda>x. x - h) ` M)
[PROOF STEP]
by (simp add: a1)
[PROOF STATE]
proof (state)
this:
r - h = s - h

goal (1 subgoal):
 1. r = s
[PROOF STEP]
thus \<open>r = s\<close>
[PROOF STATE]
proof (prove)
using this:
r - h = s - h

goal (1 subgoal):
 1. r = s
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r = s

goal:
No subgoals!
[PROOF STEP]
qed

\<comment> \<open>Theorem 2.6 in @{cite conway2013course}\<close>


[STATEMENT]
lemma infsetsum_nonneg: "(\<And>x. x \<in> A \<Longrightarrow> f x \<ge> (0::real)) \<Longrightarrow> infsetsum f A \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x) \<Longrightarrow> 0 \<le> infsetsum f A
[PROOF STEP]
unfolding infsetsum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x) \<Longrightarrow> 0 \<le> integral\<^sup>L (count_space A) f
[PROOF STEP]
by (rule Bochner_Integration.integral_nonneg) auto


[STATEMENT]
lemma frechet_derivative_divide: "frechet_derivative (\<lambda>x. f x / g x) (at x) =
    (\<lambda>h. frechet_derivative f (at x) h / (g x) -frechet_derivative g (at x) h * f x / (g x)\<^sup>2)"
  if "f differentiable at x" "g differentiable at x" "g x \<noteq> 0" for f::"_\<Rightarrow>_::real_normed_field"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frechet_derivative (\<lambda>x. f x / g x) (at x) = (\<lambda>h. frechet_derivative f (at x) h / g x - frechet_derivative g (at x) h * f x / (g x)\<^sup>2)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
f differentiable at x
g differentiable at x
g x \<noteq> (0::'d)

goal (1 subgoal):
 1. frechet_derivative (\<lambda>x. f x / g x) (at x) = (\<lambda>h. frechet_derivative f (at x) h / g x - frechet_derivative g (at x) h * f x / (g x)\<^sup>2)
[PROOF STEP]
by (auto simp: divide_inverse_commute bounded_bilinear.frechet_derivative[OF bounded_bilinear_mult]
      frechet_derivative_inverse)


[STATEMENT]
lemma general_digit_base:
  assumes "t1 > t2" and "b>1"
  shows "nth_digit (a * b^t1) t2 b = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
have 1: "b^t1 div b^t2 = b^(t1-t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b ^ t1 div b ^ t2 = b ^ (t1 - t2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
t2 < t1
1 < b

goal (1 subgoal):
 1. b ^ t1 div b ^ t2 = b ^ (t1 - t2)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t2 < t1; Suc 0 < b\<rbrakk> \<Longrightarrow> b ^ t1 div b ^ t2 = b ^ (t1 - t2)
[PROOF STEP]
by (metis Suc_lessD less_imp_le less_numeral_extra(3) power_diff)
[PROOF STATE]
proof (state)
this:
b ^ t1 div b ^ t2 = b ^ (t1 - t2)

goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
have "b^t2 dvd b^t1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b ^ t2 dvd b ^ t1
[PROOF STEP]
using `t1 > t2`
[PROOF STATE]
proof (prove)
using this:
t2 < t1

goal (1 subgoal):
 1. b ^ t2 dvd b ^ t1
[PROOF STEP]
by (simp add: le_imp_power_dvd)
[PROOF STATE]
proof (state)
this:
b ^ t2 dvd b ^ t1

goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
hence "(a * b^t1) div b^t2 = a * b^(t1-t2)"
[PROOF STATE]
proof (prove)
using this:
b ^ t2 dvd b ^ t1

goal (1 subgoal):
 1. a * b ^ t1 div b ^ t2 = a * b ^ (t1 - t2)
[PROOF STEP]
using div_mult_swap[of "b^t2" "b^t1" "a"] 1
[PROOF STATE]
proof (prove)
using this:
b ^ t2 dvd b ^ t1
b ^ t2 dvd b ^ t1 \<Longrightarrow> a * (b ^ t1 div b ^ t2) = a * b ^ t1 div b ^ t2
b ^ t1 div b ^ t2 = b ^ (t1 - t2)

goal (1 subgoal):
 1. a * b ^ t1 div b ^ t2 = a * b ^ (t1 - t2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a * b ^ t1 div b ^ t2 = a * b ^ (t1 - t2)

goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a * b ^ t1 div b ^ t2 = a * b ^ (t1 - t2)

goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
using nth_digit_def assms
[PROOF STATE]
proof (prove)
using this:
a * b ^ t1 div b ^ t2 = a * b ^ (t1 - t2)
nth_digit ?num ?k ?base = ?num div ?base ^ ?k mod ?base
t2 < t1
1 < b

goal (1 subgoal):
 1. nth_digit (a * b ^ t1) t2 b = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (a * b ^ t1) t2 b = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma satisfiableEquivalent:
  fixes formula1 :: Formula and formula2 :: Formula
  assumes "equivalentFormulae formula1 formula2"
  shows "satisfiable formula1 = satisfiable formula2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. satisfiable formula1 = satisfiable formula2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
equivalentFormulae formula1 formula2

goal (1 subgoal):
 1. satisfiable formula1 = satisfiable formula2
[PROOF STEP]
unfolding equivalentFormulae_def
[PROOF STATE]
proof (prove)
using this:
\<forall>valuation. model valuation formula1 = model valuation formula2

goal (1 subgoal):
 1. satisfiable formula1 = satisfiable formula2
[PROOF STEP]
unfolding satisfiable_def
[PROOF STATE]
proof (prove)
using this:
\<forall>valuation. model valuation formula1 = model valuation formula2

goal (1 subgoal):
 1. (\<exists>valuation. model valuation formula1) = (\<exists>valuation. model valuation formula2)
[PROOF STEP]
by auto


[STATEMENT]
lemma absdiff_norm_less:
  assumes "sum (\<lambda>x. norm (f x - g x)) S < e"
  shows "\<bar>sum (\<lambda>x. norm(f x)) S - sum (\<lambda>x. norm(g x)) S\<bar> < e" (is "?lhs < e")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
have "?lhs \<le> (\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> \<le> (\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>)
[PROOF STEP]
by (metis (no_types) sum_abs sum_subtractf)
[PROOF STATE]
proof (state)
this:
\<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> \<le> (\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>)

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> \<le> (\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>)

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
have "... \<le> (\<Sum>x\<in>S. norm (f x - g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>) \<le> (\<Sum>x\<in>S. norm (f x - g x))
[PROOF STEP]
by (simp add: norm_triangle_ineq3 sum_mono)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>) \<le> (\<Sum>x\<in>S. norm (f x - g x))

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>S. \<bar>norm (f i) - norm (g i)\<bar>) \<le> (\<Sum>x\<in>S. norm (f x - g x))

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
have "... < e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>S. norm (f x - g x)) < e
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>S. norm (f x - g x)) < e

goal (1 subgoal):
 1. (\<Sum>x\<in>S. norm (f x - g x)) < e
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>S. norm (f x - g x)) < e

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e

goal (1 subgoal):
 1. \<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<bar>(\<Sum>x\<in>S. norm (f x)) - (\<Sum>x\<in>S. norm (g x))\<bar> < e

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_splice:
  "(\<Sum>i::nat = 0..<2*n. f i) = (\<Sum>i = 0..<n. f (2*i)) + (\<Sum>i = 0..<n. f (2*i+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
have "(\<Sum>i::nat = 0..<2*n. f i) =
    sum f ((*) 2 ` {0..<n}) + sum f ((%i. 2*i+1) ` {0..<n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 * n} = sum f ((*) 2 ` {0..<n}) + sum f ((\<lambda>i. 2 * i + 1) ` {0..<n})
[PROOF STEP]
by (simp add: ivl_splice_Un ivl_splice_Int sum.union_disjoint)
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} = sum f ((*) 2 ` {0..<n}) + sum f ((\<lambda>i. 2 * i + 1) ` {0..<n})

goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} = sum f ((*) 2 ` {0..<n}) + sum f ((\<lambda>i. 2 * i + 1) ` {0..<n})

goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
have "... = (\<Sum>i = 0..<n. f (2*i)) + (\<Sum>i = 0..<n. f (2*i+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f ((*) 2 ` {0..<n}) + sum f ((\<lambda>i. 2 * i + 1) ` {0..<n}) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
by (simp add: sum.reindex [OF double_inj_on]
      sum.reindex [OF Suc_double_inj_on])
[PROOF STATE]
proof (state)
this:
sum f ((*) 2 ` {0..<n}) + sum f ((\<lambda>i. 2 * i + 1) ` {0..<n}) = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))

goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))

goal (1 subgoal):
 1. sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum f {0..<2 * n} = (\<Sum>i = 0..<n. f (2 * i)) + (\<Sum>i = 0..<n. f (2 * i + 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma decompress_compress_no_mod_plus_minus:
  assumes "x\<in>{0..\<lceil>q-(q/(2*2^d))\<rceil>-1}"
          "of_nat d < \<lceil>(log 2 q)::real\<rceil>"
          "d>0"
  shows "abs ((decompress d (compress d x) - x) mod+- q) \<le>
          round ( real_of_int q / real_of_int (2^(d+1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))
[PROOF STEP]
have "abs ((decompress d (compress d x) - x) mod+- q) =
        abs ((decompress d (compress d x) - x)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>
[PROOF STEP]
using no_mod_plus_minus[OF decompress_compress_no_mod
      [OF assms(1) assms(2)] assms(3)]
[PROOF STATE]
proof (prove)
using this:
\<bar>decompress d (compress d x) - x\<bar> = \<bar>(decompress d (compress d x) - x) mod+- q\<bar>

goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>

goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>

goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))
[PROOF STEP]
using decompress_compress_no_mod
    [OF assms(1) assms(2)]
[PROOF STATE]
proof (prove)
using this:
\<bar>(decompress d (compress d x) - x) mod+- q\<bar> = \<bar>decompress d (compress d x) - x\<bar>
\<bar>decompress d (compress d x) - x\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))

goal (1 subgoal):
 1. \<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>(decompress d (compress d x) - x) mod+- q\<bar> \<le> round (real_of_int q / real_of_int (2 ^ (d + 1)))

goal:
No subgoals!
[PROOF STEP]
qed