author  haftmann 
Fri, 27 Mar 2009 10:05:11 +0100  
changeset 30738  0842e906300c 
parent 30488  5c4c3a9e9102 
child 31021  53642251a04f 
permissions  rwrr 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1 
(* Title: Univ_Poly.thy 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

2 
Author: Amine Chaieb 
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  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  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 

26194  13 
primrec (in semiring_0) poly :: "'a list => 'a => 'a" where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

14 
poly_Nil: "poly [] x = 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

15 
 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

16 

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 
subsection{*Arithmetic Operations on Polynomials*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

19 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

20 
text{*addition*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

21 

30488  22 
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

23 
where 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

24 
padd_Nil: "[] +++ l2 = l2" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

25 
 padd_Cons: "(h#t) +++ l2 = (if l2 = [] then h#t 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

26 
else (h + hd l2)#(t +++ tl l2))" 
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  29 
primrec (in semiring_0) cmult :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixl "%*" 70) where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

30 
cmult_Nil: "c %* [] = []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

31 
 cmult_Cons: "c %* (h#t) = (c * h)#(c %* t)" 
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  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 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

36 
pmult_Nil: "[] *** l2 = []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

37 
 pmult_Cons: "(h#t) *** l2 = (if t = [] then h %* l2 
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  41 
primrec (in semiring_0) mulexp :: "nat \<Rightarrow> 'a list \<Rightarrow> '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

42 
mulexp_zero: "mulexp 0 p q = q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

43 
 mulexp_Suc: "mulexp (Suc n) p q = p *** mulexp n p q" 
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  46 
primrec (in semiring_1) pexp :: "'a list \<Rightarrow> nat \<Rightarrow> 'a list" (infixl "%^" 80) where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

47 
pexp_0: "p %^ 0 = [1]" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

48 
 pexp_Suc: "p %^ (Suc n) = p *** (p %^ n)" 
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 *) 
26194  52 
primrec (in field) "pquot" :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

53 
pquot_Nil: "pquot [] a= []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

54 
 pquot_Cons: "pquot (h#t) a = (if t = [] then [h] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

55 
else (inverse(a) * (h  hd( pquot t a)))#(pquot t a))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

56 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

57 
text{*normalization of polynomials (remove extra 0 coeff)*} 
26194  58 
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

59 
pnormalize_Nil: "pnormalize [] = []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

60 
 pnormalize_Cons: "pnormalize (h#p) = (if ( (pnormalize p) = []) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

61 
then (if (h = 0) then [] else [h]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

62 
else (h#(pnormalize p)))" 
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 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

68 
definition (in ring_1) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

69 
poly_minus :: "'a list => 'a list" (" _" [80] 80) where 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

70 
" p = ( 1) %* p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

71 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

72 
definition (in semiring_0) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

73 
divides :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infixl "divides" 70) where 
28562  74 
[code del]: "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

75 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

76 
{*order of a polynomial*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

77 
definition (in ring_1) order :: "'a => 'a list => nat" where 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

78 
"order a p = (SOME n. ([a, 1] %^ n) divides p & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

79 
~ (([a, 1] %^ (Suc n)) divides p))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

80 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

81 
{*degree of a polynomial*} 
30488  82 
definition (in semiring_0) degree :: "'a list => nat" where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

83 
"degree p = length (pnormalize p)  1" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

84 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

85 
{*squarefree polynomials  NB with respect to real roots only.*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

86 
definition (in ring_1) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

87 
rsquarefree :: "'a list => bool" where 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

88 
"rsquarefree p = (poly p \<noteq> poly [] & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

89 
(\<forall>a. (order a p = 0)  (order a p = 1)))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

90 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

91 
context semiring_0 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

92 
begin 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

93 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

94 
lemma padd_Nil2[simp]: "p +++ [] = p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

95 
by (induct p) auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

96 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

97 
lemma padd_Cons_Cons: "(h1 # p1) +++ (h2 # p2) = (h1 + h2) # (p1 +++ p2)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

98 
by auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

99 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

100 
lemma pminus_Nil[simp]: " [] = []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

101 
by (simp add: poly_minus_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

102 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

103 
lemma pmult_singleton: "[h1] *** p1 = h1 %* p1" by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

104 
end 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

105 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

106 
lemma (in semiring_1) poly_ident_mult[simp]: "1 %* t = t" by (induct "t", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

107 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

108 
lemma (in semiring_0) poly_simple_add_Cons[simp]: "[a] +++ ((0)#t) = (a#t)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

109 
by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

110 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

111 
text{*Handy general properties*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

112 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

113 
lemma (in comm_semiring_0) padd_commut: "b +++ a = a +++ b" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

114 
proof(induct b arbitrary: a) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

115 
case Nil thus ?case by auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

116 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

117 
case (Cons b bs a) thus ?case by (cases a, simp_all add: add_commute) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

118 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

119 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

120 
lemma (in comm_semiring_0) padd_assoc: "\<forall>b c. (a +++ b) +++ c = a +++ (b +++ c)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

121 
apply (induct a arbitrary: b c) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

122 
apply (simp, clarify) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

123 
apply (case_tac b, simp_all add: add_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

124 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

125 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

126 
lemma (in semiring_0) poly_cmult_distr: "a %* ( p +++ q) = (a %* p +++ a %* q)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

127 
apply (induct p arbitrary: q,simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

128 
apply (case_tac q, simp_all add: right_distrib) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

129 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

130 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

131 
lemma (in ring_1) pmult_by_x[simp]: "[0, 1] *** t = ((0)#t)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

132 
apply (induct "t", simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

133 
apply (auto simp add: mult_zero_left poly_ident_mult padd_commut) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

134 
apply (case_tac t, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

135 
done 
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) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

141 
case Nil thus ?case by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

142 
next 
30488  143 
case (Cons a as p2) thus ?case 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

144 
by (cases p2, simp_all add: add_ac right_distrib) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

145 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

146 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

147 
lemma (in comm_semiring_0) poly_cmult: "poly (c %* p) x = c * poly p x" 
30488  148 
apply (induct "p") 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

149 
apply (case_tac [2] "x=zero") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

150 
apply (auto simp add: right_distrib mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

151 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

152 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

153 
lemma (in comm_semiring_0) poly_cmult_map: "poly (map (op * c) p) x = c*poly p x" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

154 
by (induct p, auto simp add: right_distrib mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

155 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

156 
lemma (in comm_ring_1) poly_minus: "poly ( p) x =  (poly p x)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

157 
apply (simp add: poly_minus_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

158 
apply (auto simp add: poly_cmult minus_mult_left[symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

159 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

160 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

161 
lemma (in comm_semiring_0) poly_mult: "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

162 
proof(induct p1 arbitrary: p2) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

163 
case Nil thus ?case by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

164 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

165 
case (Cons a as p2) 
30488  166 
thus ?case by (cases as, 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

167 
simp_all add: poly_cmult poly_add left_distrib right_distrib mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

168 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

169 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

170 
class recpower_semiring = semiring + recpower 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

171 
class recpower_semiring_1 = semiring_1 + recpower 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

172 
class recpower_semiring_0 = semiring_0 + recpower 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

173 
class recpower_ring = ring + recpower 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

174 
class recpower_ring_1 = ring_1 + recpower 
28823  175 
subclass (in recpower_ring_1) recpower_ring .. 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

176 
class recpower_comm_semiring_1 = recpower + comm_semiring_1 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

177 
class recpower_comm_ring_1 = recpower + comm_ring_1 
28823  178 
subclass (in recpower_comm_ring_1) recpower_comm_semiring_1 .. 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

179 
class recpower_idom = recpower + idom 
28823  180 
subclass (in recpower_idom) recpower_comm_ring_1 .. 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

181 
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

182 
class recpower_idom_char_0 = recpower + idom_char_0 
28823  183 
subclass (in recpower_idom_char_0) recpower_idom .. 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

184 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

185 
lemma (in recpower_comm_ring_1) poly_exp: "poly (p %^ n) x = (poly p x) ^ n" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

186 
apply (induct "n") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

187 
apply (auto simp add: poly_cmult poly_mult power_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

188 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

189 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

190 
text{*More Polynomial Evaluation Lemmas*} 
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 
lemma (in semiring_0) poly_add_rzero[simp]: "poly (a +++ []) x = poly a x" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

193 
by simp 
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_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

196 
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

197 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

198 
lemma (in semiring_0) poly_mult_Nil2[simp]: "poly (p *** []) x = 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

199 
by (induct "p", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

200 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

201 
lemma (in comm_semiring_1) poly_exp_add: "poly (p %^ (n + d)) x = poly( p %^ n *** p %^ d) x" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

202 
apply (induct "n") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

203 
apply (auto 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

204 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

205 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

206 
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

207 
@{term "p(x)"} *} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

208 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

209 
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

210 
proof(induct t) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

211 
case Nil 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

212 
{fix h have "[h] = [h] +++ [ a, 1] *** []" by simp} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

213 
thus ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

214 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

215 
case (Cons x xs) 
30488  216 
{fix h 
217 
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

218 
obtain q r where qr: "x#xs = [r] +++ [ a, 1] *** q" by blast 
30488  219 
have "h#x#xs = [a*r + h] +++ [a, 1] *** (r#q)" 
220 
using qr by(cases q, simp_all add: algebra_simps diff_def[symmetric] 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

221 
minus_mult_left[symmetric] right_minus) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

222 
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

223 
thus ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

224 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

225 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

226 
lemma (in comm_ring_1) poly_linear_rem: "\<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

227 
by (cut_tac t = t and a = a in lemma_poly_linear_rem, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

228 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

229 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

230 
lemma (in comm_ring_1) poly_linear_divides: "(poly p a = 0) = ((p = [])  (\<exists>q. p = [a, 1] *** q))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

231 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

232 
{assume p: "p = []" hence ?thesis by simp} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

233 
moreover 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

234 
{fix x xs assume p: "p = x#xs" 
30488  235 
{fix q assume "p = [a, 1] *** q" hence "poly p a = 0" 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

236 
by (simp add: poly_add poly_cmult minus_mult_left[symmetric])} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

237 
moreover 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

238 
{assume p0: "poly p a = 0" 
30488  239 
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

240 
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

241 
have "r = 0" using p0 by (simp only: p qr poly_mult poly_add) simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

242 
hence "\<exists>q. p = [ a, 1] *** q" using p qr apply  apply (rule exI[where x=q])apply auto apply (cases q) apply auto done} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

243 
ultimately have ?thesis using p by blast} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

244 
ultimately show ?thesis by (cases p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

245 
qed 
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_mult[simp]: "\<forall>h k a. length (k %* p +++ (h # (a %* p))) = Suc (length p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

248 
by (induct "p", auto) 
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 semiring_0) lemma_poly_length_mult2[simp]: "\<forall>h k. length (k %* p +++ (h # p)) = Suc (length p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

251 
by (induct "p", auto) 
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 
lemma (in ring_1) poly_length_mult[simp]: "length([a,1] *** q) = Suc (length q)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

254 
by auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

255 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

256 
subsection{*Polynomial length*} 
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_cmult_length[simp]: "length (a %* p) = length p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

259 
by (induct "p", auto) 
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_add_length: "length (p1 +++ p2) = max (length p1) (length p2)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

262 
apply (induct p1 arbitrary: p2, simp_all) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

263 
apply arith 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

264 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

265 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

266 
lemma (in semiring_0) poly_root_mult_length[simp]: "length([a,b] *** p) = Suc (length p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

267 
by (simp add: poly_add_length) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

268 

30488  269 
lemma (in idom) poly_mult_not_eq_poly_Nil[simp]: 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

270 
"poly (p *** q) x \<noteq> poly [] x \<longleftrightarrow> poly p x \<noteq> poly [] x \<and> poly q x \<noteq> poly [] x" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

271 
by (auto simp add: poly_mult) 
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 idom) poly_mult_eq_zero_disj: "poly (p *** q) x = 0 \<longleftrightarrow> poly p x = 0 \<or> poly q x = 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

274 
by (auto simp add: poly_mult) 
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{*Normalisation Properties*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

277 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

278 
lemma (in semiring_0) poly_normalized_nil: "(pnormalize p = []) > (poly p x = 0)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

279 
by (induct "p", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

280 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

281 
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

282 
lemma (in idom) poly_roots_index_lemma: 
30488  283 
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

284 
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

285 
using p n 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

286 
proof(induct n arbitrary: p x) 
30488  287 
case 0 thus ?case by simp 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

288 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

289 
case (Suc n p x) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

290 
{assume C: "\<And>i. \<exists>x. poly p x = 0 \<and> (\<forall>m\<le>Suc n. x \<noteq> i m)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

291 
from Suc.prems have p0: "poly p x \<noteq> 0" "p\<noteq> []" by auto 
30488  292 
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

293 
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

294 
from C obtain a where a: "poly p a = 0" by blast 
30488  295 
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

296 
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

297 
have lg: "length q = n" using q Suc.prems(2) by simp 
30488  298 
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

299 
by (auto simp add: poly_mult poly_add poly_cmult) 
30488  300 
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

301 
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

302 
let ?i = "\<lambda>m. if m = Suc n then a else i m" 
30488  303 
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

304 
by blast 
30488  305 
from y have "y = a \<or> poly q y = 0" 
29667  306 
by (simp only: q poly_mult_eq_zero_disj poly_add) (simp add: algebra_simps) 
30488  307 
with i[rule_format, of y] y(1) y(2) have False apply auto 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

308 
apply (erule_tac x="m" in allE) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

309 
apply auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

310 
done} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

311 
thus ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

312 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

313 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

314 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

315 
lemma (in idom) poly_roots_index_length: "poly p x \<noteq> poly [] x ==> 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

316 
\<exists>i. \<forall>x. (poly p x = 0) > (\<exists>n. n \<le> length p & x = i n)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

317 
by (blast intro: poly_roots_index_lemma) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

318 

26313  319 
lemma (in idom) poly_roots_finite_lemma1: "poly p x \<noteq> poly [] x ==> 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

320 
\<exists>N i. \<forall>x. (poly p x = 0) > (\<exists>n. (n::nat) < N & x = i n)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

321 
apply (drule poly_roots_index_length, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

322 
apply (rule_tac x = "Suc (length p)" in exI) 
30488  323 
apply (rule_tac x = i in exI) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

324 
apply (simp add: less_Suc_eq_le) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

325 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

326 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

327 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

328 
lemma (in idom) idom_finite_lemma: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

329 
assumes P: "\<forall>x. P x > (\<exists>n. n < length j & x = j!n)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

330 
shows "finite {x. P x}" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

331 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

332 
let ?M = "{x. P x}" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

333 
let ?N = "set j" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

334 
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

335 
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

336 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

337 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

338 

26313  339 
lemma (in idom) poly_roots_finite_lemma2: "poly p x \<noteq> poly [] x ==> 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

340 
\<exists>i. \<forall>x. (poly p x = 0) > x \<in> set i" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

341 
apply (drule poly_roots_index_length, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

342 
apply (rule_tac x="map (\<lambda>n. i n) [0 ..< Suc (length p)]" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

343 
apply (auto simp add: image_iff) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

344 
apply (erule_tac x="x" in allE, clarsimp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

345 
by (case_tac "n=length p", auto simp add: order_le_less) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

346 

30488  347 
lemma (in ring_char_0) UNIV_ring_char_0_infinte: 
348 
"\<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

349 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

350 
assume F: "finite (UNIV :: 'a set)" 
29292  351 
have "finite (UNIV :: nat set)" 
352 
proof (rule finite_imageD) 

353 
have "of_nat ` UNIV \<subseteq> UNIV" by simp 

354 
then show "finite (of_nat ` UNIV :: 'a set)" using F by (rule finite_subset) 

355 
show "inj (of_nat :: nat \<Rightarrow> 'a)" by (simp add: inj_on_def) 

356 
qed 

29879  357 
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

358 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

359 

30488  360 
lemma (in idom_char_0) poly_roots_finite: "(poly p \<noteq> poly []) = 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

361 
finite {x. poly p x = 0}" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

362 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

363 
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

364 
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

365 
using H 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

366 
apply  
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

367 
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

368 
apply (rule ccontr) 
26313  369 
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

370 
using finite_subset 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

371 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

372 
fix x i 
30488  373 
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

374 
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

375 
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

376 
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

377 
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

378 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

379 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

380 
assume F: "finite {x. poly p x = (0\<Colon>'a)}" 
30488  381 
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

382 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

383 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

384 
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

385 

30488  386 
lemma (in idom_char_0) poly_entire_lemma2: 
26313  387 
assumes p0: "poly p \<noteq> poly []" and q0: "poly q \<noteq> poly []" 
388 
shows "poly (p***q) \<noteq> poly []" 

389 
proof 

390 
let ?S = "\<lambda>p. {x. poly p x = 0}" 

391 
have "?S (p *** q) = ?S p \<union> ?S q" by (auto simp add: poly_mult) 

392 
with p0 q0 show ?thesis unfolding poly_roots_finite by auto 

393 
qed 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

394 

30488  395 
lemma (in idom_char_0) poly_entire: 
26313  396 
"poly (p *** q) = poly [] \<longleftrightarrow> poly p = poly [] \<or> poly q = poly []" 
29667  397 
using poly_entire_lemma2[of p q] 
398 
by (auto simp add: expand_fun_eq poly_mult) 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

399 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

400 
lemma (in idom_char_0) poly_entire_neg: "(poly (p *** q) \<noteq> poly []) = ((poly p \<noteq> poly []) & (poly q \<noteq> poly []))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

401 
by (simp add: poly_entire) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

402 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

403 
lemma fun_eq: " (f = g) = (\<forall>x. f x = g x)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

404 
by (auto intro!: ext) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

405 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

406 
lemma (in comm_ring_1) poly_add_minus_zero_iff: "(poly (p +++  q) = poly []) = (poly p = poly q)" 
29667  407 
by (auto simp add: algebra_simps poly_add poly_minus_def fun_eq poly_cmult minus_mult_left[symmetric]) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

408 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

409 
lemma (in comm_ring_1) poly_add_minus_mult_eq: "poly (p *** q +++ (p *** r)) = poly (p *** (q +++  r))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

410 
by (auto simp add: poly_add poly_minus_def fun_eq poly_mult poly_cmult right_distrib minus_mult_left[symmetric] minus_mult_right[symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

411 

28823  412 
subclass (in idom_char_0) comm_ring_1 .. 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

413 
lemma (in idom_char_0) poly_mult_left_cancel: "(poly (p *** q) = poly (p *** r)) = (poly p = poly []  poly q = poly r)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

414 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

415 
have "poly (p *** q) = poly (p *** r) \<longleftrightarrow> poly (p *** q +++  (p *** r)) = poly []" by (simp only: poly_add_minus_zero_iff) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

416 
also have "\<dots> \<longleftrightarrow> poly p = poly []  poly q = poly r" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

417 
by (auto intro: ext simp add: poly_add_minus_mult_eq poly_entire poly_add_minus_zero_iff) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

418 
finally show ?thesis . 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

419 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

420 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

421 
lemma (in recpower_idom) poly_exp_eq_zero[simp]: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

422 
"(poly (p %^ n) = poly []) = (poly p = poly [] & n \<noteq> 0)" 
30488  423 
apply (simp only: fun_eq add: all_simps [symmetric]) 
424 
apply (rule arg_cong [where f = All]) 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

425 
apply (rule ext) 
26194  426 
apply (induct n) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

427 
apply (auto simp add: poly_exp poly_mult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

428 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

429 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

430 
lemma (in semiring_1) one_neq_zero[simp]: "1 \<noteq> 0" using zero_neq_one by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

431 
lemma (in comm_ring_1) poly_prime_eq_zero[simp]: "poly [a,1] \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

432 
apply (simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

433 
apply (rule_tac x = "minus one a" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

434 
apply (unfold diff_minus) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

435 
apply (subst add_commute) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

436 
apply (subst add_assoc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

437 
apply simp 
30488  438 
done 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

439 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

440 
lemma (in recpower_idom) poly_exp_prime_eq_zero: "(poly ([a, 1] %^ n) \<noteq> poly [])" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

441 
by auto 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

442 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

443 
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

444 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

445 
lemma (in idom_char_0) poly_zero_lemma': "poly (h # t) = poly [] ==> h = 0 & poly t = poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

446 
apply(simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

447 
apply (case_tac "h = zero") 
30488  448 
apply (drule_tac [2] x = zero in spec, auto) 
449 
apply (cases "poly t = poly []", simp) 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

450 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

451 
fix x 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

452 
assume H: "\<forall>x. x = (0\<Colon>'a) \<or> poly t x = (0\<Colon>'a)" and pnz: "poly t \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

453 
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

454 
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

455 
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

456 
from poly_roots_finite pnz have th': "finite ?S" by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

457 
from finite_subset[OF th th'] UNIV_ring_char_0_infinte 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

458 
show "poly t x = (0\<Colon>'a)" by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

459 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

460 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

461 
lemma (in idom_char_0) poly_zero: "(poly p = poly []) = list_all (%c. c = 0) p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

462 
apply (induct "p", simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

463 
apply (rule iffI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

464 
apply (drule poly_zero_lemma', auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

465 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

466 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

467 
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

468 
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

469 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

470 

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 
text{*Basics of divisibility.*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

473 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

474 
lemma (in idom) poly_primes: "([a, 1] divides (p *** q)) = ([a, 1] divides p  [a, 1] divides q)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

475 
apply (auto simp add: divides_def fun_eq poly_mult poly_add poly_cmult left_distrib [symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

476 
apply (drule_tac x = "uminus a" in spec) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

477 
apply (simp add: poly_linear_divides poly_add poly_cmult left_distrib [symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

478 
apply (cases "p = []") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

479 
apply (rule exI[where x="[]"]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

480 
apply simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

481 
apply (cases "q = []") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

482 
apply (erule allE[where x="[]"], simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

483 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

484 
apply clarsimp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

485 
apply (cases "\<exists>q\<Colon>'a list. p = a %* q +++ ((0\<Colon>'a) # q)") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

486 
apply (clarsimp simp add: poly_add poly_cmult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

487 
apply (rule_tac x="qa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

488 
apply (simp add: left_distrib [symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

489 
apply clarsimp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

490 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

491 
apply (auto simp add: right_minus poly_linear_divides poly_add poly_cmult left_distrib [symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

492 
apply (rule_tac x = "pmult qa q" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

493 
apply (rule_tac [2] x = "pmult p qa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

494 
apply (auto simp add: poly_add poly_mult poly_cmult mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

495 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

496 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

497 
lemma (in comm_semiring_1) poly_divides_refl[simp]: "p divides p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

498 
apply (simp add: divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

499 
apply (rule_tac x = "[one]" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

500 
apply (auto simp add: poly_mult fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

501 
done 
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_trans: "[ p divides q; q divides r ] ==> p divides r" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

504 
apply (simp add: divides_def, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

505 
apply (rule_tac x = "pmult qa qaa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

506 
apply (auto simp add: poly_mult fun_eq mult_assoc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

507 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

508 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

509 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

510 
lemma (in recpower_comm_semiring_1) poly_divides_exp: "m \<le> n ==> (p %^ m) divides (p %^ n)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

511 
apply (auto simp add: le_iff_add) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

512 
apply (induct_tac k) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

513 
apply (rule_tac [2] poly_divides_trans) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

514 
apply (auto simp add: divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

515 
apply (rule_tac x = p in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

516 
apply (auto simp add: poly_mult fun_eq mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

517 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

518 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

519 
lemma (in recpower_comm_semiring_1) poly_exp_divides: "[ (p %^ n) divides q; m\<le>n ] ==> (p %^ m) divides q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

520 
by (blast intro: poly_divides_exp poly_divides_trans) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

521 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

522 
lemma (in comm_semiring_0) poly_divides_add: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

523 
"[ p divides q; p divides r ] ==> p divides (q +++ r)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

524 
apply (simp add: divides_def, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

525 
apply (rule_tac x = "padd qa qaa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

526 
apply (auto simp add: poly_add fun_eq poly_mult right_distrib) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

527 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

528 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

529 
lemma (in comm_ring_1) poly_divides_diff: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

530 
"[ p divides q; p divides (q +++ r) ] ==> p divides r" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

531 
apply (simp add: divides_def, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

532 
apply (rule_tac x = "padd qaa (poly_minus qa)" in exI) 
29667  533 
apply (auto simp add: poly_add fun_eq poly_mult poly_minus algebra_simps) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

534 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

535 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

536 
lemma (in comm_ring_1) poly_divides_diff2: "[ p divides r; p divides (q +++ r) ] ==> p divides q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

537 
apply (erule poly_divides_diff) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

538 
apply (auto simp add: poly_add fun_eq poly_mult divides_def add_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

539 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

540 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

541 
lemma (in semiring_0) poly_divides_zero: "poly p = poly [] ==> q divides p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

542 
apply (simp add: divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

543 
apply (rule exI[where x="[]"]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

544 
apply (auto simp add: fun_eq poly_mult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

545 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

546 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

547 
lemma (in semiring_0) poly_divides_zero2[simp]: "q divides []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

548 
apply (simp add: divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

549 
apply (rule_tac x = "[]" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

550 
apply (auto simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

551 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

552 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

553 
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

554 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

555 
lemma (in idom_char_0) poly_order_exists_lemma: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

556 
assumes lp: "length p = d" and p: "poly p \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

557 
shows "\<exists>n q. p = mulexp n [a, 1] q \<and> poly q a \<noteq> 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

558 
using lp p 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

559 
proof(induct d arbitrary: p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

560 
case 0 thus ?case by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

561 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

562 
case (Suc n p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

563 
{assume p0: "poly p a = 0" 
29292  564 
from Suc.prems have h: "length p = Suc n" "poly p \<noteq> poly []" by auto 
565 
hence pN: "p \<noteq> []" by auto 

30488  566 
from p0[unfolded poly_linear_divides] pN obtain q where 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

567 
q: "p = [a, 1] *** q" by blast 
30488  568 
from q h p0 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

569 
apply  
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

570 
apply simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

571 
apply (simp only: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

572 
apply (rule ccontr) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

573 
apply (simp add: fun_eq poly_add poly_cmult minus_mult_left[symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

574 
done 
30488  575 
from Suc.hyps[OF qh] obtain m r where 
576 
mr: "q = mulexp m [a,1] r" "poly r a \<noteq> 0" by blast 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

577 
from mr q have "p = mulexp (Suc m) [a,1] r \<and> poly r a \<noteq> 0" by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

578 
hence ?case by blast} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

579 
moreover 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

580 
{assume p0: "poly p a \<noteq> 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

581 
hence ?case using Suc.prems apply simp by (rule exI[where x="0::nat"], simp)} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

582 
ultimately show ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

583 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

584 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

585 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

586 
lemma (in recpower_comm_semiring_1) poly_mulexp: "poly (mulexp n p q) x = (poly p x) ^ n * poly q x" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

587 
by(induct n, auto simp add: poly_mult power_Suc mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

588 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

589 
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

590 
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

591 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

592 
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

593 
unfolding divides_def by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

594 
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

595 
"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

596 
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

597 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

598 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

599 

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 
(* FIXME: Tidy up *) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

602 

30488  603 
lemma (in recpower_semiring_1) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

604 
zero_power_iff: "0 ^ n = (if n = 0 then 1 else 0)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

605 
by (induct n, simp_all add: power_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

606 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

607 
lemma (in recpower_idom_char_0) poly_order_exists: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

608 
assumes lp: "length p = d" and p0: "poly p \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

609 
shows "\<exists>n. ([a, 1] %^ n) divides p & ~(([a, 1] %^ (Suc n)) divides p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

610 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

611 
let ?poly = poly 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

612 
let ?mulexp = mulexp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

613 
let ?pexp = pexp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

614 
from lp p0 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

615 
show ?thesis 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

616 
apply  
30488  617 
apply (drule poly_order_exists_lemma [where a=a], assumption, clarify) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

618 
apply (rule_tac x = n in exI, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

619 
apply (unfold divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

620 
apply (rule_tac x = q in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

621 
apply (induct_tac "n", simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

622 
apply (simp (no_asm_simp) add: poly_add poly_cmult poly_mult right_distrib mult_ac) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

623 
apply safe 
30488  624 
apply (subgoal_tac "?poly (?mulexp n [uminus a, one] q) \<noteq> ?poly (pmult (?pexp [uminus a, one] (Suc n)) qa)") 
625 
apply simp 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

626 
apply (induct_tac "n") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

627 
apply (simp del: pmult_Cons pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

628 
apply (erule_tac Q = "?poly q a = zero" in contrapos_np) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

629 
apply (simp add: poly_add poly_cmult minus_mult_left[symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

630 
apply (rule pexp_Suc [THEN ssubst]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

631 
apply (rule ccontr) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

632 
apply (simp add: poly_mult_left_cancel poly_mult_assoc del: pmult_Cons pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

633 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

634 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

635 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

636 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

637 
lemma (in semiring_1) poly_one_divides[simp]: "[1] divides p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

638 
by (simp add: divides_def, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

639 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

640 
lemma (in recpower_idom_char_0) poly_order: "poly p \<noteq> poly [] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

641 
==> EX! n. ([a, 1] %^ n) divides p & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

642 
~(([a, 1] %^ (Suc n)) divides p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

643 
apply (auto intro: poly_order_exists simp add: less_linear simp del: pmult_Cons pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

644 
apply (cut_tac x = y and y = n in less_linear) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

645 
apply (drule_tac m = n in poly_exp_divides) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

646 
apply (auto dest: Suc_le_eq [THEN iffD2, THEN [2] poly_exp_divides] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

647 
simp del: pmult_Cons pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

648 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

649 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

650 
text{*Order*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

651 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

652 
lemma some1_equalityD: "[ n = (@n. P n); EX! n. P n ] ==> P n" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

653 
by (blast intro: someI2) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

654 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

655 
lemma (in recpower_idom_char_0) order: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

656 
"(([a, 1] %^ n) divides p & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

657 
~(([a, 1] %^ (Suc n)) divides p)) = 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

658 
((n = order a p) & ~(poly p = poly []))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

659 
apply (unfold order_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

660 
apply (rule iffI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

661 
apply (blast dest: poly_divides_zero intro!: some1_equality [symmetric] poly_order) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

662 
apply (blast intro!: poly_order [THEN [2] some1_equalityD]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

663 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

664 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

665 
lemma (in recpower_idom_char_0) order2: "[ poly p \<noteq> poly [] ] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

666 
==> ([a, 1] %^ (order a p)) divides p & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

667 
~(([a, 1] %^ (Suc(order a p))) divides p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

668 
by (simp add: order del: pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

669 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

670 
lemma (in recpower_idom_char_0) order_unique: "[ poly p \<noteq> poly []; ([a, 1] %^ n) divides p; 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

671 
~(([a, 1] %^ (Suc n)) divides p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

672 
] ==> (n = order a p)" 
30488  673 
by (insert order [of a n p], auto) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

674 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

675 
lemma (in recpower_idom_char_0) order_unique_lemma: "(poly p \<noteq> poly [] & ([a, 1] %^ n) divides p & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

676 
~(([a, 1] %^ (Suc n)) divides p)) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

677 
==> (n = order a p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

678 
by (blast intro: order_unique) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

679 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

680 
lemma (in ring_1) order_poly: "poly p = poly q ==> order a p = order a q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

681 
by (auto simp add: fun_eq divides_def poly_mult order_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

682 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

683 
lemma (in semiring_1) pexp_one[simp]: "p %^ (Suc 0) = p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

684 
apply (induct "p") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

685 
apply (auto simp add: numeral_1_eq_1) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

686 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

687 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

688 
lemma (in comm_ring_1) lemma_order_root: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

689 
" 0 < n & [ a, 1] %^ n divides p & ~ [ a, 1] %^ (Suc n) divides p 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

690 
\<Longrightarrow> poly p a = 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

691 
apply (induct n arbitrary: a p, blast) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

692 
apply (auto simp add: divides_def poly_mult simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

693 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

694 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

695 
lemma (in recpower_idom_char_0) order_root: "(poly p a = 0) = ((poly p = poly [])  order a p \<noteq> 0)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

696 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

697 
let ?poly = poly 
30488  698 
show ?thesis 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

699 
apply (case_tac "?poly p = ?poly []", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

700 
apply (simp add: poly_linear_divides del: pmult_Cons, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

701 
apply (drule_tac [!] a = a in order2) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

702 
apply (rule ccontr) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

703 
apply (simp add: divides_def poly_mult fun_eq del: pmult_Cons, blast) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

704 
using neq0_conv 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

705 
apply (blast intro: lemma_order_root) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

706 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

707 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

708 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

709 
lemma (in recpower_idom_char_0) order_divides: "(([a, 1] %^ n) divides p) = ((poly p = poly [])  n \<le> order a p)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

710 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

711 
let ?poly = poly 
30488  712 
show ?thesis 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

713 
apply (case_tac "?poly p = ?poly []", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

714 
apply (simp add: divides_def fun_eq poly_mult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

715 
apply (rule_tac x = "[]" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

716 
apply (auto dest!: order2 [where a=a] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

717 
intro: poly_exp_divides simp del: pexp_Suc) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

718 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

719 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

720 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

721 
lemma (in recpower_idom_char_0) order_decomp: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

722 
"poly p \<noteq> poly [] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

723 
==> \<exists>q. (poly p = poly (([a, 1] %^ (order a p)) *** q)) & 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

724 
~([a, 1] divides q)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

725 
apply (unfold divides_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

726 
apply (drule order2 [where a = a]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

727 
apply (simp add: divides_def del: pexp_Suc pmult_Cons, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

728 
apply (rule_tac x = q in exI, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

729 
apply (drule_tac x = qa in spec) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

730 
apply (auto simp add: poly_mult fun_eq poly_exp mult_ac simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

731 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

732 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

733 
text{*Important composition properties of orders.*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

734 
lemma order_mult: "poly (p *** q) \<noteq> poly [] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

735 
==> order a (p *** q) = order a p + order (a::'a::{recpower_idom_char_0}) q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

736 
apply (cut_tac a = a and p = "p *** q" and n = "order a p + order a q" in order) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

737 
apply (auto simp add: poly_entire simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

738 
apply (drule_tac a = a in order2)+ 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

739 
apply safe 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

740 
apply (simp add: divides_def fun_eq poly_exp_add poly_mult del: pmult_Cons, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

741 
apply (rule_tac x = "qa *** qaa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

742 
apply (simp add: poly_mult mult_ac del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

743 
apply (drule_tac a = a in order_decomp)+ 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

744 
apply safe 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

745 
apply (subgoal_tac "[a,1] divides (qa *** qaa) ") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

746 
apply (simp add: poly_primes del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

747 
apply (auto simp add: divides_def simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

748 
apply (rule_tac x = qb in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

749 
apply (subgoal_tac "poly ([a, 1] %^ (order a p) *** (qa *** qaa)) = poly ([a, 1] %^ (order a p) *** ([a, 1] *** qb))") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

750 
apply (drule poly_mult_left_cancel [THEN iffD1], force) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

751 
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))) ") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

752 
apply (drule poly_mult_left_cancel [THEN iffD1], force) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

753 
apply (simp add: fun_eq poly_exp_add poly_mult mult_ac del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

754 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

755 

30488  756 
lemma (in recpower_idom_char_0) order_mult: 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

757 
assumes pq0: "poly (p *** q) \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

758 
shows "order a (p *** q) = order a p + order a q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

759 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

760 
let ?order = order 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

761 
let ?divides = "op divides" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

762 
let ?poly = poly 
30488  763 
from pq0 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

764 
show ?thesis 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

765 
apply (cut_tac a = a and p = "pmult p q" and n = "?order a p + ?order a q" in order) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

766 
apply (auto simp add: poly_entire simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

767 
apply (drule_tac a = a in order2)+ 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

768 
apply safe 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

769 
apply (simp add: divides_def fun_eq poly_exp_add poly_mult del: pmult_Cons, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

770 
apply (rule_tac x = "pmult qa qaa" in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

771 
apply (simp add: poly_mult mult_ac del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

772 
apply (drule_tac a = a in order_decomp)+ 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

773 
apply safe 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

774 
apply (subgoal_tac "?divides [uminus a,one ] (pmult qa qaa) ") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

775 
apply (simp add: poly_primes del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

776 
apply (auto simp add: divides_def simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

777 
apply (rule_tac x = qb in exI) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

778 
apply (subgoal_tac "?poly (pmult (pexp [uminus a, one] (?order a p)) (pmult qa qaa)) = ?poly (pmult (pexp [uminus a, one] (?order a p)) (pmult [uminus a, one] qb))") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

779 
apply (drule poly_mult_left_cancel [THEN iffD1], force) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

780 
apply (subgoal_tac "?poly (pmult (pexp [uminus a, one ] (order a q)) (pmult (pexp [uminus a, one] (order a p)) (pmult qa qaa))) = ?poly (pmult (pexp [uminus a, one] (order a q)) (pmult (pexp [uminus a, one] (order a p)) (pmult [uminus a, one] qb))) ") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

781 
apply (drule poly_mult_left_cancel [THEN iffD1], force) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

782 
apply (simp add: fun_eq poly_exp_add poly_mult mult_ac del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

783 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

784 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

785 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

786 
lemma (in recpower_idom_char_0) order_root2: "poly p \<noteq> poly [] ==> (poly p a = 0) = (order a p \<noteq> 0)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

787 
by (rule order_root [THEN ssubst], auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

788 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

789 
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

790 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

791 
lemma (in semiring_0) poly_Nil_zero: "poly [] = poly [0]" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

792 
by (simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

793 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

794 
lemma (in recpower_idom_char_0) rsquarefree_decomp: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

795 
"[ rsquarefree p; poly p a = 0 ] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

796 
==> \<exists>q. (poly p = poly ([a, 1] *** q)) & poly q a \<noteq> 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

797 
apply (simp add: rsquarefree_def, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

798 
apply (frule_tac a = a in order_decomp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

799 
apply (drule_tac x = a in spec) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

800 
apply (drule_tac a = a in order_root2 [symmetric]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

801 
apply (auto simp del: pmult_Cons) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

802 
apply (rule_tac x = q in exI, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

803 
apply (simp add: poly_mult fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

804 
apply (drule_tac p1 = q in poly_linear_divides [THEN iffD1]) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

805 
apply (simp add: divides_def del: pmult_Cons, safe) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

806 
apply (drule_tac x = "[]" in spec) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

807 
apply (auto simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

808 
done 
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 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

811 
text{*Normalization of a polynomial.*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

812 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

813 
lemma (in semiring_0) poly_normalize[simp]: "poly (pnormalize p) = poly p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

814 
apply (induct "p") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

815 
apply (auto simp add: fun_eq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

816 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

817 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

818 
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

819 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

820 
lemma (in semiring_0) lemma_degree_zero: 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

821 
"list_all (%c. c = 0) p \<longleftrightarrow> pnormalize p = []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

822 
by (induct "p", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

823 

30488  824 
lemma (in idom_char_0) degree_zero: 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

825 
assumes pN: "poly p = poly []" shows"degree p = 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

826 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

827 
let ?pn = pnormalize 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

828 
from pN 
30488  829 
show ?thesis 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

830 
apply (simp add: degree_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

831 
apply (case_tac "?pn p = []") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

832 
apply (auto simp add: poly_zero lemma_degree_zero ) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

833 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

834 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

835 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

836 
lemma (in semiring_0) pnormalize_sing: "(pnormalize [x] = [x]) \<longleftrightarrow> x \<noteq> 0" by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

837 
lemma (in semiring_0) pnormalize_pair: "y \<noteq> 0 \<longleftrightarrow> (pnormalize [x, y] = [x, y])" by simp 
30488  838 
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

839 
unfolding pnormal_def by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

840 
lemma (in semiring_0) pnormal_tail: "p\<noteq>[] \<Longrightarrow> pnormal (c#p) \<Longrightarrow> pnormal p" 
30488  841 
unfolding pnormal_def 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

842 
apply (cases "pnormalize p = []", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

843 
by (cases "c = 0", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

844 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

845 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

846 
lemma (in semiring_0) pnormal_last_nonzero: "pnormal p ==> last p \<noteq> 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

847 
proof(induct p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

848 
case Nil thus ?case by (simp add: pnormal_def) 
30488  849 
next 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

850 
case (Cons a as) thus ?case 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

851 
apply (simp add: pnormal_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

852 
apply (cases "pnormalize as = []", simp_all) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

853 
apply (cases "as = []", simp_all) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

854 
apply (cases "a=0", simp_all) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

855 
apply (cases "a=0", simp_all) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

856 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

857 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

858 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

859 
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

860 
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

861 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

862 
lemma (in semiring_0) pnormal_last_length: "\<lbrakk>0 < length p ; last p \<noteq> 0\<rbrakk> \<Longrightarrow> pnormal p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

863 
apply (induct p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

864 
apply (case_tac "p = []", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

865 
apply (simp add: pnormal_def) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

866 
by (rule pnormal_cons, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

867 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

868 
lemma (in semiring_0) pnormal_id: "pnormal p \<longleftrightarrow> (0 < length p \<and> last p \<noteq> 0)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

869 
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

870 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

871 
lemma (in idom_char_0) poly_Cons_eq: "poly (c#cs) = poly (d#ds) \<longleftrightarrow> c=d \<and> poly cs = poly ds" (is "?lhs \<longleftrightarrow> ?rhs") 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

872 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

873 
assume eq: ?lhs 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

874 
hence "\<And>x. poly ((c#cs) +++  (d#ds)) x = 0" 
29667  875 
by (simp only: poly_minus poly_add algebra_simps) simp 
876 
hence "poly ((c#cs) +++  (d#ds)) = poly []" by(simp add:expand_fun_eq) 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

877 
hence "c = d \<and> list_all (\<lambda>x. x=0) ((cs +++  ds))" 
29667  878 
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

879 
hence "c = d \<and> (\<forall>x. poly (cs +++  ds) x = 0)" 
30488  880 
unfolding poly_zero[symmetric] by simp 
29667  881 
thus ?rhs by (simp add: poly_minus poly_add algebra_simps expand_fun_eq) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

882 
next 
29667  883 
assume ?rhs then show ?lhs by(simp add:expand_fun_eq) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

884 
qed 
30488  885 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

886 
lemma (in idom_char_0) pnormalize_unique: "poly p = poly q \<Longrightarrow> pnormalize p = pnormalize q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

887 
proof(induct q arbitrary: p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

888 
case Nil 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

889 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

890 
case (Cons c cs p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

891 
thus ?case 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

892 
proof(induct p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

893 
case Nil 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

894 
hence "poly [] = poly (c#cs)" by blast 
30488  895 
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

896 
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

897 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

898 
case (Cons d ds) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

899 
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

900 
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

901 
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

902 
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

903 
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

904 
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

905 
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

906 
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

907 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

908 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

909 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

910 
lemma (in idom_char_0) degree_unique: assumes pq: "poly p = poly q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

911 
shows "degree p = degree q" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

912 
using pnormalize_unique[OF pq] unfolding degree_def by simp 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

913 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

914 
lemma (in semiring_0) pnormalize_length: "length (pnormalize p) \<le> length p" by (induct p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

915 

30488  916 
lemma (in semiring_0) last_linear_mul_lemma: 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

917 
"last ((a %* p) +++ (x#(b %* p))) = (if p=[] then x else b*last p)" 
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 
apply (induct p arbitrary: a x b, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

920 
apply (subgoal_tac "padd (cmult aa p) (times b a # cmult b p) \<noteq> []", simp) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

921 
apply (induct_tac p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

922 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

923 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

924 
lemma (in semiring_1) last_linear_mul: assumes p:"p\<noteq>[]" shows "last ([a,1] *** p) = last p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

925 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

926 
from p obtain c cs where cs: "p = c#cs" by (cases p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

927 
from cs have eq:"[a,1] *** p = (a %* (c#cs)) +++ (0#(1 %* (c#cs)))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

928 
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

929 
show ?thesis using cs 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

930 
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

931 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

932 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

933 
lemma (in semiring_0) pnormalize_eq: "last p \<noteq> 0 \<Longrightarrow> pnormalize p = p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

934 
apply (induct p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

935 
apply (case_tac p, auto)+ 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

936 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

937 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

938 
lemma (in semiring_0) last_pnormalize: "pnormalize p \<noteq> [] \<Longrightarrow> last (pnormalize p) \<noteq> 0" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

939 
by (induct p, auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

940 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

941 
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

942 
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

943 

26313  944 
lemma (in semiring_0) poly_Nil_ext: "poly [] = (\<lambda>x. 0)" by (rule ext) 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 
lemma (in idom_char_0) linear_mul_degree: assumes p: "poly p \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

947 
shows "degree ([a,1] *** p) = degree p + 1" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

948 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

949 
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

950 
unfolding poly_zero lemma_degree_zero . 
30488  951 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

952 
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

953 
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

954 
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

955 
pnormal_degree[OF l0] pnormal_degree[OF last_pnormalize[OF pnz]] pnz 
30488  956 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

957 

30488  958 
have th: "degree ([a,1] *** pnormalize p) = degree (pnormalize p) + 1" 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

959 
by (auto simp add: poly_length_mult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

960 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

961 
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

962 
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

963 
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

964 
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

965 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

966 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

967 
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

968 
"degree([a,1] %^n *** p) = (if poly p = poly [] then 0 else degree p + n)" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

969 
proof(induct n arbitrary: a p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

970 
case (0 a p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

971 
{assume p: "poly p = poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

972 
hence ?case using degree_unique[OF p] by (simp add: degree_def)} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

973 
moreover 
26313  974 
{assume p: "poly p \<noteq> poly []" hence ?case by (auto simp add: poly_Nil_ext) } 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

975 
ultimately show ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

976 
next 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

977 
case (Suc n a p) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

978 
have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1] %^ n *** ([a,1] *** p))" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

979 
apply (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

980 
by (simp add: mult_ac add_ac right_distrib) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

981 
note deq = degree_unique[OF eq] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

982 
{assume p: "poly p = poly []" 
30488  983 
with eq have eq': "poly ([a,1] %^(Suc n) *** p) = poly []" 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

984 
by  (rule ext,simp add: poly_mult poly_cmult poly_add) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

985 
from degree_unique[OF eq'] p have ?case by (simp add: degree_def)} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

986 
moreover 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

987 
{assume p: "poly p \<noteq> poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

988 
from p have ap: "poly ([a,1] *** p) \<noteq> poly []" 
30488  989 
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

990 
have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1]%^n *** ([a,1] *** p))" 
29667  991 
by (rule ext, simp add: poly_mult poly_add poly_exp poly_cmult algebra_simps) 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

992 
from ap have ap': "(poly ([a,1] *** p) = poly []) = False" by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

993 
have th0: "degree ([a,1]%^n *** ([a,1] *** p)) = degree ([a,1] *** p) + n" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

994 
apply (simp only: Suc.hyps[of a "pmult [a,one] p"] ap') 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

995 
by simp 
30488  996 

26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

997 
from degree_unique[OF eq] ap p th0 linear_mul_degree[OF p, of a] 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

998 
have ?case by (auto simp del: poly.simps)} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

999 
ultimately show ?case by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1000 
qed 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1001 

30488  1002 
lemma (in recpower_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

1003 
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

1004 
shows "order a p \<le> degree p" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1005 
proof 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1006 
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

1007 
obtain q where q: "poly p = poly ([ a, 1]%^ (order a p) *** q)" by blast 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1008 
{assume "poly q = poly []" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1009 
with q p0 have False by (simp add: poly_mult poly_entire)} 
30488  1010 
with degree_unique[OF q, unfolded linear_pow_mul_degree] 
26124
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1011 
show ?thesis by auto 
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 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1016 
lemma (in idom_char_0) poly_roots_finite_set: "poly p \<noteq> poly [] ==> finite {x. poly p x = 0}" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1017 
unfolding poly_roots_finite . 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1018 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1019 
text{*bound for polynomial.*} 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1020 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1021 
lemma poly_mono: "abs(x) \<le> k ==> abs(poly p (x::'a::{ordered_idom})) \<le> poly (map abs p) k" 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1022 
apply (induct "p", auto) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1023 
apply (rule_tac y = "abs a + abs (x * poly p x)" in order_trans) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1024 
apply (rule abs_triangle_ineq) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1025 
apply (auto intro!: mult_mono simp add: abs_mult) 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1026 
done 
2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1027 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1028 
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

1029 

2514f0ade8bc
A library for univariate polynomials  generalizes old Hyperreal/Poly.thy from reals to locales
chaieb
parents:
diff
changeset

1030 
end 