
(/VERSIONCHECK 2) 

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

(DEFUN |WP;lookup| (|v| $)
  (PROG (#0=#:G1831 |l|)
    (RETURN
      (SEQ (EXIT (SEQ (LETT |l| (QREFELT $ 20) . #1=(|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 #0#
                                            (QCDR (|SPADfirst| |l|)) . #1#)
                                           (GO #0#)))
                                        ('T (LETT |l| (CDR |l|) . #1#)))))
                           NIL (GO G190) G191 (EXIT NIL))
                      (EXIT 0)))
           #0# (EXIT #0#))))) 

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

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

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

(DEFUN |WP;coerce;$Of;6| (|p| $)
  (PROG (#0=#:G1861 |c| #1=#:G1862)
    (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 #0# NIL . #2=(|WP;coerce;$Of;6|))
                             (SEQ (LETT |c| NIL . #2#)
                                  (LETT #1#
                                        (SPADCALL |p| (QREFELT $ 49)) . #2#)
                                  G190
                                  (COND
                                    ((OR (ATOM #1#)
                                      (PROGN
                                        (LETT |c| (CAR #1#) . #2#)
                                        NIL))
                                     (GO G191)))
                                  (SEQ (EXIT
                                        (LETT #0#
                                         (CONS
                                          (SPADCALL
                                           (SPADCALL |c|
                                            (QREFELT $ 56))
                                           (QREFELT $ 57))
                                          #0#) . #2#)))
                                  (LETT #1# (CDR #1#) . #2#) (GO G190)
                                  G191 (EXIT (NREVERSE0 #0#)))))
                  (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))))
               #0=(GO G191)))
            (SEQ (EXIT (LETT |x1| (SPADCALL |x1| (QREFELT $ 46))
                             . #1=(|WP;=;2$B;9|))))
            NIL #2=(GO G190) G191 (EXIT NIL))
       (SEQ G190
            (COND
              ((NULL (< (QREFELT $ 12) (SPADCALL |x2| (QREFELT $ 44))))
               #0#))
            (SEQ (EXIT (LETT |x2| (SPADCALL |x2| (QREFELT $ 46)) . #1#)))
            NIL #2# 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))
                 . #0=(|WP;*;3$;12|))
           (SEQ G190
                (COND
                  ((NULL (< (QREFELT $ 12)
                            (SPADCALL |w| (QREFELT $ 44))))
                   (GO G191)))
                (SEQ (EXIT (LETT |w|
                                 (SPADCALL |w| (QREFELT $ 46)) . #0#)))
                NIL (GO G190) G191 (EXIT NIL))
           (EXIT |w|))))) 

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

(DEFUN |WeightedPolynomials;| (|#1| |#2| |#3| |#4| |#5| |#6| |#7|)
  (PROG (DV$1 DV$2 DV$3 DV$4 DV$5 DV$6 DV$7 |dv$| $ |pv$| #0=#:G1877
              |n| #1=#:G1879 |v| #2=#:G1878)
    (RETURN
      (SEQ (PROGN
             (LETT DV$1 (|devaluate| |#1|)
                   . #3=(|WeightedPolynomials|))
             (LETT DV$2 (|devaluate| |#2|) . #3#)
             (LETT DV$3 (|devaluate| |#3|) . #3#)
             (LETT DV$4 (|devaluate| |#4|) . #3#)
             (LETT DV$5 (|devaluate| |#5|) . #3#)
             (LETT DV$6 (|devaluate| |#6|) . #3#)
             (LETT DV$7 (|devaluate| |#7|) . #3#)
             (LETT |dv$|
                   (LIST '|WeightedPolynomials| DV$1 DV$2 DV$3 DV$4
                         DV$5 DV$6 DV$7) . #3#)
             (LETT $ (GETREFV 76) . #3#)
             (QSETREFV $ 0 |dv$|)
             (QSETREFV $ 3
                 (LETT |pv$|
                       (|buildPredVector| 0 0
                           (LIST (|HasCategory| |#1|
                                     '(|CommutativeRing|))
                                 (|HasCategory| |#1| '(|Field|)))) . #3#))
             (|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 #0# NIL . #3#)
                   (SEQ (LETT |n| NIL . #3#) (LETT #1# |#6| . #3#)
                        (LETT |v| NIL . #3#) (LETT #2# |#5| . #3#) G190
                        (COND
                          ((OR (ATOM #2#)
                               (PROGN (LETT |v| (CAR #2#) . #3#) NIL)
                               (ATOM #1#)
                               (PROGN (LETT |n| (CAR #1#) . #3#) NIL))
                           (GO G191)))
                        (SEQ (EXIT (LETT #0#
                                    (CONS (CONS |v| |n|) #0#) . #3#)))
                        (LETT #2#
                              (PROG1 (CDR #2#)
                                (LETT #1# (CDR #1#) . #3#)) . #3#)
                        (GO G190) G191 (EXIT (NREVERSE0 #0#)))))
             $))))) 

(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 . |#|) '#:G1815 '|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 * 306)
          '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 0 54 1 1 0 9 0 52 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 0 0 0 15 1 2 0 0 0
                                  73 1 2 1 0 6 0 1 2 1 0 0 6 1 2 0 0 54
                                  0 1 2 0 0 0 0 71 2 0 0 15 0 1 2 0 0
                                  73 0 1)))))
          '|lookupComplete|)) 
