
(/VERSIONCHECK 2) 

(DEFUN |WP;changeWeightLevel;NniV;1| (|n| $) (SETELT $ 12 |n|)) 

(DEFUN |WP;lookup| (|v| $)
  (PROG (|l| #1=#:G677)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (LETT |l| (QREFELT $ 20) . #2=(|WP;lookup|))
            (SEQ G190
                 (COND
                  ((NULL
                    (COND ((SPADCALL |l| NIL (QREFELT $ 24)) 'NIL) ('T 'T)))
                   (GO G191)))
                 (SEQ
                  (EXIT
                   (COND
                    ((SPADCALL |v| (QCAR (|SPADfirst| |l|)) (QREFELT $ 25))
                     (PROGN
                      (LETT #1# (QCDR (|SPADfirst| |l|)) . #2#)
                      (GO #1#)))
                    ('T (LETT |l| (CDR |l|) . #2#)))))
                 NIL (GO G190) G191 (EXIT NIL))
            (EXIT 0)))
      #1# (EXIT #1#))))) 

(DEFUN |WP;innercoerce| (|p| |z| $)
  (PROG (|tmp| |ans| |mon| |up| |lcup| |f| |d| |n| |mv|)
    (RETURN
     (SEQ
      (COND
       ((OR (< |z| 0) (SPADCALL |p| (QREFELT $ 27))) (|spadConstant| $ 26))
       ('T
        (SEQ (LETT |mv| (SPADCALL |p| (QREFELT $ 29)) . #1=(|WP;innercoerce|))
             (EXIT
              (COND ((QEQCAR |mv| 1) (SPADCALL |p| 0 (QREFELT $ 30)))
                    ('T
                     (SEQ (LETT |n| (|WP;lookup| (QCDR |mv|) $) . #1#)
                          (LETT |up| (SPADCALL |p| (QCDR |mv|) (QREFELT $ 32))
                                . #1#)
                          (LETT |ans| (|spadConstant| $ 26) . #1#)
                          (SEQ G190
                               (COND
                                ((NULL
                                  (COND ((SPADCALL |up| (QREFELT $ 34)) 'NIL)
                                        ('T 'T)))
                                 #2=(GO G191)))
                               (SEQ
                                (LETT |d| (SPADCALL |up| (QREFELT $ 35)) . #1#)
                                (LETT |f| (* |n| |d|) . #1#)
                                (LETT |lcup| (SPADCALL |up| (QREFELT $ 36))
                                      . #1#)
                                (LETT |up|
                                      (SPADCALL |up|
                                                (SPADCALL |up| (QREFELT $ 37))
                                                (QREFELT $ 38))
                                      . #1#)
                                (LETT |mon|
                                      (SPADCALL (|spadConstant| $ 39)
                                                (QCDR |mv|) |d| (QREFELT $ 40))
                                      . #1#)
                                (EXIT
                                 (COND
                                  ((NULL (< |z| |f|))
                                   (SEQ
                                    (LETT |tmp|
                                          (|WP;innercoerce| |lcup| (- |z| |f|)
                                           $)
                                          . #1#)
                                    (EXIT
                                     (SEQ G190
                                          (COND
                                           ((NULL
                                             (COND
                                              ((SPADCALL |tmp| (QREFELT $ 41))
                                               'NIL)
                                              ('T 'T)))
                                            #2#))
                                          (SEQ
                                           (LETT |ans|
                                                 (SPADCALL |ans|
                                                           (SPADCALL
                                                            (SPADCALL |mon|
                                                                      (SPADCALL
                                                                       |tmp|
                                                                       (QREFELT
                                                                        $ 42))
                                                                      (QREFELT
                                                                       $ 43))
                                                            (+
                                                             (SPADCALL |tmp|
                                                                       (QREFELT
                                                                        $ 44))
                                                             |f|)
                                                            (QREFELT $ 30))
                                                           (QREFELT $ 45))
                                                 . #1#)
                                           (EXIT
                                            (LETT |tmp|
                                                  (SPADCALL |tmp|
                                                            (QREFELT $ 46))
                                                  . #1#)))
                                          NIL #3=(GO G190) G191
                                          (EXIT NIL))))))))
                               NIL #3# G191 (EXIT NIL))
                          (EXIT |ans|)))))))))))) 

(DEFUN |WP;coerce;P$;4| (|p| $) (|WP;innercoerce| |p| (QREFELT $ 12) $)) 

(DEFUN |WP;coerce;$P;5| (|w| $)
  (PROG (#1=#:G697 #2=#:G696 #3=#:G698 #4=#:G700 |c|)
    (RETURN
     (SEQ
      (PROGN
       (LETT #1# NIL . #5=(|WP;coerce;$P;5|))
       (SEQ (LETT |c| NIL . #5#) (LETT #4# (SPADCALL |w| (QREFELT $ 49)) . #5#)
            G190
            (COND
             ((OR (ATOM #4#) (PROGN (LETT |c| (CAR #4#) . #5#) NIL))
              (GO G191)))
            (SEQ
             (EXIT
              (PROGN
               (LETT #3# |c| . #5#)
               (COND (#1# (LETT #2# (SPADCALL #2# #3# (QREFELT $ 50)) . #5#))
                     ('T (PROGN (LETT #2# #3# . #5#) (LETT #1# 'T . #5#)))))))
            (LETT #4# (CDR #4#) . #5#) (GO G190) G191 (EXIT NIL))
       (COND (#1# #2#) ('T (|spadConstant| $ 51)))))))) 

(DEFUN |WP;coerce;$Of;6| (|p| $)
  (PROG (#1=#:G708 |c| #2=#:G707)
    (RETURN
     (SEQ
      (COND ((SPADCALL |p| (QREFELT $ 41)) (SPADCALL 0 (QREFELT $ 55)))
            ((EQL (SPADCALL |p| (QREFELT $ 44)) 0)
             (SPADCALL (SPADCALL |p| (QREFELT $ 42)) (QREFELT $ 56)))
            ('T
             (SPADCALL (ELT $ 58)
                       (REVERSE
                        (PROGN
                         (LETT #2# NIL . #3=(|WP;coerce;$Of;6|))
                         (SEQ (LETT |c| NIL . #3#)
                              (LETT #1# (SPADCALL |p| (QREFELT $ 49)) . #3#)
                              G190
                              (COND
                               ((OR (ATOM #1#)
                                    (PROGN (LETT |c| (CAR #1#) . #3#) NIL))
                                (GO G191)))
                              (SEQ
                               (EXIT
                                (LETT #2#
                                      (CONS
                                       (SPADCALL (SPADCALL |c| (QREFELT $ 56))
                                                 (QREFELT $ 57))
                                       #2#)
                                      . #3#)))
                              (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                              (EXIT (NREVERSE0 #2#)))))
                       (QREFELT $ 61)))))))) 

(DEFUN |WP;Zero;$;7| ($) (|spadConstant| $ 63)) 

(DEFUN |WP;One;$;8| ($) (|spadConstant| $ 64)) 

(DEFUN |WP;=;2$B;9| (|x1| |x2| $)
  (SEQ
   (SEQ G190
        (COND
         ((NULL (< (QREFELT $ 12) (SPADCALL |x1| (QREFELT $ 44))))
          #1=(GO G191)))
        (SEQ
         (EXIT (LETT |x1| (SPADCALL |x1| (QREFELT $ 46)) . #2=(|WP;=;2$B;9|))))
        NIL #3=(GO G190) G191 (EXIT NIL))
   (SEQ G190
        (COND ((NULL (< (QREFELT $ 12) (SPADCALL |x2| (QREFELT $ 44)))) #1#))
        (SEQ (EXIT (LETT |x2| (SPADCALL |x2| (QREFELT $ 46)) . #2#))) NIL #3#
        G191 (EXIT NIL))
   (EXIT (SPADCALL |x1| |x2| (QREFELT $ 66))))) 

(DEFUN |WP;+;3$;10| (|x1| |x2| $) (SPADCALL |x1| |x2| (QREFELT $ 68))) 

(DEFUN |WP;-;2$;11| (|x1| $) (SPADCALL |x1| (QREFELT $ 69))) 

(DEFUN |WP;*;3$;12| (|x1| |x2| $)
  (PROG (|w|)
    (RETURN
     (SEQ (LETT |w| (SPADCALL |x1| |x2| (QREFELT $ 70)) . #1=(|WP;*;3$;12|))
          (SEQ G190
               (COND
                ((NULL (< (QREFELT $ 12) (SPADCALL |w| (QREFELT $ 44))))
                 (GO G191)))
               (SEQ (EXIT (LETT |w| (SPADCALL |w| (QREFELT $ 46)) . #1#))) NIL
               (GO G190) G191 (EXIT NIL))
          (EXIT |w|))))) 

(DEFUN |WeightedPolynomials| (&REST #1=#:G726)
  (PROG ()
    (RETURN
     (PROG (#2=#:G727)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (|devaluateList| #1#)
                                           (HGET |$ConstructorCache|
                                                 '|WeightedPolynomials|)
                                           '|domainEqualList|)
                . #3=(|WeightedPolynomials|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT
              (PROG1 (APPLY (|function| |WeightedPolynomials;|) #1#)
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|WeightedPolynomials|))))))))))) 

(DEFUN |WeightedPolynomials;| (|#1| |#2| |#3| |#4| |#5| |#6| |#7|)
  (PROG (#1=#:G724 |v| #2=#:G725 |n| #3=#:G723 |pv$| $ |dv$| DV$7 DV$6 DV$5
         DV$4 DV$3 DV$2 DV$1)
    (RETURN
     (SEQ
      (PROGN
       (LETT DV$1 (|devaluate| |#1|) . #4=(|WeightedPolynomials|))
       (LETT DV$2 (|devaluate| |#2|) . #4#)
       (LETT DV$3 (|devaluate| |#3|) . #4#)
       (LETT DV$4 (|devaluate| |#4|) . #4#)
       (LETT DV$5 (|devaluate| |#5|) . #4#)
       (LETT DV$6 (|devaluate| |#6|) . #4#)
       (LETT DV$7 (|devaluate| |#7|) . #4#)
       (LETT |dv$|
             (LIST '|WeightedPolynomials| DV$1 DV$2 DV$3 DV$4 DV$5 DV$6 DV$7)
             . #4#)
       (LETT $ (GETREFV 76) . #4#)
       (QSETREFV $ 0 |dv$|)
       (QSETREFV $ 3
                 (LETT |pv$|
                       (|buildPredVector| 0 0
                                          (LIST
                                           (|HasCategory| |#1|
                                                          '(|CommutativeRing|))
                                           (|HasCategory| |#1| '(|Field|))))
                       . #4#))
       (|haddProp| |$ConstructorCache| '|WeightedPolynomials|
                   (LIST DV$1 DV$2 DV$3 DV$4 DV$5 DV$6 DV$7) (CONS 1 $))
       (|stuffDomainSlots| $)
       (QSETREFV $ 6 |#1|)
       (QSETREFV $ 7 |#2|)
       (QSETREFV $ 8 |#3|)
       (QSETREFV $ 9 |#4|)
       (QSETREFV $ 10 |#5|)
       (QSETREFV $ 11 |#6|)
       (QSETREFV $ 12 |#7|)
       (QSETREFV $ 13 (|PolynomialRing| |#4| (|NonNegativeInteger|)))
       (QSETREFV $ 19 (EQL (LENGTH |#5|) (SPADCALL |#6| (QREFELT $ 18))))
       (COND ((QREFELT $ 19))
             ('T (|error| "incompatible length lists in WeightedPolynomial")))
       (QSETREFV $ 20
                 (PROGN
                  (LETT #3# NIL . #4#)
                  (SEQ (LETT |n| NIL . #4#) (LETT #2# |#6| . #4#)
                       (LETT |v| NIL . #4#) (LETT #1# |#5| . #4#) G190
                       (COND
                        ((OR (ATOM #1#) (PROGN (LETT |v| (CAR #1#) . #4#) NIL)
                             (ATOM #2#) (PROGN (LETT |n| (CAR #2#) . #4#) NIL))
                         (GO G191)))
                       (SEQ (EXIT (LETT #3# (CONS (CONS |v| |n|) #3#) . #4#)))
                       (LETT #1# (PROG1 (CDR #1#) (LETT #2# (CDR #2#) . #4#))
                             . #4#)
                       (GO G190) G191 (EXIT (NREVERSE0 #3#)))))
       $))))) 

(MAKEPROP '|WeightedPolynomials| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) (|local| |#4|) (|local| |#5|) (|local| |#6|)
              (|local| |#7|) '|Rep| (|Void|) (|NonNegativeInteger|)
              |WP;changeWeightLevel;NniV;1| (|List| 15) (0 . |#|) '#:G661
              '|lookupList| (|Boolean|)
              (|Record| (|:| |var| 7) (|:| |weight| 15)) (|List| 22) (5 . =)
              (11 . =)
              (CONS IDENTITY (FUNCALL (|dispatchFunction| |WP;Zero;$;7|) $))
              (17 . |zero?|) (|Union| 7 '"failed") (22 . |mainVariable|)
              (27 . |monomial|) (|SparseUnivariatePolynomial| $)
              (33 . |univariate|) (|SparseUnivariatePolynomial| 9)
              (39 . |zero?|) (44 . |degree|) (49 . |leadingCoefficient|)
              (54 . |leadingMonomial|) (59 . -) (65 . |One|) (69 . |monomial|)
              (76 . |zero?|) (81 . |leadingCoefficient|) (86 . *)
              (92 . |degree|) |WP;+;3$;10| (97 . |reductum|) |WP;coerce;P$;4|
              (|List| 9) (102 . |coefficients|) (107 . +) (113 . |Zero|)
              |WP;coerce;$P;5| (|OutputForm|) (|Integer|) (117 . |coerce|)
              (122 . |coerce|) (127 . |paren|) (132 . +) (|Mapping| 53 53 53)
              (|List| 53) (138 . |reduce|) |WP;coerce;$Of;6| (144 . |Zero|)
              (148 . |One|)
              (CONS IDENTITY (FUNCALL (|dispatchFunction| |WP;One;$;8|) $))
              (152 . =) |WP;=;2$B;9| (158 . +) |WP;-;2$;11| (164 . *)
              |WP;*;3$;12| (|Union| $ '"failed") (|PositiveInteger|) (|String|)
              (|SingleInteger|))
           '#(~= 170 |zero?| 176 |subtractIfCan| 181 |sample| 187 |recip| 191
              |one?| 196 |latex| 201 |hash| 206 |coerce| 211 |characteristic|
              236 |changeWeightLevel| 240 ^ 245 |Zero| 257 |One| 261 = 265 /
              271 - 277 + 288 * 294)
           'NIL
           (CONS
            (|makeByteWordVec2| 1 '(1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0))
            (CONS
             '#(|Algebra&| |Module&| |Ring&| NIL NIL NIL NIL NIL
                |AbelianGroup&| NIL NIL |AbelianMonoid&| |Monoid&| NIL
                |SemiGroup&| |AbelianSemiGroup&| |SetCategory&| NIL
                |BasicType&| NIL)
             (CONS
              '#((|Algebra| 6) (|Module| 6) (|Ring|) (|BiModule| 6 6) (|Rng|)
                 (|LeftModule| $$) (|LeftModule| 6) (|RightModule| 6)
                 (|AbelianGroup|) (|CancellationAbelianMonoid|) (|SemiRing|)
                 (|AbelianMonoid|) (|Monoid|) (|SemiRng|) (|SemiGroup|)
                 (|AbelianSemiGroup|) (|SetCategory|) (|unitsKnown|)
                 (|BasicType|) (|CoercibleTo| 53))
              (|makeByteWordVec2| 75
                                  '(1 17 15 0 18 2 23 21 0 0 24 2 7 21 0 0 25 1
                                    9 21 0 27 1 9 28 0 29 2 13 0 9 15 30 2 9 31
                                    0 7 32 1 33 21 0 34 1 33 15 0 35 1 33 9 0
                                    36 1 33 0 0 37 2 33 0 0 0 38 0 9 0 39 3 9 0
                                    0 7 15 40 1 0 21 0 41 1 13 9 0 42 2 9 0 0 0
                                    43 1 13 15 0 44 1 13 0 0 46 1 13 48 0 49 2
                                    9 0 0 0 50 0 9 0 51 1 54 53 0 55 1 9 53 0
                                    56 1 53 0 0 57 2 53 0 0 0 58 2 60 53 59 0
                                    61 0 13 0 63 0 13 0 64 2 13 21 0 0 66 2 13
                                    0 0 0 68 2 13 0 0 0 70 2 0 21 0 0 1 1 0 21
                                    0 41 2 0 72 0 0 1 0 0 0 1 1 0 72 0 1 1 0 21
                                    0 1 1 0 74 0 1 1 0 75 0 1 1 1 0 6 1 1 0 0 9
                                    47 1 0 9 0 52 1 0 0 54 1 1 0 53 0 62 0 0 15
                                    1 1 0 14 15 16 2 0 0 0 15 1 2 0 0 0 73 1 0
                                    0 0 26 0 0 0 65 2 0 21 0 0 67 2 2 72 0 0 1
                                    1 0 0 0 69 2 0 0 0 0 1 2 0 0 0 0 45 2 1 0 0
                                    6 1 2 1 0 6 0 1 2 0 0 0 0 71 2 0 0 54 0 1 2
                                    0 0 15 0 1 2 0 0 73 0 1)))))
           '|lookupComplete|)) 
