src/HOL/Computational_Algebra/Polynomial_FPS.thy
author wenzelm
Wed Nov 01 20:46:23 2017 +0100 (22 months ago)
changeset 66983 df83b66f1d94
parent 66480 4b8d1df8933b
child 67399 eab6ce8368fa
permissions -rw-r--r--
proper merge (amending fb46c031c841);
wenzelm@65435
     1
(*  Title:      HOL/Computational_Algebra/Polynomial_FPS.thy
wenzelm@65366
     2
    Author:     Manuel Eberl, TU München
eberlm@63317
     3
*)
eberlm@63317
     4
eberlm@63317
     5
section \<open>Converting polynomials to formal power series\<close>
wenzelm@65366
     6
eberlm@63317
     7
theory Polynomial_FPS
wenzelm@65366
     8
  imports Polynomial Formal_Power_Series
eberlm@63317
     9
begin
eberlm@63317
    10
eberlm@66480
    11
context
eberlm@66480
    12
  includes fps_notation
eberlm@66480
    13
begin
eberlm@66480
    14
eberlm@63319
    15
definition fps_of_poly where
eberlm@63319
    16
  "fps_of_poly p = Abs_fps (coeff p)"
eberlm@63317
    17
eberlm@63319
    18
lemma fps_of_poly_eq_iff: "fps_of_poly p = fps_of_poly q \<longleftrightarrow> p = q"
eberlm@63319
    19
  by (simp add: fps_of_poly_def poly_eq_iff fps_eq_iff)
eberlm@63317
    20
eberlm@63319
    21
lemma fps_of_poly_nth [simp]: "fps_of_poly p $ n = coeff p n"
eberlm@63319
    22
  by (simp add: fps_of_poly_def)
eberlm@63317
    23
  
eberlm@63319
    24
lemma fps_of_poly_const: "fps_of_poly [:c:] = fps_const c"
eberlm@63317
    25
proof (subst fps_eq_iff, clarify)
eberlm@63319
    26
  fix n :: nat show "fps_of_poly [:c:] $ n = fps_const c $ n"
eberlm@63319
    27
    by (cases n) (auto simp: fps_of_poly_def)
eberlm@63317
    28
qed
eberlm@63317
    29
eberlm@63319
    30
lemma fps_of_poly_0 [simp]: "fps_of_poly 0 = 0"
eberlm@63319
    31
  by (subst fps_const_0_eq_0 [symmetric], subst fps_of_poly_const [symmetric]) simp
eberlm@63317
    32
eberlm@63319
    33
lemma fps_of_poly_1 [simp]: "fps_of_poly 1 = 1"
haftmann@65486
    34
  by (simp add: fps_eq_iff)
eberlm@63317
    35
eberlm@63319
    36
lemma fps_of_poly_1' [simp]: "fps_of_poly [:1:] = 1"
eberlm@63319
    37
  by (subst fps_const_1_eq_1 [symmetric], subst fps_of_poly_const [symmetric])
eberlm@63317
    38
     (simp add: one_poly_def)
eberlm@63317
    39
eberlm@63319
    40
lemma fps_of_poly_numeral [simp]: "fps_of_poly (numeral n) = numeral n"
eberlm@63319
    41
  by (simp add: numeral_fps_const fps_of_poly_const [symmetric] numeral_poly)
eberlm@63317
    42
eberlm@63319
    43
lemma fps_of_poly_numeral' [simp]: "fps_of_poly [:numeral n:] = numeral n"
eberlm@63319
    44
  by (simp add: numeral_fps_const fps_of_poly_const [symmetric] numeral_poly)
eberlm@63317
    45
eberlm@66480
    46
lemma fps_of_poly_fps_X [simp]: "fps_of_poly [:0, 1:] = fps_X"
eberlm@63319
    47
  by (auto simp add: fps_of_poly_def fps_eq_iff coeff_pCons split: nat.split)
eberlm@63317
    48
eberlm@63319
    49
lemma fps_of_poly_add: "fps_of_poly (p + q) = fps_of_poly p + fps_of_poly q"
eberlm@63319
    50
  by (simp add: fps_of_poly_def plus_poly.rep_eq fps_plus_def)
eberlm@63317
    51
eberlm@63319
    52
lemma fps_of_poly_diff: "fps_of_poly (p - q) = fps_of_poly p - fps_of_poly q"
eberlm@63319
    53
  by (simp add: fps_of_poly_def minus_poly.rep_eq fps_minus_def)
eberlm@63317
    54
eberlm@63319
    55
lemma fps_of_poly_uminus: "fps_of_poly (-p) = -fps_of_poly p"
eberlm@63319
    56
  by (simp add: fps_of_poly_def uminus_poly.rep_eq fps_uminus_def)
eberlm@63317
    57
eberlm@63319
    58
lemma fps_of_poly_mult: "fps_of_poly (p * q) = fps_of_poly p * fps_of_poly q"
eberlm@63319
    59
  by (simp add: fps_of_poly_def fps_times_def fps_eq_iff coeff_mult atLeast0AtMost)
eberlm@63317
    60
eberlm@63319
    61
lemma fps_of_poly_smult: 
eberlm@63319
    62
  "fps_of_poly (smult c p) = fps_const c * fps_of_poly p"
eberlm@63319
    63
  using fps_of_poly_mult[of "[:c:]" p] by (simp add: fps_of_poly_mult fps_of_poly_const)
eberlm@63317
    64
  
nipkow@64267
    65
lemma fps_of_poly_sum: "fps_of_poly (sum f A) = sum (\<lambda>x. fps_of_poly (f x)) A"
eberlm@63319
    66
  by (cases "finite A", induction rule: finite_induct) (simp_all add: fps_of_poly_add)
eberlm@63317
    67
nipkow@63882
    68
lemma fps_of_poly_sum_list: "fps_of_poly (sum_list xs) = sum_list (map fps_of_poly xs)"
eberlm@63319
    69
  by (induction xs) (simp_all add: fps_of_poly_add)
eberlm@63317
    70
  
nipkow@64272
    71
lemma fps_of_poly_prod: "fps_of_poly (prod f A) = prod (\<lambda>x. fps_of_poly (f x)) A"
eberlm@63319
    72
  by (cases "finite A", induction rule: finite_induct) (simp_all add: fps_of_poly_mult)
eberlm@63317
    73
  
nipkow@63882
    74
lemma fps_of_poly_prod_list: "fps_of_poly (prod_list xs) = prod_list (map fps_of_poly xs)"
eberlm@63319
    75
  by (induction xs) (simp_all add: fps_of_poly_mult)
eberlm@63317
    76
eberlm@63319
    77
lemma fps_of_poly_pCons: 
eberlm@66480
    78
  "fps_of_poly (pCons (c :: 'a :: semiring_1) p) = fps_const c + fps_of_poly p * fps_X"
eberlm@66480
    79
  by (subst fps_mult_fps_X_commute [symmetric], intro fps_ext) 
eberlm@63319
    80
     (auto simp: fps_of_poly_def coeff_pCons split: nat.split)
eberlm@63317
    81
  
eberlm@63319
    82
lemma fps_of_poly_pderiv: "fps_of_poly (pderiv p) = fps_deriv (fps_of_poly p)"
eberlm@63319
    83
  by (intro fps_ext) (simp add: fps_of_poly_nth coeff_pderiv)
eberlm@63317
    84
eberlm@63319
    85
lemma fps_of_poly_power: "fps_of_poly (p ^ n) = fps_of_poly p ^ n"
eberlm@63319
    86
  by (induction n) (simp_all add: fps_of_poly_mult)
eberlm@63317
    87
  
eberlm@66480
    88
lemma fps_of_poly_monom: "fps_of_poly (monom (c :: 'a :: comm_ring_1) n) = fps_const c * fps_X ^ n"
eberlm@63317
    89
  by (intro fps_ext) simp_all
eberlm@63317
    90
eberlm@66480
    91
lemma fps_of_poly_monom': "fps_of_poly (monom (1 :: 'a :: comm_ring_1) n) = fps_X ^ n"
eberlm@63319
    92
  by (simp add: fps_of_poly_monom)
eberlm@63317
    93
eberlm@63319
    94
lemma fps_of_poly_div:
eberlm@63317
    95
  assumes "(q :: 'a :: field poly) dvd p"
eberlm@63319
    96
  shows   "fps_of_poly (p div q) = fps_of_poly p / fps_of_poly q"
eberlm@63317
    97
proof (cases "q = 0")
eberlm@63317
    98
  case False
eberlm@63319
    99
  from False fps_of_poly_eq_iff[of q 0] have nz: "fps_of_poly q \<noteq> 0" by simp 
eberlm@63317
   100
  from assms have "p = (p div q) * q" by simp
eberlm@63319
   101
  also have "fps_of_poly \<dots> = fps_of_poly (p div q) * fps_of_poly q" 
eberlm@63319
   102
    by (simp add: fps_of_poly_mult)
eberlm@63319
   103
  also from nz have "\<dots> / fps_of_poly q = fps_of_poly (p div q)"
haftmann@64240
   104
    by (intro nonzero_mult_div_cancel_right) (auto simp: fps_of_poly_0)
eberlm@63317
   105
  finally show ?thesis ..
eberlm@63317
   106
qed simp
eberlm@63317
   107
eberlm@63319
   108
lemma fps_of_poly_divide_numeral:
eberlm@63319
   109
  "fps_of_poly (smult (inverse (numeral c :: 'a :: field)) p) = fps_of_poly p / numeral c"
eberlm@63317
   110
proof -
eberlm@63317
   111
  have "smult (inverse (numeral c)) p = [:inverse (numeral c):] * p" by simp
eberlm@63319
   112
  also have "fps_of_poly \<dots> = fps_of_poly p / numeral c"
eberlm@63319
   113
    by (subst fps_of_poly_mult) (simp add: numeral_fps_const fps_of_poly_pCons)
eberlm@63317
   114
  finally show ?thesis by simp
eberlm@63317
   115
qed
eberlm@63317
   116
eberlm@63317
   117
eberlm@63319
   118
lemma subdegree_fps_of_poly:
eberlm@63317
   119
  assumes "p \<noteq> 0"
eberlm@63317
   120
  defines "n \<equiv> Polynomial.order 0 p"
eberlm@63319
   121
  shows   "subdegree (fps_of_poly p) = n"
eberlm@63317
   122
proof (rule subdegreeI)
eberlm@63317
   123
  from assms have "monom 1 n dvd p" by (simp add: monom_1_dvd_iff)
eberlm@63319
   124
  thus zero: "fps_of_poly p $ i = 0" if "i < n" for i
eberlm@63317
   125
    using that by (simp add: monom_1_dvd_iff')
eberlm@63317
   126
    
eberlm@63317
   127
  from assms have "\<not>monom 1 (Suc n) dvd p"
eberlm@63317
   128
    by (auto simp: monom_1_dvd_iff simp del: power_Suc)
wenzelm@63539
   129
  then obtain k where k: "k \<le> n" "fps_of_poly p $ k \<noteq> 0" 
eberlm@63317
   130
    by (auto simp: monom_1_dvd_iff' less_Suc_eq_le)
wenzelm@63539
   131
  with zero[of k] have "k = n" by linarith
wenzelm@63539
   132
  with k show "fps_of_poly p $ n \<noteq> 0" by simp
eberlm@63317
   133
qed
eberlm@63317
   134
eberlm@63319
   135
lemma fps_of_poly_dvd:
eberlm@63317
   136
  assumes "p dvd q"
eberlm@63319
   137
  shows   "fps_of_poly (p :: 'a :: field poly) dvd fps_of_poly q"
eberlm@63317
   138
proof (cases "p = 0 \<or> q = 0")
eberlm@63317
   139
  case False
eberlm@63319
   140
  with assms fps_of_poly_eq_iff[of p 0] fps_of_poly_eq_iff[of q 0] show ?thesis
eberlm@63319
   141
    by (auto simp: fps_dvd_iff subdegree_fps_of_poly dvd_imp_order_le)
eberlm@63317
   142
qed (insert assms, auto)
eberlm@63317
   143
eberlm@63317
   144
eberlm@63319
   145
lemmas fps_of_poly_simps =
eberlm@66480
   146
  fps_of_poly_0 fps_of_poly_1 fps_of_poly_numeral fps_of_poly_const fps_of_poly_fps_X
eberlm@63319
   147
  fps_of_poly_add fps_of_poly_diff fps_of_poly_uminus fps_of_poly_mult fps_of_poly_smult
nipkow@64272
   148
  fps_of_poly_sum fps_of_poly_sum_list fps_of_poly_prod fps_of_poly_prod_list
eberlm@63319
   149
  fps_of_poly_pCons fps_of_poly_pderiv fps_of_poly_power fps_of_poly_monom
eberlm@63319
   150
  fps_of_poly_divide_numeral
eberlm@63317
   151
eberlm@63319
   152
lemma fps_of_poly_pcompose:
eberlm@63317
   153
  assumes "coeff q 0 = (0 :: 'a :: idom)"
eberlm@63319
   154
  shows   "fps_of_poly (pcompose p q) = fps_compose (fps_of_poly p) (fps_of_poly q)"
eberlm@63317
   155
  using assms by (induction p rule: pCons_induct)
eberlm@63319
   156
                 (auto simp: pcompose_pCons fps_of_poly_simps fps_of_poly_pCons 
eberlm@63317
   157
                             fps_compose_add_distrib fps_compose_mult_distrib)
eberlm@63317
   158
  
eberlm@63317
   159
lemmas reify_fps_atom =
eberlm@66480
   160
  fps_of_poly_0 fps_of_poly_1' fps_of_poly_numeral' fps_of_poly_const fps_of_poly_fps_X
eberlm@63317
   161
eberlm@63317
   162
eberlm@63317
   163
text \<open>
eberlm@63317
   164
  The following simproc can reduce the equality of two polynomial FPSs two equality of the
eberlm@63317
   165
  respective polynomials. A polynomial FPS is one that only has finitely many non-zero 
eberlm@63319
   166
  coefficients and can therefore be written as @{term "fps_of_poly p"} for some 
wenzelm@64911
   167
  polynomial \<open>p\<close>.
eberlm@63317
   168
  
eberlm@63317
   169
  This may sound trivial, but it covers a number of annoying side conditions like 
eberlm@66480
   170
  @{term "1 + fps_X \<noteq> 0"} that would otherwise not be solved automatically.
eberlm@63317
   171
\<close>
eberlm@63317
   172
eberlm@63317
   173
ML \<open>
eberlm@63317
   174
eberlm@63317
   175
(* TODO: Support for division *)
eberlm@63317
   176
signature POLY_FPS = sig
eberlm@63317
   177
eberlm@63317
   178
val reify_conv : conv
eberlm@63317
   179
val eq_conv : conv
eberlm@63317
   180
val eq_simproc : cterm -> thm option
eberlm@63317
   181
eberlm@63317
   182
end
eberlm@63317
   183
eberlm@63317
   184
eberlm@63317
   185
structure Poly_Fps = struct
eberlm@63317
   186
eberlm@63317
   187
fun const_binop_conv s conv ct =
eberlm@63317
   188
  case Thm.term_of ct of
eberlm@63317
   189
    (Const (s', _) $ _ $ _) => 
eberlm@63317
   190
      if s = s' then 
eberlm@63317
   191
        Conv.binop_conv conv ct 
eberlm@63317
   192
      else 
eberlm@63317
   193
        raise CTERM ("const_binop_conv", [ct])
eberlm@63317
   194
  | _ => raise CTERM ("const_binop_conv", [ct])
eberlm@63317
   195
eberlm@63317
   196
fun reify_conv ct = 
eberlm@63317
   197
  let
eberlm@63317
   198
    val rewr = Conv.rewrs_conv o map (fn thm => thm RS @{thm eq_reflection})
eberlm@63317
   199
    val un = Conv.arg_conv reify_conv
eberlm@63317
   200
    val bin = Conv.binop_conv reify_conv
eberlm@63317
   201
  in
eberlm@63317
   202
    case Thm.term_of ct of
eberlm@63319
   203
      (Const (@{const_name "fps_of_poly"}, _) $ _) => ct |> Conv.all_conv
eberlm@63317
   204
    | (Const (@{const_name "Groups.plus"}, _) $ _ $ _) => ct |> (
eberlm@63319
   205
        bin then_conv rewr @{thms fps_of_poly_add [symmetric]})
eberlm@63317
   206
    | (Const (@{const_name "Groups.uminus"}, _) $ _) => ct |> (
eberlm@63319
   207
        un then_conv rewr @{thms fps_of_poly_uminus [symmetric]})
eberlm@63317
   208
    | (Const (@{const_name "Groups.minus"}, _) $ _ $ _) => ct |> (
eberlm@63319
   209
        bin then_conv rewr @{thms fps_of_poly_diff [symmetric]})
eberlm@63317
   210
    | (Const (@{const_name "Groups.times"}, _) $ _ $ _) => ct |> (
eberlm@63319
   211
        bin then_conv rewr @{thms fps_of_poly_mult [symmetric]})
eberlm@63317
   212
    | (Const (@{const_name "Rings.divide"}, _) $ _ $ (Const (@{const_name "Num.numeral"}, _) $ _))
eberlm@63317
   213
        => ct |> (Conv.fun_conv (Conv.arg_conv reify_conv)
eberlm@63319
   214
             then_conv rewr @{thms fps_of_poly_divide_numeral [symmetric]})
eberlm@66480
   215
    | (Const (@{const_name "Power.power"}, _) $ Const (@{const_name "fps_X"},_) $ _) => ct |> (
eberlm@63319
   216
        rewr @{thms fps_of_poly_monom' [symmetric]}) 
eberlm@63317
   217
    | (Const (@{const_name "Power.power"}, _) $ _ $ _) => ct |> (
eberlm@63317
   218
        Conv.fun_conv (Conv.arg_conv reify_conv) 
eberlm@63319
   219
        then_conv rewr @{thms fps_of_poly_power [symmetric]})
eberlm@63317
   220
    | _ => ct |> (
eberlm@63317
   221
        rewr @{thms reify_fps_atom [symmetric]})
eberlm@63317
   222
  end
eberlm@63317
   223
    
eberlm@63317
   224
eberlm@63317
   225
fun eq_conv ct =
eberlm@63317
   226
  case Thm.term_of ct of
eberlm@63317
   227
    (Const (@{const_name "HOL.eq"}, _) $ _ $ _) => ct |> (
eberlm@63317
   228
      Conv.binop_conv reify_conv
eberlm@63319
   229
      then_conv Conv.rewr_conv @{thm fps_of_poly_eq_iff[THEN eq_reflection]})
eberlm@63317
   230
  | _ => raise CTERM ("poly_fps_eq_conv", [ct])
eberlm@63317
   231
eberlm@63317
   232
val eq_simproc = try eq_conv
eberlm@63317
   233
eberlm@63317
   234
end
eberlm@63317
   235
\<close> 
eberlm@63317
   236
eberlm@63317
   237
simproc_setup poly_fps_eq ("(f :: 'a fps) = g") = \<open>K (K Poly_Fps.eq_simproc)\<close>
eberlm@63317
   238
eberlm@66480
   239
lemma fps_of_poly_linear: "fps_of_poly [:a,1 :: 'a :: field:] = fps_X + fps_const a"
eberlm@63317
   240
  by simp
eberlm@63317
   241
eberlm@66480
   242
lemma fps_of_poly_linear': "fps_of_poly [:1,a :: 'a :: field:] = 1 + fps_const a * fps_X"
eberlm@63317
   243
  by simp
eberlm@63317
   244
eberlm@63319
   245
lemma fps_of_poly_cutoff [simp]: 
eberlm@63319
   246
  "fps_of_poly (poly_cutoff n p) = fps_cutoff n (fps_of_poly p)"
eberlm@63317
   247
  by (simp add: fps_eq_iff coeff_poly_cutoff)
eberlm@63317
   248
eberlm@63319
   249
lemma fps_of_poly_shift [simp]: "fps_of_poly (poly_shift n p) = fps_shift n (fps_of_poly p)"
eberlm@63317
   250
  by (simp add: fps_eq_iff coeff_poly_shift)
eberlm@63317
   251
eberlm@63317
   252
eberlm@63317
   253
definition poly_subdegree :: "'a::zero poly \<Rightarrow> nat" where
eberlm@63319
   254
  "poly_subdegree p = subdegree (fps_of_poly p)"
eberlm@63317
   255
eberlm@63317
   256
lemma coeff_less_poly_subdegree:
eberlm@63317
   257
  "k < poly_subdegree p \<Longrightarrow> coeff p k = 0"
eberlm@63319
   258
  unfolding poly_subdegree_def using nth_less_subdegree_zero[of k "fps_of_poly p"] by simp
eberlm@63317
   259
eberlm@63317
   260
(* TODO: Move ? *)
eberlm@63317
   261
definition prefix_length :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> nat" where
eberlm@63317
   262
  "prefix_length P xs = length (takeWhile P xs)"
eberlm@63317
   263
eberlm@63317
   264
primrec prefix_length_aux :: "('a \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 'a list \<Rightarrow> nat" where
eberlm@63317
   265
  "prefix_length_aux P acc [] = acc"
eberlm@63317
   266
| "prefix_length_aux P acc (x#xs) = (if P x then prefix_length_aux P (Suc acc) xs else acc)"
eberlm@63317
   267
eberlm@63317
   268
lemma prefix_length_aux_correct: "prefix_length_aux P acc xs = prefix_length P xs + acc"
eberlm@63317
   269
  by (induction xs arbitrary: acc) (simp_all add: prefix_length_def)
eberlm@63317
   270
eberlm@63317
   271
lemma prefix_length_code [code]: "prefix_length P xs = prefix_length_aux P 0 xs"
eberlm@63317
   272
  by (simp add: prefix_length_aux_correct)
eberlm@63317
   273
eberlm@63317
   274
lemma prefix_length_le_length: "prefix_length P xs \<le> length xs"
eberlm@63317
   275
  by (induction xs) (simp_all add: prefix_length_def)
eberlm@63317
   276
  
eberlm@63317
   277
lemma prefix_length_less_length: "(\<exists>x\<in>set xs. \<not>P x) \<Longrightarrow> prefix_length P xs < length xs"
eberlm@63317
   278
  by (induction xs) (simp_all add: prefix_length_def)
eberlm@63317
   279
eberlm@63317
   280
lemma nth_prefix_length:
eberlm@63317
   281
  "(\<exists>x\<in>set xs. \<not>P x) \<Longrightarrow> \<not>P (xs ! prefix_length P xs)"
eberlm@63317
   282
  by (induction xs) (simp_all add: prefix_length_def)
eberlm@63317
   283
  
eberlm@63317
   284
lemma nth_less_prefix_length:
eberlm@63317
   285
  "n < prefix_length P xs \<Longrightarrow> P (xs ! n)"
eberlm@63317
   286
  by (induction xs arbitrary: n) 
eberlm@63317
   287
     (auto simp: prefix_length_def nth_Cons split: if_splits nat.splits)
eberlm@63317
   288
(* END TODO *)
eberlm@63317
   289
  
eberlm@63317
   290
lemma poly_subdegree_code [code]: "poly_subdegree p = prefix_length (op = 0) (coeffs p)"
eberlm@63317
   291
proof (cases "p = 0")
eberlm@63317
   292
  case False
eberlm@63317
   293
  note [simp] = this
eberlm@63317
   294
  define n where "n = prefix_length (op = 0) (coeffs p)"
eberlm@63317
   295
  from False have "\<exists>k. coeff p k \<noteq> 0" by (auto simp: poly_eq_iff)
eberlm@63317
   296
  hence ex: "\<exists>x\<in>set (coeffs p). x \<noteq> 0" by (auto simp: coeffs_def)
eberlm@63317
   297
  hence n_less: "n < length (coeffs p)" and nonzero: "coeffs p ! n \<noteq> 0" 
eberlm@63317
   298
    unfolding n_def by (auto intro!: prefix_length_less_length nth_prefix_length)
eberlm@63317
   299
  show ?thesis unfolding poly_subdegree_def
eberlm@63317
   300
  proof (intro subdegreeI)
eberlm@63319
   301
    from n_less have "fps_of_poly p $ n = coeffs p ! n"
eberlm@63317
   302
      by (subst coeffs_nth) (simp_all add: degree_eq_length_coeffs)
eberlm@63319
   303
    with nonzero show "fps_of_poly p $ prefix_length (op = 0) (coeffs p) \<noteq> 0"
eberlm@63317
   304
      unfolding n_def by simp
eberlm@63317
   305
  next
eberlm@63317
   306
    fix k assume A: "k < prefix_length (op = 0) (coeffs p)"
eberlm@63317
   307
    also have "\<dots> \<le> length (coeffs p)" by (rule prefix_length_le_length)
eberlm@63319
   308
    finally show "fps_of_poly p $ k = 0"
eberlm@63317
   309
      using nth_less_prefix_length[OF A]
eberlm@63317
   310
      by (simp add: coeffs_nth degree_eq_length_coeffs)
eberlm@63317
   311
  qed
eberlm@63317
   312
qed (simp_all add: poly_subdegree_def prefix_length_def)
eberlm@63317
   313
eberlm@63317
   314
end
eberlm@66480
   315
eberlm@66480
   316
end