[1201] | 1 | ;;; -*- Mode: Lisp -*-
|
---|
[77] | 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 3 | ;;;
|
---|
| 4 | ;;; Copyright (C) 1999, 2002, 2009, 2015 Marek Rychlik <rychlik@u.arizona.edu>
|
---|
| 5 | ;;;
|
---|
| 6 | ;;; This program is free software; you can redistribute it and/or modify
|
---|
| 7 | ;;; it under the terms of the GNU General Public License as published by
|
---|
| 8 | ;;; the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | ;;; (at your option) any later version.
|
---|
| 10 | ;;;
|
---|
| 11 | ;;; This program is distributed in the hope that it will be useful,
|
---|
| 12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | ;;; GNU General Public License for more details.
|
---|
| 15 | ;;;
|
---|
| 16 | ;;; You should have received a copy of the GNU General Public License
|
---|
| 17 | ;;; along with this program; if not, write to the Free Software
|
---|
| 18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 19 | ;;;
|
---|
| 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 21 |
|
---|
[1927] | 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 23 | ;;
|
---|
| 24 | ;; Polynomials
|
---|
| 25 | ;;
|
---|
| 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
[77] | 27 |
|
---|
[431] | 28 | (defpackage "POLYNOMIAL"
|
---|
[2462] | 29 | (:use :cl :ring :monom :order :term #| :infix |# )
|
---|
[432] | 30 | (:export "POLY"
|
---|
| 31 | ))
|
---|
[143] | 32 |
|
---|
[431] | 33 | (in-package :polynomial)
|
---|
| 34 |
|
---|
[1927] | 35 | (proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0)))
|
---|
[52] | 36 |
|
---|
[2442] | 37 | #|
|
---|
[52] | 38 | ;;
|
---|
| 39 | ;; BOA constructor, by default constructs zero polynomial
|
---|
| 40 | (:constructor make-poly-from-termlist (termlist &optional (sugar (termlist-sugar termlist))))
|
---|
| 41 | (:constructor make-poly-zero (&aux (termlist nil) (sugar -1)))
|
---|
| 42 | ;; Constructor of polynomials representing a variable
|
---|
[1657] | 43 | (:constructor make-poly-variable (ring nvars pos &optional (power 1)
|
---|
[53] | 44 | &aux
|
---|
| 45 | (termlist (list
|
---|
| 46 | (make-term-variable ring nvars pos power)))
|
---|
| 47 | (sugar power)))
|
---|
| 48 | (:constructor poly-unit (ring dimension
|
---|
| 49 | &aux
|
---|
| 50 | (termlist (termlist-unit ring dimension))
|
---|
| 51 | (sugar 0))))
|
---|
[52] | 52 |
|
---|
[2442] | 53 | |#
|
---|
| 54 |
|
---|
| 55 | (defclass poly ()
|
---|
| 56 | ((termlist :initarg :terms :accessor poly-termlist))
|
---|
| 57 | (:default-initargs :termlist nil))
|
---|
| 58 |
|
---|
[2466] | 59 | (defgeneric insert-item (object item)
|
---|
[2464] | 60 | (:method ((self poly) (item (term)))
|
---|
[2465] | 61 | (push item (poly-termlist self))
|
---|
| 62 | self))
|
---|
[2464] | 63 |
|
---|
[2466] | 64 | (defgeneric append-item (object item)
|
---|
[2467] | 65 | (:method ((self poly) (item term))
|
---|
[2466] | 66 | (setf (cdr (last ((poly-termlist self)))) (list item))
|
---|
| 67 | self))
|
---|
| 68 |
|
---|
[52] | 69 | ;; Leading term
|
---|
[2442] | 70 | (defgeneric leading-term (object)
|
---|
| 71 | (:method ((self poly))
|
---|
| 72 | (car (poly-termlist self))))
|
---|
[52] | 73 |
|
---|
| 74 | ;; Second term
|
---|
[2442] | 75 | (defgeneric second-leading-term (object)
|
---|
| 76 | (:method ((self poly))
|
---|
| 77 | (cadar (poly-termlist self))))
|
---|
[52] | 78 |
|
---|
| 79 | ;; Leading coefficient
|
---|
[2442] | 80 | (defgeneric leading-coefficient (object)
|
---|
| 81 | (:method ((self poly))
|
---|
| 82 | (r-coeff (leading-term self))))
|
---|
[52] | 83 |
|
---|
| 84 | ;; Second coefficient
|
---|
[2442] | 85 | (defgeneric second-leading-coefficient (object)
|
---|
| 86 | (:method ((self poly))
|
---|
[2463] | 87 | (r-coeff (second-leading-term self))))
|
---|
[52] | 88 |
|
---|
| 89 | ;; Testing for a zero polynomial
|
---|
[2445] | 90 | (defmethod r-zerop ((self poly))
|
---|
| 91 | (null (poly-termlist self)))
|
---|
[52] | 92 |
|
---|
| 93 | ;; The number of terms
|
---|
[2445] | 94 | (defmethod r-length ((self poly))
|
---|
| 95 | (length (poly-termlist self)))
|
---|
[52] | 96 |
|
---|
[2456] | 97 | #|
|
---|
| 98 |
|
---|
[2448] | 99 | (defgeneric multiply-by (self other)
|
---|
| 100 | (:method ((self poly) (other scalar))
|
---|
| 101 | (mapc #'(lambda (term) (multiply-by term other)) (poly-termlist self))
|
---|
| 102 | self)
|
---|
| 103 | (:method ((self poly) (other monom))
|
---|
| 104 | (mapc #'(lambda (term) (multiply-by term monom)) (poly-termlist self))
|
---|
| 105 | self))
|
---|
[1215] | 106 |
|
---|
[2448] | 107 | (defgeneric add-to (self other)
|
---|
| 108 | (:method ((self poly) (other poly))))
|
---|
[53] | 109 |
|
---|
[2448] | 110 | (defgeneric subtract-from (self other)
|
---|
| 111 | (:method ((self poly) (other poly))))
|
---|
[52] | 112 |
|
---|
[2448] | 113 | (defmethod unary-uminus (self))
|
---|
[52] | 114 |
|
---|
| 115 | (defun poly-standard-extension (plist &aux (k (length plist)))
|
---|
| 116 | "Calculate [U1*P1,U2*P2,...,UK*PK], where PLIST=[P1,P2,...,PK]."
|
---|
| 117 | (declare (list plist) (fixnum k))
|
---|
| 118 | (labels ((incf-power (g i)
|
---|
| 119 | (dolist (x (poly-termlist g))
|
---|
| 120 | (incf (monom-elt (term-monom x) i)))
|
---|
| 121 | (incf (poly-sugar g))))
|
---|
| 122 | (setf plist (poly-list-add-variables plist k))
|
---|
| 123 | (dotimes (i k plist)
|
---|
| 124 | (incf-power (nth i plist) i))))
|
---|
| 125 |
|
---|
[1473] | 126 | (defun saturation-extension (ring f plist
|
---|
| 127 | &aux
|
---|
| 128 | (k (length plist))
|
---|
[1474] | 129 | (d (monom-dimension (poly-lm (car plist))))
|
---|
| 130 | f-x plist-x)
|
---|
[52] | 131 | "Calculate [F, U1*P1-1,U2*P2-1,...,UK*PK-1], where PLIST=[P1,P2,...,PK]."
|
---|
[1907] | 132 | (declare (type ring ring))
|
---|
[1474] | 133 | (setf f-x (poly-list-add-variables f k)
|
---|
| 134 | plist-x (mapcar #'(lambda (x)
|
---|
[1843] | 135 | (setf (poly-termlist x)
|
---|
| 136 | (nconc (poly-termlist x)
|
---|
| 137 | (list (make-term :monom (make-monom :dimension d)
|
---|
[1844] | 138 | :coeff (funcall (ring-uminus ring)
|
---|
| 139 | (funcall (ring-unit ring)))))))
|
---|
[1474] | 140 | x)
|
---|
| 141 | (poly-standard-extension plist)))
|
---|
| 142 | (append f-x plist-x))
|
---|
[52] | 143 |
|
---|
| 144 |
|
---|
[1475] | 145 | (defun polysaturation-extension (ring f plist
|
---|
| 146 | &aux
|
---|
| 147 | (k (length plist))
|
---|
[1476] | 148 | (d (+ k (monom-dimension (poly-lm (car plist)))))
|
---|
[1494] | 149 | ;; Add k variables to f
|
---|
[1493] | 150 | (f (poly-list-add-variables f k))
|
---|
[1495] | 151 | ;; Set PLIST to [U1*P1,U2*P2,...,UK*PK]
|
---|
[1493] | 152 | (plist (apply #'poly-append (poly-standard-extension plist))))
|
---|
[1497] | 153 | "Calculate [F, U1*P1+U2*P2+...+UK*PK-1], where PLIST=[P1,P2,...,PK]. It destructively modifies F."
|
---|
[1493] | 154 | ;; Add -1 as the last term
|
---|
[1908] | 155 | (declare (type ring ring))
|
---|
[1493] | 156 | (setf (cdr (last (poly-termlist plist)))
|
---|
[1845] | 157 | (list (make-term :monom (make-monom :dimension d)
|
---|
| 158 | :coeff (funcall (ring-uminus ring) (funcall (ring-unit ring))))))
|
---|
[1493] | 159 | (append f (list plist)))
|
---|
[52] | 160 |
|
---|
[1477] | 161 | (defun saturation-extension-1 (ring f p)
|
---|
[1497] | 162 | "Calculate [F, U*P-1]. It destructively modifies F."
|
---|
[1908] | 163 | (declare (type ring ring))
|
---|
[1477] | 164 | (polysaturation-extension ring f (list p)))
|
---|
[53] | 165 |
|
---|
| 166 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 167 | ;;
|
---|
| 168 | ;; Evaluation of polynomial (prefix) expressions
|
---|
| 169 | ;;
|
---|
| 170 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 171 |
|
---|
| 172 | (defun coerce-coeff (ring expr vars)
|
---|
| 173 | "Coerce an element of the coefficient ring to a constant polynomial."
|
---|
| 174 | ;; Modular arithmetic handler by rat
|
---|
[1908] | 175 | (declare (type ring ring))
|
---|
[1846] | 176 | (make-poly-from-termlist (list (make-term :monom (make-monom :dimension (length vars))
|
---|
| 177 | :coeff (funcall (ring-parse ring) expr)))
|
---|
[53] | 178 | 0))
|
---|
| 179 |
|
---|
[1046] | 180 | (defun poly-eval (expr vars
|
---|
| 181 | &optional
|
---|
[1668] | 182 | (ring +ring-of-integers+)
|
---|
[1048] | 183 | (order #'lex>)
|
---|
[1170] | 184 | (list-marker :[)
|
---|
[1047] | 185 | &aux
|
---|
| 186 | (ring-and-order (make-ring-and-order :ring ring :order order)))
|
---|
[1168] | 187 | "Evaluate Lisp form EXPR to a polynomial or a list of polynomials in
|
---|
[1208] | 188 | variables VARS. Return the resulting polynomial or list of
|
---|
| 189 | polynomials. Standard arithmetical operators in form EXPR are
|
---|
| 190 | replaced with their analogues in the ring of polynomials, and the
|
---|
| 191 | resulting expression is evaluated, resulting in a polynomial or a list
|
---|
[1209] | 192 | of polynomials in internal form. A similar operation in another computer
|
---|
| 193 | algebra system could be called 'expand' or so."
|
---|
[1909] | 194 | (declare (type ring ring))
|
---|
[1050] | 195 | (labels ((p-eval (arg) (poly-eval arg vars ring order))
|
---|
[1140] | 196 | (p-eval-scalar (arg) (poly-eval-scalar arg))
|
---|
[53] | 197 | (p-eval-list (args) (mapcar #'p-eval args))
|
---|
[989] | 198 | (p-add (x y) (poly-add ring-and-order x y)))
|
---|
[53] | 199 | (cond
|
---|
[1128] | 200 | ((null expr) (error "Empty expression"))
|
---|
[53] | 201 | ((eql expr 0) (make-poly-zero))
|
---|
| 202 | ((member expr vars :test #'equalp)
|
---|
| 203 | (let ((pos (position expr vars :test #'equalp)))
|
---|
[1657] | 204 | (make-poly-variable ring (length vars) pos)))
|
---|
[53] | 205 | ((atom expr)
|
---|
| 206 | (coerce-coeff ring expr vars))
|
---|
| 207 | ((eq (car expr) list-marker)
|
---|
| 208 | (cons list-marker (p-eval-list (cdr expr))))
|
---|
| 209 | (t
|
---|
| 210 | (case (car expr)
|
---|
| 211 | (+ (reduce #'p-add (p-eval-list (cdr expr))))
|
---|
| 212 | (- (case (length expr)
|
---|
| 213 | (1 (make-poly-zero))
|
---|
| 214 | (2 (poly-uminus ring (p-eval (cadr expr))))
|
---|
[989] | 215 | (3 (poly-sub ring-and-order (p-eval (cadr expr)) (p-eval (caddr expr))))
|
---|
| 216 | (otherwise (poly-sub ring-and-order (p-eval (cadr expr))
|
---|
[53] | 217 | (reduce #'p-add (p-eval-list (cddr expr)))))))
|
---|
| 218 | (*
|
---|
| 219 | (if (endp (cddr expr)) ;unary
|
---|
| 220 | (p-eval (cdr expr))
|
---|
[989] | 221 | (reduce #'(lambda (p q) (poly-mul ring-and-order p q)) (p-eval-list (cdr expr)))))
|
---|
[1106] | 222 | (/
|
---|
| 223 | ;; A polynomial can be divided by a scalar
|
---|
[1115] | 224 | (cond
|
---|
| 225 | ((endp (cddr expr))
|
---|
[1117] | 226 | ;; A special case (/ ?), the inverse
|
---|
[1119] | 227 | (coerce-coeff ring (apply (ring-div ring) (cdr expr)) vars))
|
---|
[1128] | 228 | (t
|
---|
[1115] | 229 | (let ((num (p-eval (cadr expr)))
|
---|
[1142] | 230 | (denom-inverse (apply (ring-div ring)
|
---|
| 231 | (cons (funcall (ring-unit ring))
|
---|
| 232 | (mapcar #'p-eval-scalar (cddr expr))))))
|
---|
[1118] | 233 | (scalar-times-poly ring denom-inverse num)))))
|
---|
[53] | 234 | (expt
|
---|
| 235 | (cond
|
---|
| 236 | ((member (cadr expr) vars :test #'equalp)
|
---|
| 237 | ;;Special handling of (expt var pow)
|
---|
| 238 | (let ((pos (position (cadr expr) vars :test #'equalp)))
|
---|
[1657] | 239 | (make-poly-variable ring (length vars) pos (caddr expr))))
|
---|
[53] | 240 | ((not (and (integerp (caddr expr)) (plusp (caddr expr))))
|
---|
| 241 | ;; Negative power means division in coefficient ring
|
---|
| 242 | ;; Non-integer power means non-polynomial coefficient
|
---|
| 243 | (coerce-coeff ring expr vars))
|
---|
[989] | 244 | (t (poly-expt ring-and-order (p-eval (cadr expr)) (caddr expr)))))
|
---|
[53] | 245 | (otherwise
|
---|
| 246 | (coerce-coeff ring expr vars)))))))
|
---|
| 247 |
|
---|
[1133] | 248 | (defun poly-eval-scalar (expr
|
---|
| 249 | &optional
|
---|
[1668] | 250 | (ring +ring-of-integers+)
|
---|
[1133] | 251 | &aux
|
---|
| 252 | (order #'lex>))
|
---|
| 253 | "Evaluate a scalar expression EXPR in ring RING."
|
---|
[1910] | 254 | (declare (type ring ring))
|
---|
[1133] | 255 | (poly-lc (poly-eval expr nil ring order)))
|
---|
| 256 |
|
---|
[1189] | 257 | (defun spoly (ring-and-order f g
|
---|
| 258 | &aux
|
---|
| 259 | (ring (ro-ring ring-and-order)))
|
---|
[55] | 260 | "It yields the S-polynomial of polynomials F and G."
|
---|
[1911] | 261 | (declare (type ring-and-order ring-and-order) (type poly f g))
|
---|
[55] | 262 | (let* ((lcm (monom-lcm (poly-lm f) (poly-lm g)))
|
---|
| 263 | (mf (monom-div lcm (poly-lm f)))
|
---|
| 264 | (mg (monom-div lcm (poly-lm g))))
|
---|
| 265 | (declare (type monom mf mg))
|
---|
| 266 | (multiple-value-bind (c cf cg)
|
---|
| 267 | (funcall (ring-ezgcd ring) (poly-lc f) (poly-lc g))
|
---|
| 268 | (declare (ignore c))
|
---|
| 269 | (poly-sub
|
---|
[1189] | 270 | ring-and-order
|
---|
[55] | 271 | (scalar-times-poly ring cg (monom-times-poly mf f))
|
---|
| 272 | (scalar-times-poly ring cf (monom-times-poly mg g))))))
|
---|
[53] | 273 |
|
---|
| 274 |
|
---|
[55] | 275 | (defun poly-primitive-part (ring p)
|
---|
| 276 | "Divide polynomial P with integer coefficients by gcd of its
|
---|
| 277 | coefficients and return the result."
|
---|
[1912] | 278 | (declare (type ring ring) (type poly p))
|
---|
[55] | 279 | (if (poly-zerop p)
|
---|
| 280 | (values p 1)
|
---|
| 281 | (let ((c (poly-content ring p)))
|
---|
[1203] | 282 | (values (make-poly-from-termlist
|
---|
| 283 | (mapcar
|
---|
| 284 | #'(lambda (x)
|
---|
[1847] | 285 | (make-term :monom (term-monom x)
|
---|
| 286 | :coeff (funcall (ring-div ring) (term-coeff x) c)))
|
---|
[1203] | 287 | (poly-termlist p))
|
---|
| 288 | (poly-sugar p))
|
---|
| 289 | c))))
|
---|
[55] | 290 |
|
---|
| 291 | (defun poly-content (ring p)
|
---|
| 292 | "Greatest common divisor of the coefficients of the polynomial P. Use the RING structure
|
---|
| 293 | to compute the greatest common divisor."
|
---|
[1913] | 294 | (declare (type ring ring) (type poly p))
|
---|
[55] | 295 | (reduce (ring-gcd ring) (mapcar #'term-coeff (rest (poly-termlist p))) :initial-value (poly-lc p)))
|
---|
[1066] | 296 |
|
---|
[1091] | 297 | (defun read-infix-form (&key (stream t))
|
---|
[1066] | 298 | "Parser of infix expressions with integer/rational coefficients
|
---|
| 299 | The parser will recognize two kinds of polynomial expressions:
|
---|
| 300 |
|
---|
| 301 | - polynomials in fully expanded forms with coefficients
|
---|
| 302 | written in front of symbolic expressions; constants can be optionally
|
---|
| 303 | enclosed in (); for example, the infix form
|
---|
| 304 | X^2-Y^2+(-4/3)*U^2*W^3-5
|
---|
| 305 | parses to
|
---|
| 306 | (+ (- (EXPT X 2) (EXPT Y 2)) (* (- (/ 4 3)) (EXPT U 2) (EXPT W 3)) (- 5))
|
---|
| 307 |
|
---|
| 308 | - lists of polynomials; for example
|
---|
| 309 | [X-Y, X^2+3*Z]
|
---|
| 310 | parses to
|
---|
| 311 | (:[ (- X Y) (+ (EXPT X 2) (* 3 Z)))
|
---|
| 312 | where the first symbol [ marks a list of polynomials.
|
---|
| 313 |
|
---|
| 314 | -other infix expressions, for example
|
---|
| 315 | [(X-Y)*(X+Y)/Z,(X+1)^2]
|
---|
| 316 | parses to:
|
---|
| 317 | (:[ (/ (* (- X Y) (+ X Y)) Z) (EXPT (+ X 1) 2))
|
---|
| 318 | Currently this function is implemented using M. Kantrowitz's INFIX package."
|
---|
| 319 | (read-from-string
|
---|
| 320 | (concatenate 'string
|
---|
| 321 | "#I("
|
---|
| 322 | (with-output-to-string (s)
|
---|
| 323 | (loop
|
---|
| 324 | (multiple-value-bind (line eof)
|
---|
| 325 | (read-line stream t)
|
---|
| 326 | (format s "~A" line)
|
---|
| 327 | (when eof (return)))))
|
---|
| 328 | ")")))
|
---|
| 329 |
|
---|
[1145] | 330 | (defun read-poly (vars &key
|
---|
| 331 | (stream t)
|
---|
[1668] | 332 | (ring +ring-of-integers+)
|
---|
[1145] | 333 | (order #'lex>))
|
---|
[1067] | 334 | "Reads an expression in prefix form from a stream STREAM.
|
---|
[1144] | 335 | The expression read from the strem should represent a polynomial or a
|
---|
| 336 | list of polynomials in variables VARS, over the ring RING. The
|
---|
| 337 | polynomial or list of polynomials is returned, with terms in each
|
---|
| 338 | polynomial ordered according to monomial order ORDER."
|
---|
[1146] | 339 | (poly-eval (read-infix-form :stream stream) vars ring order))
|
---|
[1092] | 340 |
|
---|
[1146] | 341 | (defun string->poly (str vars
|
---|
[1164] | 342 | &optional
|
---|
[1668] | 343 | (ring +ring-of-integers+)
|
---|
[1146] | 344 | (order #'lex>))
|
---|
| 345 | "Converts a string STR to a polynomial in variables VARS."
|
---|
[1097] | 346 | (with-input-from-string (s str)
|
---|
[1165] | 347 | (read-poly vars :stream s :ring ring :order order)))
|
---|
[1095] | 348 |
|
---|
[1143] | 349 | (defun poly->alist (p)
|
---|
| 350 | "Convert a polynomial P to an association list. Thus, the format of the
|
---|
| 351 | returned value is ((MONOM[0] . COEFF[0]) (MONOM[1] . COEFF[1]) ...), where
|
---|
| 352 | MONOM[I] is a list of exponents in the monomial and COEFF[I] is the
|
---|
| 353 | corresponding coefficient in the ring."
|
---|
[1171] | 354 | (cond
|
---|
| 355 | ((poly-p p)
|
---|
| 356 | (mapcar #'term->cons (poly-termlist p)))
|
---|
| 357 | ((and (consp p) (eq (car p) :[))
|
---|
[1172] | 358 | (cons :[ (mapcar #'poly->alist (cdr p))))))
|
---|
[1143] | 359 |
|
---|
[1164] | 360 | (defun string->alist (str vars
|
---|
| 361 | &optional
|
---|
[1668] | 362 | (ring +ring-of-integers+)
|
---|
[1164] | 363 | (order #'lex>))
|
---|
[1143] | 364 | "Convert a string STR representing a polynomial or polynomial list to
|
---|
[1158] | 365 | an association list (... (MONOM . COEFF) ...)."
|
---|
[1166] | 366 | (poly->alist (string->poly str vars ring order)))
|
---|
[1440] | 367 |
|
---|
| 368 | (defun poly-equal-no-sugar-p (p q)
|
---|
| 369 | "Compare polynomials for equality, ignoring sugar."
|
---|
[1914] | 370 | (declare (type poly p q))
|
---|
[1440] | 371 | (equalp (poly-termlist p) (poly-termlist q)))
|
---|
[1559] | 372 |
|
---|
| 373 | (defun poly-set-equal-no-sugar-p (p q)
|
---|
| 374 | "Compare polynomial sets P and Q for equality, ignoring sugar."
|
---|
| 375 | (null (set-exclusive-or p q :test #'poly-equal-no-sugar-p )))
|
---|
[1560] | 376 |
|
---|
| 377 | (defun poly-list-equal-no-sugar-p (p q)
|
---|
| 378 | "Compare polynomial lists P and Q for equality, ignoring sugar."
|
---|
| 379 | (every #'poly-equal-no-sugar-p p q))
|
---|
[2456] | 380 | |#
|
---|