src/HOL/Library/Univ_Poly.thy
author wenzelm
Tue, 03 Sep 2013 01:12:40 +0200
changeset 53374 a14d2a854c02
parent 53196 942a1b48bb31
child 53636 9b5735de1f1a
permissions -rw-r--r--
tuned proofs -- clarified flow of facts wrt. calculation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
     1
(*  Title:      HOL/Library/Univ_Poly.thy
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
     2
    Author:     Amine Chaieb
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
     3
*)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
     4
29292
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
     5
header {* Univariate Polynomials *}
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
     6
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
     7
theory Univ_Poly
30738
0842e906300c normalized imports
haftmann
parents: 30488
diff changeset
     8
imports Main
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
     9
begin
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    10
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    11
text{* Application of polynomial as a function. *}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    12
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    13
primrec (in semiring_0) poly :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    14
where
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    15
  poly_Nil:  "poly [] x = 0"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    16
| poly_Cons: "poly (h#t) x = h + x * poly t x"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    17
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    18
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    19
subsection{*Arithmetic Operations on Polynomials*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    20
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    21
text{*addition*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    22
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
    23
primrec (in semiring_0) padd :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"  (infixl "+++" 65)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    24
where
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    25
  padd_Nil:  "[] +++ l2 = l2"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    26
| padd_Cons: "(h#t) +++ l2 = (if l2 = [] then h#t else (h + hd l2)#(t +++ tl l2))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    27
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    28
text{*Multiplication by a constant*}
26194
haftmann
parents: 26124
diff changeset
    29
primrec (in semiring_0) cmult :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list"  (infixl "%*" 70) where
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    30
  cmult_Nil:  "c %* [] = []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    31
| cmult_Cons: "c %* (h#t) = (c * h)#(c %* t)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    32
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    33
text{*Multiplication by a polynomial*}
26194
haftmann
parents: 26124
diff changeset
    34
primrec (in semiring_0) pmult :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"  (infixl "***" 70)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    35
where
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    36
  pmult_Nil:  "[] *** l2 = []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    37
| pmult_Cons: "(h#t) *** l2 = (if t = [] then h %* l2
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    38
                              else (h %* l2) +++ ((0) # (t *** l2)))"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    39
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    40
text{*Repeated multiplication by a polynomial*}
26194
haftmann
parents: 26124
diff changeset
    41
primrec (in semiring_0) mulexp :: "nat \<Rightarrow> 'a list \<Rightarrow> 'a  list \<Rightarrow> 'a list" where
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    42
  mulexp_zero:  "mulexp 0 p q = q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    43
| mulexp_Suc:   "mulexp (Suc n) p q = p *** mulexp n p q"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    44
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    45
text{*Exponential*}
26194
haftmann
parents: 26124
diff changeset
    46
primrec (in semiring_1) pexp :: "'a list \<Rightarrow> nat \<Rightarrow> 'a list"  (infixl "%^" 80) where
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    47
  pexp_0:   "p %^ 0 = [1]"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    48
| pexp_Suc: "p %^ (Suc n) = p *** (p %^ n)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    49
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    50
text{*Quotient related value of dividing a polynomial by x + a*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    51
(* Useful for divisor properties in inductive proofs *)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    52
primrec (in field) "pquot" :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    53
where
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    54
  pquot_Nil:  "pquot [] a= []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    55
| pquot_Cons: "pquot (h#t) a =
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    56
    (if t = [] then [h] else (inverse(a) * (h - hd( pquot t a)))#(pquot t a))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    57
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    58
text{*normalization of polynomials (remove extra 0 coeff)*}
26194
haftmann
parents: 26124
diff changeset
    59
primrec (in semiring_0) pnormalize :: "'a list \<Rightarrow> 'a list" where
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    60
  pnormalize_Nil:  "pnormalize [] = []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    61
| pnormalize_Cons: "pnormalize (h#p) =
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    62
    (if pnormalize p = [] then (if h = 0 then [] else [h]) else h # pnormalize p)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    63
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    64
definition (in semiring_0) "pnormal p = ((pnormalize p = p) \<and> p \<noteq> [])"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    65
definition (in semiring_0) "nonconstant p = (pnormal p \<and> (\<forall>x. p \<noteq> [x]))"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    66
text{*Other definitions*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    67
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    68
definition (in ring_1) poly_minus :: "'a list \<Rightarrow> 'a list" ("-- _" [80] 80)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    69
  where "-- p = (- 1) %* p"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    70
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    71
definition (in semiring_0) divides :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"  (infixl "divides" 70)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    72
  where "p1 divides p2 = (\<exists>q. poly p2 = poly(p1 *** q))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    73
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    74
    --{*order of a polynomial*}
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    75
definition (in ring_1) order :: "'a \<Rightarrow> 'a list \<Rightarrow> nat" where
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    76
  "order a p = (SOME n. ([-a, 1] %^ n) divides p \<and> ~ (([-a, 1] %^ (Suc n)) divides p))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    77
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    78
     --{*degree of a polynomial*}
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    79
definition (in semiring_0) degree :: "'a list \<Rightarrow> nat"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    80
  where "degree p = length (pnormalize p) - 1"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    81
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    82
     --{*squarefree polynomials --- NB with respect to real roots only.*}
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    83
definition (in ring_1) rsquarefree :: "'a list \<Rightarrow> bool"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    84
  where "rsquarefree p \<longleftrightarrow> poly p \<noteq> poly [] \<and> (\<forall>a. order a p = 0 \<or> order a p = 1)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    85
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    86
context semiring_0
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    87
begin
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    88
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    89
lemma padd_Nil2[simp]: "p +++ [] = p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    90
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    91
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    92
lemma padd_Cons_Cons: "(h1 # p1) +++ (h2 # p2) = (h1 + h2) # (p1 +++ p2)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    93
  by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    94
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
    95
lemma pminus_Nil: "-- [] = []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    96
  by (simp add: poly_minus_def)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    97
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
    98
lemma pmult_singleton: "[h1] *** p1 = h1 %* p1" by simp
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
    99
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   100
end
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   101
46730
e3b99d0231bc tuned proofs;
wenzelm
parents: 45129
diff changeset
   102
lemma (in semiring_1) poly_ident_mult[simp]: "1 %* t = t" by (induct t) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   103
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   104
lemma (in semiring_0) poly_simple_add_Cons[simp]: "[a] +++ ((0)#t) = (a#t)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   105
  by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   106
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   107
text{*Handy general properties*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   108
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   109
lemma (in comm_semiring_0) padd_commut: "b +++ a = a +++ b"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   110
proof (induct b arbitrary: a)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   111
  case Nil
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   112
  thus ?case by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   113
next
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   114
  case (Cons b bs a)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   115
  thus ?case by (cases a) (simp_all add: add_commute)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   116
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   117
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   118
lemma (in comm_semiring_0) padd_assoc: "\<forall>b c. (a +++ b) +++ c = a +++ (b +++ c)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   119
  apply (induct a)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   120
  apply (simp, clarify)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   121
  apply (case_tac b, simp_all add: add_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   122
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   123
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   124
lemma (in semiring_0) poly_cmult_distr: "a %* ( p +++ q) = (a %* p +++ a %* q)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   125
  apply (induct p arbitrary: q)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   126
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   127
  apply (case_tac q, simp_all add: distrib_left)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   128
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   129
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   130
lemma (in ring_1) pmult_by_x[simp]: "[0, 1] *** t = ((0)#t)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   131
  apply (induct t)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   132
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   133
  apply (auto simp add: padd_commut)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   134
  apply (case_tac t, auto)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   135
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   136
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   137
text{*properties of evaluation of polynomials.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   138
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   139
lemma (in semiring_0) poly_add: "poly (p1 +++ p2) x = poly p1 x + poly p2 x"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   140
proof(induct p1 arbitrary: p2)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   141
  case Nil
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   142
  thus ?case by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   143
next
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   144
  case (Cons a as p2)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   145
  thus ?case
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   146
    by (cases p2) (simp_all  add: add_ac distrib_left)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   147
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   148
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   149
lemma (in comm_semiring_0) poly_cmult: "poly (c %* p) x = c * poly p x"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   150
  apply (induct p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   151
  apply (case_tac [2] "x = zero")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   152
  apply (auto simp add: distrib_left mult_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   153
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   154
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   155
lemma (in comm_semiring_0) poly_cmult_map: "poly (map (op * c) p) x = c*poly p x"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   156
  by (induct p) (auto simp add: distrib_left mult_ac)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   157
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   158
lemma (in comm_ring_1) poly_minus: "poly (-- p) x = - (poly p x)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   159
  apply (simp add: poly_minus_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   160
  apply (auto simp add: poly_cmult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   161
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   162
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   163
lemma (in comm_semiring_0) poly_mult: "poly (p1 *** p2) x = poly p1 x * poly p2 x"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   164
proof (induct p1 arbitrary: p2)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   165
  case Nil
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   166
  thus ?case by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   167
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   168
  case (Cons a as p2)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   169
  thus ?case by (cases as)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   170
    (simp_all add: poly_cmult poly_add distrib_right distrib_left mult_ac)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   171
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   172
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   173
class idom_char_0 = idom + ring_char_0
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   174
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   175
lemma (in comm_ring_1) poly_exp: "poly (p %^ n) x = (poly p x) ^ n"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   176
  by (induct n) (auto simp add: poly_cmult poly_mult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   177
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   178
text{*More Polynomial Evaluation Lemmas*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   179
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   180
lemma (in semiring_0) poly_add_rzero[simp]: "poly (a +++ []) x = poly a x"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   181
  by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   182
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   183
lemma (in comm_semiring_0) poly_mult_assoc: "poly ((a *** b) *** c) x = poly (a *** (b *** c)) x"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   184
  by (simp add: poly_mult mult_assoc)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   185
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   186
lemma (in semiring_0) poly_mult_Nil2[simp]: "poly (p *** []) x = 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   187
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   188
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   189
lemma (in comm_semiring_1) poly_exp_add: "poly (p %^ (n + d)) x = poly( p %^ n *** p %^ d) x"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   190
  by (induct n) (auto simp add: poly_mult mult_assoc)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   191
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   192
subsection{*Key Property: if @{term "f(a) = 0"} then @{term "(x - a)"} divides
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   193
 @{term "p(x)"} *}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   194
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   195
lemma (in comm_ring_1) lemma_poly_linear_rem: "\<forall>h. \<exists>q r. h#t = [r] +++ [-a, 1] *** q"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   196
proof(induct t)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   197
  case Nil
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   198
  { fix h have "[h] = [h] +++ [- a, 1] *** []" by simp }
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   199
  thus ?case by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   200
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   201
  case (Cons  x xs)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   202
  { fix h
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   203
    from Cons.hyps[rule_format, of x]
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   204
    obtain q r where qr: "x#xs = [r] +++ [- a, 1] *** q" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   205
    have "h#x#xs = [a*r + h] +++ [-a, 1] *** (r#q)"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   206
      using qr by (cases q) (simp_all add: algebra_simps)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   207
    hence "\<exists>q r. h#x#xs = [r] +++ [-a, 1] *** q" by blast}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   208
  thus ?case by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   209
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   210
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   211
lemma (in comm_ring_1) poly_linear_rem: "\<exists>q r. h#t = [r] +++ [-a, 1] *** q"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   212
  using lemma_poly_linear_rem [where t = t and a = a] by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   213
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   214
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   215
lemma (in comm_ring_1) poly_linear_divides: "(poly p a = 0) = ((p = []) | (\<exists>q. p = [-a, 1] *** q))"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   216
proof -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   217
  { assume p: "p = []" hence ?thesis by simp }
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   218
  moreover
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   219
  {
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   220
    fix x xs assume p: "p = x#xs"
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   221
    {
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   222
      fix q assume "p = [-a, 1] *** q"
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   223
      hence "poly p a = 0" by (simp add: poly_add poly_cmult)
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   224
    }
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   225
    moreover
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   226
    { assume p0: "poly p a = 0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   227
      from poly_linear_rem[of x xs a] obtain q r
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   228
      where qr: "x#xs = [r] +++ [- a, 1] *** q" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   229
      have "r = 0" using p0 by (simp only: p qr poly_mult poly_add) simp
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   230
      hence "\<exists>q. p = [- a, 1] *** q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   231
        using p qr
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   232
        apply -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   233
        apply (rule exI[where x=q])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   234
        apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   235
        apply (cases q)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   236
        apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   237
        done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   238
    }
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   239
    ultimately have ?thesis using p by blast
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   240
  }
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   241
  ultimately show ?thesis by (cases p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   242
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   243
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   244
lemma (in semiring_0) lemma_poly_length_mult[simp]: "\<forall>h k a. length (k %* p +++  (h # (a %* p))) = Suc (length p)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   245
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   246
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   247
lemma (in semiring_0) lemma_poly_length_mult2[simp]: "\<forall>h k. length (k %* p +++  (h # p)) = Suc (length p)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   248
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   249
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   250
lemma (in ring_1) poly_length_mult[simp]: "length([-a,1] *** q) = Suc (length q)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   251
  by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   252
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   253
subsection{*Polynomial length*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   254
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   255
lemma (in semiring_0) poly_cmult_length[simp]: "length (a %* p) = length p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   256
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   257
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   258
lemma (in semiring_0) poly_add_length: "length (p1 +++ p2) = max (length p1) (length p2)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   259
  by (induct p1 arbitrary: p2) (simp_all, arith)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   260
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   261
lemma (in semiring_0) poly_root_mult_length[simp]: "length([a,b] *** p) = Suc (length p)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   262
  by (simp add: poly_add_length)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   263
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   264
lemma (in idom) poly_mult_not_eq_poly_Nil[simp]:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   265
  "poly (p *** q) x \<noteq> poly [] x \<longleftrightarrow> poly p x \<noteq> poly [] x \<and> poly q x \<noteq> poly [] x"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   266
  by (auto simp add: poly_mult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   267
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   268
lemma (in idom) poly_mult_eq_zero_disj: "poly (p *** q) x = 0 \<longleftrightarrow> poly p x = 0 \<or> poly q x = 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   269
  by (auto simp add: poly_mult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   270
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   271
text{*Normalisation Properties*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   272
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   273
lemma (in semiring_0) poly_normalized_nil: "(pnormalize p = []) --> (poly p x = 0)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   274
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   275
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   276
text{*A nontrivial polynomial of degree n has no more than n roots*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   277
lemma (in idom) poly_roots_index_lemma:
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   278
   assumes p: "poly p x \<noteq> poly [] x" and n: "length p = n"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   279
  shows "\<exists>i. \<forall>x. poly p x = 0 \<longrightarrow> (\<exists>m\<le>n. x = i m)"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   280
  using p n
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   281
proof (induct n arbitrary: p x)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   282
  case 0
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   283
  thus ?case by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   284
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   285
  case (Suc n p x)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   286
  {
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   287
    assume C: "\<And>i. \<exists>x. poly p x = 0 \<and> (\<forall>m\<le>Suc n. x \<noteq> i m)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   288
    from Suc.prems have p0: "poly p x \<noteq> 0" "p\<noteq> []" by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   289
    from p0(1)[unfolded poly_linear_divides[of p x]]
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   290
    have "\<forall>q. p \<noteq> [- x, 1] *** q" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   291
    from C obtain a where a: "poly p a = 0" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   292
    from a[unfolded poly_linear_divides[of p a]] p0(2)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   293
    obtain q where q: "p = [-a, 1] *** q" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   294
    have lg: "length q = n" using q Suc.prems(2) by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   295
    from q p0 have qx: "poly q x \<noteq> poly [] x"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   296
      by (auto simp add: poly_mult poly_add poly_cmult)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   297
    from Suc.hyps[OF qx lg] obtain i where
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   298
      i: "\<forall>x. poly q x = 0 \<longrightarrow> (\<exists>m\<le>n. x = i m)" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   299
    let ?i = "\<lambda>m. if m = Suc n then a else i m"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   300
    from C[of ?i] obtain y where y: "poly p y = 0" "\<forall>m\<le> Suc n. y \<noteq> ?i m"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   301
      by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   302
    from y have "y = a \<or> poly q y = 0"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29504
diff changeset
   303
      by (simp only: q poly_mult_eq_zero_disj poly_add) (simp add: algebra_simps)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   304
    with i[rule_format, of y] y(1) y(2) have False
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   305
      apply auto
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   306
      apply (erule_tac x = "m" in allE)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   307
      apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   308
      done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   309
  }
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   310
  thus ?case by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   311
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   312
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   313
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   314
lemma (in idom) poly_roots_index_length:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   315
  "poly p x \<noteq> poly [] x \<Longrightarrow> \<exists>i. \<forall>x. (poly p x = 0) \<longrightarrow> (\<exists>n. n \<le> length p \<and> x = i n)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   316
  by (blast intro: poly_roots_index_lemma)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   317
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   318
lemma (in idom) poly_roots_finite_lemma1:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   319
  "poly p x \<noteq> poly [] x \<Longrightarrow> \<exists>N i. \<forall>x. (poly p x = 0) \<longrightarrow> (\<exists>n. (n::nat) < N \<and> x = i n)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   320
  apply (drule poly_roots_index_length, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   321
  apply (rule_tac x = "Suc (length p)" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   322
  apply (rule_tac x = i in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   323
  apply (simp add: less_Suc_eq_le)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   324
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   325
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   326
lemma (in idom) idom_finite_lemma:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   327
  assumes P: "\<forall>x. P x --> (\<exists>n. n < length j \<and> x = j!n)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   328
  shows "finite {x. P x}"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   329
proof -
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   330
  let ?M = "{x. P x}"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   331
  let ?N = "set j"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   332
  have "?M \<subseteq> ?N" using P by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   333
  thus ?thesis using finite_subset by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   334
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   335
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   336
lemma (in idom) poly_roots_finite_lemma2:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   337
  "poly p x \<noteq> poly [] x \<Longrightarrow> \<exists>i. \<forall>x. poly p x = 0 \<longrightarrow> x \<in> set i"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   338
  apply (drule poly_roots_index_length, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   339
  apply (rule_tac x="map (\<lambda>n. i n) [0 ..< Suc (length p)]" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   340
  apply (auto simp add: image_iff)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   341
  apply (erule_tac x="x" in allE, clarsimp)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   342
  apply (case_tac "n = length p")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   343
  apply (auto simp add: order_le_less)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   344
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   345
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   346
lemma (in ring_char_0) UNIV_ring_char_0_infinte: "\<not> (finite (UNIV:: 'a set))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   347
proof
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   348
  assume F: "finite (UNIV :: 'a set)"
29292
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   349
  have "finite (UNIV :: nat set)"
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   350
  proof (rule finite_imageD)
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   351
    have "of_nat ` UNIV \<subseteq> UNIV" by simp
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   352
    then show "finite (of_nat ` UNIV :: 'a set)" using F by (rule finite_subset)
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   353
    show "inj (of_nat :: nat \<Rightarrow> 'a)" by (simp add: inj_on_def)
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   354
  qed
29879
4425849f5db7 Moved FTA into Lib and cleaned it up a little.
nipkow
parents: 29667
diff changeset
   355
  with infinite_UNIV_nat show False ..
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   356
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   357
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   358
lemma (in idom_char_0) poly_roots_finite: "poly p \<noteq> poly [] \<longleftrightarrow> finite {x. poly p x = 0}"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   359
proof
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   360
  assume H: "poly p \<noteq> poly []"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   361
  show "finite {x. poly p x = (0::'a)}"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   362
    using H
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   363
    apply -
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   364
    apply (erule contrapos_np, rule ext)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   365
    apply (rule ccontr)
26313
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   366
    apply (clarify dest!: poly_roots_finite_lemma2)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   367
    using finite_subset
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   368
  proof -
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   369
    fix x i
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   370
    assume F: "\<not> finite {x. poly p x = (0\<Colon>'a)}"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   371
      and P: "\<forall>x. poly p x = (0\<Colon>'a) \<longrightarrow> x \<in> set i"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   372
    let ?M= "{x. poly p x = (0\<Colon>'a)}"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   373
    from P have "?M \<subseteq> set i" by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   374
    with finite_subset F show False by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   375
  qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   376
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   377
  assume F: "finite {x. poly p x = (0\<Colon>'a)}"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   378
  show "poly p \<noteq> poly []" using F UNIV_ring_char_0_infinte by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   379
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   380
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   381
text{*Entirety and Cancellation for polynomials*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   382
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   383
lemma (in idom_char_0) poly_entire_lemma2:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   384
  assumes p0: "poly p \<noteq> poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   385
    and q0: "poly q \<noteq> poly []"
26313
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   386
  shows "poly (p***q) \<noteq> poly []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   387
proof -
26313
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   388
  let ?S = "\<lambda>p. {x. poly p x = 0}"
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   389
  have "?S (p *** q) = ?S p \<union> ?S q" by (auto simp add: poly_mult)
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   390
  with p0 q0 show ?thesis  unfolding poly_roots_finite by auto
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   391
qed
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   392
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   393
lemma (in idom_char_0) poly_entire:
26313
8590bf5ef343 avoid rebinding of existing facts;
wenzelm
parents: 26194
diff changeset
   394
  "poly (p *** q) = poly [] \<longleftrightarrow> poly p = poly [] \<or> poly q = poly []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   395
  using poly_entire_lemma2[of p q]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   396
  by (auto simp add: fun_eq_iff poly_mult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   397
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   398
lemma (in idom_char_0) poly_entire_neg:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   399
  "poly (p *** q) \<noteq> poly [] \<longleftrightarrow> poly p \<noteq> poly [] \<and> poly q \<noteq> poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   400
  by (simp add: poly_entire)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   401
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   402
lemma fun_eq: "f = g \<longleftrightarrow> (\<forall>x. f x = g x)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   403
  by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   404
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   405
lemma (in comm_ring_1) poly_add_minus_zero_iff:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   406
  "poly (p +++ -- q) = poly [] \<longleftrightarrow> poly p = poly q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   407
  by (auto simp add: algebra_simps poly_add poly_minus_def fun_eq poly_cmult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   408
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   409
lemma (in comm_ring_1) poly_add_minus_mult_eq:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   410
  "poly (p *** q +++ --(p *** r)) = poly (p *** (q +++ -- r))"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   411
  by (auto simp add: poly_add poly_minus_def fun_eq poly_mult poly_cmult distrib_left)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   412
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 28562
diff changeset
   413
subclass (in idom_char_0) comm_ring_1 ..
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   414
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   415
lemma (in idom_char_0) poly_mult_left_cancel:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   416
  "poly (p *** q) = poly (p *** r) \<longleftrightarrow> poly p = poly [] \<or> poly q = poly r"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   417
proof -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   418
  have "poly (p *** q) = poly (p *** r) \<longleftrightarrow> poly (p *** q +++ -- (p *** r)) = poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   419
    by (simp only: poly_add_minus_zero_iff)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   420
  also have "\<dots> \<longleftrightarrow> poly p = poly [] \<or> poly q = poly r"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   421
    by (auto intro: simp add: poly_add_minus_mult_eq poly_entire poly_add_minus_zero_iff)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   422
  finally show ?thesis .
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   423
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   424
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   425
lemma (in idom) poly_exp_eq_zero[simp]:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   426
  "poly (p %^ n) = poly [] \<longleftrightarrow> poly p = poly [] \<and> n \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   427
  apply (simp only: fun_eq add: HOL.all_simps [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   428
  apply (rule arg_cong [where f = All])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   429
  apply (rule ext)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   430
  apply (induct n)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   431
  apply (auto simp add: poly_exp poly_mult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   432
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   433
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   434
lemma (in comm_ring_1) poly_prime_eq_zero[simp]: "poly [a,1] \<noteq> poly []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   435
  apply (simp add: fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   436
  apply (rule_tac x = "minus one a" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   437
  apply (unfold diff_minus)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   438
  apply (subst add_commute)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   439
  apply (subst add_assoc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   440
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   441
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   442
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   443
lemma (in idom) poly_exp_prime_eq_zero: "poly ([a, 1] %^ n) \<noteq> poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   444
  by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   445
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   446
text{*A more constructive notion of polynomials being trivial*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   447
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   448
lemma (in idom_char_0) poly_zero_lemma': "poly (h # t) = poly [] \<Longrightarrow> h = 0 \<and> poly t = poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   449
  apply (simp add: fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   450
  apply (case_tac "h = zero")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   451
  apply (drule_tac [2] x = zero in spec, auto)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   452
  apply (cases "poly t = poly []", simp)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   453
proof -
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   454
  fix x
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   455
  assume H: "\<forall>x. x = (0\<Colon>'a) \<or> poly t x = (0\<Colon>'a)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   456
    and pnz: "poly t \<noteq> poly []"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   457
  let ?S = "{x. poly t x = 0}"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   458
  from H have "\<forall>x. x \<noteq>0 \<longrightarrow> poly t x = 0" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   459
  hence th: "?S \<supseteq> UNIV - {0}" by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   460
  from poly_roots_finite pnz have th': "finite ?S" by blast
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   461
  from finite_subset[OF th th'] UNIV_ring_char_0_infinte show "poly t x = (0\<Colon>'a)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   462
    by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   463
qed
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   464
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   465
lemma (in idom_char_0) poly_zero: "(poly p = poly []) = list_all (%c. c = 0) p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   466
  apply (induct p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   467
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   468
  apply (rule iffI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   469
  apply (drule poly_zero_lemma', auto)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   470
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   471
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   472
lemma (in idom_char_0) poly_0: "list_all (\<lambda>c. c = 0) p \<Longrightarrow> poly p x = 0"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   473
  unfolding poly_zero[symmetric] by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   474
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   475
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   476
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   477
text{*Basics of divisibility.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   478
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   479
lemma (in idom) poly_primes:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   480
  "[a, 1] divides (p *** q) \<longleftrightarrow> [a, 1] divides p \<or> [a, 1] divides q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   481
  apply (auto simp add: divides_def fun_eq poly_mult poly_add poly_cmult distrib_right [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   482
  apply (drule_tac x = "uminus a" in spec)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   483
  apply (simp add: poly_linear_divides poly_add poly_cmult distrib_right [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   484
  apply (cases "p = []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   485
  apply (rule exI[where x="[]"])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   486
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   487
  apply (cases "q = []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   488
  apply (erule allE[where x="[]"], simp)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   489
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   490
  apply clarsimp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   491
  apply (cases "\<exists>q\<Colon>'a list. p = a %* q +++ ((0\<Colon>'a) # q)")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   492
  apply (clarsimp simp add: poly_add poly_cmult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   493
  apply (rule_tac x="qa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   494
  apply (simp add: distrib_right [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   495
  apply clarsimp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   496
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   497
  apply (auto simp add: poly_linear_divides poly_add poly_cmult distrib_right [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   498
  apply (rule_tac x = "pmult qa q" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   499
  apply (rule_tac [2] x = "pmult p qa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   500
  apply (auto simp add: poly_add poly_mult poly_cmult mult_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   501
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   502
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   503
lemma (in comm_semiring_1) poly_divides_refl[simp]: "p divides p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   504
  apply (simp add: divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   505
  apply (rule_tac x = "[one]" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   506
  apply (auto simp add: poly_mult fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   507
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   508
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   509
lemma (in comm_semiring_1) poly_divides_trans: "p divides q \<Longrightarrow> q divides r \<Longrightarrow> p divides r"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   510
  apply (simp add: divides_def, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   511
  apply (rule_tac x = "pmult qa qaa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   512
  apply (auto simp add: poly_mult fun_eq mult_assoc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   513
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   514
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   515
lemma (in comm_semiring_1) poly_divides_exp: "m \<le> n \<Longrightarrow> (p %^ m) divides (p %^ n)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   516
  apply (auto simp add: le_iff_add)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   517
  apply (induct_tac k)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   518
  apply (rule_tac [2] poly_divides_trans)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   519
  apply (auto simp add: divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   520
  apply (rule_tac x = p in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   521
  apply (auto simp add: poly_mult fun_eq mult_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   522
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   523
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   524
lemma (in comm_semiring_1) poly_exp_divides:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   525
  "(p %^ n) divides q \<Longrightarrow> m \<le> n \<Longrightarrow> (p %^ m) divides q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   526
  by (blast intro: poly_divides_exp poly_divides_trans)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   527
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   528
lemma (in comm_semiring_0) poly_divides_add:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   529
  "p divides q \<Longrightarrow> p divides r \<Longrightarrow> p divides (q +++ r)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   530
  apply (simp add: divides_def, auto)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   531
  apply (rule_tac x = "padd qa qaa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   532
  apply (auto simp add: poly_add fun_eq poly_mult distrib_left)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   533
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   534
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   535
lemma (in comm_ring_1) poly_divides_diff:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   536
  "p divides q \<Longrightarrow> p divides (q +++ r) \<Longrightarrow> p divides r"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   537
  apply (simp add: divides_def, auto)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   538
  apply (rule_tac x = "padd qaa (poly_minus qa)" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   539
  apply (auto simp add: poly_add fun_eq poly_mult poly_minus algebra_simps)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   540
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   541
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   542
lemma (in comm_ring_1) poly_divides_diff2:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   543
  "p divides r \<Longrightarrow> p divides (q +++ r) \<Longrightarrow> p divides q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   544
  apply (erule poly_divides_diff)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   545
  apply (auto simp add: poly_add fun_eq poly_mult divides_def add_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   546
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   547
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   548
lemma (in semiring_0) poly_divides_zero: "poly p = poly [] \<Longrightarrow> q divides p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   549
  apply (simp add: divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   550
  apply (rule exI[where x="[]"])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   551
  apply (auto simp add: fun_eq poly_mult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   552
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   553
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   554
lemma (in semiring_0) poly_divides_zero2 [simp]: "q divides []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   555
  apply (simp add: divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   556
  apply (rule_tac x = "[]" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   557
  apply (auto simp add: fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   558
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   559
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   560
text{*At last, we can consider the order of a root.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   561
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   562
lemma (in idom_char_0) poly_order_exists_lemma:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   563
  assumes lp: "length p = d"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   564
    and p: "poly p \<noteq> poly []"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   565
  shows "\<exists>n q. p = mulexp n [-a, 1] q \<and> poly q a \<noteq> 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   566
  using lp p
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   567
proof (induct d arbitrary: p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   568
  case 0
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   569
  thus ?case by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   570
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   571
  case (Suc n p)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   572
  show ?case
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   573
  proof (cases "poly p a = 0")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   574
    case True
29292
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   575
    from Suc.prems have h: "length p = Suc n" "poly p \<noteq> poly []" by auto
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 28952
diff changeset
   576
    hence pN: "p \<noteq> []" by auto
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   577
    from True[unfolded poly_linear_divides] pN obtain q where q: "p = [-a, 1] *** q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   578
      by blast
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   579
    from q h True have qh: "length q = n" "poly q \<noteq> poly []"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   580
      apply -
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   581
      apply simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   582
      apply (simp only: fun_eq)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   583
      apply (rule ccontr)
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   584
      apply (simp add: fun_eq poly_add poly_cmult)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   585
      done
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   586
    from Suc.hyps[OF qh] obtain m r where mr: "q = mulexp m [-a,1] r" "poly r a \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   587
      by blast
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   588
    from mr q have "p = mulexp (Suc m) [-a,1] r \<and> poly r a \<noteq> 0" by simp
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   589
    then show ?thesis by blast
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   590
  next
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   591
    case False
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   592
    then show ?thesis
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   593
      using Suc.prems
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   594
      apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   595
      apply (rule exI[where x="0::nat"])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   596
      apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   597
      done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   598
  qed
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   599
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   600
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   601
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   602
lemma (in comm_semiring_1) poly_mulexp: "poly (mulexp n p q) x = (poly p x) ^ n * poly q x"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   603
  by (induct n) (auto simp add: poly_mult mult_ac)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   604
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   605
lemma (in comm_semiring_1) divides_left_mult:
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   606
  assumes d:"(p***q) divides r" shows "p divides r \<and> q divides r"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   607
proof-
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   608
  from d obtain t where r:"poly r = poly (p***q *** t)"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   609
    unfolding divides_def by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   610
  hence "poly r = poly (p *** (q *** t))"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   611
    "poly r = poly (q *** (p***t))" by(auto simp add: fun_eq poly_mult mult_ac)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   612
  thus ?thesis unfolding divides_def by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   613
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   614
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   615
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   616
(* FIXME: Tidy up *)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   617
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   618
lemma (in semiring_1) zero_power_iff: "0 ^ n = (if n = 0 then 1 else 0)"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   619
  by (induct n) simp_all
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   620
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   621
lemma (in idom_char_0) poly_order_exists:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   622
  assumes "length p = d" and "poly p \<noteq> poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   623
  shows "\<exists>n. ([-a, 1] %^ n) divides p \<and> ~(([-a, 1] %^ (Suc n)) divides p)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   624
  using assms
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   625
  apply -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   626
  apply (drule poly_order_exists_lemma [where a=a], assumption, clarify)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   627
  apply (rule_tac x = n in exI, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   628
  apply (unfold divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   629
  apply (rule_tac x = q in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   630
  apply (induct_tac n, simp)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   631
  apply (simp (no_asm_simp) add: poly_add poly_cmult poly_mult distrib_left mult_ac)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   632
  apply safe
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   633
  apply (subgoal_tac "poly (mulexp n [uminus a, one] q) \<noteq>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   634
    poly (pmult (pexp [uminus a, one] (Suc n)) qa)")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   635
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   636
  apply (induct_tac n)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   637
  apply (simp del: pmult_Cons pexp_Suc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   638
  apply (erule_tac Q = "poly q a = zero" in contrapos_np)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   639
  apply (simp add: poly_add poly_cmult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   640
  apply (rule pexp_Suc [THEN ssubst])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   641
  apply (rule ccontr)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   642
  apply (simp add: poly_mult_left_cancel poly_mult_assoc del: pmult_Cons pexp_Suc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   643
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   644
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   645
lemma (in semiring_1) poly_one_divides[simp]: "[1] divides p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   646
  by (auto simp add: divides_def)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   647
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   648
lemma (in idom_char_0) poly_order:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   649
  "poly p \<noteq> poly [] \<Longrightarrow> \<exists>!n. ([-a, 1] %^ n) divides p \<and> \<not> (([-a, 1] %^ Suc n) divides p)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   650
  apply (auto intro: poly_order_exists simp add: less_linear simp del: pmult_Cons pexp_Suc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   651
  apply (cut_tac x = y and y = n in less_linear)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   652
  apply (drule_tac m = n in poly_exp_divides)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   653
  apply (auto dest: Suc_le_eq [THEN iffD2, THEN [2] poly_exp_divides]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   654
              simp del: pmult_Cons pexp_Suc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   655
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   656
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   657
text{*Order*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   658
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   659
lemma some1_equalityD: "n = (SOME n. P n) \<Longrightarrow> \<exists>!n. P n \<Longrightarrow> P n"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   660
  by (blast intro: someI2)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   661
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   662
lemma (in idom_char_0) order:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   663
      "(([-a, 1] %^ n) divides p \<and>
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   664
        ~(([-a, 1] %^ (Suc n)) divides p)) =
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   665
        ((n = order a p) \<and> ~(poly p = poly []))"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   666
  apply (unfold order_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   667
  apply (rule iffI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   668
  apply (blast dest: poly_divides_zero intro!: some1_equality [symmetric] poly_order)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   669
  apply (blast intro!: poly_order [THEN [2] some1_equalityD])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   670
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   671
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   672
lemma (in idom_char_0) order2:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   673
  "poly p \<noteq> poly [] \<Longrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   674
    ([-a, 1] %^ (order a p)) divides p \<and> \<not> (([-a, 1] %^ (Suc (order a p))) divides p)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   675
  by (simp add: order del: pexp_Suc)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   676
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   677
lemma (in idom_char_0) order_unique:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   678
  "poly p \<noteq> poly [] \<Longrightarrow> ([-a, 1] %^ n) divides p \<Longrightarrow> ~(([-a, 1] %^ (Suc n)) divides p) \<Longrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   679
    n = order a p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   680
  using order [of a n p] by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   681
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   682
lemma (in idom_char_0) order_unique_lemma:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   683
  "poly p \<noteq> poly [] \<and> ([-a, 1] %^ n) divides p \<and> ~(([-a, 1] %^ (Suc n)) divides p) \<Longrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   684
    n = order a p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   685
  by (blast intro: order_unique)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   686
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   687
lemma (in ring_1) order_poly: "poly p = poly q \<Longrightarrow> order a p = order a q"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   688
  by (auto simp add: fun_eq divides_def poly_mult order_def)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   689
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   690
lemma (in semiring_1) pexp_one[simp]: "p %^ (Suc 0) = p"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   691
  by (induct "p") auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   692
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   693
lemma (in comm_ring_1) lemma_order_root:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   694
  "0 < n \<and> [- a, 1] %^ n divides p \<and> ~ [- a, 1] %^ (Suc n) divides p \<Longrightarrow> poly p a = 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   695
  by (induct n arbitrary: a p) (auto simp add: divides_def poly_mult simp del: pmult_Cons)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   696
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   697
lemma (in idom_char_0) order_root:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   698
  "poly p a = 0 \<longleftrightarrow> poly p = poly [] \<or> order a p \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   699
  apply (cases "poly p = poly []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   700
  apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   701
  apply (simp add: poly_linear_divides del: pmult_Cons, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   702
  apply (drule_tac [!] a = a in order2)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   703
  apply (rule ccontr)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   704
  apply (simp add: divides_def poly_mult fun_eq del: pmult_Cons, blast)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   705
  using neq0_conv
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   706
  apply (blast intro: lemma_order_root)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   707
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   708
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   709
lemma (in idom_char_0) order_divides:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   710
  "([-a, 1] %^ n) divides p \<longleftrightarrow> poly p = poly [] \<or> n \<le> order a p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   711
  apply (cases "poly p = poly []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   712
  apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   713
  apply (simp add: divides_def fun_eq poly_mult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   714
  apply (rule_tac x = "[]" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   715
  apply (auto dest!: order2 [where a=a] intro: poly_exp_divides simp del: pexp_Suc)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   716
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   717
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   718
lemma (in idom_char_0) order_decomp:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   719
  "poly p \<noteq> poly [] \<Longrightarrow> \<exists>q. poly p = poly (([-a, 1] %^ (order a p)) *** q) \<and> ~([-a, 1] divides q)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   720
  apply (unfold divides_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   721
  apply (drule order2 [where a = a])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   722
  apply (simp add: divides_def del: pexp_Suc pmult_Cons, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   723
  apply (rule_tac x = q in exI, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   724
  apply (drule_tac x = qa in spec)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   725
  apply (auto simp add: poly_mult fun_eq poly_exp mult_ac simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   726
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   727
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   728
text{*Important composition properties of orders.*}
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   729
lemma order_mult:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   730
  "poly (p *** q) \<noteq> poly [] \<Longrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   731
    order a (p *** q) = order a p + order (a::'a::{idom_char_0}) q"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   732
  apply (cut_tac a = a and p = "p *** q" and n = "order a p + order a q" in order)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   733
  apply (auto simp add: poly_entire simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   734
  apply (drule_tac a = a in order2)+
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   735
  apply safe
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   736
  apply (simp add: divides_def fun_eq poly_exp_add poly_mult del: pmult_Cons, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   737
  apply (rule_tac x = "qa *** qaa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   738
  apply (simp add: poly_mult mult_ac del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   739
  apply (drule_tac a = a in order_decomp)+
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   740
  apply safe
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   741
  apply (subgoal_tac "[-a,1] divides (qa *** qaa) ")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   742
  apply (simp add: poly_primes del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   743
  apply (auto simp add: divides_def simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   744
  apply (rule_tac x = qb in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   745
  apply (subgoal_tac "poly ([-a, 1] %^ (order a p) *** (qa *** qaa)) = poly ([-a, 1] %^ (order a p) *** ([-a, 1] *** qb))")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   746
  apply (drule poly_mult_left_cancel [THEN iffD1], force)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   747
  apply (subgoal_tac "poly ([-a, 1] %^ (order a q) *** ([-a, 1] %^ (order a p) *** (qa *** qaa))) = poly ([-a, 1] %^ (order a q) *** ([-a, 1] %^ (order a p) *** ([-a, 1] *** qb))) ")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   748
  apply (drule poly_mult_left_cancel [THEN iffD1], force)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   749
  apply (simp add: fun_eq poly_exp_add poly_mult mult_ac del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   750
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   751
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   752
lemma (in idom_char_0) order_mult:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   753
  assumes "poly (p *** q) \<noteq> poly []"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   754
  shows "order a (p *** q) = order a p + order a q"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   755
  using assms
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   756
  apply (cut_tac a = a and p = "pmult p q" and n = "order a p + order a q" in order)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   757
  apply (auto simp add: poly_entire simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   758
  apply (drule_tac a = a in order2)+
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   759
  apply safe
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   760
  apply (simp add: divides_def fun_eq poly_exp_add poly_mult del: pmult_Cons, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   761
  apply (rule_tac x = "pmult qa qaa" in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   762
  apply (simp add: poly_mult mult_ac del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   763
  apply (drule_tac a = a in order_decomp)+
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   764
  apply safe
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   765
  apply (subgoal_tac "[uminus a, one] divides pmult qa qaa")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   766
  apply (simp add: poly_primes del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   767
  apply (auto simp add: divides_def simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   768
  apply (rule_tac x = qb in exI)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   769
  apply (subgoal_tac "poly (pmult (pexp [uminus a, one] (order a p)) (pmult qa qaa)) =
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   770
    poly (pmult (pexp [uminus a, one] (?order a p)) (pmult [uminus a, one] qb))")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   771
  apply (drule poly_mult_left_cancel [THEN iffD1], force)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   772
  apply (subgoal_tac "poly (pmult (pexp [uminus a, one] (order a q))
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   773
      (pmult (pexp [uminus a, one] (order a p)) (pmult qa qaa))) =
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   774
    poly (pmult (pexp [uminus a, one] (order a q))
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   775
      (pmult (pexp [uminus a, one] (order a p)) (pmult [uminus a, one] qb)))")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   776
  apply (drule poly_mult_left_cancel [THEN iffD1], force)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   777
  apply (simp add: fun_eq poly_exp_add poly_mult mult_ac del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   778
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   779
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   780
lemma (in idom_char_0) order_root2: "poly p \<noteq> poly [] \<Longrightarrow> poly p a = 0 \<longleftrightarrow> order a p \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   781
  by (rule order_root [THEN ssubst]) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   782
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   783
lemma (in semiring_1) pmult_one[simp]: "[1] *** p = p" by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   784
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   785
lemma (in semiring_0) poly_Nil_zero: "poly [] = poly [0]"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   786
  by (simp add: fun_eq)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   787
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
   788
lemma (in idom_char_0) rsquarefree_decomp:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   789
  "rsquarefree p \<Longrightarrow> poly p a = 0 \<Longrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   790
    \<exists>q. poly p = poly ([-a, 1] *** q) \<and> poly q a \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   791
  apply (simp add: rsquarefree_def, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   792
  apply (frule_tac a = a in order_decomp)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   793
  apply (drule_tac x = a in spec)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   794
  apply (drule_tac a = a in order_root2 [symmetric])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   795
  apply (auto simp del: pmult_Cons)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   796
  apply (rule_tac x = q in exI, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   797
  apply (simp add: poly_mult fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   798
  apply (drule_tac p1 = q in poly_linear_divides [THEN iffD1])
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   799
  apply (simp add: divides_def del: pmult_Cons, safe)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   800
  apply (drule_tac x = "[]" in spec)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   801
  apply (auto simp add: fun_eq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   802
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   803
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   804
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   805
text{*Normalization of a polynomial.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   806
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   807
lemma (in semiring_0) poly_normalize[simp]: "poly (pnormalize p) = poly p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   808
  by (induct p) (auto simp add: fun_eq)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   809
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   810
text{*The degree of a polynomial.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   811
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   812
lemma (in semiring_0) lemma_degree_zero: "list_all (%c. c = 0) p \<longleftrightarrow> pnormalize p = []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   813
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   814
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   815
lemma (in idom_char_0) degree_zero:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   816
  assumes "poly p = poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   817
  shows "degree p = 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   818
  using assms
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   819
  by (cases "pnormalize p = []") (auto simp add: degree_def poly_zero lemma_degree_zero)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   820
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31021
diff changeset
   821
lemma (in semiring_0) pnormalize_sing: "(pnormalize [x] = [x]) \<longleftrightarrow> x \<noteq> 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   822
  by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   823
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   824
lemma (in semiring_0) pnormalize_pair: "y \<noteq> 0 \<longleftrightarrow> (pnormalize [x, y] = [x, y])"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   825
  by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   826
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   827
lemma (in semiring_0) pnormal_cons: "pnormal p \<Longrightarrow> pnormal (c#p)"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   828
  unfolding pnormal_def by simp
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   829
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   830
lemma (in semiring_0) pnormal_tail: "p\<noteq>[] \<Longrightarrow> pnormal (c#p) \<Longrightarrow> pnormal p"
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31021
diff changeset
   831
  unfolding pnormal_def by(auto split: split_if_asm)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   832
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   833
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   834
lemma (in semiring_0) pnormal_last_nonzero: "pnormal p \<Longrightarrow> last p \<noteq> 0"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   835
  by (induct p) (simp_all add: pnormal_def split: split_if_asm)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   836
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   837
lemma (in semiring_0) pnormal_length: "pnormal p \<Longrightarrow> 0 < length p"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   838
  unfolding pnormal_def length_greater_0_conv by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   839
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   840
lemma (in semiring_0) pnormal_last_length: "0 < length p \<Longrightarrow> last p \<noteq> 0 \<Longrightarrow> pnormal p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   841
  by (induct p) (auto simp: pnormal_def  split: split_if_asm)
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31021
diff changeset
   842
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   843
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   844
lemma (in semiring_0) pnormal_id: "pnormal p \<longleftrightarrow> 0 < length p \<and> last p \<noteq> 0"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   845
  using pnormal_last_length pnormal_length pnormal_last_nonzero by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   846
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   847
lemma (in idom_char_0) poly_Cons_eq:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   848
  "poly (c # cs) = poly (d # ds) \<longleftrightarrow> c = d \<and> poly cs = poly ds"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   849
  (is "?lhs \<longleftrightarrow> ?rhs")
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   850
proof
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   851
  assume eq: ?lhs
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   852
  hence "\<And>x. poly ((c#cs) +++ -- (d#ds)) x = 0"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29504
diff changeset
   853
    by (simp only: poly_minus poly_add algebra_simps) simp
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   854
  hence "poly ((c#cs) +++ -- (d#ds)) = poly []" by(simp add: fun_eq_iff)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   855
  hence "c = d \<and> list_all (\<lambda>x. x=0) ((cs +++ -- ds))"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29504
diff changeset
   856
    unfolding poly_zero by (simp add: poly_minus_def algebra_simps)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   857
  hence "c = d \<and> (\<forall>x. poly (cs +++ -- ds) x = 0)"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   858
    unfolding poly_zero[symmetric] by simp
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   859
  then show ?rhs by (simp add: poly_minus poly_add algebra_simps fun_eq_iff)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   860
next
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   861
  assume ?rhs
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   862
  then show ?lhs by(simp add:fun_eq_iff)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   863
qed
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   864
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   865
lemma (in idom_char_0) pnormalize_unique: "poly p = poly q \<Longrightarrow> pnormalize p = pnormalize q"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   866
proof (induct q arbitrary: p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   867
  case Nil
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   868
  thus ?case by (simp only: poly_zero lemma_degree_zero) simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   869
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   870
  case (Cons c cs p)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   871
  thus ?case
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   872
  proof (induct p)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   873
    case Nil
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   874
    hence "poly [] = poly (c#cs)" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   875
    then have "poly (c#cs) = poly [] " by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   876
    thus ?case by (simp only: poly_zero lemma_degree_zero) simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   877
  next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   878
    case (Cons d ds)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   879
    hence eq: "poly (d # ds) = poly (c # cs)" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   880
    hence eq': "\<And>x. poly (d # ds) x = poly (c # cs) x" by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   881
    hence "poly (d # ds) 0 = poly (c # cs) 0" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   882
    hence dc: "d = c" by auto
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   883
    with eq have "poly ds = poly cs"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   884
      unfolding  poly_Cons_eq by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   885
    with Cons.prems have "pnormalize ds = pnormalize cs" by blast
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   886
    with dc show ?case by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   887
  qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   888
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   889
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   890
lemma (in idom_char_0) degree_unique:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   891
  assumes pq: "poly p = poly q"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   892
  shows "degree p = degree q"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   893
  using pnormalize_unique[OF pq] unfolding degree_def by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   894
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   895
lemma (in semiring_0) pnormalize_length:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   896
  "length (pnormalize p) \<le> length p" by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   897
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   898
lemma (in semiring_0) last_linear_mul_lemma:
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   899
  "last ((a %* p) +++ (x#(b %* p))) = (if p = [] then x else b * last p)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   900
  apply (induct p arbitrary: a x b)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   901
  apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   902
  apply (subgoal_tac "padd (cmult aa p) (times b a # cmult b p) \<noteq> []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   903
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   904
  apply (induct_tac p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   905
  apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   906
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   907
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   908
lemma (in semiring_1) last_linear_mul:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   909
  assumes p: "p \<noteq> []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   910
  shows "last ([a,1] *** p) = last p"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   911
proof -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   912
  from p obtain c cs where cs: "p = c#cs" by (cases p) auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   913
  from cs have eq: "[a,1] *** p = (a %* (c#cs)) +++ (0#(1 %* (c#cs)))"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   914
    by (simp add: poly_cmult_distr)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   915
  show ?thesis using cs
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   916
    unfolding eq last_linear_mul_lemma by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   917
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   918
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   919
lemma (in semiring_0) pnormalize_eq: "last p \<noteq> 0 \<Longrightarrow> pnormalize p = p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   920
  by (induct p) (auto split: split_if_asm)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   921
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   922
lemma (in semiring_0) last_pnormalize: "pnormalize p \<noteq> [] \<Longrightarrow> last (pnormalize p) \<noteq> 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   923
  by (induct p) auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   924
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   925
lemma (in semiring_0) pnormal_degree: "last p \<noteq> 0 \<Longrightarrow> degree p = length p - 1"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   926
  using pnormalize_eq[of p] unfolding degree_def by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   927
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   928
lemma (in semiring_0) poly_Nil_ext: "poly [] = (\<lambda>x. 0)"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   929
  by (rule ext) simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   930
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   931
lemma (in idom_char_0) linear_mul_degree:
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   932
  assumes p: "poly p \<noteq> poly []"
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   933
  shows "degree ([a,1] *** p) = degree p + 1"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   934
proof -
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   935
  from p have pnz: "pnormalize p \<noteq> []"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   936
    unfolding poly_zero lemma_degree_zero .
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   937
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   938
  from last_linear_mul[OF pnz, of a] last_pnormalize[OF pnz]
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   939
  have l0: "last ([a, 1] *** pnormalize p) \<noteq> 0" by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   940
  from last_pnormalize[OF pnz] last_linear_mul[OF pnz, of a]
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   941
    pnormal_degree[OF l0] pnormal_degree[OF last_pnormalize[OF pnz]] pnz
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   942
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   943
  have th: "degree ([a,1] *** pnormalize p) = degree (pnormalize p) + 1"
53191
14ab2f821e1d tuned proofs -- fewer warnings;
wenzelm
parents: 49962
diff changeset
   944
    by simp
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   945
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   946
  have eqs: "poly ([a,1] *** pnormalize p) = poly ([a,1] *** p)"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   947
    by (rule ext) (simp add: poly_mult poly_add poly_cmult)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   948
  from degree_unique[OF eqs] th
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   949
  show ?thesis by (simp add: degree_unique[OF poly_normalize])
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   950
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   951
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   952
lemma (in idom_char_0) linear_pow_mul_degree:
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   953
  "degree([a,1] %^n *** p) = (if poly p = poly [] then 0 else degree p + n)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   954
proof (induct n arbitrary: a p)
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   955
  case (0 a p)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   956
  show ?case
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   957
  proof (cases "poly p = poly []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   958
    case True
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   959
    then show ?thesis
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   960
      using degree_unique[OF True] by (simp add: degree_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   961
  next
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   962
    case False
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   963
    then show ?thesis by (auto simp add: poly_Nil_ext)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   964
  qed
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   965
next
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   966
  case (Suc n a p)
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   967
  have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1] %^ n *** ([a,1] *** p))"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   968
    apply (rule ext)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   969
    apply (simp add: poly_mult poly_add poly_cmult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   970
    apply (simp add: mult_ac add_ac distrib_left)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   971
    done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   972
  note deq = degree_unique[OF eq]
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   973
  show ?case
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   974
  proof (cases "poly p = poly []")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   975
    case True
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   976
    with eq have eq': "poly ([a,1] %^(Suc n) *** p) = poly []"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   977
      apply -
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   978
      apply (rule ext)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   979
      apply (simp add: poly_mult poly_cmult poly_add)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   980
      done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   981
    from degree_unique[OF eq'] True show ?thesis
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   982
      by (simp add: degree_def)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   983
  next
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   984
    case False
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   985
    then have ap: "poly ([a,1] *** p) \<noteq> poly []"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 29879
diff changeset
   986
      using poly_mult_not_eq_poly_Nil unfolding poly_entire by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   987
    have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1]%^n *** ([a,1] *** p))"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   988
      by (rule ext, simp add: poly_mult poly_add poly_exp poly_cmult algebra_simps)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   989
    from ap have ap': "(poly ([a,1] *** p) = poly []) = False"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   990
      by blast
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   991
    have th0: "degree ([a,1]%^n *** ([a,1] *** p)) = degree ([a,1] *** p) + n"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   992
      apply (simp only: Suc.hyps[of a "pmult [a,one] p"] ap')
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   993
      apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   994
      done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   995
    from degree_unique[OF eq] ap False th0 linear_mul_degree[OF False, of a]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   996
    show ?thesis by (auto simp del: poly.simps)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
   997
  qed
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   998
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
   999
31021
53642251a04f farewell to class recpower
haftmann
parents: 30738
diff changeset
  1000
lemma (in idom_char_0) order_degree:
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1001
  assumes p0: "poly p \<noteq> poly []"
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1002
  shows "order a p \<le> degree p"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1003
proof -
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1004
  from order2[OF p0, unfolded divides_def]
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1005
  obtain q where q: "poly p = poly ([- a, 1]%^ (order a p) *** q)" by blast
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1006
  {
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1007
    assume "poly q = poly []"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1008
    with q p0 have False by (simp add: poly_mult poly_entire)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1009
  }
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1010
  with degree_unique[OF q, unfolded linear_pow_mul_degree] show ?thesis
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1011
    by auto
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1012
qed
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1013
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1014
text{*Tidier versions of finiteness of roots.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1015
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1016
lemma (in idom_char_0) poly_roots_finite_set:
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1017
  "poly p \<noteq> poly [] \<Longrightarrow> finite {x. poly p x = 0}"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1018
  unfolding poly_roots_finite .
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1019
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1020
text{*bound for polynomial.*}
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1021
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1022
lemma poly_mono: "abs(x) \<le> k \<Longrightarrow> abs(poly p (x::'a::{linordered_idom})) \<le> poly (map abs p) k"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1023
  apply (induct p)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1024
  apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1025
  apply (rule_tac y = "abs a + abs (x * poly p x)" in order_trans)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1026
  apply (rule abs_triangle_ineq)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1027
  apply (auto intro!: mult_mono simp add: abs_mult)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53191
diff changeset
  1028
  done
26124
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1029
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1030
lemma (in semiring_0) poly_Sing: "poly [c] x = c" by simp
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1031
2514f0ade8bc A library for univariate polynomials -- generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff changeset
  1032
end