
(/VERSIONCHECK 2) 

(PUT '|FM1;numberOfMonomials;$Nni;1| '|SPADreplace| 'LENGTH) 

(DEFUN |FM1;numberOfMonomials;$Nni;1| (|p| $) (LENGTH |p|)) 

(PUT '|FM1;ListOfTerms;$L;2| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |FM1;ListOfTerms;$L;2| (|x| $) |x|) 

(PUT '|FM1;leadingTerm;$R;3| '|SPADreplace| '|SPADfirst|) 

(DEFUN |FM1;leadingTerm;$R;3| (|x| $) (|SPADfirst| |x|)) 

(DEFUN |FM1;leadingMonomial;$S;4| (|x| $) (QCAR (|SPADfirst| |x|))) 

(DEFUN |FM1;coefficients;$L;5| (|x| $)
  (PROG (#0=#:G1832 |t| #1=#:G1833)
    (RETURN
      (SEQ (PROGN
             (LETT #0# NIL . #2=(|FM1;coefficients;$L;5|))
             (SEQ (LETT |t| NIL . #2#) (LETT #1# |x| . #2#) G190
                  (COND
                    ((OR (ATOM #1#)
                         (PROGN (LETT |t| (CAR #1#) . #2#) NIL))
                     (GO G191)))
                  (SEQ (EXIT (LETT #0# (CONS (QCDR |t|) #0#) . #2#)))
                  (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                  (EXIT (NREVERSE0 #0#)))))))) 

(DEFUN |FM1;monomials;$L;6| (|x| $)
  (PROG (#0=#:G1836 |t| #1=#:G1837)
    (RETURN
      (SEQ (PROGN
             (LETT #0# NIL . #2=(|FM1;monomials;$L;6|))
             (SEQ (LETT |t| NIL . #2#) (LETT #1# |x| . #2#) G190
                  (COND
                    ((OR (ATOM #1#)
                         (PROGN (LETT |t| (CAR #1#) . #2#) NIL))
                     (GO G191)))
                  (SEQ (EXIT (LETT #0#
                                   (CONS
                                    (SPADCALL (QCAR |t|) (QCDR |t|)
                                     (QREFELT $ 18))
                                    #0#) . #2#)))
                  (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                  (EXIT (NREVERSE0 #0#)))))))) 

(DEFUN |FM1;retractIfCan;$U;7| (|x| $)
  (COND
    ((NULL (EQL (SPADCALL |x| (QREFELT $ 10)) 1)) (CONS 1 "failed"))
    ('T
     (COND
       ((SPADCALL (QCDR (|SPADfirst| |x|)) (|spadConstant| $ 21)
            (QREFELT $ 23))
        (CONS 0 (QCAR (|SPADfirst| |x|))))
       ('T (CONS 1 "failed")))))) 

(DEFUN |FM1;coerce;S$;8| (|s| $)
  (LIST (CONS |s| (|spadConstant| $ 21)))) 

(DEFUN |FM1;retract;$S;9| (|x| $)
  (PROG (|rr|)
    (RETURN
      (SEQ (LETT |rr| (SPADCALL |x| (QREFELT $ 25)) |FM1;retract;$S;9|)
           (EXIT (COND
                   ((QEQCAR |rr| 1) (|error| "FM1.retract impossible"))
                   ('T (QCDR |rr|)))))))) 

(DEFUN |FM1;*;R2$;10| (|r| |x| $)
  (PROG (#0=#:G1855 |u| #1=#:G1856)
    (RETURN
      (SEQ (COND
             ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
              (|spadConstant| $ 28))
             ('T
              (PROGN
                (LETT #0# NIL . #2=(|FM1;*;R2$;10|))
                (SEQ (LETT |u| NIL . #2#) (LETT #1# |x| . #2#) G190
                     (COND
                       ((OR (ATOM #1#)
                            (PROGN (LETT |u| (CAR #1#) . #2#) NIL))
                        (GO G191)))
                     (SEQ (EXIT (LETT #0#
                                      (CONS
                                       (CONS (QCAR |u|)
                                        (SPADCALL |r| (QCDR |u|)
                                         (QREFELT $ 30)))
                                       #0#) . #2#)))
                     (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                     (EXIT (NREVERSE0 #0#)))))))))) 

(DEFUN |FM1;*;$R$;11| (|x| |r| $)
  (PROG (#0=#:G1859 |u| #1=#:G1860)
    (RETURN
      (SEQ (COND
             ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
              (|spadConstant| $ 28))
             ('T
              (PROGN
                (LETT #0# NIL . #2=(|FM1;*;$R$;11|))
                (SEQ (LETT |u| NIL . #2#) (LETT #1# |x| . #2#) G190
                     (COND
                       ((OR (ATOM #1#)
                            (PROGN (LETT |u| (CAR #1#) . #2#) NIL))
                        (GO G191)))
                     (SEQ (EXIT (LETT #0#
                                      (CONS
                                       (CONS (QCAR |u|)
                                        (SPADCALL (QCDR |u|) |r|
                                         (QREFELT $ 30)))
                                       #0#) . #2#)))
                     (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                     (EXIT (NREVERSE0 #0#)))))))))) 

(DEFUN |FM1;*;R2$;12| (|r| |x| $)
  (PROG (#0=#:G1864 |u| #1=#:G1865 |a|)
    (RETURN
      (SEQ (COND
             ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
              (|spadConstant| $ 28))
             (#2='T
              (PROGN
                (LETT #0# NIL . #3=(|FM1;*;R2$;12|))
                (SEQ (LETT |u| NIL . #3#) (LETT #1# |x| . #3#) G190
                     (COND
                       ((OR (ATOM #1#)
                            (PROGN (LETT |u| (CAR #1#) . #3#) NIL))
                        (GO G191)))
                     (SEQ (EXIT (COND
                                  ((SEQ
                                    (LETT |a|
                                     (SPADCALL |r| (QCDR |u|)
                                      (QREFELT $ 30)) . #3#)
                                    (EXIT
                                     (COND
                                       ((SPADCALL |a|
                                         (|spadConstant| $ 29)
                                         (QREFELT $ 23))
                                        'NIL)
                                       (#2# 'T))))
                                   (LETT #0#
                                    (CONS (CONS (QCAR |u|) |a|) #0#) . #3#)))))
                     (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                     (EXIT (NREVERSE0 #0#)))))))))) 

(DEFUN |FM1;*;$R$;13| (|x| |r| $)
  (PROG (#0=#:G1869 |u| #1=#:G1870 |a|)
    (RETURN
      (SEQ (COND
             ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
              (|spadConstant| $ 28))
             (#2='T
              (PROGN
                (LETT #0# NIL . #3=(|FM1;*;$R$;13|))
                (SEQ (LETT |u| NIL . #3#) (LETT #1# |x| . #3#) G190
                     (COND
                       ((OR (ATOM #1#)
                            (PROGN (LETT |u| (CAR #1#) . #3#) NIL))
                        (GO G191)))
                     (SEQ (EXIT (COND
                                  ((SEQ
                                    (LETT |a|
                                     (SPADCALL (QCDR |u|) |r|
                                      (QREFELT $ 30)) . #3#)
                                    (EXIT
                                     (COND
                                       ((SPADCALL |a|
                                         (|spadConstant| $ 29)
                                         (QREFELT $ 23))
                                        'NIL)
                                       (#2# 'T))))
                                   (LETT #0#
                                    (CONS (CONS (QCAR |u|) |a|) #0#) . #3#)))))
                     (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                     (EXIT (NREVERSE0 #0#)))))))))) 

(DEFUN |FM1;*;RS$;14| (|r| |s| $)
  (COND
    ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
     (|spadConstant| $ 28))
    ('T (LIST (CONS |s| |r|))))) 

(DEFUN |FM1;*;SR$;15| (|s| |r| $)
  (COND
    ((SPADCALL |r| (|spadConstant| $ 29) (QREFELT $ 23))
     (|spadConstant| $ 28))
    ('T (LIST (CONS |s| |r|))))) 

(DEFUN |FM1;monom;SR$;16| (|b| |r| $) (LIST (CONS |b| |r|))) 

(DEFUN |FM1;outTerm| (|r| |s| $)
  (COND
    ((SPADCALL |r| (|spadConstant| $ 21) (QREFELT $ 23))
     (SPADCALL |s| (QREFELT $ 36)))
    ('T
     (SPADCALL (SPADCALL |r| (QREFELT $ 37))
         (SPADCALL |s| (QREFELT $ 36)) (QREFELT $ 38))))) 

(DEFUN |FM1;coerce;$Of;18| (|a| $)
  (PROG (#0=#:G1879 |t| #1=#:G1880)
    (RETURN
      (SEQ (COND
             ((NULL |a|)
              (SPADCALL (|spadConstant| $ 29) (QREFELT $ 37)))
             ('T
              (SPADCALL (ELT $ 39)
                  (NREVERSE
                      (PROGN
                        (LETT #0# NIL . #2=(|FM1;coerce;$Of;18|))
                        (SEQ (LETT |t| NIL . #2#) (LETT #1# |a| . #2#)
                             G190
                             (COND
                               ((OR (ATOM #1#)
                                    (PROGN
                                      (LETT |t| (CAR #1#) . #2#)
                                      NIL))
                                (GO G191)))
                             (SEQ (EXIT (LETT #0#
                                         (CONS
                                          (|FM1;outTerm| (QCDR |t|)
                                           (QCAR |t|) $)
                                          #0#) . #2#)))
                             (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                             (EXIT (NREVERSE0 #0#)))))
                  (QREFELT $ 42)))))))) 

(DEFUN |FM1;coefficient;$SR;19| (|x| |s| $)
  (COND
    ((NULL |x|) (|spadConstant| $ 29))
    ((SPADCALL |s| (QCAR (|SPADfirst| |x|)) (QREFELT $ 44))
     (SPADCALL (CDR |x|) |s| (QREFELT $ 45)))
    ((SPADCALL (QCAR (|SPADfirst| |x|)) |s| (QREFELT $ 46))
     (QCDR (|SPADfirst| |x|)))
    ('T (|spadConstant| $ 29)))) 

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

(DEFUN |FreeModule1;| (|#1| |#2|)
  (PROG (DV$1 DV$2 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|FreeModule1|))
        (LETT DV$2 (|devaluate| |#2|) . #0#)
        (LETT |dv$| (LIST '|FreeModule1| DV$1 DV$2) . #0#)
        (LETT $ (GETREFV 53) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3
            (LETT |pv$|
                  (|buildPredVector| 0 0
                      (LIST (|HasCategory| |#1| '(|CommutativeRing|)))) . #0#))
        (|haddProp| |$ConstructorCache| '|FreeModule1| (LIST DV$1 DV$2)
            (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 7 |#2|)
        (QSETREFV $ 8
            (|List| (|Record| (|:| |k| |#2|) (|:| |c| |#1|))))
        (COND
          ((|HasCategory| |#1| '(|noZeroDivisors|))
           (PROGN
             (QSETREFV $ 31
                 (CONS (|dispatchFunction| |FM1;*;R2$;10|) $))
             (QSETREFV $ 32
                 (CONS (|dispatchFunction| |FM1;*;$R$;11|) $))))
          ('T
           (PROGN
             (QSETREFV $ 31
                 (CONS (|dispatchFunction| |FM1;*;R2$;12|) $))
             (QSETREFV $ 32
                 (CONS (|dispatchFunction| |FM1;*;$R$;13|) $)))))
        $)))) 

(MAKEPROP '|FreeModule1| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL (|FreeModule| 6 7) (|local| |#1|)
             (|local| |#2|) '|Rep| (|NonNegativeInteger|)
             |FM1;numberOfMonomials;$Nni;1|
             (|Record| (|:| |k| 7) (|:| |c| 6)) (|List| 11)
             |FM1;ListOfTerms;$L;2| |FM1;leadingTerm;$R;3|
             |FM1;leadingMonomial;$S;4| (|List| 6)
             |FM1;coefficients;$L;5| |FM1;monom;SR$;16| (|List| $)
             |FM1;monomials;$L;6| (0 . |One|) (|Boolean|) (4 . =)
             (|Union| 7 '"failed") |FM1;retractIfCan;$U;7|
             |FM1;coerce;S$;8| |FM1;retract;$S;9| (10 . |Zero|)
             (14 . |Zero|) (18 . *) (24 . *) (30 . *) |FM1;*;RS$;14|
             |FM1;*;SR$;15| (|OutputForm|) (36 . |coerce|)
             (41 . |coerce|) (46 . *) (52 . +) (|Mapping| 35 35 35)
             (|List| 35) (58 . |reduce|) |FM1;coerce;$Of;18| (64 . <)
             |FM1;coefficient;$SR;19| (70 . =) (|Mapping| 6 6)
             (|Integer|) (|Union| $ '"failed") (|PositiveInteger|)
             (|SingleInteger|) (|String|))
          '#(~= 76 |zero?| 82 |subtractIfCan| 87 |sample| 93
             |retractIfCan| 97 |retract| 102 |reductum| 107
             |numberOfMonomials| 112 |monomials| 117 |monomial?| 122
             |monom| 127 |map| 133 |leadingTerm| 139 |leadingMonomial|
             144 |leadingCoefficient| 149 |latex| 154 |hash| 159
             |coerce| 164 |coefficients| 174 |coefficient| 179 |Zero|
             185 |ListOfTerms| 189 = 194 - 200 + 211 * 217)
          'NIL
          (CONS (|makeByteWordVec2| 1 '(0 1 0 0 0 0 0 0 0 0 0 0 0))
                (CONS '#(NIL |Module&| NIL NIL NIL |AbelianGroup&| NIL
                         |AbelianMonoid&| |AbelianSemiGroup&|
                         |SetCategory&| |RetractableTo&| |BasicType&|
                         NIL)
                      (CONS '#((|FreeModuleCat| 6 7) (|Module| 6)
                               (|BiModule| 6 6) (|LeftModule| 6)
                               (|RightModule| 6) (|AbelianGroup|)
                               (|CancellationAbelianMonoid|)
                               (|AbelianMonoid|) (|AbelianSemiGroup|)
                               (|SetCategory|) (|RetractableTo| 7)
                               (|BasicType|) (|CoercibleTo| 35))
                            (|makeByteWordVec2| 52
                                '(0 6 0 21 2 6 22 0 0 23 0 0 0 28 0 6 0
                                  29 2 6 0 0 0 30 2 0 0 6 0 31 2 0 0 0
                                  6 32 1 7 35 0 36 1 6 35 0 37 2 35 0 0
                                  0 38 2 35 0 0 0 39 2 41 35 40 0 42 2
                                  7 22 0 0 44 2 7 22 0 0 46 2 0 22 0 0
                                  1 1 0 22 0 1 2 0 49 0 0 1 0 0 0 1 1 0
                                  24 0 25 1 0 7 0 27 1 0 0 0 1 1 0 9 0
                                  10 1 0 19 0 20 1 0 22 0 1 2 0 0 7 6
                                  18 2 0 0 47 0 1 1 0 11 0 14 1 0 7 0
                                  15 1 0 6 0 1 1 0 52 0 1 1 0 51 0 1 1
                                  0 0 7 26 1 0 35 0 43 1 0 16 0 17 2 0
                                  6 0 7 45 0 0 0 28 1 0 12 0 13 2 0 22
                                  0 0 1 2 0 0 0 0 1 1 0 0 0 1 2 0 0 0 0
                                  1 2 0 0 7 6 34 2 0 0 6 7 33 2 0 0 6 0
                                  31 2 0 0 0 6 32 2 0 0 48 0 1 2 0 0 9
                                  0 1 2 0 0 50 0 1)))))
          '|lookupComplete|)) 
