[STATEMENT]
lemma reduce_system_matrix_match_R:
  fixes p:: "real poly"
  fixes qs :: "real poly list"
  fixes subsets :: "(nat list*nat list) list"
  fixes signs :: "rat list list"
  assumes nonzero: "p \<noteq> 0"
  assumes welldefined_signs1: "well_def_signs (length qs) signs"
  assumes distinct_signs: "distinct signs"
  assumes all_info: "set (characterize_consistent_signs_at_roots p qs) \<subseteq> set(signs)"
  assumes match: "satisfy_equation_R p qs subsets signs"
  assumes inv: "invertible_mat (matrix_A_R signs subsets)"
  shows "matrix_A_R (get_signs_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))
  (get_subsets_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs))))) =
  (get_matrix_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
let ?A = "(matrix_A_R signs subsets)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
let ?lhs_vec = "(solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
let ?red_mtx = "(take_rows_from_matrix (reduce_mat_cols (matrix_A_R signs subsets) ?lhs_vec) (rows_to_keep (reduce_mat_cols (matrix_A_R signs subsets) ?lhs_vec)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h1: "matrix_A_R (get_signs_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))
  (get_subsets_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))
   = matrix_A_R (reduction_signs_R p qs signs subsets (matrix_A_R signs subsets)) (reduction_subsets_R p qs signs subsets (matrix_A_R signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (reduction_signs_R p qs signs subsets (M_mat_R signs subsets)) (reduction_subsets_R p qs signs subsets (M_mat_R signs subsets))
[PROOF STEP]
using reduction_signs_is_get_signs_R reduction_subsets_is_get_subsets_R
[PROOF STATE]
proof (prove)
using this:
reduction_signs_R ?p ?qs ?signs ?subsets ?m = get_signs_R (reduce_system_R ?p (?qs, ?m, ?subsets, ?signs))
reduction_subsets_R ?p ?qs ?signs ?subsets ?m = get_subsets_R (reduce_system_R ?p (?qs, ?m, ?subsets, ?signs))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (reduction_signs_R p qs signs subsets (M_mat_R signs subsets)) (reduction_subsets_R p qs signs subsets (M_mat_R signs subsets))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (reduction_signs_R p qs signs subsets (M_mat_R signs subsets)) (reduction_subsets_R p qs signs subsets (M_mat_R signs subsets))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h1_var: "matrix_A_R (get_signs_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))
  (get_subsets_R (reduce_system_R p (qs, ((matrix_A_R signs subsets), (subsets, signs)))))
   = matrix_A_R (take_indices signs (find_nonzeros_from_input_vec ?lhs_vec)) (take_indices subsets (rows_to_keep (reduce_mat_cols ?A ?lhs_vec)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
[PROOF STEP]
using h1 reduction_signs_R_def reduction_subsets_R_def
[PROOF STATE]
proof (prove)
using this:
M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (reduction_signs_R p qs signs subsets (M_mat_R signs subsets)) (reduction_subsets_R p qs signs subsets (M_mat_R signs subsets))
reduction_signs_R ?p ?qs ?signs ?subsets ?matr = take_indices ?signs (find_nonzeros_from_input_vec (solve_for_lhs_R ?p ?qs ?subsets ?matr))
reduction_subsets_R ?p ?qs ?signs ?subsets ?matr = take_indices ?subsets (rows_to_keep (reduce_mat_cols ?matr (solve_for_lhs_R ?p ?qs ?subsets ?matr)))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h2: "?red_mtx = (take_rows_from_matrix (take_cols_from_matrix ?A (find_nonzeros_from_input_vec ?lhs_vec)) (rows_to_keep (take_cols_from_matrix ?A (find_nonzeros_from_input_vec ?lhs_vec))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_rows_from_matrix (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
take_rows_from_matrix (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h30: "(construct_lhs_vector_R p qs signs) = ?lhs_vec"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
[PROOF STEP]
using assms construct_lhs_matches_solve_for_lhs_R
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
well_def_signs (length qs) signs
distinct signs
set (characterize_consistent_signs_at_roots p qs) \<subseteq> set signs
satisfy_equation_R p qs subsets signs
invertible_mat (M_mat_R signs subsets)
\<lbrakk>satisfy_equation_R ?p ?qs ?subsets ?signs; invertible_mat (M_mat_R ?signs ?subsets)\<rbrakk> \<Longrightarrow> w_vec_R ?p ?qs ?signs = solve_for_lhs_R ?p ?qs ?subsets (M_mat_R ?signs ?subsets)

goal (1 subgoal):
 1. w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h3a: "\<forall>x. List.member (find_nonzeros_from_input_vec ?lhs_vec) x \<longrightarrow>x < length (signs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length signs
[PROOF STEP]
using h30 size_of_lhs_R[of p qs signs]
[PROOF STATE]
proof (prove)
using this:
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
dim_vec (w_vec_R p qs signs) = length signs

goal (1 subgoal):
 1. \<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length signs
[PROOF STEP]
unfolding find_nonzeros_from_input_vec_def
[PROOF STATE]
proof (prove)
using this:
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
dim_vec (w_vec_R p qs signs) = length signs

goal (1 subgoal):
 1. \<forall>x. List.member (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) x \<longrightarrow> x < length signs
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets); dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)) = length signs; List.member (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length signs]) x\<rbrakk> \<Longrightarrow> x < length signs
[PROOF STEP]
using in_set_member
[PROOF STATE]
proof (prove)
using this:
(?x \<in> set ?xs) = List.member ?xs ?x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets); dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)) = length signs; List.member (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length signs]) x\<rbrakk> \<Longrightarrow> x < length signs
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length signs

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h3b_a: "\<forall>x. List.member (find_nonzeros_from_input_vec ?lhs_vec) x \<longrightarrow>x < length (subsets)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length subsets
[PROOF STEP]
using assms h30 size_of_lhs_R same_size_R
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
well_def_signs (length qs) signs
distinct signs
set (characterize_consistent_signs_at_roots p qs) \<subseteq> set signs
satisfy_equation_R p qs subsets signs
invertible_mat (M_mat_R signs subsets)
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
dim_vec (w_vec_R ?p ?qs ?signs) = length ?signs
invertible_mat (M_mat_R ?signs ?subsets) \<Longrightarrow> length ?subsets = length ?signs

goal (1 subgoal):
 1. \<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length subsets
[PROOF STEP]
unfolding find_nonzeros_from_input_vec_def
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
well_def_signs (length qs) signs
distinct signs
set (characterize_consistent_signs_at_roots p qs) \<subseteq> set signs
satisfy_equation_R p qs subsets signs
invertible_mat (M_mat_R signs subsets)
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
dim_vec (w_vec_R ?p ?qs ?signs) = length ?signs
invertible_mat (M_mat_R ?signs ?subsets) \<Longrightarrow> length ?subsets = length ?signs

goal (1 subgoal):
 1. \<forall>x. List.member (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) x \<longrightarrow> x < length subsets
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>p \<noteq> 0; well_def_signs (length qs) signs; distinct signs; set (characterize_consistent_signs_at_roots p qs) \<subseteq> set signs; satisfy_equation_R p qs subsets signs; invertible_mat (M_mat_R signs subsets); w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets); \<And>p qs signs. dim_vec (w_vec_R p qs signs) = length signs; \<And>signs subsets. invertible_mat (M_mat_R signs subsets) \<Longrightarrow> length subsets = length signs; List.member (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) x\<rbrakk> \<Longrightarrow> x < length signs
[PROOF STEP]
by (simp add: find_nonzeros_from_input_vec_def h3a)
[PROOF STATE]
proof (state)
this:
\<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length subsets

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h3ba: "length
     (filter (\<lambda>i. solve_for_lhs_R p qs subsets (matrix_A_R signs subsets) $ i \<noteq> 0)
       [0..<length subsets])
    \<le> length subsets"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length subsets]) \<le> length subsets
[PROOF STEP]
using length_filter_le[where P = "(\<lambda>i. solve_for_lhs_R p qs subsets (matrix_A_R signs subsets) $ i \<noteq> 0)",
    where xs = "[0..<length subsets]"] length_upto
[PROOF STATE]
proof (prove)
using this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length subsets]) \<le> length [0..<length subsets]
length [?i..?j] = nat (?j - ?i + 1)

goal (1 subgoal):
 1. length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length subsets]) \<le> length subsets
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length subsets]) \<le> length subsets

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have " length subsets = dim_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))
[PROOF STEP]
using h30 inv size_of_lhs_R same_size_R[of signs subsets]
[PROOF STATE]
proof (prove)
using this:
w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets)
invertible_mat (M_mat_R signs subsets)
dim_vec (w_vec_R ?p ?qs ?signs) = length ?signs
invertible_mat (M_mat_R signs subsets) \<Longrightarrow> length subsets = length signs

goal (1 subgoal):
 1. length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>w_vec_R p qs signs = solve_for_lhs_R p qs subsets (M_mat_R signs subsets); invertible_mat (M_mat_R signs subsets); \<And>p qs signs. dim_vec (w_vec_R p qs signs) = length signs; length subsets = length signs\<rbrakk> \<Longrightarrow> length signs = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))
[PROOF STEP]
have "length
     (filter (\<lambda>i. solve_for_lhs_R p qs subsets (matrix_A_R signs subsets) $ i \<noteq> 0)
       [0..<dim_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))])
    \<le> length subsets"
[PROOF STATE]
proof (prove)
using this:
length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))

goal (1 subgoal):
 1. length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets
[PROOF STEP]
using h3ba
[PROOF STATE]
proof (prove)
using this:
length subsets = dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<length subsets]) \<le> length subsets

goal (1 subgoal):
 1. length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets
[PROOF STEP]
have h3b: "length subsets \<ge> length (take_indices signs (find_nonzeros_from_input_vec ?lhs_vec))"
[PROOF STATE]
proof (prove)
using this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets

goal (1 subgoal):
 1. length (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) \<le> length subsets
[PROOF STEP]
unfolding take_indices_def find_nonzeros_from_input_vec_def
[PROOF STATE]
proof (prove)
using this:
length (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))]) \<le> length subsets

goal (1 subgoal):
 1. length (map ((!) signs) (filter (\<lambda>i. solve_for_lhs_R p qs subsets (M_mat_R signs subsets) $ i \<noteq> 0) [0..<dim_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))])) \<le> length subsets
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) \<le> length subsets

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h3c: "\<forall>x. List.member (rows_to_keep (reduce_mat_cols ?A ?lhs_vec)) x \<longrightarrow> x < length (subsets)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. List.member (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) x \<longrightarrow> x < length subsets
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
assume x_mem: "List.member (rows_to_keep
            (take_cols_from_matrix (matrix_A_R signs subsets)
              (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))))) x"
[PROOF STATE]
proof (state)
this:
List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x

goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
obtain nn :: "rat list list \<Rightarrow> nat list \<Rightarrow> nat" where
      "\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>nn. \<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by moura
[PROOF STATE]
proof (state)
this:
\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)

goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)
[PROOF STEP]
have f4: "nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))) < length signs \<or> matrix_A_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets)))) subsets = take_cols_from_matrix (matrix_A_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets)))"
[PROOF STATE]
proof (prove)
using this:
\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)

goal (1 subgoal):
 1. nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))
[PROOF STEP]
using nonzero
[PROOF STATE]
proof (prove)
using this:
\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)
p \<noteq> 0

goal (1 subgoal):
 1. nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))
[PROOF STEP]
using h3a reduce_system_matrix_signs_helper_R
[PROOF STATE]
proof (prove)
using this:
\<forall>x2 x3. (\<exists>v4. v4 \<in> set x3 \<and> \<not> v4 < length x2) = (nn x2 x3 \<in> set x3 \<and> \<not> nn x2 x3 < length x2)
p \<noteq> 0
\<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length signs
\<lbrakk>\<forall>x. List.member ?S x \<longrightarrow> x < length ?signs; ?p \<noteq> 0\<rbrakk> \<Longrightarrow> M_mat_R (take_indices ?signs ?S) ?subsets = take_cols_from_matrix (M_mat_R ?signs ?subsets) ?S

goal (1 subgoal):
 1. nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))

goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))
[PROOF STEP]
have "matrix_A_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets)))) subsets = take_cols_from_matrix (matrix_A_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (matrix_A_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (matrix_A_R signs subsets))))\<^sup>T)))"
[PROOF STATE]
proof (prove)
using this:
nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))

goal (1 subgoal):
 1. M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))
[PROOF STEP]
using f4
[PROOF STATE]
proof (prove)
using this:
nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))
nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<in> set (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> \<not> nn signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) < length signs \<or> M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))

goal (1 subgoal):
 1. M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))
[PROOF STEP]
by (metis h3a in_set_member rows_to_keep_def x_mem)
[PROOF STATE]
proof (state)
this:
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))

goal (1 subgoal):
 1. \<And>x. List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x \<Longrightarrow> x < length subsets
[PROOF STEP]
thus "x < length (subsets)"
[PROOF STATE]
proof (prove)
using this:
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))

goal (1 subgoal):
 1. x < length subsets
[PROOF STEP]
using x_mem
[PROOF STATE]
proof (prove)
using this:
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))
List.member (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) x

goal (1 subgoal):
 1. x < length subsets
[PROOF STEP]
unfolding rows_to_keep_def
[PROOF STATE]
proof (prove)
using this:
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) subsets = take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) \<and> x \<in> set (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T)))
List.member (map snd (pivot_positions (gauss_jordan_single (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))\<^sup>T))) x

goal (1 subgoal):
 1. x < length subsets
[PROOF STEP]
by (metis dim_row_matrix_A_R rows_to_keep_def rows_to_keep_lem)
[PROOF STATE]
proof (state)
this:
x < length subsets

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x. List.member (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) x \<longrightarrow> x < length subsets

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
have h3: "matrix_A_R (take_indices signs (find_nonzeros_from_input_vec ?lhs_vec)) (take_indices subsets (rows_to_keep (reduce_mat_cols ?A ?lhs_vec))) =
    (take_rows_from_matrix (take_cols_from_matrix ?A (find_nonzeros_from_input_vec ?lhs_vec)) (rows_to_keep (take_cols_from_matrix ?A (find_nonzeros_from_input_vec ?lhs_vec))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
[PROOF STEP]
using inv h3a h3b h3c reduce_system_matrix_subsets_helper_R reduce_system_matrix_signs_helper_R
      assms
[PROOF STATE]
proof (prove)
using this:
invertible_mat (M_mat_R signs subsets)
\<forall>x. List.member (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) x \<longrightarrow> x < length signs
length (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) \<le> length subsets
\<forall>x. List.member (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) x \<longrightarrow> x < length subsets
\<lbrakk>?p \<noteq> 0; length ?signs \<le> length ?subsets; \<forall>x. List.member ?S x \<longrightarrow> x < length ?subsets\<rbrakk> \<Longrightarrow> M_mat_R ?signs (take_indices ?subsets ?S) = take_rows_from_matrix (M_mat_R ?signs ?subsets) ?S
\<lbrakk>\<forall>x. List.member ?S x \<longrightarrow> x < length ?signs; ?p \<noteq> 0\<rbrakk> \<Longrightarrow> M_mat_R (take_indices ?signs ?S) ?subsets = take_cols_from_matrix (M_mat_R ?signs ?subsets) ?S
p \<noteq> 0
well_def_signs (length qs) signs
distinct signs
set (characterize_consistent_signs_at_roots p qs) \<subseteq> set signs
satisfy_equation_R p qs subsets signs
invertible_mat (M_mat_R signs subsets)

goal (1 subgoal):
 1. M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
using h1 h2 h3
[PROOF STATE]
proof (prove)
using this:
M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = M_mat_R (reduction_signs_R p qs signs subsets (M_mat_R signs subsets)) (reduction_subsets_R p qs signs subsets (M_mat_R signs subsets))
take_rows_from_matrix (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))) (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))
M_mat_R (take_indices signs (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (take_indices subsets (rows_to_keep (reduce_mat_cols (M_mat_R signs subsets) (solve_for_lhs_R p qs subsets (M_mat_R signs subsets))))) = take_rows_from_matrix (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))) (rows_to_keep (take_cols_from_matrix (M_mat_R signs subsets) (find_nonzeros_from_input_vec (solve_for_lhs_R p qs subsets (M_mat_R signs subsets)))))

goal (1 subgoal):
 1. M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))
[PROOF STEP]
by (metis fst_conv get_matrix_R_def h1_var reduce_system_R.simps reduction_step_R.simps)
[PROOF STATE]
proof (state)
this:
M_mat_R (get_signs_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) (get_subsets_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))) = get_matrix_R (reduce_system_R p (qs, M_mat_R signs subsets, subsets, signs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem "\<exists>(x::int). 0 < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. 0 < x
[PROOF STEP]
by presburger


[STATEMENT]
lemma isomorphism_expand:
  "f \<circ> g = id \<and> g \<circ> f = id \<longleftrightarrow> (\<forall>x. f (g x) = x) \<and> (\<forall>x. g (f x) = x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<circ> g = id \<and> g \<circ> f = id) = ((\<forall>x. f (g x) = x) \<and> (\<forall>x. g (f x) = x))
[PROOF STEP]
by (simp add: fun_eq_iff o_def id_def)


[STATEMENT]
lemma convex_affine_hull [simp]: "convex (affine hull S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex (affine hull S)
[PROOF STEP]
by (simp add: affine_imp_convex)


[STATEMENT]
lemma inj_Variable[simp]: "\<And> i j. Variable i = Variable j \<longleftrightarrow> i = j"
  and Variable[simp,intro!]: "\<And>i. Variable i \<in> var"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i j. (Variable i = Variable j) = (i = j)) &&& (\<And>i. Variable i \<in> var)
[PROOF STEP]
using Variable_inj_var image_def
[PROOF STATE]
proof (prove)
using this:
inj Variable \<and> range Variable \<subseteq> var
?f ` ?A = {y. \<exists>x\<in>?A. y = ?f x}

goal (1 subgoal):
 1. (\<And>i j. (Variable i = Variable j) = (i = j)) &&& (\<And>i. Variable i \<in> var)
[PROOF STEP]
unfolding inj_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>x y. Variable x = Variable y \<longrightarrow> x = y) \<and> range Variable \<subseteq> var
?f ` ?A = {y. \<exists>x\<in>?A. y = ?f x}

goal (1 subgoal):
 1. (\<And>i j. (Variable i = Variable j) = (i = j)) &&& (\<And>i. Variable i \<in> var)
[PROOF STEP]
by auto


[STATEMENT]
lemma (in idom_char_0) poly_zero: "poly p = poly [] \<longleftrightarrow> (\<forall>c \<in> set p. c = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a))
[PROOF STEP]
proof (induct p)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (poly [] = poly []) = (\<forall>c\<in>set []. c = (0::'a))
 2. \<And>a p. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a)) \<Longrightarrow> (poly (a # p) = poly []) = (\<forall>c\<in>set (a # p). c = (0::'a))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (poly [] = poly []) = (\<forall>c\<in>set []. c = (0::'a))
 2. \<And>a p. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a)) \<Longrightarrow> (poly (a # p) = poly []) = (\<forall>c\<in>set (a # p). c = (0::'a))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly [] = poly []) = (\<forall>c\<in>set []. c = (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(poly [] = poly []) = (\<forall>c\<in>set []. c = (0::'a))

goal (1 subgoal):
 1. \<And>a p. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a)) \<Longrightarrow> (poly (a # p) = poly []) = (\<forall>c\<in>set (a # p). c = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a p. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a)) \<Longrightarrow> (poly (a # p) = poly []) = (\<forall>c\<in>set (a # p). c = (0::'a))
[PROOF STEP]
case Cons
[PROOF STATE]
proof (state)
this:
(poly p_ = poly []) = (\<forall>c\<in>set p_. c = (0::'a))

goal (1 subgoal):
 1. \<And>a p. (poly p = poly []) = (\<forall>c\<in>set p. c = (0::'a)) \<Longrightarrow> (poly (a # p) = poly []) = (\<forall>c\<in>set (a # p). c = (0::'a))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly (a_ # p_) = poly []) = (\<forall>c\<in>set (a_ # p_). c = (0::'a))
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. poly (a_ # p_) = poly [] \<Longrightarrow> \<forall>c\<in>set (a_ # p_). c = (0::'a)
 2. \<forall>c\<in>set (a_ # p_). c = (0::'a) \<Longrightarrow> poly (a_ # p_) = poly []
[PROOF STEP]
apply (drule poly_zero_lemma')
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. a_ = (0::'a) \<and> poly p_ = poly [] \<Longrightarrow> \<forall>c\<in>set (a_ # p_). c = (0::'a)
 2. \<forall>c\<in>set (a_ # p_). c = (0::'a) \<Longrightarrow> poly (a_ # p_) = poly []
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
(poly p_ = poly []) = (\<forall>c\<in>set p_. c = (0::'a))

goal (2 subgoals):
 1. a_ = (0::'a) \<and> poly p_ = poly [] \<Longrightarrow> \<forall>c\<in>set (a_ # p_). c = (0::'a)
 2. \<forall>c\<in>set (a_ # p_). c = (0::'a) \<Longrightarrow> poly (a_ # p_) = poly []
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(poly (a_ # p_) = poly []) = (\<forall>c\<in>set (a_ # p_). c = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma aux1_bitAND_digit_mult:
  fixes a b c :: nat
  shows "k > 0 \<and> a mod 2 = 0 \<and> b \<le> 1 \<Longrightarrow> (a + b) div 2^k = a div 2^k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < k \<and> a mod 2 = 0 \<and> b \<le> 1 \<Longrightarrow> (a + b) div 2 ^ k = a div 2 ^ k
[PROOF STEP]
by (induction k, auto)
     (metis One_nat_def add_cancel_left_right div_mult2_eq even_succ_div_two le_0_eq le_Suc_eq)


[STATEMENT]
lemma column_set_Gram_Schmidt_upt_k:
  fixes A::"'a::{real_inner}^'cols::{mod_type}^'rows"
  assumes k: "Suc k < CARD ('cols)"
  shows "{column i (Gram_Schmidt_upt_k A (Suc k)) |i. to_nat i\<le>(Suc k)} =
  {column i (Gram_Schmidt_upt_k A k) |i. to_nat i\<le>k} \<union> {column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k)
  - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. to_nat i\<le>k}. (x \<bullet> (column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k)) / (x \<bullet> x)) *\<^sub>R x)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
have set_rw: "{\<chi> ia. Gram_Schmidt_upt_k A k $ ia $ i |i.
    i < from_nat (Suc k)} = {\<chi> ia. Gram_Schmidt_upt_k A k $ ia $ i |i. to_nat i \<le> k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < mod_type_class.from_nat (Suc k)} = {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}
[PROOF STEP]
proof (auto, vector, metis less_Suc_eq_le to_nat_le)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. (\<lambda>ia. Gram_Schmidt_upt_k A k $ ia $ i) = (\<lambda>iaa. Gram_Schmidt_upt_k A k $ iaa $ ia) \<and> ia < mod_type_class.from_nat (Suc k)
[PROOF STEP]
fix i::'cols
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. (\<lambda>ia. Gram_Schmidt_upt_k A k $ ia $ i) = (\<lambda>iaa. Gram_Schmidt_upt_k A k $ iaa $ ia) \<and> ia < mod_type_class.from_nat (Suc k)
[PROOF STEP]
assume "to_nat i \<le> k"
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> k

goal (1 subgoal):
 1. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. (\<lambda>ia. Gram_Schmidt_upt_k A k $ ia $ i) = (\<lambda>iaa. Gram_Schmidt_upt_k A k $ iaa $ ia) \<and> ia < mod_type_class.from_nat (Suc k)
[PROOF STEP]
hence "to_nat i < Suc k"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i \<le> k

goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i < Suc k

goal (1 subgoal):
 1. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. (\<lambda>ia. Gram_Schmidt_upt_k A k $ ia $ i) = (\<lambda>iaa. Gram_Schmidt_upt_k A k $ iaa $ ia) \<and> ia < mod_type_class.from_nat (Suc k)
[PROOF STEP]
hence i_less_suc: "i < from_nat (Suc k)"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc k

goal (1 subgoal):
 1. i < mod_type_class.from_nat (Suc k)
[PROOF STEP]
using from_nat_le[OF _ k]
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc k
mod_type_class.to_nat ?i < Suc k \<Longrightarrow> ?i < mod_type_class.from_nat (Suc k)

goal (1 subgoal):
 1. i < mod_type_class.from_nat (Suc k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < mod_type_class.from_nat (Suc k)

goal (1 subgoal):
 1. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. (\<lambda>ia. Gram_Schmidt_upt_k A k $ ia $ i) = (\<lambda>iaa. Gram_Schmidt_upt_k A k $ iaa $ ia) \<and> ia < mod_type_class.from_nat (Suc k)
[PROOF STEP]
show "\<exists>l. (\<lambda>j. Gram_Schmidt_upt_k A k $ j $ i) = (\<lambda>j'. Gram_Schmidt_upt_k A k $ j' $ l) \<and>  l < mod_type_class.from_nat (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>l. (\<lambda>j. Gram_Schmidt_upt_k A k $ j $ i) = (\<lambda>j'. Gram_Schmidt_upt_k A k $ j' $ l) \<and> l < mod_type_class.from_nat (Suc k)
[PROOF STEP]
by (rule exI[of _ i], simp add: i_less_suc)
[PROOF STATE]
proof (state)
this:
\<exists>l. (\<lambda>j. Gram_Schmidt_upt_k A k $ j $ i) = (\<lambda>j'. Gram_Schmidt_upt_k A k $ j' $ l) \<and> l < mod_type_class.from_nat (Suc k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < mod_type_class.from_nat (Suc k)} = {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
have rw: "[0..<Suc (Suc k)] = [0..<Suc k] @ [(Suc k)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<Suc (Suc k)] = [0..<Suc k] @ [Suc k]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[0..<Suc (Suc k)] = [0..<Suc k] @ [Suc k]

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
have "{column i (Gram_Schmidt_upt_k A (Suc k)) |i. to_nat i\<le>(Suc k)}
    = {column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. to_nat i \<le> Suc k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}
[PROOF STEP]
unfolding Gram_Schmidt_upt_k_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (foldl Gram_Schmidt_column_k A [0..<Suc (Suc k)]) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}
[PROOF STEP]
unfolding rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (foldl Gram_Schmidt_column_k A ([0..<Suc k] @ [Suc k])) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}
[PROOF STEP]
unfolding foldl_append
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (foldl Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) [Suc k]) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}
[PROOF STEP]
unfolding foldl.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (foldl Gram_Schmidt_column_k A [0..<Suc k]) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
{column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k}

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
have "... = {column i (Gram_Schmidt_upt_k A k) |i. to_nat i\<le>k} \<union> {column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k)
    - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. to_nat i\<le>k}. (x \<bullet> (column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k)) / (x \<bullet> x)) *\<^sub>R x)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
proof (auto)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
 2. \<exists>i. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat i \<le> Suc k
 3. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_upt_k A k) = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat ia \<le> Suc k
[PROOF STEP]
fix i::'cols
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
 2. \<exists>i. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat i \<le> Suc k
 3. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_upt_k A k) = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat ia \<le> Suc k
[PROOF STEP]
assume ik: "to_nat i \<le> k"
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> k

goal (3 subgoals):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
 2. \<exists>i. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat i \<le> Suc k
 3. \<And>i. mod_type_class.to_nat i \<le> k \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_upt_k A k) = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat ia \<le> Suc k
[PROOF STEP]
show "\<exists>ia. column i (Gram_Schmidt_upt_k A k)
      = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> to_nat ia \<le> Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>ia. column i (Gram_Schmidt_upt_k A k) = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat ia \<le> Suc k
[PROOF STEP]
proof (rule exI[of _ i], rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
 2. mod_type_class.to_nat i \<le> Suc k
[PROOF STEP]
have i_less_suc: "to_nat i < Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc k
[PROOF STEP]
using ik
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i \<le> k

goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i < Suc k

goal (2 subgoals):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
 2. mod_type_class.to_nat i \<le> Suc k
[PROOF STEP]
thus "to_nat i \<le> Suc k"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc k

goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> Suc k

goal (1 subgoal):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
show  "column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
using column_Gram_Schmidt_upt_k_preserves[OF i_less_suc k, of A]
[PROOF STATE]
proof (prove)
using this:
column i (Gram_Schmidt_upt_k A (Suc k)) = column i (Gram_Schmidt_upt_k A k)

goal (1 subgoal):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
unfolding Gram_Schmidt_upt_k_suc
[PROOF STATE]
proof (prove)
using this:
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column i (Gram_Schmidt_upt_k A k)

goal (1 subgoal):
 1. column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
column i (Gram_Schmidt_upt_k A k) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>ia. column i (Gram_Schmidt_upt_k A k) = column ia (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat ia \<le> Suc k

goal (2 subgoals):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
 2. \<exists>i. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat i \<le> Suc k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
 2. \<exists>i. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat i \<le> Suc k
[PROOF STEP]
show "\<exists>a. column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) -
      (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i.
      to_nat i \<le> k}. (x \<bullet> column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) =
      column a (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and>
      to_nat a \<le> Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column a (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat a \<le> Suc k
[PROOF STEP]
proof (rule exI[of _ "from_nat (Suc k)::'cols"], rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
 2. mod_type_class.to_nat (mod_type_class.from_nat (Suc k)) \<le> Suc k
[PROOF STEP]
show "to_nat (from_nat (Suc k)::'cols) \<le> Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat (mod_type_class.from_nat (Suc k)) \<le> Suc k
[PROOF STEP]
unfolding to_nat_from_nat_id[OF k]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc k \<le> Suc k
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (mod_type_class.from_nat (Suc k)) \<le> Suc k

goal (1 subgoal):
 1. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
show "column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) -
        (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i.
        to_nat i \<le> k}. (x \<bullet> column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) =
        column (from_nat (Suc k)) (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
[PROOF STEP]
unfolding Gram_Schmidt_column_k_def column_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. (\<chi>a b. (if b = mod_type_class.from_nat (Suc k) then (\<chi>i. Gram_Schmidt_upt_k A k $ i $ b) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ b) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < b} else \<chi>i. Gram_Schmidt_upt_k A k $ i $ b) $ a) $ i $ mod_type_class.from_nat (Suc k))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < mod_type_class.from_nat (Suc k)} $ i)
[PROOF STEP]
unfolding set_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i)
[PROOF STEP]
unfolding vector_scaleR_component[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i)
[PROOF STEP]
unfolding sum_component[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i)
[PROOF STEP]
unfolding proj_onto_def proj_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - (\<Sum>u\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) $ i)
[PROOF STEP]
unfolding proj_onto_sum_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> x / (x \<bullet> x)) *\<^sub>R x) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - (\<Sum>u\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) $ i)
[PROOF STEP]
by vector
[PROOF STATE]
proof (state)
this:
column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>a. column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x) = column a (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<and> mod_type_class.to_nat a \<le> Suc k

goal (1 subgoal):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
assume col_not_eq: "column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq>
      column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) -
      (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i.
      to_nat i \<le> k}. (x \<bullet> column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)"
      and i: "to_nat i \<le> Suc k"
[PROOF STATE]
proof (state)
this:
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)
mod_type_class.to_nat i \<le> Suc k

goal (1 subgoal):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
have i_not_suc_k: "i \<noteq> from_nat (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<noteq> mod_type_class.from_nat (Suc k)
[PROOF STEP]
proof (rule ccontr, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = mod_type_class.from_nat (Suc k) \<Longrightarrow> False
[PROOF STEP]
assume i2: "i = from_nat (Suc k)"
[PROOF STATE]
proof (state)
this:
i = mod_type_class.from_nat (Suc k)

goal (1 subgoal):
 1. i = mod_type_class.from_nat (Suc k) \<Longrightarrow> False
[PROOF STEP]
have "column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) =
        column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) -
        (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i.
        to_nat i \<le> k}. (x \<bullet> column (from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding i2  Gram_Schmidt_column_k_def column_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. (\<chi>a b. (if b = mod_type_class.from_nat (Suc k) then (\<chi>i. Gram_Schmidt_upt_k A k $ i $ b) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ b) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < b} else \<chi>i. Gram_Schmidt_upt_k A k $ i $ b) $ a) $ i $ mod_type_class.from_nat (Suc k)) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. i < mod_type_class.from_nat (Suc k)} $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding set_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding vector_scaleR_component[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding sum_component[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - proj_onto (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) {\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k} $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding proj_onto_def proj_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - (\<Sum>u\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding proj_onto_sum_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k) - (\<Sum>u\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) $ i) = (\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) - (\<Sum>x\<in>{\<chi>ia. Gram_Schmidt_upt_k A k $ ia $ i |i. mod_type_class.to_nat i \<le> k}. ((\<chi>i. Gram_Schmidt_upt_k A k $ i $ mod_type_class.from_nat (Suc k)) \<bullet> x / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
by vector
[PROOF STATE]
proof (state)
this:
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)

goal (1 subgoal):
 1. i = mod_type_class.from_nat (Suc k) \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)

goal (1 subgoal):
 1. False
[PROOF STEP]
using col_not_eq
[PROOF STATE]
proof (prove)
using this:
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)
column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i \<noteq> mod_type_class.from_nat (Suc k)

goal (1 subgoal):
 1. \<And>i. \<lbrakk>column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) \<noteq> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x); mod_type_class.to_nat i \<le> Suc k\<rbrakk> \<Longrightarrow> \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
show "\<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k))
      = column ia (Gram_Schmidt_upt_k A k) \<and> to_nat ia \<le> k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k
[PROOF STEP]
proof (rule exI[of _ i], rule conjI, unfold Gram_Schmidt_upt_k_suc[symmetric], rule column_Gram_Schmidt_upt_k_preserves)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. mod_type_class.to_nat i < Suc k
 2. Suc k < CARD('cols)
 3. mod_type_class.to_nat i \<le> k
[PROOF STEP]
show "to_nat i < Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc k
[PROOF STEP]
using i i_not_suc_k
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i \<le> Suc k
i \<noteq> mod_type_class.from_nat (Suc k)

goal (1 subgoal):
 1. mod_type_class.to_nat i < Suc k
[PROOF STEP]
by (metis le_imp_less_or_eq from_nat_to_nat_id)
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i < Suc k

goal (2 subgoals):
 1. Suc k < CARD('cols)
 2. mod_type_class.to_nat i \<le> k
[PROOF STEP]
thus "to_nat i \<le> k"
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc k

goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> k
[PROOF STEP]
using less_Suc_eq_le
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat i < Suc k
(?m < Suc ?n) = (?m \<le> ?n)

goal (1 subgoal):
 1. mod_type_class.to_nat i \<le> k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat i \<le> k

goal (1 subgoal):
 1. Suc k < CARD('cols)
[PROOF STEP]
show "Suc k < CARD('cols)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc k < CARD('cols)
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
Suc k < CARD('cols)

goal (1 subgoal):
 1. Suc k < CARD('cols)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Suc k < CARD('cols)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>ia. column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) = column ia (Gram_Schmidt_upt_k A k) \<and> mod_type_class.to_nat ia \<le> k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{column i (Gram_Schmidt_column_k (Gram_Schmidt_upt_k A k) (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}

goal (1 subgoal):
 1. {column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{column i (Gram_Schmidt_upt_k A (Suc k)) |i. mod_type_class.to_nat i \<le> Suc k} = {column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k} \<union> {column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) - (\<Sum>x\<in>{column i (Gram_Schmidt_upt_k A k) |i. mod_type_class.to_nat i \<le> k}. (x \<bullet> column (mod_type_class.from_nat (Suc k)) (Gram_Schmidt_upt_k A k) / (x \<bullet> x)) *\<^sub>R x)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_to_list_set:
  assumes "finite S"
  shows "set (set_to_list S) = S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (sorted_list_of_set S) = S
[PROOF STEP]
by (simp add: assms)


[STATEMENT]
lemma restrict_inv_into_Bij: "f \<in> Bij S \<Longrightarrow> (\<lambda>x \<in> S. (inv_into S f) x) \<in> Bij S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> Bij S \<Longrightarrow> restrict (inv_into S f) S \<in> Bij S
[PROOF STEP]
by (simp add: Bij_def bij_betw_inv_into)


[STATEMENT]
lemma ceiling_add_numeral [simp]: "\<lceil>x + numeral v\<rceil> = \<lceil>x\<rceil> + numeral v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>x + numeral v\<rceil> = \<lceil>x\<rceil> + numeral v
[PROOF STEP]
using ceiling_add_of_int [of x "numeral v"]
[PROOF STATE]
proof (prove)
using this:
\<lceil>x + of_int (numeral v)\<rceil> = \<lceil>x\<rceil> + numeral v

goal (1 subgoal):
 1. \<lceil>x + numeral v\<rceil> = \<lceil>x\<rceil> + numeral v
[PROOF STEP]
by simp


[STATEMENT]
lemma ls_delete_length:
  "length (fst (ls_delete k l)) = (
    if (k \<in> set (map fst l)) then
      (length l - 1)
    else
      length l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (fst (ls_delete k l)) = (if k \<in> set (map fst l) then length l - 1 else length l)
[PROOF STEP]
proof (induct l rule: ls_delete.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>k. length (fst (ls_delete k [])) = (if k \<in> set (map fst []) then length [] - 1 else length [])
 2. \<And>k l w ls. (k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)) \<Longrightarrow> length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>k. length (fst (ls_delete k [])) = (if k \<in> set (map fst []) then length [] - 1 else length [])
 2. \<And>k l w ls. (k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)) \<Longrightarrow> length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (fst (ls_delete k_ [])) = (if k_ \<in> set (map fst []) then length [] - 1 else length [])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (fst (ls_delete k_ [])) = (if k_ \<in> set (map fst []) then length [] - 1 else length [])

goal (1 subgoal):
 1. \<And>k l w ls. (k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)) \<Longrightarrow> length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k l w ls. (k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)) \<Longrightarrow> length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
case (2 k l w ls)
[PROOF STATE]
proof (state)
this:
k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)

goal (1 subgoal):
 1. \<And>k l w ls. (k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)) \<Longrightarrow> length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
k \<noteq> l \<Longrightarrow> length (fst (ls_delete k ls)) = (if k \<in> set (map fst ls) then length ls - 1 else length ls)

goal (1 subgoal):
 1. length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))
[PROOF STEP]
by (cases ls) (auto simp add: Let_def)
[PROOF STATE]
proof (state)
this:
length (fst (ls_delete k ((l, w) # ls))) = (if k \<in> set (map fst ((l, w) # ls)) then length ((l, w) # ls) - 1 else length ((l, w) # ls))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sums_append2:
  "sums (xs@ys) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sums (xs @ ys) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums ys)
[PROOF STEP]
proof (induct ys rule: rev_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sums (xs @ []) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums [])
 2. \<And>x xsa. sums (xs @ xsa) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums xsa) \<Longrightarrow> sums (xs @ xsa @ [x]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (xsa @ [x]))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. sums (xs @ []) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums [])
 2. \<And>x xsa. sums (xs @ xsa) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums xsa) \<Longrightarrow> sums (xs @ xsa @ [x]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (xsa @ [x]))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sums (xs @ []) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums [])
[PROOF STEP]
by (cases xs rule: rev_cases) (auto simp add: sums_snoc)
[PROOF STATE]
proof (state)
this:
sums (xs @ []) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums [])

goal (1 subgoal):
 1. \<And>x xsa. sums (xs @ xsa) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums xsa) \<Longrightarrow> sums (xs @ xsa @ [x]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (xsa @ [x]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xsa. sums (xs @ xsa) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums xsa) \<Longrightarrow> sums (xs @ xsa @ [x]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (xsa @ [x]))
[PROOF STEP]
case (snoc y ys)
[PROOF STATE]
proof (state)
this:
sums (xs @ ys) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums ys)

goal (1 subgoal):
 1. \<And>x xsa. sums (xs @ xsa) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums xsa) \<Longrightarrow> sums (xs @ xsa @ [x]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (xsa @ [x]))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
sums (xs @ ys) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums ys)

goal (1 subgoal):
 1. sums (xs @ ys @ [y]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (ys @ [y]))
[PROOF STEP]
using sums_snoc[of "xs@ys"]
[PROOF STATE]
proof (prove)
using this:
sums (xs @ ys) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums ys)
sums ((xs @ ys) @ [?x]) = sums (xs @ ys) @ [sum_list ((xs @ ys) @ [?x])]

goal (1 subgoal):
 1. sums (xs @ ys @ [y]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (ys @ [y]))
[PROOF STEP]
by (simp add: sums_snoc)
[PROOF STATE]
proof (state)
this:
sums (xs @ ys @ [y]) = butlast (sums xs) @ map ((+) (sum_list xs)) (sums (ys @ [y]))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcd_diff_dvd_right1: "a dvd b \<Longrightarrow> gcd a (b - c) = gcd a c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a dvd b \<Longrightarrow> gcd a (b - c) = gcd a c
[PROOF STEP]
using gcd_add_dvd_right1[of a b "-c"]
[PROOF STATE]
proof (prove)
using this:
a dvd b \<Longrightarrow> gcd a (b + - c) = gcd a (- c)

goal (1 subgoal):
 1. a dvd b \<Longrightarrow> gcd a (b - c) = gcd a c
[PROOF STEP]
by simp