[STATEMENT]
lemma to_fun_sub:
  assumes "g \<in> carrier P"
  assumes "f \<in> carrier P"
  assumes "a \<in> carrier R"
  shows "to_fun (f of  g) a = (to_fun f) (to_fun g a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R f g) a = to_fun f (to_fun g a)
[PROOF STEP]
proof(rule poly_induct2[of f])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f \<in> carrier P
 2. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
 3. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
show "f \<in> carrier P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> carrier P
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier P
f \<in> carrier P
a \<in> carrier R

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

goal (2 subgoals):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
 2. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
show "\<And>p. p \<in> carrier P \<Longrightarrow> degree p = 0 \<Longrightarrow> to_fun (p of g) a = to_fun p (to_fun g a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
assume A0: "p \<in> carrier P"
[PROOF STATE]
proof (state)
this:
p \<in> carrier P

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
assume A1: "degree p = 0"
[PROOF STATE]
proof (state)
this:
deg R p = 0

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
deg R p = 0
[PROOF STEP]
have P0: "degree (p of g) = 0"
[PROOF STATE]
proof (prove)
using this:
deg R p = 0

goal (1 subgoal):
 1. deg R (Cring_Poly.compose R p g) = 0
[PROOF STEP]
by (simp add: A0 assms(1) sub_const)
[PROOF STATE]
proof (state)
this:
deg R (Cring_Poly.compose R p g) = 0

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
deg R (Cring_Poly.compose R p g) = 0
[PROOF STEP]
obtain b where b_def: "p of g = to_poly b \<and> b \<in> carrier R"
[PROOF STATE]
proof (prove)
using this:
deg R (Cring_Poly.compose R p g) = 0

goal (1 subgoal):
 1. (\<And>b. Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using A0 A1 cfs_closed assms(1) to_poly_inverse
[PROOF STATE]
proof (prove)
using this:
deg R (Cring_Poly.compose R p g) = 0
p \<in> carrier P
deg R p = 0
?f \<in> carrier P \<Longrightarrow> ?f ?n \<in> carrier R
g \<in> carrier P
\<lbrakk>?f \<in> carrier P; deg R ?f = 0\<rbrakk> \<Longrightarrow> ?f = to_polynomial R (?f 0)

goal (1 subgoal):
 1. (\<And>b. Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson sub_closed)
[PROOF STATE]
proof (state)
this:
Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R
[PROOF STEP]
have "to_fun (p of g) a = b"
[PROOF STATE]
proof (prove)
using this:
Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = b
[PROOF STEP]
by (simp add: assms(3) to_fun_to_poly)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = b

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
have "p of g = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cring_Poly.compose R p g = p
[PROOF STEP]
using A0 A1 P_def sub_const UP_cring_axioms assms(1)
[PROOF STATE]
proof (prove)
using this:
p \<in> carrier P
deg R p = 0
P \<equiv> UP R
\<lbrakk>?g \<in> carrier P; ?f \<in> carrier P; deg R ?f = 0\<rbrakk> \<Longrightarrow> Cring_Poly.compose R ?f ?g = ?f
UP_cring R
g \<in> carrier P

goal (1 subgoal):
 1. Cring_Poly.compose R p g = p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Cring_Poly.compose R p g = p

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Cring_Poly.compose R p g = p
[PROOF STEP]
have P1: "p = to_poly b"
[PROOF STATE]
proof (prove)
using this:
Cring_Poly.compose R p g = p

goal (1 subgoal):
 1. p = to_polynomial R b
[PROOF STEP]
using b_def
[PROOF STATE]
proof (prove)
using this:
Cring_Poly.compose R p g = p
Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R

goal (1 subgoal):
 1. p = to_polynomial R b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p = to_polynomial R b

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
have "to_fun g a \<in> carrier R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_fun g a \<in> carrier R
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
g \<in> carrier P
f \<in> carrier P
a \<in> carrier R

goal (1 subgoal):
 1. to_fun g a \<in> carrier R
[PROOF STEP]
by (simp add: to_fun_closed)
[PROOF STATE]
proof (state)
this:
to_fun g a \<in> carrier R

goal (1 subgoal):
 1. \<And>p. \<lbrakk>p \<in> carrier P; deg R p = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_fun g a \<in> carrier R
[PROOF STEP]
show "to_fun (p of g) a =  to_fun p (to_fun g a)"
[PROOF STATE]
proof (prove)
using this:
to_fun g a \<in> carrier R

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
using P1 \<open>to_fun (p of g) a = b\<close> b_def
[PROOF STATE]
proof (prove)
using this:
to_fun g a \<in> carrier R
p = to_polynomial R b
to_fun (Cring_Poly.compose R p g) a = b
Cring_Poly.compose R p g = to_polynomial R b \<and> b \<in> carrier R

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
by (simp add: to_fun_to_poly)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?p1 \<in> carrier P; deg R ?p1 = 0\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R ?p1 g) a = to_fun ?p1 (to_fun g a)

goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
show "\<And>p. 0 < degree p \<Longrightarrow> p \<in> carrier P \<Longrightarrow>
            to_fun (trunc p of g) a = to_fun (trunc p) (to_fun g a) \<Longrightarrow>
            to_fun (p of g) a = to_fun p (to_fun g a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
assume A0: "0 < degree p"
[PROOF STATE]
proof (state)
this:
0 < deg R p

goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
assume A1: " p \<in> carrier P"
[PROOF STATE]
proof (state)
this:
p \<in> carrier P

goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
assume A2: "to_fun (trunc p of g) a = to_fun (trunc p) (to_fun g a)"
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)

goal (1 subgoal):
 1. \<And>p. \<lbrakk>0 < deg R p; p \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
show "to_fun (p of g) a = to_fun p (to_fun g a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
have "p of g = (trunc p) of g \<oplus>\<^bsub>P\<^esub> (ltrm p) of g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cring_Poly.compose R p g = Cring_Poly.compose R (Cring_Poly.truncate R p) g \<oplus>\<^bsub>P\<^esub> Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g
[PROOF STEP]
by (metis A1 assms(1) ltrm_closed sub_add trunc_simps(1) trunc_closed)
[PROOF STATE]
proof (state)
this:
Cring_Poly.compose R p g = Cring_Poly.compose R (Cring_Poly.truncate R p) g \<oplus>\<^bsub>P\<^esub> Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Cring_Poly.compose R p g = Cring_Poly.compose R (Cring_Poly.truncate R p) g \<oplus>\<^bsub>P\<^esub> Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g
[PROOF STEP]
have "to_fun (p of g) a = to_fun ((trunc p) of g) a \<oplus> (to_fun ((ltrm p) of g) a)"
[PROOF STATE]
proof (prove)
using this:
Cring_Poly.compose R p g = Cring_Poly.compose R (Cring_Poly.truncate R p) g \<oplus>\<^bsub>P\<^esub> Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a
[PROOF STEP]
by (simp add: A1 assms(1) assms(3) to_fun_plus ltrm_closed sub_closed trunc_closed)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a
[PROOF STEP]
have 0: "to_fun (p of g) a = to_fun (trunc p) (to_fun g a) \<oplus> (to_fun ((ltrm p) of g) a)"
[PROOF STATE]
proof (prove)
using this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.compose R (Cring_Poly.truncate R p) g) a \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a
[PROOF STEP]
by (simp add: A2)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
have "(to_fun ((ltrm p) of g) a) = to_fun (ltrm p) (to_fun g a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
using to_fun_sub_monom
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_UP_monom ?f; ?g \<in> carrier P; ?a \<in> carrier R\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R ?f ?g) ?a = to_fun ?f (to_fun ?g ?a)

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
by (simp add: A1 assms(1) assms(3) ltrm_is_UP_monom)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
have "to_fun (p of g) a = to_fun (trunc p) (to_fun g a) \<oplus>  to_fun (ltrm p) (to_fun g a)"
[PROOF STATE]
proof (prove)
using this:
to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
using 0
[PROOF STATE]
proof (prove)
using this:
to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a = to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (Cring_Poly.compose R (monom P (p (deg R p)) (deg R p)) g) a

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
to_fun (Cring_Poly.compose R p g) a = to_fun (Cring_Poly.truncate R p) (to_fun g a) \<oplus> to_fun (monom P (p (deg R p)) (deg R p)) (to_fun g a)

goal (1 subgoal):
 1. to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)
[PROOF STEP]
by (metis A1 assms(1) assms(3) to_fun_closed to_fun_plus ltrm_closed trunc_simps(1) trunc_closed)
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
to_fun (Cring_Poly.compose R p g) a = to_fun p (to_fun g a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < deg R ?p1; ?p1 \<in> carrier P; to_fun (Cring_Poly.compose R (Cring_Poly.truncate R ?p1) g) a = to_fun (Cring_Poly.truncate R ?p1) (to_fun g a)\<rbrakk> \<Longrightarrow> to_fun (Cring_Poly.compose R ?p1 g) a = to_fun ?p1 (to_fun g a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tmap_eq_TCons_conv:
  "tmap f g xs = TCons y ys \<longleftrightarrow>
  (\<exists>z zs. xs = TCons z zs \<and> f z = y \<and> tmap f g zs = ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (tmap f g xs = TCons y ys) = (\<exists>z zs. xs = TCons z zs \<and> f z = y \<and> tmap f g zs = ys)
[PROOF STEP]
by(cases xs) simp_all


[STATEMENT]
lemma cont_ccTTree1:
  "cont (\<lambda> S. ccTTree S G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cont (\<lambda>S. ccTTree S G)
[PROOF STEP]
apply (rule contI2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. monofun (\<lambda>S. ccTTree S G)
 2. \<And>Y. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G)\<rbrakk> \<Longrightarrow> ccTTree (\<Squnion>i. Y i) G \<sqsubseteq> (\<Squnion>i. ccTTree (Y i) G)
[PROOF STEP]
apply (rule monofunI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x y. x \<sqsubseteq> y \<Longrightarrow> ccTTree x G \<sqsubseteq> ccTTree y G
 2. \<And>Y. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G)\<rbrakk> \<Longrightarrow> ccTTree (\<Squnion>i. Y i) G \<sqsubseteq> (\<Squnion>i. ccTTree (Y i) G)
[PROOF STEP]
apply (erule ccTTree_mono1[folded below_set_def])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Y. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G)\<rbrakk> \<Longrightarrow> ccTTree (\<Squnion>i. Y i) G \<sqsubseteq> (\<Squnion>i. ccTTree (Y i) G)
[PROOF STEP]
apply (rule ttree_belowI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Y xs. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G); xs \<in> paths (ccTTree (\<Squnion>i. Y i) G)\<rbrakk> \<Longrightarrow> xs \<in> paths (\<Squnion>i. ccTTree (Y i) G)
[PROOF STEP]
apply (simp add: paths_Either lub_set lub_is_either)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Y xs. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G); xs \<in> valid_lists (\<Union> (range Y)) G\<rbrakk> \<Longrightarrow> xs = [] \<or> (\<exists>x. xs \<in> valid_lists (Y x) G)
[PROOF STEP]
apply (drule (1) valid_lists_chain1[rotated])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Y xs. \<lbrakk>chain Y; chain (\<lambda>i. ccTTree (Y i) G); \<exists>i. xs \<in> valid_lists (Y i) G\<rbrakk> \<Longrightarrow> xs = [] \<or> (\<exists>x. xs \<in> valid_lists (Y x) G)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prv_eqv_refl: "\<phi> \<in> fmla \<Longrightarrow> prv (eqv \<phi> \<phi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> \<in> fmla \<Longrightarrow> prv (eqv \<phi> \<phi>)
[PROOF STEP]
by (simp add: prv_cnjI prv_imp_refl eqv_def)


[STATEMENT]
lemma infinite_lessThan_int: "infinite {..<(n::int)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite {..<n}
[PROOF STEP]
apply (simp only: atMost_remove[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite ({..n} - {n})
[PROOF STEP]
apply (rule Diff_infinite_finite[OF singleton_finite])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite {..n}
[PROOF STEP]
apply (rule infinite_atMost_int)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma contour_integrable_neg_iff:
  "(\<lambda>x. -f x) contour_integrable_on g \<longleftrightarrow> f contour_integrable_on g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. - f x) contour_integrable_on g) = (f contour_integrable_on g)
[PROOF STEP]
using contour_integrable_neg[of f g] contour_integrable_neg[of "\<lambda>x. -f x" g]
[PROOF STATE]
proof (prove)
using this:
f contour_integrable_on g \<Longrightarrow> (\<lambda>x. - f x) contour_integrable_on g
(\<lambda>x. - f x) contour_integrable_on g \<Longrightarrow> (\<lambda>x. - (- f x)) contour_integrable_on g

goal (1 subgoal):
 1. ((\<lambda>x. - f x) contour_integrable_on g) = (f contour_integrable_on g)
[PROOF STEP]
by auto


[STATEMENT]
lemma pmf_transition_of_st_mat[simp]: "pmf (transition_of_st_mat A a) i = st_mat A $ i $ a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (transition_of_st_mat A a) i = st_mat A $h i $h a
[PROOF STEP]
unfolding transition_of_st_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (pmf_of_st_vec (transition_vec_of_st_mat A a)) i = st_mat A $h i $h a
[PROOF STEP]
by (transfer, auto simp: measure_def)


[STATEMENT]
lemma inv_rbt_join: "inv_12 l \<Longrightarrow> inv_12 r \<Longrightarrow> inv_12 (rbt_join l a b r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inv_12 l; inv_12 r\<rbrakk> \<Longrightarrow> inv_12 (rbt_join l a b r)
[PROOF STEP]
by (auto simp: rbt_join_def Let_def inv1l_rbt_joinL inv1l_rbt_joinR
      inv2_rbt_joinL inv2_rbt_joinR inv_12_def)


[STATEMENT]
lemma symmetric_point_uniqueness:
  assumes "P Midpoint A P1" and
    "P Midpoint A P2"
  shows "P1 = P2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P1 = P2
[PROOF STEP]
by (metis Midpoint_def assms(1) assms(2) between_cong_3 cong_diff_4 cong_inner_transitivity)


[STATEMENT]
lemma word_less_minus_cancel: "y - x < z - x \<Longrightarrow> x \<le> z \<Longrightarrow> y < z"
  for x y z :: "'a::len word"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>y - x < z - x; x \<le> z\<rbrakk> \<Longrightarrow> y < z
[PROOF STEP]
by uint_arith


[STATEMENT]
lemma vrestr_image:
  assumes "x \<in> f--`A"
  shows "x \<in> space M" "f x \<in> space M" "f x \<in> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> space M &&& f x \<in> space M &&& f x \<in> A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> f --` A

goal (1 subgoal):
 1. x \<in> space M &&& f x \<in> space M &&& f x \<in> A
[PROOF STEP]
unfolding vimage_restr_def
[PROOF STATE]
proof (prove)
using this:
x \<in> f -` (A \<inter> space M) \<inter> space M

goal (1 subgoal):
 1. x \<in> space M &&& f x \<in> space M &&& f x \<in> A
[PROOF STEP]
by auto


[STATEMENT]
lemma pcompose_prod: "pcompose (prod f A) p = prod (\<lambda>i. pcompose (f i) p) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod f A \<circ>\<^sub>p p = (\<Prod>i\<in>A. f i \<circ>\<^sub>p p)
[PROOF STEP]
by (induct A rule: infinite_finite_induct) (simp_all add: pcompose_1 pcompose_mult)


[STATEMENT]
lemma last_index_less_size_conv:
  "(last_index xs x < size xs) = (x : set xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (last_index xs x < length xs) = (x \<in> set xs)
[PROOF STEP]
by(simp add: last_index_def Let_def index_size_conv length_pos_if_in_set
        del:length_greater_0_conv)


[STATEMENT]
lemma fpxs_X_power_0 [simp]: "fpxs_X_power 0 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fpxs_X_power 0 = 1
[PROOF STEP]
by transfer auto


[STATEMENT]
lemma support_impl_in: "G e \<longrightarrow> support (\<lambda>l s.  H e l s) \<subseteq> T
  \<Longrightarrow> support (\<lambda>l s. G e \<longrightarrow>  H e l s) \<subseteq> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. G e \<longrightarrow> support (H e) \<subseteq> T \<Longrightarrow> support (\<lambda>l s. G e \<longrightarrow> H e l s) \<subseteq> T
[PROOF STEP]
unfolding support_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. G e \<longrightarrow> {x. \<exists>l1 l2 s. (\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y) \<and> H e l1 s \<noteq> H e l2 s} \<subseteq> T \<Longrightarrow> {x. \<exists>l1 l2 s. (\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y) \<and> (G e \<longrightarrow> H e l1 s) \<noteq> (G e \<longrightarrow> H e l2 s)} \<subseteq> T
[PROOF STEP]
apply(auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x l1 l2 s. \<lbrakk>\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y; {x. \<exists>l1 l2. (\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y) \<and> (\<exists>s. H e l1 s = (\<not> H e l2 s))} \<subseteq> T; G e; \<not> H e l2 s; H e l1 s\<rbrakk> \<Longrightarrow> x \<in> T
 2. \<And>x l1 l2 s. \<lbrakk>\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y; {x. \<exists>l1 l2. (\<forall>y. y \<noteq> x \<longrightarrow> l1 y = l2 y) \<and> (\<exists>s. H e l1 s = (\<not> H e l2 s))} \<subseteq> T; x \<notin> T; G e; \<not> H e l1 s; H e l2 s\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply blast+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma temp_dyn_up_real_arith:
  assumes "a > 0" and Thyps: "Tmin \<le> T" "T \<le> Tmax" "Tmax < (L::real)"
    and thyps: "0 \<le> t" "\<forall>\<tau>\<in>{0..t}. \<tau> \<le> - (ln ((L - Tmax) / (L - T)) / a) "
  shows "L - Tmax \<le> exp (-(a * t)) * (L - T)"
    and "L - exp (-(a * t)) * (L - T) \<le> Tmax"
    and "Tmin \<le> L - exp (-(a * t)) * (L - T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T) &&& L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax &&& Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
have "0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)
[PROOF STEP]
using thyps
[PROOF STATE]
proof (prove)
using this:
0 \<le> t
\<forall>\<tau>\<in>{0..t}. \<tau> \<le> - (ln ((L - Tmax) / (L - T)) / a)

goal (1 subgoal):
 1. 0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
hence "ln ((L - Tmax) / (L - T)) \<le> - a * t \<and> - a * t \<le> 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)

goal (1 subgoal):
 1. ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0
[PROOF STEP]
using assms(1) divide_le_cancel
[PROOF STATE]
proof (prove)
using this:
0 \<le> t \<and> t \<le> - (ln ((L - Tmax) / (L - T)) / a)
0 < a
(?a / ?c \<le> ?b / ?c) = (((0::?'a) < ?c \<longrightarrow> ?a \<le> ?b) \<and> (?c < (0::?'a) \<longrightarrow> ?b \<le> ?a))

goal (1 subgoal):
 1. ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
have "(L - Tmax) / (L - T) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < (L - Tmax) / (L - T)
[PROOF STEP]
using Thyps
[PROOF STATE]
proof (prove)
using this:
Tmin \<le> T
T \<le> Tmax
Tmax < L

goal (1 subgoal):
 1. 0 < (L - Tmax) / (L - T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < (L - Tmax) / (L - T)

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0
0 < (L - Tmax) / (L - T)
[PROOF STEP]
have "(L - Tmax) / (L - T) \<le> exp (-a * t) \<and> exp (-a * t) \<le> 1"
[PROOF STATE]
proof (prove)
using this:
ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0
0 < (L - Tmax) / (L - T)

goal (1 subgoal):
 1. (L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1
[PROOF STEP]
using exp_ln exp_le_one_iff
[PROOF STATE]
proof (prove)
using this:
ln ((L - Tmax) / (L - T)) \<le> - a \<cdot> t \<and> - a \<cdot> t \<le> 0
0 < (L - Tmax) / (L - T)
0 < ?x \<Longrightarrow> exp (ln ?x) = ?x
(exp ?x \<le> 1) = (?x \<le> 0)

goal (1 subgoal):
 1. (L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1
[PROOF STEP]
by (metis exp_less_cancel_iff not_less)
[PROOF STATE]
proof (state)
this:
(L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
have "L - T > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < L - T
[PROOF STEP]
using Thyps
[PROOF STATE]
proof (prove)
using this:
Tmin \<le> T
T \<le> Tmax
Tmax < L

goal (1 subgoal):
 1. 0 < L - T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < L - T

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1
0 < L - T
[PROOF STEP]
have obs: "(L - Tmax) \<le> exp (-a * t) * (L - T) \<and> exp (-a * t) * (L - T) \<le> (L - T)"
[PROOF STATE]
proof (prove)
using this:
(L - Tmax) / (L - T) \<le> exp (- a \<cdot> t) \<and> exp (- a \<cdot> t) \<le> 1
0 < L - T

goal (1 subgoal):
 1. L - Tmax \<le> exp (- a \<cdot> t) \<cdot> (L - T) \<and> exp (- a \<cdot> t) \<cdot> (L - T) \<le> L - T
[PROOF STEP]
by (simp add: pos_divide_le_eq)
[PROOF STATE]
proof (state)
this:
L - Tmax \<le> exp (- a \<cdot> t) \<cdot> (L - T) \<and> exp (- a \<cdot> t) \<cdot> (L - T) \<le> L - T

goal (3 subgoals):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
 2. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 3. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
thus "(L - Tmax) \<le> exp (-(a * t)) * (L - T)"
[PROOF STATE]
proof (prove)
using this:
L - Tmax \<le> exp (- a \<cdot> t) \<cdot> (L - T) \<and> exp (- a \<cdot> t) \<cdot> (L - T) \<le> L - T

goal (1 subgoal):
 1. L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)

goal (2 subgoals):
 1. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
 2. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
thus "L - exp (-(a * t)) * (L - T) \<le> Tmax"
[PROOF STATE]
proof (prove)
using this:
L - Tmax \<le> exp (- (a \<cdot> t)) \<cdot> (L - T)

goal (1 subgoal):
 1. L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
L - exp (- (a \<cdot> t)) \<cdot> (L - T) \<le> Tmax

goal (1 subgoal):
 1. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
show "Tmin \<le> L - exp (-(a * t)) * (L - T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
using Thyps and obs
[PROOF STATE]
proof (prove)
using this:
Tmin \<le> T
T \<le> Tmax
Tmax < L
L - Tmax \<le> exp (- a \<cdot> t) \<cdot> (L - T) \<and> exp (- a \<cdot> t) \<cdot> (L - T) \<le> L - T

goal (1 subgoal):
 1. Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Tmin \<le> L - exp (- (a \<cdot> t)) \<cdot> (L - T)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_wrt_linorder_index_less_iff:
  assumes "linorder_on A R" "set xs \<subseteq> A" "sorted_wrt R xs"
          "x \<in> set xs" "y \<in> set xs"
  shows   "index xs x < index xs y \<longleftrightarrow> (y,x) \<notin> R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (index xs x < index xs y) = ((y, x) \<notin> R)
[PROOF STEP]
by (subst sorted_wrt_linorder_index_le_iff[OF assms(1-3) assms(5,4), symmetric]) auto


[STATEMENT]
lemma less_eq_funI [intro?]:
  assumes "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m"
  shows "f \<lesssim> g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<lesssim> g
[PROOF STEP]
unfolding less_eq_fun_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m
[PROOF STEP]
by (rule assms)


[STATEMENT]
lemma elem_index_inj:
  assumes "elem_index x = elem_index y"
  shows "x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
using inj_elem_index assms
[PROOF STATE]
proof (prove)
using this:
inj elem_index
elem_index x = elem_index y

goal (1 subgoal):
 1. x = y
[PROOF STEP]
by (rule injD)


[STATEMENT]
lemma nextMax_max[intro]:
  assumes "finite x" "v \<in> x"
  shows "v < nextMax x" "v \<le> nextMax x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v < nextMax x &&& v \<le> nextMax x
[PROOF STEP]
using Max.coboundedI[OF assms] assms(2)
[PROOF STATE]
proof (prove)
using this:
v \<le> Max x
v \<in> x

goal (1 subgoal):
 1. v < nextMax x &&& v \<le> nextMax x
[PROOF STEP]
unfolding nextMax_def
[PROOF STATE]
proof (prove)
using this:
v \<le> Max x
v \<in> x

goal (1 subgoal):
 1. v < (if x = {} then 0 else Suc (Max x)) &&& v \<le> (if x = {} then 0 else Suc (Max x))
[PROOF STEP]
by auto


[STATEMENT]
lemma primepow_cases:
  "primepow d \<longleftrightarrow>
     (  primepow_even d \<and> \<not> primepow_odd d \<and> \<not> prime d) \<or>
     (\<not> primepow_even d \<and>   primepow_odd d \<and> \<not> prime d) \<or>
     (\<not> primepow_even d \<and> \<not> primepow_odd d \<and>   prime d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primepow d = (primepow_even d \<and> \<not> primepow_odd d \<and> \<not> prime d \<or> \<not> primepow_even d \<and> primepow_odd d \<and> \<not> prime d \<or> \<not> primepow_even d \<and> \<not> primepow_odd d \<and> prime d)
[PROOF STEP]
by (auto simp: primepow_even_altdef primepow_odd_altdef multiplicity_aprimedivisor_Suc_0_iff
           elim!: oddE intro!: Nat.gr0I)


[STATEMENT]
lemma sum_length_partition_by_median:
  assumes "(l, m, r) = partition_by_median k ps"
  shows "length ps = length l + length r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ps = length l + length r
[PROOF STEP]
using assms sum_length_filter_compl[of "(\<lambda>p. p $ k \<le> axis_median k ps)"]
[PROOF STATE]
proof (prove)
using this:
(l, m, r) = partition_by_median k ps
length (filter (\<lambda>p. p $ k \<le> axis_median k ps) ?xs) + length (filter (\<lambda>x. \<not> x $ k \<le> axis_median k ps) ?xs) = length ?xs

goal (1 subgoal):
 1. length ps = length l + length r
[PROOF STEP]
unfolding partition_by_median_def
[PROOF STATE]
proof (prove)
using this:
(l, m, r) = (let m = axis_median k ps; (l, r) = partition (\<lambda>p. p $ k \<le> m) ps in (l, m, r))
length (filter (\<lambda>p. p $ k \<le> axis_median k ps) ?xs) + length (filter (\<lambda>x. \<not> x $ k \<le> axis_median k ps) ?xs) = length ?xs

goal (1 subgoal):
 1. length ps = length l + length r
[PROOF STEP]
by (simp add: Let_def o_def)


[STATEMENT]
lemma UINF_upto_expand_first:
  "m < n \<Longrightarrow> (\<Sqinter> i \<in> {m..<n} \<bullet> P(i)) = ((P(m) :: '\<alpha> upred) \<or> (\<Sqinter> i \<in> {Suc m..<n} \<bullet> P(i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < n \<Longrightarrow> (\<Sqinter> i \<in> {m..<n} \<bullet> P i) = (P m \<or> (\<Sqinter> i \<in> {Suc m..<n} \<bullet> P i))
[PROOF STEP]
apply (rel_auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b x. \<lbrakk>\<lbrakk>P x\<rbrakk>\<^sub>e b; m \<le> x; x < n; \<forall>x\<ge>Suc m. \<lbrakk>P x\<rbrakk>\<^sub>e b \<longrightarrow> \<not> x < n\<rbrakk> \<Longrightarrow> \<lbrakk>P m\<rbrakk>\<^sub>e b
[PROOF STEP]
using Suc_leI le_eq_less_or_eq
[PROOF STATE]
proof (prove)
using this:
?m < ?n \<Longrightarrow> Suc ?m \<le> ?n
(?m \<le> ?n) = (?m < ?n \<or> ?m = ?n)

goal (1 subgoal):
 1. \<And>b x. \<lbrakk>\<lbrakk>P x\<rbrakk>\<^sub>e b; m \<le> x; x < n; \<forall>x\<ge>Suc m. \<lbrakk>P x\<rbrakk>\<^sub>e b \<longrightarrow> \<not> x < n\<rbrakk> \<Longrightarrow> \<lbrakk>P m\<rbrakk>\<^sub>e b
[PROOF STEP]
by auto


[STATEMENT]
lemma lm021:
  assumes "finite X" "mx \<in> X" "\<forall>x \<in> X-{mx}. f x < f mx"
  shows "argmax f X \<subseteq> {mx}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. argmax f X \<subseteq> {mx}
[PROOF STEP]
using assms mk_disjoint_insert
[PROOF STATE]
proof (prove)
using this:
finite X
mx \<in> X
\<forall>x\<in>X - {mx}. f x < f mx
?a \<in> ?A \<Longrightarrow> \<exists>B. ?A = insert ?a B \<and> ?a \<notin> B

goal (1 subgoal):
 1. argmax f X \<subseteq> {mx}
[PROOF STEP]
by force


[STATEMENT]
theorem sorted_ghc_sort:
  "sorted (ghc_sort xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (ghc_sort xs)
[PROOF STEP]
unfolding ghc_sort_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (merge_list [] (map (\<lambda>ys. if decr ys then rev ys else ys) (cuts xs)))
[PROOF STEP]
using reverse_phase_sorted
[PROOF STATE]
proof (prove)
using this:
Ball (set (map (\<lambda>ys. if decr ys then rev ys else ys) (cuts ?xs))) sorted

goal (1 subgoal):
 1. sorted (merge_list [] (map (\<lambda>ys. if decr ys then rev ys else ys) (cuts xs)))
[PROOF STEP]
by (intro merge_list_correct[THEN conjunct1]) auto


[STATEMENT]
lemma weak_ranking_of_weak_ranking:
  assumes "is_finite_weak_ranking xs"
  shows   "weak_ranking (of_weak_ranking xs) = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weak_ranking (of_weak_ranking xs) = xs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. weak_ranking (of_weak_ranking xs) = xs
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
is_finite_weak_ranking xs
[PROOF STEP]
interpret finite_total_preorder_on "\<Union>(set xs)" "of_weak_ranking xs"
[PROOF STATE]
proof (prove)
using this:
is_finite_weak_ranking xs

goal (1 subgoal):
 1. finite_total_preorder_on (\<Union> (set xs)) (of_weak_ranking xs)
[PROOF STEP]
by (intro finite_total_preorder_of_weak_ranking) simp_all
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. weak_ranking (of_weak_ranking xs) = xs
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
is_finite_weak_ranking xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
is_finite_weak_ranking xs

goal (1 subgoal):
 1. weak_ranking (of_weak_ranking xs) = xs
[PROOF STEP]
by (intro sym[OF weak_ranking_unique]) (simp_all add: is_finite_weak_ranking_def)
[PROOF STATE]
proof (state)
this:
weak_ranking (of_weak_ranking xs) = xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in ordered_comm_monoid_add) positive_sum:
  assumes X : "finite X"
      and "f : X \<rightarrow> { y :: 'a. y \<ge> 0 }"
  shows "sum f X \<ge> 0 \<and> (sum f X = 0 \<longrightarrow> f ` X \<subseteq> {0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite X
f \<in> X \<rightarrow> {y. (0::'a) \<le> y}

goal (1 subgoal):
 1. (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
[PROOF STEP]
proof (induct set:finite)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
case (insert x X)
[PROOF STATE]
proof (state)
this:
finite X
x \<notin> X
f \<in> X \<rightarrow> {a. (0::'a) \<le> a} \<Longrightarrow> (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
f \<in> insert x X \<rightarrow> {a. (0::'a) \<le> a}

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
hence x0: "f x \<ge> 0" and sum0: "sum f X \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
finite X
x \<notin> X
f \<in> X \<rightarrow> {a. (0::'a) \<le> a} \<Longrightarrow> (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
f \<in> insert x X \<rightarrow> {a. (0::'a) \<le> a}

goal (1 subgoal):
 1. (0::'a) \<le> f x &&& (0::'a) \<le> sum f X
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> f x
(0::'a) \<le> sum f X

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
hence "sum f (insert x X) \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<le> f x
(0::'a) \<le> sum f X

goal (1 subgoal):
 1. (0::'a) \<le> sum f (insert x X)
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<le> f x
(0::'a) \<le> sum f X
finite X
x \<notin> X
f \<in> X \<rightarrow> {a. (0::'a) \<le> a} \<Longrightarrow> (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
f \<in> insert x X \<rightarrow> {a. (0::'a) \<le> a}

goal (1 subgoal):
 1. (0::'a) \<le> sum f (insert x X)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> sum f (insert x X)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> sum f (insert x X)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> sum f (insert x X)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
assume "sum f (insert x X) = 0"
[PROOF STATE]
proof (state)
this:
sum f (insert x X) = (0::'a)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
hence "f x = 0" "sum f X = 0"
[PROOF STATE]
proof (prove)
using this:
sum f (insert x X) = (0::'a)

goal (1 subgoal):
 1. f x = (0::'a) &&& sum f X = (0::'a)
[PROOF STEP]
using sum0 x0 insert add_nonneg_eq_0_iff
[PROOF STATE]
proof (prove)
using this:
sum f (insert x X) = (0::'a)
(0::'a) \<le> sum f X
(0::'a) \<le> f x
finite X
x \<notin> X
f \<in> X \<rightarrow> {a. (0::'a) \<le> a} \<Longrightarrow> (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
f \<in> insert x X \<rightarrow> {a. (0::'a) \<le> a}
\<lbrakk>(0::'a) \<le> ?x; (0::'a) \<le> ?y\<rbrakk> \<Longrightarrow> (?x + ?y = (0::'a)) = (?x = (0::'a) \<and> ?y = (0::'a))

goal (1 subgoal):
 1. f x = (0::'a) &&& sum f X = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f x = (0::'a)
sum f X = (0::'a)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
sum f (insert x X) = (0::'a) \<Longrightarrow> f x = (0::'a)
sum f (insert x X) = (0::'a) \<Longrightarrow> sum f X = (0::'a)

goal (2 subgoals):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f \<in> F \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f F \<and> (sum f F = (0::'a) \<longrightarrow> f ` F \<subseteq> {0::'a}); f \<in> insert x F \<rightarrow> Collect ((\<le>) (0::'a))\<rbrakk> \<Longrightarrow> (0::'a) \<le> sum f (insert x F) \<and> (sum f (insert x F) = (0::'a) \<longrightarrow> f ` insert x F \<subseteq> {0::'a})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(0::'a) \<le> sum f (insert x X)
sum f (insert x X) = (0::'a) \<Longrightarrow> f x = (0::'a)
sum f (insert x X) = (0::'a) \<Longrightarrow> sum f X = (0::'a)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<le> sum f (insert x X)
sum f (insert x X) = (0::'a) \<Longrightarrow> f x = (0::'a)
sum f (insert x X) = (0::'a) \<Longrightarrow> sum f X = (0::'a)

goal (1 subgoal):
 1. (0::'a) \<le> sum f (insert x X) \<and> (sum f (insert x X) = (0::'a) \<longrightarrow> f ` insert x X \<subseteq> {0::'a})
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
(0::'a) \<le> sum f (insert x X)
sum f (insert x X) = (0::'a) \<Longrightarrow> f x = (0::'a)
sum f (insert x X) = (0::'a) \<Longrightarrow> sum f X = (0::'a)
finite X
x \<notin> X
f \<in> X \<rightarrow> {a. (0::'a) \<le> a} \<Longrightarrow> (0::'a) \<le> sum f X \<and> (sum f X = (0::'a) \<longrightarrow> f ` X \<subseteq> {0::'a})
f \<in> insert x X \<rightarrow> {a. (0::'a) \<le> a}

goal (1 subgoal):
 1. (0::'a) \<le> sum f (insert x X) \<and> (sum f (insert x X) = (0::'a) \<longrightarrow> f ` insert x X \<subseteq> {0::'a})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(0::'a) \<le> sum f (insert x X) \<and> (sum f (insert x X) = (0::'a) \<longrightarrow> f ` insert x X \<subseteq> {0::'a})

goal (1 subgoal):
 1. f \<in> {} \<rightarrow> Collect ((\<le>) (0::'a)) \<Longrightarrow> (0::'a) \<le> sum f {} \<and> (sum f {} = (0::'a) \<longrightarrow> f ` {} \<subseteq> {0::'a})
[PROOF STEP]
qed auto


[STATEMENT]
lemma cat_obj_prod_2_ex_is_iso_arr:
  assumes "\<pi> : P <\<^sub>C\<^sub>F\<^sub>.\<^sub>\<times> {a,b} : 2\<^sub>C \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>"
    and "\<pi>' : P' <\<^sub>C\<^sub>F\<^sub>.\<^sub>\<times> {a,b} : 2\<^sub>C \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>"
  obtains f where "f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P" and "\<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
interpret \<pi>: is_cat_obj_prod_2 \<alpha> a b \<CC> P \<pi>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi> : P <\<^sub>C\<^sub>F\<^sub>.\<^sub>\<times> {a,b} : 2\<^sub>C \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>
[PROOF STEP]
by (rule assms(1))
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
interpret \<pi>': is_cat_obj_prod_2 \<alpha> a b \<CC> P' \<pi>'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>' : P' <\<^sub>C\<^sub>F\<^sub>.\<^sub>\<times> {a,b} : 2\<^sub>C \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>
[PROOF STEP]
by (rule assms(2))
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from that
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> ?f\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?f : P' \<mapsto>\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<CC>\<^esub> P; \<pi>' = \<pi> \<bullet>\<^sub>N\<^sub>T\<^sub>S\<^sub>M\<^sub>C\<^sub>F ntcf_const (:\<^sub>C (2\<^sub>\<nat>)) \<CC> ?f\<rbrakk> \<Longrightarrow> thesis

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by
      (
        elim cat_obj_prod_ex_is_iso_arr[
          OF \<pi>.is_cat_obj_prod_axioms \<pi>'.is_cat_obj_prod_axioms
          ]
      )
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_Gauss_Jordan_det_P:
fixes A::"'a::{field}^'n::{mod_type}^'n::{mod_type}"
shows "(fst (Gauss_Jordan_det_P A)) * det A = det (snd (Gauss_Jordan_det_P A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (Gauss_Jordan_det_P A) * det A = det (snd (Gauss_Jordan_det_P A))
[PROOF STEP]
using det_Gauss_Jordan_upt_k_det_P
[PROOF STATE]
proof (prove)
using this:
fst (Gauss_Jordan_upt_k_det_P ?A ?k) * det ?A = det (snd (Gauss_Jordan_upt_k_det_P ?A ?k))

goal (1 subgoal):
 1. fst (Gauss_Jordan_det_P A) * det A = det (snd (Gauss_Jordan_det_P A))
[PROOF STEP]
unfolding Gauss_Jordan_det_P_def
[PROOF STATE]
proof (prove)
using this:
fst (Gauss_Jordan_upt_k_det_P ?A ?k) * det ?A = det (snd (Gauss_Jordan_upt_k_det_P ?A ?k))

goal (1 subgoal):
 1. fst (Gauss_Jordan_upt_k_det_P A (ncols A - 1)) * det A = det (snd (Gauss_Jordan_upt_k_det_P A (ncols A - 1)))
[PROOF STEP]
by simp


[STATEMENT]
theorem well_defined_vec_mat_Tensor:
"(mat (row_length M) (length M) M) \<Longrightarrow>
                  (mat
                    ((row_length M)*(length v))
                    (length M)
                           (vec_mat_Tensor v M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
proof(induct M)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
mat (row_length []) (length []) []

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "(vec_mat_Tensor v []) = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_mat_Tensor v [] = []
[PROOF STEP]
using vec_mat_Tensor.simps(1) Nil
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor ?xs [] = []
mat (row_length []) (length []) []

goal (1 subgoal):
 1. vec_mat_Tensor v [] = []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_mat_Tensor v [] = []

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
vec_mat_Tensor v [] = []

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "(row_length [] = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_length [] = 0
[PROOF STEP]
using row_length_def Nil
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
mat (row_length []) (length []) []

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

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
row_length [] = 0

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "(length []) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length [] = 0
[PROOF STEP]
using Nil
[PROOF STATE]
proof (prove)
using this:
mat (row_length []) (length []) []

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

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
vec_mat_Tensor v [] = []
row_length [] = 0
length [] = 0
[PROOF STEP]
have
       "mat ((row_length [])*(length v)) (length []) (vec_mat_Tensor v [])"
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor v [] = []
row_length [] = 0
length [] = 0

goal (1 subgoal):
 1. mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
[PROOF STEP]
using zero_matrix
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor v [] = []
row_length [] = 0
length [] = 0
mat 0 0 []

goal (1 subgoal):
 1. mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
[PROOF STEP]
by (metis mult_zero_left)
[PROOF STATE]
proof (state)
this:
mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])

goal (2 subgoals):
 1. mat (row_length []) (length []) [] \<Longrightarrow> mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
 2. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])

goal (1 subgoal):
 1. mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat (row_length [] * length v) (length []) (vec_mat_Tensor v [])

goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
fix a M
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
assume hyp :
   "(mat (row_length M) (length M) M
           \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M))"
   "mat (row_length (a#M)) (length (a#M)) (a#M)"
[PROOF STATE]
proof (state)
this:
mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
mat (row_length (a # M)) (length (a # M)) (a # M)

goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
let ?case =
   "mat (row_length (a#M) * length v) (length (a#M)) (vec_mat_Tensor v (a#M))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have step1: "mat (row_length M) (length M) M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length M) (length M) M
[PROOF STEP]
using hyp(2) reduct_matrix
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M)) (length (a # M)) (a # M)
mat (row_length (?a # ?M)) (length (?a # ?M)) (?a # ?M) \<Longrightarrow> mat (row_length ?M) (length ?M) ?M

goal (1 subgoal):
 1. mat (row_length M) (length M) M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length M) (length M) M

goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length M) (length M) M
[PROOF STEP]
have step2:
    "mat (row_length M * length v) (length M) (vec_mat_Tensor v M)"
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M

goal (1 subgoal):
 1. mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
using hyp(1)
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M
mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)

goal (1 subgoal):
 1. mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)

goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have
   "mat
        (row_length (a#M) * length v)
        (length (a#M))
             (vec_mat_Tensor v (a#M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
proof (cases M)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
M = []

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 1:"(vec_mat_Tensor v (a#M)) = [vec_vec_Tensor v a]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_mat_Tensor v (a # M) = [vec_vec_Tensor v a]
[PROOF STEP]
using vec_mat_Tensor.simps Nil
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor ?xs [] = []
vec_mat_Tensor ?xs (?ys # ?yss) = vec_vec_Tensor ?xs ?ys # vec_mat_Tensor ?xs ?yss
M = []

goal (1 subgoal):
 1. vec_mat_Tensor v (a # M) = [vec_vec_Tensor v a]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_mat_Tensor v (a # M) = [vec_vec_Tensor v a]

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have   "(x \<in> (set [vec_vec_Tensor v a])) \<longrightarrow>  x = (vec_vec_Tensor v a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a
[PROOF STEP]
using set_def
[PROOF STATE]
proof (prove)
using this:
set \<equiv> ctor_fold_list (\<lambda>z. set1_pre_list z \<union> \<Union> (set2_pre_list z))

goal (1 subgoal):
 1. x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a
[PROOF STEP]
have 2:
        "(x \<in> (set [vec_vec_Tensor v a]))
                    \<longrightarrow> (vec (length (vec_vec_Tensor v a)) x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a

goal (1 subgoal):
 1. x \<in> set [vec_vec_Tensor v a] \<longrightarrow> vec (length (vec_vec_Tensor v a)) x
[PROOF STEP]
using vec_def
[PROOF STATE]
proof (prove)
using this:
x \<in> set [vec_vec_Tensor v a] \<longrightarrow> x = vec_vec_Tensor v a
vec ?n ?x = (length ?x = ?n)

goal (1 subgoal):
 1. x \<in> set [vec_vec_Tensor v a] \<longrightarrow> vec (length (vec_vec_Tensor v a)) x
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x \<in> set [vec_vec_Tensor v a] \<longrightarrow> vec (length (vec_vec_Tensor v a)) x

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 3:"length (vec_vec_Tensor v a) = (length v)*(length a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length v * length a
[PROOF STEP]
using vec_vec_Tensor_length
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor ?x ?y) = length ?x * length ?y

goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length v * length a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (vec_vec_Tensor v a) = length v * length a

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (vec_vec_Tensor v a) = length v * length a
[PROOF STEP]
have 4:
        "length (vec_vec_Tensor v a) = (length v)*(row_length (a#M))"
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor v a) = length v * length a

goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length v * row_length (a # M)
[PROOF STEP]
using row_length_def  list.distinct(1)
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor v a) = length v * length a
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
[] \<noteq> ?x21.0 # ?x22.0

goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length v * row_length (a # M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (vec_vec_Tensor v a) = length v * row_length (a # M)

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 6: "length (vec_mat_Tensor v (a#M)) = (length (a#M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (vec_mat_Tensor v (a # M)) = length (a # M)
[PROOF STEP]
using vec_mat_Tensor_length
[PROOF STATE]
proof (prove)
using this:
length (vec_mat_Tensor ?xs ?ys) = length ?ys

goal (1 subgoal):
 1. length (vec_mat_Tensor v (a # M)) = length (a # M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
hence "mat (length (vec_vec_Tensor v a)) (length (a # M)) [vec_vec_Tensor v a]"
[PROOF STATE]
proof (prove)
using this:
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (1 subgoal):
 1. mat (length (vec_vec_Tensor v a)) (length (a # M)) [vec_vec_Tensor v a]
[PROOF STEP]
by (simp add: Nil mat_def vec_def)
[PROOF STATE]
proof (state)
this:
mat (length (vec_vec_Tensor v a)) (length (a # M)) [vec_vec_Tensor v a]

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
hence
        "mat (row_length (a#M) * length v)
             (length (vec_mat_Tensor v (a#M)))
             (vec_mat_Tensor v (a#M))"
[PROOF STATE]
proof (prove)
using this:
mat (length (vec_vec_Tensor v a)) (length (a # M)) [vec_vec_Tensor v a]

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))
[PROOF STEP]
using 1 4 6
[PROOF STATE]
proof (prove)
using this:
mat (length (vec_vec_Tensor v a)) (length (a # M)) [vec_vec_Tensor v a]
vec_mat_Tensor v (a # M) = [vec_vec_Tensor v a]
length (vec_vec_Tensor v a) = length v * row_length (a # M)
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))

goal (2 subgoals):
 1. M = [] \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
 2. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
using 6
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M) * length v) (length (vec_mat_Tensor v (a # M))) (vec_mat_Tensor v (a # M))
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
case (Cons b L)
[PROOF STATE]
proof (state)
this:
M = b # L

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 1:"x \<in> (set (a#M)) \<longrightarrow> ((x=a) \<or> (x \<in> (set M)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> x = a \<or> x \<in> set M
[PROOF STEP]
using hd_set
[PROOF STATE]
proof (prove)
using this:
?x \<in> set (?a # ?M) \<Longrightarrow> ?x = ?a \<or> ?x \<in> set ?M

goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> x = a \<or> x \<in> set M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (a # M) \<longrightarrow> x = a \<or> x \<in> set M

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "mat (row_length (a#M)) (length (a#M)) (a#M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length (a # M)) (length (a # M)) (a # M)
[PROOF STEP]
using hyp
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
mat (row_length (a # M)) (length (a # M)) (a # M)

goal (1 subgoal):
 1. mat (row_length (a # M)) (length (a # M)) (a # M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M)) (length (a # M)) (a # M)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length (a # M)) (length (a # M)) (a # M)
[PROOF STEP]
have "x\<in> (set (a#M)) \<longrightarrow> (vec (row_length (a#M)) x)"
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M)) (length (a # M)) (a # M)

goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x
[PROOF STEP]
using mat_def Ball_def
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M)) (length (a # M)) (a # M)
mat ?nr ?nc ?m = (length ?m = ?nc \<and> Ball (set ?m) (vec ?nr))
Ball ?A ?P = (\<forall>x. x \<in> ?A \<longrightarrow> ?P x)

goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x
[PROOF STEP]
have "x\<in> (set (a#M))\<longrightarrow> (vec (length a) x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x

goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> vec (length a) x
[PROOF STEP]
using row_length_def  list.distinct(1)
[PROOF STATE]
proof (prove)
using this:
x \<in> set (a # M) \<longrightarrow> vec (row_length (a # M)) x
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
[] \<noteq> ?x21.0 # ?x22.0

goal (1 subgoal):
 1. x \<in> set (a # M) \<longrightarrow> vec (length a) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (a # M) \<longrightarrow> vec (length a) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
with 1
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (a # M) \<longrightarrow> x = a \<or> x \<in> set M
x \<in> set (a # M) \<longrightarrow> vec (length a) x
[PROOF STEP]
have "x\<in> (set M)\<longrightarrow> (vec (length a) x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (a # M) \<longrightarrow> x = a \<or> x \<in> set M
x \<in> set (a # M) \<longrightarrow> vec (length a) x

goal (1 subgoal):
 1. x \<in> set M \<longrightarrow> vec (length a) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set M \<longrightarrow> vec (length a) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x \<in> set M \<longrightarrow> vec (length a) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have " b \<in> (set M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<in> set M
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
M = b # L

goal (1 subgoal):
 1. b \<in> set M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b \<in> set M

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x \<in> set M \<longrightarrow> vec (length a) x
b \<in> set M
[PROOF STEP]
have "vec (length a) b"
[PROOF STATE]
proof (prove)
using this:
x \<in> set M \<longrightarrow> vec (length a) x
b \<in> set M

goal (1 subgoal):
 1. vec (length a) b
[PROOF STEP]
using  hyp(2) in_set_member mat_def member_rec(1) vec_def
[PROOF STATE]
proof (prove)
using this:
x \<in> set M \<longrightarrow> vec (length a) x
b \<in> set M
mat (row_length (a # M)) (length (a # M)) (a # M)
(?x \<in> set ?xs) = List.member ?xs ?x
mat ?nr ?nc ?m = (length ?m = ?nc \<and> Ball (set ?m) (vec ?nr))
List.member (?x # ?xs) ?y = (?x = ?y \<or> List.member ?xs ?y)
vec ?n ?x = (length ?x = ?n)

goal (1 subgoal):
 1. vec (length a) b
[PROOF STEP]
by (metis)
[PROOF STATE]
proof (state)
this:
vec (length a) b

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec (length a) b
[PROOF STEP]
have "(length b) = (length a)"
[PROOF STATE]
proof (prove)
using this:
vec (length a) b

goal (1 subgoal):
 1. length b = length a
[PROOF STEP]
using vec_def vec_uniqueness
[PROOF STATE]
proof (prove)
using this:
vec (length a) b
vec ?n ?x = (length ?x = ?n)
\<lbrakk>vec ?m ?v; vec ?n ?v\<rbrakk> \<Longrightarrow> ?m = ?n

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

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length b = length a
[PROOF STEP]
have 2:"row_length M = (length a)"
[PROOF STATE]
proof (prove)
using this:
length b = length a

goal (1 subgoal):
 1. row_length M = length a
[PROOF STEP]
using row_length_def   Cons list.distinct(1)
[PROOF STATE]
proof (prove)
using this:
length b = length a
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
M = b # L
[] \<noteq> ?x21.0 # ?x22.0

goal (1 subgoal):
 1. row_length M = length a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row_length M = length a

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "mat (row_length M * length v) (length M) (vec_mat_Tensor v M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
using step2
[PROOF STATE]
proof (prove)
using this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)

goal (1 subgoal):
 1. mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
[PROOF STEP]
have 3:
          "Ball (set (vec_mat_Tensor v M)) (vec ((row_length M)*(length v)))"
[PROOF STATE]
proof (prove)
using this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)

goal (1 subgoal):
 1. Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))
[PROOF STEP]
using mat_def
[PROOF STATE]
proof (prove)
using this:
mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
mat ?nr ?nc ?m = (length ?m = ?nc \<and> Ball (set ?m) (vec ?nr))

goal (1 subgoal):
 1. Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))
[PROOF STEP]
have "(x \<in> set (vec_mat_Tensor v M))
                        \<longrightarrow> (vec ((row_length M)*(length v)) x)"
[PROOF STATE]
proof (prove)
using this:
Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x
[PROOF STEP]
using mat_def Ball_def
[PROOF STATE]
proof (prove)
using this:
Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))
mat ?nr ?nc ?m = (length ?m = ?nc \<and> Ball (set ?m) (vec ?nr))
Ball ?A ?P = (\<forall>x. x \<in> ?A \<longrightarrow> ?P x)

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x
[PROOF STEP]
have 4:"(x \<in> set (vec_mat_Tensor v M))
                          \<longrightarrow> (vec ((length a)*(length v)) x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (length a * length v) x
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (row_length M * length v) x
row_length M = length a

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (length a * length v) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (length a * length v) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 5:"length (vec_vec_Tensor v a) = (length a)*(length v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length a * length v
[PROOF STEP]
using   vec_vec_Tensor_length
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor ?x ?y) = length ?x * length ?y

goal (1 subgoal):
 1. length (vec_vec_Tensor v a) = length a * length v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (vec_vec_Tensor v a) = length a * length v

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (vec_vec_Tensor v a) = length a * length v
[PROOF STEP]
have 6:" vec ((length a)*(length v)) (vec_vec_Tensor v a)"
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor v a) = length a * length v

goal (1 subgoal):
 1. vec (length a * length v) (vec_vec_Tensor v a)
[PROOF STEP]
using vec_vec_Tensor_length vec_def
[PROOF STATE]
proof (prove)
using this:
length (vec_vec_Tensor v a) = length a * length v
length (vec_vec_Tensor ?x ?y) = length ?x * length ?y
vec ?n ?x = (length ?x = ?n)

goal (1 subgoal):
 1. vec (length a * length v) (vec_vec_Tensor v a)
[PROOF STEP]
by (metis (full_types))
[PROOF STATE]
proof (state)
this:
vec (length a * length v) (vec_vec_Tensor v a)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 7:"(length a) = (row_length (a#M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length a = row_length (a # M)
[PROOF STEP]
using row_length_def   list.distinct(1)
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
[] \<noteq> ?x21.0 # ?x22.0

goal (1 subgoal):
 1. length a = row_length (a # M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length a = row_length (a # M)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have "vec_mat_Tensor v (a#M)
                   = (vec_vec_Tensor v a)#(vec_mat_Tensor v M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M
[PROOF STEP]
using vec_mat_Tensor.simps(2)
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor ?xs (?ys # ?yss) = vec_vec_Tensor ?xs ?ys # vec_mat_Tensor ?xs ?yss

goal (1 subgoal):
 1. vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M
[PROOF STEP]
have "(x \<in> set (vec_mat_Tensor v (a#M)))
                      \<longrightarrow> ((x = (vec_vec_Tensor v a))
                           \<or> (x \<in> (set (vec_mat_Tensor v M))))"
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> x = vec_vec_Tensor v a \<or> x \<in> set (vec_mat_Tensor v M)
[PROOF STEP]
using  hd_set
[PROOF STATE]
proof (prove)
using this:
vec_mat_Tensor v (a # M) = vec_vec_Tensor v a # vec_mat_Tensor v M
?x \<in> set (?a # ?M) \<Longrightarrow> ?x = ?a \<or> ?x \<in> set ?M

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> x = vec_vec_Tensor v a \<or> x \<in> set (vec_mat_Tensor v M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> x = vec_vec_Tensor v a \<or> x \<in> set (vec_mat_Tensor v M)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
with 4 6
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (length a * length v) x
vec (length a * length v) (vec_vec_Tensor v a)
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> x = vec_vec_Tensor v a \<or> x \<in> set (vec_mat_Tensor v M)
[PROOF STEP]
have "(x \<in> set (vec_mat_Tensor v (a#M)))
                             \<longrightarrow>  vec ((length a)*(length v)) x"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (vec_mat_Tensor v M) \<longrightarrow> vec (length a * length v) x
vec (length a * length v) (vec_vec_Tensor v a)
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> x = vec_vec_Tensor v a \<or> x \<in> set (vec_mat_Tensor v M)

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (length a * length v) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (length a * length v) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
with 7
[PROOF STATE]
proof (chain)
picking this:
length a = row_length (a # M)
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (length a * length v) x
[PROOF STEP]
have "(x \<in> set (vec_mat_Tensor v (a#M)))
                                \<longrightarrow>  vec ((row_length (a#M))*(length v)) x"
[PROOF STATE]
proof (prove)
using this:
length a = row_length (a # M)
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (length a * length v) x

goal (1 subgoal):
 1. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
[PROOF STEP]
have "\<forall>x.((x \<in> set (vec_mat_Tensor v (a#M)))
                                \<longrightarrow>  vec ((row_length (a#M))*(length v)) x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x

goal (1 subgoal):
 1. \<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
[PROOF STEP]
using "2" "3" "6" "7" hd_set vec_mat_Tensor.simps(2)
[PROOF STATE]
proof (prove)
using this:
x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
row_length M = length a
Ball (set (vec_mat_Tensor v M)) (vec (row_length M * length v))
vec (length a * length v) (vec_vec_Tensor v a)
length a = row_length (a # M)
?x \<in> set (?a # ?M) \<Longrightarrow> ?x = ?a \<or> ?x \<in> set ?M
vec_mat_Tensor ?xs (?ys # ?yss) = vec_vec_Tensor ?xs ?ys # vec_mat_Tensor ?xs ?yss

goal (1 subgoal):
 1. \<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
[PROOF STEP]
have 7:
      "Ball
            (set (vec_mat_Tensor v (a#M)))
            (vec ((row_length (a#M))*(length v)))"
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x

goal (1 subgoal):
 1. Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))
[PROOF STEP]
using Ball_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x \<in> set (vec_mat_Tensor v (a # M)) \<longrightarrow> vec (row_length (a # M) * length v) x
Ball ?A ?P = (\<forall>x. x \<in> ?A \<longrightarrow> ?P x)

goal (1 subgoal):
 1. Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
have 8: "length (vec_mat_Tensor v (a#M)) = length (a#M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (vec_mat_Tensor v (a # M)) = length (a # M)
[PROOF STEP]
using vec_mat_Tensor_length
[PROOF STATE]
proof (prove)
using this:
length (vec_mat_Tensor ?xs ?ys) = length ?ys

goal (1 subgoal):
 1. length (vec_mat_Tensor v (a # M)) = length (a # M)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
with 6  7
[PROOF STATE]
proof (chain)
picking this:
vec (length a * length v) (vec_vec_Tensor v a)
Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))
length (vec_mat_Tensor v (a # M)) = length (a # M)
[PROOF STEP]
have
               "mat
                 ((row_length (a#M))*(length v))
                 (length (a#M))
                           (vec_mat_Tensor v (a#M))"
[PROOF STATE]
proof (prove)
using this:
vec (length a * length v) (vec_vec_Tensor v a)
Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))
length (vec_mat_Tensor v (a # M)) = length (a # M)

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
using mat_def  "5" length_code
[PROOF STATE]
proof (prove)
using this:
vec (length a * length v) (vec_vec_Tensor v a)
Ball (set (vec_mat_Tensor v (a # M))) (vec (row_length (a # M) * length v))
length (vec_mat_Tensor v (a # M)) = length (a # M)
mat ?nr ?nc ?m = (length ?m = ?nc \<and> Ball (set ?m) (vec ?nr))
length (vec_vec_Tensor v a) = length a * length v
length = List.gen_length 0

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
by (metis (opaque_lifting, no_types))
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. \<And>aa list. M = aa # list \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. \<And>a M. \<lbrakk>mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M); mat (row_length (a # M)) (length (a # M)) (a # M)\<rbrakk> \<Longrightarrow> mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
with  hyp
[PROOF STATE]
proof (chain)
picking this:
mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
mat (row_length (a # M)) (length (a # M)) (a # M)
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M \<Longrightarrow> mat (row_length M * length v) (length M) (vec_mat_Tensor v M)
mat (row_length (a # M)) (length (a # M)) (a # M)
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal (1 subgoal):
 1. mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length (a # M) * length v) (length (a # M)) (vec_mat_Tensor v (a # M))

goal:
No subgoals!
[PROOF STEP]
qed