[STATEMENT]
lemma set_vebt_succ'[vebt_simps]: "invar_vebt t n \<Longrightarrow> vebt_succ t x = (if \<exists>  y \<in> set_vebt t. y > x then Some (LEAST y \<in> set_vebt t. y > x) else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar_vebt t n \<Longrightarrow> vebt_succ t x = (if \<exists>y\<in>set_vebt t. x < y then Some (LEAST y. y \<in> set_vebt t \<and> x < y) else None)
[PROOF STEP]
apply (clarsimp;safe)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>y. \<lbrakk>invar_vebt t n; y \<in> set_vebt t; x < y\<rbrakk> \<Longrightarrow> vebt_succ t x = Some (LEAST y. y \<in> set_vebt t \<and> x < y)
 2. \<lbrakk>invar_vebt t n; \<forall>xa\<in>set_vebt t. \<not> x < xa\<rbrakk> \<Longrightarrow> vebt_succ t x = None
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; y_ \<in> set_vebt t; x < y_\<rbrakk> \<Longrightarrow> vebt_succ t x = Some (LEAST y. y \<in> set_vebt t \<and> x < y)
[PROOF STEP]
apply(clarsimp simp add: succ_correct is_succ_in_set_def Least_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; y_ \<in> set_vebt t; x < y_\<rbrakk> \<Longrightarrow> (LEAST y. y \<in> set_vebt t \<and> x < y) \<in> set_vebt t \<and> x < (LEAST y. y \<in> set_vebt t \<and> x < y)
[PROOF STEP]
by (metis (no_types, lifting) LeastI_ex)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; \<forall>xa\<in>set_vebt t. \<not> x < xa\<rbrakk> \<Longrightarrow> vebt_succ t x = None
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar_vebt t n; \<forall>xa\<in>set_vebt t. \<not> x < xa\<rbrakk> \<Longrightarrow> vebt_succ t x = None
[PROOF STEP]
by (meson succ_correct is_succ_in_set_def option.exhaust_sel)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma integrable_real_mult_indicator:
  fixes f :: "'a \<Rightarrow> real"
  shows "A \<in> sets M \<Longrightarrow> integrable M f \<Longrightarrow> integrable M (\<lambda>x. f x * indicator A x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> sets M; integrable M f\<rbrakk> \<Longrightarrow> integrable M (\<lambda>x. f x * indicat_real A x)
[PROOF STEP]
using integrable_mult_indicator[of A M f]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>A \<in> sets M; integrable M f\<rbrakk> \<Longrightarrow> integrable M (\<lambda>x. indicat_real A x *\<^sub>R f x)

goal (1 subgoal):
 1. \<lbrakk>A \<in> sets M; integrable M f\<rbrakk> \<Longrightarrow> integrable M (\<lambda>x. f x * indicat_real A x)
[PROOF STEP]
by (simp add: mult_ac)


[STATEMENT]
lemma eqMinimumI:
  assumes "x \<in> S"
  and "\<And> y. y \<in> S \<Longrightarrow> x \<le> y"
shows "Minimum S = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Minimum S = x
[PROOF STEP]
unfolding Minimum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (THE x. x \<in> S \<and> Ball S ((\<le>) x)) = x
[PROOF STEP]
by (standard, insert assms, auto, fastforce)


[STATEMENT]
theorem not_finite_prime: "infinite {p::nat. prime p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
obtain N k where N: "\<forall>n\<in>- {0}. hypnat_of_nat n dvd N" "k\<in>starprime" "k dvd N + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>N k. \<lbrakk>\<forall>n\<in>- {0}. hypnat_of_nat n dvd N; k \<in> starprime; k dvd N + 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson hyperprime_factor_exists hypnat_add_one_gt_one hypnat_dvd_all_hypnat_of_nat)
[PROOF STATE]
proof (state)
this:
\<forall>n\<in>- {0}. hypnat_of_nat n dvd N
k \<in> starprime
k dvd N + 1

goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>n\<in>- {0}. hypnat_of_nat n dvd N
k \<in> starprime
k dvd N + 1
[PROOF STEP]
have "k \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
\<forall>n\<in>- {0}. hypnat_of_nat n dvd N
k \<in> starprime
k dvd N + 1

goal (1 subgoal):
 1. k \<noteq> 1
[PROOF STEP]
using \<open>k \<in> starprime\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>n\<in>- {0}. hypnat_of_nat n dvd N
k \<in> starprime
k dvd N + 1
k \<in> starprime

goal (1 subgoal):
 1. k \<noteq> 1
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
k \<noteq> 1

goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> 1
[PROOF STEP]
have "k \<notin> hypnat_of_nat ` {p. prime p}"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 1

goal (1 subgoal):
 1. k \<notin> hypnat_of_nat ` {p. prime p}
[PROOF STEP]
using N dvd_add_right_iff hdvd_one_eq_one not_prime_0
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 1
\<forall>n\<in>- {0}. hypnat_of_nat n dvd N
k \<in> starprime
k dvd N + 1
?a dvd ?b \<Longrightarrow> (?a dvd ?b + ?c) = (?a dvd ?c)
is_unit ?x \<Longrightarrow> ?x = 1
\<not> prime (0::?'a)

goal (1 subgoal):
 1. k \<notin> hypnat_of_nat ` {p. prime p}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
k \<notin> hypnat_of_nat ` {p. prime p}

goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<notin> hypnat_of_nat ` {p. prime p}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k \<notin> hypnat_of_nat ` {p. prime p}

goal (1 subgoal):
 1. infinite {p. prime p}
[PROOF STEP]
by (metis \<open>k \<in> starprime\<close> finite_starsetNat_iff starprime_def)
[PROOF STATE]
proof (state)
this:
infinite {p. prime p}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma preimage_range: "preimage f (ran f) = dom f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. preimage f (ran f) = dom f
[PROOF STEP]
by (auto simp add: preimage_def ran_def)


[STATEMENT]
lemma scalar_product_assoc:
  assumes wfm: "mat nr nc m"
  and wfr: "vec nr r"
  and wfc: "vec nc c"
  shows "scalar_prod (map (\<lambda>k. scalar_prod r (col m k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r (col m k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr])
[PROOF STEP]
using wfm wfc
[PROOF STATE]
proof (prove)
using this:
mat nr nc m
vec nc c

goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r (col m k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr])
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
using this:
mat nr nc m
vec nc c

goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr])
[PROOF STEP]
proof (induct m arbitrary: nc c)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
mat nr nc []
vec nc c

goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
hence nc: "nc = 0"
[PROOF STATE]
proof (prove)
using this:
mat nr nc []
vec nc c

goal (1 subgoal):
 1. nc = 0
[PROOF STEP]
unfolding mat_def
[PROOF STATE]
proof (prove)
using this:
length [] = nc \<and> Ball (set []) (vec nr)
vec nc c

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

goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
from wfr
[PROOF STATE]
proof (chain)
picking this:
vec nr r
[PROOF STEP]
have nr: "nr = length r"
[PROOF STATE]
proof (prove)
using this:
vec nr r

goal (1 subgoal):
 1. nr = length r
[PROOF STEP]
unfolding vec_def
[PROOF STATE]
proof (prove)
using this:
length r = nr

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

goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
let ?term = "\<lambda> r :: 'a vec. zip r (map (\<lambda> k. zero) [0..<length r])"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
let ?fun = "\<lambda> (x,y). plus (times x y)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
have "foldr ?fun (?term r) zero = zero"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)
[PROOF STEP]
proof (induct r, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a r. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a) \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (a # r) (map (\<lambda>k. 0::'a) [0..<length (a # r)])) (0::'a) = (0::'a)
[PROOF STEP]
case (Cons d r)
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)

goal (1 subgoal):
 1. \<And>a r. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a) \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (a # r) (map (\<lambda>k. 0::'a) [0..<length (a # r)])) (0::'a) = (0::'a)
[PROOF STEP]
have "foldr ?fun (?term (d # r)) zero = foldr ?fun ( (d,zero) # ?term r) zero"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldr (\<lambda>(x, y). (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a)
[PROOF STEP]
by (simp only: map_replicate_trivial, simp)
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a)

goal (1 subgoal):
 1. \<And>a r. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a) \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (a # r) (map (\<lambda>k. 0::'a) [0..<length (a # r)])) (0::'a) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a)

goal (1 subgoal):
 1. \<And>a r. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a) \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (a # r) (map (\<lambda>k. 0::'a) [0..<length (a # r)])) (0::'a) = (0::'a)
[PROOF STEP]
have "\<dots> = zero"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)

goal (1 subgoal):
 1. foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>(x, y). (+) (x * y)) ((d, 0::'a) # zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)

goal (1 subgoal):
 1. \<And>a r. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a) \<Longrightarrow> foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (a # r) (map (\<lambda>k. 0::'a) [0..<length (a # r)])) (0::'a) = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = (0::'a)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = (0::'a)

goal (1 subgoal):
 1. foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>a. case a of (x, y) \<Rightarrow> (+) (x * y)) (zip (d # r) (map (\<lambda>k. 0::'a) [0..<length (d # r)])) (0::'a) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)

goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
hence "zero = foldr ?fun (zip r (map (\<lambda> k. zero) [0..<nr])) zero"
[PROOF STATE]
proof (prove)
using this:
foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<length r])) (0::'a) = (0::'a)

goal (1 subgoal):
 1. (0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<nr])) (0::'a)
[PROOF STEP]
by (simp add: nr)
[PROOF STATE]
proof (state)
this:
(0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<nr])) (0::'a)

goal (2 subgoals):
 1. \<And>nc c. \<lbrakk>mat nr nc []; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
 2. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
with Nil nc
[PROOF STATE]
proof (chain)
picking this:
mat nr nc []
vec nc c
nc = 0
(0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<nr])) (0::'a)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
mat nr nc []
vec nc c
nc = 0
(0::'a) = foldr (\<lambda>(x, y). (+) (x * y)) (zip r (map (\<lambda>k. 0::'a) [0..<nr])) (0::'a)

goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])
[PROOF STEP]
by (simp add: scalar_prodI_def row_def)
[PROOF STATE]
proof (state)
this:
scalar_prod (map (\<lambda>k. scalar_prod r ([] ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row [] k) c) [0..<nr])

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
case (Cons v m)
[PROOF STATE]
proof (state)
this:
\<lbrakk>mat nr ?nc1 m; vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
mat nr nc (v # m)
vec nc c

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>mat nr ?nc1 m; vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
mat nr nc (v # m)
vec nc c
[PROOF STEP]
obtain ncc where nc: "nc = Suc ncc" and wf: "mat nr ncc m"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>mat nr ?nc1 m; vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
mat nr nc (v # m)
vec nc c

goal (1 subgoal):
 1. (\<And>ncc. \<lbrakk>nc = Suc ncc; mat nr ncc m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding mat_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length m = ?nc1 \<and> Ball (set m) (vec nr); vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
length (v # m) = nc \<and> Ball (set (v # m)) (vec nr)
vec nc c

goal (1 subgoal):
 1. (\<And>ncc. \<lbrakk>nc = Suc ncc; length m = ncc \<and> Ball (set m) (vec nr)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: vec_def)
[PROOF STATE]
proof (state)
this:
nc = Suc ncc
mat nr ncc m

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
from nc \<open>vec nc c\<close>
[PROOF STATE]
proof (chain)
picking this:
nc = Suc ncc
vec nc c
[PROOF STEP]
obtain a cc where c: "c = a # cc" and wfc: "vec ncc cc"
[PROOF STATE]
proof (prove)
using this:
nc = Suc ncc
vec nc c

goal (1 subgoal):
 1. (\<And>a cc. \<lbrakk>c = a # cc; vec ncc cc\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding vec_def
[PROOF STATE]
proof (prove)
using this:
nc = Suc ncc
length c = nc

goal (1 subgoal):
 1. (\<And>a cc. \<lbrakk>c = a # cc; length cc = ncc\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases c, auto)
[PROOF STATE]
proof (state)
this:
c = a # cc
vec ncc cc

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
have rec: "scalar_prod (map (\<lambda> k. scalar_prod r (m ! k)) [0..<ncc]) cc = scalar_prod r (map (\<lambda> k. scalar_prod (row m k) cc) [0..<nr])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<ncc]) cc = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) cc) [0..<nr])
[PROOF STEP]
by (rule Cons, rule wf, rule wfc)
[PROOF STATE]
proof (state)
this:
scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<ncc]) cc = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) cc) [0..<nr])

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
have id: "map (\<lambda>k. scalar_prod r ((v # m) ! k)) [0..<Suc ncc] = scalar_prod r v # map (\<lambda> k. scalar_prod r (m ! k)) [0..<ncc]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. scalar_prod r ((v # m) ! k)) [0..<Suc ncc] = scalar_prod r v # map (\<lambda>k. scalar_prod r (m ! k)) [0..<ncc]
[PROOF STEP]
by (induct ncc, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. scalar_prod r ((v # m) ! k)) [0..<Suc ncc] = scalar_prod r v # map (\<lambda>k. scalar_prod r (m ! k)) [0..<ncc]

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
from wfr
[PROOF STATE]
proof (chain)
picking this:
vec nr r
[PROOF STEP]
have nr: "nr = length r"
[PROOF STATE]
proof (prove)
using this:
vec nr r

goal (1 subgoal):
 1. nr = length r
[PROOF STEP]
unfolding vec_def
[PROOF STATE]
proof (prove)
using this:
length r = nr

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

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
with Cons
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>mat nr ?nc1 m; vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
mat nr nc (v # m)
vec nc c
nr = length r
[PROOF STEP]
have v: "length v = length r"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>mat nr ?nc1 m; vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
mat nr nc (v # m)
vec nc c
nr = length r

goal (1 subgoal):
 1. length v = length r
[PROOF STEP]
unfolding mat_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length m = ?nc1 \<and> Ball (set m) (vec nr); vec ?nc1 ?c1\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<?nc1]) ?c1 = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) ?c1) [0..<nr])
length (v # m) = nc \<and> Ball (set (v # m)) (vec nr)
vec nc c
nr = length r

goal (1 subgoal):
 1. length v = length r
[PROOF STEP]
by (auto simp: vec_def)
[PROOF STATE]
proof (state)
this:
length v = length r

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
have "\<forall> i < nr. vec ncc (row m i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<nr. vec ncc (row m i)
[PROOF STEP]
by (intro allI impI, rule row[OF wf], simp)
[PROOF STATE]
proof (state)
this:
\<forall>i<nr. vec ncc (row m i)

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
obtain tm where tm: "tm = transpose nr m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>tm. tm = Matrix_Legacy.transpose nr m \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tm = Matrix_Legacy.transpose nr m

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
hence idk: "\<forall> k < length r. row m k = tm ! k"
[PROOF STATE]
proof (prove)
using this:
tm = Matrix_Legacy.transpose nr m

goal (1 subgoal):
 1. \<forall>k<length r. row m k = tm ! k
[PROOF STEP]
using col_transpose_is_row[OF wf]
[PROOF STATE]
proof (prove)
using this:
tm = Matrix_Legacy.transpose nr m
?i < nr \<Longrightarrow> col (Matrix_Legacy.transpose nr m) ?i = row m ?i

goal (1 subgoal):
 1. \<forall>k<length r. row m k = tm ! k
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
using this:
tm = Matrix_Legacy.transpose nr m
?i < nr \<Longrightarrow> Matrix_Legacy.transpose nr m ! ?i = row m ?i

goal (1 subgoal):
 1. \<forall>k<length r. row m k = tm ! k
[PROOF STEP]
by (auto simp: nr)
[PROOF STATE]
proof (state)
this:
\<forall>k<length r. row m k = tm ! k

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
hence idtm1: "map (\<lambda>k. scalar_prod (row m k) cc) [0..<length r] = map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]"
    and idtm2: "map (\<lambda>k. plus (times (v ! k) a) (scalar_prod (row m k) cc)) [0..<length r] = map (\<lambda>k. plus (times (v ! k) a) (scalar_prod (tm ! k) cc)) [0..<length r]"
[PROOF STATE]
proof (prove)
using this:
\<forall>k<length r. row m k = tm ! k

goal (1 subgoal):
 1. map (\<lambda>k. scalar_prod (row m k) cc) [0..<length r] = map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r] &&& map (\<lambda>k. v ! k * a + scalar_prod (row m k) cc) [0..<length r] = map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. scalar_prod (row m k) cc) [0..<length r] = map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]
map (\<lambda>k. v ! k * a + scalar_prod (row m k) cc) [0..<length r] = map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
from tm transpose[OF wf]
[PROOF STATE]
proof (chain)
picking this:
tm = Matrix_Legacy.transpose nr m
mat ncc nr (Matrix_Legacy.transpose nr m)
[PROOF STEP]
have "mat ncc nr tm"
[PROOF STATE]
proof (prove)
using this:
tm = Matrix_Legacy.transpose nr m
mat ncc nr (Matrix_Legacy.transpose nr m)

goal (1 subgoal):
 1. mat ncc nr tm
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat ncc nr tm

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
with nr
[PROOF STATE]
proof (chain)
picking this:
nr = length r
mat ncc nr tm
[PROOF STEP]
have "length tm = length r" and  "(\<forall> i < length r. length (tm ! i) = ncc)"
[PROOF STATE]
proof (prove)
using this:
nr = length r
mat ncc nr tm

goal (1 subgoal):
 1. length tm = length r &&& \<forall>i<length r. length (tm ! i) = ncc
[PROOF STEP]
unfolding mat_def
[PROOF STATE]
proof (prove)
using this:
nr = length r
length tm = nr \<and> Ball (set tm) (vec ncc)

goal (1 subgoal):
 1. length tm = length r &&& \<forall>i<length r. length (tm ! i) = ncc
[PROOF STEP]
by (auto simp: vec_def)
[PROOF STATE]
proof (state)
this:
length tm = length r
\<forall>i<length r. length (tm ! i) = ncc

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
with v
[PROOF STATE]
proof (chain)
picking this:
length v = length r
length tm = length r
\<forall>i<length r. length (tm ! i) = ncc
[PROOF STEP]
have main: "plus (times (scalar_prod r v) a) (scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r])) =
    scalar_prod r (map (\<lambda>k. plus (times (v ! k) a) (scalar_prod (tm ! k) cc)) [0..<length r])"
[PROOF STATE]
proof (prove)
using this:
length v = length r
length tm = length r
\<forall>i<length r. length (tm ! i) = ncc

goal (1 subgoal):
 1. scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r])
[PROOF STEP]
proof (induct r arbitrary: v tm)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>v tm. \<lbrakk>length v = length []; length tm = length []; \<forall>i<length []. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod [] v * a + scalar_prod [] (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length []]) = scalar_prod [] (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length []])
 2. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
length v = length []
length tm = length []
\<forall>i<length []. length (tm ! i) = ncc

goal (2 subgoals):
 1. \<And>v tm. \<lbrakk>length v = length []; length tm = length []; \<forall>i<length []. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod [] v * a + scalar_prod [] (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length []]) = scalar_prod [] (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length []])
 2. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
length v = length []
length tm = length []
\<forall>i<length []. length (tm ! i) = ncc

goal (1 subgoal):
 1. scalar_prod [] v * a + scalar_prod [] (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length []]) = scalar_prod [] (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length []])
[PROOF STEP]
by (auto simp: scalar_prodI_def row_def)
[PROOF STATE]
proof (state)
this:
scalar_prod [] v * a + scalar_prod [] (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length []]) = scalar_prod [] (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length []])

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
case (Cons b r)
[PROOF STATE]
proof (state)
this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc
[PROOF STEP]
obtain c vv where v: "v = c # vv" and vvlen: "length vv = length r"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc

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

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
from Cons
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc
[PROOF STEP]
obtain u mm where tm: "tm = u # mm" and mmlen: "length mm = length r"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc

goal (1 subgoal):
 1. (\<And>u mm. \<lbrakk>tm = u # mm; length mm = length r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases tm, auto)
[PROOF STATE]
proof (state)
this:
tm = u # mm
length mm = length r

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
from Cons tm
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc
tm = u # mm
[PROOF STEP]
have argLen: "\<forall> i < length r. length (mm ! i) = ncc"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length ?v1 = length r; length ?tm1 = length r; \<forall>i<length r. length (?tm1 ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r ?v1 * a + scalar_prod r (map (\<lambda>k. scalar_prod (?tm1 ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. ?v1 ! k * a + scalar_prod (?tm1 ! k) cc) [0..<length r])
length v = length (b # r)
length tm = length (b # r)
\<forall>i<length (b # r). length (tm ! i) = ncc
tm = u # mm

goal (1 subgoal):
 1. \<forall>i<length r. length (mm ! i) = ncc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i<length r. length (mm ! i) = ncc

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
have rec: "plus (times (scalar_prod r vv) a) (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) =
     scalar_prod r (map (\<lambda>k. plus (times (vv ! k) a) (scalar_prod (mm ! k) cc)) [0..<length r])"
      (is "plus (times ?rv a) ?recl = ?recr")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
by (rule Cons, auto simp: vvlen mmlen argLen)
[PROOF STATE]
proof (state)
this:
scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
have id: "map (\<lambda>k. scalar_prod ((u # mm) ! k) cc) [0..<length (b # r)] = scalar_prod u cc # map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. scalar_prod ((u # mm) ! k) cc) [0..<length (b # r)] = scalar_prod u cc # map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]
[PROOF STEP]
by (simp, induct r, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. scalar_prod ((u # mm) ! k) cc) [0..<length (b # r)] = scalar_prod u cc # map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
have id2: "map (\<lambda>k. plus (times ((c # vv) ! k) a) (scalar_prod ((u # mm) ! k) cc)) [0..<length (b # r)] =
               (plus (times c a) (scalar_prod u cc)) #
               map (\<lambda>k. plus (times (vv ! k) a) (scalar_prod (mm ! k) cc)) [0..<length r]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>k. (c # vv) ! k * a + scalar_prod ((u # mm) ! k) cc) [0..<length (b # r)] = (c * a + scalar_prod u cc) # map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]
[PROOF STEP]
by (simp, induct r, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>k. (c # vv) ! k * a + scalar_prod ((u # mm) ! k) cc) [0..<length (b # r)] = (c * a + scalar_prod u cc) # map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]

goal (1 subgoal):
 1. \<And>aa r v tm. \<lbrakk>\<And>v tm. \<lbrakk>length v = length r; length tm = length r; \<forall>i<length r. length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r]); length v = length (aa # r); length tm = length (aa # r); \<forall>i<length (aa # r). length (tm ! i) = ncc\<rbrakk> \<Longrightarrow> scalar_prod (aa # r) v * a + scalar_prod (aa # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (aa # r)]) = scalar_prod (aa # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (aa # r)])
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod (b # r) v * a + scalar_prod (b # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (b # r)]) = scalar_prod (b # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (b # r)])
[PROOF STEP]
proof (simp only: v tm, simp only: id, simp only: id2, simp only: scalar_prod_cons)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
let ?uc = "scalar_prod u cc"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
let ?bca = "times (times b c) a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "plus (times (plus (times b c) ?rv) a) (plus (times b ?uc) ?recl) = plus (plus ?bca (times ?rv a)) (plus (times b ?uc) ?recl)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]))
[PROOF STEP]
by (simp add: distrib_right)
[PROOF STATE]
proof (state)
this:
(b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]))

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]))

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "\<dots> = plus (plus ?bca (times ?rv a)) (plus ?recl (times b ?uc))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)
[PROOF STEP]
by (simp add: add.commute)
[PROOF STATE]
proof (state)
this:
b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b * c * a + scalar_prod r vv * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "\<dots> = plus ?bca (plus (plus (times ?rv a) ?recl) (times b ?uc))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)
[PROOF STEP]
by (simp add: add.assoc)
[PROOF STATE]
proof (state)
this:
b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b * c * a + scalar_prod r vv * a + (scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "\<dots> = plus ?bca (plus ?recr (times b ?uc))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)
[PROOF STEP]
by (simp only: rec)
[PROOF STATE]
proof (state)
this:
b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b * c * a + (scalar_prod r vv * a + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc)

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "\<dots> = plus ?bca (plus (times b ?uc) ?recr)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]))
[PROOF STEP]
by (simp add: add.commute)
[PROOF STATE]
proof (state)
this:
b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]))

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b * c * a + (scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]) + b * scalar_prod u cc) = b * c * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r]))

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
have "\<dots> = plus (times b (plus (times c a) ?uc)) ?recr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b * c * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
by (simp add: distrib_left mult.assoc add.assoc)
[PROOF STATE]
proof (state)
this:
b * c * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
show "plus (times (plus (times b c) ?rv) a) (plus (times b ?uc) ?recl) = plus (times b (plus (times c a) ?uc)) ?recr"
[PROOF STATE]
proof (prove)
using this:
(b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])

goal (1 subgoal):
 1. (b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(b * c + scalar_prod r vv) * a + (b * scalar_prod u cc + scalar_prod r (map (\<lambda>k. scalar_prod (mm ! k) cc) [0..<length r])) = b * (c * a + scalar_prod u cc) + scalar_prod r (map (\<lambda>k. vv ! k * a + scalar_prod (mm ! k) cc) [0..<length r])

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
scalar_prod (b # r) v * a + scalar_prod (b # r) (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length (b # r)]) = scalar_prod (b # r) (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length (b # r)])

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
scalar_prod r v * a + scalar_prod r (map (\<lambda>k. scalar_prod (tm ! k) cc) [0..<length r]) = scalar_prod r (map (\<lambda>k. v ! k * a + scalar_prod (tm ! k) cc) [0..<length r])

goal (1 subgoal):
 1. \<And>a m nc c. \<lbrakk>\<And>nc c. \<lbrakk>mat nr nc m; vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r (m ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row m k) c) [0..<nr]); mat nr nc (a # m); vec nc c\<rbrakk> \<Longrightarrow> scalar_prod (map (\<lambda>k. scalar_prod r ((a # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (a # m) k) c) [0..<nr])
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_prod (map (\<lambda>k. scalar_prod r ((v # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (v # m) k) c) [0..<nr])
[PROOF STEP]
by (simp only: c scalar_prod_cons, simp only: nc, simp only: id, simp only: scalar_prod_cons, simp only: rec, simp only: nr, simp only: idtm1 idtm2, simp only: main, simp only: idtm2[symmetric], simp add: row_def scalar_prod_cons)
[PROOF STATE]
proof (state)
this:
scalar_prod (map (\<lambda>k. scalar_prod r ((v # m) ! k)) [0..<nc]) c = scalar_prod r (map (\<lambda>k. scalar_prod (row (v # m) k) c) [0..<nr])

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nrows_diagonal_to_Smith_i[simp]: "nrows (diagonal_to_Smith_i xs A i bezout) = nrows A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nrows (diagonal_to_Smith_i xs A i bezout) = nrows A
[PROOF STEP]
by (induct xs A i bezout rule: diagonal_to_Smith_i.induct, auto simp add: nrows_def)


[STATEMENT]
lemma inf_greatest:
  assumes "A \<subseteq> carrier L" "z \<in> carrier L"
          "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x)"
  shows "z \<sqsubseteq> \<Sqinter>A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<sqsubseteq> \<Sqinter>A
[PROOF STEP]
by (metis Lower_memI assms greatest_le inf_glb)


[STATEMENT]
lemma in_mktop: "(x,y) \<in> mktop L z \<longleftrightarrow> x\<noteq>z \<and> (if y=z then x\<noteq>y else (x,y) \<in> L)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((x, y) \<in> mktop L z) = (x \<noteq> z \<and> (if y = z then x \<noteq> y else (x, y) \<in> L))
[PROOF STEP]
by(auto simp:mktop_def)


[STATEMENT]
lemma polysub_0:
  fixes p::"'a::ring_1 poly"
  shows "isnpolyh p n0 \<Longrightarrow> isnpolyh q n1 \<Longrightarrow> p -\<^sub>p q = 0\<^sub>p \<longleftrightarrow> p = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh p n0; isnpolyh q n1\<rbrakk> \<Longrightarrow> (p -\<^sub>p q = 0\<^sub>p) = (p = q)
[PROOF STEP]
unfolding polysub_def split_def fst_conv snd_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isnpolyh p n0; isnpolyh q n1\<rbrakk> \<Longrightarrow> (p +\<^sub>p ~\<^sub>p q = 0\<^sub>p) = (p = q)
[PROOF STEP]
by (induct p q arbitrary: n0 n1 rule:polyadd.induct)
    (auto simp: Nsub0[simplified Nsub_def] Let_def)


[STATEMENT]
lemma normalize_gcd_left: "gcd (normalize a) b = gcd a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (normalize a) b = gcd a b
[PROOF STEP]
by (fact gcd.normalize_left_idem)


[STATEMENT]
theorem avl_delete_auto:
  "avl t \<Longrightarrow> avl(delete x t)"
  "avl t \<Longrightarrow> height t \<in> {height (delete x t), height (delete x t) + 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (avl t \<Longrightarrow> avl (delete x t)) &&& (avl t \<Longrightarrow> height t \<in> {height (delete x t), height (delete x t) + 1})
[PROOF STEP]
proof (induct t rule: tree2_induct)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
 3. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> avl (delete x \<langle>x1, (a, b), x3\<rangle>)
 4. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> height \<langle>x1, (a, b), x3\<rangle> \<in> {height (delete x \<langle>x1, (a, b), x3\<rangle>), height (delete x \<langle>x1, (a, b), x3\<rangle>) + 1}
[PROOF STEP]
case (Node l a n r)
[PROOF STATE]
proof (state)
this:
avl l \<Longrightarrow> avl (delete x l)
avl l \<Longrightarrow> height l \<in> {height (delete x l), height (delete x l) + 1}
avl r \<Longrightarrow> avl (delete x r)
avl r \<Longrightarrow> height r \<in> {height (delete x r), height (delete x r) + 1}

goal (4 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
 3. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> avl (delete x \<langle>x1, (a, b), x3\<rangle>)
 4. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> height \<langle>x1, (a, b), x3\<rangle> \<in> {height (delete x \<langle>x1, (a, b), x3\<rangle>), height (delete x \<langle>x1, (a, b), x3\<rangle>) + 1}
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:
avl \<langle>l, (a, n), r\<rangle>

goal (4 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
 3. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> avl (delete x \<langle>x1, (a, b), x3\<rangle>)
 4. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> height \<langle>x1, (a, b), x3\<rangle> \<in> {height (delete x \<langle>x1, (a, b), x3\<rangle>), height (delete x \<langle>x1, (a, b), x3\<rangle>) + 1}
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
avl \<langle>l, (a, n), r\<rangle>

goal (1 subgoal):
 1. avl (delete x \<langle>l, (a, n), r\<rangle>)
[PROOF STEP]
using Node avl_split_max[of l]
[PROOF STATE]
proof (prove)
using this:
avl \<langle>l, (a, n), r\<rangle>
avl l \<Longrightarrow> avl (delete x l)
avl l \<Longrightarrow> height l \<in> {height (delete x l), height (delete x l) + 1}
avl r \<Longrightarrow> avl (delete x r)
avl r \<Longrightarrow> height r \<in> {height (delete x r), height (delete x r) + 1}
\<lbrakk>avl l; l \<noteq> \<langle>\<rangle>\<rbrakk> \<Longrightarrow> avl (fst (split_max l)) \<and> height l \<in> {height (fst (split_max l)), height (fst (split_max l)) + 1}

goal (1 subgoal):
 1. avl (delete x \<langle>l, (a, n), r\<rangle>)
[PROOF STEP]
by (auto intro!: avl_balL avl_balR split: prod.split)
[PROOF STATE]
proof (state)
this:
avl (delete x \<langle>l, (a, n), r\<rangle>)

goal (3 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
 3. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> height \<langle>x1, (a, b), x3\<rangle> \<in> {height (delete x \<langle>x1, (a, b), x3\<rangle>), height (delete x \<langle>x1, (a, b), x3\<rangle>) + 1}
[PROOF STEP]
case 2
[PROOF STATE]
proof (state)
this:
avl \<langle>l, (a, n), r\<rangle>

goal (3 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
 3. \<And>x1 a b x3. \<lbrakk>avl x1 \<Longrightarrow> avl (delete x x1); avl x1 \<Longrightarrow> height x1 \<in> {height (delete x x1), height (delete x x1) + 1}; avl x3 \<Longrightarrow> avl (delete x x3); avl x3 \<Longrightarrow> height x3 \<in> {height (delete x x3), height (delete x x3) + 1}; avl \<langle>x1, (a, b), x3\<rangle>\<rbrakk> \<Longrightarrow> height \<langle>x1, (a, b), x3\<rangle> \<in> {height (delete x \<langle>x1, (a, b), x3\<rangle>), height (delete x \<langle>x1, (a, b), x3\<rangle>) + 1}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height \<langle>l, (a, n), r\<rangle> \<in> {height (delete x \<langle>l, (a, n), r\<rangle>), height (delete x \<langle>l, (a, n), r\<rangle>) + 1}
[PROOF STEP]
using 2 Node avl_split_max[of l]
[PROOF STATE]
proof (prove)
using this:
avl \<langle>l, (a, n), r\<rangle>
avl l \<Longrightarrow> avl (delete x l)
avl l \<Longrightarrow> height l \<in> {height (delete x l), height (delete x l) + 1}
avl r \<Longrightarrow> avl (delete x r)
avl r \<Longrightarrow> height r \<in> {height (delete x r), height (delete x r) + 1}
\<lbrakk>avl l; l \<noteq> \<langle>\<rangle>\<rbrakk> \<Longrightarrow> avl (fst (split_max l)) \<and> height l \<in> {height (fst (split_max l)), height (fst (split_max l)) + 1}

goal (1 subgoal):
 1. height \<langle>l, (a, n), r\<rangle> \<in> {height (delete x \<langle>l, (a, n), r\<rangle>), height (delete x \<langle>l, (a, n), r\<rangle>) + 1}
[PROOF STEP]
by auto
         (auto simp: balL_def balR_def max_absorb1 max_absorb2  split!: tree.splits prod.splits if_splits)
[PROOF STATE]
proof (state)
this:
height \<langle>l, (a, n), r\<rangle> \<in> {height (delete x \<langle>l, (a, n), r\<rangle>), height (delete x \<langle>l, (a, n), r\<rangle>) + 1}

goal (2 subgoals):
 1. avl \<langle>\<rangle> \<Longrightarrow> avl (delete x \<langle>\<rangle>)
 2. avl \<langle>\<rangle> \<Longrightarrow> height \<langle>\<rangle> \<in> {height (delete x \<langle>\<rangle>), height (delete x \<langle>\<rangle>) + 1}
[PROOF STEP]
qed simp_all


[STATEMENT]
lemma add_left_neutral:
  fixes a::"'n::mod_type"
  shows "(a + b = a) = (b = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + b = a) = (b = (0::'n))
[PROOF STEP]
by (auto, metis add_left_cancel monoid_add_class.add.right_neutral)


[STATEMENT]
lemma alw_eq_sconst: "(alw (HLD {h}) t) = (t = sconst h)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. alw (HLD {h}) t = (t = sconst h)
[PROOF STEP]
unfolding sconst_alt alw_HLD_iff_streams streams_iff_sset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sset t \<subseteq> {h}) = (sset t = {h})
[PROOF STEP]
using stream.set_sel(1)
[PROOF STATE]
proof (prove)
using this:
shd ?a \<in> sset ?a

goal (1 subgoal):
 1. (sset t \<subseteq> {h}) = (sset t = {h})
[PROOF STEP]
by force


[STATEMENT]
lemma eint_minus_plus'':
  assumes "a - eint c - eint b = eint f"
  shows "a - eint c - eint f =  eint b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a - eint c - eint f = eint b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
a - eint c - eint b = eint f

goal (1 subgoal):
 1. a - eint c - eint f = eint b
[PROOF STEP]
apply(induction a )
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>int. eint int - eint c - eint b = eint f \<Longrightarrow> eint int - eint c - eint f = eint b
 2. \<infinity> - eint c - eint b = eint f \<Longrightarrow> \<infinity> - eint c - eint f = eint b
[PROOF STEP]
apply (metis add.commute add_diff_cancel_eint eint.distinct(2) eint_add_cancel_fact)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<infinity> - eint c - eint b = eint f \<Longrightarrow> \<infinity> - eint c - eint f = eint b
[PROOF STEP]
by simp


[STATEMENT]
lemma homeomorphic_empty_space:
     "X homeomorphic_space Y \<Longrightarrow> topspace X = {} \<longleftrightarrow> topspace Y = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X homeomorphic_space Y \<Longrightarrow> (topspace X = {}) = (topspace Y = {})
[PROOF STEP]
by (metis homeomorphic_imp_surjective_map homeomorphic_space image_is_empty)


[STATEMENT]
lemma rtranclp_mono' :
"r\<^sup>*\<^sup>* a b \<Longrightarrow> r \<le> s \<Longrightarrow> s\<^sup>*\<^sup>* a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>r\<^sup>*\<^sup>* a b; r \<le> s\<rbrakk> \<Longrightarrow> s\<^sup>*\<^sup>* a b
[PROOF STEP]
by (metis rtrancl_mono_proof sup.orderE sup2CI)


[STATEMENT]
lemma efficient_code_aux:
  assumes "n > 0" "set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n" "distinct ps"
  shows   "f n = (\<Prod>(p,d) \<leftarrow> ps. f_prime p ^ Suc d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < n
set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n
distinct ps
[PROOF STEP]
have
    "(\<Prod>(p,d) \<leftarrow> ps. f_prime p ^ Suc d) =
       (\<Prod>(p,d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d)"
[PROOF STATE]
proof (prove)
using this:
0 < n
set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n
distinct ps

goal (1 subgoal):
 1. (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d)
[PROOF STEP]
by (subst prod.distinct_set_conv_list [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d)

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d)

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
have "\<dots> = (\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d) = (\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n)
[PROOF STEP]
by (subst prod.reindex) (auto simp: inj_on_def prime_factors_multiplicity
                                  simp del: power_Suc intro!: prod.cong)
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d) = (\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n)

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime p ^ Suc d) = (\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n)

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
have "\<dots> = f n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n) = f n
[PROOF STEP]
by (rule prod_prime_factors'' [symmetric]) fact+
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>prime_factors n. f_prime x ^ multiplicity x n) = f n

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d) = f n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d) = f n

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime p ^ Suc d)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lcm_self: "lcm a a = normalize a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lcm a a = normalize a
[PROOF STEP]
by (fact lcm.idem_normalize)


[STATEMENT]
lemma (in monoid) group_commutes_pow:
  fixes n::nat
  shows "\<lbrakk>x \<otimes> y = y \<otimes> x; x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x [^] n \<otimes> y = y \<otimes> x [^] n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<otimes> y = y \<otimes> x; x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x [^] n \<otimes> y = y \<otimes> x [^] n
[PROOF STEP]
apply (induction n, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>x [^] n \<otimes> y = y \<otimes> x [^] n; x \<otimes> y = y \<otimes> x; x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x [^] n \<otimes> x \<otimes> y = y \<otimes> (x [^] n \<otimes> x)
[PROOF STEP]
by (metis m_assoc nat_pow_closed)


[STATEMENT]
lemma less_setsD: "\<lbrakk>A \<lless> B; a \<in> A; b \<in> B\<rbrakk> \<Longrightarrow> a < b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<lless> B; a \<in> A; b \<in> B\<rbrakk> \<Longrightarrow> a < b
[PROOF STEP]
by (auto simp: less_sets_def)


[STATEMENT]
lemma real_of_rat_sgn: "sgn (of_rat x) = real_of_rat (sgn x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (real_of_rat x) = real_of_rat (sgn x)
[PROOF STEP]
unfolding sgn_real_def sgn_rat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if real_of_rat x = 0 then 0 else if 0 < real_of_rat x then 1 else - 1) = real_of_rat (if x = 0 then 0 else if 0 < x then 1 else - 1)
[PROOF STEP]
by auto


[STATEMENT]
lemma capped_greatest_fixpoint:
  "y \<le> u \<Longrightarrow> z \<le> v \<Longrightarrow> u * v \<le> v \<Longrightarrow> is_greatest_fixpoint (\<lambda>x . (y * x \<squnion> z) \<sqinter> v) (y\<^sup>\<omega>\<^sub>v \<squnion> y\<^sup>\<star> * z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>y \<le> u; z \<le> v; u * v \<le> v\<rbrakk> \<Longrightarrow> is_greatest_fixpoint (\<lambda>x. (y * x \<squnion> z) \<sqinter> v) (y\<^sup>\<omega>\<^sub>v \<squnion> y\<^sup>\<star> * z)
[PROOF STEP]
by (smt capped_fix order_refl capped_omega_induct is_greatest_fixpoint_def)


[STATEMENT]
lemma sorted_list_of_maximal_sequences_in_tree_MPT[code] :
  "sorted_list_of_maximal_sequences_in_tree (MPT m) =
    (if Mapping.keys m = {}
      then [[]]
      else concat (map (\<lambda>k . map ((#) k) (sorted_list_of_maximal_sequences_in_tree (the (Mapping.lookup m k)))) (sorted_list_of_set (Mapping.keys m))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_maximal_sequences_in_tree (MPT m) = (if Mapping.keys m = {} then [[]] else concat (map (\<lambda>k. map ((#) k) (sorted_list_of_maximal_sequences_in_tree (the (Mapping.lookup m k)))) (sorted_list_of_set (Mapping.keys m))))
[PROOF STEP]
unfolding MPT_def sorted_list_of_maximal_sequences_in_tree.simps keys_dom_lookup
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if dom (Mapping.lookup m) = {} then [[]] else concat (map (\<lambda>k. map ((#) k) (sorted_list_of_maximal_sequences_in_tree (the (Mapping.lookup m k)))) (sorted_list_of_set (dom (Mapping.lookup m))))) = (if dom (Mapping.lookup m) = {} then [[]] else concat (map (\<lambda>k. map ((#) k) (sorted_list_of_maximal_sequences_in_tree (the (Mapping.lookup m k)))) (sorted_list_of_set (dom (Mapping.lookup m)))))
[PROOF STEP]
by simp


[STATEMENT]
theorem straighten_inv:"straighten w1 w2 \<Longrightarrow> (kauff_mat w1) = (kauff_mat w2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. straighten w1 w2 \<Longrightarrow> kauff_mat w1 = kauff_mat w2
[PROOF STEP]
unfolding straighten_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. straighten_topdown w1 w2 \<or> straighten_downtop w1 w2 \<Longrightarrow> kauff_mat w1 = kauff_mat w2
[PROOF STEP]
using straighten_topdown_inv straighten_downtop_inv
[PROOF STATE]
proof (prove)
using this:
straighten_topdown ?w1.0 ?w2.0 \<Longrightarrow> kauff_mat ?w1.0 = kauff_mat ?w2.0
straighten_downtop ?w1.0 ?w2.0 \<Longrightarrow> kauff_mat ?w1.0 = kauff_mat ?w2.0

goal (1 subgoal):
 1. straighten_topdown w1 w2 \<or> straighten_downtop w1 w2 \<Longrightarrow> kauff_mat w1 = kauff_mat w2
[PROOF STEP]
by auto


[STATEMENT]
lemma eq_or_less_helperD:
  "\<lbrakk> n = unat (2 ^ m - 1 :: 'a :: len word) \<or> n < unat (2 ^ m - 1 :: 'a word); m < LENGTH('a) \<rbrakk>
   \<Longrightarrow> n < 2 ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n = unat (2 ^ m - 1) \<or> n < unat (2 ^ m - 1); m < LENGTH('a)\<rbrakk> \<Longrightarrow> n < 2 ^ m
[PROOF STEP]
by (meson le_less_trans nat_less_le unat_less_power word_power_less_1)


[STATEMENT]
lemma lm029:
  assumes "a1 \<in> injectionsUniverse"
          "a2 \<in> injectionsUniverse"
          "(Range a1) \<inter> (Range a2)={}"
          "(Domain a1) \<inter> (Domain a2) = {}"
  shows "a1 \<union> a2 \<in> injectionsUniverse"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a1 \<union> a2 \<in> injectionsUniverse
[PROOF STEP]
using assms disj_Un_runiq
[PROOF STATE]
proof (prove)
using this:
a1 \<in> injectionsUniverse
a2 \<in> injectionsUniverse
Range a1 \<inter> Range a2 = {}
Domain a1 \<inter> Domain a2 = {}
\<lbrakk>runiq ?P; runiq ?Q; Domain ?P \<inter> Domain ?Q = {}\<rbrakk> \<Longrightarrow> runiq (?P \<union> ?Q)

goal (1 subgoal):
 1. a1 \<union> a2 \<in> injectionsUniverse
[PROOF STEP]
by (metis (no_types) Domain_converse converse_Un mem_Collect_eq)


[STATEMENT]
lemma pow_generator_mod: "\<^bold>g [^] (k mod order G) = \<^bold>g [^] k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
proof(cases "order G > 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
 2. \<not> 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 < order G

goal (2 subgoals):
 1. 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
 2. \<not> 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
obtain n where n: "k = n * order G + k mod order G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. k = n * order G + k mod order G \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis div_mult_mod_eq)
[PROOF STATE]
proof (state)
this:
k = n * order G + k mod order G

goal (2 subgoals):
 1. 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
 2. \<not> 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
have "\<^bold>g [^] k = (\<^bold>g [^] order G) [^] n \<otimes> \<^bold>g [^] (k mod order G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<^bold>g [^] k = (\<^bold>g [^] order G) [^] n \<otimes> \<^bold>g [^] (k mod order G)
[PROOF STEP]
by(subst n)(simp add: nat_pow_mult nat_pow_pow mult_ac)
[PROOF STATE]
proof (state)
this:
\<^bold>g [^] k = (\<^bold>g [^] order G) [^] n \<otimes> \<^bold>g [^] (k mod order G)

goal (2 subgoals):
 1. 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
 2. \<not> 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<^bold>g [^] k = (\<^bold>g [^] order G) [^] n \<otimes> \<^bold>g [^] (k mod order G)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<^bold>g [^] k = (\<^bold>g [^] order G) [^] n \<otimes> \<^bold>g [^] (k mod order G)

goal (1 subgoal):
 1. \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
by(simp add: generator_pow_order)
[PROOF STATE]
proof (state)
this:
\<^bold>g [^] (k mod order G) = \<^bold>g [^] k

goal (1 subgoal):
 1. \<not> 0 < order G \<Longrightarrow> \<^bold>g [^] (k mod order G) = \<^bold>g [^] k
[PROOF STEP]
qed simp


[STATEMENT]
lemma mat_gt_trans: assumes sd: "sd \<le> n" and AB: "mat_gt gt sd A B" and BC: "mat_gt gt sd B C"
  and A: "A \<in> carrier_mat n n" and B: "B \<in> carrier_mat n n"
shows "mat_gt gt sd A C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_gt (\<succ>) sd A C
[PROOF STEP]
using mat_ge_gt_trans[OF sd mat_gt_imp_mat_ge[OF AB] BC A B]
[PROOF STATE]
proof (prove)
using this:
mat_gt (\<succ>) sd A C

goal (1 subgoal):
 1. mat_gt (\<succ>) sd A C
[PROOF STEP]
.


[STATEMENT]
lemma \<nu>_fin_eq_Pn: "\<nu>_fin n s = (\<Sum>i<n. l^i * measure_pmf.expectation (Pn' p s i) r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<nu>_fin n s = (\<Sum>i<n. l ^ i * measure_pmf.expectation (Pn' p s i) r)
[PROOF STEP]
by (induction n; simp add: Pn'_eq_\<T> integral_distr)


[STATEMENT]
lemma image_flatten_ideal: "flatten ` ideal F = ideal (flatten ` F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. flatten ` ideal F = ideal (flatten ` F)
[PROOF STEP]
using flatten_plus flatten_times surj_flatten
[PROOF STATE]
proof (prove)
using this:
flatten (?p + ?q) = flatten ?p + flatten ?q
flatten (?p * ?q) = flatten ?p * flatten ?q
surj flatten

goal (1 subgoal):
 1. flatten ` ideal F = ideal (flatten ` F)
[PROOF STEP]
by (rule image_ideal_eq_surj)


[STATEMENT]
theorem (in abelian_subgroup) a_factorgroup_is_comm_group: "comm_group (G A_Mod H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comm_group (G A_Mod H)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. comm_group (G A_Mod H)
[PROOF STEP]
have "Group.comm_monoid_axioms (G A_Mod H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.comm_monoid_axioms (G A_Mod H)
[PROOF STEP]
apply (rule comm_monoid_axioms.intro)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> carrier (G A_Mod H); y \<in> carrier (G A_Mod H)\<rbrakk> \<Longrightarrow> x \<otimes>\<^bsub>G A_Mod H\<^esub> y = y \<otimes>\<^bsub>G A_Mod H\<^esub> x
[PROOF STEP]
apply (auto simp: A_FactGroup_def FactGroup_def RCOSETS_def a_normal add.m_comm normal.rcos_sum)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
Group.comm_monoid_axioms (G A_Mod H)

goal (1 subgoal):
 1. comm_group (G A_Mod H)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Group.comm_monoid_axioms (G A_Mod H)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Group.comm_monoid_axioms (G A_Mod H)

goal (1 subgoal):
 1. comm_group (G A_Mod H)
[PROOF STEP]
by (intro comm_group.intro comm_monoid.intro) (simp_all add: a_factorgroup_is_group group.is_monoid)
[PROOF STATE]
proof (state)
this:
comm_group (G A_Mod H)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infinite_Ord_omega: "Ord \<alpha> \<Longrightarrow> infinite (elts \<alpha>) \<Longrightarrow> \<omega> \<le> \<alpha>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ord \<alpha>; infinite (elts \<alpha>)\<rbrakk> \<Longrightarrow> \<omega> \<le> \<alpha>
[PROOF STEP]
by (meson Ord_\<omega> Ord_linear2 Ord_mem_iff_lt finite_Ord_omega)


[STATEMENT]
lemma  cross_rotation_matrix: "rotation_matrix A \<Longrightarrow> (A *v x) \<times> (A *v y) =  A *v (x \<times> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotation_matrix A \<Longrightarrow> (A *v x) \<times> (A *v y) = A *v x \<times> y
[PROOF STEP]
by (simp add: rotation_matrix_def cross_orthogonal_matrix)


[STATEMENT]
lemma iter_tensor_mult_distr:
  assumes "n \<ge> 1" and "dim_col A = dim_row B" and "dim_col A > 0" and "dim_col B > 0"
  shows "(A \<otimes>\<^bsup>(Suc n)\<^esup>) * (B \<otimes>\<^bsup>(Suc n)\<^esup>) = (A * B) \<Otimes> ((A \<otimes>\<^bsup>n\<^esup>) * (B \<otimes>\<^bsup>n\<^esup>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
have "(A \<otimes>\<^bsup>(Suc n)\<^esup>) * (B \<otimes>\<^bsup>(Suc n)\<^esup>) = (A \<Otimes> (A \<otimes>\<^bsup>n\<^esup>)) * (B \<Otimes> (B \<otimes>\<^bsup>n\<^esup>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)
[PROOF STEP]
using Suc_le_D assms(1)
[PROOF STATE]
proof (prove)
using this:
Suc ?n \<le> ?m' \<Longrightarrow> \<exists>m. ?m' = Suc m
1 \<le> n

goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)

goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)
[PROOF STEP]
show "?thesis"
[PROOF STATE]
proof (prove)
using this:
A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)

goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
using mult_distr_tensor[of "A" "B" "(iter_tensor A n)" "(iter_tensor B n)"] assms
[PROOF STATE]
proof (prove)
using this:
A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)
\<lbrakk>dim_col A = dim_row B; dim_col (A \<otimes>\<^bsup>n\<^esup>) = dim_row (B \<otimes>\<^bsup>n\<^esup>); 0 < dim_col A; 0 < dim_col B; 0 < dim_col (A \<otimes>\<^bsup>n\<^esup>); 0 < dim_col (B \<otimes>\<^bsup>n\<^esup>)\<rbrakk> \<Longrightarrow> A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup> = (A \<Otimes> A \<otimes>\<^bsup>n\<^esup>) * (B \<Otimes> B \<otimes>\<^bsup>n\<^esup>)
1 \<le> n
dim_col A = dim_row B
0 < dim_col A
0 < dim_col B

goal (1 subgoal):
 1. A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A \<otimes>\<^bsup>Suc n\<^esup> * B \<otimes>\<^bsup>Suc n\<^esup> = A * B \<Otimes> A \<otimes>\<^bsup>n\<^esup> * B \<otimes>\<^bsup>n\<^esup>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma \<omega>_gt1 [simp]: "\<omega> > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < \<omega>
[PROOF STEP]
by (simp add: OrdmemD one_V_def)


[STATEMENT]
lemma combine_union_sets_alt:
  fixes X Y
  defines "Z \<equiv> X \<union> {x. x \<in> Y \<and> set x \<inter> \<Union>(set ` X) = {}}"
  assumes "\<forall>xs \<in> Y. \<forall>ys \<in> Y. xs = ys \<or> set xs \<inter> set ys = {}"
      and "\<forall>xs \<in> X. \<forall>ys \<in> X. xs = ys \<or> set xs \<inter> set ys = {}"
    shows "Z = X \<union> (Y - {x. set x \<inter> \<Union>(set ` X) \<noteq> {}})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z = X \<union> (Y - {x. set x \<inter> \<Union> (set ` X) \<noteq> {}})
[PROOF STEP]
unfolding assms(1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X \<union> {x \<in> Y. set x \<inter> \<Union> (set ` X) = {}} = X \<union> (Y - {x. set x \<inter> \<Union> (set ` X) \<noteq> {}})
[PROOF STEP]
using assms(2,3)
[PROOF STATE]
proof (prove)
using this:
\<forall>xs\<in>Y. \<forall>ys\<in>Y. xs = ys \<or> set xs \<inter> set ys = {}
\<forall>xs\<in>X. \<forall>ys\<in>X. xs = ys \<or> set xs \<inter> set ys = {}

goal (1 subgoal):
 1. X \<union> {x \<in> Y. set x \<inter> \<Union> (set ` X) = {}} = X \<union> (Y - {x. set x \<inter> \<Union> (set ` X) \<noteq> {}})
[PROOF STEP]
by fast


[STATEMENT]
lemma sqrt_lower_bound_2_large:
  assumes "0 \<le> x"
    shows "32*x*(x + 16)*(x^2 + 96*x + 256) / (x^4 + 448*x^3 + 17920*x^2 + 114688*x + 65536) \<le> sqrt x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 32 * x * (x + 16) * (x\<^sup>2 + 96 * x + 256) / (x ^ 4 + 448 * x ^ 3 + 17920 * x\<^sup>2 + 114688 * x + 65536) \<le> sqrt x
[PROOF STEP]
apply (rule order_trans [OF eq_refl gen_sqrt_lower_scaled [of x "1/4" 2]])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. 32 * x * (x + 16) * (x\<^sup>2 + 96 * x + 256) / (x ^ 4 + 448 * x ^ 3 + 17920 * x\<^sup>2 + 114688 * x + 65536) = sqrtl (x * (1 / 4)\<^sup>2) 2 / (1 / 4)
 2. 0 \<le> x
 3. 0 < 1 / 4
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> x

goal (3 subgoals):
 1. 32 * x * (x + 16) * (x\<^sup>2 + 96 * x + 256) / (x ^ 4 + 448 * x ^ 3 + 17920 * x\<^sup>2 + 114688 * x + 65536) = sqrtl (x * (1 / 4)\<^sup>2) 2 / (1 / 4)
 2. 0 \<le> x
 3. 0 < 1 / 4
[PROOF STEP]
apply (auto simp: sqrtl_2_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> 32 * x * (x + 16) * (x\<^sup>2 + 96 * x + 256) / (x ^ 4 + 448 * x ^ 3 + 17920 * x\<^sup>2 + 114688 * x + 65536) = 32 * (x * ((1 / 4)\<^sup>2 * ((x * (1 / 4)\<^sup>2 + 1) * ((x * (1 / 4)\<^sup>2)\<^sup>2 + 6 * (x * (1 / 4)\<^sup>2) + 1)))) / ((x * (1 / 4)\<^sup>2) ^ 4 + 28 * (x * (1 / 4)\<^sup>2) ^ 3 + 70 * (x * (1 / 4)\<^sup>2)\<^sup>2 + 28 * (x * (1 / 4)\<^sup>2) + 1)
[PROOF STEP]
apply (simp add: divide_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nonpos_Reals_mult_I1: "\<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> a * b \<in> \<real>\<^sub>\<le>\<^sub>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> \<real>\<^sub>\<ge>\<^sub>0; b \<in> \<real>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> a * b \<in> \<real>\<^sub>\<le>\<^sub>0
[PROOF STEP]
by (metis nonneg_Reals_mult_I mult_minus_right uminus_nonneg_Reals_iff)


[STATEMENT]
lemma lotteries_on_subset:
  assumes "A \<subseteq> B"
  shows "lotteries_on A \<subseteq> lotteries_on B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lotteries_on A \<subseteq> lotteries_on B
[PROOF STEP]
by (metis (no_types, lifting) Collect_mono assms gfp.leq_trans lotteries_on_def)