[STATEMENT]
lemma typeII_twoCubeImg:
  assumes "typeII_twoCube twoC"
  shows "\<exists>a b g1 g2. a < b \<and> (\<forall>x \<in> {a .. b}. g2 x \<le> g1 x) \<and>
                      cubeImage twoC = {(y,x). x \<in> {a..b} \<and> y \<in> {g2 x .. g1 x}}
                      \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b))
                      \<and> g1 piecewise_C1_differentiable_on {a .. b} \<and> g2 piecewise_C1_differentiable_on {a .. b} "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(y, x). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
typeII_twoCube twoC

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(y, x). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
proof (simp add: typeII_twoCube_def cubeImage_def image_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
assume " \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and>
                            twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and>
                            g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})"
[PROOF STATE]
proof (state)
this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
obtain a b g1 g2 where
    twoCisTypeII: "a < b"
    "(\<forall>x\<in>{a..b}. g2 x \<le> g1 x)"
    "twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b))"
    "g1 piecewise_C1_differentiable_on {a .. b}"
    "g2 piecewise_C1_differentiable_on {a .. b}"
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})

goal (1 subgoal):
 1. (\<And>a b g2 g1. \<lbrakk>a < b; \<forall>x\<in>{a..b}. g2 x \<le> g1 x; twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)); g1 piecewise_C1_differentiable_on {a..b}; g2 piecewise_C1_differentiable_on {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < b
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b))
g1 piecewise_C1_differentiable_on {a..b}
g2 piecewise_C1_differentiable_on {a..b}

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
have ab1: "a - x * a + x * b \<le> b" if a1: "0 \<le> x" "x \<le> 1" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a - x * a + x * b \<le> b
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
x \<le> 1

goal (1 subgoal):
 1. a - x * a + x * b \<le> b
[PROOF STEP]
apply (simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> a + b * x \<le> b + a * x
[PROOF STEP]
by (metis affine_ineq less_eq_real_def mult.commute twoCisTypeII(1))
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 \<le> ?x; ?x \<le> 1\<rbrakk> \<Longrightarrow> a - ?x * a + ?x * b \<le> b

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
have ex: "\<exists>z\<in>Green.unit_cube.
               (d, c) =
               (case z of
                (y, x) \<Rightarrow>
                  (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b),
                   a - x * a + x * b))"
    if c_bounds: "a \<le> c" "c \<le> b" and d_bounds: "g2 c \<le> d" "d \<le> g1 c" for c d
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (d, c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (d, c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
have b_minus_a_nzero: "b - a \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b - a \<noteq> 0
[PROOF STEP]
using twoCisTypeII(1)
[PROOF STATE]
proof (prove)
using this:
a < b

goal (1 subgoal):
 1. b - a \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b - a \<noteq> 0

goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (d, c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
have x_witness: "\<exists>k1. c = (1 - k1)*a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
apply (rule_tac x="(c - a)/(b - a)" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b \<and> 0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1
[PROOF STEP]
using c_bounds \<open>a < b\<close>
[PROOF STATE]
proof (prove)
using this:
a \<le> c
c \<le> b
a < b

goal (1 subgoal):
 1. c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b \<and> 0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1
[PROOF STEP]
apply (simp add: divide_simps algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<le> c; c \<le> b; a < b\<rbrakk> \<Longrightarrow> a * a + b * b = a * (b * 2) \<longrightarrow> c = 0
[PROOF STEP]
using sum_sqs_eq
[PROOF STATE]
proof (prove)
using this:
?x * ?x + ?y * ?y = ?x * (?y * (2::?'a)) \<Longrightarrow> ?y = ?x

goal (1 subgoal):
 1. \<lbrakk>a \<le> c; c \<le> b; a < b\<rbrakk> \<Longrightarrow> a * a + b * b = a * (b * 2) \<longrightarrow> c = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1

goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (d, c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
have y_witness: "\<exists>k2. d = (1 - k2)*(g2 c) + k2 * (g1 c) \<and> 0 \<le> k2 \<and> k2 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
proof (cases "g1 c - g2 c = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. g1 c - g2 c = 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
 2. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
g1 c - g2 c = 0

goal (2 subgoals):
 1. g1 c - g2 c = 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
 2. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
with d_bounds
[PROOF STATE]
proof (chain)
picking this:
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c = 0

goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
by (fastforce simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
g1 c - g2 c \<noteq> 0

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
let ?k2 = "(d - g2 c)/(g1 c - g2 c)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
have k2_in_bounds: "0 \<le> ?k2 \<and> ?k2 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
[PROOF STEP]
using twoCisTypeII(2) c_bounds d_bounds False
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
a \<le> c
c \<le> b
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c \<noteq> 0

goal (1 subgoal):
 1. 0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
have "d = (1 - ?k2) * g2 c + ?k2 * g1 c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
using False sum_sqs_eq
[PROOF STATE]
proof (prove)
using this:
g1 c - g2 c \<noteq> 0
?x * ?x + ?y * ?y = ?x * (?y * (2::?'a)) \<Longrightarrow> ?y = ?x

goal (1 subgoal):
 1. d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
by (fastforce simp add: divide_simps algebra_simps)
[PROOF STATE]
proof (state)
this:
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
with k2_in_bounds
[PROOF STATE]
proof (chain)
picking this:
0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c

goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (d, c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
show "\<exists>x\<in>unit_cube. (d, c) = (case x of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>unit_cube. (d, c) = (case x of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
using x_witness y_witness
[PROOF STATE]
proof (prove)
using this:
\<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. \<exists>x\<in>unit_cube. (d, c) = (case x of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))
[PROOF STEP]
by (force simp add: left_diff_distrib)
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>unit_cube. (d, c) = (case x of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>a \<le> ?c; ?c \<le> b; g2 ?c \<le> ?d; ?d \<le> g1 ?c\<rbrakk> \<Longrightarrow> \<exists>z\<in>unit_cube. (?d, ?c) = (case z of (y, x) \<Rightarrow> (g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b), a - x * a + x * b))

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
have "{y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
[PROOF STEP]
apply (auto simp add: twoCisTypeII ab1 left_diff_distrib ex)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * a \<le> ba * b
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> aa * g2 (a - ba * a + ba * b) \<le> aa * g1 (a - ba * a + ba * b)
 3. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - ba * a + ba * b) - aa * g2 (a - ba * a + ba * b) + aa * g1 (a - ba * a + ba * b) \<le> g1 (a - ba * a + ba * b)
[PROOF STEP]
using order.order_iff_strict twoCisTypeII(1)
[PROOF STATE]
proof (prove)
using this:
(?a \<le> ?b) = (?a < ?b \<or> ?a = ?b)
a < b

goal (3 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * a \<le> ba * b
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> aa * g2 (a - ba * a + ba * b) \<le> aa * g1 (a - ba * a + ba * b)
 3. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - ba * a + ba * b) - aa * g2 (a - ba * a + ba * b) + aa * g1 (a - ba * a + ba * b) \<le> g1 (a - ba * a + ba * b)
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> aa * g2 (a - ba * a + ba * b) \<le> aa * g1 (a - ba * a + ba * b)
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - ba * a + ba * b) - aa * g2 (a - ba * a + ba * b) + aa * g1 (a - ba * a + ba * b) \<le> g1 (a - ba * a + ba * b)
[PROOF STEP]
apply (smt affine_ineq atLeastAtMost_iff mult_left_mono twoCisTypeII)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}) \<Longrightarrow> \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
[PROOF STEP]
show "\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and>
                            {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and>
                            twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and>
                            g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})"
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
using twoCisTypeII
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
a < b
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b))
g1 piecewise_C1_differentiable_on {a..b}
g2 piecewise_C1_differentiable_on {a..b}

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(y, x). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x} \<and> twoC = (\<lambda>(y, x). ((1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b), (1 - x) * a + x * b)) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_range_pair:
  assumes 1: "finite_range (\<lambda>x. fst (f x))" and 2: "finite_range (\<lambda>x. snd (f x))"
  shows "finite_range f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_range f
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite_range f
[PROOF STEP]
have "range f \<subseteq> range (\<lambda>x. fst (f x)) \<times> range (\<lambda>x. snd (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range f \<subseteq> range (\<lambda>x. fst (f x)) \<times> range (\<lambda>x. snd (f x))
[PROOF STEP]
by(auto 4 3 intro: rev_image_eqI dest: sym)
[PROOF STATE]
proof (state)
this:
range f \<subseteq> range (\<lambda>x. fst (f x)) \<times> range (\<lambda>x. snd (f x))

goal (1 subgoal):
 1. finite_range f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
range f \<subseteq> range (\<lambda>x. fst (f x)) \<times> range (\<lambda>x. snd (f x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
range f \<subseteq> range (\<lambda>x. fst (f x)) \<times> range (\<lambda>x. snd (f x))

goal (1 subgoal):
 1. finite_range f
[PROOF STEP]
by(rule finite_subset)(use assms in simp)
[PROOF STATE]
proof (state)
this:
finite_range f

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma diagonal_to_Smith_row_i_preserves_previous:
  fixes A::"'a:: {bezout_ring}^'b::mod_type^'c::mod_type"
  assumes ib: "is_bezout_ext bezout"
  and i_min: "i < min (nrows A) (ncols A)"
  and a_not_b: "to_nat a \<noteq> to_nat b"
  shows "Diagonal_to_Smith_row_i A i bezout $ a $ b = A $ a $ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Diagonal_to_Smith_row_i A i bezout $ a $ b = A $ a $ b
[PROOF STEP]
unfolding Diagonal_to_Smith_row_i_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i [i + 1..<min (nrows A) (ncols A)] A i bezout $ a $ b = A $ a $ b
[PROOF STEP]
by (rule diagonal_to_Smith_i_preserves_previous, insert assms, auto)


[STATEMENT]
lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x"
  for x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> ln (inverse x) = - ln x
[PROOF STEP]
by (rule ln_unique) (simp add: exp_minus)


[STATEMENT]
lemma maximalI_trans: "x \<in> maximal f S \<Longrightarrow> f x \<le> f y \<Longrightarrow> y \<in> S \<Longrightarrow> y \<in> maximal f S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> maximal f S; f x \<le> f y; y \<in> S\<rbrakk> \<Longrightarrow> y \<in> maximal f S
[PROOF STEP]
unfolding maximal_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> {x \<in> S. \<forall>y\<in>S. f y \<le> f x}; f x \<le> f y; y \<in> S\<rbrakk> \<Longrightarrow> y \<in> {x \<in> S. \<forall>y\<in>S. f y \<le> f x}
[PROOF STEP]
by (blast intro: antisym order_trans)


[STATEMENT]
lemma continuous_on_coordinatewise_then_product [continuous_intros]:
  fixes f :: "'a::topological_space \<Rightarrow> 'b \<Rightarrow> 'c::topological_space"
  assumes "\<And>i. continuous_on S (\<lambda>x. f x i)"
  shows "continuous_on S f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on S f
[PROOF STEP]
using continuous_map_coordinatewise_then_product [of UNIV, where T = "\<lambda>i. euclidean"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>i. i \<in> UNIV \<Longrightarrow> continuous_map ?T1.0 euclidean (\<lambda>x. ?f x i); \<And>i x. \<lbrakk>i \<notin> UNIV; x \<in> topspace ?T1.0\<rbrakk> \<Longrightarrow> ?f x i = undefined\<rbrakk> \<Longrightarrow> continuous_map ?T1.0 (product_topology (\<lambda>i. euclidean) UNIV) ?f

goal (1 subgoal):
 1. continuous_on S f
[PROOF STEP]
by (metis UNIV_I assms continuous_map_iff_continuous euclidean_product_topology)


[STATEMENT]
lemma  row_formula:
 fixes M1 and M2
 shows "\<forall>i.((i < (row_length M1)*(row_length M2))
          \<and>(mat (row_length M1) (length M1) M1)
          \<and>(mat (row_length M2) (length M2) M2)
             \<longrightarrow> row (M1 \<otimes> M2) i
                        =  vec_vec_Tensor
                                 (row M1 (i div row_length M2))
                                 (row M2 (i mod row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
apply(rule allI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
proof(induct M1)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < row_length [] * row_length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row ([] \<otimes> M2) i = vec_vec_Tensor (row [] (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>i. i < row_length [] * row_length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row ([] \<otimes> M2) i = vec_vec_Tensor (row [] (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < row_length [] * row_length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row ([] \<otimes> M2) i = vec_vec_Tensor (row [] (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using Nil
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < row_length [] * row_length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row ([] \<otimes> M2) i = vec_vec_Tensor (row [] (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by (metis less_nat_zero_code mult_0 row_length_Nil)
[PROOF STATE]
proof (state)
this:
i < row_length [] * row_length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row ([] \<otimes> M2) i = vec_vec_Tensor (row [] (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
case (Cons v M)
[PROOF STATE]
proof (state)
this:
?i < row_length M * row_length M2 \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M \<otimes> M2) ?i = vec_vec_Tensor (row M (?i div row_length M2)) (row M2 (?i mod row_length M2))

goal (1 subgoal):
 1. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have
    "((i < (row_length (v#M))*(row_length M2))
    \<and> (mat (row_length (v#M)) (length (v#M)) (v#M))
    \<and> (mat (row_length M2) (length M2) M2)
     \<Longrightarrow> row ((v#M) \<otimes> M2) i =  vec_vec_Tensor
                                    (row (v#M) (i div row_length M2))
                                    (row M2 (i mod row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
assume assms:
                 "(i < (row_length (v#M))*(row_length M2))
                 \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
                 \<and>(mat (row_length M2) (length M2) M2)"
[PROOF STATE]
proof (state)
this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have 0:"i < (length v)*(row_length M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length v * row_length M2
[PROOF STEP]
using assms row_length_def
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)

goal (1 subgoal):
 1. i < length v * row_length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < length v * row_length M2

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have 1:"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 assms  reduct_matrix
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
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 (metis)
[PROOF STATE]
proof (state)
this:
mat (row_length M) (length M) M

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "row ((v#M)\<otimes>M2) i = row ((vec_mat_Tensor v M2)@(M \<otimes> M2)) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i
[PROOF STEP]
have 2:"... = (row (vec_mat_Tensor v M2) i)@(row (M \<otimes> M2) i)"
[PROOF STATE]
proof (prove)
using this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i

goal (1 subgoal):
 1. row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i
[PROOF STEP]
using row_append
[PROOF STATE]
proof (prove)
using this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i
row (?A @ ?B) ?i = row ?A ?i @ row ?B ?i

goal (1 subgoal):
 1. row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
proof(cases M)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = []\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
M = []

goal (2 subgoals):
 1. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = []\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "row ((v#M)\<otimes>M2) i = (row (vec_mat_Tensor v M2) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i
[PROOF STEP]
using Nil 2
[PROOF STATE]
proof (prove)
using this:
M = []
row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i

goal (2 subgoals):
 1. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = []\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i

goal (2 subgoals):
 1. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = []\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "row (vec_mat_Tensor v M2) i =  times
                                                (v!(i div row_length M2))
                                                (row M2 (i mod row_length M2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using row_vec_mat_Tensor_prelim assms 0
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < length ?v * row_length ?M \<and> mat ?nr (length ?M) ?M \<longrightarrow> row (vec_mat_Tensor ?v ?M) i = local.times (?v ! (i div row_length ?M)) (row ?M (i mod row_length ?M))
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
i < length v * row_length M2

goal (1 subgoal):
 1. row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))

goal (2 subgoals):
 1. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = []\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
 2. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using vec_vec_Tensor_def
             Nil append_Nil2 vec_vec_Tensor.simps(1)
             vec_vec_Tensor.simps(2) row_Cons row_empty
[PROOF STATE]
proof (prove)
using this:
row (v # M \<otimes> M2) i = row (vec_mat_Tensor v M2) i
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
vec_vec_Tensor \<equiv> rec_list (\<lambda>ys. []) (\<lambda>x xs xsa ys. local.times x ys @ xsa ys)
M = []
?xs @ [] = ?xs
vec_vec_Tensor [] ?ys = []
vec_vec_Tensor (?x # ?xs) ?ys = local.times ?x ?ys @ vec_vec_Tensor ?xs ?ys
row (?v # ?M) ?i = ?v ! ?i # row ?M ?i
row [] ?i = []

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by (metis)
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
case (Cons w N)
[PROOF STATE]
proof (state)
this:
M = w # N

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have Cons_Cons_1:"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 assms reduct_matrix
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
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 list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mat (row_length M) (length M) M
[PROOF STEP]
have "row_length (w#N) = row_length (v#M)"
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M

goal (1 subgoal):
 1. row_length (w # N) = row_length (v # M)
[PROOF STEP]
using assms Cons
[PROOF STATE]
proof (prove)
using this:
mat (row_length M) (length M) M
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
M = w # N

goal (1 subgoal):
 1. row_length (w # N) = row_length (v # M)
[PROOF STEP]
unfolding mat_def Ball_def vec_def
[PROOF STATE]
proof (prove)
using this:
length M = length M \<and> (\<forall>x. x \<in> set M \<longrightarrow> length x = row_length M)
i < row_length (v # M) * row_length M2 \<and> (length (v # M) = length (v # M) \<and> (\<forall>x. x \<in> set (v # M) \<longrightarrow> length x = row_length (v # M))) \<and> length M2 = length M2 \<and> (\<forall>x. x \<in> set M2 \<longrightarrow> length x = row_length M2)
M = w # N

goal (1 subgoal):
 1. row_length (w # N) = row_length (v # M)
[PROOF STEP]
using append_Cons  hd_in_set list.distinct(1)
                        rotate1.simps(2) set_rotate1
[PROOF STATE]
proof (prove)
using this:
length M = length M \<and> (\<forall>x. x \<in> set M \<longrightarrow> length x = row_length M)
i < row_length (v # M) * row_length M2 \<and> (length (v # M) = length (v # M) \<and> (\<forall>x. x \<in> set (v # M) \<longrightarrow> length x = row_length (v # M))) \<and> length M2 = length M2 \<and> (\<forall>x. x \<in> set M2 \<longrightarrow> length x = row_length M2)
M = w # N
(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys
?xs \<noteq> [] \<Longrightarrow> hd ?xs \<in> set ?xs
[] \<noteq> ?x21.0 # ?x22.0
rotate1 (?x # ?xs) = ?xs @ [?x]
set (rotate1 ?xs) = set ?xs

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

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row_length (w # N) = row_length (v # M)
[PROOF STEP]
have Cons_Cons_2:"i < (row_length M)*(row_length M2)"
[PROOF STATE]
proof (prove)
using this:
row_length (w # N) = row_length (v # M)

goal (1 subgoal):
 1. i < row_length M * row_length M2
[PROOF STEP]
using assms Cons
[PROOF STATE]
proof (prove)
using this:
row_length (w # N) = row_length (v # M)
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
M = w # N

goal (1 subgoal):
 1. i < row_length M * row_length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < row_length M * row_length M2

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < row_length M * row_length M2
[PROOF STEP]
have Cons_Cons_3:"(row (M \<otimes> M2) i) =  vec_vec_Tensor
                                          (row M (i div row_length M2))
                                           (row M2 (i mod row_length M2))"
[PROOF STATE]
proof (prove)
using this:
i < row_length M * row_length M2

goal (1 subgoal):
 1. row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using Cons.hyps Cons_Cons_1 assms
[PROOF STATE]
proof (prove)
using this:
i < row_length M * row_length M2
?i < row_length M * row_length M2 \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M \<otimes> M2) ?i = vec_vec_Tensor (row M (?i div row_length M2)) (row M2 (?i mod row_length M2))
mat (row_length M) (length M) M
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "row (vec_mat_Tensor v M2) i
                                            =  times
                                               (v!(i div row_length M2))
                                               (row M2 (i mod row_length M2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using row_vec_mat_Tensor_prelim assms 0
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < length ?v * row_length ?M \<and> mat ?nr (length ?M) ?M \<longrightarrow> row (vec_mat_Tensor ?v ?M) i = local.times (?v ! (i div row_length ?M)) (row ?M (i mod row_length ?M))
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
i < length v * row_length M2

goal (1 subgoal):
 1. row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "row ((v#M)\<otimes>M2) i =
                           (times
                                   (v!(i div row_length M2))
                                    (row M2 (i mod row_length M2)))
                                      @(vec_vec_Tensor
                                          (row M (i div row_length M2))
                                           (row M2 (i mod row_length M2)))"
[PROOF STATE]
proof (prove)
using this:
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using 2 Cons_Cons_3
[PROOF STATE]
proof (prove)
using this:
row (vec_mat_Tensor v M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2))
row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i
row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "... = (vec_vec_Tensor
                                        ((v!(i div row_length M2))
                                             #(row M (i div row_length M2)))
                                        (row M2 (i mod row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using vec_vec_Tensor.simps(2)
[PROOF STATE]
proof (prove)
using this:
vec_vec_Tensor (?x # ?xs) ?ys = local.times ?x ?ys @ vec_vec_Tensor ?xs ?ys

goal (1 subgoal):
 1. local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
have "... = (vec_vec_Tensor (row (v#M) (i div row_length M2))
                                           (row M2 (i mod row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
using row_Cons
[PROOF STATE]
proof (prove)
using this:
row (?v # ?M) ?i = ?v ! ?i # row ?M ?i

goal (1 subgoal):
 1. vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a list. \<lbrakk>row (vec_mat_Tensor v M2 @ (M \<otimes> M2)) i = row (vec_mat_Tensor v M2) i @ row (M \<otimes> M2) i; M = a # list\<rbrakk> \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))
vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
row (M \<otimes> M2) i = vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
row (v # M \<otimes> M2) i = local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2))
local.times (v ! (i div row_length M2)) (row M2 (i mod row_length M2)) @ vec_vec_Tensor (row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2))
vec_vec_Tensor (v ! (i div row_length M2) # row M (i div row_length M2)) (row M2 (i mod row_length M2)) = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. \<And>a M1 i. (\<And>i. i < row_length M1 * row_length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (M1 \<otimes> M2) i = vec_vec_Tensor (row M1 (i div row_length M2)) (row M2 (i mod row_length M2))) \<Longrightarrow> i < row_length (a # M1) * row_length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (a # M1 \<otimes> M2) i = vec_vec_Tensor (row (a # M1) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < row_length (v # M) * row_length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> row (v # M \<otimes> M2) i = vec_vec_Tensor (row (v # M) (i div row_length M2)) (row M2 (i mod row_length M2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Ord_mem_iff_lt: "Ord(k) \<Longrightarrow> Ord(l) \<Longrightarrow> k\<^bold>\<in>l \<longleftrightarrow> k < l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ord k; Ord l\<rbrakk> \<Longrightarrow> (k \<^bold>\<in> l) = (k < l)
[PROOF STEP]
by (metis Ord_linear OrdmemD hmem_not_refl less_hf_def less_le_not_le)


[STATEMENT]
lemma All_prod_contract: "(\<forall>a b. P a b) \<longleftrightarrow> (\<forall>z. P (fst z) (snd z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a b. P a b) = (\<forall>z. P (fst z) (snd z))
[PROOF STEP]
by auto


[STATEMENT]
lemma span_span: "span (span A) = span A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (span A) = span A
[PROOF STEP]
unfolding span_def hull_hull
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subspace hull A = subspace hull A
[PROOF STEP]
..


[STATEMENT]
lemma exp_minus_inverse: "exp x * exp (- x) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp x * exp (- x) = (1::'a)
[PROOF STEP]
by (simp add: exp_add_commuting[symmetric])


[STATEMENT]
lemma scaleC_le_cancel_left: "c *\<^sub>C a \<le> c *\<^sub>C b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
  if "c \<in> \<real>" (* Not present in Real_Vector_Spaces *)
  for b :: "'a::ordered_complex_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (c *\<^sub>C a \<le> c *\<^sub>C b) = ((0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a))
[PROOF STEP]
by (smt (verit, ccfv_threshold) Complex_Vector_Spaces0.neg_divideC_le_eq complex_vector.scale_cancel_left complex_vector.scale_zero_right dual_order.eq_iff dual_order.trans ordered_complex_vector_class.pos_le_divideC_eq that zero_le_scaleC_iff)


[STATEMENT]
lemma plus_one_in_nonpos_Ints_imp: "z + 1 \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> z \<in> \<int>\<^sub>\<le>\<^sub>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z + (1::'a) \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> z \<in> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
using nonpos_Ints_diff_Nats[of "z+1" "1"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>z + (1::'a) \<in> \<int>\<^sub>\<le>\<^sub>0; (1::'a) \<in> \<nat>\<rbrakk> \<Longrightarrow> z + (1::'a) - (1::'a) \<in> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. z + (1::'a) \<in> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> z \<in> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
by simp_all


[STATEMENT]
lemma delmod: "(a::nat) mod (b*c) mod c = a mod c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a mod (b * c) mod c = a mod c
[PROOF STEP]
by (rule mod_mod_cancel [OF dvd_triv_right])


[STATEMENT]
lemma adj_uminus: \<open>(-A)* = - (A*)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- A)* = - A*
[PROOF STEP]
apply (rule adjoint_eqI[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. (- A* *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (- A *\<^sub>V y)
[PROOF STEP]
by (simp add: cblinfun.minus_left cinner_adj_left)


[STATEMENT]
lemma monom_mult_list[simp]: "eval_monom_list \<alpha> (monom_mult_list m n) = eval_monom_list \<alpha> m * eval_monom_list \<alpha> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_monom_list \<alpha> (monom_mult_list m n) = eval_monom_list \<alpha> m * eval_monom_list \<alpha> n
[PROOF STEP]
by (induct m n rule: monom_mult_list.induct, auto split: list.splits prod.splits simp: field_simps power_add)


[STATEMENT]
lemma abelian_free_Abelian_group: "comm_group(free_Abelian_group S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comm_group (free_Abelian_group S)
[PROOF STEP]
apply (rule group.group_comm_groupI [OF group_free_Abelian_group])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> carrier (free_Abelian_group S); y \<in> carrier (free_Abelian_group S)\<rbrakk> \<Longrightarrow> x \<otimes>\<^bsub>free_Abelian_group S\<^esub> y = y \<otimes>\<^bsub>free_Abelian_group S\<^esub> x
[PROOF STEP]
by (simp add: free_Abelian_group_def)


[STATEMENT]
lemma Limit_vfinite_in_VsetI:
  assumes "Limit \<alpha>" and "A \<subseteq>\<^sub>\<circ> Vset \<alpha>" and "vfinite A"
  shows "A \<in>\<^sub>\<circ> Vset \<alpha>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
from assms(3)
[PROOF STATE]
proof (chain)
picking this:
vfinite A
[PROOF STEP]
obtain n where n: "n \<in>\<^sub>\<circ> \<omega>" and "n \<approx>\<^sub>\<circ> A"
[PROOF STATE]
proof (prove)
using this:
vfinite A

goal (1 subgoal):
 1. (\<And>n. \<lbrakk>n \<in>\<^sub>\<circ> \<omega>; n \<approx>\<^sub>\<circ> A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by clarsimp
[PROOF STATE]
proof (state)
this:
n \<in>\<^sub>\<circ> \<omega>
n \<approx>\<^sub>\<circ> A

goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<in>\<^sub>\<circ> \<omega>
n \<approx>\<^sub>\<circ> A
[PROOF STEP]
obtain f where f: "v11 f" and dr: "\<D>\<^sub>\<circ> f = n" "\<R>\<^sub>\<circ> f = A"
[PROOF STATE]
proof (prove)
using this:
n \<in>\<^sub>\<circ> \<omega>
n \<approx>\<^sub>\<circ> A

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>v11 f; \<D>\<^sub>\<circ> f = n; \<R>\<^sub>\<circ> f = A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v11 f
\<D>\<^sub>\<circ> f = n
\<R>\<^sub>\<circ> f = A

goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
interpret f: v11 f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v11 f
[PROOF STEP]
by (rule f)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
n \<in>\<^sub>\<circ> \<omega>
[PROOF STEP]
have n: "vfinite n"
[PROOF STATE]
proof (prove)
using this:
n \<in>\<^sub>\<circ> \<omega>

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

goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in>\<^sub>\<circ> Vset \<alpha>
[PROOF STEP]
by (rule f.vsv_Limit_vrange_in_VsetI[simplified dr, OF assms(1,2) n])
[PROOF STATE]
proof (state)
this:
A \<in>\<^sub>\<circ> Vset \<alpha>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Func_Pfunc:
"Func_option A B \<subseteq> Pfunc A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Func_option A B \<subseteq> Pfunc A B
[PROOF STEP]
unfolding Func_option_def Pfunc_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {f. (\<forall>a. (f a \<noteq> None) = (a \<in> A)) \<and> (\<forall>a\<in>A. case f a of None \<Rightarrow> True | Some b \<Rightarrow> b \<in> B)} \<subseteq> {f. (\<forall>a. f a \<noteq> None \<longrightarrow> a \<in> A) \<and> (\<forall>a. case f a of None \<Rightarrow> True | Some b \<Rightarrow> b \<in> B)}
[PROOF STEP]
by auto


[STATEMENT]
lemma dvd_minus_eq_mod:
  fixes c::"'a::unique_euclidean_ring"
  assumes "c \<noteq> 0" and "c dvd a - b" shows "a mod c = b mod c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a mod c = b mod c
[PROOF STEP]
using assms dvd_div_mult_self[of c]
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'a)
c dvd a - b
c dvd ?b \<Longrightarrow> ?b div c * c = ?b

goal (1 subgoal):
 1. a mod c = b mod c
[PROOF STEP]
by (metis add.commute diff_add_cancel mod_mult_self1)


[STATEMENT]
lemma continuous_on_diff [continuous_intros]:
  fixes f g :: "_ \<Rightarrow> 'b::topological_group_add"
  shows "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> continuous_on s (\<lambda>x. f x - g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>continuous_on s f; continuous_on s g\<rbrakk> \<Longrightarrow> continuous_on s (\<lambda>x. f x - g x)
[PROOF STEP]
unfolding continuous_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>s. (f \<longlongrightarrow> f x) (at x within s); \<forall>x\<in>s. (g \<longlongrightarrow> g x) (at x within s)\<rbrakk> \<Longrightarrow> \<forall>x\<in>s. ((\<lambda>x. f x - g x) \<longlongrightarrow> f x - g x) (at x within s)
[PROOF STEP]
by (auto intro: tendsto_diff)


[STATEMENT]
lemma zero_less_Log_cancel_iff [simp]:
  "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < Log a x \<longleftrightarrow> 1 < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>1 < a; 0 < x\<rbrakk> \<Longrightarrow> (0 < Log a x) = (1 < x)
[PROOF STEP]
using Log_less_cancel_iff[of a 1 x]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>1 < a; 0 < 1; 0 < x\<rbrakk> \<Longrightarrow> (Log a 1 < Log a x) = (1 < x)

goal (1 subgoal):
 1. \<lbrakk>1 < a; 0 < x\<rbrakk> \<Longrightarrow> (0 < Log a x) = (1 < x)
[PROOF STEP]
by simp


[STATEMENT]
lemma multiplicity_prime_fact:
  fixes p :: nat
  assumes "prime p"
  shows   "multiplicity p (fact n) = legendre_aux n p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
proof (cases "p \<le> n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
p \<le> n

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
have "fact n = (\<Prod>p | prime p \<and> p \<le> n. p ^ legendre_aux n p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact n = (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p)
[PROOF STEP]
using legendre_identity'[of "real n"]
[PROOF STATE]
proof (prove)
using this:
fact (nat \<lfloor>real n\<rfloor>) = (\<Prod>p\<in>{p. prime p \<and> real p \<le> real n}. p ^ legendre_aux (real n) p)

goal (1 subgoal):
 1. fact n = (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fact n = (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p)

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact n = (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p)

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
have "multiplicity p \<dots> = (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux n q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicity p (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p) = (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. multiplicity p (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p) = (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q))
[PROOF STEP]
by (subst prime_elem_multiplicity_prod_distrib) auto
[PROOF STATE]
proof (state)
this:
multiplicity p (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p) = (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q))

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
multiplicity p (\<Prod>p\<in>{p. prime p \<and> p \<le> n}. p ^ legendre_aux (real n) p) = (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q))

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
have "\<dots> = (\<Sum>q\<in>{p}. legendre_aux n q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q)) = sum (legendre_aux (real n)) {p}
[PROOF STEP]
using assms \<open>p \<le> n\<close> prime_multiplicity_other[of p]
[PROOF STATE]
proof (prove)
using this:
prime p
p \<le> n
\<lbrakk>prime p; prime ?q; p \<noteq> ?q\<rbrakk> \<Longrightarrow> multiplicity p ?q = 0

goal (1 subgoal):
 1. (\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q)) = sum (legendre_aux (real n)) {p}
[PROOF STEP]
by (intro sum.mono_neutral_cong_right)
       (auto simp: prime_elem_multiplicity_power_distrib prime_multiplicity_prime split: if_splits)
[PROOF STATE]
proof (state)
this:
(\<Sum>q | prime q \<and> q \<le> n. multiplicity p (q ^ legendre_aux (real n) q)) = sum (legendre_aux (real n)) {p}

goal (2 subgoals):
 1. p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
 2. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
multiplicity p (fact n) = sum (legendre_aux (real n)) {p}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
multiplicity p (fact n) = sum (legendre_aux (real n)) {p}

goal (1 subgoal):
 1. multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
multiplicity p (fact n) = legendre_aux (real n) p

goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> p \<le> n

goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
hence "multiplicity p (fact n) = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> p \<le> n

goal (1 subgoal):
 1. multiplicity p (fact n) = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> p \<le> n
prime p

goal (1 subgoal):
 1. multiplicity p (fact n) = 0
[PROOF STEP]
by (intro not_dvd_imp_multiplicity_0) (auto simp: prime_dvd_fact_iff)
[PROOF STATE]
proof (state)
this:
multiplicity p (fact n) = 0

goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
multiplicity p (fact n) = 0

goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
\<not> p \<le> n
[PROOF STEP]
have "legendre_aux (real n) p = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> p \<le> n

goal (1 subgoal):
 1. legendre_aux (real n) p = 0
[PROOF STEP]
by (intro legendre_aux_eq_0) auto
[PROOF STATE]
proof (state)
this:
legendre_aux (real n) p = 0

goal (1 subgoal):
 1. \<not> p \<le> n \<Longrightarrow> multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
multiplicity p (fact n) = 0
legendre_aux (real n) p = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
multiplicity p (fact n) = 0
legendre_aux (real n) p = 0

goal (1 subgoal):
 1. multiplicity p (fact n) = legendre_aux (real n) p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
multiplicity p (fact n) = legendre_aux (real n) p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma [smt_arith_multiplication]:
  fixes A B :: real and p n :: real
  assumes "A \<le> B" "0 < n" "p > 0"
  shows "(A / n) * p \<le> (B / n) * p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A / n * p \<le> B / n * p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<le> B
0 < n
0 < p

goal (1 subgoal):
 1. A / n * p \<le> B / n * p
[PROOF STEP]
by (auto simp: field_simps)


[STATEMENT]
lemma outer_prod_add_left:
  fixes v::"complex Matrix.vec"
  assumes "dim_vec v = dim_vec x"
  shows "outer_prod (v + x) w = outer_prod v w + (outer_prod x w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
define paw where "paw = outer_prod (v+x) w"
[PROOF STATE]
proof (state)
this:
paw = outer_prod (v + x) w

goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
define apw where "apw = outer_prod v w + (outer_prod x w)"
[PROOF STATE]
proof (state)
this:
apw = outer_prod v w + outer_prod x w

goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
have "paw = apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. paw = apw
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
have rv: "dim_row paw = dim_vec v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row paw = dim_vec v
[PROOF STEP]
unfolding paw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (outer_prod (v + x) w) = dim_vec v
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec v = dim_vec x

goal (1 subgoal):
 1. dim_row (outer_prod (v + x) w) = dim_vec v
[PROOF STEP]
by (metis carrier_matD(1) carrier_vec_dim_vec index_add_vec(2) paw_def)
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_vec v

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_vec v

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
have "... = dim_row apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = dim_row apw
[PROOF STEP]
unfolding apw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = dim_row (outer_prod v w + outer_prod x w)
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec v = dim_vec x

goal (1 subgoal):
 1. dim_vec v = dim_row (outer_prod v w + outer_prod x w)
[PROOF STEP]
by (metis carrier_matD(1) carrier_vec_dim_vec index_add_mat(2))
[PROOF STATE]
proof (state)
this:
dim_vec v = dim_row apw

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_row paw = dim_row apw
 3. dim_col paw = dim_col apw
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_row paw = dim_row apw
[PROOF STEP]
show dr: "dim_row paw = dim_row apw"
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row apw

goal (1 subgoal):
 1. dim_row paw = dim_row apw
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_row paw = dim_row apw

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
have cw: "dim_col paw = dim_vec w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col paw = dim_vec w
[PROOF STEP]
unfolding paw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (outer_prod (v + x) w) = dim_vec w
[PROOF STEP]
using outer_prod_dim assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec v = dim_vec x

goal (1 subgoal):
 1. dim_col (outer_prod (v + x) w) = dim_vec w
[PROOF STEP]
using carrier_vec_dim_vec
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec v = dim_vec x
?v \<in> carrier_vec (dim_vec ?v)

goal (1 subgoal):
 1. dim_col (outer_prod (v + x) w) = dim_vec w
[PROOF STEP]
by (metis carrier_matD(2))
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_vec w

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_vec w

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
have "... = dim_col apw"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec w = dim_col apw
[PROOF STEP]
unfolding apw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec w = dim_col (outer_prod v w + outer_prod x w)
[PROOF STEP]
using outer_prod_dim
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m

goal (1 subgoal):
 1. dim_vec w = dim_col (outer_prod v w + outer_prod x w)
[PROOF STEP]
by (metis apw_def carrier_matD(2) carrier_vec_dim_vec add_carrier_mat)
[PROOF STATE]
proof (state)
this:
dim_vec w = dim_col apw

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
 2. dim_col paw = dim_col apw
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_col paw = dim_col apw
[PROOF STEP]
show dc: "dim_col paw = dim_col apw"
[PROOF STATE]
proof (prove)
using this:
dim_col paw = dim_col apw

goal (1 subgoal):
 1. dim_col paw = dim_col apw
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_col paw = dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
show "\<And>i j. i < dim_row apw \<Longrightarrow> j < dim_col apw \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
assume  "i < dim_row apw" and "j < dim_col apw"
[PROOF STATE]
proof (state)
this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
note ij = this
[PROOF STATE]
proof (state)
this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
hence "paw $$ (i,j) = (Matrix.vec_index v i + Matrix.vec_index x i) *
        cnj (Matrix.vec_index w j)"
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. paw $$ (i, j) = (v $ i + x $ i) * cnj (w $ j)
[PROOF STEP]
using dr dc
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw
dim_row paw = dim_row apw
dim_col paw = dim_col apw

goal (1 subgoal):
 1. paw $$ (i, j) = (v $ i + x $ i) * cnj (w $ j)
[PROOF STEP]
unfolding  paw_def outer_prod_def
[PROOF STATE]
proof (prove)
using this:
i < dim_row apw
j < dim_col apw
dim_row (Matrix.mat (dim_vec (v + x)) 1 (\<lambda>(i, j). (v + x) $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) = dim_row apw
dim_col (Matrix.mat (dim_vec (v + x)) 1 (\<lambda>(i, j). (v + x) $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) = dim_col apw

goal (1 subgoal):
 1. (Matrix.mat (dim_vec (v + x)) 1 (\<lambda>(i, j). (v + x) $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) = (v $ i + x $ i) * cnj (w $ j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = (v $ i + x $ i) * cnj (w $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = (v $ i + x $ i) * cnj (w $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = Matrix.vec_index v i * cnj (Matrix.vec_index w j) +
        Matrix.vec_index x i * cnj (Matrix.vec_index w j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v $ i + x $ i) * cnj (w $ j) = v $ i * cnj (w $ j) + x $ i * cnj (w $ j)
[PROOF STEP]
by (simp add: ring_class.ring_distribs(2))
[PROOF STATE]
proof (state)
this:
(v $ i + x $ i) * cnj (w $ j) = v $ i * cnj (w $ j) + x $ i * cnj (w $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(v $ i + x $ i) * cnj (w $ j) = v $ i * cnj (w $ j) + x $ i * cnj (w $ j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = (outer_prod v w) $$ (i,j) + (outer_prod x w) $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ i * cnj (w $ j) + x $ i * cnj (w $ j) = outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j)
[PROOF STEP]
using rv cw dr dc ij assms
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_vec v
dim_col paw = dim_vec w
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw
dim_vec v = dim_vec x

goal (1 subgoal):
 1. v $ i * cnj (w $ j) + x $ i * cnj (w $ j) = outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j)
[PROOF STEP]
unfolding outer_prod_def
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_vec v
dim_col paw = dim_vec w
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw
dim_vec v = dim_vec x

goal (1 subgoal):
 1. v $ i * cnj (w $ j) + x $ i * cnj (w $ j) = (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) + (Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j) + x $ i * cnj (w $ j) = outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v $ i * cnj (w $ j) + x $ i * cnj (w $ j) = outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
have "... = apw $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
using dr dc ij
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row apw
dim_col paw = dim_col apw
i < dim_row apw
j < dim_col apw

goal (1 subgoal):
 1. outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
unfolding apw_def outer_prod_def
[PROOF STATE]
proof (prove)
using this:
dim_row paw = dim_row (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) + Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y))
dim_col paw = dim_col (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) + Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y))
i < dim_row (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) + Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y))
j < dim_col (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) + Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y))

goal (1 subgoal):
 1. (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) + (Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) = (Matrix.mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y) + Matrix.mat (dim_vec x) 1 (\<lambda>(i, j). x $ i) * Matrix.mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
outer_prod v w $$ (i, j) + outer_prod x w $$ (i, j) = apw $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row apw; j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
show "paw $$ (i, j) = apw $$ (i, j)"
[PROOF STATE]
proof (prove)
using this:
paw $$ (i, j) = apw $$ (i, j)

goal (1 subgoal):
 1. paw $$ (i, j) = apw $$ (i, j)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
paw $$ (i, j) = apw $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row apw; ?j < dim_col apw\<rbrakk> \<Longrightarrow> paw $$ (?i, ?j) = apw $$ (?i, ?j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
paw = apw

goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
paw = apw

goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
unfolding paw_def apw_def
[PROOF STATE]
proof (prove)
using this:
outer_prod (v + x) w = outer_prod v w + outer_prod x w

goal (1 subgoal):
 1. outer_prod (v + x) w = outer_prod v w + outer_prod x w
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
outer_prod (v + x) w = outer_prod v w + outer_prod x w

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma choose_square_sum: "(\<Sum>k\<le>n. (n choose k)^2) = ((2*n) choose n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. (n choose k)\<^sup>2) = 2 * n choose n
[PROOF STEP]
using vandermonde[of n n n]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k\<le>n. (n choose k) * (n choose (n - k))) = n + n choose n

goal (1 subgoal):
 1. (\<Sum>k\<le>n. (n choose k)\<^sup>2) = 2 * n choose n
[PROOF STEP]
by (simp add: power2_eq_square mult_2 binomial_symmetric [symmetric])