[STATEMENT]
lemma dvd_modulo_to_lincomb:
  fixes u :: "int poly" and d
  defines "d \<equiv> degree u"
  assumes d: "d < n"
      and dvd: "poly_mod.dvdm k u (poly_of_vec g)"
      and k_not0: "k\<noteq>0"
      and monic_u: "monic u"
      and dim_g: "dim_vec g = n"
      and deg_u: "degree u > 0"
  shows "\<exists>c. lincomb_list c (factorization_lattice u (n-d) k) = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
interpret p: poly_mod k
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
.
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have u_not0: "u \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<noteq> 0
[PROOF STEP]
using monic_u
[PROOF STATE]
proof (prove)
using this:
monic u

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

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
hence n[simp]: "0 < n"
[PROOF STATE]
proof (prove)
using this:
u \<noteq> 0

goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
u \<noteq> 0
d < n

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

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
obtain q' r' where g: "poly_of_vec g = q' * u + smult k r'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>q' r'. poly_of_vec g = q' * u + smult k r' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using p.dvdm_imp_div_mod[OF dvd]
[PROOF STATE]
proof (prove)
using this:
\<exists>q r. poly_of_vec g = q * u + smult k r

goal (1 subgoal):
 1. (\<And>q' r'. poly_of_vec g = q' * u + smult k r' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly_of_vec g = q' * u + smult k r'

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
obtain q'' r'' where r': "r' = q'' * u + r''" and deg_r'': "degree r''<degree u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>q'' r''. \<lbrakk>r' = q'' * u + r''; degree r'' < degree u\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using monic_imp_div_mod_int_poly_degree2[OF monic_u deg_u, of r']
[PROOF STATE]
proof (prove)
using this:
\<exists>q r. r' = q * u + r \<and> degree r < degree u

goal (1 subgoal):
 1. (\<And>q'' r''. \<lbrakk>r' = q'' * u + r''; degree r'' < degree u\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r' = q'' * u + r''
degree r'' < degree u

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
(*The following fact is explained in the paragraph below equation (6) in page 476 of the textbook*)
[PROOF STATE]
proof (state)
this:
r' = q'' * u + r''
degree r'' < degree u

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have g1: "poly_of_vec g = (q' + smult k q'') * u + smult k r''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec g = (q' + smult k q'') * u + smult k r''
[PROOF STEP]
unfolding g r'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q' * u + smult k (q'' * u + r'') = (q' + smult k q'') * u + smult k r''
[PROOF STEP]
by (metis (no_types, lifting) combine_common_factor mult_smult_left smult_add_right)
[PROOF STATE]
proof (state)
this:
poly_of_vec g = (q' + smult k q'') * u + smult k r''

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
define q where q: "q = (q' + smult k q'')"
[PROOF STATE]
proof (state)
this:
q = q' + smult k q''

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
define r where r: "r = r''"
[PROOF STATE]
proof (state)
this:
r = r''

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have degree_q: "q = 0 \<or> degree (q' + smult k q'') < n - d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q = 0 \<or> degree (q' + smult k q'') < n - d
[PROOF STEP]
proof (cases "q = 0",auto, rule degree_div_mod_smult[OF _ _ _ g1])
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. q \<noteq> 0 \<Longrightarrow> degree (poly_of_vec g) < n
 2. q \<noteq> 0 \<Longrightarrow> degree r'' < d
 3. q \<noteq> 0 \<Longrightarrow> degree u = d
 4. q \<noteq> 0 \<Longrightarrow> q' + smult k q'' \<noteq> 0
 5. q \<noteq> 0 \<Longrightarrow> k \<noteq> 0
[PROOF STEP]
show "degree (poly_of_vec g) < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (poly_of_vec g) < n
[PROOF STEP]
by (rule degree_poly_of_vec_less, auto simp add: dim_g)
[PROOF STATE]
proof (state)
this:
degree (poly_of_vec g) < n

goal (4 subgoals):
 1. q \<noteq> 0 \<Longrightarrow> degree r'' < d
 2. q \<noteq> 0 \<Longrightarrow> degree u = d
 3. q \<noteq> 0 \<Longrightarrow> q' + smult k q'' \<noteq> 0
 4. q \<noteq> 0 \<Longrightarrow> k \<noteq> 0
[PROOF STEP]
show "degree r'' < d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree r'' < d
[PROOF STEP]
using deg_r''
[PROOF STATE]
proof (prove)
using this:
degree r'' < degree u

goal (1 subgoal):
 1. degree r'' < d
[PROOF STEP]
unfolding d_def
[PROOF STATE]
proof (prove)
using this:
degree r'' < degree u

goal (1 subgoal):
 1. degree r'' < degree u
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
degree r'' < d

goal (3 subgoals):
 1. q \<noteq> 0 \<Longrightarrow> degree u = d
 2. q \<noteq> 0 \<Longrightarrow> q' + smult k q'' \<noteq> 0
 3. q \<noteq> 0 \<Longrightarrow> k \<noteq> 0
[PROOF STEP]
assume "q\<noteq>0"
[PROOF STATE]
proof (state)
this:
q \<noteq> 0

goal (3 subgoals):
 1. q \<noteq> 0 \<Longrightarrow> degree u = d
 2. q \<noteq> 0 \<Longrightarrow> q' + smult k q'' \<noteq> 0
 3. q \<noteq> 0 \<Longrightarrow> k \<noteq> 0
[PROOF STEP]
thus "q' + smult k q'' \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0

goal (1 subgoal):
 1. q' + smult k q'' \<noteq> 0
[PROOF STEP]
unfolding q
[PROOF STATE]
proof (prove)
using this:
q' + smult k q'' \<noteq> 0

goal (1 subgoal):
 1. q' + smult k q'' \<noteq> 0
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
q' + smult k q'' \<noteq> 0

goal (2 subgoals):
 1. q \<noteq> 0 \<Longrightarrow> degree u = d
 2. q \<noteq> 0 \<Longrightarrow> k \<noteq> 0
[PROOF STEP]
show "k \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<noteq> 0
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
k \<noteq> 0

goal (1 subgoal):
 1. q \<noteq> 0 \<Longrightarrow> degree u = d
[PROOF STEP]
show "degree u = d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree u = d
[PROOF STEP]
using d_def
[PROOF STATE]
proof (prove)
using this:
d \<equiv> degree u

goal (1 subgoal):
 1. degree u = d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
degree u = d

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
q = 0 \<or> degree (q' + smult k q'') < n - d

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have g2: "(vec_of_poly_n (q*u) n) + (vec_of_poly_n (smult k r) n) = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
have "g = vec_of_poly_n (poly_of_vec g) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g = vec_of_poly_n (poly_of_vec g) n
[PROOF STEP]
by (rule vec_of_poly_n_poly_of_vec[symmetric], auto simp add: dim_g)
[PROOF STATE]
proof (state)
this:
g = vec_of_poly_n (poly_of_vec g) n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
g = vec_of_poly_n (poly_of_vec g) n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
have "\<dots> = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (poly_of_vec g) n = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n
[PROOF STEP]
using g1
[PROOF STATE]
proof (prove)
using this:
poly_of_vec g = (q' + smult k q'') * u + smult k r''

goal (1 subgoal):
 1. vec_of_poly_n (poly_of_vec g) n = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (poly_of_vec g) n = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (poly_of_vec g) n = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
have "... = vec_of_poly_n (q * u + smult k r'') n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n = vec_of_poly_n (q * u + smult k r'') n
[PROOF STEP]
unfolding q
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n = vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n = vec_of_poly_n (q * u + smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec_of_poly_n ((q' + smult k q'') * u + smult k r'') n = vec_of_poly_n (q * u + smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
have "... = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (q * u + smult k r'') n = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n
[PROOF STEP]
by (rule vec_of_poly_n_add)
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u + smult k r'') n = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
g = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
g = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
unfolding r
[PROOF STATE]
proof (prove)
using this:
g = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r'') n = g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g

goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
let ?c = "\<lambda>i. if i < n - d then coeff q  (n - d - 1 - i) else coeff r (n - Suc i)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
let ?c1 = "\<lambda>i. ?c i \<cdot>\<^sub>v factorization_lattice u (n-d) k ! i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g
[PROOF STEP]
proof (rule exI[of _ ?c])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
let ?part1 = "map (\<lambda>i. vec_of_poly_n (u * monom 1 i) n) [n-d>..0]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
let ?part2 = "map (\<lambda>i. vec_of_poly_n (monom k i) n) [d>..0]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have [simp]: "dim_vec (M.sumlist (map ?c1 [0..<n - d])) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = n
[PROOF STEP]
by (rule dim_sumlist, auto simp add: dim_factorization_lattice d_def)
[PROOF STATE]
proof (state)
this:
dim_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have [simp]: "dim_vec (M.sumlist (map ?c1 [n-d..<n])) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = n
[PROOF STEP]
by (rule dim_sumlist, insert d, auto simp add: dim_factorization_lattice d_def)
[PROOF STATE]
proof (state)
this:
dim_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have [simp]: "factorization_lattice u (n-d) k ! x \<in> carrier_vec n" if x: "x < n" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factorization_lattice u (n - d) k ! x \<in> carrier_vec n
[PROOF STEP]
using x dim_factorization_lattice_element nth_factorization_lattice[of x u "n-d"] d
[PROOF STATE]
proof (prove)
using this:
x < n
?x \<in> set (factorization_lattice ?u ?d ?m) \<Longrightarrow> dim_vec ?x = degree ?u + ?d
x < degree u + (n - d) \<Longrightarrow> factorization_lattice u (n - d) ?m ! x = vec_of_poly_n (if x < n - d then u * monom 1 (n - d - Suc x) else monom ?m (degree u + (n - d) - Suc x)) (degree u + (n - d))
d < n

goal (1 subgoal):
 1. factorization_lattice u (n - d) k ! x \<in> carrier_vec n
[PROOF STEP]
by (auto simp: d_def)
[PROOF STATE]
proof (state)
this:
?x1 < n \<Longrightarrow> factorization_lattice u (n - d) k ! ?x1 \<in> carrier_vec n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "[0..<length (factorization_lattice u (n-d) k)] = [0..<n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<length (factorization_lattice u (n - d) k)] = [0..<n]
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
d < n

goal (1 subgoal):
 1. [0..<length (factorization_lattice u (n - d) k)] = [0..<n]
[PROOF STEP]
by (simp add: d_def less_imp_le_nat)
[PROOF STATE]
proof (state)
this:
[0..<length (factorization_lattice u (n - d) k)] = [0..<n]

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[0..<length (factorization_lattice u (n - d) k)] = [0..<n]

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "... = [0..<n - d] @ [n-d..<n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<n] = [0..<n - d] @ [n - d..<n]
[PROOF STEP]
by (rule upt_minus_eq_append, auto)
[PROOF STATE]
proof (state)
this:
[0..<n] = [0..<n - d] @ [n - d..<n]

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[0..<length (factorization_lattice u (n - d) k)] = [0..<n - d] @ [n - d..<n]
[PROOF STEP]
have list_rw: "[0..<length (factorization_lattice u (n-d) k)] = [0..<n - d] @ [n-d..<n]"
[PROOF STATE]
proof (prove)
using this:
[0..<length (factorization_lattice u (n - d) k)] = [0..<n - d] @ [n - d..<n]

goal (1 subgoal):
 1. [0..<length (factorization_lattice u (n - d) k)] = [0..<n - d] @ [n - d..<n]
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
[0..<length (factorization_lattice u (n - d) k)] = [0..<n - d] @ [n - d..<n]

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have qu1: "poly_of_vec (M.sumlist (map ?c1 [0..<n - d])) = q*u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
have "poly_of_vec (M.sumlist (map ?c1 [0..<n - d])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n-d}. ?c1 i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)
[PROOF STEP]
by (subst sumlist_map_as_finsum, auto)
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
have "... = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n-d]. ?c1 i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{0..<n - d}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
have "... = sum (\<lambda>i. poly_of_vec (?c1 i)) (set [0..<n-d])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))
[PROOF STEP]
by (auto simp:poly_of_vec_finsum)
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [0..<n - d]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
have "... = sum (\<lambda>i. poly_of_vec (?c1 i)) {0..<n-d}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set [0..<n - d]. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
have "... = q*u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have deg: "degree (u * monom 1 (n - Suc (d + i))) < n" if i: "i < n - d" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
let ?m="monom (1::int) (n - Suc (d + i))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
have monom_not0: "?m \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom 1 (n - Suc (d + i)) \<noteq> 0
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < n - d

goal (1 subgoal):
 1. monom 1 (n - Suc (d + i)) \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
monom 1 (n - Suc (d + i)) \<noteq> 0

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
have deg_m: "degree ?m = n - Suc (d + i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (monom 1 (n - Suc (d + i))) = n - Suc (d + i)
[PROOF STEP]
by (rule degree_monom_eq, auto)
[PROOF STATE]
proof (state)
this:
degree (monom 1 (n - Suc (d + i))) = n - Suc (d + i)

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
have "degree (u * ?m) = d + (n - Suc (d + i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) = d + (n - Suc (d + i))
[PROOF STEP]
using degree_mult_eq[OF u_not0 monom_not0] d_def deg_m
[PROOF STATE]
proof (prove)
using this:
degree (u * monom 1 (n - Suc (d + i))) = degree u + degree (monom 1 (n - Suc (d + i)))
d \<equiv> degree u
degree (monom 1 (n - Suc (d + i))) = n - Suc (d + i)

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) = d + (n - Suc (d + i))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
degree (u * monom 1 (n - Suc (d + i))) = d + (n - Suc (d + i))

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
degree (u * monom 1 (n - Suc (d + i))) = d + (n - Suc (d + i))

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
have "... < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d + (n - Suc (d + i)) < n
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < n - d

goal (1 subgoal):
 1. d + (n - Suc (d + i)) < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d + (n - Suc (d + i)) < n

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
degree (u * monom 1 (n - Suc (d + i))) < n

goal (1 subgoal):
 1. degree (u * monom 1 (n - Suc (d + i))) < n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
degree (u * monom 1 (n - Suc (d + i))) < n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i1 < n - d \<Longrightarrow> degree (u * monom 1 (n - Suc (d + ?i1))) < n

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have lattice_rw: "factorization_lattice u (n-d) k ! i = vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n"
          if i: "i< n - d" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factorization_lattice u (n - d) k ! i = vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n
[PROOF STEP]
apply (subst nth_factorization_lattice)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. i < degree u + (n - d)
 2. vec_of_poly_n (if i < n - d then u * monom 1 (n - d - Suc i) else monom k (degree u + (n - d) - Suc i)) (degree u + (n - d)) = vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < n - d

goal (2 subgoals):
 1. i < degree u + (n - d)
 2. vec_of_poly_n (if i < n - d then u * monom 1 (n - d - Suc i) else monom k (degree u + (n - d) - Suc i)) (degree u + (n - d)) = vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n
[PROOF STEP]
by (auto simp:d_def)
[PROOF STATE]
proof (state)
this:
?i1 < n - d \<Longrightarrow> factorization_lattice u (n - d) k ! ?i1 = vec_of_poly_n (u * monom 1 (n - Suc (d + ?i1))) n

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have q_rw: "q = (\<Sum>i = 0..<n - d. (smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))
[PROOF STEP]
proof (auto simp add: poly_eq_iff coeff_sum)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
let ?m = "n-d-1-j"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
let ?f = "\<lambda>x. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have set_rw: "{0..<n-d} = insert ?m ({0..<n-d} - {?m})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0..<n - d} = insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j})
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
d < n

goal (1 subgoal):
 1. {0..<n - d} = insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0..<n - d} = insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j})

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have sum0: "(\<Sum>x \<in> {0..<n-d} - {?m}. ?f x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = 0
[PROOF STEP]
by (rule sum.neutral, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = 0

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have "(\<Sum>x = 0..<n - d. ?f x) = (\<Sum>x \<in> insert ?m ({0..<n-d} - {?m}). ?f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = (\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))
[PROOF STEP]
using set_rw
[PROOF STATE]
proof (prove)
using this:
{0..<n - d} = insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j})

goal (1 subgoal):
 1. (\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = (\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = (\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = (\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have "... = ?f ?m + (\<Sum>x \<in> {0..<n-d} - {?m}. ?f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))
[PROOF STEP]
by (rule sum.insert, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>insert (n - d - 1 - j) ({0..<n - d} - {n - d - 1 - j}). coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0))

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have "... = ?f ?m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0)
[PROOF STEP]
unfolding sum0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + 0 = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0)

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) + (\<Sum>x\<in>{0..<n - d} - {n - d - 1 - j}. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0)

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
have "... = coeff q j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
proof (cases "j < n - d")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
 2. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j < n - d

goal (2 subgoals):
 1. j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
 2. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < n - d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
j < n - d

goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j

goal (1 subgoal):
 1. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> j < n - d

goal (1 subgoal):
 1. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
have "j>degree q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree q < j
[PROOF STEP]
using degree_q q False d
[PROOF STATE]
proof (prove)
using this:
q = 0 \<or> degree (q' + smult k q'') < n - d
q = q' + smult k q''
\<not> j < n - d
d < n

goal (1 subgoal):
 1. degree q < j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
degree q < j

goal (1 subgoal):
 1. \<not> j < n - d \<Longrightarrow> coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree q < j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
degree q < j

goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
using coeff_eq_0
[PROOF STATE]
proof (prove)
using this:
degree q < j
degree ?p < ?n \<Longrightarrow> coeff ?p ?n = (0::?'a)

goal (1 subgoal):
 1. coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coeff q (n - Suc (d + (n - d - 1 - j))) * (if n - Suc (d + (n - d - 1 - j)) = j then 1 else 0) = coeff q j

goal (1 subgoal):
 1. \<And>na. coeff q na = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = na then 1 else 0))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q j
[PROOF STEP]
show "coeff q j = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i))
            * (if n - Suc (d + i) = j then 1 else 0))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x = 0..<n - d. coeff q (n - Suc (d + x)) * (if n - Suc (d + x) = j then 1 else 0)) = coeff q j

goal (1 subgoal):
 1. coeff q j = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = j then 1 else 0))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
coeff q j = (\<Sum>i = 0..<n - d. coeff q (n - Suc (d + i)) * (if n - Suc (d + i) = j then 1 else 0))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
q = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "sum (\<lambda>i. poly_of_vec (?c1 i)) {0..<n-d}
        = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n-d) k ! i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))
[PROOF STEP]
by (rule sum.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "...  = (\<Sum>i = 0..<n - d. (poly_of_vec (coeff q (n - Suc (d + i))
          \<cdot>\<^sub>v (vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n))
[PROOF STEP]
by (rule sum.cong, auto simp add: lattice_rw)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "... = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n)) = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i))))
[PROOF STEP]
by (rule sum.cong, auto simp add: poly_of_vec_scalar_mult[OF deg])
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n)) = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec (coeff q (n - Suc (d + i)) \<cdot>\<^sub>v vec_of_poly_n (u * monom 1 (n - Suc (d + i))) n)) = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "... = (\<Sum>i = 0..<n - d. u*(smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i)))) = (\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i)))) = (\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (u * monom 1 (n - Suc (d + i)))) = (\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "... = u *(\<Sum>i = 0..<n - d. (smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))
[PROOF STEP]
by (rule sum_distrib_left[symmetric])
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. u * smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "... = u * q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * q
[PROOF STEP]
using q_rw
[PROOF STATE]
proof (prove)
using this:
q = (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i))))

goal (1 subgoal):
 1. u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * q

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
u * (\<Sum>i = 0..<n - d. smult (coeff q (n - Suc (d + i))) (monom 1 (n - Suc (d + i)))) = u * q

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
have "... = q*u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u * q = q * u
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u * q = q * u

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u

goal (1 subgoal):
 1. (\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n - d. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = q * u

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have qu: "M.sumlist (map ?c1 [0..<n - d]) = vec_of_poly_n (q*u) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
have "vec_of_poly_n (q*u) n = vec_of_poly_n (poly_of_vec (M.sumlist (map ?c1 [0..<n - d]))) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (q * u) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n
[PROOF STEP]
using qu1
[PROOF STATE]
proof (prove)
using this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])) = q * u

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
have "vec_of_poly_n (poly_of_vec (M.sumlist (map ?c1 [0..<n - d]))) n
        = M.sumlist (map ?c1 [0..<n - d])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])
[PROOF STEP]
by (rule vec_of_poly_n_poly_of_vec, auto)
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]))) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
vec_of_poly_n (q * u) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
vec_of_poly_n (q * u) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d])

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) = vec_of_poly_n (q * u) n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have rm1: "poly_of_vec (M.sumlist (map ?c1 [n-d..<n])) = smult k r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
have "poly_of_vec (M.sumlist (map ?c1 [n-d..<n])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n-d..<n}. ?c1 i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)
[PROOF STEP]
by (subst sumlist_map_as_finsum, auto)
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
have "... = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n-d..<n]. ?c1 i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>{n - d..<n}. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
have "... = sum (\<lambda>i. poly_of_vec (?c1 i)) {n-d..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))
[PROOF STEP]
by (auto simp: poly_of_vec_finsum)
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly_of_vec (\<Oplus>\<^bsub>V\<^esub>i\<in>set [n - d..<n]. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) = (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
have "... = smult k r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have deg: "degree (monom k (n - Suc i)) < n" if i: "n-d\<le>i" and i2: "i<n" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (monom k (n - Suc i)) < n
[PROOF STEP]
using degree_monom_le i i2
[PROOF STATE]
proof (prove)
using this:
degree (monom ?a ?n) \<le> ?n
n - d \<le> i
i < n

goal (1 subgoal):
 1. degree (monom k (n - Suc i)) < n
[PROOF STEP]
by (simp add: degree_monom_eq k_not0)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n - d \<le> ?i1; ?i1 < n\<rbrakk> \<Longrightarrow> degree (monom k (n - Suc ?i1)) < n

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have lattice_rw: "factorization_lattice u (n-d) k ! i = vec_of_poly_n (monom k (n - Suc i)) n"
          if i: "n - d \<le> i" and i2: "i<n" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factorization_lattice u (n - d) k ! i = vec_of_poly_n (monom k (n - Suc i)) n
[PROOF STEP]
using i2 i d d_def
[PROOF STATE]
proof (prove)
using this:
i < n
n - d \<le> i
d < n
d \<equiv> degree u

goal (1 subgoal):
 1. factorization_lattice u (n - d) k ! i = vec_of_poly_n (monom k (n - Suc i)) n
[PROOF STEP]
by (subst nth_factorization_lattice, auto)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n - d \<le> ?i1; ?i1 < n\<rbrakk> \<Longrightarrow> factorization_lattice u (n - d) k ! ?i1 = vec_of_poly_n (monom k (n - Suc ?i1)) n

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have r_rw: "r = (\<Sum>i \<in> {n-d..<n}. (monom (coeff r (n - Suc i)) (n - Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))
[PROOF STEP]
proof (auto simp add: poly_eq_iff coeff_sum)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff r na = (\<Sum>i = n - d..<n. if n - Suc i = na then coeff r (n - Suc i) else 0)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff r na = (\<Sum>i = n - d..<n. if n - Suc i = na then coeff r (n - Suc i) else 0)
[PROOF STEP]
show "coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
proof (cases "j<d")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j < d

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have j_eq: "n - Suc (n - 1 - j) = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - Suc (n - 1 - j) = j
[PROOF STEP]
using d True
[PROOF STATE]
proof (prove)
using this:
d < n
j < d

goal (1 subgoal):
 1. n - Suc (n - 1 - j) = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - Suc (n - 1 - j) = j

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
let ?i = "n-1-j"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
let ?f ="\<lambda>i. if n - Suc i = j then coeff r (n - Suc i) else 0"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have sum0: "sum ?f ({n-d..<n} - {?i}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0
[PROOF STEP]
by (rule sum.neutral, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have "{n-d..<n} = insert ?i ({n-d..<n} - {?i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {n - d..<n} = insert (n - 1 - j) ({n - d..<n} - {n - 1 - j})
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
j < d

goal (1 subgoal):
 1. {n - d..<n} = insert (n - 1 - j) ({n - d..<n} - {n - 1 - j})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{n - d..<n} = insert (n - 1 - j) ({n - d..<n} - {n - 1 - j})

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
hence "sum ?f {n - d..<n} = sum ?f (insert ?i ({n-d..<n} - {?i}))"
[PROOF STATE]
proof (prove)
using this:
{n - d..<n} = insert (n - 1 - j) ({n - d..<n} - {n - 1 - j})

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = (\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = (\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0)

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = (\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0)

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have "... = ?f ?i + sum ?f ({n-d..<n} - {?i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0) = (if n - Suc (n - 1 - j) = j then coeff r (n - Suc (n - 1 - j)) else 0) + (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
by (rule sum.insert, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0) = (if n - Suc (n - 1 - j) = j then coeff r (n - Suc (n - 1 - j)) else 0) + (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0)

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>insert (n - 1 - j) ({n - d..<n} - {n - 1 - j}). if n - Suc i = j then coeff r (n - Suc i) else 0) = (if n - Suc (n - 1 - j) = j then coeff r (n - Suc (n - 1 - j)) else 0) + (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0)

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have "... = coeff r j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if n - Suc (n - 1 - j) = j then coeff r (n - Suc (n - 1 - j)) else 0) + (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j
[PROOF STEP]
unfolding sum0 j_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if j = j then coeff r j else 0) + 0 = coeff r j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if n - Suc (n - 1 - j) = j then coeff r (n - Suc (n - 1 - j)) else 0) + (\<Sum>i\<in>{n - d..<n} - {n - 1 - j}. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j

goal (2 subgoals):
 1. j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
 2. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j

goal (1 subgoal):
 1. coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)

goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> j < d

goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
hence "(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> j < d

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0
[PROOF STEP]
by (intro sum.neutral ballI, insert False, simp, linarith)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0

goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = 0

goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
have "... = coeff r j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = coeff r j
[PROOF STEP]
by (rule coeff_eq_0[symmetric], insert False deg_r'' r d_def, auto)
[PROOF STATE]
proof (state)
this:
0 = coeff r j

goal (1 subgoal):
 1. \<not> j < d \<Longrightarrow> coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0) = coeff r j

goal (1 subgoal):
 1. coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coeff r j = (\<Sum>i = n - d..<n. if n - Suc i = j then coeff r (n - Suc i) else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
r = (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "sum (\<lambda>i. poly_of_vec (?c1 i)) {n-d..<n}
        = (\<Sum>i \<in> {n-d..<n}. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n-d) k ! i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))
[PROOF STEP]
by (rule sum.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "...  = (\<Sum>i \<in> {n-d..<n}. (poly_of_vec (coeff r (n - Suc i)
          \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n))
[PROOF STEP]
by (rule sum.cong, auto simp add: lattice_rw)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "... = (\<Sum>i \<in> {n-d..<n}. smult (coeff r (n - Suc i)) (monom k (n - Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n)) = (\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i)))
[PROOF STEP]
by (rule sum.cong, auto simp add: poly_of_vec_scalar_mult[OF deg])
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n)) = (\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i)))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec (coeff r (n - Suc i) \<cdot>\<^sub>v vec_of_poly_n (monom k (n - Suc i)) n)) = (\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i)))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "... = (\<Sum>i \<in> {n-d..<n}. smult k (monom (coeff r (n - Suc i)) (n - Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i))) = (\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i)))
[PROOF STEP]
by (rule sum.cong, auto simp add: smult_monom smult_sum2)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i))) = (\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i)))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. smult (coeff r (n - Suc i)) (monom k (n - Suc i))) = (\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i)))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "... = smult k (\<Sum>i \<in> {n-d..<n}. (monom (coeff r (n - Suc i)) (n - Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i))) = smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))
[PROOF STEP]
by (simp add: smult_sum2)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i))) = smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. smult k (monom (coeff r (n - Suc i)) (n - Suc i))) = smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
have "... = smult k r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i)) = smult k r
[PROOF STEP]
using r_rw
[PROOF STATE]
proof (prove)
using this:
r = (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i))

goal (1 subgoal):
 1. smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i)) = smult k r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
smult k (\<Sum>i = n - d..<n. monom (coeff r (n - Suc i)) (n - Suc i)) = smult k r

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r

goal (1 subgoal):
 1. (\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = n - d..<n. poly_of_vec ((if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i)) = smult k r

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r

goal (1 subgoal):
 1. poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have rm: "(M.sumlist (map ?c1 [n-d..<n])) = vec_of_poly_n (smult k r) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
have "vec_of_poly_n (smult k r) n
        = vec_of_poly_n (poly_of_vec (M.sumlist (map ?c1 [n-d..<n]))) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (smult k r) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n
[PROOF STEP]
using rm1
[PROOF STATE]
proof (prove)
using this:
poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])) = smult k r

goal (1 subgoal):
 1. vec_of_poly_n (smult k r) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (smult k r) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (smult k r) n = vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
have "vec_of_poly_n (poly_of_vec (M.sumlist (map ?c1 [n-d..<n]))) n
        = M.sumlist (map ?c1 [n-d..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])
[PROOF STEP]
by (rule vec_of_poly_n_poly_of_vec, auto)
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (poly_of_vec (M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]))) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
vec_of_poly_n (smult k r) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
vec_of_poly_n (smult k r) n = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (smult k r) n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "lincomb_list ?c (factorization_lattice u (n-d) k) = M.sumlist (map ?c1 ([0..<n - d] @ [n-d..<n]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n]))
[PROOF STEP]
unfolding lincomb_list_def list_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n])) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n]))

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n]))

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "... = M.sumlist (map ?c1 [0..<n - d] @ map ?c1 [n-d..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n])) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n])) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) ([0..<n - d] @ [n - d..<n])) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "... = M.sumlist (map ?c1 [0..<n - d]) + M.sumlist (map ?c1 [n-d..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
d < n

goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])
[PROOF STEP]
by (auto simp add: d_def nth_factorization_lattice intro!: M.sumlist_append)
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d] @ map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n])

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "... = vec_of_poly_n (q*u) n + vec_of_poly_n (smult k r) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n
[PROOF STEP]
unfolding qu rm
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [0..<n - d]) + M.sumlist (map (\<lambda>i. (if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) \<cdot>\<^sub>v factorization_lattice u (n - d) k ! i) [n - d..<n]) = vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
have "... = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
using g2
[PROOF STATE]
proof (prove)
using this:
vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g

goal (1 subgoal):
 1. vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_poly_n (q * u) n + vec_of_poly_n (smult k r) n = g

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
show "lincomb_list ?c (factorization_lattice u (n-d) k) = g"
[PROOF STATE]
proof (prove)
using this:
lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. if i < n - d then coeff q (n - d - 1 - i) else coeff r (n - Suc i)) (factorization_lattice u (n - d) k) = g

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>c. lincomb_list c (factorization_lattice u (n - d) k) = g

goal:
No subgoals!
[PROOF STEP]
qed