[STATEMENT]
theorem m_red_to_comp: "\<lbrakk> many_reducible_to A B; computable B \<rbrakk> \<Longrightarrow> computable A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
assume "many_reducible_to A B"
[PROOF STATE]
proof (state)
this:
many_reducible_to A B

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
many_reducible_to A B
[PROOF STEP]
obtain f where A1: "many_reducible_to_via A B f"
[PROOF STATE]
proof (prove)
using this:
many_reducible_to A B

goal (1 subgoal):
 1. (\<And>f. many_reducible_to_via A B f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding many_reducible_to_def
[PROOF STATE]
proof (prove)
using this:
Ex (many_reducible_to_via A B)

goal (1 subgoal):
 1. (\<And>f. many_reducible_to_via A B f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
many_reducible_to_via A B f

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
from A1
[PROOF STATE]
proof (chain)
picking this:
many_reducible_to_via A B f
[PROOF STEP]
have f_tr: "total_recursive f"
[PROOF STATE]
proof (prove)
using this:
many_reducible_to_via A B f

goal (1 subgoal):
 1. total_recursive f
[PROOF STEP]
by (unfold many_reducible_to_via_def, auto)
[PROOF STATE]
proof (state)
this:
total_recursive f

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
from A1
[PROOF STATE]
proof (chain)
picking this:
many_reducible_to_via A B f
[PROOF STEP]
have L1: "\<forall> x. (x \<in> A) = (f x \<in> B)"
[PROOF STATE]
proof (prove)
using this:
many_reducible_to_via A B f

goal (1 subgoal):
 1. \<forall>x. (x \<in> A) = (f x \<in> B)
[PROOF STEP]
by (unfold many_reducible_to_via_def, auto)
[PROOF STATE]
proof (state)
this:
\<forall>x. (x \<in> A) = (f x \<in> B)

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
assume "computable B"
[PROOF STATE]
proof (state)
this:
computable B

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
computable B
[PROOF STEP]
have L2: "total_recursive (chf B)"
[PROOF STATE]
proof (prove)
using this:
computable B

goal (1 subgoal):
 1. total_recursive (chf B)
[PROOF STEP]
by (rule comp_impl_tot_rec)
[PROOF STATE]
proof (state)
this:
total_recursive (chf B)

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
have L3: "chf A = (chf B) o f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chf A = chf B \<circ> f
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. chf A x = (chf B \<circ> f) x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. chf A x = (chf B \<circ> f) x
[PROOF STEP]
have "chf A x = (chf B) (f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. chf A x = chf B (f x)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> chf A x = chf B (f x)
 2. \<not> ?P \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
assume A: "x \<in> A"
[PROOF STATE]
proof (state)
this:
x \<in> A

goal (2 subgoals):
 1. ?P \<Longrightarrow> chf A x = chf B (f x)
 2. \<not> ?P \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> A
[PROOF STEP]
have L3_1: "chf A x = 0"
[PROOF STATE]
proof (prove)
using this:
x \<in> A

goal (1 subgoal):
 1. chf A x = 0
[PROOF STEP]
by (simp add: chf_lm_2)
[PROOF STATE]
proof (state)
this:
chf A x = 0

goal (2 subgoals):
 1. ?P \<Longrightarrow> chf A x = chf B (f x)
 2. \<not> ?P \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
from A L1
[PROOF STATE]
proof (chain)
picking this:
x \<in> A
\<forall>x. (x \<in> A) = (f x \<in> B)
[PROOF STEP]
have "f x \<in> B"
[PROOF STATE]
proof (prove)
using this:
x \<in> A
\<forall>x. (x \<in> A) = (f x \<in> B)

goal (1 subgoal):
 1. f x \<in> B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f x \<in> B

goal (2 subgoals):
 1. ?P \<Longrightarrow> chf A x = chf B (f x)
 2. \<not> ?P \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x \<in> B
[PROOF STEP]
have L3_2: "(chf B) (f x) = 0"
[PROOF STATE]
proof (prove)
using this:
f x \<in> B

goal (1 subgoal):
 1. chf B (f x) = 0
[PROOF STEP]
by (simp add: chf_lm_2)
[PROOF STATE]
proof (state)
this:
chf B (f x) = 0

goal (2 subgoals):
 1. ?P \<Longrightarrow> chf A x = chf B (f x)
 2. \<not> ?P \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
from L3_1 L3_2
[PROOF STATE]
proof (chain)
picking this:
chf A x = 0
chf B (f x) = 0
[PROOF STEP]
show "chf A x = (chf B) (f x)"
[PROOF STATE]
proof (prove)
using this:
chf A x = 0
chf B (f x) = 0

goal (1 subgoal):
 1. chf A x = chf B (f x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
chf A x = chf B (f x)

goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
assume A: "x \<notin> A"
[PROOF STATE]
proof (state)
this:
x \<notin> A

goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<notin> A
[PROOF STEP]
have L3_1: "chf A x = 1"
[PROOF STATE]
proof (prove)
using this:
x \<notin> A

goal (1 subgoal):
 1. chf A x = 1
[PROOF STEP]
by (simp add: chf_lm_3)
[PROOF STATE]
proof (state)
this:
chf A x = 1

goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
from A L1
[PROOF STATE]
proof (chain)
picking this:
x \<notin> A
\<forall>x. (x \<in> A) = (f x \<in> B)
[PROOF STEP]
have "f x \<notin> B"
[PROOF STATE]
proof (prove)
using this:
x \<notin> A
\<forall>x. (x \<in> A) = (f x \<in> B)

goal (1 subgoal):
 1. f x \<notin> B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f x \<notin> B

goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x \<notin> B
[PROOF STEP]
have L3_2: "(chf B) (f x) = 1"
[PROOF STATE]
proof (prove)
using this:
f x \<notin> B

goal (1 subgoal):
 1. chf B (f x) = 1
[PROOF STEP]
by (simp add: chf_lm_3)
[PROOF STATE]
proof (state)
this:
chf B (f x) = 1

goal (1 subgoal):
 1. x \<notin> A \<Longrightarrow> chf A x = chf B (f x)
[PROOF STEP]
from L3_1 L3_2
[PROOF STATE]
proof (chain)
picking this:
chf A x = 1
chf B (f x) = 1
[PROOF STEP]
show "chf A x = (chf B) (f x)"
[PROOF STATE]
proof (prove)
using this:
chf A x = 1
chf B (f x) = 1

goal (1 subgoal):
 1. chf A x = chf B (f x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
chf A x = chf B (f x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
chf A x = chf B (f x)

goal (1 subgoal):
 1. \<And>x. chf A x = (chf B \<circ> f) x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
chf A x = chf B (f x)
[PROOF STEP]
show "chf A x = (chf B \<circ> f) x"
[PROOF STATE]
proof (prove)
using this:
chf A x = chf B (f x)

goal (1 subgoal):
 1. chf A x = (chf B \<circ> f) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
chf A x = (chf B \<circ> f) x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
chf A = chf B \<circ> f

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
from L2 f_tr
[PROOF STATE]
proof (chain)
picking this:
total_recursive (chf B)
total_recursive f
[PROOF STEP]
have "total_recursive (chf B \<circ> f)"
[PROOF STATE]
proof (prove)
using this:
total_recursive (chf B)
total_recursive f

goal (1 subgoal):
 1. total_recursive (chf B \<circ> f)
[PROOF STEP]
by (rule comp_tot_rec)
[PROOF STATE]
proof (state)
this:
total_recursive (chf B \<circ> f)

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
with L3
[PROOF STATE]
proof (chain)
picking this:
chf A = chf B \<circ> f
total_recursive (chf B \<circ> f)
[PROOF STEP]
have "total_recursive (chf A)"
[PROOF STATE]
proof (prove)
using this:
chf A = chf B \<circ> f
total_recursive (chf B \<circ> f)

goal (1 subgoal):
 1. total_recursive (chf A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
total_recursive (chf A)

goal (1 subgoal):
 1. \<lbrakk>many_reducible_to A B; computable B\<rbrakk> \<Longrightarrow> computable A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
total_recursive (chf A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
total_recursive (chf A)

goal (1 subgoal):
 1. computable A
[PROOF STEP]
by (rule tot_rec_impl_comp)
[PROOF STATE]
proof (state)
this:
computable A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma DERIV_isconst2:
  fixes f :: "real \<Rightarrow> real"
  assumes "a < b" and contf: "continuous_on {a..b} f" and derf: "\<And>x. \<lbrakk>a < x; x < b\<rbrakk> \<Longrightarrow> DERIV f x :> 0"
    and "a \<le> x" "x \<le> b"
shows "f x = f a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x = f a
[PROOF STEP]
proof (cases "a < x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a < x \<Longrightarrow> f x = f a
 2. \<not> a < x \<Longrightarrow> f x = f a
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a < x

goal (2 subgoals):
 1. a < x \<Longrightarrow> f x = f a
 2. \<not> a < x \<Longrightarrow> f x = f a
[PROOF STEP]
have *: "continuous_on {a..x} f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on {a..x} f
[PROOF STEP]
using \<open>x \<le> b\<close> contf continuous_on_subset
[PROOF STATE]
proof (prove)
using this:
x \<le> b
continuous_on {a..b} f
\<lbrakk>continuous_on ?s ?f; ?t \<subseteq> ?s\<rbrakk> \<Longrightarrow> continuous_on ?t ?f

goal (1 subgoal):
 1. continuous_on {a..x} f
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
continuous_on {a..x} f

goal (2 subgoals):
 1. a < x \<Longrightarrow> f x = f a
 2. \<not> a < x \<Longrightarrow> f x = f a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x = f a
[PROOF STEP]
by (rule DERIV_isconst_end [OF True *]) (use \<open>x \<le> b\<close> derf in auto)
[PROOF STATE]
proof (state)
this:
f x = f a

goal (1 subgoal):
 1. \<not> a < x \<Longrightarrow> f x = f a
[PROOF STEP]
qed (use \<open>a \<le> x\<close> in auto)


[STATEMENT]
lemma log_eqI:
  assumes "n > 0" "2^k \<le> n" "n < 2 * 2^k"
  shows   "log n = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.log n = k
[PROOF STEP]
proof (rule antisym)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. local.log n \<le> k
 2. k \<le> local.log n
[PROOF STEP]
from \<open>n > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "2 ^ log n \<le> n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. 2 ^ local.log n \<le> n
[PROOF STEP]
by (rule log_exp2_le)
[PROOF STATE]
proof (state)
this:
2 ^ local.log n \<le> n

goal (2 subgoals):
 1. local.log n \<le> k
 2. k \<le> local.log n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 ^ local.log n \<le> n

goal (2 subgoals):
 1. local.log n \<le> k
 2. k \<le> local.log n
[PROOF STEP]
have "\<dots> < 2 ^ Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < 2 ^ Suc k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
2 ^ k \<le> n
n < 2 * 2 ^ k

goal (1 subgoal):
 1. n < 2 ^ Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n < 2 ^ Suc k

goal (2 subgoals):
 1. local.log n \<le> k
 2. k \<le> local.log n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 ^ local.log n < 2 ^ Suc k
[PROOF STEP]
have "log n < Suc k"
[PROOF STATE]
proof (prove)
using this:
2 ^ local.log n < 2 ^ Suc k

goal (1 subgoal):
 1. local.log n < Suc k
[PROOF STEP]
by (subst (asm) power_strict_increasing_iff) simp_all
[PROOF STATE]
proof (state)
this:
local.log n < Suc k

goal (2 subgoals):
 1. local.log n \<le> k
 2. k \<le> local.log n
[PROOF STEP]
thus "log n \<le> k"
[PROOF STATE]
proof (prove)
using this:
local.log n < Suc k

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

goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
have "2^k \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ k \<le> n
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
2 ^ k \<le> n

goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 ^ k \<le> n

goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
have "\<dots> < 2^(Suc (log n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < 2 ^ Suc (local.log n)
[PROOF STEP]
by (simp add: log_exp2_gt)
[PROOF STATE]
proof (state)
this:
n < 2 ^ Suc (local.log n)

goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 ^ k < 2 ^ Suc (local.log n)
[PROOF STEP]
have "k < Suc (log n)"
[PROOF STATE]
proof (prove)
using this:
2 ^ k < 2 ^ Suc (local.log n)

goal (1 subgoal):
 1. k < Suc (local.log n)
[PROOF STEP]
by (subst (asm) power_strict_increasing_iff) simp_all
[PROOF STATE]
proof (state)
this:
k < Suc (local.log n)

goal (1 subgoal):
 1. k \<le> local.log n
[PROOF STEP]
thus "k \<le> log n"
[PROOF STATE]
proof (prove)
using this:
k < Suc (local.log n)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ideal_generated_singleton: "ideal_generated {a} = {k*a|k. k \<in> UNIV}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ideal_generated {a} = {k * a |k. k \<in> UNIV}
[PROOF STEP]
proof (auto simp add: ideal_generated_eq_left_ideal left_ideal_explicit)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>f U. \<lbrakk>finite U; U \<subseteq> {a}\<rbrakk> \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
 2. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
fix f U
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>f U. \<lbrakk>finite U; U \<subseteq> {a}\<rbrakk> \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
 2. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
assume U: "finite U" and U_in_a: "U \<subseteq> {a}"
[PROOF STATE]
proof (state)
this:
finite U
U \<subseteq> {a}

goal (2 subgoals):
 1. \<And>f U. \<lbrakk>finite U; U \<subseteq> {a}\<rbrakk> \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
 2. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
show "\<exists>k. (\<Sum>i\<in>U. f i * i) = k * a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
proof (cases "U={}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. U = {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
 2. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
U = {}

goal (2 subgoals):
 1. U = {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
 2. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
by (rule exI[of _ 0], simp add: True)
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i\<in>U. f i * i) = k * a

goal (1 subgoal):
 1. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
U \<noteq> {}

goal (1 subgoal):
 1. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
hence Ua: "U = {a}"
[PROOF STATE]
proof (prove)
using this:
U \<noteq> {}

goal (1 subgoal):
 1. U = {a}
[PROOF STEP]
using U_in_a
[PROOF STATE]
proof (prove)
using this:
U \<noteq> {}
U \<subseteq> {a}

goal (1 subgoal):
 1. U = {a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U = {a}

goal (1 subgoal):
 1. U \<noteq> {} \<Longrightarrow> \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
by (rule exI[of _ "f a"]) (simp add: Ua sum_singleton)
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i\<in>U. f i * i) = k * a

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<Sum>i\<in>U. f i * i) = k * a

goal (1 subgoal):
 1. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
show " \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a
[PROOF STEP]
by (rule exI[of _ "\<lambda>i. k"], rule exI[of _ "{a}"], simp)
[PROOF STATE]
proof (state)
this:
\<exists>f U. finite U \<and> U \<subseteq> {a} \<and> (\<Sum>i\<in>U. f i * i) = k * a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma reflp_list_all2:
  assumes "reflp R"
  shows "reflp (list_all2 R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reflp (list_all2 R)
[PROOF STEP]
proof (rule reflpI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. list_all2 R x x
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
reflp R
[PROOF STEP]
have *: "\<And>xs. R xs xs"
[PROOF STATE]
proof (prove)
using this:
reflp R

goal (1 subgoal):
 1. \<And>xs. R xs xs
[PROOF STEP]
by (rule reflpE)
[PROOF STATE]
proof (state)
this:
R ?xs ?xs

goal (1 subgoal):
 1. \<And>x. list_all2 R x x
[PROOF STEP]
fix xs
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. list_all2 R x x
[PROOF STEP]
show "list_all2 R xs xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_all2 R xs xs
[PROOF STEP]
by (induct xs) (simp_all add: *)
[PROOF STATE]
proof (state)
this:
list_all2 R xs xs

goal:
No subgoals!
[PROOF STEP]
qed


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

goal (2 subgoals):
 1. i < length b \<Longrightarrow> flip i (flip i b) = b
 2. \<not> i < length b \<Longrightarrow> flip i (flip i b) = b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < length b
[PROOF STEP]
have A: "i < length (flip i b)"
[PROOF STATE]
proof (prove)
using this:
i < length b

goal (1 subgoal):
 1. i < length (flip i b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < length (flip i b)

goal (2 subgoals):
 1. i < length b \<Longrightarrow> flip i (flip i b) = b
 2. \<not> i < length b \<Longrightarrow> flip i (flip i b) = b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. flip i (flip i b) = b
[PROOF STEP]
apply(simp add: list_eq_iff_nth_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>ia<length b. flip i (flip i b) ! ia = b ! ia
[PROOF STEP]
apply(clarify)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia < length b \<Longrightarrow> flip i (flip i b) ! ia = b ! ia
[PROOF STEP]
proof (goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ia. ia < length b \<Longrightarrow> flip i (flip i b) ! ia = b ! ia
[PROOF STEP]
case (1 j)
[PROOF STATE]
proof (state)
this:
j < length b

goal (1 subgoal):
 1. \<And>ia. ia < length b \<Longrightarrow> flip i (flip i b) ! ia = b ! ia
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length b
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
j < length b

goal (1 subgoal):
 1. flip i (flip i b) ! j = b ! j
[PROOF STEP]
apply(cases "i=j")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>j < length b; i = j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
 2. \<lbrakk>j < length b; i \<noteq> j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
[PROOF STEP]
using flip_itself[OF A] flip_itself[OF True]
[PROOF STATE]
proof (prove)
using this:
flip i (flip i b) ! i = (\<not> flip i b ! i)
flip i b ! i = (\<not> b ! i)

goal (2 subgoals):
 1. \<lbrakk>j < length b; i = j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
 2. \<lbrakk>j < length b; i \<noteq> j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>j < length b; i \<noteq> j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
[PROOF STEP]
using flip_other True 1
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?y < length ?X; ?z < length ?X; ?z \<noteq> ?y\<rbrakk> \<Longrightarrow> flip ?z ?X ! ?y = ?X ! ?y
i < length b
j < length b

goal (1 subgoal):
 1. \<lbrakk>j < length b; i \<noteq> j\<rbrakk> \<Longrightarrow> flip i (flip i b) ! j = b ! j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
flip i (flip i b) ! j = b ! j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
flip i (flip i b) = b

goal (1 subgoal):
 1. \<not> i < length b \<Longrightarrow> flip i (flip i b) = b
[PROOF STEP]
qed (simp add: flip_out_of_bounds)


[STATEMENT]
lemma eval_fds_zeta: "Re s > 1 \<Longrightarrow> eval_fds fds_zeta s = zeta s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < Re s \<Longrightarrow> eval_fds fds_zeta s = zeta s
[PROOF STEP]
using sums_zeta [of s]
[PROOF STATE]
proof (prove)
using this:
1 < Re s \<Longrightarrow> (\<lambda>n. of_nat (Suc n) powr - s) sums zeta s

goal (1 subgoal):
 1. 1 < Re s \<Longrightarrow> eval_fds fds_zeta s = zeta s
[PROOF STEP]
by (intro eval_fds_eqI) (auto simp: powr_minus divide_simps)


[STATEMENT]
lemma rref_first_position_zero_imp_column_0:
fixes A::"'a::{one,zero}^'cols::{mod_type}^'rows::{mod_type}"
assumes rref: "reduced_row_echelon_form A"
and A_00: "A $ 0 $ 0 = 0"
shows "column 0 A = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column (0::'cols) A = 0
[PROOF STEP]
proof (unfold column_def, vector, clarify)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
have "is_zero_row_upt_k 0 1 A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k (0::'rows) 1 A
[PROOF STEP]
unfolding is_zero_row_upt_k_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j. mod_type_class.to_nat j < 1 \<longrightarrow> A $ (0::'rows) $ j = (0::'a)
[PROOF STEP]
using A_00
[PROOF STATE]
proof (prove)
using this:
A $ (0::'rows) $ (0::'cols) = (0::'a)

goal (1 subgoal):
 1. \<forall>j. mod_type_class.to_nat j < 1 \<longrightarrow> A $ (0::'rows) $ j = (0::'a)
[PROOF STEP]
by (metis One_nat_def less_Suc0 to_nat_eq_0)
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k (0::'rows) 1 A

goal (1 subgoal):
 1. \<And>i. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
hence "is_zero_row_upt_k i 1 A"
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k (0::'rows) 1 A

goal (1 subgoal):
 1. is_zero_row_upt_k i 1 A
[PROOF STEP]
using rref_upt_condition1[OF rref_implies_rref_upt[OF rref]]
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k (0::'rows) 1 A
\<forall>i. is_zero_row_upt_k i ?k A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j ?k A)

goal (1 subgoal):
 1. is_zero_row_upt_k i 1 A
[PROOF STEP]
using least_mod_type less_le
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k (0::'rows) 1 A
\<forall>i. is_zero_row_upt_k i ?k A \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j ?k A)
(0::?'a) \<le> ?n
(?x < ?y) = (?x \<le> ?y \<and> ?x \<noteq> ?y)

goal (1 subgoal):
 1. is_zero_row_upt_k i 1 A
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k i 1 A

goal (1 subgoal):
 1. \<And>i. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
thus "A $ i $ 0 = 0"
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i 1 A

goal (1 subgoal):
 1. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
unfolding is_zero_row_upt_k_def
[PROOF STATE]
proof (prove)
using this:
\<forall>j. mod_type_class.to_nat j < 1 \<longrightarrow> A $ i $ j = (0::'a)

goal (1 subgoal):
 1. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
using to_nat_eq_0
[PROOF STATE]
proof (prove)
using this:
\<forall>j. mod_type_class.to_nat j < 1 \<longrightarrow> A $ i $ j = (0::'a)
(mod_type_class.to_nat ?x = 0) = (?x = (0::?'a))

goal (1 subgoal):
 1. A $ i $ (0::'cols) = (0::'a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A $ i $ (0::'cols) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma d_nom_pos_iff_i_pos: "$d^{m} > 0 \<longleftrightarrow> i > 0" if "m \<noteq> 0" for m::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < i)
[PROOF STEP]
have "$d^{m} > 0 \<longleftrightarrow> $i^{m} > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < $i^{m})
[PROOF STEP]
unfolding d_nom_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < $i^{m} / (1 + $i^{m} / real m)) = (0 < $i^{m})
[PROOF STEP]
using zero_less_divide_iff i_nom_pos_iff_i_pos v_futr_m_pos that
[PROOF STATE]
proof (prove)
using this:
((0::?'a) < ?a / ?b) = ((0::?'a) < ?a \<and> (0::?'a) < ?b \<or> ?a < (0::?'a) \<and> ?b < (0::?'a))
?m \<noteq> 0 \<Longrightarrow> (0 < $i^{?m}) = (0 < i)
?m \<noteq> 0 \<Longrightarrow> 0 < 1 + $i^{?m} / real ?m
m \<noteq> 0

goal (1 subgoal):
 1. (0 < $i^{m} / (1 + $i^{m} / real m)) = (0 < $i^{m})
[PROOF STEP]
by smt
[PROOF STATE]
proof (state)
this:
(0 < $d^{m}) = (0 < $i^{m})

goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < i)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(0 < $d^{m}) = (0 < $i^{m})

goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < i)
[PROOF STEP]
using i_nom_pos_iff_i_pos that
[PROOF STATE]
proof (prove)
using this:
(0 < $d^{m}) = (0 < $i^{m})
?m \<noteq> 0 \<Longrightarrow> (0 < $i^{?m}) = (0 < i)
m \<noteq> 0

goal (1 subgoal):
 1. (0 < $d^{m}) = (0 < i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0 < $d^{m}) = (0 < i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infdist_le2: "a \<in> A \<Longrightarrow> dist x a \<le> d \<Longrightarrow> infdist x A \<le> d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> A; dist x a \<le> d\<rbrakk> \<Longrightarrow> infdist x A \<le> d
[PROOF STEP]
by (auto intro!: cINF_lower2 simp add: infdist_def)


[STATEMENT]
lemma swap_row_to_front_result: "A \<in> carrier_mat n m \<Longrightarrow> I < n \<Longrightarrow> swap_row_to_front A I =
  mat n m (\<lambda> (i,j). if i = 0 then A $$ (I,j)
  else if i \<le> I then A $$ (i - 1, j) else A $$ (i,j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
proof (induct I arbitrary: A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>A. \<lbrakk>A \<in> carrier_mat n m; 0 < n\<rbrakk> \<Longrightarrow> swap_row_to_front A 0 = mat n m (\<lambda>(i, j). if i = 0 then A $$ (0, j) else if i \<le> 0 then A $$ (i - 1, j) else A $$ (i, j))
 2. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat n m
0 < n

goal (2 subgoals):
 1. \<And>A. \<lbrakk>A \<in> carrier_mat n m; 0 < n\<rbrakk> \<Longrightarrow> swap_row_to_front A 0 = mat n m (\<lambda>(i, j). if i = 0 then A $$ (0, j) else if i \<le> 0 then A $$ (i - 1, j) else A $$ (i, j))
 2. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n m
0 < n

goal (1 subgoal):
 1. swap_row_to_front A 0 = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then A $$ (0, j) else if i \<le> 0 then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
by (intro eq_matI, auto)
[PROOF STATE]
proof (state)
this:
swap_row_to_front A 0 = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then A $$ (0, j) else if i \<le> 0 then A $$ (i - 1, j) else A $$ (i, j))

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
case (Suc I A)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front ?A I = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then ?A $$ (I, j) else if i \<le> I then ?A $$ (i - 1, j) else ?A $$ (i, j))
A \<in> carrier_mat n m
Suc I < n

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
from Suc(3)
[PROOF STATE]
proof (chain)
picking this:
Suc I < n
[PROOF STEP]
have I: "I < n"
[PROOF STATE]
proof (prove)
using this:
Suc I < n

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

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
let ?I = "Suc I"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
let ?A = "swaprows I ?I A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
have AA: "?A \<in> carrier_mat n m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaprows I (Suc I) A \<in> carrier_mat n m
[PROOF STEP]
using Suc(2)
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n m

goal (1 subgoal):
 1. swaprows I (Suc I) A \<in> carrier_mat n m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
swaprows I (Suc I) A \<in> carrier_mat n m

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
have "swap_row_to_front A (Suc I) = swap_row_to_front ?A I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swap_row_to_front A (Suc I) = swap_row_to_front (swaprows I (Suc I) A) I
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
swap_row_to_front A (Suc I) = swap_row_to_front (swaprows I (Suc I) A) I

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
swap_row_to_front A (Suc I) = swap_row_to_front (swaprows I (Suc I) A) I

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
have "\<dots> = mat n m
   (\<lambda>(i, j). if i = 0 then ?A $$ (I, j)
       else if i \<le> I then ?A $$ (i - 1, j) else ?A $$ (i, j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swap_row_to_front (swaprows I (Suc I) A) I = mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))
[PROOF STEP]
using Suc(1)[OF AA I]
[PROOF STATE]
proof (prove)
using this:
swap_row_to_front (swaprows I (Suc I) A) I = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))

goal (1 subgoal):
 1. swap_row_to_front (swaprows I (Suc I) A) I = mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
swap_row_to_front (swaprows I (Suc I) A) I = mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
swap_row_to_front (swaprows I (Suc I) A) I = mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
have "\<dots> = mat n m
   (\<lambda>(i, j). if i = 0 then A $$ (?I, j)
       else if i \<le> ?I then A $$ (i - 1, j) else A $$ (i, j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j)) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
by (rule eq_matI, insert I Suc(2), auto)
[PROOF STATE]
proof (state)
this:
mat n m (\<lambda>(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i \<le> I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j)) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))

goal (1 subgoal):
 1. \<And>I A. \<lbrakk>\<And>A. \<lbrakk>A \<in> carrier_mat n m; I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A I = mat n m (\<lambda>(i, j). if i = 0 then A $$ (I, j) else if i \<le> I then A $$ (i - 1, j) else A $$ (i, j)); A \<in> carrier_mat n m; Suc I < n\<rbrakk> \<Longrightarrow> swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
swap_row_to_front A (Suc I) = mat n m (\<lambda>(i, j). if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))

goal (1 subgoal):
 1. swap_row_to_front A (Suc I) = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
swap_row_to_front A (Suc I) = mat n m (\<lambda>a. case a of (i, j) \<Rightarrow> if i = 0 then A $$ (Suc I, j) else if i \<le> Suc I then A $$ (i - 1, j) else A $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma MVT_ivl':
  fixes f::"'a::ordered_euclidean_space\<Rightarrow>'b::ordered_euclidean_space"
  assumes fderiv: "(\<And>x. x \<in> D \<Longrightarrow> (f has_derivative J x) (at x within D))"
  assumes J_ivl: "\<And>x. x \<in> D \<Longrightarrow> J x (a - b) \<in> {J0..J1}"
  assumes line_in: "\<And>x. x \<in> {0..1} \<Longrightarrow> b + x *\<^sub>R (a - b) \<in> D"
  shows "f a \<in> {f b + J0..f b + J1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a \<in> {f b + J0..f b + J1}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f a \<in> {f b + J0..f b + J1}
[PROOF STEP]
have "f (b + (a - b)) - f b \<in> {J0 .. J1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (b + (a - b)) - f b \<in> {J0..J1}
[PROOF STEP]
using J_ivl MVT_ivl fderiv line_in
[PROOF STATE]
proof (prove)
using this:
?x \<in> D \<Longrightarrow> J ?x (a - b) \<in> {J0..J1}
\<lbrakk>\<And>x. x \<in> ?D \<Longrightarrow> (?f has_derivative ?J x) (at x within ?D); \<And>x. x \<in> ?D \<Longrightarrow> ?J x ?u \<in> {?J0.0..?J1.0}; \<And>x. x \<in> {0..1} \<Longrightarrow> ?a + x *\<^sub>R ?u \<in> ?D\<rbrakk> \<Longrightarrow> ?f (?a + ?u) - ?f ?a \<in> {?J0.0..?J1.0}
?x \<in> D \<Longrightarrow> (f has_derivative J ?x) (at ?x within D)
?x \<in> {0..1} \<Longrightarrow> b + ?x *\<^sub>R (a - b) \<in> D

goal (1 subgoal):
 1. f (b + (a - b)) - f b \<in> {J0..J1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f (b + (a - b)) - f b \<in> {J0..J1}

goal (1 subgoal):
 1. f a \<in> {f b + J0..f b + J1}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f (b + (a - b)) - f b \<in> {J0..J1}

goal (1 subgoal):
 1. f a \<in> {f b + J0..f b + J1}
[PROOF STEP]
by (auto simp: diff_le_eq le_diff_eq ac_simps)
[PROOF STATE]
proof (state)
this:
f a \<in> {f b + J0..f b + J1}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_sum_mult_right:
  shows "(\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d) \<Longrightarrow> A \<in> carrier_mat d d
    \<Longrightarrow> matrix_sum d (\<lambda>k. (f k) * A) n = matrix_sum d (\<lambda>k. f k) n * A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>k. k < 0 \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) 0 = matrix_sum d f 0 * A
 2. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
?k < 0 \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (2 subgoals):
 1. \<lbrakk>\<And>k. k < 0 \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) 0 = matrix_sum d f 0 * A
 2. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < 0 \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?k < 0 \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. matrix_sum d (\<lambda>k. f k * A) 0 = matrix_sum d f 0 * A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_sum d (\<lambda>k. f k * A) 0 = matrix_sum d f 0 * A

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
?k < Suc n \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
?k < Suc n \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d
[PROOF STEP]
have "k < n \<Longrightarrow> f k \<in> carrier_mat d d" and dfn: "f n \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
?k < Suc n \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. (k < n \<Longrightarrow> f k \<in> carrier_mat d d) &&& f n \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
f n \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
f n \<in> carrier_mat d d
[PROOF STEP]
have dsfn: "matrix_sum d f n \<in> carrier_mat d d"
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
f n \<in> carrier_mat d d

goal (1 subgoal):
 1. matrix_sum d f n \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
f n \<in> carrier_mat d d
(\<And>k. k < ?n \<Longrightarrow> ?f k \<in> carrier_mat ?d ?d) \<Longrightarrow> matrix_sum ?d ?f ?n \<in> carrier_mat ?d ?d

goal (1 subgoal):
 1. matrix_sum d f n \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_sum d f n \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
have "(f n + matrix_sum d f n) * A = f n * A + matrix_sum d f n * A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f n + matrix_sum d f n) * A = f n * A + matrix_sum d f n * A
[PROOF STEP]
apply (mat_assoc d)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. matrix_sum d f n \<in> carrier_mat d d
 2. f n \<in> carrier_mat d d
 3. A \<in> carrier_mat d d
[PROOF STEP]
using Suc dsfn
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
?k < Suc n \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d
matrix_sum d f n \<in> carrier_mat d d

goal (3 subgoals):
 1. matrix_sum d f n \<in> carrier_mat d d
 2. f n \<in> carrier_mat d d
 3. A \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(f n + matrix_sum d f n) * A = f n * A + matrix_sum d f n * A

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(f n + matrix_sum d f n) * A = f n * A + matrix_sum d f n * A

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
have "\<dots> = f n * A + matrix_sum d (\<lambda>k. f k * A) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f n * A + matrix_sum d f n * A = f n * A + matrix_sum d (\<lambda>k. f k * A) n
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A
?k < Suc n \<Longrightarrow> f ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. f n * A + matrix_sum d f n * A = f n * A + matrix_sum d (\<lambda>k. f k * A) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f n * A + matrix_sum d f n * A = f n * A + matrix_sum d (\<lambda>k. f k * A) n

goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<lbrakk>\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) n = matrix_sum d f n * A; \<And>k. k < Suc n \<Longrightarrow> f k \<in> carrier_mat d d; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(f n + matrix_sum d f n) * A = f n * A + matrix_sum d (\<lambda>k. f k * A) n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(f n + matrix_sum d f n) * A = f n * A + matrix_sum d (\<lambda>k. f k * A) n

goal (1 subgoal):
 1. matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matrix_sum d (\<lambda>k. f k * A) (Suc n) = matrix_sum d f (Suc n) * A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma remdups_replicate: "remdups (replicate n x) = (if n = 0 then [] else [x])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. remdups (replicate n x) = (if n = 0 then [] else [x])
[PROOF STEP]
by(induction n) simp_all


[STATEMENT]
lemma mat0_index[simp]: assumes "i < nc" and "j < nr"
  shows "mat0I ze nr nc ! i ! j = ze"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat0I ze nr nc ! i ! j = ze
[PROOF STEP]
unfolding mat0I_def vec0I_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. replicate nc (replicate nr ze) ! i ! j = ze
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < nc
j < nr

goal (1 subgoal):
 1. replicate nc (replicate nr ze) ! i ! j = ze
[PROOF STEP]
by auto


[STATEMENT]
lemma param_foldli_induct:
  assumes l: "(l,l') \<in> \<langle>Ra\<rangle>list_rel"
  assumes c: "(c,c') \<in> Rb \<rightarrow> bool_rel"
  assumes \<sigma>: "(\<sigma>,\<sigma>') \<in> Rb"
  assumes P\<sigma>: "P \<sigma> \<sigma>'"
  assumes f: "\<And>a a' b b'. (a,a')\<in>Ra \<Longrightarrow> (b,b')\<in>Rb \<Longrightarrow> c b \<Longrightarrow> c' b' \<Longrightarrow>
                           P b b' \<Longrightarrow> (f a b, f' a' b') \<in> Rb \<and>
                          P (f a b) (f' a' b')"
  shows "(foldli l c f \<sigma>, foldli l' c' f' \<sigma>') \<in> Rb"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (foldli l c f \<sigma>, foldli l' c' f' \<sigma>') \<in> Rb
[PROOF STEP]
using c \<sigma> P\<sigma> f
[PROOF STATE]
proof (prove)
using this:
(c, c') \<in> Rb \<rightarrow> bool_rel
(\<sigma>, \<sigma>') \<in> Rb
P \<sigma> \<sigma>'
\<lbrakk>(?a, ?a') \<in> Ra; (?b, ?b') \<in> Rb; c ?b; c' ?b'; P ?b ?b'\<rbrakk> \<Longrightarrow> (f ?a ?b, f' ?a' ?b') \<in> Rb \<and> P (f ?a ?b) (f' ?a' ?b')

goal (1 subgoal):
 1. (foldli l c f \<sigma>, foldli l' c' f' \<sigma>') \<in> Rb
[PROOF STEP]
by (induction arbitrary: \<sigma> \<sigma>' rule: list_rel_induct[OF l],
                   auto dest!: fun_relD)


[STATEMENT]
lemma bin_UNIV_I: "a \<in> S \<Longrightarrow> 1-a \<in> S \<Longrightarrow> S = binUNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> S; 1 - a \<in> S\<rbrakk> \<Longrightarrow> S = binUNIV
[PROOF STEP]
using bin_UNIV_iff
[PROOF STATE]
proof (prove)
using this:
(?S = binUNIV) = (?a \<in> ?S \<and> 1 - ?a \<in> ?S)

goal (1 subgoal):
 1. \<lbrakk>a \<in> S; 1 - a \<in> S\<rbrakk> \<Longrightarrow> S = binUNIV
[PROOF STEP]
by blast


[STATEMENT]
lemma test_comp_anti_iff: "test p \<Longrightarrow> test q \<Longrightarrow> p \<le> q \<longleftrightarrow> !q \<le> !p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>test p; test q\<rbrakk> \<Longrightarrow> (p \<le> q) = (!q \<le> !p)
[PROOF STEP]
using n_anti_iff
[PROOF STATE]
proof (prove)
using this:
(!?x \<le> !?y) = (t ?y \<le> t ?x)

goal (1 subgoal):
 1. \<lbrakk>test p; test q\<rbrakk> \<Longrightarrow> (p \<le> q) = (!q \<le> !p)
[PROOF STEP]
by auto


[STATEMENT]
lemma hypreal_of_real_le_add_Infininitesimal_cancel2:
  "u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>
    hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow> x \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>u \<in> Infinitesimal; v \<in> Infinitesimal; hypreal_of_real x + u \<le> hypreal_of_real y + v\<rbrakk> \<Longrightarrow> x \<le> y
[PROOF STEP]
by (blast intro: star_of_le [THEN iffD1] intro!: hypreal_of_real_le_add_Infininitesimal_cancel)


[STATEMENT]
lemma Gauss_Jordan_in_ij_1:
  fixes A::"'a::{field}^'m^'n::{finite, ord, wellorder}"
  assumes ex: "\<exists>n. A $ n $ j \<noteq> 0 \<and> i \<le> n"
  shows "(Gauss_Jordan_in_ij A i j) $ i $ j = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Gauss_Jordan_in_ij A i j $ i $ j = (1::'a)
[PROOF STEP]
proof (unfold Gauss_Jordan_in_ij_def Let_def mult_row_def interchange_rows_def, vector)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j \<noteq> (0::'a)
[PROOF STEP]
obtain n where Anj: "A $ n $ j \<noteq> 0 \<and> i \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex
[PROOF STATE]
proof (prove)
using this:
\<exists>n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n

goal (1 subgoal):
 1. (\<And>n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A $ n $ j \<noteq> (0::'a) \<and> i \<le> n

goal (1 subgoal):
 1. A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j \<noteq> (0::'a)
[PROOF STEP]
show "A $ (LEAST n. A $ n $ j \<noteq> 0 \<and> i \<le> n) $ j \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j \<noteq> (0::'a)
[PROOF STEP]
using LeastI[of "\<lambda>n. A $ n $ j \<noteq> 0 \<and> i \<le> n" n, OF Anj]
[PROOF STATE]
proof (prove)
using this:
A $ (LEAST x. A $ x $ j \<noteq> (0::'a) \<and> i \<le> x) $ j \<noteq> (0::'a) \<and> i \<le> (LEAST x. A $ x $ j \<noteq> (0::'a) \<and> i \<le> x)

goal (1 subgoal):
 1. A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j \<noteq> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A $ (LEAST n. A $ n $ j \<noteq> (0::'a) \<and> i \<le> n) $ j \<noteq> (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma minus_zero_iarray:
  fixes A::"'a::{group_add} iarray"
  shows "A - 0 = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A - 0 = A
[PROOF STEP]
proof (unfold iarray_exhaust2 list_eq_iff_nth_eq, auto, unfold IArray.length_def[symmetric] IArray.sub_def[symmetric])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. IArray.length (A - 0) = IArray.length A
 2. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
have max_eq: "(max (IArray.length A) (IArray.length 0))= IArray.length A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (IArray.length A) (IArray.length 0) = IArray.length A
[PROOF STEP]
unfolding zero_iarray_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. max (IArray.length A) (IArray.length (IArray [])) = IArray.length A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
max (IArray.length A) (IArray.length 0) = IArray.length A

goal (2 subgoals):
 1. IArray.length (A - 0) = IArray.length A
 2. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
show length_eq: "IArray.length (A - 0) = IArray.length A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (A - 0) = IArray.length A
[PROOF STEP]
unfolding minus_iarray_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (max (IArray.length A) (IArray.length 0)) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (max (IArray.length A) (IArray.length 0)) !! a) (max (IArray.length A) (IArray.length 0))) = IArray.length A
[PROOF STEP]
unfolding max_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.length (IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)) = IArray.length A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
IArray.length (A - 0) = IArray.length A

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
assume i: "i < IArray.length (A - 0)"
[PROOF STATE]
proof (state)
this:
i < IArray.length (A - 0)

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
hence i2: "i< (IArray.length A)"
[PROOF STATE]
proof (prove)
using this:
i < IArray.length (A - 0)

goal (1 subgoal):
 1. i < IArray.length A
[PROOF STEP]
unfolding length_eq
[PROOF STATE]
proof (prove)
using this:
i < IArray.length A

goal (1 subgoal):
 1. i < IArray.length A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
i < IArray.length A

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
have "A - 0 = IArray.of_fun
    (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else 0) (IArray.length A) !! a -
    IArray.of_fun (\<lambda>a. if a < IArray.length (0::'a iarray) then 0 !! a else 0) (IArray.length A) !! a)
    (IArray.length A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A - 0 = IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)
[PROOF STEP]
unfolding minus_iarray_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (max (IArray.length A) (IArray.length 0)) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (max (IArray.length A) (IArray.length 0)) !! a) (max (IArray.length A) (IArray.length 0)) = IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)
[PROOF STEP]
unfolding max_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A) = IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
A - 0 = IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A - 0 = IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A)

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
have "... !! i = A !! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A) !! i = A !! i
[PROOF STEP]
unfolding of_fun_nth[OF i2] length_zero_iarray
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i < IArray.length A then A !! i else (0::'a)) - (if i < 0 then 0 !! i else (0::'a)) = A !! i
[PROOF STEP]
using i2
[PROOF STATE]
proof (prove)
using this:
i < IArray.length A

goal (1 subgoal):
 1. (if i < IArray.length A then A !! i else (0::'a)) - (if i < 0 then 0 !! i else (0::'a)) = A !! i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
IArray.of_fun (\<lambda>a. IArray.of_fun (\<lambda>a. if a < IArray.length A then A !! a else (0::'a)) (IArray.length A) !! a - IArray.of_fun (\<lambda>a. if a < IArray.length 0 then 0 !! a else (0::'a)) (IArray.length A) !! a) (IArray.length A) !! i = A !! i

goal (1 subgoal):
 1. \<And>i. i < IArray.length (A - 0) \<Longrightarrow> (A - 0) !! i = A !! i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(A - 0) !! i = A !! i
[PROOF STEP]
show "(A - 0) !! i = A !! i"
[PROOF STATE]
proof (prove)
using this:
(A - 0) !! i = A !! i

goal (1 subgoal):
 1. (A - 0) !! i = A !! i
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(A - 0) !! i = A !! i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma incident_polar_swap:
  assumes "proj2_incident p (polar q)"
  shows "proj2_incident q (polar p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj2_incident q (polar p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proj2_incident q (polar p)
[PROOF STEP]
from \<open>proj2_incident p (polar q)\<close>
[PROOF STATE]
proof (chain)
picking this:
proj2_incident p (polar q)
[PROOF STEP]
have "proj2_rep p \<bullet> (M *v proj2_rep q) = 0"
[PROOF STATE]
proof (prove)
using this:
proj2_incident p (polar q)

goal (1 subgoal):
 1. proj2_rep p \<bullet> (M *v proj2_rep q) = 0
[PROOF STEP]
by (unfold incident_polar)
[PROOF STATE]
proof (state)
this:
proj2_rep p \<bullet> (M *v proj2_rep q) = 0

goal (1 subgoal):
 1. proj2_incident q (polar p)
[PROOF STEP]
hence "proj2_rep q \<bullet> (M *v proj2_rep p) = 0"
[PROOF STATE]
proof (prove)
using this:
proj2_rep p \<bullet> (M *v proj2_rep q) = 0

goal (1 subgoal):
 1. proj2_rep q \<bullet> (M *v proj2_rep p) = 0
[PROOF STEP]
by (simp add: M_reverse)
[PROOF STATE]
proof (state)
this:
proj2_rep q \<bullet> (M *v proj2_rep p) = 0

goal (1 subgoal):
 1. proj2_incident q (polar p)
[PROOF STEP]
thus "proj2_incident q (polar p)"
[PROOF STATE]
proof (prove)
using this:
proj2_rep q \<bullet> (M *v proj2_rep p) = 0

goal (1 subgoal):
 1. proj2_incident q (polar p)
[PROOF STEP]
by (unfold incident_polar)
[PROOF STATE]
proof (state)
this:
proj2_incident q (polar p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma subseq_wf:
  shows "wf {(x, y). subseq x y \<and> x \<noteq> y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
have "wf (measure length)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf (measure length)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
wf (measure length)

goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
wf (measure length)

goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
have "{(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> measure length"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> measure length
[PROOF STEP]
unfolding measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> inv_image less_than length
[PROOF STEP]
by (auto simp add: subseq_strict_length)
[PROOF STATE]
proof (state)
this:
{(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> measure length

goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
wf (measure length)
{(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> measure length
[PROOF STEP]
show "wf {(x, y). subseq x y \<and> x \<noteq> y}"
[PROOF STATE]
proof (prove)
using this:
wf (measure length)
{(x, y). subseq x y \<and> x \<noteq> y} \<subseteq> measure length

goal (1 subgoal):
 1. wf {(x, y). subseq x y \<and> x \<noteq> y}
[PROOF STEP]
by (rule wf_subset)
[PROOF STATE]
proof (state)
this:
wf {(x, y). subseq x y \<and> x \<noteq> y}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem find_set_path_compression:
  "VARS p y
  [ find_set_precondition p x \<and> p0 = p ]
  y := find_set p x;
  p := path_compression p x y
  [ path_compression_postcondition p x y p0 ]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [find_set_precondition p x \<and> p0 = p]
y := find_set p x; p := path_compression p x y
[path_compression_postcondition p x y p0]
[PROOF STEP]
apply vcg_tc_simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. find_set_precondition p0 x \<Longrightarrow> path_compression_postcondition (path_compression p0 x (find_set p0 x)) x (find_set p0 x) p0
[PROOF STEP]
using find_set_function find_set_postcondition_def find_set_precondition_def path_compression_function path_compression_precondition_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>find_set_precondition ?p ?x; ?y = find_set ?p ?x\<rbrakk> \<Longrightarrow> find_set_postcondition ?p ?x ?y
find_set_postcondition ?p ?x ?y \<equiv> point ?y \<and> ?y = root ?p ?x
find_set_precondition ?p ?x \<equiv> ((coreflexive (?p[[?p]]) \<and> times_top_class.total ?p) \<and> pd_kleene_allegory_class.acyclic (?p - (1::'a))) \<and> point ?x
\<lbrakk>path_compression_precondition ?p ?x ?y; ?p' = path_compression ?p ?x ?y\<rbrakk> \<Longrightarrow> path_compression_postcondition ?p' ?x ?y ?p
path_compression_precondition ?p ?x ?y \<equiv> ((coreflexive (?p[[?p]]) \<and> times_top_class.total ?p) \<and> pd_kleene_allegory_class.acyclic (?p - (1::'a))) \<and> point ?x \<and> point ?y \<and> ?y = root ?p ?x

goal (1 subgoal):
 1. find_set_precondition p0 x \<Longrightarrow> path_compression_postcondition (path_compression p0 x (find_set p0 x)) x (find_set p0 x) p0
[PROOF STEP]
by fastforce


[STATEMENT]
lemma exp_series_add_commuting:
  fixes x y :: "'a::{real_normed_algebra_1,banach}"
  defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n"
  assumes comm: "x * y = y * x"
  shows "S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i))
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. S (x + y) 0 = (\<Sum>i\<le>0. S x i * S y (0 - i))
 2. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. S (x + y) 0 = (\<Sum>i\<le>0. S x i * S y (0 - i))
 2. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S (x + y) 0 = (\<Sum>i\<le>0. S x i * S y (0 - i))
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y) ^ 0 /\<^sub>R fact 0 = (\<Sum>i\<le>0. x ^ i /\<^sub>R fact i * (y ^ (0 - i) /\<^sub>R fact (0 - i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
S (x + y) 0 = (\<Sum>i\<le>0. S x i * S y (0 - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have S_Suc: "\<And>x n. S x (Suc n) = (x * S x n) /\<^sub>R real (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x n. S x (Suc n) = x * S x n /\<^sub>R real (Suc n)
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x n. x ^ Suc n /\<^sub>R fact (Suc n) = x * (x ^ n /\<^sub>R fact n) /\<^sub>R real (Suc n)
[PROOF STEP]
by (simp del: mult_Suc)
[PROOF STATE]
proof (state)
this:
S ?x (Suc ?n) = ?x * S ?x ?n /\<^sub>R real (Suc ?n)

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S ?x (Suc ?n) = ?x * S ?x ?n /\<^sub>R real (Suc ?n)
[PROOF STEP]
have times_S: "\<And>x n. x * S x n = real (Suc n) *\<^sub>R S x (Suc n)"
[PROOF STATE]
proof (prove)
using this:
S ?x (Suc ?n) = ?x * S ?x ?n /\<^sub>R real (Suc ?n)

goal (1 subgoal):
 1. \<And>x n. x * S x n = real (Suc n) *\<^sub>R S x (Suc n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?x * S ?x ?n = real (Suc ?n) *\<^sub>R S ?x (Suc ?n)

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have S_comm: "\<And>n. S x n * y = y * S x n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. S x n * y = y * S x n
[PROOF STEP]
by (simp add: power_commuting_commutes comm S_def)
[PROOF STATE]
proof (state)
this:
S x ?n * y = y * S x ?n

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))
[PROOF STEP]
by (metis Suc.hyps times_S)
[PROOF STATE]
proof (state)
this:
real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "\<dots> = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i)) = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i))
[PROOF STEP]
by (rule distrib_right)
[PROOF STATE]
proof (state)
this:
(x + y) * (\<Sum>i\<le>n. S x i * S y (n - i)) = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x + y) * (\<Sum>i\<le>n. S x i * S y (n - i)) = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))
[PROOF STEP]
by (simp add: sum_distrib_left ac_simps S_comm)
[PROOF STATE]
proof (state)
this:
x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i)) = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i)))
                + (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i))) = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) + (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))
[PROOF STEP]
by (simp add: times_S Suc_diff_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i))) = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) + (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i))) = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) + (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i)))
           = (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))
[PROOF STEP]
by (subst sum.atMost_Suc_shift) simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) = (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))
           = (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))
           + (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))
           = (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) + (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))
[PROOF STEP]
by (simp flip: sum.distrib scaleR_add_left of_nat_add)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) + (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) + (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) = (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i))) = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
by (simp only: scaleR_right.sum)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i))) = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))

goal (1 subgoal):
 1. \<And>n. S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i)) \<Longrightarrow> S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (Suc n) *\<^sub>R S (x + y) (Suc n) = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"
[PROOF STATE]
proof (prove)
using this:
real (Suc n) *\<^sub>R S (x + y) (Suc n) = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))

goal (1 subgoal):
 1. S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))
[PROOF STEP]
by (simp del: sum.cl_ivl_Suc)
[PROOF STATE]
proof (state)
this:
S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma time_split_at_tm:
  "time (split_at_tm n xs) = min n (length xs) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. time (split_at_tm n xs) = min n (length xs) + 1
[PROOF STEP]
by (induction xs arbitrary: n) (auto simp: time_simps split: nat.split prod.split)


[STATEMENT]
lemma coeff_mult_semiring_closed:
  assumes "\<And>i. coeff p i \<in> R" "\<And>i. coeff q i \<in> R"
  shows   "coeff (p * q) i \<in> R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * q) i \<in> R
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coeff (p * q) i \<in> R
[PROOF STEP]
have R_sum: "sum f A \<in> R" if "\<And>x. x \<in> A \<Longrightarrow> f x \<in> R" for A and f :: "nat \<Rightarrow> 'a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A \<in> R
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> f ?x \<in> R

goal (1 subgoal):
 1. sum f A \<in> R
[PROOF STEP]
by (induction A rule: infinite_finite_induct) (auto intro: R_0 R_plus)
[PROOF STATE]
proof (state)
this:
(\<And>x. x \<in> ?A \<Longrightarrow> ?f x \<in> R) \<Longrightarrow> sum ?f ?A \<in> R

goal (1 subgoal):
 1. coeff (p * q) i \<in> R
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * q) i \<in> R
[PROOF STEP]
unfolding coeff_mult
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. coeff p ia * coeff q (i - ia)) \<in> R
[PROOF STEP]
by (auto intro!: R_sum R_mult assms)
[PROOF STATE]
proof (state)
this:
coeff (p * q) i \<in> R

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_lens_id_equiv:
  "1\<^sub>L \<times>\<^sub>L 1\<^sub>L = 1\<^sub>L"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1\<^sub>L \<times>\<^sub>L 1\<^sub>L = 1\<^sub>L
[PROOF STEP]
by (auto simp add: lens_prod_def id_lens_def)


[STATEMENT]
lemma nth_prime_le_prime_sequence:
  fixes p :: "nat \<Rightarrow> nat"
  assumes "strict_mono_on {..<n} p" and "\<And>k. k < n \<Longrightarrow> prime (p k)" and "k < n"
  shows   "nth_prime k \<le> p k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_prime k \<le> p k
[PROOF STEP]
using assms(3)
[PROOF STATE]
proof (prove)
using this:
k < n

goal (1 subgoal):
 1. nth_prime k \<le> p k
[PROOF STEP]
proof (induction k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < n \<Longrightarrow> nth_prime 0 \<le> p 0
 2. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 < n

goal (2 subgoals):
 1. 0 < n \<Longrightarrow> nth_prime 0 \<le> p 0
 2. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
hence "prime (p 0)"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. prime (p 0)
[PROOF STEP]
by (intro assms)
[PROOF STATE]
proof (state)
this:
prime (p 0)

goal (2 subgoals):
 1. 0 < n \<Longrightarrow> nth_prime 0 \<le> p 0
 2. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
hence "p 0 \<ge> 2"
[PROOF STATE]
proof (prove)
using this:
prime (p 0)

goal (1 subgoal):
 1. 2 \<le> p 0
[PROOF STEP]
by (auto dest: prime_gt_1_nat)
[PROOF STATE]
proof (state)
this:
2 \<le> p 0

goal (2 subgoals):
 1. 0 < n \<Longrightarrow> nth_prime 0 \<le> p 0
 2. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
2 \<le> p 0

goal (1 subgoal):
 1. nth_prime 0 \<le> p 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_prime 0 \<le> p 0

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
k < n \<Longrightarrow> nth_prime k \<le> p k
Suc k < n

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
have IH: "Suc (nth_prime k) \<le> Suc (p k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (nth_prime k) \<le> Suc (p k)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
k < n \<Longrightarrow> nth_prime k \<le> p k
Suc k < n

goal (1 subgoal):
 1. Suc (nth_prime k) \<le> Suc (p k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc (nth_prime k) \<le> Suc (p k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
have "nth_prime (Suc k) = smallest_prime_beyond (Suc (nth_prime k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_prime (Suc k) = smallest_prime_beyond (Suc (nth_prime k))
[PROOF STEP]
by (simp add: nth_prime_Suc)
[PROOF STATE]
proof (state)
this:
nth_prime (Suc k) = smallest_prime_beyond (Suc (nth_prime k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nth_prime (Suc k) = smallest_prime_beyond (Suc (nth_prime k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
nth_prime (Suc k) = smallest_prime_beyond (Suc (nth_prime k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
have "Suc (nth_prime k) \<le> Suc (p k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (nth_prime k) \<le> Suc (p k)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
k < n \<Longrightarrow> nth_prime k \<le> p k
Suc k < n

goal (1 subgoal):
 1. Suc (nth_prime k) \<le> Suc (p k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc (nth_prime k) \<le> Suc (p k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Suc (nth_prime k) \<le> Suc (p k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
have "\<dots> \<le> smallest_prime_beyond (Suc (p k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (p k) \<le> smallest_prime_beyond (Suc (p k))
[PROOF STEP]
by (rule smallest_prime_beyond_le)
[PROOF STATE]
proof (state)
this:
Suc (p k) \<le> smallest_prime_beyond (Suc (p k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Suc (nth_prime k) \<le> smallest_prime_beyond (Suc (p k))
[PROOF STEP]
have "smallest_prime_beyond (Suc (nth_prime k)) \<le> smallest_prime_beyond (Suc (p k))"
[PROOF STATE]
proof (prove)
using this:
Suc (nth_prime k) \<le> smallest_prime_beyond (Suc (p k))

goal (1 subgoal):
 1. smallest_prime_beyond (Suc (nth_prime k)) \<le> smallest_prime_beyond (Suc (p k))
[PROOF STEP]
by (rule smallest_prime_beyond_smallest[OF prime_smallest_prime_beyond])
[PROOF STATE]
proof (state)
this:
smallest_prime_beyond (Suc (nth_prime k)) \<le> smallest_prime_beyond (Suc (p k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
smallest_prime_beyond (Suc (nth_prime k)) \<le> smallest_prime_beyond (Suc (p k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
smallest_prime_beyond (Suc (nth_prime k)) \<le> smallest_prime_beyond (Suc (p k))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
have "p k < p (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p k < p (Suc k)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
k < n \<Longrightarrow> nth_prime k \<le> p k
Suc k < n

goal (1 subgoal):
 1. p k < p (Suc k)
[PROOF STEP]
by (intro strict_mono_onD[OF assms(1)]) auto
[PROOF STATE]
proof (state)
this:
p k < p (Suc k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
hence "smallest_prime_beyond (Suc (p k)) \<le> p (Suc k)"
[PROOF STATE]
proof (prove)
using this:
p k < p (Suc k)

goal (1 subgoal):
 1. smallest_prime_beyond (Suc (p k)) \<le> p (Suc k)
[PROOF STEP]
using Suc.prems
[PROOF STATE]
proof (prove)
using this:
p k < p (Suc k)
Suc k < n

goal (1 subgoal):
 1. smallest_prime_beyond (Suc (p k)) \<le> p (Suc k)
[PROOF STEP]
by (intro smallest_prime_beyond_smallest assms) auto
[PROOF STATE]
proof (state)
this:
smallest_prime_beyond (Suc (p k)) \<le> p (Suc k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k < n \<Longrightarrow> nth_prime k \<le> p k; Suc k < n\<rbrakk> \<Longrightarrow> nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
nth_prime (Suc k) \<le> p (Suc k)

goal (1 subgoal):
 1. nth_prime (Suc k) \<le> p (Suc k)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
nth_prime (Suc k) \<le> p (Suc k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma weak_duality_theorem:
  fixes A :: "'a :: linordered_comm_semiring_strict mat"
  assumes A: "A \<in> carrier_mat nr nc"
    and b: "b \<in> carrier_vec nr"
    and c: "c \<in> carrier_vec nc"
    and x: "x \<in> carrier_vec nc"
    and Axb: "A *\<^sub>v x \<le> b"
    and y0: "y \<ge> 0\<^sub>v nr"
    and yA: "A\<^sup>T *\<^sub>v y = c"
  shows "c \<bullet> x \<le> b \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
from y0
[PROOF STATE]
proof (chain)
picking this:
0\<^sub>v nr \<le> y
[PROOF STEP]
have y: "y \<in> carrier_vec nr"
[PROOF STATE]
proof (prove)
using this:
0\<^sub>v nr \<le> y

goal (1 subgoal):
 1. y \<in> carrier_vec nr
[PROOF STEP]
unfolding less_eq_vec_def
[PROOF STATE]
proof (prove)
using this:
dim_vec (0\<^sub>v nr) = dim_vec y \<and> (\<forall>i<dim_vec y. 0\<^sub>v nr $ i \<le> y $ i)

goal (1 subgoal):
 1. y \<in> carrier_vec nr
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y \<in> carrier_vec nr

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
have "c \<bullet> x = (A\<^sup>T *\<^sub>v y) \<bullet> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<bullet> x = (A\<^sup>T *\<^sub>v y) \<bullet> x
[PROOF STEP]
unfolding yA
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<bullet> x = c \<bullet> x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c \<bullet> x = (A\<^sup>T *\<^sub>v y) \<bullet> x

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c \<bullet> x = (A\<^sup>T *\<^sub>v y) \<bullet> x

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
have "\<dots> = y \<bullet> (A *\<^sub>v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A\<^sup>T *\<^sub>v y) \<bullet> x = y \<bullet> (A *\<^sub>v x)
[PROOF STEP]
using x y A
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier_vec nc
y \<in> carrier_vec nr
A \<in> carrier_mat nr nc

goal (1 subgoal):
 1. (A\<^sup>T *\<^sub>v y) \<bullet> x = y \<bullet> (A *\<^sub>v x)
[PROOF STEP]
by (metis transpose_vec_mult_scalar)
[PROOF STATE]
proof (state)
this:
(A\<^sup>T *\<^sub>v y) \<bullet> x = y \<bullet> (A *\<^sub>v x)

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(A\<^sup>T *\<^sub>v y) \<bullet> x = y \<bullet> (A *\<^sub>v x)

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
have "\<dots> \<le> y \<bullet> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<bullet> (A *\<^sub>v x) \<le> y \<bullet> b
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_vec (A *\<^sub>v x). y $ i * (A *\<^sub>v x) $ i) \<le> (\<Sum>i = 0..<dim_vec b. y $ i * b $ i)
[PROOF STEP]
using A b Axb y0
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat nr nc
b \<in> carrier_vec nr
A *\<^sub>v x \<le> b
0\<^sub>v nr \<le> y

goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_vec (A *\<^sub>v x). y $ i * (A *\<^sub>v x) $ i) \<le> (\<Sum>i = 0..<dim_vec b. y $ i * b $ i)
[PROOF STEP]
by (auto intro!: sum_mono mult_left_mono simp: less_eq_vec_def)
[PROOF STATE]
proof (state)
this:
y \<bullet> (A *\<^sub>v x) \<le> y \<bullet> b

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
y \<bullet> (A *\<^sub>v x) \<le> y \<bullet> b

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
have "\<dots> = b \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<bullet> b = b \<bullet> y
[PROOF STEP]
using y b
[PROOF STATE]
proof (prove)
using this:
y \<in> carrier_vec nr
b \<in> carrier_vec nr

goal (1 subgoal):
 1. y \<bullet> b = b \<bullet> y
[PROOF STEP]
by (metis comm_scalar_prod)
[PROOF STATE]
proof (state)
this:
y \<bullet> b = b \<bullet> y

goal (1 subgoal):
 1. c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
c \<bullet> x \<le> b \<bullet> y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c \<bullet> x \<le> b \<bullet> y

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_selsort[simp]: "set (selsort xs) = set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (selsort xs) = set xs
[PROOF STEP]
using in_set_selsort_eq
[PROOF STATE]
proof (prove)
using this:
(?x \<in> set (selsort ?xs)) = (?x \<in> set ?xs)

goal (1 subgoal):
 1. set (selsort xs) = set xs
[PROOF STEP]
by blast