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

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(row_length []) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_length [] = 0
[PROOF STEP]
using row_length_def
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)

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

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row_length [] = 0
[PROOF STEP]
have "(i< ((row_length [])*(row_length M2))) \<longrightarrow> False"
[PROOF STATE]
proof (prove)
using this:
row_length [] = 0

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

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
i < row_length [] * row_length M2 \<longrightarrow> False
[PROOF STEP]
have "((i<((row_length [])*(row_length M2)))
                 \<and>(j < (length [])*(length M2)))
                 \<and>(mat (row_length []) (length []) [])
                 \<and>(mat (row_length M2) (length M2) M2)
                                                 \<longrightarrow> False"
[PROOF STATE]
proof (prove)
using this:
i < row_length [] * row_length M2 \<longrightarrow> False

goal (1 subgoal):
 1. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "([] \<otimes> M2) = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [] \<otimes> M2 = []
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[] \<otimes> M2 = []

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[] \<otimes> M2 = []

goal (2 subgoals):
 1. \<And>i j. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have
          "((i<((row_length [])*(row_length M2)))
           \<and>(j < (length [])*(length M2)))
           \<and>(mat (row_length []) (length []) [])
           \<and>(mat (row_length M2) (length M2) M2)
               \<longrightarrow> (([] \<otimes> M2)!j!i) =
                           f
                             ([]!(j div (length []))!(i div (row_length M2)))
                              (M2!(j mod length [])!(i mod (row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length []) ! (i div row_length M2) * M2 ! (j mod length []) ! (i mod row_length M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(i < row_length [] * row_length M2 \<and> j < length [] * length M2) \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> ([] \<otimes> M2) ! j ! i = [] ! (j div length []) ! (i div row_length M2) * M2 ! (j mod length []) ! (i mod row_length M2)

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

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length 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> ?j < length M * length M2) \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! ?j ! ?i = M ! (?j div length M2) ! (?i div row_length M2) * M2 ! (?j mod length M2) ! (?i mod row_length M2)

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have 0:"(v#M) \<otimes> M2 = (vec_mat_Tensor v M2)@(Tensor M M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)

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

goal (1 subgoal):
 1. j < length M2 \<longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j
[PROOF STEP]
using append_simpl vec_mat_Tensor_length
[PROOF STATE]
proof (prove)
using this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
?i < length ?xs \<longrightarrow> (?xs @ ?ys) ! ?i = ?xs ! ?i
length (vec_mat_Tensor ?xs ?ys) = length ?ys

goal (1 subgoal):
 1. j < length M2 \<longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
j < length M2 \<longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have " (((i<((length a)*(row_length M2)))
      \<and>(j < (length M2)))\<and>(mat (row_length M2) (length M2) M2)
  \<longrightarrow> ((vec_mat_Tensor a M2)!j!i) = f (a!(i div (row_length M2))) (M2!j!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i < length a * row_length M2 \<and> j < length M2) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> vec_mat_Tensor a M2 ! j ! i = a ! (i div row_length M2) * M2 ! j ! (i mod row_length M2)
[PROOF STEP]
using vec_mat_Tensor_elements
[PROOF STATE]
proof (prove)
using this:
\<forall>i j. (i < length ?v * row_length ?M \<and> j < length ?M) \<and> mat (row_length ?M) (length ?M) ?M \<longrightarrow> vec_mat_Tensor ?v ?M ! j ! i = ?v ! (i div row_length ?M) * ?M ! j ! (i mod row_length ?M)

goal (1 subgoal):
 1. (i < length a * row_length M2 \<and> j < length M2) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> vec_mat_Tensor a M2 ! j ! i = a ! (i div row_length M2) * M2 ! j ! (i mod row_length M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(i < length a * row_length M2 \<and> j < length M2) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> vec_mat_Tensor a M2 ! j ! i = a ! (i div row_length M2) * M2 ! j ! (i mod row_length M2)

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j < (length M2)) \<longrightarrow> (j div (length M2)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M2 \<longrightarrow> j div length M2 = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<longrightarrow> j div length M2 = 0

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length M2 \<longrightarrow> j div length M2 = 0
[PROOF STEP]
have 2:"(j < (length M2)) \<longrightarrow> (v#M)!(j div (length M2)) = v"
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<longrightarrow> j div length M2 = 0

goal (1 subgoal):
 1. j < length M2 \<longrightarrow> (v # M) ! (j div length M2) = v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<longrightarrow> (v # M) ! (j div length M2) = v

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j < (length M2)) \<longrightarrow> (j mod (length M2)) = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M2 \<longrightarrow> j mod length M2 = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<longrightarrow> j mod length M2 = j

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
j < length M2 \<longrightarrow> j mod length M2 = j

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have step0:
    "(j < (length M2)) \<longrightarrow>
               (((i<((length v)*(row_length M2)))
              \<and>(j < (length M2) * (length (v#M))))
              \<and>(mat (row_length M2) (length M2) M2)
                  \<longrightarrow> ((Tensor (v#M) M2)!j!i)
                     = f
                         ((v#M)!(j div (length M2))!(i div (row_length M2)))
                         (M2!(j mod (length M2))!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M2 \<longrightarrow> (i < length v * row_length M2 \<and> j < length M2 * length (v # M)) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using 2 1  calculation(1) vec_mat_Tensor_elements
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<longrightarrow> (v # M) ! (j div length M2) = v
j < length M2 \<longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j
j < length M2 \<longrightarrow> j mod length M2 = j
\<forall>i j. (i < length ?v * row_length ?M \<and> j < length ?M) \<and> mat (row_length ?M) (length ?M) ?M \<longrightarrow> vec_mat_Tensor ?v ?M ! j ! i = ?v ! (i div row_length ?M) * ?M ! j ! (i mod row_length ?M)

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have step1:
     "(j < (length M2))
        \<longrightarrow> (((i<((row_length (v#M))*(row_length M2)))
            \<and>(j <  (length (v#M))*(length M2)))
            \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
            \<and>(mat (row_length M2) (length M2) M2)
                 \<longrightarrow> ((Tensor (v#M) M2)!j!i) =
                   f
                     ((v#M)!(j div (length M2))!(i div (row_length M2)))
                     (M2!(j mod (length M2))!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M2 \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using row_length_def  step0
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
j < length M2 \<longrightarrow> (i < length v * row_length M2 \<and> j < length M2 * length (v # M)) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from 0
[PROOF STATE]
proof (chain)
picking this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
[PROOF STEP]
have 3:
        "(j \<ge> (length M2)) \<longrightarrow> ((v#M) \<otimes> M2)!j = (M \<otimes> M2)!(j - (length M2))"
[PROOF STATE]
proof (prove)
using this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)

goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
using vec_mat_Tensor_length add.commute append_simpl2
[PROOF STATE]
proof (prove)
using this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
length (vec_mat_Tensor ?xs ?ys) = length ?ys
?a + ?b = ?b + ?a
length ?xs \<le> ?i \<longrightarrow> (?xs @ ?ys) ! ?i = ?ys ! (?i - length ?xs)

goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have 4:
      "(j \<ge> (length M2)) \<longrightarrow>
                 (((i<((row_length M)*(row_length M2)))
                 \<and>((j-(length M2)) < (length M)*(length M2)))
                 \<and>(mat (row_length M) (length M) M)
                 \<and>(mat (row_length M2) (length M2) M2)
               \<longrightarrow> ((M \<otimes> M2)!(j-(length M2))!i)
              = f
                 (M!((j-(length M2)) div (length M2))!(i div (row_length M2)))
                 (M2!((j-(length M2)) mod length M2)!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using Cons.hyps
[PROOF STATE]
proof (prove)
using this:
(?i < row_length M * row_length M2 \<and> ?j < length M * length M2) \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! ?j ! ?i = M ! (?j div length M2) ! (?i div row_length M2) * M2 ! (?j mod length M2) ! (?i mod row_length M2)

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(mat (row_length (v#M)) (length (v#M)) (v#M))
                              \<longrightarrow>(mat (row_length M) (length M) M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> mat (row_length M) (length M) M
[PROOF STEP]
using reduct_matrix
[PROOF STATE]
proof (prove)
using this:
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 (v # M)) (length (v # M)) (v # M) \<longrightarrow> mat (row_length M) (length M) M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> mat (row_length M) (length M) M

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have 5:
      "(j \<ge> (length M2))
        \<longrightarrow> (((i<((row_length M)*(row_length M2)))
         \<and>((j-(length M2)) < (length M)*(length M2)))
         \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
         \<and>(mat (row_length M2) (length M2) M2)
         \<longrightarrow> ((M \<otimes> M2)!(j-(length M2))!i)
              = f
                (M!((j-(length M2)) div (length M2))!(i div (row_length M2)))
                (M2!((j-(length M2)) mod length M2)!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using 4 calculation(3)
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> mat (row_length M) (length M) M

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

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j - length M2 < length M * length M2 \<longrightarrow> j < (length M + 1) * length M2
[PROOF STEP]
have 6:
        "(((j-(length M2)) < (length M)*(length M2)))
              \<longrightarrow>
               (j < ((length (v#M))*(length M2)))"
[PROOF STATE]
proof (prove)
using this:
j - length M2 < length M * length M2 \<longrightarrow> j < (length M + 1) * length M2

goal (1 subgoal):
 1. j - length M2 < length M * length M2 \<longrightarrow> j < length (v # M) * length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j - length M2 < length M * length M2 \<longrightarrow> j < length (v # M) * length M2

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have 7:
      "(j \<ge> (length M2))
        \<longrightarrow>
          ((j-(length M2)) div (length M2)) = ((j div (length M2)) - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1
[PROOF STEP]
using  add_diff_cancel_left' div_add_self1 div_by_0
                 le_imp_diff_is_add add.commute zero_diff
[PROOF STATE]
proof (prove)
using this:
?a + ?b - ?a = ?b
?b \<noteq> (0::?'a) \<Longrightarrow> (?b + ?a) div ?b = ?a div ?b + (1::?'a)
?a div (0::?'a) = (0::?'a)
?i \<le> ?j \<Longrightarrow> (?j - ?i = ?k) = (?j = ?k + ?i)
?a + ?b = ?b + ?a
(0::?'a) - ?a = (0::?'a)

goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1
[PROOF STEP]
have 8:
      "(j \<ge> (length M2))
         \<longrightarrow>
          M!((j-(length M2)) div (length M2))
                      = M!((j div (length M2)) - 1)"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1

goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> M ! ((j - length M2) div length M2) = M ! (j div length M2 - 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<longrightarrow> M ! ((j - length M2) div length M2) = M ! (j div length M2 - 1)

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have step2:
   "(j \<ge> (length M2))
      \<longrightarrow>
       (((i<((row_length (v#M))*(row_length M2)))
       \<and>(j < (length (v#M))*(length M2)))
       \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
       \<and>(mat (row_length M2) (length M2) M2))
      \<longrightarrow>(((v#M) \<otimes> M2)!j!i) =
                          f
                         ((v#M)!(j div (length M2))!(i div (row_length M2)))
                         (M2!(j mod length M2)!(i mod (row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
proof(cases M2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. M2 = [] \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
M2 = []

goal (2 subgoals):
 1. M2 = [] \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(0 = ((row_length (v#M))*(row_length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = row_length (v # M) * row_length M2
[PROOF STEP]
using row_length_def Nil mult_0_right
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)
M2 = []
?m * 0 = 0

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

goal (2 subgoals):
 1. M2 = [] \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 = row_length (v # M) * row_length M2
[PROOF STEP]
have "(i < ((row_length (v#M))*(row_length M2))) \<longrightarrow> False"
[PROOF STATE]
proof (prove)
using this:
0 = row_length (v # M) * row_length M2

goal (1 subgoal):
 1. i < row_length (v # M) * row_length M2 \<longrightarrow> False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < row_length (v # M) * row_length M2 \<longrightarrow> False

goal (2 subgoals):
 1. M2 = [] \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < row_length (v # M) * row_length M2 \<longrightarrow> False
[PROOF STEP]
have " (j \<ge> (length M2))
                 \<longrightarrow>(((i<((row_length (v#M))*(row_length M2)))
                    \<and>(j < (length (v#M))*(length M2)))
                    \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
                    \<and>(mat (row_length M2) (length M2) M2))
                            \<longrightarrow> False"
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length M2 \<longrightarrow> False

goal (1 subgoal):
 1. length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False

goal (2 subgoals):
 1. M2 = [] \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
 2. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> False

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

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
case (Cons w N)
[PROOF STATE]
proof (state)
this:
M2 = w # N

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(k < (length M))\<and> (k \<ge> 1) \<longrightarrow> M!(k - 1)  = (v#M)!k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < length M \<and> 1 \<le> k \<longrightarrow> M ! (k - 1) = (v # M) ! k
[PROOF STEP]
using   not_one_le_zero nth_Cons'
[PROOF STATE]
proof (prove)
using this:
\<not> (1::?'a) \<le> (0::?'a)
(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))

goal (1 subgoal):
 1. k < length M \<and> 1 \<le> k \<longrightarrow> M ! (k - 1) = (v # M) ! k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k < length M \<and> 1 \<le> k \<longrightarrow> M ! (k - 1) = (v # M) ! k

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j \<ge> (length (w#N))) \<longrightarrow> (j div (length (w#N))) \<ge> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> 1 \<le> j div length (w # N)
[PROOF STEP]
using  div_le_mono div_self length_0_conv neq_Nil_conv
[PROOF STATE]
proof (prove)
using this:
?m \<le> ?n \<Longrightarrow> ?m div ?k \<le> ?n div ?k
?a \<noteq> (0::?'a) \<Longrightarrow> ?a div ?a = (1::?'a)
(length ?xs = 0) = (?xs = [])
(?xs \<noteq> []) = (\<exists>y ys. ?xs = y # ys)

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> 1 \<le> j div length (w # N)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> 1 \<le> j div length (w # N)

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> 1 \<le> j div length (w # N)

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j \<ge> (length (w#N))) \<longrightarrow> (j div (length (w#N)))- 1  \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> 0 \<le> j div length (w # N) - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> 0 \<le> j div length (w # N) - 1

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> 0 \<le> j div length (w # N) - 1

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j \<ge> (length (w#N)))
                          \<longrightarrow> M!((j div (length (w#N)))- 1 )
                                 = (v#M)!(j div (length (w#N)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))
[PROOF STEP]
using calculation(1) not_one_le_zero nth_Cons'
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> 1 \<le> j div length (w # N)
\<not> (1::?'a) \<le> (0::?'a)
(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from this 7
[PROOF STATE]
proof (chain)
picking this:
length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1
[PROOF STEP]
have 9:" (j \<ge> (length (w#N)))
                         \<longrightarrow>  M!((j-(length (w#N))) div (length (w#N)))
                                   = (v#M)!(j div (length (w#N)))"
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> M ! (j div length (w # N) - 1) = (v # M) ! (j div length (w # N))
length M2 \<le> j \<longrightarrow> (j - length M2) div length M2 = j div length M2 - 1
M2 = w # N

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have 10: "(j \<ge> (length (w#N)))
                     \<longrightarrow>  ((j-(length (w#N))) mod (length (w#N)))
                                   = (j mod(length (w#N)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)
[PROOF STEP]
using mod_if not_less
[PROOF STATE]
proof (prove)
using this:
?m mod ?n = (if ?m < ?n then ?m else (?m - ?n) mod ?n)
(\<not> ?x < ?y) = (?y \<le> ?x)

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
with 5 9
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))
length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)
[PROOF STEP]
have
     "(j \<ge> (length (w#N))) \<longrightarrow>
     ((i<((row_length M)*(row_length (w#N))))
     \<and>((j-(length (w#N))) < (length M)*(length (w#N)))
     \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
     \<and>(mat (row_length (w#N)) (length (w#N)) (w#N)))
     \<longrightarrow> (((M \<otimes> (w#N))!(j-(length (w#N)))!i)
          = f
              ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
              ((w#N)!(j mod length (w#N))!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))
length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<longrightarrow> (i < row_length M * row_length M2 \<and> j - length M2 < length M * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M \<otimes> M2) ! (j - length M2) ! i = M ! ((j - length M2) div length M2) ! (i div row_length M2) * M2 ! ((j - length M2) mod length M2) ! (i mod row_length M2)
length (w # N) \<le> j \<longrightarrow> M ! ((j - length (w # N)) div length (w # N)) = (v # M) ! (j div length (w # N))
length (w # N) \<le> j \<longrightarrow> (j - length (w # N)) mod length (w # N) = j mod length (w # N)
M2 = w # N

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have
      "(j \<ge> (length (w#N))) \<longrightarrow>
                ((i<((row_length M)*(row_length (w#N))))
                \<and>(j <(length (v#M))*(length (w#N)))
                \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
                \<and>(mat (row_length (w#N)) (length (w#N)) (w#N)))
                \<longrightarrow> (((M \<otimes> (w#N))!(j-(length (w#N)))!i)
                 = f
                    ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
                    ((w#N)!(j mod length (w#N))!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
using 6
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j - length (w # N) < length M * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
j - length M2 < length M * length M2 \<longrightarrow> j < length (v # M) * length M2

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have 11:
     "(j \<ge> (length (w#N))) \<longrightarrow>
            ((i<((row_length M)*(row_length (w#N))))
            \<and>(j <(length (v#M))*(length (w#N)))
            \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
            \<and>(mat (row_length (w#N)) (length (w#N)) (w#N)))
            \<longrightarrow> (((v#M) \<otimes> (w#N))!j!i) =
                    f
                    ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
                    ((w#N)!(j mod length (w#N))!(i mod (row_length (w#N))))"
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
using 3 Cons
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (M \<otimes> w # N) ! (j - length (w # N)) ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
length M2 \<le> j \<longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)
M2 = w # N

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

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have
      "(j \<ge> (length (w#N))) \<longrightarrow>
              ((i<((row_length (v#M))*(row_length (w#N))))
              \<and>(j <(length (v#M))*(length (w#N)))
              \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
              \<and>(mat (row_length (w#N)) (length (w#N)) (w#N)))
                     \<longrightarrow> (((v#M) \<otimes> (w#N))!j!i)
                = f
                    ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
                    ((w#N)!(j mod length (w#N))!(i mod (row_length (w#N))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
proof(cases M)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
M = []

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have Nil0:"(length (v#[])) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length [v] = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length [v] = 1

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length [v] = 1
[PROOF STEP]
have Nil1:
             "(j <(length (v#[]))*(length (w#N))) = (j< (length (w#N)))"
[PROOF STATE]
proof (prove)
using this:
length [v] = 1

goal (1 subgoal):
 1. (j < length [v] * length (w # N)) = (j < length (w # N))
[PROOF STEP]
by (metis Nil nat_mult_1)
[PROOF STATE]
proof (state)
this:
(j < length [v] * length (w # N)) = (j < length (w # N))

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have
              "row_length (v#[]) = (length v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_length [v] = length v
[PROOF STEP]
using row_length_def
[PROOF STATE]
proof (prove)
using this:
row_length ?xs \<equiv> if ?xs = [] then 0 else length (hd ?xs)

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

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row_length [v] = length v
[PROOF STEP]
have Nil2:
              "(i<((row_length (v#M))*(row_length (w#N))))
                                 = (i<((length v)*(row_length (w#N))))"
[PROOF STATE]
proof (prove)
using this:
row_length [v] = length v

goal (1 subgoal):
 1. (i < row_length (v # M) * row_length (w # N)) = (i < length v * row_length (w # N))
[PROOF STEP]
using Nil
[PROOF STATE]
proof (prove)
using this:
row_length [v] = length v
M = []

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

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(i < row_length (v # M) * row_length (w # N)) = (i < length v * row_length (w # N))
[PROOF STEP]
have "(j< (length (w#N))) \<longrightarrow> (j div (length (w#N))) = 0"
[PROOF STATE]
proof (prove)
using this:
(i < row_length (v # M) * row_length (w # N)) = (i < length v * row_length (w # N))

goal (1 subgoal):
 1. j < length (w # N) \<longrightarrow> j div length (w # N) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (w # N) \<longrightarrow> j div length (w # N) = 0

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
j < length (w # N) \<longrightarrow> j div length (w # N) = 0
[PROOF STEP]
have Nil3:
                 "(j< (length (w#N))) \<longrightarrow> (v#M)!(j div (length (w#N))) = v"
[PROOF STATE]
proof (prove)
using this:
j < length (w # N) \<longrightarrow> j div length (w # N) = 0

goal (1 subgoal):
 1. j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v
[PROOF STEP]
using Nil
[PROOF STATE]
proof (prove)
using this:
j < length (w # N) \<longrightarrow> j div length (w # N) = 0
M = []

goal (1 subgoal):
 1. j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v
[PROOF STEP]
have Nil4:
                 "(j< (length (w#N))) \<longrightarrow> (j mod (length (w#N))) = j"
[PROOF STATE]
proof (prove)
using this:
j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v

goal (1 subgoal):
 1. j < length (w # N) \<longrightarrow> j mod length (w # N) = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (w # N) \<longrightarrow> j mod length (w # N) = j

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length (w # N) \<longrightarrow> j mod length (w # N) = j
[PROOF STEP]
have Nil5:"(v#M) \<otimes> (w#N) = vec_mat_Tensor v (w#N)"
[PROOF STATE]
proof (prove)
using this:
j < length (w # N) \<longrightarrow> j mod length (w # N) = j

goal (1 subgoal):
 1. v # M \<otimes> w # N = vec_mat_Tensor v (w # N)
[PROOF STEP]
using Nil Tensor.simps(2) Tensor.simps(1)
[PROOF STATE]
proof (prove)
using this:
j < length (w # N) \<longrightarrow> j mod length (w # N) = j
M = []
?x # ?xs \<otimes> ?ys = vec_mat_Tensor ?x ?ys @ (?xs \<otimes> ?ys)
[] \<otimes> ?xs = []

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

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
from vec_mat_Tensor_elements
[PROOF STATE]
proof (chain)
picking this:
\<forall>i j. (i < length ?v * row_length ?M \<and> j < length ?M) \<and> mat (row_length ?M) (length ?M) ?M \<longrightarrow> vec_mat_Tensor ?v ?M ! j ! i = ?v ! (i div row_length ?M) * ?M ! j ! (i mod row_length ?M)
[PROOF STEP]
have
                      "(((i<((length v)*(row_length (w#N))))
                       \<and>(j < (length (w#N))))
                       \<and>(mat (row_length (w#N)) (length (w#N)) (w#N))
                          \<longrightarrow> ((vec_mat_Tensor v (w#N))!j!i)
                                    = f
                                       (v!(i div (row_length (w#N))))
                                       ((w#N)!j!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
\<forall>i j. (i < length ?v * row_length ?M \<and> j < length ?M) \<and> mat (row_length ?M) (length ?M) ?M \<longrightarrow> vec_mat_Tensor ?v ?M ! j ! i = ?v ! (i div row_length ?M) * ?M ! j ! (i mod row_length ?M)

goal (1 subgoal):
 1. (i < length v * row_length (w # N) \<and> j < length (w # N)) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(i < length v * row_length (w # N) \<and> j < length (w # N)) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(i < length v * row_length (w # N) \<and> j < length (w # N)) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
[PROOF STEP]
have
            "((i<((row_length (v#M))*(row_length (w#N))))
             \<and>(j < ((length (v#M))*(length (w#N))))
             \<and>(mat (row_length (w#N)) (length (w#N)) (w#N))
         \<longrightarrow> ((vec_mat_Tensor v (w#N))!j!i)
                    = f (v!(i div (row_length (w#N))))
                        ((w#N)!j!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
(i < length v * row_length (w # N) \<and> j < length (w # N)) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))

goal (1 subgoal):
 1. i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
[PROOF STEP]
using Nil1 Nil2 Nil
[PROOF STATE]
proof (prove)
using this:
(i < length v * row_length (w # N) \<and> j < length (w # N)) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
(j < length [v] * length (w # N)) = (j < length (w # N))
(i < row_length (v # M) * row_length (w # N)) = (i < length v * row_length (w # N))
M = []

goal (1 subgoal):
 1. i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
[PROOF STEP]
have
            "((i<((row_length (v#M))*(row_length (w#N))))
             \<and>(j < ((length (v#M))*(length (w#N))))
             \<and>(mat (row_length (w#N)) (length (w#N)) (w#N))
          \<longrightarrow> (((v#M)\<otimes>(w#N))!j!i)
                     = f
                        ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
                        ((w#N)!(j mod (length (w#N)))!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))

goal (1 subgoal):
 1. i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
using Nil3 Nil4  Nil5 Nil
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> vec_mat_Tensor v (w # N) ! j ! i = v ! (i div row_length (w # N)) * (w # N) ! j ! (i mod row_length (w # N))
j < length (w # N) \<longrightarrow> (v # M) ! (j div length (w # N)) = v
j < length (w # N) \<longrightarrow> j mod length (w # N) = j
v # M \<otimes> w # N = vec_mat_Tensor v (w # N)
M = []

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

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have
             "((i<((row_length (v#M))*(row_length (w#N))))
             \<and>(j < ((length (v#M))*(length (w#N))))
             \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
             \<and>(mat (row_length (w#N)) (length (w#N)) (w#N))
                  \<longrightarrow> (((v#M)\<otimes>(w#N))!j!i)
                       = f
                         ((v#M)!(j div (length (w#N)))!(i div (row_length (w#N))))
                         ((w#N)!(j mod (length (w#N)))!(i mod (row_length (w#N)))))"
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

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

goal (2 subgoals):
 1. M = [] \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
 2. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

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

goal (1 subgoal):
 1. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
case (Cons u P)
[PROOF STATE]
proof (state)
this:
M = u # P

goal (1 subgoal):
 1. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
have "(mat (row_length (v#M)) (length (v#M)) (v#M)) \<longrightarrow> (row_length (v#M)) = (row_length M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> row_length (v # M) = row_length M
[PROOF STEP]
using Cons row_length_eq
[PROOF STATE]
proof (prove)
using this:
M = u # P
mat (row_length (?a # ?b # ?N)) (length (?a # ?b # ?N)) (?a # ?b # ?N) \<longrightarrow> row_length (?a # ?b # ?N) = row_length (?b # ?N)

goal (1 subgoal):
 1. mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> row_length (v # M) = row_length M
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> row_length (v # M) = row_length M

goal (1 subgoal):
 1. \<And>a list. M = a # list \<Longrightarrow> length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
from this 11
[PROOF STATE]
proof (chain)
picking this:
mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> row_length (v # M) = row_length M
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat (row_length (v # M)) (length (v # M)) (v # M) \<longrightarrow> row_length (v # M) = row_length M
length (w # N) \<le> j \<longrightarrow> i < row_length M * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

goal (1 subgoal):
 1. \<And>a list. M2 = a # list \<Longrightarrow> length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
length (w # N) \<le> j \<longrightarrow> i < row_length (v # M) * row_length (w # N) \<and> j < length (v # M) * length (w # N) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length (w # N)) (length (w # N)) (w # N) \<longrightarrow> (v # M \<otimes> w # N) ! j ! i = (v # M) ! (j div length (w # N)) ! (i div row_length (w # N)) * (w # N) ! (j mod length (w # N)) ! (i mod row_length (w # N))

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

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

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
have "(j<(length M2)) \<or> (j \<ge> (length M2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length M2 \<or> length M2 \<le> j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<or> length M2 \<le> j

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from this step1 step2 logic
[PROOF STATE]
proof (chain)
picking this:
j < length M2 \<or> length M2 \<le> j
j < length M2 \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
\<lbrakk>?A \<longrightarrow> ?B; \<not> ?A \<longrightarrow> ?B\<rbrakk> \<Longrightarrow> ?B
[PROOF STEP]
have
     "(((i<((row_length (v#M))*(row_length M2)))
      \<and>(j < (length M2) * (length (v#M))))
      \<and>(mat (row_length (v#M)) (length (v#M)) (v#M))
      \<and>(mat (row_length M2) (length M2) M2)
      \<longrightarrow> ( ((v#M) \<otimes> M2)!j!i)
                 = f
                     ((v#M)!(j div (length M2))!(i div (row_length M2)))
                     (M2!(j mod (length M2))!(i mod (row_length M2))))"
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<or> length M2 \<le> j
j < length M2 \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
\<lbrakk>?A \<longrightarrow> ?B; \<not> ?A \<longrightarrow> ?B\<rbrakk> \<Longrightarrow> ?B

goal (1 subgoal):
 1. (i < row_length (v # M) * row_length M2 \<and> j < length M2 * length (v # M)) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
using  mult.commute
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<or> length M2 \<le> j
j < length M2 \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
length M2 \<le> j \<longrightarrow> (i < row_length (v # M) * row_length M2 \<and> j < length (v # M) * length M2) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
\<lbrakk>?A \<longrightarrow> ?B; \<not> ?A \<longrightarrow> ?B\<rbrakk> \<Longrightarrow> ?B
?a * ?b = ?b * ?a

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

goal (1 subgoal):
 1. \<And>a M1 i j. (\<And>i j. (i < row_length M1 * row_length M2 \<and> j < length M1 * length M2) \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (M1 \<otimes> M2) ! j ! i = M1 ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)) \<Longrightarrow> (i < row_length (a # M1) * row_length M2 \<and> j < length (a # M1) * length M2) \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (a # M1 \<otimes> M2) ! j ! i = (a # M1) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
(i < row_length (v # M) * row_length M2 \<and> j < length M2 * length (v # M)) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length 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> j < length M2 * length (v # M)) \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> (v # M \<otimes> M2) ! j ! i = (v # M) ! (j div length M2) ! (i div row_length M2) * M2 ! (j mod length M2) ! (i mod row_length M2)

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

goal:
No subgoals!
[PROOF STEP]
qed