[STATEMENT]
lemma mult_distr_tensor:
  assumes a1:"dim_col A = dim_row B" and a2:"dim_col C = dim_row D" and a3:"dim_col A > 0" and
    a4:"dim_col B > 0" and a5:"dim_col C > 0" and a6:"dim_col D > 0"
  shows "(A * B) \<Otimes> (C * D) = (A \<Otimes> C) * (B \<Otimes> D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
define A' B' C' D' M N where "A' = mat_to_cols_list A" and "B' = mat_to_cols_list B" and
    "C' = mat_to_cols_list C" and "D' = mat_to_cols_list D" and
    "M = mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))" and
    "N = mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))"
[PROOF STATE]
proof (state)
this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D
M = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))
N = Tensor.mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D
M = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))
N = Tensor.mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))
[PROOF STEP]
have "(A \<Otimes> C) * (B \<Otimes> D) = M * N"
[PROOF STATE]
proof (prove)
using this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D
M = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))
N = Tensor.mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))

goal (1 subgoal):
 1. (A \<Otimes> C) * (B \<Otimes> D) = M * N
[PROOF STEP]
by (simp add: tensor_mat_def)
[PROOF STATE]
proof (state)
this:
(A \<Otimes> C) * (B \<Otimes> D) = M * N

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(A \<Otimes> C) * (B \<Otimes> D) = M * N

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
have "\<dots> = mat_of_cols_list (dim_row A * dim_row C) (plus_mult.matrix_mult (*) 0 (+)
  (mat_to_cols_list M) (mat_to_cols_list N))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M * N = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N))
[PROOF STEP]
using assms M_def N_def dim_col_tensor_mat dim_row_tensor_mat tensor_mat_def
[PROOF STATE]
proof (prove)
using this:
dim_col A = dim_row B
dim_col C = dim_row D
0 < dim_col A
0 < dim_col B
0 < dim_col C
0 < dim_col D
M = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))
N = Tensor.mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))
dim_col (?A \<Otimes> ?B) = dim_col ?A * dim_col ?B
dim_row (?A \<Otimes> ?B) = dim_row ?A * dim_row ?B
?A \<Otimes> ?B \<equiv> Tensor.mat_of_cols_list (dim_row ?A * dim_row ?B) (mult.Tensor (*) (mat_to_cols_list ?A) (mat_to_cols_list ?B))

goal (1 subgoal):
 1. M * N = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N))
[PROOF STEP]
by(simp add: matrix_mult_to_times_mat)
[PROOF STATE]
proof (state)
this:
M * N = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M * N = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
have f1:"\<dots> = mat_of_cols_list (dim_row A * dim_row C) (plus_mult.matrix_mult (*) 0 (+)
  (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
define M' N' where "M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)" and
      "N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)"
[PROOF STATE]
proof (state)
this:
M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)
N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)
N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)
[PROOF STEP]
have "mat (mult.row_length M') (length M') M'"
[PROOF STATE]
proof (prove)
using this:
M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)
N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length M') (length M') M'
[PROOF STEP]
using M'_def mult.effective_well_defined_Tensor[of 1 "(*)"] mat_to_cols_list_is_mat a3 a5
[PROOF STATE]
proof (prove)
using this:
M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)
N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)
M' = mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C)
\<lbrakk>Matrix_Tensor.mult (1::?'a1) (*); Matrix_Legacy.mat (mult.row_length ?M1.0) (length ?M1.0) ?M1.0; Matrix_Legacy.mat (mult.row_length ?M2.0) (length ?M2.0) ?M2.0\<rbrakk> \<Longrightarrow> Matrix_Legacy.mat (mult.row_length ?M1.0 * mult.row_length ?M2.0) (length ?M1.0 * length ?M2.0) (mult.Tensor (*) ?M1.0 ?M2.0)
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)
0 < dim_col A
0 < dim_col C

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length M') (length M') M'
[PROOF STEP]
by (smt mult.length_Tensor mult.row_length_mat plus_mult_cpx plus_mult_def)
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length M') (length M') M'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length M') (length M') M'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
have "mat (mult.row_length N') (length N') N'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length N') (length N') N'
[PROOF STEP]
using N'_def mult.effective_well_defined_Tensor[of 1 "(*)"] mat_to_cols_list_is_mat a4 a6
[PROOF STATE]
proof (prove)
using this:
N' = mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D)
\<lbrakk>Matrix_Tensor.mult (1::?'a1) (*); Matrix_Legacy.mat (mult.row_length ?M1.0) (length ?M1.0) ?M1.0; Matrix_Legacy.mat (mult.row_length ?M2.0) (length ?M2.0) ?M2.0\<rbrakk> \<Longrightarrow> Matrix_Legacy.mat (mult.row_length ?M1.0 * mult.row_length ?M2.0) (length ?M1.0 * length ?M2.0) (mult.Tensor (*) ?M1.0 ?M2.0)
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)
0 < dim_col B
0 < dim_col D

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length N') (length N') N'
[PROOF STEP]
by (smt mult.length_Tensor mult.row_length_mat plus_mult_cpx plus_mult_def)
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length N') (length N') N'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Matrix_Legacy.mat (mult.row_length M') (length M') M'
Matrix_Legacy.mat (mult.row_length N') (length N') N'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Matrix_Legacy.mat (mult.row_length M') (length M') M'
Matrix_Legacy.mat (mult.row_length N') (length N') N'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
using list_to_mat_to_cols_list M_def N_def mult.row_length_mat row_length_mat_to_cols_list
      assms(3) a4 a5 a6 A'_def B'_def C'_def D'_def
[PROOF STATE]
proof (prove)
using this:
Matrix_Legacy.mat (mult.row_length M') (length M') M'
Matrix_Legacy.mat (mult.row_length N') (length N') N'
Matrix_Legacy.mat ?nr ?nc ?l \<Longrightarrow> mat_to_cols_list (Tensor.mat_of_cols_list ?nr ?l) = ?l
M = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list A) (mat_to_cols_list C))
N = Tensor.mat_of_cols_list (dim_row B * dim_row D) (mult.Tensor (*) (mat_to_cols_list B) (mat_to_cols_list D))
Matrix_Tensor.mult ?id ?f \<Longrightarrow> mult.row_length (mult.Tensor ?f ?m1.0 ?m2.0) = mult.row_length ?m1.0 * mult.row_length ?m2.0
0 < dim_col ?A \<Longrightarrow> mult.row_length (mat_to_cols_list ?A) = dim_row ?A
0 < dim_col A
0 < dim_col B
0 < dim_col C
0 < dim_col D
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
[PROOF STEP]
by(metis M'_def N'_def plus_mult_cpx plus_mult_def)
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
have "\<dots> = mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*)
    (plus_mult.matrix_mult (*) 0 (+) A' B')
    (plus_mult.matrix_mult (*) 0 (+) C' D'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have f2:"mat (mult.row_length A') (length A') A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length A') (length A') A'
[PROOF STEP]
using A'_def a3 mat_to_cols_list_is_mat
[PROOF STATE]
proof (prove)
using this:
A' = mat_to_cols_list A
0 < dim_col A
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length A') (length A') A'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length A') (length A') A'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length A') (length A') A'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "mat (mult.row_length B') (length B') B'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length B') (length B') B'
[PROOF STEP]
using B'_def a4 mat_to_cols_list_is_mat
[PROOF STATE]
proof (prove)
using this:
B' = mat_to_cols_list B
0 < dim_col B
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length B') (length B') B'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length B') (length B') B'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length B') (length B') B'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "mat (mult.row_length C') (length C') C'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length C') (length C') C'
[PROOF STEP]
using C'_def a5 mat_to_cols_list_is_mat
[PROOF STATE]
proof (prove)
using this:
C' = mat_to_cols_list C
0 < dim_col C
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length C') (length C') C'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length C') (length C') C'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length C') (length C') C'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "mat (mult.row_length D') (length D') D'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length D') (length D') D'
[PROOF STEP]
using D'_def a6 mat_to_cols_list_is_mat
[PROOF STATE]
proof (prove)
using this:
D' = mat_to_cols_list D
0 < dim_col D
0 < dim_col ?A \<Longrightarrow> Matrix_Legacy.mat (mult.row_length (mat_to_cols_list ?A)) (length (mat_to_cols_list ?A)) (mat_to_cols_list ?A)

goal (1 subgoal):
 1. Matrix_Legacy.mat (mult.row_length D') (length D') D'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length D') (length D') D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.mat (mult.row_length D') (length D') D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "length A' = mult.row_length B'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length A' = mult.row_length B'
[PROOF STEP]
using A'_def B'_def a1 a4
[PROOF STATE]
proof (prove)
using this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
dim_col A = dim_row B
0 < dim_col B

goal (1 subgoal):
 1. length A' = mult.row_length B'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length A' = mult.row_length B'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length A' = mult.row_length B'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "length C' = mult.row_length D'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length C' = mult.row_length D'
[PROOF STEP]
using C'_def D'_def a2 a6
[PROOF STATE]
proof (prove)
using this:
C' = mat_to_cols_list C
D' = mat_to_cols_list D
dim_col C = dim_row D
0 < dim_col D

goal (1 subgoal):
 1. length C' = mult.row_length D'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length C' = mult.row_length D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length C' = mult.row_length D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
have "A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []
[PROOF STEP]
using A'_def B'_def C'_def D'_def a3 a4 a5 a6
[PROOF STATE]
proof (prove)
using this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D
0 < dim_col A
0 < dim_col B
0 < dim_col C
0 < dim_col D

goal (1 subgoal):
 1. A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Matrix_Legacy.mat (mult.row_length A') (length A') A'
Matrix_Legacy.mat (mult.row_length B') (length B') B'
Matrix_Legacy.mat (mult.row_length C') (length C') C'
Matrix_Legacy.mat (mult.row_length D') (length D') D'
length A' = mult.row_length B'
length C' = mult.row_length D'
A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []
[PROOF STEP]
have "plus_mult.matrix_match A' B' C' D'"
[PROOF STATE]
proof (prove)
using this:
Matrix_Legacy.mat (mult.row_length A') (length A') A'
Matrix_Legacy.mat (mult.row_length B') (length B') B'
Matrix_Legacy.mat (mult.row_length C') (length C') C'
Matrix_Legacy.mat (mult.row_length D') (length D') D'
length A' = mult.row_length B'
length C' = mult.row_length D'
A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []

goal (1 subgoal):
 1. plus_mult.matrix_match A' B' C' D'
[PROOF STEP]
using plus_mult.matrix_match_def[of 1 "(*)" 0 "(+)" "a_inv cpx_rng"]
[PROOF STATE]
proof (prove)
using this:
Matrix_Legacy.mat (mult.row_length A') (length A') A'
Matrix_Legacy.mat (mult.row_length B') (length B') B'
Matrix_Legacy.mat (mult.row_length C') (length C') C'
Matrix_Legacy.mat (mult.row_length D') (length D') D'
length A' = mult.row_length B'
length C' = mult.row_length D'
A' \<noteq> [] \<and> B' \<noteq> [] \<and> C' \<noteq> [] \<and> D' \<noteq> []
plus_mult 1 (*) 0 (+) (a_inv cpx_rng) \<Longrightarrow> plus_mult.matrix_match ?A1.0 ?A2.0 ?B1.0 ?B2.0 \<equiv> Matrix_Legacy.mat (mult.row_length ?A1.0) (length ?A1.0) ?A1.0 \<and> Matrix_Legacy.mat (mult.row_length ?A2.0) (length ?A2.0) ?A2.0 \<and> Matrix_Legacy.mat (mult.row_length ?B1.0) (length ?B1.0) ?B1.0 \<and> Matrix_Legacy.mat (mult.row_length ?B2.0) (length ?B2.0) ?B2.0 \<and> length ?A1.0 = mult.row_length ?A2.0 \<and> length ?B1.0 = mult.row_length ?B2.0 \<and> ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> []

goal (1 subgoal):
 1. plus_mult.matrix_match A' B' C' D'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
plus_mult.matrix_match A' B' C' D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
plus_mult.matrix_match A' B' C' D'

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
using f1 plus_mult.distributivity plus_mult_cpx
[PROOF STATE]
proof (prove)
using this:
plus_mult.matrix_match A' B' C' D'
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mat_to_cols_list M)) (mat_to_cols_list M) (mat_to_cols_list N)) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D'))
\<lbrakk>plus_mult ?id ?f ?zer ?g ?inver; plus_mult.matrix_match ?A1.0 ?A2.0 ?B1.0 ?B2.0\<rbrakk> \<Longrightarrow> mult.Tensor ?f (mat_multI ?zer ?g ?f (mult.row_length ?A1.0) ?A1.0 ?A2.0) (mat_multI ?zer ?g ?f (mult.row_length ?B1.0) ?B1.0 ?B2.0) = mat_multI ?zer ?g ?f (mult.row_length (mult.Tensor ?f ?A1.0 ?B1.0)) (mult.Tensor ?f ?A1.0 ?B1.0) (mult.Tensor ?f ?A2.0 ?B2.0)
plus_mult 1 (*) 0 (+) (a_inv cpx_rng)

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mat_mult (mult.row_length (mult.Tensor (*) A' C')) (mult.Tensor (*) A' C') (mult.Tensor (*) B' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D'))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
have "\<dots> = mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*)
   (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))
[PROOF STEP]
using A'_def B'_def C'_def D'_def a1 a2 a3 a5
[PROOF STATE]
proof (prove)
using this:
A' = mat_to_cols_list A
B' = mat_to_cols_list B
C' = mat_to_cols_list C
D' = mat_to_cols_list D
dim_col A = dim_row B
dim_col C = dim_row D
0 < dim_col A
0 < dim_col C

goal (1 subgoal):
 1. Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_mult (mult.row_length A') A' B') (mat_mult (mult.row_length C') C' D')) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(A \<Otimes> C) * (B \<Otimes> D) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(A \<Otimes> C) * (B \<Otimes> D) = Tensor.mat_of_cols_list (dim_row A * dim_row C) (mult.Tensor (*) (mat_to_cols_list (A * B)) (mat_to_cols_list (C * D)))

goal (1 subgoal):
 1. A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)
[PROOF STEP]
by(simp add: tensor_mat_def)
[PROOF STATE]
proof (state)
this:
A * B \<Otimes> C * D = (A \<Otimes> C) * (B \<Otimes> D)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma triangle_num_le_iff: "triangle_num m \<le> triangle_num n \<longleftrightarrow> m \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (triangle_num m \<le> triangle_num n) = (m \<le> n)
[PROOF STEP]
using strict_mono_less_eq[OF strict_mono_triangle_num]
[PROOF STATE]
proof (prove)
using this:
(triangle_num ?x \<le> triangle_num ?y) = (?x \<le> ?y)

goal (1 subgoal):
 1. (triangle_num m \<le> triangle_num n) = (m \<le> n)
[PROOF STEP]
.


[STATEMENT]
lemma eq_len_iff_less: assumes eq: "x \<cdot> y = u \<cdot> v" shows "\<^bold>|x\<^bold>| < \<^bold>|u\<^bold>| \<longleftrightarrow> \<^bold>|v\<^bold>| < \<^bold>|y\<^bold>|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<^bold>|x\<^bold>| < \<^bold>|u\<^bold>|) = (\<^bold>|v\<^bold>| < \<^bold>|y\<^bold>|)
[PROOF STEP]
using lenarg[OF eq]
[PROOF STATE]
proof (prove)
using this:
\<^bold>|x \<cdot> y\<^bold>| = \<^bold>|u \<cdot> v\<^bold>|

goal (1 subgoal):
 1. (\<^bold>|x\<^bold>| < \<^bold>|u\<^bold>|) = (\<^bold>|v\<^bold>| < \<^bold>|y\<^bold>|)
[PROOF STEP]
unfolding lenmorph
[PROOF STATE]
proof (prove)
using this:
\<^bold>|x\<^bold>| + \<^bold>|y\<^bold>| = \<^bold>|u\<^bold>| + \<^bold>|v\<^bold>|

goal (1 subgoal):
 1. (\<^bold>|x\<^bold>| < \<^bold>|u\<^bold>|) = (\<^bold>|v\<^bold>| < \<^bold>|y\<^bold>|)
[PROOF STEP]
by auto


[STATEMENT]
lemma transpose_of_prod:
  fixes M N::"complex Matrix.mat"
  assumes "dim_col M = dim_row N"
  shows "(M * N)\<^sup>t = N\<^sup>t * (M\<^sup>t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M * N\<^sup>t = N\<^sup>t * M\<^sup>t
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
fix i j::nat
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
assume a0: "i < dim_row (N\<^sup>t * (M\<^sup>t))" and a1: "j < dim_col (N\<^sup>t * (M\<^sup>t))"
[PROOF STATE]
proof (state)
this:
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
have "(M * N)\<^sup>t $$ (i,j) = (M * N) $$ (j,i)"
[PROOF STATE]
proof (prove)
using this:
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)

goal (1 subgoal):
 1. M * N\<^sup>t $$ (i, j) = (M * N) $$ (j, i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M * N\<^sup>t $$ (i, j) = (M * N) $$ (j, i)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M * N\<^sup>t $$ (i, j) = (M * N) $$ (j, i)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
have "... = (\<Sum>k<dim_row M\<^sup>t.  M $$ (j,k) * N $$ (k,i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M * N) $$ (j, i) = (\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i))
[PROOF STEP]
using assms a0 a1
[PROOF STATE]
proof (prove)
using this:
dim_col M = dim_row N
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)

goal (1 subgoal):
 1. (M * N) $$ (j, i) = (\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(M * N) $$ (j, i) = (\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(M * N) $$ (j, i) = (\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
have "... = (\<Sum>k<dim_row M\<^sup>t. N $$ (k,i) * M $$ (j,k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i)) = (\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k))
[PROOF STEP]
by (simp add: semiring_normalization_rules(7))
[PROOF STATE]
proof (state)
this:
(\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i)) = (\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<dim_row M\<^sup>t. M $$ (j, k) * N $$ (k, i)) = (\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
have "... = (\<Sum>k<dim_row M\<^sup>t. ((N\<^sup>t) $$ (i,k)) * (M\<^sup>t) $$ (k,j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k)) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))
[PROOF STEP]
using assms a0 a1
[PROOF STATE]
proof (prove)
using this:
dim_col M = dim_row N
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)

goal (1 subgoal):
 1. (\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k)) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k<dim_row M\<^sup>t. N $$ (k, i) * M $$ (j, k)) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (N\<^sup>t * M\<^sup>t); j < dim_col (N\<^sup>t * M\<^sup>t)\<rbrakk> \<Longrightarrow> M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
 2. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 3. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
M * N\<^sup>t $$ (i, j) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))
[PROOF STEP]
show "((M * N)\<^sup>t) $$ (i,j) = (N\<^sup>t * (M\<^sup>t)) $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
M * N\<^sup>t $$ (i, j) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))

goal (1 subgoal):
 1. M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
[PROOF STEP]
using assms a0 a1
[PROOF STATE]
proof (prove)
using this:
M * N\<^sup>t $$ (i, j) = (\<Sum>k<dim_row M\<^sup>t. N\<^sup>t $$ (i, k) * M\<^sup>t $$ (k, j))
dim_col M = dim_row N
i < dim_row (N\<^sup>t * M\<^sup>t)
j < dim_col (N\<^sup>t * M\<^sup>t)

goal (1 subgoal):
 1. M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M * N\<^sup>t $$ (i, j) = (N\<^sup>t * M\<^sup>t) $$ (i, j)

goal (2 subgoals):
 1. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 2. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
 2. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
show "dim_row ((M * N)\<^sup>t) = dim_row (N\<^sup>t * (M\<^sup>t))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row M * N\<^sup>t = dim_row (N\<^sup>t * M\<^sup>t)

goal (1 subgoal):
 1. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
show "dim_col ((M * N)\<^sup>t) = dim_col (N\<^sup>t * (M\<^sup>t))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_col M * N\<^sup>t = dim_col (N\<^sup>t * M\<^sup>t)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem Class_commutes_with_inverse:
  "a \<in> G \<Longrightarrow> quotient.inverse (Class a) = Class (inverse a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> G \<Longrightarrow> quotient.inverse (Class a) = Class (inverse a)
[PROOF STEP]
by (rule quotient.inverse_equality) (auto simp: Class_right_inverse Class_left_inverse)


[STATEMENT]
lemma exp_1_bounds:
  assumes "x > (0::real)"
  shows   "exp 1 > (1 + 1 / x) powr x" and "exp 1 < (1 + 1 / x) powr (x+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + 1 / x) powr x < exp 1 &&& exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (1 + 1 / x) powr x < exp 1
 2. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
have "ln (1 + 1 / x) < 1 / x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (1 + 1 / x) < 1 / x
[PROOF STEP]
using ln_add_one_self_less_self assms
[PROOF STATE]
proof (prove)
using this:
0 < ?x \<Longrightarrow> ln (1 + ?x) < ?x
0 < x

goal (1 subgoal):
 1. ln (1 + 1 / x) < 1 / x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln (1 + 1 / x) < 1 / x

goal (2 subgoals):
 1. (1 + 1 / x) powr x < exp 1
 2. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
thus "exp 1 > (1 + 1 / x) powr x"
[PROOF STATE]
proof (prove)
using this:
ln (1 + 1 / x) < 1 / x

goal (1 subgoal):
 1. (1 + 1 / x) powr x < exp 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
ln (1 + 1 / x) < 1 / x
0 < x

goal (1 subgoal):
 1. (1 + 1 / x) powr x < exp 1
[PROOF STEP]
by (simp add: field_simps powr_def)
[PROOF STATE]
proof (state)
this:
(1 + 1 / x) powr x < exp 1

goal (1 subgoal):
 1. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
have "1 < (x + 1) * ln ((x + 1) / x)" (is "_ < ?f x")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < (x + 1) * ln ((x + 1) / x)
[PROOF STEP]
proof (rule DERIV_neg_imp_decreasing_at_top[where ?f = ?f])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
fix t
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
assume t: "x \<le> t"
[PROOF STATE]
proof (state)
this:
x \<le> t

goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
have "(?f has_field_derivative (ln (1 + 1 / t) - 1 / t)) (at t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)
[PROOF STEP]
using t assms
[PROOF STATE]
proof (prove)
using this:
x \<le> t
0 < x

goal (1 subgoal):
 1. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp:divide_simps)
[PROOF STATE]
proof (state)
this:
((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)

goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)

goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
have "ln (1 + 1 / t) - 1 / t < 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (1 + 1 / t) - 1 / t < 0
[PROOF STEP]
using ln_add_one_self_less_self[of "1 / t"] t assms
[PROOF STATE]
proof (prove)
using this:
0 < 1 / t \<Longrightarrow> ln (1 + 1 / t) < 1 / t
x \<le> t
0 < x

goal (1 subgoal):
 1. ln (1 + 1 / t) - 1 / t < 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ln (1 + 1 / t) - 1 / t < 0

goal (2 subgoals):
 1. \<And>xa. x \<le> xa \<Longrightarrow> \<exists>y. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative y) (at xa) \<and> y < 0
 2. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)
ln (1 + 1 / t) - 1 / t < 0
[PROOF STEP]
show "\<exists>y. ((\<lambda>t. (t + 1) * ln ((t + 1) / t)) has_real_derivative y) (at t) \<and> y < 0"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>a. (a + 1) * ln ((a + 1) / a)) has_real_derivative ln (1 + 1 / t) - 1 / t) (at t)
ln (1 + 1 / t) - 1 / t < 0

goal (1 subgoal):
 1. \<exists>y. ((\<lambda>t. (t + 1) * ln ((t + 1) / t)) has_real_derivative y) (at t) \<and> y < 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>y. ((\<lambda>t. (t + 1) * ln ((t + 1) / t)) has_real_derivative y) (at t) \<and> y < 0

goal (1 subgoal):
 1. ((\<lambda>a. (a + 1) * ln ((a + 1) / a)) \<longlongrightarrow> 1) at_top
[PROOF STEP]
qed real_asymp
[PROOF STATE]
proof (state)
this:
1 < (x + 1) * ln ((x + 1) / x)

goal (1 subgoal):
 1. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
thus "exp 1 < (1 + 1 / x) powr (x + 1)"
[PROOF STATE]
proof (prove)
using this:
1 < (x + 1) * ln ((x + 1) / x)

goal (1 subgoal):
 1. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 < (x + 1) * ln ((x + 1) / x)
0 < x

goal (1 subgoal):
 1. exp 1 < (1 + 1 / x) powr (x + 1)
[PROOF STEP]
by (simp add: powr_def field_simps)
[PROOF STATE]
proof (state)
this:
exp 1 < (1 + 1 / x) powr (x + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prime_multiplicity_square_part:
  assumes "prime p"
  shows   "multiplicity p (square_part n) = multiplicity p n div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiplicity p (square_part n) = multiplicity p n div 2
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = (0::'a) \<Longrightarrow> multiplicity p (square_part n) = multiplicity p n div 2
 2. n \<noteq> (0::'a) \<Longrightarrow> multiplicity p (square_part n) = multiplicity p n div 2
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> (0::'a)

goal (2 subgoals):
 1. n = (0::'a) \<Longrightarrow> multiplicity p (square_part n) = multiplicity p n div 2
 2. n \<noteq> (0::'a) \<Longrightarrow> multiplicity p (square_part n) = multiplicity p n div 2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<noteq> (0::'a)

goal (1 subgoal):
 1. multiplicity p (square_part n) = multiplicity p n div 2
[PROOF STEP]
unfolding square_part_nonzero[OF False] multiplicity_normalize_right
[PROOF STATE]
proof (prove)
using this:
n \<noteq> (0::'a)

goal (1 subgoal):
 1. multiplicity p (\<Prod>p\<in>prime_factors n. p ^ (multiplicity p n div 2)) = multiplicity p n div 2
[PROOF STEP]
using finite_prime_divisors[of n] assms
[PROOF STATE]
proof (prove)
using this:
n \<noteq> (0::'a)
n \<noteq> (0::'a) \<Longrightarrow> finite {p. prime p \<and> p dvd n}
prime p

goal (1 subgoal):
 1. multiplicity p (\<Prod>p\<in>prime_factors n. p ^ (multiplicity p n div 2)) = multiplicity p n div 2
[PROOF STEP]
by (subst multiplicity_prod_prime_powers)
       (auto simp: not_dvd_imp_multiplicity_0 prime_factors_dvd multiplicity_prod_prime_powers)
[PROOF STATE]
proof (state)
this:
multiplicity p (square_part n) = multiplicity p n div 2

goal (1 subgoal):
 1. n = (0::'a) \<Longrightarrow> multiplicity p (square_part n) = multiplicity p n div 2
[PROOF STEP]
qed auto


[STATEMENT]
lemma homotopic_pathsI:
  fixes h :: "real \<times> real \<Rightarrow> _"
  assumes "continuous_on ({0..1} \<times> {0..1}) h"
  assumes "h ` ({0..1} \<times> {0..1}) \<subseteq> s"
  assumes "\<And>x. x \<in> {0..1} \<Longrightarrow> h (0, x) = p x"
  assumes "\<And>x. x \<in> {0..1} \<Longrightarrow> h (1, x) = q x"
  assumes "\<And>x. x \<in> {0..1} \<Longrightarrow> pathstart (h \<circ> Pair x) = pathstart p"
  assumes "\<And>x. x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair x) = pathfinish p"
  shows   "homotopic_paths s p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_paths s p q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on ({0..1} \<times> {0..1}) h
h ` ({0..1} \<times> {0..1}) \<subseteq> s
?x \<in> {0..1} \<Longrightarrow> h (0, ?x) = p ?x
?x \<in> {0..1} \<Longrightarrow> h (1, ?x) = q ?x
?x \<in> {0..1} \<Longrightarrow> pathstart (h \<circ> Pair ?x) = pathstart p
?x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair ?x) = pathfinish p

goal (1 subgoal):
 1. homotopic_paths s p q
[PROOF STEP]
unfolding homotopic_paths
[PROOF STATE]
proof (prove)
using this:
continuous_on ({0..1} \<times> {0..1}) h
h ` ({0..1} \<times> {0..1}) \<subseteq> s
?x \<in> {0..1} \<Longrightarrow> h (0, ?x) = p ?x
?x \<in> {0..1} \<Longrightarrow> h (1, ?x) = q ?x
?x \<in> {0..1} \<Longrightarrow> pathstart (h \<circ> Pair ?x) = pathstart p
?x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair ?x) = pathfinish p

goal (1 subgoal):
 1. \<exists>h. continuous_on ({0..1} \<times> {0..1}) h \<and> h ` ({0..1} \<times> {0..1}) \<subseteq> s \<and> (\<forall>x\<in>{0..1}. h (0, x) = p x) \<and> (\<forall>x\<in>{0..1}. h (1, x) = q x) \<and> (\<forall>t\<in>{0..1}. pathstart (h \<circ> Pair t) = pathstart p \<and> pathfinish (h \<circ> Pair t) = pathfinish p)
[PROOF STEP]
by (intro exI[of _ h]) auto


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


[STATEMENT]
lemma cos_monotone_minus_pi_0':
  assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0"
  shows "cos y \<le> cos x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos y \<le> cos x
[PROOF STEP]
proof (cases "y < x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. y < x \<Longrightarrow> cos y \<le> cos x
 2. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
y < x

goal (2 subgoals):
 1. y < x \<Longrightarrow> cos y \<le> cos x
 2. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos y \<le> cos x
[PROOF STEP]
using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>]
[PROOF STATE]
proof (prove)
using this:
cos y < cos x

goal (1 subgoal):
 1. cos y \<le> cos x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cos y \<le> cos x

goal (1 subgoal):
 1. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> y < x

goal (1 subgoal):
 1. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> y < x
[PROOF STEP]
have "y = x"
[PROOF STATE]
proof (prove)
using this:
\<not> y < x

goal (1 subgoal):
 1. y = x
[PROOF STEP]
using \<open>y \<le> x\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> y < x
y \<le> x

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

goal (1 subgoal):
 1. \<not> y < x \<Longrightarrow> cos y \<le> cos x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y = x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
y = x

goal (1 subgoal):
 1. cos y \<le> cos x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cos y \<le> cos x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closer_points_lemma:
  assumes "inner y z > 0"
  shows "\<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm(v *\<^sub>R z - y) < norm y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
have z: "inner z z > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < z \<bullet> z
[PROOF STEP]
unfolding inner_gt_zero_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<noteq> (0::'a)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < y \<bullet> z

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

goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
have "norm (v *\<^sub>R z - y) < norm y"
    if "0 < v" and "v \<le> inner y z / inner z z" for v
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
unfolding norm_lt
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v *\<^sub>R z - y) \<bullet> (v *\<^sub>R z - y) < y \<bullet> y
[PROOF STEP]
using z assms that
[PROOF STATE]
proof (prove)
using this:
0 < z \<bullet> z
0 < y \<bullet> z
0 < v
v \<le> y \<bullet> z / (z \<bullet> z)

goal (1 subgoal):
 1. (v *\<^sub>R z - y) \<bullet> (v *\<^sub>R z - y) < y \<bullet> y
[PROOF STEP]
by (simp add: field_simps inner_diff inner_commute mult_strict_left_mono[OF _ \<open>0<v\<close>])
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < ?v; ?v \<le> y \<bullet> z / (z \<bullet> z)\<rbrakk> \<Longrightarrow> norm (?v *\<^sub>R z - y) < norm y

goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < ?v; ?v \<le> y \<bullet> z / (z \<bullet> z)\<rbrakk> \<Longrightarrow> norm (?v *\<^sub>R z - y) < norm y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?v; ?v \<le> y \<bullet> z / (z \<bullet> z)\<rbrakk> \<Longrightarrow> norm (?v *\<^sub>R z - y) < norm y

goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
using assms z
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?v; ?v \<le> y \<bullet> z / (z \<bullet> z)\<rbrakk> \<Longrightarrow> norm (?v *\<^sub>R z - y) < norm y
0 < y \<bullet> z
0 < z \<bullet> z

goal (1 subgoal):
 1. \<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y
[PROOF STEP]
by (rule_tac x = "inner y z / inner z z" in exI) auto
[PROOF STATE]
proof (state)
this:
\<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R z - y) < norm y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neg_numeral_less_signed_real_of_word_sum:
  \<open>- numeral n < signed_real_of_word v + signed_real_of_word w
    \<longleftrightarrow> - numeral n < sint v + sint w\<close> (is \<open>?P \<longleftrightarrow> ?Q\<close>)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
have \<open>?Q \<longleftrightarrow> real_of_int (- numeral n) < real_of_int (sint v + sint w)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- numeral n < sint v + sint w) = (real_of_int (- numeral n) < real_of_int (sint v + sint w))
[PROOF STEP]
by (simp only: of_int_less_iff)
[PROOF STATE]
proof (state)
this:
(- numeral n < sint v + sint w) = (real_of_int (- numeral n) < real_of_int (sint v + sint w))

goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(- numeral n < sint v + sint w) = (real_of_int (- numeral n) < real_of_int (sint v + sint w))

goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
have \<open>\<dots> \<longleftrightarrow> ?P\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real_of_int (- numeral n) < real_of_int (sint v + sint w)) = (- numeral n < signed_real_of_word v + signed_real_of_word w)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(real_of_int (- numeral n) < real_of_int (sint v + sint w)) = (- numeral n < signed_real_of_word v + signed_real_of_word w)

goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(- numeral n < sint v + sint w) = (- numeral n < signed_real_of_word v + signed_real_of_word w)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(- numeral n < sint v + sint w) = (- numeral n < signed_real_of_word v + signed_real_of_word w)

goal (1 subgoal):
 1. (- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(- numeral n < signed_real_of_word v + signed_real_of_word w) = (- numeral n < sint v + sint w)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma c1:
  assumes "e2 = (x + c1) mod q"
    and  "x < q" "c1 < q"
  shows "c1 = (e2 + q - x) mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c1 = (e2 + q - x) mod q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c1 = (e2 + q - x) mod q
[PROOF STEP]
have "[e2 + q = x + c1] (mod q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [e2 + q = x + c1] (mod q)
[PROOF STEP]
by(simp add: assms cong_def)
[PROOF STATE]
proof (state)
this:
[e2 + q = x + c1] (mod q)

goal (1 subgoal):
 1. c1 = (e2 + q - x) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e2 + q = x + c1] (mod q)
[PROOF STEP]
have "[e2 + q - x  =  c1] (mod q)"
[PROOF STATE]
proof (prove)
using this:
[e2 + q = x + c1] (mod q)

goal (1 subgoal):
 1. [e2 + q - x = c1] (mod q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [e2 + q = x + c1] (mod q) \<Longrightarrow> [e2 + q - x = c1] (mod q)
[PROOF STEP]
have "e2 + q \<ge> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> e2 + q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
e2 = (x + c1) mod q
x < q
c1 < q

goal (1 subgoal):
 1. x \<le> e2 + q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<le> e2 + q

goal (1 subgoal):
 1. [e2 + q = x + c1] (mod q) \<Longrightarrow> [e2 + q - x = c1] (mod q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<le> e2 + q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<le> e2 + q

goal (1 subgoal):
 1. [e2 + q - x = c1] (mod q)
[PROOF STEP]
by (metis \<open>[e2 + q = x + c1] (mod q)\<close> cong_add_lcancel_nat le_add_diff_inverse)
[PROOF STATE]
proof (state)
this:
[e2 + q - x = c1] (mod q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[e2 + q - x = c1] (mod q)

goal (1 subgoal):
 1. c1 = (e2 + q - x) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e2 + q - x = c1] (mod q)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[e2 + q - x = c1] (mod q)

goal (1 subgoal):
 1. c1 = (e2 + q - x) mod q
[PROOF STEP]
by(simp add: cong_def assms)
[PROOF STATE]
proof (state)
this:
c1 = (e2 + q - x) mod q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in Ring) sum_ideals_la2:"\<lbrakk>ideal R I1; ideal R I2 \<rbrakk> \<Longrightarrow> I2 \<subseteq> (I1 \<minusplus> I2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ideal R I1; ideal R I2\<rbrakk> \<Longrightarrow> I2 \<subseteq> I1 \<minusplus> I2
[PROOF STEP]
apply (cut_tac ring_is_ag)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ideal R I1; ideal R I2; aGroup R\<rbrakk> \<Longrightarrow> I2 \<subseteq> I1 \<minusplus> I2
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>ideal R I1; ideal R I2; aGroup R; x \<in> I2\<rbrakk> \<Longrightarrow> x \<in> I1 \<minusplus> I2
[PROOF STEP]
apply (frule ideal_zero[of "I1"],
       frule_tac h = x in ideal_subset[of "I2"], assumption+,
       frule_tac x = x in aGroup.ag_l_zero[of "R"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>ideal R I1; ideal R I2; aGroup R; x \<in> I2; \<zero> \<in> I1; x \<in> carrier R; \<zero> \<plusminus> x = x\<rbrakk> \<Longrightarrow> x \<in> I1 \<minusplus> I2
[PROOF STEP]
apply (subst aGroup.set_sum, assumption,
       simp add:ideal_subset1, simp add:ideal_subset1, simp,
       frule sym, thin_tac "\<zero> \<plusminus> x = x", blast)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "a1 \<ge> 0 \<and> a2 \<ge> 0 \<and> (a1 * a1 + a2 * a2 = b1 * b1 + b2 * b2 + 2) \<and> (a1 * b1 + a2 * b2 = 0) \<longrightarrow>
    a1 * a2 - b1 * b2 \<ge> (0::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> a1 \<and> 0 \<le> a2 \<and> a1 * a1 + a2 * a2 = b1 * b1 + b2 * b2 + 2 \<and> a1 * b1 + a2 * b2 = 0 \<longrightarrow> 0 \<le> a1 * a2 - b1 * b2
[PROOF STEP]
by (sos "(((A<0 * R<1) + (([~1/2*a1*b2 + ~1/2*a2*b1] * A=0) + (([~1/2*a1*a2 + 1/2*b1*b2] * A=1) + (((A<0 * R<1) * ((R<1/2 * [b2]^2) + (R<1/2 * [b1]^2))) + ((A<=0 * (A<=1 * R<1)) * ((R<1/2 * [b2]^2) + ((R<1/2 * [b1]^2) + ((R<1/2 * [a2]^2) + (R<1/2 * [a1]^2))))))))))")


[STATEMENT]
lemma floor_less_zero [simp]: "\<lfloor>x\<rfloor> < 0 \<longleftrightarrow> x < 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lfloor>x\<rfloor> < 0) = (x < (0::'a))
[PROOF STEP]
by (simp add: floor_less_iff)


[STATEMENT]
lemma S'_telescope_trapezium:
  assumes "n > 0"
  shows   "S' n x = (\<Sum>r<n. T (of_nat r + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
n = Suc m

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
hence m: "Suc m = n"
[PROOF STATE]
proof (prove)
using this:
n = Suc m

goal (1 subgoal):
 1. Suc m = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc m = n

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "(\<Sum>r<n. T (of_nat r + x)) =
          (\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) + (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r<n. T (real r + x)) = (\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) + (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x))
[PROOF STEP]
unfolding m
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r<n. T (real r + x)) = (\<Sum>r<n. 1 / (2 * real r + 2 * x)) + (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x))
[PROOF STEP]
by (simp add: T_def sum.distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>r<n. T (real r + x)) = (\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) + (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r<n. T (real r + x)) = (\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) + (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "(\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) =
               1/(2*x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x))" (is "_ = ?a + ?S")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) = 1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x))
[PROOF STEP]
by (subst sum.lessThan_Suc_shift) simp
[PROOF STATE]
proof (state)
this:
(\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) = 1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r<Suc m. 1 / (2 * real r + 2 * x)) = 1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "(\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x)) =
               ?S + 1 / (2*(real m + x + 1))" (is "_ = _ + ?b")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))
[PROOF STEP]
by (simp add: Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r<n. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "?a + ?S + (?S + ?b) = 2*?S + ?a + ?b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + ((\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))) = 2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * x) + 1 / (2 * (real m + x + 1))
[PROOF STEP]
by (simp add: add_ac)
[PROOF STATE]
proof (state)
this:
1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + ((\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))) = 2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * x) + 1 / (2 * (real m + x + 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / (2 * x) + (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + ((\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * (real m + x + 1))) = 2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) + 1 / (2 * x) + 1 / (2 * (real m + x + 1))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "2 * ?S = (\<Sum>r=0..<m. 1 / (real (Suc r) + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r = 0..<m. 1 / (real (Suc r) + x))
[PROOF STEP]
unfolding sum_distrib_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n<m. 2 * (1 / (2 * real (Suc n) + 2 * x))) = (\<Sum>r = 0..<m. 1 / (real (Suc r) + x))
[PROOF STEP]
by (intro sum.cong) (auto simp add: divide_simps)
[PROOF STATE]
proof (state)
this:
2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r = 0..<m. 1 / (real (Suc r) + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * (\<Sum>r<m. 1 / (2 * real (Suc r) + 2 * x)) = (\<Sum>r = 0..<m. 1 / (real (Suc r) + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "(\<Sum>r=0..<m. 1 / (real (Suc r) + x)) = (\<Sum>r=Suc 0..<Suc m. 1 / (real r + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = 0..<m. 1 / (real (Suc r) + x)) = (\<Sum>r = Suc 0..<Suc m. 1 / (real r + x))
[PROOF STEP]
by (subst sum.atLeast_Suc_lessThan_Suc_shift) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 0..<m. 1 / (real (Suc r) + x)) = (\<Sum>r = Suc 0..<Suc m. 1 / (real r + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 0..<m. 1 / (real (Suc r) + x)) = (\<Sum>r = Suc 0..<Suc m. 1 / (real r + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "\<dots> = (\<Sum>r=1..<n. 1 / (real r + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = Suc 0..<Suc m. 1 / (real r + x)) = (\<Sum>r = 1..<n. 1 / (real r + x))
[PROOF STEP]
unfolding m
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = Suc 0..<n. 1 / (real r + x)) = (\<Sum>r = 1..<n. 1 / (real r + x))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>r = Suc 0..<Suc m. 1 / (real r + x)) = (\<Sum>r = 1..<n. 1 / (real r + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r = Suc 0..<Suc m. 1 / (real r + x)) = (\<Sum>r = 1..<n. 1 / (real r + x))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
have "\<dots> + ?a + ?b = S' n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = 1..<n. 1 / (real r + x)) + 1 / (2 * x) + 1 / (2 * (real m + x + 1)) = S' n x
[PROOF STEP]
by (simp add: S'_def Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..<n. 1 / (real r + x)) + 1 / (2 * x) + 1 / (2 * (real m + x + 1)) = S' n x

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
 2. \<And>nat. n = Suc nat \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>r<n. T (real r + x)) = S' n x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>r<n. T (real r + x)) = S' n x

goal (1 subgoal):
 1. S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
S' n x = (\<Sum>r<n. T (real r + x))

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> S' n x = (\<Sum>r<n. T (real r + x))
[PROOF STEP]
qed (insert assms, simp_all)


[STATEMENT]
lemma real_sqrt_pow2_iff [simp]: "(sqrt x)\<^sup>2 = x \<longleftrightarrow> 0 \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((sqrt x)\<^sup>2 = x) = (0 \<le> x)
[PROOF STEP]
by (metis real_sqrt_pow2 zero_le_power2)


[STATEMENT]
lemma closure_of_Union_subset: "\<Union>((\<lambda>S. X closure_of S) ` \<A>) \<subseteq> X closure_of (\<Union>\<A>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> ((closure_of) X ` \<A>) \<subseteq> X closure_of \<Union> \<A>
[PROOF STEP]
by clarify (meson Union_upper closure_of_mono subsetD)


[STATEMENT]
lemma zero_in_bigtheta_iff [simp]: "(\<lambda>_. 0) \<in> \<Theta>[F](f) \<longleftrightarrow> eventually (\<lambda>x. f x = 0) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>_. 0::'b) \<in> \<Theta>[F](f)) = (\<forall>\<^sub>F x in F. f x = (0::'b))
[PROOF STEP]
unfolding bigtheta_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>_. 0::'b) \<in> O[F](f) \<inter> \<Omega>[F](f)) = (\<forall>\<^sub>F x in F. f x = (0::'b))
[PROOF STEP]
by simp


[STATEMENT]
lemma radius_disconnected_graph: "\<not> is_connected_set V \<Longrightarrow> radius = \<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_connected_set V \<Longrightarrow> radius = \<infinity>
[PROOF STEP]
unfolding radius_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> is_connected_set V \<Longrightarrow> Inf (eccentricity ` V) = \<infinity>
[PROOF STEP]
using eccentricity_disconnected_graph
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_connected_set V; ?v \<in> V\<rbrakk> \<Longrightarrow> eccentricity ?v = \<infinity>

goal (1 subgoal):
 1. \<not> is_connected_set V \<Longrightarrow> Inf (eccentricity ` V) = \<infinity>
[PROOF STEP]
by (metis INF_eq_const is_connected_set_empty)


[STATEMENT]
lemma sint_range':
  \<open>- (2 ^ (LENGTH('a) - Suc 0)) \<le> sint x \<and> sint x < 2 ^ (LENGTH('a) - Suc 0)\<close>
  for x :: \<open>'a::len word\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (2 ^ (LENGTH('a) - Suc 0)) \<le> sint x \<and> sint x < 2 ^ (LENGTH('a) - Suc 0)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. - (2 ^ (LENGTH('a) - Suc 0)) \<le> signed_take_bit (LENGTH('a) - Suc 0) x \<and> signed_take_bit (LENGTH('a) - Suc 0) x < 2 ^ (LENGTH('a) - Suc 0)
[PROOF STEP]
using sbintr_ge sbintr_lt
[PROOF STATE]
proof (prove)
using this:
- (2 ^ ?n) \<le> signed_take_bit ?n ?w
signed_take_bit ?n ?w < 2 ^ ?n

goal (1 subgoal):
 1. \<And>x. - (2 ^ (LENGTH('a) - Suc 0)) \<le> signed_take_bit (LENGTH('a) - Suc 0) x \<and> signed_take_bit (LENGTH('a) - Suc 0) x < 2 ^ (LENGTH('a) - Suc 0)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma QR_lemma_07:
  "f_2 ` Res_l (int p * int q) = Res_h (int p * int q)"
  "f_2 ` Res_h (int p * int q) = Res_l (int p * int q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1} &&& f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
 2. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
have 1: "f_2 ` Res_l (int p * int q) \<subseteq> Res_h (int p * int q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
by (force simp: f_2_def)
[PROOF STATE]
proof (state)
this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}

goal (2 subgoals):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
 2. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
have 2: "f_2 ` Res_h (int p * int q) \<subseteq> Res_l (int p * int q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
[PROOF STEP]
using pq_eq2
[PROOF STATE]
proof (prove)
using this:
int p * int q = 2 * ((int p * int q - 1) div 2) + 1

goal (1 subgoal):
 1. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
[PROOF STEP]
by (fastforce simp: f_2_def)
[PROOF STATE]
proof (state)
this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}

goal (2 subgoals):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
 2. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
from 2
[PROOF STATE]
proof (chain)
picking this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
[PROOF STEP]
have 3: "Res_h (int p * int q) \<subseteq> f_2 ` Res_l (int p * int q)"
[PROOF STATE]
proof (prove)
using this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}

goal (1 subgoal):
 1. {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> f_2 ` {0<..(int p * int q - 1) div 2}
[PROOF STEP]
using f_2_lemma_3
[PROOF STATE]
proof (prove)
using this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
f_2 ?x \<in> ?S \<Longrightarrow> ?x \<in> f_2 ` ?S

goal (1 subgoal):
 1. {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> f_2 ` {0<..(int p * int q - 1) div 2}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> f_2 ` {0<..(int p * int q - 1) div 2}

goal (2 subgoals):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
 2. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
from 1
[PROOF STATE]
proof (chain)
picking this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
have 4: "Res_l (int p * int q) \<subseteq> f_2 ` Res_h (int p * int q)"
[PROOF STATE]
proof (prove)
using this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}

goal (1 subgoal):
 1. {0<..(int p * int q - 1) div 2} \<subseteq> f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
using f_2_lemma_3
[PROOF STATE]
proof (prove)
using this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}
f_2 ?x \<in> ?S \<Longrightarrow> ?x \<in> f_2 ` ?S

goal (1 subgoal):
 1. {0<..(int p * int q - 1) div 2} \<subseteq> f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{0<..(int p * int q - 1) div 2} \<subseteq> f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1}

goal (2 subgoals):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
 2. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
from 1 3
[PROOF STATE]
proof (chain)
picking this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}
{(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> f_2 ` {0<..(int p * int q - 1) div 2}
[PROOF STEP]
show "f_2 ` Res_l (int p * int q) = Res_h (int p * int q)"
[PROOF STATE]
proof (prove)
using this:
f_2 ` {0<..(int p * int q - 1) div 2} \<subseteq> {(int p * int q - 1) div 2<..int p * int q - 1}
{(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> f_2 ` {0<..(int p * int q - 1) div 2}

goal (1 subgoal):
 1. f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f_2 ` {0<..(int p * int q - 1) div 2} = {(int p * int q - 1) div 2<..int p * int q - 1}

goal (1 subgoal):
 1. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
from 2 4
[PROOF STATE]
proof (chain)
picking this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
{0<..(int p * int q - 1) div 2} \<subseteq> f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1}
[PROOF STEP]
show "f_2 ` Res_h (int p * int q) = Res_l (int p * int q)"
[PROOF STATE]
proof (prove)
using this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} \<subseteq> {0<..(int p * int q - 1) div 2}
{0<..(int p * int q - 1) div 2} \<subseteq> f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1}

goal (1 subgoal):
 1. f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f_2 ` {(int p * int q - 1) div 2<..int p * int q - 1} = {0<..(int p * int q - 1) div 2}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dist_scaleR [simp]: "dist (x *\<^sub>R a) (y *\<^sub>R a) = \<bar>x - y\<bar> * norm a"
  for a :: "'a::real_normed_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (x *\<^sub>R a) (y *\<^sub>R a) = \<bar>x - y\<bar> * norm a
[PROOF STEP]
by (metis dist_norm norm_scaleR scaleR_left.diff)


[STATEMENT]
lemma integral_eq_zero_AE:
  "(AE x in M. f x = 0) \<Longrightarrow> integral\<^sup>L M f = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. f x = (0::'b) \<Longrightarrow> integral\<^sup>L M f = (0::'b)
[PROOF STEP]
using integral_cong_AE[of f M "\<lambda>_. 0"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f \<in> borel_measurable M; (\<lambda>_. 0::'b) \<in> borel_measurable M; AE x in M. f x = (0::'b)\<rbrakk> \<Longrightarrow> integral\<^sup>L M f = LINT _|M. (0::'b)

goal (1 subgoal):
 1. AE x in M. f x = (0::'b) \<Longrightarrow> integral\<^sup>L M f = (0::'b)
[PROOF STEP]
by (cases "integrable M f") (simp_all add: not_integrable_integral_eq)


[STATEMENT]
lemma M_1[simp]: "M 1 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M 1 = 1
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 mod m = 1
[PROOF STEP]
using m1
[PROOF STATE]
proof (prove)
using this:
1 < m

goal (1 subgoal):
 1. 1 mod m = 1
[PROOF STEP]
by auto


[STATEMENT]
lemma exp2: "Suc 0 < 3 * exp 3 (B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc 0 < 3 * exp 3 B
[PROOF STEP]
using exp3Min[of B]
[PROOF STATE]
proof (prove)
using this:
0 < exp 3 B

goal (1 subgoal):
 1. Suc 0 < 3 * exp 3 B
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma limitin_atin:
   "limitin Y f y (atin X x) \<longleftrightarrow>
        y \<in> topspace Y \<and>
        (x \<in> topspace X
        \<longrightarrow> (\<forall>V. openin Y V \<and> y \<in> V
                 \<longrightarrow> (\<exists>U. openin X U \<and> x \<in> U \<and> f ` (U - {x}) \<subseteq> V)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limitin Y f y (atin X x) = (y \<in> topspace Y \<and> (x \<in> topspace X \<longrightarrow> (\<forall>V. openin Y V \<and> y \<in> V \<longrightarrow> (\<exists>U. openin X U \<and> x \<in> U \<and> f ` (U - {x}) \<subseteq> V))))
[PROOF STEP]
by (auto simp: limitin_def eventually_atin image_subset_iff)


[STATEMENT]
lemma length_tl_list_minus_butlast_gt_zero:
  assumes "length s < length t" and "strict_prefix (butlast s) t" and "length s > 0"
  shows "length (tl (t - (butlast s))) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < length (tl (t - butlast s))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length s < length t
strict_prefix (butlast s) t
0 < length s

goal (1 subgoal):
 1. 0 < length (tl (t - butlast s))
[PROOF STEP]
by (metis Nitpick.size_list_simp(2) butlast_snoc hd_Cons_tl length_butlast length_greater_0_conv length_tl less_trans nat_neq_iff strict_prefix_minus_not_empty prefix_order.dual_order.strict_implies_order prefix_concat_minus)


[STATEMENT]
theorem well_defined_compose:
 assumes "is_tangle_diagram x"
     and "is_tangle_diagram y"
     and "domain_wall x = codomain_wall y"
 shows "(Abs_Tangle_Diagram x) \<circ> (Abs_Tangle_Diagram y)
                          = (Abs_Tangle_Diagram (x \<circ> y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Abs_Tangle_Diagram x \<circ> Abs_Tangle_Diagram y = Abs_Tangle_Diagram (x \<circ> y)
[PROOF STEP]
using  Abs_Tangle_Diagram_inverse assms(1) assms(2) compose_Tangle_def
        mem_Collect_eq
[PROOF STATE]
proof (prove)
using this:
?y \<in> {x. is_tangle_diagram x} \<Longrightarrow> Rep_Tangle_Diagram (Abs_Tangle_Diagram ?y) = ?y
is_tangle_diagram x
is_tangle_diagram y
?x \<circ> ?y = Abs_Tangle_Diagram (Rep_Tangle_Diagram ?x \<circ> Rep_Tangle_Diagram ?y)
(?a \<in> Collect ?P) = ?P ?a

goal (1 subgoal):
 1. Abs_Tangle_Diagram x \<circ> Abs_Tangle_Diagram y = Abs_Tangle_Diagram (x \<circ> y)
[PROOF STEP]
by auto


[STATEMENT]
lemma det_swap_rows: assumes A: "A \<in> carrier_mat (k + n) (k + n)"
  shows "det A = (-1)^(k * n) * det (mat (k + n) (k + n) (\<lambda> (i,j).
    A $$ ((if i < k then i + n else i - k),j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))
[PROOF STEP]
have le: "n + k \<le> k + n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n + k \<le> k + n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n + k \<le> k + n

goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))
[PROOF STEP]
unfolding det_swap_initial_rows[OF A le]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- (1::'a)) ^ (n * k) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else if i < n + k then i - k else i, j))) = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))
[PROOF STEP]
by (intro arg_cong2[of _ _ _ _ "\<lambda> x y. ((-1)^x * det y)"], force, intro eq_matI, auto)
[PROOF STATE]
proof (state)
this:
det A = (- (1::'a)) ^ (k * n) * det (mat (k + n) (k + n) (\<lambda>(i, j). A $$ (if i < k then i + n else i - k, j)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_divide_cancel_right [simp]:
  assumes "algebraic y" "y \<noteq> 0"
  shows   "algebraic (x / y) \<longleftrightarrow> algebraic x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (x / y) = algebraic x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. algebraic (x / y) = algebraic x
[PROOF STEP]
have "algebraic (x * inverse y) \<longleftrightarrow> algebraic x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (x * inverse y) = algebraic x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
algebraic y
y \<noteq> (0::'a)

goal (1 subgoal):
 1. algebraic (x * inverse y) = algebraic x
[PROOF STEP]
by (intro algebraic_mult_cancel_right) auto
[PROOF STATE]
proof (state)
this:
algebraic (x * inverse y) = algebraic x

goal (1 subgoal):
 1. algebraic (x / y) = algebraic x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
algebraic (x * inverse y) = algebraic x

goal (1 subgoal):
 1. algebraic (x / y) = algebraic x
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
algebraic (x / y) = algebraic x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_add_split_nat_ivl_singleton:
  assumes less: "m < (n::nat)"
    and g: "!!i. [| m < i; i < n |] ==> g i = f i"
  shows "f m + sum g {m<..<n} = sum f {m..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f m + sum g {m<..<n} = sum f {m..<n}
[PROOF STEP]
using less g
[PROOF STATE]
proof (prove)
using this:
m < n
\<lbrakk>m < ?i; ?i < n\<rbrakk> \<Longrightarrow> g ?i = f ?i

goal (1 subgoal):
 1. f m + sum g {m<..<n} = sum f {m..<n}
[PROOF STEP]
by(simp add: sum_add_nat_ivl_singleton cong: sum.cong_simp)


[STATEMENT]
lemma L2_set_left_distrib:
  "0 \<le> r \<Longrightarrow> L2_set f A * r = L2_set (\<lambda>x. f x * r) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> r \<Longrightarrow> L2_set f A * r = L2_set (\<lambda>x. f x * r) A
[PROOF STEP]
unfolding L2_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> r \<Longrightarrow> sqrt (\<Sum>i\<in>A. (f i)\<^sup>2) * r = sqrt (\<Sum>i\<in>A. (f i * r)\<^sup>2)
[PROOF STEP]
apply (simp add: power_mult_distrib)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> r \<Longrightarrow> sqrt (\<Sum>i\<in>A. (f i)\<^sup>2) * r = sqrt (\<Sum>i\<in>A. (f i)\<^sup>2 * r\<^sup>2)
[PROOF STEP]
apply (simp add: sum_distrib_right [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> r \<Longrightarrow> sqrt (\<Sum>i\<in>A. (f i)\<^sup>2) * r = sqrt ((\<Sum>i\<in>A. (f i)\<^sup>2) * r\<^sup>2)
[PROOF STEP]
apply (simp add: real_sqrt_mult sum_nonneg)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma cut_greater_Max_eq: "\<lbrakk> finite I; I \<down>> t \<noteq> {} \<rbrakk> \<Longrightarrow> Max (I \<down>> t) = Max I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<down>> t \<noteq> {}\<rbrakk> \<Longrightarrow> Max (I \<down>> t) = Max I
[PROOF STEP]
apply (drule cut_greater_not_empty_iff[THEN iffD1])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; \<exists>x\<in>I. t < x\<rbrakk> \<Longrightarrow> Max (I \<down>> t) = Max I
[PROOF STEP]
apply (rule Max_equality)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>finite I; \<exists>x\<in>I. t < x\<rbrakk> \<Longrightarrow> Max I \<in> I \<down>> t
 2. \<lbrakk>finite I; \<exists>x\<in>I. t < x\<rbrakk> \<Longrightarrow> finite (I \<down>> t)
 3. \<And>x. \<lbrakk>finite I; \<exists>x\<in>I. t < x; x \<in> I \<down>> t\<rbrakk> \<Longrightarrow> x \<le> Max I
[PROOF STEP]
apply (fastforce intro: MaxI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; \<exists>x\<in>I. t < x\<rbrakk> \<Longrightarrow> finite (I \<down>> t)
 2. \<And>x. \<lbrakk>finite I; \<exists>x\<in>I. t < x; x \<in> I \<down>> t\<rbrakk> \<Longrightarrow> x \<le> Max I
[PROOF STEP]
apply (simp add: cut_greater_finite)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>finite I; \<exists>x\<in>I. t < x; x \<in> I \<down>> t\<rbrakk> \<Longrightarrow> x \<le> Max I
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma natPredCases: "(!n. P n) | (~P 0) | (? n . P n & ~ P (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>n. P n) \<or> \<not> P 0 \<or> (\<exists>n. P n \<and> \<not> P (Suc n))
[PROOF STEP]
apply(rule claim[THEN iffD2])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<nexists>n. P n \<and> \<not> P (Suc n)) \<longrightarrow> \<not> \<not> P 0 \<longrightarrow> (\<forall>n. P n)
[PROOF STEP]
apply(intro impI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<nexists>n. P n \<and> \<not> P (Suc n); \<not> \<not> P 0\<rbrakk> \<Longrightarrow> \<forall>n. P n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>n. P n \<longrightarrow> P (Suc n); P 0\<rbrakk> \<Longrightarrow> \<forall>n. P n
[PROOF STEP]
apply rule
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>\<forall>n. P n \<longrightarrow> P (Suc n); P 0\<rbrakk> \<Longrightarrow> P n
[PROOF STEP]
apply(induct_tac n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>\<forall>n. P n \<longrightarrow> P (Suc n); P 0\<rbrakk> \<Longrightarrow> P 0
 2. \<And>n na. \<lbrakk>\<forall>n. P n \<longrightarrow> P (Suc n); P 0; P na\<rbrakk> \<Longrightarrow> P (Suc na)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma agree_on_subg_compose:
  assumes "agree_on R g h" "agree_on F f g" "subgraph F R"
  shows "agree_on F f h"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. agree_on F f h
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
agree_on R g h
agree_on F f g
subgraph F R

goal (1 subgoal):
 1. agree_on F f h
[PROOF STEP]
unfolding agree_on_def subgraph_def graph_union_iff
[PROOF STATE]
proof (prove)
using this:
\<forall>v\<in>vertices R. g `` {v} = h `` {v}
\<forall>v\<in>vertices F. f `` {v} = g `` {v}
graph F \<and> graph R \<and> edges F \<subseteq> edges R \<and> vertices F \<subseteq> vertices R

goal (1 subgoal):
 1. \<forall>v\<in>vertices F. f `` {v} = h `` {v}
[PROOF STEP]
by auto


[STATEMENT]
lemma setsum_one_less:
  fixes n::nat
  assumes "\<forall>i < n. f i \<le> 1"
  shows "(\<Sum>i < n. f i) \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..<n} \<le> n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i<n. f i \<le> 1

goal (1 subgoal):
 1. sum f {..<n} \<le> n
[PROOF STEP]
by (induct n) (auto)


[STATEMENT]
lemma lex_pm_iff: "lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
have "lex_pm s t = (\<not> lex_pm_strict t s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lex_pm s t = (\<not> lex_pm_strict t s)
[PROOF STEP]
by (simp add: lex_pm_strict_alt)
[PROOF STATE]
proof (state)
this:
lex_pm s t = (\<not> lex_pm_strict t s)

goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lex_pm s t = (\<not> lex_pm_strict t s)

goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
have "\<dots> = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> lex_pm_strict t s) = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
by (simp add: lex_pm_strict_def less_poly_mapping_def less_fun_def) (metis leD leI)
[PROOF STATE]
proof (state)
this:
(\<not> lex_pm_strict t s) = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))

goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))

goal (1 subgoal):
 1. lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
lex_pm s t = (\<forall>x. lookup s x \<le> lookup t x \<or> (\<exists>y<x. lookup s y \<noteq> lookup t y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma permutation_inverse_works:
  assumes "permutation p"
  shows "inv p \<circ> p = id"
    and "p \<circ> inv p = id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv p \<circ> p = id &&& p \<circ> inv p = id
[PROOF STEP]
using permutation_bijective [OF assms]
[PROOF STATE]
proof (prove)
using this:
bij p

goal (1 subgoal):
 1. inv p \<circ> p = id &&& p \<circ> inv p = id
[PROOF STEP]
by (auto simp: bij_def inj_iff surj_iff)


[STATEMENT]
lemma addrow_mat: assumes A: "A \<in> carrier_mat n nc"
  and l: "l < n"
  shows "addrow a k l A = addrow_mat n a k l * A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. addrow a k l A = addrow_mat n a k l * A
[PROOF STEP]
by (rule eq_matI, insert l A, auto simp: row_addrow
  add_scalar_prod_distrib[of _ n] smult_scalar_prod_distrib[of _ n])


[STATEMENT]
lemma proots_def: "proots p = {x. poly p x=0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots p = {x. poly p x = (0::'a)}
[PROOF STEP]
unfolding proots_within_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x \<in> UNIV. poly p x = (0::'a)} = {x. poly p x = (0::'a)}
[PROOF STEP]
by auto