[STATEMENT]
lemma matrix_equation_helper_step:
  fixes p:: "real poly"
  fixes qs:: "real poly list"
  fixes I:: "nat list"
  fixes signs:: "rat list list"
  assumes nonzero: "p\<noteq>0"
  assumes distinct_signs: "distinct signs"
  assumes all_info: "set (characterize_consistent_signs_at_roots_copr p qs) \<subseteq> set(signs)"
  assumes welldefined: "list_constr I (length qs)"
  assumes pairwise_rel_prime_1: "\<forall>q. ((List.member qs q) \<longrightarrow> (coprime p q))"
  shows "(vec_of_list (mtx_row signs I) \<bullet> (construct_lhs_vector p qs signs)) =
   rat_of_int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x > 0}) -
   rat_of_int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have "finite (set (map (consistent_sign_vec_copr qs)  (characterize_root_list_p p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
let ?gt = "(set (map (consistent_sign_vec_copr qs)  (characterize_root_list_p p)) \<inter> {s. z I s = 1})"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
let ?lt = "  (set (map (consistent_sign_vec_copr qs)  (characterize_root_list_p p)) \<inter> {s. z I s = -1})"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have eq: "set (map (consistent_sign_vec_copr qs)  (characterize_root_list_p p)) = ?gt \<union> ?lt"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) = set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1} \<union> set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. \<lbrakk>xa \<in> set (characterize_root_list_p p); z I (consistent_sign_vec_copr qs xa) \<noteq> - 1\<rbrakk> \<Longrightarrow> z I (consistent_sign_vec_copr qs xa) = 1
[PROOF STEP]
by (metis characterize_root_list_p_def horiz_vector_helper_neg horiz_vector_helper_pos_ind nonzero nonzero_product pairwise_rel_prime_1 poly_roots_finite sorted_list_of_set(1) welldefined)
[PROOF STATE]
proof (state)
this:
set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) = set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1} \<union> set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
(* First, drop the signs that are irrelevant *)
[PROOF STATE]
proof (state)
this:
set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) = set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1} \<union> set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
from construct_lhs_vector_drop_consistent[OF assms(1-4)]
[PROOF STATE]
proof (chain)
picking this:
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)
[PROOF STEP]
have
    "vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs =
  vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet>
  construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)"
[PROOF STATE]
proof (prove)
using this:
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
(* Now we split the sum *)
[PROOF STATE]
proof (state)
this:
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
from lhs_dot_rewrite[OF assms(1)]
[PROOF STATE]
proof (chain)
picking this:
vec_of_list (mtx_row ?signs ?I) \<bullet> construct_lhs_vector p ?qs ?signs = (\<Sum>s\<leftarrow>?signs. z ?I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr ?qs x = s})))
[PROOF STEP]
moreover
[PROOF STATE]
proof (chain)
picking this:
vec_of_list (mtx_row ?signs ?I) \<bullet> construct_lhs_vector p ?qs ?signs = (\<Sum>s\<leftarrow>?signs. z ?I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr ?qs x = s})))
[PROOF STEP]
have "... =
  (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs.
    z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))"
[PROOF STATE]
proof (prove)
using this:
vec_of_list (mtx_row ?signs ?I) \<bullet> construct_lhs_vector p ?qs ?signs = (\<Sum>s\<leftarrow>?signs. z ?I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr ?qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have "... =
  (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs)  (characterize_root_list_p p)).
    z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
unfolding characterize_consistent_signs_at_roots_copr_def sum_code[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
vec_of_list (mtx_row ?signs ?I) \<bullet> construct_lhs_vector p ?qs ?signs = (\<Sum>s\<leftarrow>?signs. z ?I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr ?qs x = s})))
vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
(\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
have "... =
  (\<Sum>s\<in>?gt. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) +
  (\<Sum>s\<in>?lt. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))"
[PROOF STATE]
proof (prove)
using this:
vec_of_list (mtx_row ?signs ?I) \<bullet> construct_lhs_vector p ?qs ?signs = (\<Sum>s\<leftarrow>?signs. z ?I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr ?qs x = s})))
vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
(\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
apply (subst eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>signs I qs. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = (\<Sum>s\<leftarrow>signs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))\<rbrakk> \<Longrightarrow> (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1} \<union> set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
[PROOF STEP]
apply (rule sum.union_disjoint)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>\<And>signs I qs. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = (\<Sum>s\<leftarrow>signs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))\<rbrakk> \<Longrightarrow> finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1})
 2. \<lbrakk>\<And>signs I qs. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = (\<Sum>s\<leftarrow>signs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))\<rbrakk> \<Longrightarrow> finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1})
 3. \<lbrakk>\<And>signs I qs. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = (\<Sum>s\<leftarrow>signs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))); (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))\<rbrakk> \<Longrightarrow> set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1} \<inter> (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}) = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
(* Now recharacterize lt, gt*)
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have setroots: "set (characterize_root_list_p p) = {x. poly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (characterize_root_list_p p) = {x. poly p x = 0}
[PROOF STEP]
unfolding characterize_root_list_p_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (sorted_list_of_set {x. poly p x = 0}) = {x. poly p x = 0}
[PROOF STEP]
using poly_roots_finite nonzero rsquarefree_def set_sorted_list_of_set
[PROOF STATE]
proof (prove)
using this:
?p \<noteq> 0 \<Longrightarrow> finite {x. poly ?p x = (0::?'a)}
p \<noteq> 0
rsquarefree ?p = (?p \<noteq> 0 \<and> (\<forall>a. Polynomial.order a ?p = 0 \<or> Polynomial.order a ?p = 1))
finite ?A \<Longrightarrow> set (sorted_list_of_set ?A) = ?A

goal (1 subgoal):
 1. set (sorted_list_of_set {x. poly p x = 0}) = {x. poly p x = 0}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set (characterize_root_list_p p) = {x. poly p x = 0}

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have *: "\<And>s. {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s} =
        {x \<in>{x. poly p x = 0}. consistent_sign_vec_copr qs x = s}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>s. {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s} = {x \<in> {x. poly p x = 0}. consistent_sign_vec_copr qs x = s}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = ?s} = {x \<in> {x. poly p x = 0}. consistent_sign_vec_copr qs x = ?s}

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have lem_e1: "\<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow>
       card
        {s \<in> consistent_sign_vec_copr  qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}.
         consistent_sign_vec_copr qs x = s} =
       (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
assume rt: "x \<in> {x. poly p x = 0}"
[PROOF STATE]
proof (state)
this:
x \<in> {x. poly p x = 0}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {x. poly p x = 0}
[PROOF STEP]
have 1: "{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} =
      {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s}"
[PROOF STATE]
proof (prove)
using this:
x \<in> {x. poly p x = 0}

goal (1 subgoal):
 1. {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
from horiz_vector_helper_pos[OF assms(1) assms(5) rt]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (0 < poly (prod_list (retrieve_polys qs ?I)) x) = (z ?I ?sign = 1)
[PROOF STEP]
have 2: "... = {s. (0 < poly (prod_list (retrieve_polys qs I)) x)  \<and> consistent_sign_vec_copr qs x = s}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (0 < poly (prod_list (retrieve_polys qs ?I)) x) = (z ?I ?sign = 1)

goal (1 subgoal):
 1. {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s} = {s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
using welldefined
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (0 < poly (prod_list (retrieve_polys qs ?I)) x) = (z ?I ?sign = 1)
list_constr I (length qs)

goal (1 subgoal):
 1. {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s} = {s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s} = {s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
have 3: "... = (if (0 < poly (prod_list (retrieve_polys qs I)) x)  then {consistent_sign_vec_copr qs x} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then {consistent_sign_vec_copr qs x} else {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
thus "card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} =
         (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0) "
[PROOF STATE]
proof (prove)
using this:
{s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
using 1 2 3
[PROOF STATE]
proof (prove)
using this:
{s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then {consistent_sign_vec_copr qs x} else {})
{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s}
{s. z I s = 1 \<and> consistent_sign_vec_copr qs x = s} = {s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s}
{s. 0 < poly (prod_list (retrieve_polys qs I)) x \<and> consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs ?x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) ?x then 1 else 0)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have e1: "(\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}.
       card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) =
     (sum (\<lambda>x. if (poly (prod_list (retrieve_polys qs I)) x) > 0 then 1 else 0) {x. poly p x = 0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. card {x \<in> {x. poly p x = 0}. consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
apply (rule sum_multicount_gen)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite (consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1})
 2. finite {x. poly p x = 0}
 3. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
using \<open>finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))\<close> setroots
[PROOF STATE]
proof (prove)
using this:
finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))
set (characterize_root_list_p p) = {x. poly p x = 0}

goal (3 subgoals):
 1. finite (consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1})
 2. finite {x. poly p x = 0}
 3. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {x. poly p x = 0}
 2. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
apply (metis List.finite_set setroots)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
using lem_e1
[PROOF STATE]
proof (prove)
using this:
?x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs ?x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) ?x then 1 else 0)

goal (1 subgoal):
 1. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. consistent_sign_vec_copr qs x = s} = (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have gtchr: "(\<Sum>s\<in>?gt. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) =
    rat_of_int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}))
[PROOF STEP]
apply (auto simp add: setroots)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. rat_of_nat (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) = rat_of_nat (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})
[PROOF STEP]
apply (subst of_nat_sum[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_of_nat (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = rat_of_nat (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})
[PROOF STEP]
apply (subst of_nat_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}
[PROOF STEP]
apply (subst e1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | poly p x = 0. if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0) = card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}
[PROOF STEP]
apply (subst card_eq_sum)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | poly p x = 0. if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0) = (\<Sum>x | poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x. 1)
[PROOF STEP]
apply (rule sum.mono_neutral_cong_right)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. finite {x. poly p x = 0}
 2. {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x} \<subseteq> {x. poly p x = 0}
 3. \<forall>i\<in>{x. poly p x = 0} - {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}. (if 0 < poly (prod_list (retrieve_polys qs I)) i then 1 else 0) = 0
 4. \<And>x. x \<in> {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x} \<Longrightarrow> (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0) = 1
[PROOF STEP]
apply (metis List.finite_set setroots)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x} \<subseteq> {x. poly p x = 0}
 2. \<forall>i\<in>{x. poly p x = 0} - {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}. (if 0 < poly (prod_list (retrieve_polys qs I)) i then 1 else 0) = 0
 3. \<And>x. x \<in> {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x} \<Longrightarrow> (if 0 < poly (prod_list (retrieve_polys qs I)) x then 1 else 0) = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have lem_e2: "\<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow>
       card
        {s \<in> consistent_sign_vec_copr  qs ` {x. poly p x = 0} \<inter> {s. z I s = -1}.
         consistent_sign_vec_copr qs x = s} =
       (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
assume rt: "x \<in> {x. poly p x = 0}"
[PROOF STATE]
proof (state)
this:
x \<in> {x. poly p x = 0}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {x. poly p x = 0}
[PROOF STEP]
have 1: "{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = -1}. consistent_sign_vec_copr qs x = s} =
      {s. z I s = -1 \<and> consistent_sign_vec_copr qs x = s}"
[PROOF STATE]
proof (prove)
using this:
x \<in> {x. poly p x = 0}

goal (1 subgoal):
 1. {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
from horiz_vector_helper_neg[OF assms(1) assms(5) rt]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (poly (prod_list (retrieve_polys qs ?I)) x < 0) = (z ?I ?sign = - 1)
[PROOF STEP]
have 2: "... = {s. (0 > poly (prod_list (retrieve_polys qs I)) x)  \<and> consistent_sign_vec_copr qs x = s}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (poly (prod_list (retrieve_polys qs ?I)) x < 0) = (z ?I ?sign = - 1)

goal (1 subgoal):
 1. {s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s} = {s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
using welldefined
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?sign = consistent_sign_vec_copr qs x; list_constr ?I (length qs)\<rbrakk> \<Longrightarrow> (poly (prod_list (retrieve_polys qs ?I)) x < 0) = (z ?I ?sign = - 1)
list_constr I (length qs)

goal (1 subgoal):
 1. {s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s} = {s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s} = {s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s}

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
have 3: "... = (if (0 > poly (prod_list (retrieve_polys qs I)) x)  then {consistent_sign_vec_copr qs x} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then {consistent_sign_vec_copr qs x} else {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. \<And>x. x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
thus "card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = -1}. consistent_sign_vec_copr qs x = s} =
       (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
{s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
using 1 2 3
[PROOF STATE]
proof (prove)
using this:
{s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then {consistent_sign_vec_copr qs x} else {})
{s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = {s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s}
{s. z I s = - 1 \<and> consistent_sign_vec_copr qs x = s} = {s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s}
{s. poly (prod_list (retrieve_polys qs I)) x < 0 \<and> consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then {consistent_sign_vec_copr qs x} else {})

goal (1 subgoal):
 1. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs ?x = s} = (if poly (prod_list (retrieve_polys qs I)) ?x < 0 then 1 else 0)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have e2: " (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}.
       card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) =
     (sum (\<lambda>x. if (poly (prod_list (retrieve_polys qs I)) x) < 0 then 1 else 0) {x. poly p x = 0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. card {x \<in> {x. poly p x = 0}. consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
apply (rule sum_multicount_gen)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite (consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1})
 2. finite {x. poly p x = 0}
 3. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
using \<open>finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))\<close> setroots
[PROOF STATE]
proof (prove)
using this:
finite (set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)))
set (characterize_root_list_p p) = {x. poly p x = 0}

goal (3 subgoals):
 1. finite (consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1})
 2. finite {x. poly p x = 0}
 3. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {x. poly p x = 0}
 2. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
apply (metis List.finite_set setroots)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
using lem_e2
[PROOF STATE]
proof (prove)
using this:
?x \<in> {x. poly p x = 0} \<Longrightarrow> card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs ?x = s} = (if poly (prod_list (retrieve_polys qs I)) ?x < 0 then 1 else 0)

goal (1 subgoal):
 1. \<forall>x\<in>{x. poly p x = 0}. card {s \<in> consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. consistent_sign_vec_copr qs x = s} = (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = (\<Sum>x | poly p x = 0. if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
have ltchr: "(\<Sum>s\<in>?lt. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) =
    - rat_of_int (card {x. poly p x = 0 \<and> 0 > poly (prod_list (retrieve_polys qs I)) x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
apply (auto simp add: setroots sum_negf)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. rat_of_nat (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) = rat_of_nat (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0})
[PROOF STEP]
apply (subst of_nat_sum[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_of_nat (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = rat_of_nat (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0})
[PROOF STEP]
apply (subst of_nat_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>s\<in>consistent_sign_vec_copr qs ` {x. poly p x = 0} \<inter> {s. z I s = - 1}. card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}) = card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}
[PROOF STEP]
apply (subst e2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | poly p x = 0. if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0) = card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}
[PROOF STEP]
apply (subst card_eq_sum)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | poly p x = 0. if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0) = (\<Sum>x | poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0. 1)
[PROOF STEP]
apply (rule sum.mono_neutral_cong_right)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. finite {x. poly p x = 0}
 2. {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0} \<subseteq> {x. poly p x = 0}
 3. \<forall>i\<in>{x. poly p x = 0} - {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}. (if poly (prod_list (retrieve_polys qs I)) i < 0 then 1 else 0) = 0
 4. \<And>x. x \<in> {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0} \<Longrightarrow> (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0) = 1
[PROOF STEP]
apply (metis List.finite_set setroots)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0} \<subseteq> {x. poly p x = 0}
 2. \<forall>i\<in>{x. poly p x = 0} - {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}. (if poly (prod_list (retrieve_polys qs I)) i < 0 then 1 else 0) = 0
 3. \<And>x. x \<in> {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0} \<Longrightarrow> (if poly (prod_list (retrieve_polys qs I)) x < 0 then 1 else 0) = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
using gtchr ltchr
[PROOF STATE]
proof (prove)
using this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}))
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
using \<open>(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))\<close> \<open>(\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))\<close> \<open>vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))\<close> \<open>vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)\<close>
[PROOF STATE]
proof (prove)
using this:
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x}))
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
(\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) + (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)) \<inter> {s. z I s = - 1}. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
(\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s}))) = (\<Sum>s\<in>set (map (consistent_sign_vec_copr qs) (characterize_root_list_p p)). z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs) = (\<Sum>s\<leftarrow>characterize_consistent_signs_at_roots_copr p qs. z I s * rat_of_int (int (card {x. poly p x = 0 \<and> consistent_sign_vec_copr qs x = s})))
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = vec_of_list (mtx_row (characterize_consistent_signs_at_roots_copr p qs) I) \<bullet> construct_lhs_vector p qs (characterize_consistent_signs_at_roots_copr p qs)

goal (1 subgoal):
 1. vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
vec_of_list (mtx_row signs I) \<bullet> construct_lhs_vector p qs signs = rat_of_int (int (card {x. poly p x = 0 \<and> 0 < poly (prod_list (retrieve_polys qs I)) x})) - rat_of_int (int (card {x. poly p x = 0 \<and> poly (prod_list (retrieve_polys qs I)) x < 0}))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma comp_exp_nat:
  fixes k::nat
  assumes "i \<in> I"
  shows "(x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k
[PROOF STEP]
proof (induction k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (x [^]\<^bsub>DirProds G I\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0
 2. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (x [^]\<^bsub>DirProds G I\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0
 2. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i \<in> I

goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0
[PROOF STEP]
unfolding DirProds_def
[PROOF STATE]
proof (prove)
using this:
i \<in> I

goal (1 subgoal):
 1. (x [^]\<^bsub>\<lparr>carrier = Pi\<^sub>E I (carrier \<circ> G), monoid.mult = \<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i, one = \<lambda>i\<in>I. \<one>\<^bsub>G i\<^esub>\<rparr>\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> 0) i = x i [^]\<^bsub>G i\<^esub> 0

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
case i: (Suc k)
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
have "(x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = (x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = (x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i
[PROOF STEP]
by(rule comp_mult[OF assms])
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = (x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = (x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
from i
[PROOF STATE]
proof (chain)
picking this:
(x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k
[PROOF STEP]
have "\<dots> = x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i"
[PROOF STATE]
proof (prove)
using this:
(x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k

goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i = x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i = x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> k) i \<otimes>\<^bsub>G i\<^esub> x i = x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
have "\<dots> = x i [^]\<^bsub>G i\<^esub> Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x i [^]\<^bsub>G i\<^esub> k \<otimes>\<^bsub>G i\<^esub> x i = x i [^]\<^bsub>G i\<^esub> Suc k

goal (1 subgoal):
 1. \<And>k. (x [^]\<^bsub>DirProds G I\<^esub> k) i = x i [^]\<^bsub>G i\<^esub> k \<Longrightarrow> (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(x [^]\<^bsub>DirProds G I\<^esub> k \<otimes>\<^bsub>DirProds G I\<^esub> x) i = x i [^]\<^bsub>G i\<^esub> Suc k

goal (1 subgoal):
 1. (x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x [^]\<^bsub>DirProds G I\<^esub> Suc k) i = x i [^]\<^bsub>G i\<^esub> Suc k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult2_ns_eq_mult2_ns_alt:
  assumes "ns O s \<subseteq> s" "refl ns" "trans s"
  shows "mult2_alt_ns ns s = mult2_ns ns s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mult2_alt_ns ns s = mult2_ns ns s
[PROOF STEP]
using mult2_ns_one_step[OF assms]
[PROOF STATE]
proof (prove)
using this:
((?X, ?Y) \<in> mult2_ns ns s) = (\<exists>X1 X2 Y1 Y2. ?X = X1 + X2 \<and> ?Y = Y1 + Y2 \<and> (X1, Y1) \<in> multpw ns \<and> (\<forall>x. x \<in># X2 \<longrightarrow> (\<exists>y. y \<in># Y2 \<and> (x, y) \<in> s)))

goal (1 subgoal):
 1. mult2_alt_ns ns s = mult2_ns ns s
[PROOF STEP]
unfolding mult2_alt_ns_def
[PROOF STATE]
proof (prove)
using this:
((?X, ?Y) \<in> mult2_ns ns s) = (\<exists>X1 X2 Y1 Y2. ?X = X1 + X2 \<and> ?Y = Y1 + Y2 \<and> (X1, Y1) \<in> multpw ns \<and> (\<forall>x. x \<in># X2 \<longrightarrow> (\<exists>y. y \<in># Y2 \<and> (x, y) \<in> s)))

goal (1 subgoal):
 1. {(X, Y). \<exists>X1 X2 Y1 Y2. X = X1 + X2 \<and> Y = Y1 + Y2 \<and> (X1, Y1) \<in> multpw ns \<and> (\<forall>x. x \<in># X2 \<longrightarrow> (\<exists>y. y \<in># Y2 \<and> (x, y) \<in> s))} = mult2_ns ns s
[PROOF STEP]
by blast


[STATEMENT]
lemma find_seg_correct:
    assumes A: "j<length S"
    shows "S!j \<in> seg (find_seg j)" and "find_seg j < length B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S ! j \<in> seg (find_seg j) &&& find_seg j < length B
[PROOF STEP]
using find_seg_bounds[OF A]
[PROOF STATE]
proof (prove)
using this:
seg_start (find_seg j) \<le> j
j < seg_end (find_seg j)
find_seg j < length B

goal (1 subgoal):
 1. S ! j \<in> seg (find_seg j) &&& find_seg j < length B
[PROOF STEP]
unfolding seg_def
[PROOF STATE]
proof (prove)
using this:
seg_start (find_seg j) \<le> j
j < seg_end (find_seg j)
find_seg j < length B

goal (1 subgoal):
 1. S ! j \<in> {S ! ja |ja. seg_start (find_seg j) \<le> ja \<and> ja < seg_end (find_seg j)} &&& find_seg j < length B
[PROOF STEP]
by auto


[STATEMENT]
lemma nall_tuples_finite: "finite AD \<Longrightarrow> finite (nall_tuples AD n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite AD \<Longrightarrow> finite (nall_tuples AD n)
[PROOF STEP]
by (auto simp: nall_tuples_def all_tuples_finite)


[STATEMENT]
lemma zero_less_measure_iff: "0 < measure M A \<longleftrightarrow> measure M A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < Sigma_Algebra.measure M A) = (Sigma_Algebra.measure M A \<noteq> 0)
[PROOF STEP]
using measure_nonneg[of M A]
[PROOF STATE]
proof (prove)
using this:
0 \<le> Sigma_Algebra.measure M A

goal (1 subgoal):
 1. (0 < Sigma_Algebra.measure M A) = (Sigma_Algebra.measure M A \<noteq> 0)
[PROOF STEP]
by (auto simp add: le_less)


[STATEMENT]
lemma closed_vimage_fst: "closed S \<Longrightarrow> closed (fst -` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed S \<Longrightarrow> closed (fst -` S)
[PROOF STEP]
unfolding closed_open vimage_Compl [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open (- S) \<Longrightarrow> open (fst -` (- S))
[PROOF STEP]
by (rule open_vimage_fst)


[STATEMENT]
lemma image_subset_vimage_the_inv_into:
  assumes "inj_on f A" "B \<subseteq> A"
  shows   "f ` B \<subseteq> the_inv_into A f -` B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` B \<subseteq> the_inv_into A f -` B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inj_on f A
B \<subseteq> A

goal (1 subgoal):
 1. f ` B \<subseteq> the_inv_into A f -` B
[PROOF STEP]
by (auto simp: the_inv_into_f_f)


[STATEMENT]
lemma isCont_Polygamma [continuous_intros]:
  fixes f :: "_ \<Rightarrow> 'a :: {real_normed_field,euclidean_space}"
  shows "isCont f z \<Longrightarrow> f z \<notin> \<int>\<^sub>\<le>\<^sub>0 \<Longrightarrow> isCont (\<lambda>x. Polygamma n (f x)) z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>isCont f z; f z \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. Polygamma n (f x)) z
[PROOF STEP]
by (rule isCont_o2[OF _  DERIV_isCont[OF has_field_derivative_Polygamma]])


[STATEMENT]
lemma cong_cong_lcm_int: "[x = y] (mod a) \<Longrightarrow> [x = y] (mod b) \<Longrightarrow> [x = y] (mod lcm a b)"
  for x y :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>[x = y] (mod a); [x = y] (mod b)\<rbrakk> \<Longrightarrow> [x = y] (mod lcm a b)
[PROOF STEP]
by (auto simp add: cong_iff_dvd_diff lcm_least)


[STATEMENT]
lemma multi_arith_prog_mono:
  assumes "\<And>i. i < m \<Longrightarrow> c i \<le> c' i"
  shows   "multi_arith_prog m start steps c \<le>
            multi_arith_prog m start steps c'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multi_arith_prog m start steps c \<le> multi_arith_prog m start steps c'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?i < m \<Longrightarrow> c ?i \<le> c' ?i

goal (1 subgoal):
 1. multi_arith_prog m start steps c \<le> multi_arith_prog m start steps c'
[PROOF STEP]
unfolding multi_arith_prog_def
[PROOF STATE]
proof (prove)
using this:
?i < m \<Longrightarrow> c ?i \<le> c' ?i

goal (1 subgoal):
 1. start + int (\<Sum>i<m. c i * steps i) \<le> start + int (\<Sum>i<m. c' i * steps i)
[PROOF STEP]
by (auto intro!: sum_mono intro: mult_right_mono)


[STATEMENT]
lemma vector_Dflow_linear:
assumes "t \<in> existence_ivl0 x0"
shows "vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
note mem_existence_ivl_iv_defined[OF assms, intro, simp]
[PROOF STATE]
proof (state)
this:
0 \<in> UNIV
x0 \<in> X

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
have "((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. vareq x0 x)) (existence_ivl0 x0) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV
[PROOF STEP]
by (auto intro!: derivative_intros var.flow_has_vector_derivative solves_odeI
      simp: blinfun.bilinear_simps varexivl_eq_exivl vareq_def[symmetric])
[PROOF STATE]
proof (state)
this:
((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
have "\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
note is_interval_existence_ivl[of x0]
[PROOF STATE]
proof (state)
this:
is_interval (existence_ivl0 x0)

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV
\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b
is_interval (existence_ivl0 x0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV
\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b
is_interval (existence_ivl0 x0)

goal (1 subgoal):
 1. vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t
[PROOF STEP]
unfolding vareq_def[symmetric] vector_Dflow_def
[PROOF STATE]
proof (prove)
using this:
((\<lambda>c. \<alpha> *\<^sub>R var.flow x0 0 a c + \<beta> *\<^sub>R var.flow x0 0 b c) solves_ode (\<lambda>x. blinfun_apply (vareq x0 x))) (existence_ivl0 x0) UNIV
\<alpha> *\<^sub>R var.flow x0 0 a 0 + \<beta> *\<^sub>R var.flow x0 0 b 0 = \<alpha> *\<^sub>R a + \<beta> *\<^sub>R b
is_interval (existence_ivl0 x0)

goal (1 subgoal):
 1. var.flow x0 0 (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R var.flow x0 0 a t + \<beta> *\<^sub>R var.flow x0 0 b t
[PROOF STEP]
by (rule var.maximal_existence_flow) (auto simp: assms)
[PROOF STATE]
proof (state)
this:
vector_Dflow (\<alpha> *\<^sub>R a + \<beta> *\<^sub>R b) t = \<alpha> *\<^sub>R vector_Dflow a t + \<beta> *\<^sub>R vector_Dflow b t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma unat_of_nat_minus_1:
  "\<lbrakk> n < 2 ^ LENGTH('a); n \<noteq> 0 \<rbrakk> \<Longrightarrow> unat ((of_nat n:: 'a :: len word) - 1) = n - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < 2 ^ LENGTH('a); n \<noteq> 0\<rbrakk> \<Longrightarrow> unat (word_of_nat n - 1) = n - 1
[PROOF STEP]
by (simp add: of_nat_diff unat_eq_of_nat)


[STATEMENT]
lemma orthonormal_optimal_partial_sum:
  assumes "orthonormal_system S w" "\<And>i. (w i) square_integrable S"
          "f square_integrable S" "finite I"
  shows "l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x))
       \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
have "2 * (a i * l2product S f(w i)) \<le> (a i)\<^sup>2 + (l2product S f(w i))\<^sup>2" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (a i * l2product S f (w i)) \<le> (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2
[PROOF STEP]
using sum_squares_bound [of "a i" "l2product S f(w i)"]
[PROOF STATE]
proof (prove)
using this:
2 * a i * l2product S f (w i) \<le> (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2

goal (1 subgoal):
 1. 2 * (a i * l2product S f (w i)) \<le> (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2
[PROOF STEP]
by (force simp: algebra_simps)
[PROOF STATE]
proof (state)
this:
2 * (a ?i * l2product S f (w ?i)) \<le> (a ?i)\<^sup>2 + (l2product S f (w ?i))\<^sup>2

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 * (a ?i * l2product S f (w ?i)) \<le> (a ?i)\<^sup>2 + (l2product S f (w ?i))\<^sup>2
[PROOF STEP]
have *: "2 * (\<Sum>i\<in>I. a i * l2product S f(w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f(w i))\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
2 * (a ?i * l2product S f (w ?i)) \<le> (a ?i)\<^sup>2 + (l2product S f (w ?i))\<^sup>2

goal (1 subgoal):
 1. 2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2)
[PROOF STEP]
by (simp add: sum_distrib_left sum_mono)
[PROOF STATE]
proof (state)
this:
2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2)

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
have S: "S \<in> sets lebesgue"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<in> sets lebesgue
[PROOF STEP]
using assms square_integrable_def
[PROOF STATE]
proof (prove)
using this:
orthonormal_system S w
w ?i square_integrable S
f square_integrable S
finite I
?f square_integrable ?S \<equiv> ?S \<in> sets lebesgue \<and> ?f \<in> borel_measurable (lebesgue_on ?S) \<and> integrable (lebesgue_on ?S) (\<lambda>x. (?f x)\<^sup>2)

goal (1 subgoal):
 1. S \<in> sets lebesgue
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
S \<in> sets lebesgue

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
with assms *
[PROOF STATE]
proof (chain)
picking this:
orthonormal_system S w
w ?i square_integrable S
f square_integrable S
finite I
2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2)
S \<in> sets lebesgue
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
orthonormal_system S w
w ?i square_integrable S
f square_integrable S
finite I
2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2)
S \<in> sets lebesgue

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))
[PROOF STEP]
apply (simp add: l2norm_le square_integrable_sum square_integrable_diff square_integrable_lmult flip: l2norm_pow_2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>orthonormal_system S w; \<And>i. w i square_integrable S; f square_integrable S; finite I; 2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2); S \<in> sets lebesgue\<rbrakk> \<Longrightarrow> (l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)))\<^sup>2 \<le> (l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x)))\<^sup>2
[PROOF STEP]
apply (simp add: orthonormal_coeff_def orthonormal_partial_sum_diff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>orthonormal_system S w; \<And>i. w i square_integrable S; f square_integrable S; finite I; 2 * (\<Sum>i\<in>I. a i * l2product S f (w i)) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2 + (l2product S f (w i))\<^sup>2); S \<in> sets lebesgue\<rbrakk> \<Longrightarrow> (\<Sum>i\<in>I. (l2product S (w i) f)\<^sup>2) - 2 * (\<Sum>i\<in>I. l2product S (w i) f * l2product S (w i) f) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2) - 2 * (\<Sum>i\<in>I. a i * l2product S (w i) f)
[PROOF STEP]
apply (simp add: l2product_sym power2_eq_square sum.distrib)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. orthonormal_coeff S w f i * w i x)) \<le> l2norm S (\<lambda>x. f x - (\<Sum>i\<in>I. a i * w i x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bind_fv2_renamed_var:
  assumes "y \<notin> fst ` fv t"
  shows "bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t)
    = bind_fv2 (x, \<tau>) i t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t) = bind_fv2 (x, \<tau>) i t
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
y \<notin> fst ` fv t

goal (1 subgoal):
 1. bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t) = bind_fv2 (x, \<tau>) i t
[PROOF STEP]
proof (induction t arbitrary: i)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<And>x1 x2 i. y \<notin> fst ` fv (Ct x1 x2) \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] (Ct x1 x2)) = bind_fv2 (x, \<tau>) i (Ct x1 x2)
 2. \<And>x1 x2 i. y \<notin> fst ` fv (Fv x1 x2) \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] (Fv x1 x2)) = bind_fv2 (x, \<tau>) i (Fv x1 x2)
 3. \<And>xa i. y \<notin> fst ` fv (Bv xa) \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] (Bv xa)) = bind_fv2 (x, \<tau>) i (Bv xa)
 4. \<And>x1 t i. \<lbrakk>\<And>i. y \<notin> fst ` fv t \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t) = bind_fv2 (x, \<tau>) i t; y \<notin> fst ` fv (Abs x1 t)\<rbrakk> \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] (Abs x1 t)) = bind_fv2 (x, \<tau>) i (Abs x1 t)
 5. \<And>t1 t2 i. \<lbrakk>\<And>i. y \<notin> fst ` fv t1 \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t1) = bind_fv2 (x, \<tau>) i t1; \<And>i. y \<notin> fst ` fv t2 \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] t2) = bind_fv2 (x, \<tau>) i t2; y \<notin> fst ` fv (t1 $ t2)\<rbrakk> \<Longrightarrow> bind_fv2 (y, \<tau>) i (subst_term [((x, \<tau>), Fv y \<tau>)] (t1 $ t2)) = bind_fv2 (x, \<tau>) i (t1 $ t2)
[PROOF STEP]
qed auto


[STATEMENT]
lemma iteration_unfoldr_distl [simp]: " y + y \<cdot> x\<^sup>\<infinity> \<cdot> x = y \<cdot> x\<^sup>\<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y + y \<cdot> x\<^sup>\<infinity> \<cdot> x = y \<cdot> x\<^sup>\<infinity>
[PROOF STEP]
by (metis distrib_left mult.assoc mult_oner iteration_unfoldr)


[STATEMENT]
lemma word_lsb_numeral [simp]:
  "lsb (numeral bin :: 'a::len word) \<longleftrightarrow> odd (numeral bin :: int)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lsb (numeral bin) = odd (numeral bin)
[PROOF STEP]
by (simp only: lsb_odd, transfer) rule


[STATEMENT]
lemma scons_eq_smap[iff]: "y ## ys = smap f xs \<longleftrightarrow> y = f (shd xs) \<and> ys = smap f (stl xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (y ## ys = smap f xs) = (y = f (shd xs) \<and> ys = smap f (stl xs))
[PROOF STEP]
using smap_ctr
[PROOF STATE]
proof (prove)
using this:
(smap ?f ?s = ?x ## ?s') = (?f (shd ?s) = ?x \<and> smap ?f (stl ?s) = ?s')

goal (1 subgoal):
 1. (y ## ys = smap f xs) = (y = f (shd xs) \<and> ys = smap f (stl xs))
[PROOF STEP]
by metis


[STATEMENT]
lemma map_dual_dual: "(\<partial>\<^sub>F f = g) = (\<partial>\<^sub>F g = f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<partial>\<^sub>F f = g) = (\<partial>\<^sub>F g = f)
[PROOF STEP]
by (metis map_dual_invol pointfree_idE)


[STATEMENT]
theorem lagrange:
  "finite G \<Longrightarrow> card G = card H * index"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite G \<Longrightarrow> card G = card H * index
[PROOF STEP]
unfolding index_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite G \<Longrightarrow> card G = card H * card orbit.Partition
[PROOF STEP]
apply (subst card_partition)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. finite G \<Longrightarrow> finite orbit.Partition
 2. finite G \<Longrightarrow> finite (\<Union> orbit.Partition)
 3. \<And>c. \<lbrakk>finite G; c \<in> orbit.Partition\<rbrakk> \<Longrightarrow> card c = card H
 4. \<And>c1 c2. \<lbrakk>finite G; c1 \<in> orbit.Partition; c2 \<in> orbit.Partition; c1 \<noteq> c2\<rbrakk> \<Longrightarrow> c1 \<inter> c2 = {}
 5. finite G \<Longrightarrow> card G = card (\<Union> orbit.Partition)
[PROOF STEP]
apply (auto simp: finite_UnionD orbit.complete orbit.disjoint)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>finite G; c \<in> orbit.Partition\<rbrakk> \<Longrightarrow> card c = card H
[PROOF STEP]
apply (metis Right_Coset_cardinality Right_Coset_is_orbit orbit.Block_self orbit.element_exists)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nonzero_ac_imp_nonzero:
  assumes "x \<in> carrier Q\<^sub>p"
  assumes "ac m x \<noteq> 0"
  shows "x \<in> nonzero Q\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> nonzero Q\<^sub>p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier Q\<^sub>p
ac m x \<noteq> 0

goal (1 subgoal):
 1. x \<in> nonzero Q\<^sub>p
[PROOF STEP]
unfolding ac_def nonzero_def mem_Collect_eq
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier Q\<^sub>p
(if x = \<zero> then 0 else angular_component x m) \<noteq> 0

goal (1 subgoal):
 1. x \<in> carrier Q\<^sub>p \<and> x \<noteq> \<zero>
[PROOF STEP]
by presburger


[STATEMENT]
lemma R_lin_independent_ConsI :
  assumes "R_lin_independent ms"
          "\<And>r rs. set (r#rs) \<subseteq> R \<Longrightarrow> (r#rs) \<bullet>\<cdot> (m#ms) = 0 \<Longrightarrow> r = 0"
  shows   "R_lin_independent (m#ms)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R_lin_independent (m # ms)
[PROOF STEP]
using   assms R_lin_independent_Cons
[PROOF STATE]
proof (prove)
using this:
R_lin_independent ms
\<lbrakk>set (?r2 # ?rs2) \<subseteq> R; (?r2 # ?rs2) \<bullet>\<cdot> (m # ms) = (0::'m)\<rbrakk> \<Longrightarrow> ?r2 = (0::'r)
R_lin_independent (?m # ?ms) = (R_lin_independent ?ms \<and> (\<forall>r rs. set (r # rs) \<subseteq> R \<and> (r # rs) \<bullet>\<cdot> (?m # ?ms) = (0::'m) \<longrightarrow> r = (0::'r)))

goal (1 subgoal):
 1. R_lin_independent (m # ms)
[PROOF STEP]
by      fast


[STATEMENT]
lemma fmrel_rel_fmran': "fmrel P x y \<Longrightarrow> rel_set P (fmran' x) (fmran' y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmrel P x y \<Longrightarrow> rel_set P (fmran' x) (fmran' y)
[PROOF STEP]
unfolding fmran'_alt_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmrel P x y \<Longrightarrow> rel_set P (fset (fmran x)) (fset (fmran y))
[PROOF STEP]
by (metis fmrel_rel_fmran rel_fset_fset)


[STATEMENT]
lemma word_add_not [simp]: "x + NOT x = -1"
  for x :: "'a::len word"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + NOT x = - 1
[PROOF STEP]
by (simp add: not_eq_complement)


[STATEMENT]
lemma foldl_Gauss_Jordan_column_k_iarrays_eq:
"snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k]
[PROOF STEP]
proof (induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<0]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<0]
 2. \<And>k. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k] \<Longrightarrow> snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<0]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<0]
 2. \<And>k. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k] \<Longrightarrow> snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<0]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<0]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<0]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<0]

goal (1 subgoal):
 1. \<And>k. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k] \<Longrightarrow> snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k]

goal (1 subgoal):
 1. \<And>k. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k] \<Longrightarrow> snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
have suc_rw: "[0..<Suc k] = [0..<k] @ [k]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<Suc k] = [0..<k] @ [k]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[0..<Suc k] = [0..<k] @ [k]

goal (1 subgoal):
 1. \<And>k. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k] \<Longrightarrow> snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]
[PROOF STEP]
unfolding suc_rw foldl_append
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (foldl Gauss_Jordan_column_k_iarrays_PA (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) [k]) = foldl Gauss_Jordan_column_k_iarrays (foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k]) [k]
[PROOF STEP]
unfolding List.foldl.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (Gauss_Jordan_column_k_iarrays_PA (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<k]) k) = Gauss_Jordan_column_k_iarrays (foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<k]) k
[PROOF STEP]
by (metis Suc.hyps fst_snd_Gauss_Jordan_column_k_iarrays_PA_eq snd_snd_Gauss_Jordan_column_k_iarrays_PA_eq surjective_pairing)
[PROOF STATE]
proof (state)
this:
snd (foldl Gauss_Jordan_column_k_iarrays_PA (B, 0, A) [0..<Suc k]) = foldl Gauss_Jordan_column_k_iarrays (0, A) [0..<Suc k]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma qequiv_sym: "a \<cong>\<^sub>Q b \<Longrightarrow> b \<cong>\<^sub>Q a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<cong>\<^sub>Q b \<Longrightarrow> b \<cong>\<^sub>Q a
[PROOF STEP]
by (simp add: qequiv_def)