src/HOL/Library/Commutative_Ring.thy
changeset 21404 eb85850d3eb7
parent 21256 47195501ecf7
child 22665 cf152ff55d16
equal deleted inserted replaced
21403:dd58f13a8eb4 21404:eb85850d3eb7
    46   "Ipolex l (Neg P) = - Ipolex l P"
    46   "Ipolex l (Neg P) = - Ipolex l P"
    47 
    47 
    48 text {* Create polynomial normalized polynomials given normalized inputs. *}
    48 text {* Create polynomial normalized polynomials given normalized inputs. *}
    49 
    49 
    50 definition
    50 definition
    51   mkPinj :: "nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol"
    51   mkPinj :: "nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol" where
    52   "mkPinj x P = (case P of
    52   "mkPinj x P = (case P of
    53     Pc c \<Rightarrow> Pc c |
    53     Pc c \<Rightarrow> Pc c |
    54     Pinj y P \<Rightarrow> Pinj (x + y) P |
    54     Pinj y P \<Rightarrow> Pinj (x + y) P |
    55     PX p1 y p2 \<Rightarrow> Pinj x P)"
    55     PX p1 y p2 \<Rightarrow> Pinj x P)"
    56 
    56 
    57 definition
    57 definition
    58   mkPX :: "'a::{comm_ring,recpower} pol \<Rightarrow> nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol"
    58   mkPX :: "'a::{comm_ring,recpower} pol \<Rightarrow> nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol" where
    59   "mkPX P i Q = (case P of
    59   "mkPX P i Q = (case P of
    60     Pc c \<Rightarrow> (if (c = 0) then (mkPinj 1 Q) else (PX P i Q)) |
    60     Pc c \<Rightarrow> (if (c = 0) then (mkPinj 1 Q) else (PX P i Q)) |
    61     Pinj j R \<Rightarrow> PX P i Q |
    61     Pinj j R \<Rightarrow> PX P i Q |
    62     PX P2 i2 Q2 \<Rightarrow> (if (Q2 = (Pc 0)) then (PX P2 (i+i2) Q) else (PX P i Q)) )"
    62     PX P2 i2 Q2 \<Rightarrow> (if (Q2 = (Pc 0)) then (PX P2 (i+i2) Q) else (PX P i Q)) )"
    63 
    63 
   126   "neg (Pinj i P) = Pinj i (neg P)"
   126   "neg (Pinj i P) = Pinj i (neg P)"
   127   "neg (PX P x Q) = PX (neg P) x (neg Q)"
   127   "neg (PX P x Q) = PX (neg P) x (neg Q)"
   128 
   128 
   129 text {* Substraction *}
   129 text {* Substraction *}
   130 definition
   130 definition
   131   sub :: "'a::{comm_ring,recpower} pol \<Rightarrow> 'a pol \<Rightarrow> 'a pol"
   131   sub :: "'a::{comm_ring,recpower} pol \<Rightarrow> 'a pol \<Rightarrow> 'a pol" where
   132   "sub p q = add (p, neg q)"
   132   "sub p q = add (p, neg q)"
   133 
   133 
   134 text {* Square for Fast Exponentation *}
   134 text {* Square for Fast Exponentation *}
   135 primrec
   135 primrec
   136   "sqr (Pc c) = Pc (c * c)"
   136   "sqr (Pc c) = Pc (c * c)"