[STATEMENT]
lemma positive_trace:
  assumes "A \<in> carrier_mat n n" and "positive A"
  shows "trace A \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> trace A
[PROOF STEP]
using assms positive_iff_decomp trace_adjoint_positive
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
positive A
?A \<in> carrier_mat ?n ?n \<Longrightarrow> positive ?A = (\<exists>M\<in>carrier_mat ?n ?n. M * adjoint M = ?A)
0 \<le> trace (?A * adjoint ?A)

goal (1 subgoal):
 1. 0 \<le> trace A
[PROOF STEP]
by auto


[STATEMENT]
lemma finite_graph_partition_gt0:
  assumes "finite_graph_partition V P k" "finite V" "X \<in> P"
  shows "card X > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < card X
[PROOF STEP]
by (metis assms card_0_eq finite_graph_partition_def finite_graph_partition_finite gr_zeroI partition_on_def)


[STATEMENT]
lemma  cross_orthogonal_matrix:
  assumes "orthogonal_matrix A"
  shows "(A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v (x \<times> y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v x \<times> y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v x \<times> y)
[PROOF STEP]
have "mat 1 = transpose (A ** transpose A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat 1 = Finite_Cartesian_Product.transpose (A ** Finite_Cartesian_Product.transpose A)
[PROOF STEP]
by (metis (no_types) assms orthogonal_matrix_def transpose_mat)
[PROOF STATE]
proof (state)
this:
mat 1 = Finite_Cartesian_Product.transpose (A ** Finite_Cartesian_Product.transpose A)

goal (1 subgoal):
 1. (A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v x \<times> y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat 1 = Finite_Cartesian_Product.transpose (A ** Finite_Cartesian_Product.transpose A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat 1 = Finite_Cartesian_Product.transpose (A ** Finite_Cartesian_Product.transpose A)

goal (1 subgoal):
 1. (A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v x \<times> y)
[PROOF STEP]
by (metis (no_types) vector_matrix_mul_rid vector_transpose_matrix cross_matrix_mult matrix_vector_mul_assoc matrix_vector_mult_scaleR)
[PROOF STATE]
proof (state)
this:
(A *v x) \<times> (A *v y) = det A *\<^sub>R (A *v x \<times> y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_times_i:
  assumes "algebraic x"
  shows   "algebraic (\<i> * x)" "algebraic (-\<i> * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (\<i> * x) &&& algebraic (- \<i> * x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
algebraic x
[PROOF STEP]
obtain p where p: "poly p x = 0" "\<forall>i. coeff p i \<in> \<int>" "p \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
algebraic x

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>poly p x = 0; \<forall>i. coeff p i \<in> \<int>; p \<noteq> 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto elim!: algebraicE)
[PROOF STATE]
proof (state)
this:
poly p x = 0
\<forall>i. coeff p i \<in> \<int>
p \<noteq> 0

goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
define p' where "p' = pcompose p [:0, \<i>:] * pcompose p [:0, -\<i>:]"
[PROOF STATE]
proof (state)
this:
p' = p \<circ>\<^sub>p [:0, \<i>:] * p \<circ>\<^sub>p [:0, - \<i>:]

goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
have p': "poly p' (\<i> * x) = 0" "poly p' (-\<i> * x) = 0" "p' \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly p' (\<i> * x) = 0 &&& poly p' (- \<i> * x) = 0 &&& p' \<noteq> 0
[PROOF STEP]
by (auto simp: p'_def poly_pcompose algebra_simps p dest: pcompose_eq_0)
[PROOF STATE]
proof (state)
this:
poly p' (\<i> * x) = 0
poly p' (- \<i> * x) = 0
p' \<noteq> 0

goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
poly p' (\<i> * x) = 0
poly p' (- \<i> * x) = 0
p' \<noteq> 0

goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
have "\<forall>i. poly.coeff p' i \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. coeff p' i \<in> \<int>
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
poly p x = 0
\<forall>i. coeff p i \<in> \<int>
p \<noteq> 0

goal (1 subgoal):
 1. \<forall>i. coeff p' i \<in> \<int>
[PROOF STEP]
unfolding p'_def
[PROOF STATE]
proof (prove)
using this:
poly p x = 0
\<forall>i. coeff p i \<in> \<int>
p \<noteq> 0

goal (1 subgoal):
 1. \<forall>i. coeff (p \<circ>\<^sub>p [:0, \<i>:] * p \<circ>\<^sub>p [:0, - \<i>:]) i \<in> \<int>
[PROOF STEP]
by (intro allI pcompose_conjugates_integer) auto
[PROOF STATE]
proof (state)
this:
\<forall>i. coeff p' i \<in> \<int>

goal (2 subgoals):
 1. algebraic (\<i> * x)
 2. algebraic (- \<i> * x)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
poly p' (\<i> * x) = 0
poly p' (- \<i> * x) = 0
p' \<noteq> 0
\<forall>i. coeff p' i \<in> \<int>
[PROOF STEP]
show "algebraic (\<i> * x)" "algebraic (-\<i> * x)"
[PROOF STATE]
proof (prove)
using this:
poly p' (\<i> * x) = 0
poly p' (- \<i> * x) = 0
p' \<noteq> 0
\<forall>i. coeff p' i \<in> \<int>

goal (1 subgoal):
 1. algebraic (\<i> * x) &&& algebraic (- \<i> * x)
[PROOF STEP]
by (intro algebraicI[of p']; simp)+
[PROOF STATE]
proof (state)
this:
algebraic (\<i> * x)
algebraic (- \<i> * x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_integral_Icc_iff_Ioo:
  fixes f :: "real \<Rightarrow> 'a :: banach"
  shows "(f has_integral I) {a..b} \<longleftrightarrow> (f has_integral I) {a<..<b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_integral I) {a..b} = (f has_integral I) {a<..<b}
[PROOF STEP]
proof (rule has_integral_spike_set_eq)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. negligible {x \<in> {a..b} - {a<..<b}. f x \<noteq> (0::'a)}
 2. negligible {x \<in> {a<..<b} - {a..b}. f x \<noteq> (0::'a)}
[PROOF STEP]
show "negligible {x \<in> {a..b} - {a<..<b}. f x \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negligible {x \<in> {a..b} - {a<..<b}. f x \<noteq> (0::'a)}
[PROOF STEP]
by (rule negligible_subset [of "{a,b}"]) auto
[PROOF STATE]
proof (state)
this:
negligible {x \<in> {a..b} - {a<..<b}. f x \<noteq> (0::'a)}

goal (1 subgoal):
 1. negligible {x \<in> {a<..<b} - {a..b}. f x \<noteq> (0::'a)}
[PROOF STEP]
show "negligible {x \<in> {a<..<b} - {a..b}. f x \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negligible {x \<in> {a<..<b} - {a..b}. f x \<noteq> (0::'a)}
[PROOF STEP]
by (rule negligible_subset [of "{}"]) auto
[PROOF STATE]
proof (state)
this:
negligible {x \<in> {a<..<b} - {a..b}. f x \<noteq> (0::'a)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complex_Cauchy_convergent:
  fixes X :: "nat \<Rightarrow> complex"
  assumes X: "Cauchy X"
  shows "convergent X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent X
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Cauchy X

goal (1 subgoal):
 1. convergent X
[PROOF STEP]
by (rule Cauchy_convergent)


[STATEMENT]
lemma scalar_vec_plus_distrib_left:
  assumes wf1: "vec nr u"
  assumes wf2: "vec nr v"
  assumes wf3: "vec nr w"
  shows "scalar_prod (vec_plus u v) w = plus (scalar_prod u w) (scalar_prod v w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod (vec_plus u v) w = scalar_prod u w + scalar_prod v w
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
vec nr u
vec nr v
vec nr w

goal (1 subgoal):
 1. scalar_prod (vec_plus u v) w = scalar_prod u w + scalar_prod v w
[PROOF STEP]
unfolding vec_def scalar_prodI_def vec_plusI_def
[PROOF STATE]
proof (prove)
using this:
length u = nr
length v = nr
length w = nr

goal (1 subgoal):
 1. foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
proof (induct nr arbitrary: u v w)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n

goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n
[PROOF STEP]
obtain a uu where u: "u = a # uu"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n

goal (1 subgoal):
 1. (\<And>a uu. u = a # uu \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases u, auto)
[PROOF STATE]
proof (state)
this:
u = a # uu

goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n
[PROOF STEP]
obtain b vv where v: "v = b # vv"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n

goal (1 subgoal):
 1. (\<And>b vv. v = b # vv \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases v, auto)
[PROOF STATE]
proof (state)
this:
v = b # vv

goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
from Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n
[PROOF STEP]
obtain c ww where w: "w = c # ww"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n

goal (1 subgoal):
 1. (\<And>c ww. w = c # ww \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases w, auto)
[PROOF STATE]
proof (state)
this:
w = c # ww

goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
from Suc u v w
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n
u = a # uu
v = b # vv
w = c # ww
[PROOF STEP]
have lu: "length uu = n" and lv: "length vv = n" and lw: "length ww = n"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?u1 = n; length ?v1 = n; length ?w1 = n\<rbrakk> \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip ?u1 ?v1)) ?w1) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?u1 ?w1) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip ?v1 ?w1) (0::'a)
length u = Suc n
length v = Suc n
length w = Suc n
u = a # uu
v = b # vv
w = c # ww

goal (1 subgoal):
 1. length uu = n &&& length vv = n &&& length ww = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length uu = n
length vv = n
length ww = n

goal (2 subgoals):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
 2. \<And>nr u v w. \<lbrakk>\<And>u v w. \<lbrakk>length u = nr; length v = nr; length w = nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a); length u = Suc nr; length v = Suc nr; length w = Suc nr\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
by (simp only: u v w, simp, simp only: Suc(1)[OF lu lv lw], simp add: add.commute[of _ "times b c"] distrib_right add.assoc[symmetric])
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip v w) (0::'a)

goal (1 subgoal):
 1. \<And>u v w. \<lbrakk>length u = 0; length v = 0; length w = 0\<rbrakk> \<Longrightarrow> foldr (\<lambda>(x, y). (+) (x * y)) (zip (map (\<lambda>xy. fst xy + snd xy) (zip u v)) w) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip u w) (0::'a) + foldr (\<lambda>(x, y). (+) (x * y)) (zip v w) (0::'a)
[PROOF STEP]
qed simp


[STATEMENT]
lemma homotopy_eqv_trans [trans]:
  assumes 1: "X homotopy_equivalent_space Y" and 2: "Y homotopy_equivalent_space U"
    shows "X homotopy_equivalent_space U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
obtain f1 g1 where f1: "continuous_map X Y f1"
                 and g1: "continuous_map Y X g1"
                 and hom1: "homotopic_with (\<lambda>x. True) X X (g1 \<circ> f1) id"
                           "homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f1 g1. \<lbrakk>continuous_map X Y f1; continuous_map Y X g1; homotopic_with (\<lambda>x. True) X X (g1 \<circ> f1) id; homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
X homotopy_equivalent_space Y

goal (1 subgoal):
 1. (\<And>f1 g1. \<lbrakk>continuous_map X Y f1; continuous_map Y X g1; homotopic_with (\<lambda>x. True) X X (g1 \<circ> f1) id; homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: homotopy_equivalent_space_def)
[PROOF STATE]
proof (state)
this:
continuous_map X Y f1
continuous_map Y X g1
homotopic_with (\<lambda>x. True) X X (g1 \<circ> f1) id
homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
obtain f2 g2 where f2: "continuous_map Y U f2"
                 and g2: "continuous_map U Y g2"
                 and hom2: "homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id"
                           "homotopic_with (\<lambda>x. True) U U (f2 \<circ> g2) id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f2 g2. \<lbrakk>continuous_map Y U f2; continuous_map U Y g2; homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id; homotopic_with (\<lambda>x. True) U U (f2 \<circ> g2) id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
Y homotopy_equivalent_space U

goal (1 subgoal):
 1. (\<And>f2 g2. \<lbrakk>continuous_map Y U f2; continuous_map U Y g2; homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id; homotopic_with (\<lambda>x. True) U U (f2 \<circ> g2) id\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: homotopy_equivalent_space_def)
[PROOF STATE]
proof (state)
this:
continuous_map Y U f2
continuous_map U Y g2
homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id
homotopic_with (\<lambda>x. True) U U (f2 \<circ> g2) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
have "homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)
[PROOF STEP]
using f1 hom2(1) homotopic_with_compose_continuous_map_right
[PROOF STATE]
proof (prove)
using this:
continuous_map X Y f1
homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id
\<lbrakk>homotopic_with ?p ?X2.0 ?X3.0 ?f ?g; continuous_map ?X1.0 ?X2.0 ?h; \<And>j. ?p j \<Longrightarrow> ?q (j \<circ> ?h)\<rbrakk> \<Longrightarrow> homotopic_with ?q ?X1.0 ?X3.0 (?f \<circ> ?h) (?g \<circ> ?h)

goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)
[PROOF STEP]
have "homotopic_with (\<lambda>f. True) X Y (g2 \<circ> (f2 \<circ> f1)) (id \<circ> f1)"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> f2 \<circ> f1) (id \<circ> f1)

goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) X Y (g2 \<circ> (f2 \<circ> f1)) (id \<circ> f1)
[PROOF STEP]
by (simp add: o_assoc)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> (f2 \<circ> f1)) (id \<circ> f1)

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> (f2 \<circ> f1)) (id \<circ> f1)
[PROOF STEP]
have "homotopic_with (\<lambda>x. True) X X
         (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>f. True) X Y (g2 \<circ> (f2 \<circ> f1)) (id \<circ> f1)

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) X X (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))
[PROOF STEP]
by (simp add: g1 homotopic_with_compose_continuous_map_left)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
have "homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id
[PROOF STEP]
using hom1
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> f1) id
homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))
homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id
[PROOF STEP]
have SS: "homotopic_with (\<lambda>x. True) X X (g1 \<circ> g2 \<circ> (f2 \<circ> f1)) id"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> (g2 \<circ> (f2 \<circ> f1))) (g1 \<circ> (id \<circ> f1))
homotopic_with (\<lambda>x. True) X X (g1 \<circ> id \<circ> f1) id

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) X X (g1 \<circ> g2 \<circ> (f2 \<circ> f1)) id
[PROOF STEP]
by (metis comp_assoc homotopic_with_trans id_comp)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) X X (g1 \<circ> g2 \<circ> (f2 \<circ> f1)) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
have "homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)
[PROOF STEP]
using g2 hom1(2) homotopic_with_compose_continuous_map_right
[PROOF STATE]
proof (prove)
using this:
continuous_map U Y g2
homotopic_with (\<lambda>x. True) Y Y (f1 \<circ> g1) id
\<lbrakk>homotopic_with ?p ?X2.0 ?X3.0 ?f ?g; continuous_map ?X1.0 ?X2.0 ?h; \<And>j. ?p j \<Longrightarrow> ?q (j \<circ> ?h)\<rbrakk> \<Longrightarrow> homotopic_with ?q ?X1.0 ?X3.0 (?f \<circ> ?h) (?g \<circ> ?h)

goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)
[PROOF STEP]
have "homotopic_with (\<lambda>f. True) U Y (f1 \<circ> (g1 \<circ> g2)) (id \<circ> g2)"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> g1 \<circ> g2) (id \<circ> g2)

goal (1 subgoal):
 1. homotopic_with (\<lambda>f. True) U Y (f1 \<circ> (g1 \<circ> g2)) (id \<circ> g2)
[PROOF STEP]
by (simp add: o_assoc)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> (g1 \<circ> g2)) (id \<circ> g2)

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> (g1 \<circ> g2)) (id \<circ> g2)
[PROOF STEP]
have "homotopic_with (\<lambda>x. True) U U
         (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>f. True) U Y (f1 \<circ> (g1 \<circ> g2)) (id \<circ> g2)

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) U U (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))
[PROOF STEP]
by (simp add: f2 homotopic_with_compose_continuous_map_left)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
have "homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id
[PROOF STEP]
using hom2
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) Y Y (g2 \<circ> f2) id
homotopic_with (\<lambda>x. True) U U (f2 \<circ> g2) id

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))
homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id
[PROOF STEP]
have UU: "homotopic_with (\<lambda>x. True) U U (f2 \<circ> f1 \<circ> (g1 \<circ> g2)) id"
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> (f1 \<circ> (g1 \<circ> g2))) (f2 \<circ> (id \<circ> g2))
homotopic_with (\<lambda>x. True) U U (f2 \<circ> id \<circ> g2) id

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) U U (f2 \<circ> f1 \<circ> (g1 \<circ> g2)) id
[PROOF STEP]
by (simp add: fun.map_comp hom2(2) homotopic_with_trans)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) U U (f2 \<circ> f1 \<circ> (g1 \<circ> g2)) id

goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X homotopy_equivalent_space U
[PROOF STEP]
unfolding homotopy_equivalent_space_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f g. continuous_map X U f \<and> continuous_map U X g \<and> homotopic_with (\<lambda>x. True) X X (g \<circ> f) id \<and> homotopic_with (\<lambda>x. True) U U (f \<circ> g) id
[PROOF STEP]
by (blast intro: f1 f2 g1 g2 continuous_map_compose SS UU)
[PROOF STATE]
proof (state)
this:
X homotopy_equivalent_space U

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma quasi_isometry_betweenI:
  assumes "lambda C-quasi_isometry_on X f"
          "f`X \<subseteq> Y"
          "\<And>y. y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) y \<le> C"
  shows "lambda C-quasi_isometry_between X Y f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lambda C -quasi_isometry_between X Y f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry_on X f
f ` X \<subseteq> Y
?y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) ?y \<le> C

goal (1 subgoal):
 1. lambda C -quasi_isometry_between X Y f
[PROOF STEP]
unfolding quasi_isometry_between_def
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry_on X f
f ` X \<subseteq> Y
?y \<in> Y \<Longrightarrow> \<exists>x\<in>X. dist (f x) ?y \<le> C

goal (1 subgoal):
 1. lambda C -quasi_isometry_on X f \<and> f ` X \<subseteq> Y \<and> (\<forall>y\<in>Y. \<exists>x\<in>X. dist (f x) y \<le> C)
[PROOF STEP]
by auto


[STATEMENT]
lemma sin_angle_nonneg: "sin (angle a b c) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> sin (angle a b c)
[PROOF STEP]
using angle_bounds
[PROOF STATE]
proof (prove)
using this:
0 \<le> angle ?a ?b ?c
angle ?a ?b ?c \<le> pi

goal (1 subgoal):
 1. 0 \<le> sin (angle a b c)
[PROOF STEP]
by (rule sin_ge_zero)


[STATEMENT]
lemma vector_matrix_mult_code [code abstract]:
  "vec_nth (x v* A) = (%j. (\<Sum>i\<in>UNIV. A $ i $ j * x $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (x v* A) = (\<lambda>j. \<Sum>i\<in>UNIV. A $ i $ j * x $ i)
[PROOF STEP]
unfolding vector_matrix_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>j. \<Sum>i\<in>UNIV. A $ i $ j * x $ i) = (\<lambda>j. \<Sum>i\<in>UNIV. A $ i $ j * x $ i)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma prime_factorization_primepow:
  assumes "primepow n"
  shows   "prime_factorization n =
             replicate_mset (multiplicity (aprimedivisor n) n) (aprimedivisor n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime_factorization n = replicate_mset (multiplicity (aprimedivisor n) n) (aprimedivisor n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
primepow n

goal (1 subgoal):
 1. prime_factorization n = replicate_mset (multiplicity (aprimedivisor n) n) (aprimedivisor n)
[PROOF STEP]
by (auto simp: primepow_def aprimedivisor_prime_power prime_factorization_prime_power)


[STATEMENT]
lemma scalar_product_linear_left:
  "scalar_product (a+b) c =
   scalar_product a c + scalar_product b (c :: ('a qr, 'k) vec)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_product (a + b) c = scalar_product a c + scalar_product b c
[PROOF STEP]
unfolding scalar_product_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (a + b) $ i * c $ i) = (\<Sum>i\<in>UNIV. a $ i * c $ i) + (\<Sum>i\<in>UNIV. b $ i * c $ i)
[PROOF STEP]
by auto (metis (no_types, lifting) distrib_right sum.cong sum.distrib)


[STATEMENT]
lemma linorder_of_list_permute:
  assumes "\<pi> permutes {..<length xs}" "distinct xs"
  shows   "linorder_of_list (permute_list \<pi> xs) =
             map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)
[PROOF STEP]
note * = permutes_inv[OF assms(1)]
[PROOF STATE]
proof (state)
this:
inv \<pi> permutes {..<length xs}

goal (1 subgoal):
 1. linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)
[PROOF STEP]
have less: "inv \<pi> i < length xs" if "i < length xs" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv \<pi> i < length xs
[PROOF STEP]
using permutes_in_image[OF *] and that
[PROOF STATE]
proof (prove)
using this:
(inv \<pi> ?x \<in> {..<length xs}) = (?x \<in> {..<length xs})
i < length xs

goal (1 subgoal):
 1. inv \<pi> i < length xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?i < length xs \<Longrightarrow> inv \<pi> ?i < length xs

goal (1 subgoal):
 1. linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)
[PROOF STEP]
from assms and *
[PROOF STATE]
proof (chain)
picking this:
\<pi> permutes {..<length xs}
distinct xs
inv \<pi> permutes {..<length xs}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<pi> permutes {..<length xs}
distinct xs
inv \<pi> permutes {..<length xs}

goal (1 subgoal):
 1. linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)
[PROOF STEP]
by (auto simp: linorder_of_list_def map_relation_def index_nth_id index_permute_list less)
[PROOF STATE]
proof (state)
this:
linorder_of_list (permute_list \<pi> xs) = map_relation (set xs) ((!) xs \<circ> inv \<pi> \<circ> index xs) (linorder_of_list xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "min (i::int) j + max i j = i + j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. min i j + max i j = i + j
[PROOF STEP]
by linarith


[STATEMENT]
lemma odd_odd_even:
  fixes a b :: int
  assumes "odd a" "odd b"
  shows "even ((a*b-1) div 2) = even ((a-1) div 2 + (b-1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even ((a * b - 1) div 2) = even ((a - 1) div 2 + (b - 1) div 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
odd a
odd b

goal (1 subgoal):
 1. even ((a * b - 1) div 2) = even ((a - 1) div 2 + (b - 1) div 2)
[PROOF STEP]
by (auto elim!: oddE simp: algebra_simps)


[STATEMENT]
lemma rename_states_isomorphism_language :
  assumes "bij_betw f (states M) (f ` states M)"
  shows "L (rename_states M f) = L M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L (FSM.rename_states M f) = L M
[PROOF STEP]
using rename_states_isomorphism_language_state[OF assms fsm_initial]
[PROOF STATE]
proof (prove)
using this:
LS (FSM.rename_states M f) (f (FSM.initial M)) = L M

goal (1 subgoal):
 1. L (FSM.rename_states M f) = L M
[PROOF STEP]
unfolding rename_states_simps
[PROOF STATE]
proof (prove)
using this:
LS (FSM.rename_states M f) (f (FSM.initial M)) = L M

goal (1 subgoal):
 1. LS (FSM.rename_states M f) (f (FSM.initial M)) = L M
[PROOF STEP]
.


[STATEMENT]
lemma prime_dvd_primorial_iff: "prime p \<Longrightarrow> p dvd primorial x \<longleftrightarrow> p \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime p \<Longrightarrow> (p dvd primorial x) = (real p \<le> x)
[PROOF STEP]
using finite_primes_le[of x]
[PROOF STATE]
proof (prove)
using this:
finite {p. prime p \<and> real p \<le> x}

goal (1 subgoal):
 1. prime p \<Longrightarrow> (p dvd primorial x) = (real p \<le> x)
[PROOF STEP]
by (auto simp: primorial_def prime_dvd_prod_iff dest: primes_dvd_imp_eq)


[STATEMENT]
lemma bigtheta_const_ln_pow' [landau_simp]:
  "0 < a \<Longrightarrow> (\<lambda>x::real. ln (x * a) ^ p) \<in> \<Theta>(\<lambda>x. ln x ^ p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < a \<Longrightarrow> (\<lambda>x. ln (x * a) ^ p) \<in> \<Theta>(\<lambda>x. ln x ^ p)
[PROOF STEP]
by (subst mult.commute) (rule bigtheta_const_ln_pow)


[STATEMENT]
lemma M1_add_M0:
  "M1 + M0 = 1\<^sub>m K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M1 + M0 = 1\<^sub>m K
[PROOF STEP]
unfolding M0_def M1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat K K (\<lambda>(i, j). if i = j \<and> i < R then 1 else 0) + mat K K (\<lambda>(i, j). if i = j \<and> R \<le> i then 1 else 0) = 1\<^sub>m K
[PROOF STEP]
by auto


[STATEMENT]
lemma zero_less_Fract_iff: "0 < b \<Longrightarrow> 0 < Fract a b \<longleftrightarrow> 0 < a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < b \<Longrightarrow> (0 < Fract a b) = (0 < a)
[PROOF STEP]
by (simp add: Zero_rat_def zero_less_mult_iff)


[STATEMENT]
lemma sin_mono_less_eq:
  "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x < sin y \<longleftrightarrow> x < y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>- (pi / 2) \<le> x; x \<le> pi / 2; - (pi / 2) \<le> y; y \<le> pi / 2\<rbrakk> \<Longrightarrow> (sin x < sin y) = (x < y)
[PROOF STEP]
by (metis not_less_iff_gr_or_eq sin_monotone_2pi)


[STATEMENT]
lemma homeomorphic_locally_path_connected_space:
  assumes "X homeomorphic_space Y"
  shows "locally_path_connected_space X \<longleftrightarrow> locally_path_connected_space Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. locally_path_connected_space X = locally_path_connected_space Y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. locally_path_connected_space X = locally_path_connected_space Y
[PROOF STEP]
obtain f g where "homeomorphic_maps X Y f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f g. homeomorphic_maps X Y f g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms homeomorphic_space_def
[PROOF STATE]
proof (prove)
using this:
X homeomorphic_space Y
?X homeomorphic_space ?Y \<equiv> \<exists>f g. homeomorphic_maps ?X ?Y f g

goal (1 subgoal):
 1. (\<And>f g. homeomorphic_maps X Y f g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
homeomorphic_maps X Y f g

goal (1 subgoal):
 1. locally_path_connected_space X = locally_path_connected_space Y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homeomorphic_maps X Y f g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
homeomorphic_maps X Y f g

goal (1 subgoal):
 1. locally_path_connected_space X = locally_path_connected_space Y
[PROOF STEP]
by (metis (no_types) homeomorphic_map_def homeomorphic_maps_map locally_path_connected_space_quotient_map_image)
[PROOF STATE]
proof (state)
this:
locally_path_connected_space X = locally_path_connected_space Y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma foldr_same_int: "(\<And> x y. x \<in> set xs \<Longrightarrow> y \<in> set xs \<Longrightarrow> x = y) \<Longrightarrow>
                   (\<And> x . x \<in> set xs \<Longrightarrow> x = y) \<Longrightarrow>
                   foldr (+) xs 0 =  (length xs) * y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x y. \<lbrakk>x \<in> set xs; y \<in> set xs\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set xs \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) xs 0 = length xs * y
[PROOF STEP]
apply(induction xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<And>x y. \<lbrakk>x \<in> set []; y \<in> set []\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set [] \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) [] 0 = length [] * y
 2. \<And>a xs. \<lbrakk>\<lbrakk>\<And>x y. \<lbrakk>x \<in> set xs; y \<in> set xs\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set xs \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) xs 0 = length xs * y; \<And>x y. \<lbrakk>x \<in> set (a # xs); y \<in> set (a # xs)\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set (a # xs) \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) (a # xs) 0 = length (a # xs) * y
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>\<And>x y. \<lbrakk>x \<in> set xs; y \<in> set xs\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set xs \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) xs 0 = length xs * y; \<And>x y. \<lbrakk>x \<in> set (a # xs); y \<in> set (a # xs)\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set (a # xs) \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) (a # xs) 0 = length (a # xs) * y
[PROOF STEP]
apply(subst foldr.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>\<And>x y. \<lbrakk>x \<in> set xs; y \<in> set xs\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set xs \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> foldr (+) xs 0 = length xs * y; \<And>x y. \<lbrakk>x \<in> set (a # xs); y \<in> set (a # xs)\<rbrakk> \<Longrightarrow> x = y; \<And>x. x \<in> set (a # xs) \<Longrightarrow> x = y\<rbrakk> \<Longrightarrow> ((+) a \<circ> foldr (+) xs) 0 = length (a # xs) * y
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma filterlim_uminus_at_top: "(LIM x F. f x :> at_top) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_bot)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim f at_top F = (LIM x F. - f x :> at_bot)
[PROOF STEP]
using filterlim_compose[OF filterlim_uminus_at_bot_at_top, of f F]
    and filterlim_compose[OF filterlim_uminus_at_top_at_bot, of "\<lambda>x. - f x" F]
[PROOF STATE]
proof (prove)
using this:
filterlim f at_top F \<Longrightarrow> LIM x F. - f x :> at_bot
LIM x F. - f x :> at_bot \<Longrightarrow> LIM x F. - (- f x) :> at_top

goal (1 subgoal):
 1. filterlim f at_top F = (LIM x F. - f x :> at_bot)
[PROOF STEP]
by auto


[STATEMENT]
lemma homeomorphic_translation:
  fixes S :: "'a::real_normed_vector set"
  shows "S homeomorphic ((\<lambda>x. a + x) ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic (+) a ` S
[PROOF STEP]
unfolding homeomorphic_minimal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f g. (\<forall>x\<in>S. f x \<in> (+) a ` S \<and> g (f x) = x) \<and> (\<forall>y\<in>(+) a ` S. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on ((+) a ` S) g
[PROOF STEP]
apply (rule_tac x="\<lambda>x. a + x" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>g. (\<forall>x\<in>S. a + x \<in> (+) a ` S \<and> g (a + x) = x) \<and> (\<forall>y\<in>(+) a ` S. g y \<in> S \<and> a + g y = y) \<and> continuous_on S ((+) a) \<and> continuous_on ((+) a ` S) g
[PROOF STEP]
apply (rule_tac x="\<lambda>x. -a + x" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>S. a + x \<in> (+) a ` S \<and> - a + (a + x) = x) \<and> (\<forall>y\<in>(+) a ` S. - a + y \<in> S \<and> a + (- a + y) = y) \<and> continuous_on S ((+) a) \<and> continuous_on ((+) a ` S) ((+) (- a))
[PROOF STEP]
by (auto simp: continuous_intros)


[STATEMENT]
lemma Suci_mod_s_2:"\<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0\<rbrakk>
        \<Longrightarrow> (Suc i) mod s = Suc (i mod s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i mod s)
[PROOF STEP]
apply (insert div_mult_mod_eq [of "i" "s", THEN sym])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i mod s)
[PROOF STEP]
apply (subgoal_tac "Suc i = i div s * s + Suc (i mod s)")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i mod s)
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply (subgoal_tac "Suc i mod s  = (i div s * s + Suc (i mod s)) mod s")
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i mod s)
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 3. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply (subgoal_tac "Suc (i mod s) < s")
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s; Suc (i mod s) < s\<rbrakk> \<Longrightarrow> Suc i mod s = Suc (i mod s)
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s\<rbrakk> \<Longrightarrow> Suc (i mod s) < s
 3. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 4. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply (frule_tac m = s and a = "Suc i" and b = "i div s" and c = "Suc (i mod s)" in rfn_tool20, assumption+)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s\<rbrakk> \<Longrightarrow> Suc (i mod s) < s
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 3. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply (subgoal_tac "Suc (i mod s) < Suc (s - Suc 0)")
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s; Suc (i mod s) < Suc (s - Suc 0)\<rbrakk> \<Longrightarrow> Suc (i mod s) < s
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s\<rbrakk> \<Longrightarrow> Suc (i mod s) < Suc (s - Suc 0)
 3. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 4. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s); Suc i mod s = (i div s * s + Suc (i mod s)) mod s\<rbrakk> \<Longrightarrow> Suc (i mod s) < Suc (s - Suc 0)
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 3. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply (simp del:Suc_pred)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s; Suc i = i div s * s + Suc (i mod s)\<rbrakk> \<Longrightarrow> Suc i mod s = (i div s * s + Suc (i mod s)) mod s
 2. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i mod s < s - Suc 0; i = i div s * s + i mod s\<rbrakk> \<Longrightarrow> Suc i = i div s * s + Suc (i mod s)
[PROOF STEP]
apply simp+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nodes_height_lower_bound:
  "\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k
[PROOF STEP]
proof(induction t rule: nodes.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
case (2 ts t)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> bound k (height ?x) \<le> nodes ?x * k
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k
order k (Node ts t)
bal (Node ts t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
let ?sub_height = "((k + 1) ^ height t - 1)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "k*(?sub_height) \<le> (length ts)*(?sub_height)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * bound k (height t) \<le> length ts * bound k (height t)
[PROOF STEP]
using "2.prems"(1)
[PROOF STATE]
proof (prove)
using this:
order k (Node ts t)

goal (1 subgoal):
 1. k * bound k (height t) \<le> length ts * bound k (height t)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k * bound k (height t) \<le> length ts * bound k (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k * bound k (height t) \<le> length ts * bound k (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> = sum_list (replicate (length ts) ?sub_height)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ts * bound k (height t) = sum_list (replicate (length ts) (bound k (height t)))
[PROOF STEP]
using sum_list_replicate
[PROOF STATE]
proof (prove)
using this:
sum_list (replicate ?n ?c) = ?n * ?c

goal (1 subgoal):
 1. length ts * bound k (height t) = sum_list (replicate (length ts) (bound k (height t)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length ts * bound k (height t) = sum_list (replicate (length ts) (bound k (height t)))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
length ts * bound k (height t) = sum_list (replicate (length ts) (bound k (height t)))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> = sum_list (map (\<lambda>x.?sub_height) (subtrees ts))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (replicate (length ts) (bound k (height t))) = (\<Sum>x\<leftarrow>subtrees ts. bound k (height t))
[PROOF STEP]
using map_replicate_const[of ?sub_height "subtrees ts"] length_map
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. bound k (height t)) (subtrees ts) = replicate (length (subtrees ts)) (bound k (height t))
length (map ?f ?xs) = length ?xs

goal (1 subgoal):
 1. sum_list (replicate (length ts) (bound k (height t))) = (\<Sum>x\<leftarrow>subtrees ts. bound k (height t))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list (replicate (length ts) (bound k (height t))) = (\<Sum>x\<leftarrow>subtrees ts. bound k (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_list (replicate (length ts) (bound k (height t))) = (\<Sum>x\<leftarrow>subtrees ts. bound k (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> \<le> sum_list (map (\<lambda>t. nodes t * k) (subtrees ts))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>t\<leftarrow>subtrees ts. nodes t * k)
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> bound k (height ?x) \<le> nodes ?x * k
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k
order k (Node ts t)
bal (Node ts t)

goal (1 subgoal):
 1. (\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>t\<leftarrow>subtrees ts. nodes t * k)
[PROOF STEP]
using sum_list_mono[of "subtrees ts" "\<lambda>x. bound k (height t)" "\<lambda>t. nodes t * k"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> bound k (height ?x) \<le> nodes ?x * k
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k
order k (Node ts t)
bal (Node ts t)
(\<And>x. x \<in> set (subtrees ts) \<Longrightarrow> bound k (height t) \<le> nodes x * k) \<Longrightarrow> (\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>x\<leftarrow>subtrees ts. nodes x * k)

goal (1 subgoal):
 1. (\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>t\<leftarrow>subtrees ts. nodes t * k)
[PROOF STEP]
by (metis bal.simps(2) order.simps(2))
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>t\<leftarrow>subtrees ts. nodes t * k)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<leftarrow>subtrees ts. bound k (height t)) \<le> (\<Sum>t\<leftarrow>subtrees ts. nodes t * k)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> = sum_list (map nodes (subtrees ts)) * k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t\<leftarrow>subtrees ts. nodes t * k) = sum_list (map nodes (subtrees ts)) * k
[PROOF STEP]
using sum_list_mult_const[of nodes k "subtrees ts"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<leftarrow>subtrees ts. nodes x * k) = sum_list (map nodes (subtrees ts)) * k

goal (1 subgoal):
 1. (\<Sum>t\<leftarrow>subtrees ts. nodes t * k) = sum_list (map nodes (subtrees ts)) * k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>t\<leftarrow>subtrees ts. nodes t * k) = sum_list (map nodes (subtrees ts)) * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k * bound k (height t) \<le> sum_list (map nodes (subtrees ts)) * k
[PROOF STEP]
have "sum_list (map nodes (subtrees ts))*k \<ge> ?sub_height*k"
[PROOF STATE]
proof (prove)
using this:
k * bound k (height t) \<le> sum_list (map nodes (subtrees ts)) * k

goal (1 subgoal):
 1. bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "(nodes t)*k \<ge> ?sub_height"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bound k (height t) \<le> nodes t * k
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> bound k (height ?x) \<le> nodes ?x * k
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k
order k (Node ts t)
bal (Node ts t)

goal (1 subgoal):
 1. bound k (height t) \<le> nodes t * k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bound k (height t) \<le> nodes t * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k
bound k (height t) \<le> nodes t * k
[PROOF STEP]
have "(nodes (Node ts t))*k \<ge>
        k
        + ?sub_height * k
        + ?sub_height"
[PROOF STATE]
proof (prove)
using this:
bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k
bound k (height t) \<le> nodes t * k

goal (1 subgoal):
 1. k + bound k (height t) * k + bound k (height t) \<le> nodes (Node ts t) * k
[PROOF STEP]
unfolding nodes.simps add_mult_distrib
[PROOF STATE]
proof (prove)
using this:
bound k (height t) * k \<le> sum_list (map nodes (subtrees ts)) * k
bound k (height t) \<le> nodes t * k

goal (1 subgoal):
 1. k + bound k (height t) * k + bound k (height t) \<le> 1 * k + sum_list (map nodes (subtrees ts)) * k + nodes t * k
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
k + bound k (height t) * k + bound k (height t) \<le> nodes (Node ts t) * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k + bound k (height t) * k + bound k (height t) \<le> nodes (Node ts t) * k

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have
    "k + ?sub_height * k + ?sub_height =
     k + k*((k + 1) ^ height t) - k + (k + 1) ^ height t - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k + bound k (height t) * k + bound k (height t) = k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1
[PROOF STEP]
by (simp add: diff_mult_distrib2 mult.assoc mult.commute)
[PROOF STATE]
proof (state)
this:
k + bound k (height t) * k + bound k (height t) = k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k + bound k (height t) * k + bound k (height t) = k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> = k*((k + 1) ^ height t) + (k + 1) ^ height t - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1 = k * (k + 1) ^ height t + (k + 1) ^ height t - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1 = k * (k + 1) ^ height t + (k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k + k * (k + 1) ^ height t - k + (k + 1) ^ height t - 1 = k * (k + 1) ^ height t + (k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
have "\<dots> = (k+1)^(Suc(height t)) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * (k + 1) ^ height t + (k + 1) ^ height t - 1 = bound k (Suc (height t))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k * (k + 1) ^ height t + (k + 1) ^ height t - 1 = bound k (Suc (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> bound k (height x) \<le> nodes x * k; \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> bound k (height t) \<le> nodes t * k; order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
bound k (Suc (height t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
bound k (Suc (height t)) \<le> nodes (Node ts t) * k

goal (1 subgoal):
 1. bound k (height (Node ts t)) \<le> nodes (Node ts t) * k
[PROOF STEP]
by (metis "2.prems"(2) height_bal_tree)
[PROOF STATE]
proof (state)
this:
bound k (height (Node ts t)) \<le> nodes (Node ts t) * k

goal (1 subgoal):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> bound k (height Leaf) \<le> nodes Leaf * k
[PROOF STEP]
qed simp


[STATEMENT]
lemma distinct_sorted_list_lem2:
  assumes
  "sorted xs"
  "sorted ys"
  "distinct xs"
  "distinct ys"
  "e < e'"
  " \<forall> x \<in> set xs. x < e"
  " \<forall> y \<in> set ys. e' < y"
  shows
  "sorted (xs @ e # e' # ys)"
  "distinct (xs @ e # e' # ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (xs @ e # e' # ys) &&& distinct (xs @ e # e' # ys)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sorted (xs @ e # e' # ys)
 2. distinct (xs @ e # e' # ys)
[PROOF STEP]
have "sorted (e' # ys)"
    "distinct (e' # ys)"
    "\<forall> y \<in> set (e' # ys). e < y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (e' # ys) &&& distinct (e' # ys) &&& \<forall>y\<in>set (e' # ys). e < y
[PROOF STEP]
using assms(2,4,5,7)
[PROOF STATE]
proof (prove)
using this:
sorted ys
distinct ys
e < e'
\<forall>y\<in>set ys. e' < y

goal (1 subgoal):
 1. sorted (e' # ys) &&& distinct (e' # ys) &&& \<forall>y\<in>set (e' # ys). e < y
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
sorted (e' # ys)
distinct (e' # ys)
\<forall>y\<in>set (e' # ys). e < y

goal (2 subgoals):
 1. sorted (xs @ e # e' # ys)
 2. distinct (xs @ e # e' # ys)
[PROOF STEP]
thus "sorted (xs @ e # e' # ys)"
  "distinct (xs @ e # e' # ys)"
[PROOF STATE]
proof (prove)
using this:
sorted (e' # ys)
distinct (e' # ys)
\<forall>y\<in>set (e' # ys). e < y

goal (1 subgoal):
 1. sorted (xs @ e # e' # ys) &&& distinct (xs @ e # e' # ys)
[PROOF STEP]
using assms(1,3,6) distinct_sorted_list_lem1[of xs "e' # ys" e]
[PROOF STATE]
proof (prove)
using this:
sorted (e' # ys)
distinct (e' # ys)
\<forall>y\<in>set (e' # ys). e < y
sorted xs
distinct xs
\<forall>x\<in>set xs. x < e
\<lbrakk>sorted xs; sorted (e' # ys); distinct xs; distinct (e' # ys); \<forall>x\<in>set xs. x < e; \<forall>y\<in>set (e' # ys). e < y\<rbrakk> \<Longrightarrow> sorted (xs @ e # e' # ys)
\<lbrakk>sorted xs; sorted (e' # ys); distinct xs; distinct (e' # ys); \<forall>x\<in>set xs. x < e; \<forall>y\<in>set (e' # ys). e < y\<rbrakk> \<Longrightarrow> distinct (xs @ e # e' # ys)

goal (1 subgoal):
 1. sorted (xs @ e # e' # ys) &&& distinct (xs @ e # e' # ys)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sorted (xs @ e # e' # ys)
distinct (xs @ e # e' # ys)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_wrt_mergesort_by_rel:
  fixes R:: "'x \<Rightarrow> 'x \<Rightarrow> bool"
  assumes lin : "\<And>x y. (R x y) \<or> (R y x)"
      and trans_R: "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
  shows "sorted_wrt R (mergesort_by_rel R xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
proof (induct xs rule: measure_induct_rule[of "length"])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (mergesort_by_rel R y)) \<Longrightarrow> sorted_wrt R (mergesort_by_rel R x)
[PROOF STEP]
case (less xs)
[PROOF STATE]
proof (state)
this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (mergesort_by_rel R ?y)

goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (mergesort_by_rel R y)) \<Longrightarrow> sorted_wrt R (mergesort_by_rel R x)
[PROOF STEP]
note ind_hyp = this
[PROOF STATE]
proof (state)
this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (mergesort_by_rel R ?y)

goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (mergesort_by_rel R y)) \<Longrightarrow> sorted_wrt R (mergesort_by_rel R x)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
proof (cases xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. xs = [] \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
 2. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
xs = []

goal (2 subgoals):
 1. xs = [] \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
 2. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
xs = []

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel R xs)

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
case (Cons x xs')
[PROOF STATE]
proof (state)
this:
xs = x # xs'

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
note xs_eq[simp] = this
[PROOF STATE]
proof (state)
this:
xs = x # xs'

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
xs = x # xs'

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
proof (cases xs')
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>xs = x # xs'; xs' = []\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
 2. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
xs' = []

goal (2 subgoals):
 1. \<lbrakk>xs = x # xs'; xs' = []\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
 2. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
xs' = []

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel R xs)

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
case (Cons x2 xs'')
[PROOF STATE]
proof (state)
this:
xs' = x2 # xs''

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
note xs'_eq[simp] = this
[PROOF STATE]
proof (state)
this:
xs' = x2 # xs''

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
have "length (fst (mergesort_by_rel_split ([], []) xs)) < length xs"
           "length (snd (mergesort_by_rel_split ([], []) xs)) < length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (fst (mergesort_by_rel_split ([], []) xs)) < length xs &&& length (snd (mergesort_by_rel_split ([], []) xs)) < length xs
[PROOF STEP]
by (simp_all add: mergesort_by_rel_split_length)
[PROOF STATE]
proof (state)
this:
length (fst (mergesort_by_rel_split ([], []) xs)) < length xs
length (snd (mergesort_by_rel_split ([], []) xs)) < length xs

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>xs = x # xs'; xs' = a # list\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
with ind_hyp
[PROOF STATE]
proof (chain)
picking this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (mergesort_by_rel R ?y)
length (fst (mergesort_by_rel_split ([], []) xs)) < length xs
length (snd (mergesort_by_rel_split ([], []) xs)) < length xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (mergesort_by_rel R ?y)
length (fst (mergesort_by_rel_split ([], []) xs)) < length xs
length (snd (mergesort_by_rel_split ([], []) xs)) < length xs

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel R xs)
[PROOF STEP]
unfolding mergesort_by_rel.simps[of _ xs]
[PROOF STATE]
proof (prove)
using this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (mergesort_by_rel R ?y)
length (fst (mergesort_by_rel_split ([], []) xs)) < length xs
length (snd (mergesort_by_rel_split ([], []) xs)) < length xs

goal (1 subgoal):
 1. sorted_wrt R (if length xs < 2 then xs else mergesort_by_rel_merge R (mergesort_by_rel R (fst (mergesort_by_rel_split ([], []) xs))) (mergesort_by_rel R (snd (mergesort_by_rel_split ([], []) xs))))
[PROOF STEP]
by (simp add: sorted_wrt_mergesort_by_rel_merge[OF lin trans_R])
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel R xs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel R xs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel R xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma to_int_mod_ring_range:
  "range (to_int_mod_ring :: 'a mod_ring \<Rightarrow> int) = {0 ..< q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range to_int_mod_ring = {0..<q}
[PROOF STEP]
using CARD_a
[PROOF STATE]
proof (prove)
using this:
int CARD('a) = q

goal (1 subgoal):
 1. range to_int_mod_ring = {0..<q}
[PROOF STEP]
by (simp add: range_to_int_mod_ring)


[STATEMENT]
lemma "dmin a b = dmin b a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dmin a b = dmin b a
[PROOF STEP]
proof (cases "a \<prec> b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<prec> b \<Longrightarrow> dmin a b = dmin b a
 2. \<not> a \<prec> b \<Longrightarrow> dmin a b = dmin b a
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a \<prec> b

goal (2 subgoals):
 1. a \<prec> b \<Longrightarrow> dmin a b = dmin b a
 2. \<not> a \<prec> b \<Longrightarrow> dmin a b = dmin b a
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<prec> b

goal (1 subgoal):
 1. dmin a b = dmin b a
[PROOF STEP]
by (simp add: dbm_lt_asym)
[PROOF STATE]
proof (state)
this:
dmin a b = dmin b a

goal (1 subgoal):
 1. \<not> a \<prec> b \<Longrightarrow> dmin a b = dmin b a
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a \<prec> b \<Longrightarrow> dmin a b = dmin b a
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> a \<prec> b

goal (1 subgoal):
 1. \<not> a \<prec> b \<Longrightarrow> dmin a b = dmin b a
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> a \<prec> b

goal (1 subgoal):
 1. dmin a b = dmin b a
[PROOF STEP]
by (simp add: dbm_not_lt_eq)
[PROOF STATE]
proof (state)
this:
dmin a b = dmin b a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma simple_closed_path_norm_winding_number_inside:
  assumes "simple_path \<gamma>" "z \<in> inside(path_image \<gamma>)"
  shows "norm (winding_number \<gamma> z) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (winding_number \<gamma> z) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cmod (winding_number \<gamma> z) = 1
[PROOF STEP]
have "pathfinish \<gamma> = pathstart \<gamma>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pathfinish \<gamma> = pathstart \<gamma>
[PROOF STEP]
using assms inside_simple_curve_imp_closed
[PROOF STATE]
proof (prove)
using this:
simple_path \<gamma>
z \<in> inside (path_image \<gamma>)
\<lbrakk>simple_path ?\<gamma>; ?x \<in> inside (path_image ?\<gamma>)\<rbrakk> \<Longrightarrow> pathfinish ?\<gamma> = pathstart ?\<gamma>

goal (1 subgoal):
 1. pathfinish \<gamma> = pathstart \<gamma>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
pathfinish \<gamma> = pathstart \<gamma>

goal (1 subgoal):
 1. cmod (winding_number \<gamma> z) = 1
[PROOF STEP]
with assms integer_winding_number
[PROOF STATE]
proof (chain)
picking this:
simple_path \<gamma>
z \<in> inside (path_image \<gamma>)
\<lbrakk>path ?\<gamma>; pathfinish ?\<gamma> = pathstart ?\<gamma>; ?z \<notin> path_image ?\<gamma>\<rbrakk> \<Longrightarrow> winding_number ?\<gamma> ?z \<in> \<int>
pathfinish \<gamma> = pathstart \<gamma>
[PROOF STEP]
have "winding_number \<gamma> z \<in> \<int>"
[PROOF STATE]
proof (prove)
using this:
simple_path \<gamma>
z \<in> inside (path_image \<gamma>)
\<lbrakk>path ?\<gamma>; pathfinish ?\<gamma> = pathstart ?\<gamma>; ?z \<notin> path_image ?\<gamma>\<rbrakk> \<Longrightarrow> winding_number ?\<gamma> ?z \<in> \<int>
pathfinish \<gamma> = pathstart \<gamma>

goal (1 subgoal):
 1. winding_number \<gamma> z \<in> \<int>
[PROOF STEP]
by (simp add: inside_def simple_path_def)
[PROOF STATE]
proof (state)
this:
winding_number \<gamma> z \<in> \<int>

goal (1 subgoal):
 1. cmod (winding_number \<gamma> z) = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
winding_number \<gamma> z \<in> \<int>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
winding_number \<gamma> z \<in> \<int>

goal (1 subgoal):
 1. cmod (winding_number \<gamma> z) = 1
[PROOF STEP]
by (metis assms norm_minus_cancel norm_one simple_closed_path_winding_number_inside)
[PROOF STATE]
proof (state)
this:
cmod (winding_number \<gamma> z) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal_columns_fst_QR_decomposition:
  assumes i_not_ia: "(column i (fst (QR_decomposition A))) \<noteq> (column ia (fst (QR_decomposition A)))"
  shows "(column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A))) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
have i: "column i (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<in> {column i (fst (QR_decomposition A)) |i. i \<in> UNIV}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
column i (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))

goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
have ia: "column ia (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column ia (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column ia (fst (QR_decomposition A)) \<in> {column i (fst (QR_decomposition A)) |i. i \<in> UNIV}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
column ia (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))

goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
using orthogonal_fst_QR_decomposition[of A] i ia i_not_ia
[PROOF STATE]
proof (prove)
using this:
pairwise orthogonal (columns (fst (QR_decomposition A)))
column i (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
column ia (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
column i (fst (QR_decomposition A)) \<noteq> column ia (fst (QR_decomposition A))

goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
unfolding pairwise_def orthogonal_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>columns (fst (QR_decomposition A)). \<forall>y\<in>columns (fst (QR_decomposition A)). x \<noteq> y \<longrightarrow> x \<bullet> y = 0
column i (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
column ia (fst (QR_decomposition A)) \<in> columns (fst (QR_decomposition A))
column i (fst (QR_decomposition A)) \<noteq> column ia (fst (QR_decomposition A))

goal (1 subgoal):
 1. column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
column i (fst (QR_decomposition A)) \<bullet> column ia (fst (QR_decomposition A)) = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mul_and_mul_eq_imp_mul: assumes "trans r" and "(M,N) \<in> mul r" and "(N,P) \<in> mul_eq r" shows "(M,P) \<in> mul r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M, P) \<in> mul r
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
trans r
(M, N) \<in> mul r
(N, P) \<in> mul_eq r

goal (1 subgoal):
 1. (M, P) \<in> mul r
[PROOF STEP]
unfolding mult_is_mul[symmetric,OF assms(1)] mult_eq_is_mul_eq[symmetric,OF assms(1)] mult_def mult_eq_def
[PROOF STATE]
proof (prove)
using this:
trans r
(M, N) \<in> (mult1 r)\<^sup>+
(N, P) \<in> (mult1 r)\<^sup>*

goal (1 subgoal):
 1. (M, P) \<in> (mult1 r)\<^sup>+
[PROOF STEP]
by auto


[STATEMENT]
lemma bounded_dist_le_SUP_dist:
  "bounded (range f) \<Longrightarrow> bounded (range g) \<Longrightarrow> dist (f x) (g x) \<le> (SUP x. dist (f x) (g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>bounded (range f); bounded (range g)\<rbrakk> \<Longrightarrow> dist (f x) (g x) \<le> (SUP x. dist (f x) (g x))
[PROOF STEP]
by (auto intro!: cSUP_upper bounded_imp_bdd_above bounded_dist_comp)


[STATEMENT]
lemma take_bit_add:
  "take_bit n (take_bit n a + take_bit n b) = take_bit n (a + b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_bit n (take_bit n a + take_bit n b) = take_bit n (a + b)
[PROOF STEP]
by (simp add: take_bit_eq_mod mod_simps)


[STATEMENT]
lemma interior_convex_hull_explicit_minimal:
  fixes S :: "'a::euclidean_space set"
  assumes "\<not> affine_dependent S"
  shows
   "interior(convex hull S) =
             (if card(S) \<le> DIM('a) then {}
              else {y. \<exists>u. (\<forall>x \<in> S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y})"
   (is "_ = (if _ then _ else ?rhs)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interior (convex hull S) = (if card S \<le> DIM('a) then {} else {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y})
[PROOF STEP]
proof (clarsimp simp: aff_independent_finite empty_interior_convex_hull assms)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> card S \<le> DIM('a) \<Longrightarrow> interior (convex hull S) = {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y}
[PROOF STEP]
assume S: "\<not> card S \<le> DIM('a)"
[PROOF STATE]
proof (state)
this:
\<not> card S \<le> DIM('a)

goal (1 subgoal):
 1. \<not> card S \<le> DIM('a) \<Longrightarrow> interior (convex hull S) = {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y}
[PROOF STEP]
have "interior (convex hull S) = rel_interior(convex hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interior (convex hull S) = rel_interior (convex hull S)
[PROOF STEP]
using assms S
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent S
\<not> card S \<le> DIM('a)

goal (1 subgoal):
 1. interior (convex hull S) = rel_interior (convex hull S)
[PROOF STEP]
by (simp add: affine_independent_span_gt rel_interior_interior)
[PROOF STATE]
proof (state)
this:
interior (convex hull S) = rel_interior (convex hull S)

goal (1 subgoal):
 1. \<not> card S \<le> DIM('a) \<Longrightarrow> interior (convex hull S) = {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior (convex hull S) = rel_interior (convex hull S)
[PROOF STEP]
show "interior(convex hull S) = ?rhs"
[PROOF STATE]
proof (prove)
using this:
interior (convex hull S) = rel_interior (convex hull S)

goal (1 subgoal):
 1. interior (convex hull S) = {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y}
[PROOF STEP]
by (simp add: assms S rel_interior_convex_hull_explicit)
[PROOF STATE]
proof (state)
this:
interior (convex hull S) = {y. \<exists>u. (\<forall>x\<in>S. 0 < u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = y}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma echelon_form_condition2_explicit:
  assumes rref_A: "echelon_form A"
  and i_le: "i < j"
  and "\<not> is_zero_row i A" and "\<not> is_zero_row j A"
  shows "(LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ j $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a))
[PROOF STEP]
using echelon_form_condition2 assms
[PROOF STATE]
proof (prove)
using this:
echelon_form ?A \<Longrightarrow> \<forall>i. i < ?j \<and> \<not> is_zero_row i ?A \<and> \<not> is_zero_row ?j ?A \<longrightarrow> (LEAST n. ?A $ i $ n \<noteq> (0::?'a)) < (LEAST n. ?A $ ?j $ n \<noteq> (0::?'a))
echelon_form A
i < j
\<not> is_zero_row i A
\<not> is_zero_row j A

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a))
[PROOF STEP]
by blast


[STATEMENT]
lemma cnorm_le_square: "norm x \<le> a \<longleftrightarrow> 0 \<le> a \<and> cinner x x \<le> complex_of_real (a\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm x \<le> a) = (0 \<le> a \<and> cinner x x \<le> complex_of_real (a\<^sup>2))
[PROOF STEP]
by (smt (verit) cdot_square_norm complex_of_real_mono_iff norm_ge_zero power2_le_imp_le)


[STATEMENT]
lemma iso_group_mul_eq:
    "(\<lambda>(x,y). x \<otimes> y) \<in> iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G
     \<longleftrightarrow> A \<inter> B = {\<one>} \<and> A <#> B = carrier G \<and> A \<lhd> G \<and> B \<lhd> G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>(x, y). x \<otimes> y) \<in> Group.iso (subgroup_generated G A \<times>\<times> subgroup_generated G B) G) = (A \<inter> B = {\<one>} \<and> A <#> B = carrier G \<and> A \<lhd> G \<and> B \<lhd> G)
[PROOF STEP]
by (simp add: iso_group_mul_alt normal_eq_commuting cong: conj_cong)


[STATEMENT]
lemma square_less:
  fixes a n:: real
  assumes "a < n" and "a > -n"
  shows "a\<^sup>2 < n\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a\<^sup>2 < n\<^sup>2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a < n
- n < a

goal (1 subgoal):
 1. a\<^sup>2 < n\<^sup>2
[PROOF STEP]
by (smt power2_eq_iff power2_minus power_less_imp_less_base)


[STATEMENT]
lemma (in group) ord_FactGroup:
  assumes "subgroup P G" "group (G Mod P)"
  shows "order (G Mod P) * card P = order G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order (G Mod P) * card P = order G
[PROOF STEP]
using lagrange[of P] FactGroup_def[of G P] assms order_def[of "(G Mod P)"]
[PROOF STATE]
proof (prove)
using this:
subgroup P G \<Longrightarrow> card (rcosets P) * card P = order G
G Mod P = \<lparr>carrier = rcosets P, mult = (<#>), one = P\<rparr>
subgroup P G
Group.group (G Mod P)
order (G Mod P) = card (carrier (G Mod P))

goal (1 subgoal):
 1. order (G Mod P) * card P = order G
[PROOF STEP]
by fastforce


[STATEMENT]
lemma integral_component_ubound_real:
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
  assumes "f integrable_on {a..b}"
    and "\<forall>x\<in>{a..b}. f x\<bullet>k \<le> B"
    and "k \<in> Basis"
  shows "(integral {a..b} f)\<bullet>k \<le> B * content {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {a..b} f \<bullet> k \<le> B * content {a..b}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f integrable_on {a..b}
\<forall>x\<in>{a..b}. f x \<bullet> k \<le> B
k \<in> Basis

goal (1 subgoal):
 1. integral {a..b} f \<bullet> k \<le> B * content {a..b}
[PROOF STEP]
by (metis box_real(2) integral_component_ubound)