[STATEMENT]
lemma Hermite_unique_generalized:
  fixes K::"int^'n::mod_type^'n::mod_type"
  assumes A_PH: "A = P ** H"
  and A_QK: "A = Q ** K"
  and inv_A: "invertible (map_matrix rat_of_int A)" (*The original statement assumes "invertible A",
                                                      that is, invertibility over integers, which is
                                                      more restrictive.*)
  and inv_P: "invertible P"
  and inv_Q: "invertible Q"
  and H: "Hermite associates residues H"
  and K: "Hermite associates residues K"
  shows "H = K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H = K
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. H = K
[PROOF STEP]
let ?RAT = "map_matrix rat_of_int"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. H = K
[PROOF STEP]
have cs_residues: "Complete_set_residues residues"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complete_set_residues residues
[PROOF STEP]
using H
[PROOF STATE]
proof (prove)
using this:
Hermite associates residues H

goal (1 subgoal):
 1. Complete_set_residues residues
[PROOF STEP]
unfolding Hermite_def
[PROOF STATE]
proof (prove)
using this:
Complete_set_non_associates associates \<and> Complete_set_residues residues \<and> echelon_form H \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> H $ i $ (LEAST n. H $ i $ n \<noteq> 0) \<in> associates) \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> (\<forall>j<i. H $ j $ (LEAST n. H $ i $ n \<noteq> 0) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> 0))))

goal (1 subgoal):
 1. Complete_set_residues residues
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complete_set_residues residues

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have inv_H: "invertible (?RAT H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (map_matrix rat_of_int H)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible (map_matrix rat_of_int H)
[PROOF STEP]
have "?RAT A = ?RAT P ** ?RAT H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_matrix rat_of_int A = map_matrix rat_of_int P ** map_matrix rat_of_int H
[PROOF STEP]
using A_PH map_matrix_rat_of_int_mult
[PROOF STATE]
proof (prove)
using this:
A = P ** H
map_matrix rat_of_int (?A ** ?B) = map_matrix rat_of_int ?A ** map_matrix rat_of_int ?B

goal (1 subgoal):
 1. map_matrix rat_of_int A = map_matrix rat_of_int P ** map_matrix rat_of_int H
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
map_matrix rat_of_int A = map_matrix rat_of_int P ** map_matrix rat_of_int H

goal (1 subgoal):
 1. invertible (map_matrix rat_of_int H)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
map_matrix rat_of_int A = map_matrix rat_of_int P ** map_matrix rat_of_int H

goal (1 subgoal):
 1. invertible (map_matrix rat_of_int H)
[PROOF STEP]
by (metis inv_A invertible_left_inverse matrix_inv(1) matrix_mul_assoc)
[PROOF STATE]
proof (state)
this:
invertible (map_matrix rat_of_int H)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (map_matrix rat_of_int H)

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have inv_K: "invertible (?RAT K)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible (map_matrix rat_of_int K)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible (map_matrix rat_of_int K)
[PROOF STEP]
have "?RAT A = ?RAT Q ** ?RAT K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_matrix rat_of_int A = map_matrix rat_of_int Q ** map_matrix rat_of_int K
[PROOF STEP]
using A_QK map_matrix_rat_of_int_mult
[PROOF STATE]
proof (prove)
using this:
A = Q ** K
map_matrix rat_of_int (?A ** ?B) = map_matrix rat_of_int ?A ** map_matrix rat_of_int ?B

goal (1 subgoal):
 1. map_matrix rat_of_int A = map_matrix rat_of_int Q ** map_matrix rat_of_int K
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
map_matrix rat_of_int A = map_matrix rat_of_int Q ** map_matrix rat_of_int K

goal (1 subgoal):
 1. invertible (map_matrix rat_of_int K)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
map_matrix rat_of_int A = map_matrix rat_of_int Q ** map_matrix rat_of_int K

goal (1 subgoal):
 1. invertible (map_matrix rat_of_int K)
[PROOF STEP]
by (metis inv_A invertible_left_inverse matrix_inv(1) matrix_mul_assoc)
[PROOF STATE]
proof (state)
this:
invertible (map_matrix rat_of_int K)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible (map_matrix rat_of_int K)

goal (1 subgoal):
 1. H = K
[PROOF STEP]
define U where "U = (matrix_inv P)**Q"
[PROOF STATE]
proof (state)
this:
U = matrix_inv P ** Q

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have inv_U: "invertible U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible U
[PROOF STEP]
by (metis U_def inv_P inv_Q invertible_def invertible_mult matrix_inv_left matrix_inv_right)
[PROOF STATE]
proof (state)
this:
invertible U

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have H_UK: "H = U ** K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H = U ** K
[PROOF STEP]
using A_PH A_QK inv_P
[PROOF STATE]
proof (prove)
using this:
A = P ** H
A = Q ** K
invertible P

goal (1 subgoal):
 1. H = U ** K
[PROOF STEP]
by (metis U_def matrix_inv_left matrix_mul_assoc matrix_mul_lid)
[PROOF STATE]
proof (state)
this:
H = U ** K

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have "Determinants.det K *k U = H ** adjugate K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det K *k U = H ** adjugate K
[PROOF STEP]
unfolding H_UK matrix_mul_assoc[symmetric] mult_adjugate_det matrix_mul_mat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det K *k U = det K *k U
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
det K *k U = H ** adjugate K

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have upper_triangular_H: "upper_triangular H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular H
[PROOF STEP]
by (metis H Hermite_def echelon_form_imp_upper_triagular)
[PROOF STATE]
proof (state)
this:
upper_triangular H

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have upper_triangular_K: "upper_triangular K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular K
[PROOF STEP]
by (metis K Hermite_def echelon_form_imp_upper_triagular)
[PROOF STATE]
proof (state)
this:
upper_triangular K

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have upper_triangular_U: "upper_triangular U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
have U_H_K: "?RAT U = (?RAT H) ** (matrix_inv (?RAT K))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_matrix rat_of_int U = map_matrix rat_of_int H ** matrix_inv (map_matrix rat_of_int K)
[PROOF STEP]
by (metis H_UK inv_K map_matrix_rat_of_int_mult matrix_inv(2) matrix_mul_assoc matrix_mul_rid)
[PROOF STATE]
proof (state)
this:
map_matrix rat_of_int U = map_matrix rat_of_int H ** matrix_inv (map_matrix rat_of_int K)

goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
have up_inv_RAT_K: "upper_triangular (matrix_inv (?RAT K))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular (matrix_inv (map_matrix rat_of_int K))
[PROOF STEP]
using upper_triangular_inverse
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>upper_triangular ?A; invertible ?A\<rbrakk> \<Longrightarrow> upper_triangular (matrix_inv ?A)

goal (1 subgoal):
 1. upper_triangular (matrix_inv (map_matrix rat_of_int K))
[PROOF STEP]
by (simp add: upper_triangular_inverse inv_K upper_triangular_K upper_triangular_Z_eq_Q)
[PROOF STATE]
proof (state)
this:
upper_triangular (matrix_inv (map_matrix rat_of_int K))

goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
have "upper_triangular (?RAT U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular (map_matrix rat_of_int U)
[PROOF STEP]
unfolding U_H_K
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. upper_triangular (map_matrix rat_of_int H ** matrix_inv (map_matrix rat_of_int K))
[PROOF STEP]
by (rule upper_triangular_mult[OF _ up_inv_RAT_K],
          auto simp add: upper_triangular_H upper_triangular_Z_eq_Q)
[PROOF STATE]
proof (state)
this:
upper_triangular (map_matrix rat_of_int U)

goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
upper_triangular (map_matrix rat_of_int U)

goal (1 subgoal):
 1. upper_triangular U
[PROOF STEP]
using upper_triangular_Z_eq_Q
[PROOF STATE]
proof (prove)
using this:
upper_triangular (map_matrix rat_of_int U)
upper_triangular (map_matrix rat_of_int ?A) = upper_triangular ?A

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
upper_triangular U

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have unit_det_U: "is_unit (det U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_unit (det U)
[PROOF STEP]
by (metis inv_U invertible_iff_is_unit)
[PROOF STATE]
proof (state)
this:
is_unit (det U)

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have is_unit_diagonal_U: "(\<forall>i. is_unit (U $ i $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. is_unit (U $ i $ i)
[PROOF STEP]
by (rule is_unit_diagonal[OF upper_triangular_U unit_det_U])
[PROOF STATE]
proof (state)
this:
\<forall>i. is_unit (U $ i $ i)

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have Uii_1: "(\<forall>i. (U $ i $ i) = 1)" and Hii_Kii: "(\<forall>i. (H $ i $ i) = (K $ i $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. U $ i $ i = 1 &&& \<forall>i. H $ i $ i = K $ i $ i
[PROOF STEP]
proof (auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. U $ i $ i = 1
 2. \<And>i. H $ i $ i = K $ i $ i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. U $ i $ i = 1
 2. \<And>i. H $ i $ i = K $ i $ i
[PROOF STEP]
have Hii: "H $ i $ i \<in> associates"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ i $ i \<in> associates
[PROOF STEP]
by (rule diagonal_in_associates[OF H inv_H upper_triangular_H])
[PROOF STATE]
proof (state)
this:
H $ i $ i \<in> associates

goal (2 subgoals):
 1. \<And>i. U $ i $ i = 1
 2. \<And>i. H $ i $ i = K $ i $ i
[PROOF STEP]
have Kii: "K $ i $ i \<in> associates"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K $ i $ i \<in> associates
[PROOF STEP]
by (rule diagonal_in_associates[OF K inv_K upper_triangular_K])
[PROOF STATE]
proof (state)
this:
K $ i $ i \<in> associates

goal (2 subgoals):
 1. \<And>i. U $ i $ i = 1
 2. \<And>i. H $ i $ i = K $ i $ i
[PROOF STEP]
have ass_Hii_Kii: "normalize (H $ i $ i) = normalize (K $ i $ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. normalize (H $ i $ i) = normalize (K $ i $ i)
[PROOF STEP]
by (metis H_UK is_unit_diagonal_U normalize_mult_unit_left upper_triangular_K upper_triangular_U upper_triangular_mult_diagonal)
[PROOF STATE]
proof (state)
this:
normalize (H $ i $ i) = normalize (K $ i $ i)

goal (2 subgoals):
 1. \<And>i. U $ i $ i = 1
 2. \<And>i. H $ i $ i = K $ i $ i
[PROOF STEP]
show Hii_eq_Kii: "H $ i $ i = K $ i $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ i $ i = K $ i $ i
[PROOF STEP]
by (metis Hermite_def Hii K Kii ass_Hii_Kii in_Ass_not_associated)
[PROOF STATE]
proof (state)
this:
H $ i $ i = K $ i $ i

goal (1 subgoal):
 1. \<And>i. U $ i $ i = 1
[PROOF STEP]
have "H $ i $ i = U $ i $ i * K $ i $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ i $ i = U $ i $ i * K $ i $ i
[PROOF STEP]
by (metis H_UK upper_triangular_K upper_triangular_U upper_triangular_mult_diagonal)
[PROOF STATE]
proof (state)
this:
H $ i $ i = U $ i $ i * K $ i $ i

goal (1 subgoal):
 1. \<And>i. U $ i $ i = 1
[PROOF STEP]
thus "U $ i $ i = 1"
[PROOF STATE]
proof (prove)
using this:
H $ i $ i = U $ i $ i * K $ i $ i

goal (1 subgoal):
 1. U $ i $ i = 1
[PROOF STEP]
unfolding Hii_eq_Kii mult_cancel_right1
[PROOF STATE]
proof (prove)
using this:
K $ i $ i = 0 \<or> U $ i $ i = 1

goal (1 subgoal):
 1. U $ i $ i = 1
[PROOF STEP]
using inv_K invertible_and_upper_diagonal_not0 upper_triangular_K
[PROOF STATE]
proof (prove)
using this:
K $ i $ i = 0 \<or> U $ i $ i = 1
invertible (map_matrix rat_of_int K)
\<lbrakk>invertible (map_matrix rat_of_int ?H); upper_triangular ?H\<rbrakk> \<Longrightarrow> ?H $ ?i $ ?i \<noteq> 0
upper_triangular K

goal (1 subgoal):
 1. U $ i $ i = 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
U $ i $ i = 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>i. U $ i $ i = 1
\<forall>i. H $ i $ i = K $ i $ i

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have zero_above: "\<forall>j s. j\<ge>1 \<and> j < ncols A - to_nat s \<longrightarrow> U $ s $ (s + from_nat j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j s. 1 \<le> j \<and> j < ncols A - mod_type_class.to_nat s \<longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0
[PROOF STEP]
proof (clarify)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j s. \<lbrakk>1 \<le> j; j < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0
[PROOF STEP]
fix j s
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j s. \<lbrakk>1 \<le> j; j < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0
[PROOF STEP]
assume  "1 \<le> j" and "j < ncols A - (to_nat (s::'n))"
[PROOF STATE]
proof (state)
this:
1 \<le> j
j < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. \<And>j s. \<lbrakk>1 \<le> j; j < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0
[PROOF STEP]
thus "U $ s $ (s + from_nat j) = 0"
[PROOF STATE]
proof (prove)
using this:
1 \<le> j
j < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat j) = 0
[PROOF STEP]
proof (induct j rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; 1 \<le> y; y < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat y) = 0; 1 \<le> x; x < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat x) = 0
[PROOF STEP]
fix p
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; 1 \<le> y; y < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat y) = 0; 1 \<le> x; x < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat x) = 0
[PROOF STEP]
assume induct_step: "(\<And>y. y < p \<Longrightarrow> 1 \<le> y \<Longrightarrow> y < ncols A - to_nat s \<Longrightarrow> U $ s $ (s + from_nat y) = 0)"
        and p1: "1 \<le> p" and p2: "p < ncols A - to_nat s"
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y1 < p; 1 \<le> ?y1; ?y1 < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat ?y1) = 0
1 \<le> p
p < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; 1 \<le> y; y < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat y) = 0; 1 \<le> x; x < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat x) = 0
[PROOF STEP]
have s_less: "s < s + from_nat p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s < s + mod_type_class.from_nat p
[PROOF STEP]
using p1 p2
[PROOF STATE]
proof (prove)
using this:
1 \<le> p
p < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. s < s + mod_type_class.from_nat p
[PROOF STEP]
unfolding ncols_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> p
p < CARD('n) - mod_type_class.to_nat s

goal (1 subgoal):
 1. s < s + mod_type_class.from_nat p
[PROOF STEP]
by (metis One_nat_def add.commute add_diff_cancel_right' add_lessD1 add_to_nat_def
          from_nat_to_nat_id less_diff_conv neq_iff not_le
          to_nat_from_nat_id to_nat_le zero_less_Suc)
[PROOF STATE]
proof (state)
this:
s < s + mod_type_class.from_nat p

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<And>y. \<lbrakk>y < x; 1 \<le> y; y < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat y) = 0; 1 \<le> x; x < ncols A - mod_type_class.to_nat s\<rbrakk> \<Longrightarrow> U $ s $ (s + mod_type_class.from_nat x) = 0
[PROOF STEP]
show "U $ s $ (s + from_nat p) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have UNIV_rw: "UNIV = insert s (UNIV-{s})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = insert s (UNIV - {s})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
UNIV = insert s (UNIV - {s})

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have UNIV_s_rw: "UNIV-{s} = insert (s + from_nat p) ((UNIV-{s}) - {s + from_nat p})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV - {s} = insert (s + mod_type_class.from_nat p) (UNIV - {s} - {s + mod_type_class.from_nat p})
[PROOF STEP]
using p1 p2 s_less
[PROOF STATE]
proof (prove)
using this:
1 \<le> p
p < ncols A - mod_type_class.to_nat s
s < s + mod_type_class.from_nat p

goal (1 subgoal):
 1. UNIV - {s} = insert (s + mod_type_class.from_nat p) (UNIV - {s} - {s + mod_type_class.from_nat p})
[PROOF STEP]
unfolding ncols_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> p
p < CARD('n) - mod_type_class.to_nat s
s < s + mod_type_class.from_nat p

goal (1 subgoal):
 1. UNIV - {s} = insert (s + mod_type_class.from_nat p) (UNIV - {s} - {s + mod_type_class.from_nat p})
[PROOF STEP]
by (auto simp: algebra_simps)
[PROOF STATE]
proof (state)
this:
UNIV - {s} = insert (s + mod_type_class.from_nat p) (UNIV - {s} - {s + mod_type_class.from_nat p})

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have sum_rw: "(\<Sum>k\<in>UNIV-{s}. U $ s $ k * K $ k $ (s + from_nat p))
          = U $ s $ (s + from_nat p) * K $ (s + from_nat p) $ (s + from_nat p)
          + (\<Sum>k\<in>(UNIV-{s})-{s + from_nat p}. U $ s $ k * K $ k $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s} - {s + mod_type_class.from_nat p}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
using UNIV_s_rw sum.insert
[PROOF STATE]
proof (prove)
using this:
UNIV - {s} = insert (s + mod_type_class.from_nat p) (UNIV - {s} - {s + mod_type_class.from_nat p})
\<lbrakk>finite ?A; ?x \<notin> ?A\<rbrakk> \<Longrightarrow> sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A

goal (1 subgoal):
 1. (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s} - {s + mod_type_class.from_nat p}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
by (metis (erased, lifting) Diff_iff finite singletonI)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s} - {s + mod_type_class.from_nat p}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have sum_0: "(\<Sum>k\<in>(UNIV-{s})-{s + from_nat p}. U $ s $ k * K $ k $ (s + from_nat p)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>UNIV - {s} - {s + mod_type_class.from_nat p}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = 0
[PROOF STEP]
proof (rule sum.neutral, rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> UNIV - {s} - {s + mod_type_class.from_nat p} \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> UNIV - {s} - {s + mod_type_class.from_nat p} \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
assume x: "x \<in> UNIV - {s} - {s + from_nat p}"
[PROOF STATE]
proof (state)
this:
x \<in> UNIV - {s} - {s + mod_type_class.from_nat p}

goal (1 subgoal):
 1. \<And>x. x \<in> UNIV - {s} - {s + mod_type_class.from_nat p} \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
show "U $ s $ x * K $ x $ (s + from_nat p) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
proof (cases "x<s")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x < s

goal (2 subgoals):
 1. x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x < s

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
using upper_triangular_U
[PROOF STATE]
proof (prove)
using this:
x < s
upper_triangular U

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
unfolding upper_triangular_def
[PROOF STATE]
proof (prove)
using this:
x < s
\<forall>i j. j < i \<longrightarrow> U $ i $ j = 0

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0

goal (1 subgoal):
 1. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x < s

goal (1 subgoal):
 1. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
hence x_g_s: "x>s"
[PROOF STATE]
proof (prove)
using this:
\<not> x < s

goal (1 subgoal):
 1. s < x
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
\<not> x < s
x \<in> UNIV - {s} - {s + mod_type_class.from_nat p}

goal (1 subgoal):
 1. s < x
[PROOF STEP]
by (metis Diff_iff neq_iff singletonI)
[PROOF STATE]
proof (state)
this:
s < x

goal (1 subgoal):
 1. \<not> x < s \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
proof (cases "x<s+from_nat p")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x < s + mod_type_class.from_nat p

goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
define a where "a = to_nat x - to_nat s"
[PROOF STATE]
proof (state)
this:
a = mod_type_class.to_nat x - mod_type_class.to_nat s

goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
from x_g_s
[PROOF STATE]
proof (chain)
picking this:
s < x
[PROOF STEP]
have "to_nat s < to_nat x"
[PROOF STATE]
proof (prove)
using this:
s < x

goal (1 subgoal):
 1. mod_type_class.to_nat s < mod_type_class.to_nat x
[PROOF STEP]
by (rule to_nat_mono)
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat s < mod_type_class.to_nat x

goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
hence xa: "x=s+(from_nat a)"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat s < mod_type_class.to_nat x

goal (1 subgoal):
 1. x = s + mod_type_class.from_nat a
[PROOF STEP]
unfolding a_def add_to_nat_def
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat s < mod_type_class.to_nat x

goal (1 subgoal):
 1. x = mod_type_class.from_nat (mod_type_class.to_nat s + mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x - mod_type_class.to_nat s)))
[PROOF STEP]
by (simp add: less_imp_diff_less to_nat_less_card algebra_simps to_nat_from_nat_id)
[PROOF STATE]
proof (state)
this:
x = s + mod_type_class.from_nat a

goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "U $ s $ x =0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ x = 0
[PROOF STEP]
proof (unfold xa, rule induct_step)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. a < p
 2. 1 \<le> a
 3. a < ncols A - mod_type_class.to_nat s
[PROOF STEP]
show a_p: "a<p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < p
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
using p2
[PROOF STATE]
proof (prove)
using this:
p < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
unfolding ncols_def
[PROOF STATE]
proof (prove)
using this:
p < CARD('n) - mod_type_class.to_nat s

goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p < CARD('n) - mod_type_class.to_nat s \<Longrightarrow> mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
have "x < from_nat (to_nat s + to_nat (from_nat p::'n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < mod_type_class.from_nat (mod_type_class.to_nat s + mod_type_class.to_nat (mod_type_class.from_nat p))
[PROOF STEP]
by (metis (no_types) True add_to_nat_def)
[PROOF STATE]
proof (state)
this:
x < mod_type_class.from_nat (mod_type_class.to_nat s + mod_type_class.to_nat (mod_type_class.from_nat p))

goal (1 subgoal):
 1. p < CARD('n) - mod_type_class.to_nat s \<Longrightarrow> mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
hence "to_nat x - to_nat s < to_nat (from_nat p::'n)"
[PROOF STATE]
proof (prove)
using this:
x < mod_type_class.from_nat (mod_type_class.to_nat s + mod_type_class.to_nat (mod_type_class.from_nat p))

goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat s < mod_type_class.to_nat (mod_type_class.from_nat p)
[PROOF STEP]
by (simp add: add.commute less_diff_conv2 less_imp_le to_nat_le x_g_s)
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat x - mod_type_class.to_nat s < mod_type_class.to_nat (mod_type_class.from_nat p)

goal (1 subgoal):
 1. p < CARD('n) - mod_type_class.to_nat s \<Longrightarrow> mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
thus "to_nat x - to_nat s < p"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat x - mod_type_class.to_nat s < mod_type_class.to_nat (mod_type_class.from_nat p)

goal (1 subgoal):
 1. mod_type_class.to_nat x - mod_type_class.to_nat s < p
[PROOF STEP]
by (metis (no_types) from_nat_eq_imp_eq from_nat_to_nat_id le_less_trans
                        less_imp_le not_le to_nat_less_card)
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat x - mod_type_class.to_nat s < p

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a < p

goal (2 subgoals):
 1. 1 \<le> a
 2. a < ncols A - mod_type_class.to_nat s
[PROOF STEP]
show "1 \<le> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> a
[PROOF STEP]
by (auto simp add: a_def p1 p2) (metis Suc_leI to_nat_mono x_g_s zero_less_diff)
[PROOF STATE]
proof (state)
this:
1 \<le> a

goal (1 subgoal):
 1. a < ncols A - mod_type_class.to_nat s
[PROOF STEP]
show "a < ncols A - to_nat s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < ncols A - mod_type_class.to_nat s
[PROOF STEP]
using a_p p2
[PROOF STATE]
proof (prove)
using this:
a < p
p < ncols A - mod_type_class.to_nat s

goal (1 subgoal):
 1. a < ncols A - mod_type_class.to_nat s
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < ncols A - mod_type_class.to_nat s

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ s $ x = 0

goal (2 subgoals):
 1. x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
 2. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
U $ s $ x = 0

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0

goal (1 subgoal):
 1. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x < s + mod_type_class.from_nat p

goal (1 subgoal):
 1. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
hence "x>s+from_nat p"
[PROOF STATE]
proof (prove)
using this:
\<not> x < s + mod_type_class.from_nat p

goal (1 subgoal):
 1. s + mod_type_class.from_nat p < x
[PROOF STEP]
using x_g_s x
[PROOF STATE]
proof (prove)
using this:
\<not> x < s + mod_type_class.from_nat p
s < x
x \<in> UNIV - {s} - {s + mod_type_class.from_nat p}

goal (1 subgoal):
 1. s + mod_type_class.from_nat p < x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
s + mod_type_class.from_nat p < x

goal (1 subgoal):
 1. \<not> x < s + mod_type_class.from_nat p \<Longrightarrow> U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
s + mod_type_class.from_nat p < x

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
using upper_triangular_K
[PROOF STATE]
proof (prove)
using this:
s + mod_type_class.from_nat p < x
upper_triangular K

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
unfolding upper_triangular_def
[PROOF STATE]
proof (prove)
using this:
s + mod_type_class.from_nat p < x
\<forall>i j. j < i \<longrightarrow> K $ i $ j = 0

goal (1 subgoal):
 1. U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ s $ x * K $ x $ (s + mod_type_class.from_nat p) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>UNIV - {s} - {s + mod_type_class.from_nat p}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = 0

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "H $ s $ (s + from_nat p) = (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) = (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
unfolding H_UK matrix_matrix_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. \<Sum>k\<in>UNIV. U $ i $ k * K $ k $ j) $ s $ (s + mod_type_class.from_nat p) = (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
H $ s $ (s + mod_type_class.from_nat p) = (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
H $ s $ (s + mod_type_class.from_nat p) = (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "... = (\<Sum>k\<in>insert s (UNIV-{s}). U $ s $ k * K $ k $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = (\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
using UNIV_rw
[PROOF STATE]
proof (prove)
using this:
UNIV = insert s (UNIV - {s})

goal (1 subgoal):
 1. (\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = (\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = (\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>UNIV. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = (\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "... = U $ s $ s * K $ s $ (s + from_nat p)
          + (\<Sum>k\<in>UNIV-{s}. U $ s $ k * K $ k $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))
[PROOF STEP]
by (rule sum.insert, simp_all)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>insert s (UNIV - {s}). U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "... = U $ s $ s * K $ s $ (s + from_nat p)
          + U $ s $ (s + from_nat p) * K $ (s + from_nat p) $ (s + from_nat p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)
[PROOF STEP]
unfolding sum_rw sum_0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + 0) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + (\<Sum>k\<in>UNIV - {s}. U $ s $ k * K $ k $ (s + mod_type_class.from_nat p)) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)
[PROOF STEP]
have H_s_sp: "H $ s $ (s + from_nat p)
          = U $ s $ (s + from_nat p) * K $ (s + from_nat p) $ (s + from_nat p) + K $ s $ (s + from_nat p)"
[PROOF STATE]
proof (prove)
using this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)
[PROOF STEP]
using Uii_1
[PROOF STATE]
proof (prove)
using this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ s * K $ s $ (s + mod_type_class.from_nat p) + U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p)
\<forall>i. U $ i $ i = 1

goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
hence cong_HK: "cong (H $ s $ (s + from_nat p)) (K $ s $ (s + from_nat p)) (K $ (s+from_nat p) $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
using this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. cong (H $ s $ (s + mod_type_class.from_nat p)) (K $ s $ (s + mod_type_class.from_nat p)) (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
unfolding cong_def
[PROOF STATE]
proof (prove)
using this:
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. \<exists>k. H $ s $ (s + mod_type_class.from_nat p) - K $ s $ (s + mod_type_class.from_nat p) = K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) * k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cong (H $ s $ (s + mod_type_class.from_nat p)) (K $ s $ (s + mod_type_class.from_nat p)) (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have H_s_sp_residues: "(H $ s $ (s + from_nat p)) \<in> residues (K $ (s+from_nat p) $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
using above_diagonal_in_residues[OF H inv_H upper_triangular_H s_less]
[PROOF STATE]
proof (prove)
using this:
H $ s $ (LEAST n. H $ (s + mod_type_class.from_nat p) $ n \<noteq> 0) \<in> residues (H $ (s + mod_type_class.from_nat p) $ (LEAST n. H $ (s + mod_type_class.from_nat p) $ n \<noteq> 0))

goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
unfolding diagonal_least_nonzero[OF H inv_H upper_triangular_H]
[PROOF STATE]
proof (prove)
using this:
H $ s $ (s + mod_type_class.from_nat p) \<in> residues (H $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
by (metis Hii_Kii)
[PROOF STATE]
proof (state)
this:
H $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have K_s_sp_residues: "(K $ s $ (s + from_nat p)) \<in> residues (K $ (s+from_nat p) $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
using above_diagonal_in_residues[OF K inv_K upper_triangular_K s_less]
[PROOF STATE]
proof (prove)
using this:
K $ s $ (LEAST n. K $ (s + mod_type_class.from_nat p) $ n \<noteq> 0) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (LEAST n. K $ (s + mod_type_class.from_nat p) $ n \<noteq> 0))

goal (1 subgoal):
 1. K $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
unfolding diagonal_least_nonzero[OF K inv_K upper_triangular_K]
[PROOF STATE]
proof (prove)
using this:
K $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. K $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
K $ s $ (s + mod_type_class.from_nat p) \<in> residues (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have Hs_sp_Ks_sp: "(H $ s $ (s + from_nat p)) = (K $ s $ (s + from_nat p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) = K $ s $ (s + mod_type_class.from_nat p)
[PROOF STEP]
using cong_HK in_Res_not_congruent[OF cs_residues H_s_sp_residues K_s_sp_residues]
[PROOF STATE]
proof (prove)
using this:
cong (H $ s $ (s + mod_type_class.from_nat p)) (K $ s $ (s + mod_type_class.from_nat p)) (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))
H $ s $ (s + mod_type_class.from_nat p) \<noteq> K $ s $ (s + mod_type_class.from_nat p) \<Longrightarrow> \<not> cong (H $ s $ (s + mod_type_class.from_nat p)) (K $ s $ (s + mod_type_class.from_nat p)) (K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p))

goal (1 subgoal):
 1. H $ s $ (s + mod_type_class.from_nat p) = K $ s $ (s + mod_type_class.from_nat p)
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
H $ s $ (s + mod_type_class.from_nat p) = K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
have "K $ (s + from_nat p) $ (s + from_nat p) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0
[PROOF STEP]
using inv_K invertible_and_upper_diagonal_not0 upper_triangular_K
[PROOF STATE]
proof (prove)
using this:
invertible (map_matrix rat_of_int K)
\<lbrakk>invertible (map_matrix rat_of_int ?H); upper_triangular ?H\<rbrakk> \<Longrightarrow> ?H $ ?i $ ?i \<noteq> 0
upper_triangular K

goal (1 subgoal):
 1. K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
unfolding from_nat_1
[PROOF STATE]
proof (prove)
using this:
K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
using H_s_sp
[PROOF STATE]
proof (prove)
using this:
K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0
H $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
unfolding Hs_sp_Ks_sp
[PROOF STATE]
proof (prove)
using this:
K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) \<noteq> 0
K $ s $ (s + mod_type_class.from_nat p) = U $ s $ (s + mod_type_class.from_nat p) * K $ (s + mod_type_class.from_nat p) $ (s + mod_type_class.from_nat p) + K $ s $ (s + mod_type_class.from_nat p)

goal (1 subgoal):
 1. U $ s $ (s + mod_type_class.from_nat p) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U $ s $ (s + mod_type_class.from_nat p) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ s $ (s + mod_type_class.from_nat p) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ s $ (s + mod_type_class.from_nat j) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>j s. 1 \<le> j \<and> j < ncols A - mod_type_class.to_nat s \<longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0

goal (1 subgoal):
 1. H = K
[PROOF STEP]
have "U = mat 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U = mat 1
[PROOF STEP]
proof (unfold mat_def vec_eq_iff, auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>ia. U $ ia $ ia = 1
 2. \<And>i ia. i \<noteq> ia \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
fix ia
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>ia. U $ ia $ ia = 1
 2. \<And>i ia. i \<noteq> ia \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
show "U $ ia $ ia = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ ia $ ia = 1
[PROOF STEP]
using Uii_1
[PROOF STATE]
proof (prove)
using this:
\<forall>i. U $ i $ i = 1

goal (1 subgoal):
 1. U $ ia $ ia = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
U $ ia $ ia = 1

goal (1 subgoal):
 1. \<And>i ia. i \<noteq> ia \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i ia. i \<noteq> ia \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
assume i_ia: "i \<noteq> ia"
[PROOF STATE]
proof (state)
this:
i \<noteq> ia

goal (1 subgoal):
 1. \<And>i ia. i \<noteq> ia \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
show "U $ i $ ia = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
proof (cases "ia<i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ia < i \<Longrightarrow> U $ i $ ia = 0
 2. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
ia < i

goal (2 subgoals):
 1. ia < i \<Longrightarrow> U $ i $ ia = 0
 2. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ia < i

goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
using upper_triangular_U
[PROOF STATE]
proof (prove)
using this:
ia < i
upper_triangular U

goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
unfolding upper_triangular_def
[PROOF STATE]
proof (prove)
using this:
ia < i
\<forall>i j. j < i \<longrightarrow> U $ i $ j = 0

goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U $ i $ ia = 0

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> ia < i

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
hence i_less_ia: "i<ia"
[PROOF STATE]
proof (prove)
using this:
\<not> ia < i

goal (1 subgoal):
 1. i < ia
[PROOF STEP]
using i_ia
[PROOF STATE]
proof (prove)
using this:
\<not> ia < i
i \<noteq> ia

goal (1 subgoal):
 1. i < ia
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < ia

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
define a where "a = to_nat ia - to_nat i"
[PROOF STATE]
proof (state)
this:
a = mod_type_class.to_nat ia - mod_type_class.to_nat i

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
have ia_eq: "ia = i + from_nat a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ia = i + mod_type_class.from_nat a
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ia = i + mod_type_class.from_nat (mod_type_class.to_nat ia - mod_type_class.to_nat i)
[PROOF STEP]
by (metis i_less_ia a_def add_to_nat_def dual_order.strict_iff_order from_nat_to_nat_id
            le_add_diff_inverse less_imp_diff_less to_nat_from_nat_id to_nat_less_card to_nat_mono)
[PROOF STATE]
proof (state)
this:
ia = i + mod_type_class.from_nat a

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
have "1 \<le> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> a
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> mod_type_class.to_nat ia - mod_type_class.to_nat i
[PROOF STEP]
by (metis diff_is_0_eq i_less_ia less_one not_less to_nat_mono)
[PROOF STATE]
proof (state)
this:
1 \<le> a

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
1 \<le> a

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
have "a < ncols A - to_nat i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < ncols A - mod_type_class.to_nat i
[PROOF STEP]
unfolding a_def ncols_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat ia - mod_type_class.to_nat i < CARD('n) - mod_type_class.to_nat i
[PROOF STEP]
by (metis False diff_less_mono not_less to_nat_less_card to_nat_mono')
[PROOF STATE]
proof (state)
this:
a < ncols A - mod_type_class.to_nat i

goal (1 subgoal):
 1. \<not> ia < i \<Longrightarrow> U $ i $ ia = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
1 \<le> a
a < ncols A - mod_type_class.to_nat i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
a < ncols A - mod_type_class.to_nat i

goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
using zero_above
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
a < ncols A - mod_type_class.to_nat i
\<forall>j s. 1 \<le> j \<and> j < ncols A - mod_type_class.to_nat s \<longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0

goal (1 subgoal):
 1. U $ i $ ia = 0
[PROOF STEP]
unfolding ia_eq
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
a < ncols A - mod_type_class.to_nat i
\<forall>j s. 1 \<le> j \<and> j < ncols A - mod_type_class.to_nat s \<longrightarrow> U $ s $ (s + mod_type_class.from_nat j) = 0

goal (1 subgoal):
 1. U $ i $ (i + mod_type_class.from_nat a) = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
U $ i $ ia = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U $ i $ ia = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
U = mat 1

goal (1 subgoal):
 1. H = K
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
U = mat 1

goal (1 subgoal):
 1. H = K
[PROOF STEP]
using H_UK matrix_mul_lid
[PROOF STATE]
proof (prove)
using this:
U = mat 1
H = U ** K
mat (1::?'a) ** ?A = ?A

goal (1 subgoal):
 1. H = K
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
H = K

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma invariant_succs:
assumes "invariant I succs"
and "\<forall>x\<in>S. I x"
shows "\<forall>x \<in> (Rel succs)\<^sup>* `` S. I x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
have "(x,y) : (Rel succs)\<^sup>* \<Longrightarrow> I x \<Longrightarrow> I y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; I x\<rbrakk> \<Longrightarrow> I y
[PROOF STEP]
proof(induct rule:rtrancl_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. I x \<Longrightarrow> I x
 2. \<And>y z. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; (y, z) \<in> Rel succs; I x \<Longrightarrow> I y; I x\<rbrakk> \<Longrightarrow> I z
[PROOF STEP]
case base
[PROOF STATE]
proof (state)
this:
I x

goal (2 subgoals):
 1. I x \<Longrightarrow> I x
 2. \<And>y z. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; (y, z) \<in> Rel succs; I x \<Longrightarrow> I y; I x\<rbrakk> \<Longrightarrow> I z
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
I x

goal (1 subgoal):
 1. I x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
I x

goal (1 subgoal):
 1. \<And>y z. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; (y, z) \<in> Rel succs; I x \<Longrightarrow> I y; I x\<rbrakk> \<Longrightarrow> I z
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y z. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; (y, z) \<in> Rel succs; I x \<Longrightarrow> I y; I x\<rbrakk> \<Longrightarrow> I z
[PROOF STEP]
case step
[PROOF STATE]
proof (state)
this:
(x, y_) \<in> (Rel succs)\<^sup>*
(y_, z_) \<in> Rel succs
I x \<Longrightarrow> I y_
I x

goal (1 subgoal):
 1. \<And>y z. \<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; (y, z) \<in> Rel succs; I x \<Longrightarrow> I y; I x\<rbrakk> \<Longrightarrow> I z
[PROOF STEP]
with assms(1)
[PROOF STATE]
proof (chain)
picking this:
invariant I succs
(x, y_) \<in> (Rel succs)\<^sup>*
(y_, z_) \<in> Rel succs
I x \<Longrightarrow> I y_
I x
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
invariant I succs
(x, y_) \<in> (Rel succs)\<^sup>*
(y_, z_) \<in> Rel succs
I x \<Longrightarrow> I y_
I x

goal (1 subgoal):
 1. I z_
[PROOF STEP]
by(auto simp:invariant_def)
[PROOF STATE]
proof (state)
this:
I z_

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>(x, y) \<in> (Rel succs)\<^sup>*; I x\<rbrakk> \<Longrightarrow> I y

goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?x2, ?y2) \<in> (Rel succs)\<^sup>*; I ?x2\<rbrakk> \<Longrightarrow> I ?y2

goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
with assms(2)
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. I x
\<lbrakk>(?x2, ?y2) \<in> (Rel succs)\<^sup>*; I ?x2\<rbrakk> \<Longrightarrow> I ?y2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. I x
\<lbrakk>(?x2, ?y2) \<in> (Rel succs)\<^sup>*; I ?x2\<rbrakk> \<Longrightarrow> I ?y2

goal (1 subgoal):
 1. \<forall>x\<in>(Rel succs)\<^sup>* `` S. I x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>(Rel succs)\<^sup>* `` S. I x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iso_iff_section_and_retraction:
    shows "iso f \<longleftrightarrow> section f \<and> retraction f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.iso f = (section f \<and> retraction f)
[PROOF STEP]
using iso_is_retraction iso_is_section iso_iff_mono_and_retraction section_is_mono
[PROOF STATE]
proof (prove)
using this:
local.iso ?f \<Longrightarrow> retraction ?f
local.iso ?f \<Longrightarrow> section ?f
local.iso ?f = (local.mono ?f \<and> retraction ?f)
section ?g \<Longrightarrow> local.mono ?g

goal (1 subgoal):
 1. local.iso f = (section f \<and> retraction f)
[PROOF STEP]
by auto


[STATEMENT]
lemma exphr_hypreal_of_real_exp_eq: "exphr x = hypreal_of_real (exp x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
have "(\<lambda>n. inverse (fact n) * x ^ n) sums exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. inverse (fact n) * x ^ n) sums exp x
[PROOF STEP]
using exp_converges [of x]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. x ^ n /\<^sub>R fact n) sums exp x

goal (1 subgoal):
 1. (\<lambda>n. inverse (fact n) * x ^ n) sums exp x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. inverse (fact n) * x ^ n) sums exp x

goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. inverse (fact n) * x ^ n) sums exp x
[PROOF STEP]
have "(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse (fact n) * x ^ n) sums exp x

goal (1 subgoal):
 1. (\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x
[PROOF STEP]
using NSsums_def sums_NSsums_iff
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse (fact n) * x ^ n) sums exp x
?f NSsums ?s = (\<lambda>n. sum ?f {..<n}) \<longlonglongrightarrow>\<^sub>N\<^sub>S ?s
?f sums ?l = ?f NSsums ?l

goal (1 subgoal):
 1. (\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x

goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x
[PROOF STEP]
have "hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x

goal (1 subgoal):
 1. hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)
[PROOF STEP]
unfolding starfunNat_sumr [symmetric] atLeast0LessThan
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x

goal (1 subgoal):
 1. hypreal_of_real (exp x) \<approx> (*f* (\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n)) whn
[PROOF STEP]
using HNatInfinite_whn NSLIMSEQ_def approx_sym
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n) \<longlonglongrightarrow>\<^sub>N\<^sub>S exp x
whn \<in> HNatInfinite
?X \<longlonglongrightarrow>\<^sub>N\<^sub>S ?L = (\<forall>N\<in>HNatInfinite. (*f* ?X) N \<approx> star_of ?L)
?x \<approx> ?y \<Longrightarrow> ?y \<approx> ?x

goal (1 subgoal):
 1. hypreal_of_real (exp x) \<approx> (*f* (\<lambda>n. \<Sum>n<n. inverse (fact n) * x ^ n)) whn
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)

goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)

goal (1 subgoal):
 1. exphr x = hypreal_of_real (exp x)
[PROOF STEP]
unfolding exphr_def
[PROOF STATE]
proof (prove)
using this:
hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)

goal (1 subgoal):
 1. st (sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)) = hypreal_of_real (exp x)
[PROOF STEP]
using st_eq_approx_iff
[PROOF STATE]
proof (prove)
using this:
hypreal_of_real (exp x) \<approx> sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)
\<lbrakk>?x \<in> HFinite; ?y \<in> HFinite\<rbrakk> \<Longrightarrow> (?x \<approx> ?y) = (st ?x = st ?y)

goal (1 subgoal):
 1. st (sumhr (0, whn, \<lambda>n. inverse (fact n) * x ^ n)) = hypreal_of_real (exp x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
exphr x = hypreal_of_real (exp x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma deltafun_plus :
  fixes     b c :: "'b::monoid_add"
  shows     "(b+c) \<delta> a = (b \<delta> a) + (c \<delta> a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (b + c) \<delta> a = b \<delta> a + c \<delta> a
[PROOF STEP]
unfolding deltafun_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if x = a then b + c else (0::'b)) = (\<lambda>x. if x = a then b else (0::'b)) + (\<lambda>x. if x = a then c else (0::'b))
[PROOF STEP]
by        auto


[STATEMENT]
lemma a_comp_simp [simp]: "(ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
have f1: "(ad x \<oplus> ad y) \<cdot> d x = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad (ad x) \<cdot> ad (ad (ad y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad (ad x) \<cdot> ad (ad (ad y))
[PROOF STEP]
by (simp add: am_add_op_def am_d_def)
[PROOF STATE]
proof (state)
this:
(ad x \<oplus> ad y) \<cdot> d x = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad (ad x) \<cdot> ad (ad (ad y))

goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
have f2: "ad y = ad (ad (ad y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ad y = ad (ad (ad y))
[PROOF STEP]
using a_add_idem am_add_op_def
[PROOF STATE]
proof (prove)
using this:
ad ?x \<oplus> ad ?x = ad ?x
?x \<oplus> ?y \<equiv> ad (ad ?x \<cdot> ad ?y)

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

goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
have "ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y
[PROOF STEP]
by (metis (no_types) a_absorb1 a_add_comm am_add_op_def)
[PROOF STATE]
proof (state)
this:
ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y

goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y

goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
using f2 f1
[PROOF STATE]
proof (prove)
using this:
ad y = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad y
ad y = ad (ad (ad y))
(ad x \<oplus> ad y) \<cdot> d x = ad (ad (ad x) \<cdot> ad (ad y)) \<cdot> ad (ad x) \<cdot> ad (ad (ad y))

goal (1 subgoal):
 1. (ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x
[PROOF STEP]
by (simp add: am_d_def local.am2 local.mult.semigroup_axioms semigroup.assoc)
[PROOF STATE]
proof (state)
this:
(ad x \<oplus> ad y) \<cdot> d x = ad y \<cdot> d x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_sum_mono_neutral:
  fixes f :: "'a\<Rightarrow>'b::{ordered_comm_monoid_add,linorder_topology}"
  (* Does this really require a linorder topology? (Instead of order topology.) *)
  assumes \<open>has_sum f A a\<close> and "has_sum g B b"
  assumes \<open>\<And>x. x \<in> A\<inter>B \<Longrightarrow> f x \<le> g x\<close>
  assumes \<open>\<And>x. x \<in> A-B \<Longrightarrow> f x \<le> 0\<close>
  assumes \<open>\<And>x. x \<in> B-A \<Longrightarrow> g x \<ge> 0\<close>
  shows "a \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
define f' g' where \<open>f' x = (if x \<in> A then f x else 0)\<close> and \<open>g' x = (if x \<in> B then g x else 0)\<close> for x
[PROOF STATE]
proof (state)
this:
f' ?x = (if ?x \<in> A then f ?x else (0::'b))
g' ?x = (if ?x \<in> B then g ?x else (0::'b))

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
have [simp]: \<open>f summable_on A\<close> \<open>g summable_on B\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f summable_on A &&& g summable_on B
[PROOF STEP]
using assms(1,2) summable_on_def
[PROOF STATE]
proof (prove)
using this:
has_sum f A a
has_sum g B b
(?f summable_on ?A) = (\<exists>x. has_sum ?f ?A x)

goal (1 subgoal):
 1. f summable_on A &&& g summable_on B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f summable_on A
g summable_on B

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
have \<open>has_sum f' (A\<union>B) a\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. has_sum f' (A \<union> B) a
[PROOF STEP]
apply (subst has_sum_cong_neutral[where g=f and T=A])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>x. x \<in> A - (A \<union> B) \<Longrightarrow> f x = (0::'b)
 2. \<And>x. x \<in> A \<union> B - A \<Longrightarrow> f' x = (0::'b)
 3. \<And>x. x \<in> (A \<union> B) \<inter> A \<Longrightarrow> f' x = f x
 4. has_sum f A a
[PROOF STEP]
by (auto simp: f'_def assms(1))
[PROOF STATE]
proof (state)
this:
has_sum f' (A \<union> B) a

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
has_sum f' (A \<union> B) a
[PROOF STEP]
have f'_lim: \<open>(sum f' \<longlongrightarrow> a) (finite_subsets_at_top (A\<union>B))\<close>
[PROOF STATE]
proof (prove)
using this:
has_sum f' (A \<union> B) a

goal (1 subgoal):
 1. (sum f' \<longlongrightarrow> a) (finite_subsets_at_top (A \<union> B))
[PROOF STEP]
by (meson has_sum_def)
[PROOF STATE]
proof (state)
this:
(sum f' \<longlongrightarrow> a) (finite_subsets_at_top (A \<union> B))

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
have \<open>has_sum g' (A\<union>B) b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. has_sum g' (A \<union> B) b
[PROOF STEP]
apply (subst has_sum_cong_neutral[where g=g and T=B])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>x. x \<in> B - (A \<union> B) \<Longrightarrow> g x = (0::'b)
 2. \<And>x. x \<in> A \<union> B - B \<Longrightarrow> g' x = (0::'b)
 3. \<And>x. x \<in> (A \<union> B) \<inter> B \<Longrightarrow> g' x = g x
 4. has_sum g B b
[PROOF STEP]
by (auto simp: g'_def assms(2))
[PROOF STATE]
proof (state)
this:
has_sum g' (A \<union> B) b

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
has_sum g' (A \<union> B) b
[PROOF STEP]
have g'_lim: \<open>(sum g' \<longlongrightarrow> b) (finite_subsets_at_top (A\<union>B))\<close>
[PROOF STATE]
proof (prove)
using this:
has_sum g' (A \<union> B) b

goal (1 subgoal):
 1. (sum g' \<longlongrightarrow> b) (finite_subsets_at_top (A \<union> B))
[PROOF STEP]
using has_sum_def
[PROOF STATE]
proof (prove)
using this:
has_sum g' (A \<union> B) b
has_sum ?f ?A ?x = (sum ?f \<longlongrightarrow> ?x) (finite_subsets_at_top ?A)

goal (1 subgoal):
 1. (sum g' \<longlongrightarrow> b) (finite_subsets_at_top (A \<union> B))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(sum g' \<longlongrightarrow> b) (finite_subsets_at_top (A \<union> B))

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
have *: \<open>\<forall>\<^sub>F x in finite_subsets_at_top (A \<union> B). sum f' x \<le> sum g' x\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in finite_subsets_at_top (A \<union> B). sum f' x \<le> sum g' x
[PROOF STEP]
apply (rule eventually_finite_subsets_at_top_weakI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>X. \<lbrakk>finite X; X \<subseteq> A \<union> B\<rbrakk> \<Longrightarrow> sum f' X \<le> sum g' X
[PROOF STEP]
apply (rule sum_mono)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>X i. \<lbrakk>finite X; X \<subseteq> A \<union> B; i \<in> X\<rbrakk> \<Longrightarrow> f' i \<le> g' i
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
has_sum f A a
has_sum g B b
?x \<in> A \<inter> B \<Longrightarrow> f ?x \<le> g ?x
?x \<in> A - B \<Longrightarrow> f ?x \<le> (0::'b)
?x \<in> B - A \<Longrightarrow> (0::'b) \<le> g ?x

goal (1 subgoal):
 1. \<And>X i. \<lbrakk>finite X; X \<subseteq> A \<union> B; i \<in> X\<rbrakk> \<Longrightarrow> f' i \<le> g' i
[PROOF STEP]
by (auto simp: f'_def g'_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in finite_subsets_at_top (A \<union> B). sum f' x \<le> sum g' x

goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<le> b
[PROOF STEP]
apply (rule tendsto_le)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. ?F \<noteq> bot
 2. (?f \<longlongrightarrow> b) ?F
 3. (?g \<longlongrightarrow> a) ?F
 4. \<forall>\<^sub>F x in ?F. ?g x \<le> ?f x
[PROOF STEP]
using * g'_lim f'_lim
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in finite_subsets_at_top (A \<union> B). sum f' x \<le> sum g' x
(sum g' \<longlongrightarrow> b) (finite_subsets_at_top (A \<union> B))
(sum f' \<longlongrightarrow> a) (finite_subsets_at_top (A \<union> B))

goal (4 subgoals):
 1. ?F \<noteq> bot
 2. (?f \<longlongrightarrow> b) ?F
 3. (?g \<longlongrightarrow> a) ?F
 4. \<forall>\<^sub>F x in ?F. ?g x \<le> ?f x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<le> b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in loopfree_digraph) loopfree_digraphI_app_iso:
  assumes "digraph_isomorphism hom"
  shows "loopfree_digraph (app_iso hom G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. loopfree_digraph (app_iso hom G)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. loopfree_digraph (app_iso hom G)
[PROOF STEP]
interpret iG: wf_digraph "app_iso hom G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_digraph (app_iso hom G)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
digraph_isomorphism hom

goal (1 subgoal):
 1. wf_digraph (app_iso hom G)
[PROOF STEP]
by (rule wf_digraphI_app_iso)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. loopfree_digraph (app_iso hom G)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. loopfree_digraph (app_iso hom G)
[PROOF STEP]
using assms digraph_isomorphism_inj_on_verts[OF assms]
[PROOF STATE]
proof (prove)
using this:
digraph_isomorphism hom
inj_on (iso_verts hom) (verts G)

goal (1 subgoal):
 1. loopfree_digraph (app_iso hom G)
[PROOF STEP]
by unfold_locales (auto simp: iso_verts_tail iso_verts_head dest: inj_onD no_loops)
[PROOF STATE]
proof (state)
this:
loopfree_digraph (app_iso hom G)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_zero_uniq:
  assumes x: "x \<in> V"  "x \<noteq> 0" and ax: "a \<cdot> x = 0"
  shows "a = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = 0
[PROOF STEP]
proof (rule classical)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
assume a: "a \<noteq> 0"
[PROOF STATE]
proof (state)
this:
a \<noteq> 0

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
from x a
[PROOF STATE]
proof (chain)
picking this:
x \<in> V
x \<noteq> (0::'a)
a \<noteq> 0
[PROOF STEP]
have "x = (inverse a * a) \<cdot> x"
[PROOF STATE]
proof (prove)
using this:
x \<in> V
x \<noteq> (0::'a)
a \<noteq> 0

goal (1 subgoal):
 1. x = (inverse a * a) \<cdot> x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x = (inverse a * a) \<cdot> x

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x = (inverse a * a) \<cdot> x

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
from \<open>x \<in> V\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<in> V
[PROOF STEP]
have "\<dots> = inverse a \<cdot> (a \<cdot> x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> V

goal (1 subgoal):
 1. (inverse a * a) \<cdot> x = inverse a \<cdot> a \<cdot> x
[PROOF STEP]
by (rule mult_assoc)
[PROOF STATE]
proof (state)
this:
(inverse a * a) \<cdot> x = inverse a \<cdot> a \<cdot> x

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(inverse a * a) \<cdot> x = inverse a \<cdot> a \<cdot> x

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
from ax
[PROOF STATE]
proof (chain)
picking this:
a \<cdot> x = (0::'a)
[PROOF STEP]
have "\<dots> = inverse a \<cdot> 0"
[PROOF STATE]
proof (prove)
using this:
a \<cdot> x = (0::'a)

goal (1 subgoal):
 1. inverse a \<cdot> a \<cdot> x = inverse a \<cdot> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse a \<cdot> a \<cdot> x = inverse a \<cdot> (0::'a)

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
inverse a \<cdot> a \<cdot> x = inverse a \<cdot> (0::'a)

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
have "\<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse a \<cdot> (0::'a) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse a \<cdot> (0::'a) = (0::'a)

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x = (0::'a)
[PROOF STEP]
have "x = 0"
[PROOF STATE]
proof (prove)
using this:
x = (0::'a)

goal (1 subgoal):
 1. x = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x = (0::'a)

goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> a = 0
[PROOF STEP]
with \<open>x \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> (0::'a)
x = (0::'a)
[PROOF STEP]
show "a = 0"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)
x = (0::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma add_nth_take_drop: "i \<le> length zs \<Longrightarrow> add_nth i v zs = take i zs @ v # drop i zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> length zs \<Longrightarrow> add_nth i v zs = take i zs @ v # drop i zs
[PROOF STEP]
by (induction i v zs rule: add_nth.induct) (auto split: list.splits)


[STATEMENT]
lemma summable_LIMSEQ': "summable f \<Longrightarrow> (\<lambda>n. \<Sum>i\<le>n. f i) \<longlonglongrightarrow> suminf f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable f \<Longrightarrow> (\<lambda>n. sum f {..n}) \<longlonglongrightarrow> suminf f
[PROOF STEP]
using sums_def_le
[PROOF STATE]
proof (prove)
using this:
?f sums ?s = (\<lambda>n. sum ?f {..n}) \<longlonglongrightarrow> ?s

goal (1 subgoal):
 1. summable f \<Longrightarrow> (\<lambda>n. sum f {..n}) \<longlonglongrightarrow> suminf f
[PROOF STEP]
by blast


[STATEMENT]
lemma grey_protects_white_induct[consumes 1, case_names refl step, induct set: grey_protects_white]:
  assumes "(g grey_protects_white w) s"
  assumes "\<And>x. grey x s \<Longrightarrow> P x x"
  assumes "\<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z"
  shows "P g w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P g w
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(g grey_protects_white w) s
grey ?x s \<Longrightarrow> P ?x ?x
\<lbrakk>(?x has_white_path_to ?y) s; P ?x ?y; (?y points_to ?z) s; white ?z s\<rbrakk> \<Longrightarrow> P ?x ?z

goal (1 subgoal):
 1. P g w
[PROOF STEP]
unfolding grey_protects_white_def
[PROOF STATE]
proof (prove)
using this:
grey g s \<and> (g has_white_path_to w) s
grey ?x s \<Longrightarrow> P ?x ?x
\<lbrakk>(?x has_white_path_to ?y) s; P ?x ?y; (?y points_to ?z) s; white ?z s\<rbrakk> \<Longrightarrow> P ?x ?z

goal (1 subgoal):
 1. P g w
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>grey g s \<and> (g has_white_path_to w) s; \<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z\<rbrakk> \<Longrightarrow> P g w
[PROOF STEP]
apply (elim conjE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z; grey g s; (g has_white_path_to w) s\<rbrakk> \<Longrightarrow> P g w
[PROOF STEP]
apply (rotate_tac -1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(g has_white_path_to w) s; \<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z; grey g s\<rbrakk> \<Longrightarrow> P g w
[PROOF STEP]
apply (induct rule: has_white_path_to_induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>\<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z; grey x s\<rbrakk> \<Longrightarrow> P x x
 2. \<And>x y z. \<lbrakk>(x has_white_path_to y) s; \<lbrakk>\<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z; grey x s\<rbrakk> \<Longrightarrow> P x y; (y points_to z) s; white z s; \<And>x. grey x s \<Longrightarrow> P x x; \<And>x y z. \<lbrakk>(x has_white_path_to y) s; P x y; (y points_to z) s; white z s\<rbrakk> \<Longrightarrow> P x z; grey x s\<rbrakk> \<Longrightarrow> P x z
[PROOF STEP]
apply blast+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma diag_elems_ne:
  assumes "B \<in> carrier_mat n n"
  and "0 < n"
shows "diag_elems B \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_elems B \<noteq> {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. diag_elems B \<noteq> {}
[PROOF STEP]
have "B $$(0,0) \<in> diag_elems B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (0, 0) \<in> diag_elems B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
B \<in> carrier_mat n n
0 < n

goal (1 subgoal):
 1. B $$ (0, 0) \<in> diag_elems B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B $$ (0, 0) \<in> diag_elems B

goal (1 subgoal):
 1. diag_elems B \<noteq> {}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
B $$ (0, 0) \<in> diag_elems B

goal (1 subgoal):
 1. diag_elems B \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diag_elems B \<noteq> {}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma succ0_not_nil: "succs 0 \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. succs 0 \<noteq> {}
[PROOF STEP]
using succ_of_entry0
[PROOF STATE]
proof (prove)
using this:
\<exists>s. (0, s) \<in> g_E G \<and> s \<noteq> 0

goal (1 subgoal):
 1. succs 0 \<noteq> {}
[PROOF STEP]
by (auto simp add:succs_def)


[STATEMENT]
lemma filterlim_floor_at_bot: "filterlim (floor :: real \<Rightarrow> int) at_bot at_bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim floor at_bot at_bot
[PROOF STEP]
proof (subst filterlim_at_bot, rule allI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Z. \<forall>\<^sub>F x in at_bot. \<lfloor>x\<rfloor> \<le> Z
[PROOF STEP]
fix C :: int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Z. \<forall>\<^sub>F x in at_bot. \<lfloor>x\<rfloor> \<le> Z
[PROOF STEP]
show "eventually (\<lambda>x::real. \<lfloor>x\<rfloor> \<le> C) at_bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_bot. \<lfloor>x\<rfloor> \<le> C
[PROOF STEP]
using eventually_le_at_bot[of "real_of_int C"]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_bot. x \<le> real_of_int C

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_bot. \<lfloor>x\<rfloor> \<le> C
[PROOF STEP]
by eventually_elim linarith
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_bot. \<lfloor>x\<rfloor> \<le> C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma stirling_Suc_n_2:
  assumes "n \<ge> Suc 0"
  shows "stirling (Suc n) 2 = (\<Sum>k=1..n. fact n div k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Suc 0 \<le> n

goal (1 subgoal):
 1. stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc 0 \<le> 0 \<Longrightarrow> stirling (Suc 0) 2 = sum ((div) (fact 0)) {1..0}
 2. \<And>n. \<lbrakk>Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}; Suc 0 \<le> Suc n\<rbrakk> \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> 0

goal (2 subgoals):
 1. Suc 0 \<le> 0 \<Longrightarrow> stirling (Suc 0) 2 = sum ((div) (fact 0)) {1..0}
 2. \<And>n. \<lbrakk>Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}; Suc 0 \<le> Suc n\<rbrakk> \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Suc 0 \<le> 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Suc 0 \<le> 0

goal (1 subgoal):
 1. stirling (Suc 0) 2 = sum ((div) (fact 0)) {1..0}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
stirling (Suc 0) 2 = sum ((div) (fact 0)) {1..0}

goal (1 subgoal):
 1. \<And>n. \<lbrakk>Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}; Suc 0 \<le> Suc n\<rbrakk> \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}; Suc 0 \<le> Suc n\<rbrakk> \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}
Suc 0 \<le> Suc n

goal (1 subgoal):
 1. \<And>n. \<lbrakk>Suc 0 \<le> n \<Longrightarrow> stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}; Suc 0 \<le> Suc n\<rbrakk> \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
 2. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
 2. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
by (simp add: numerals(2))
[PROOF STATE]
proof (state)
this:
stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
case Suc
[PROOF STATE]
proof (state)
this:
n = Suc nat_

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = Suc nat_
[PROOF STEP]
have geq1: "Suc 0 \<le> n"
[PROOF STATE]
proof (prove)
using this:
n = Suc nat_

goal (1 subgoal):
 1. Suc 0 \<le> n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
have "stirling (Suc (Suc n)) 2 = Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stirling (Suc (Suc n)) 2 = Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0)
[PROOF STEP]
by (simp only: stirling.simps(4)[of "Suc n"] numerals(2))
[PROOF STATE]
proof (state)
this:
stirling (Suc (Suc n)) 2 = Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0)

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
stirling (Suc (Suc n)) 2 = Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0)

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
have "\<dots> = Suc n * (\<Sum>k=1..n. fact n div k) + fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0) = Suc n * sum ((div) (fact n)) {1..n} + fact n
[PROOF STEP]
using Suc.hyps[OF geq1]
[PROOF STATE]
proof (prove)
using this:
stirling (Suc n) 2 = sum ((div) (fact n)) {1..n}

goal (1 subgoal):
 1. Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0) = Suc n * sum ((div) (fact n)) {1..n} + fact n
[PROOF STEP]
by (simp only: stirling_Suc_n_1 of_nat_fact of_nat_add of_nat_mult)
[PROOF STATE]
proof (state)
this:
Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0) = Suc n * sum ((div) (fact n)) {1..n} + fact n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Suc n * stirling (Suc n) 2 + stirling (Suc n) (Suc 0) = Suc n * sum ((div) (fact n)) {1..n} + fact n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
have "\<dots> = Suc n * (\<Sum>k=1..n. fact n div k) + Suc n * fact n div Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n * sum ((div) (fact n)) {1..n} + fact n = Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n
[PROOF STEP]
by (metis nat.distinct(1) nonzero_mult_div_cancel_left)
[PROOF STATE]
proof (state)
this:
Suc n * sum ((div) (fact n)) {1..n} + fact n = Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Suc n * sum ((div) (fact n)) {1..n} + fact n = Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
have "\<dots> = (\<Sum>k=1..n. fact (Suc n) div k) + fact (Suc n) div Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n = sum ((div) (fact (Suc n))) {1..n} + fact (Suc n) div Suc n
[PROOF STEP]
by (simp add: sum_distrib_left div_mult_swap dvd_fact)
[PROOF STATE]
proof (state)
this:
Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n = sum ((div) (fact (Suc n))) {1..n} + fact (Suc n) div Suc n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Suc n * sum ((div) (fact n)) {1..n} + Suc n * fact n div Suc n = sum ((div) (fact (Suc n))) {1..n} + fact (Suc n) div Suc n

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
have "\<dots> = (\<Sum>k=1..Suc n. fact (Suc n) div k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((div) (fact (Suc n))) {1..n} + fact (Suc n) div Suc n = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum ((div) (fact (Suc n))) {1..n} + fact (Suc n) div Suc n = sum ((div) (fact (Suc n))) {1..Suc n}

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}

goal (1 subgoal):
 1. stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
stirling (Suc (Suc n)) 2 = sum ((div) (fact (Suc n))) {1..Suc n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma coeffM_code [code abstract]: "vec_nth (coeffM A n) = coeffM_row A n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (coeffM A n) = coeffM_row A n
[PROOF STEP]
unfolding coeffM_def coeffM_row_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>i j. coeff (A $ i $ j) n) = (\<lambda>i. \<chi>j. coeff (A $ i $ j) n)
[PROOF STEP]
using vec_lambda_beta
[PROOF STATE]
proof (prove)
using this:
vec_lambda ?g $ ?i = ?g ?i

goal (1 subgoal):
 1. ($) (\<chi>i j. coeff (A $ i $ j) n) = (\<lambda>i. \<chi>j. coeff (A $ i $ j) n)
[PROOF STEP]
by auto