
(/VERSIONCHECK 2) 

(DEFUN |GBF;createGroebnerBases|
       (|basis| |redPols| |nonZeroRestrictions| |inputPolys| |lcP|
        |listOfBases| |info| $)
  (PROG (|newBasis| #1=#:G1858 |p| #2=#:G1857 |newInputPolys| #3=#:G1856 |fnP|
         |nP| |allReducedFactors| #4=#:G1855 |doSplitting?|
         |irreducibleFactors| |terminateWithBasis| |stopDividing| |nPq|
         #5=#:G1854 #6=#:G1853 |q| |h|)
    (RETURN
     (SEQ (LETT |doSplitting?| 'NIL . #7=(|GBF;createGroebnerBases|))
          (LETT |terminateWithBasis| 'NIL . #7#)
          (LETT |allReducedFactors| NIL . #7#)
          (SEQ G190
               (COND
                ((NULL
                  (COND ((OR |doSplitting?| |terminateWithBasis|) 'NIL)
                        ('T 'T)))
                 #8=(GO G191)))
               (SEQ
                (LETT |terminateWithBasis|
                      (COND ((NULL |inputPolys|) (NULL |lcP|)) ('T 'NIL))
                      . #7#)
                (EXIT
                 (COND
                  ((NULL |terminateWithBasis|)
                   (SEQ
                    (LETT |nP|
                          (COND
                           ((NULL |inputPolys|)
                            (SEQ
                             (LETT |h|
                                   (SPADCALL (|SPADfirst| |lcP|)
                                             (QREFELT $ 12))
                                   . #7#)
                             (LETT |lcP| (CDR |lcP|) . #7#)
                             (EXIT
                              (SPADCALL (SPADCALL |h| |redPols| (QREFELT $ 14))
                                        (QREFELT $ 15)))))
                           ('T
                            (SEQ (LETT |p| (|SPADfirst| |inputPolys|) . #7#)
                                 (LETT |inputPolys| (CDR |inputPolys|) . #7#)
                                 (EXIT
                                  (SPADCALL
                                   (SPADCALL |p| |redPols| (QREFELT $ 14))
                                   (QREFELT $ 15))))))
                          . #7#)
                    (EXIT
                     (COND
                      ((SPADCALL |nP| (|spadConstant| $ 16) (QREFELT $ 18))
                       (SEQ
                        (LETT |basis| (LIST (CONS 0 (|spadConstant| $ 16)))
                              . #7#)
                        (EXIT (LETT |terminateWithBasis| 'T . #7#))))
                      ((NULL
                        (SPADCALL |nP| (|spadConstant| $ 21) (QREFELT $ 18)))
                       (SEQ
                        (SEQ (LETT |q| NIL . #7#)
                             (LETT #6# |nonZeroRestrictions| . #7#) G190
                             (COND
                              ((OR (ATOM #6#)
                                   (PROGN (LETT |q| (CAR #6#) . #7#) NIL))
                               #8#))
                             (SEQ (LETT |stopDividing| 'NIL . #7#)
                                  (EXIT
                                   (SEQ (LETT #5# NIL . #7#) G190
                                        (COND (#5# #8#))
                                        (SEQ
                                         (LETT |nPq|
                                               (SPADCALL |nP| |q|
                                                         (QREFELT $ 23))
                                               . #7#)
                                         (LETT |stopDividing| (QEQCAR |nPq| 1)
                                               . #7#)
                                         (COND
                                          ((NULL |stopDividing|)
                                           (LETT |nP| (QCDR |nPq|) . #7#)))
                                         (EXIT
                                          (LETT |stopDividing|
                                                (COND (|stopDividing| 'T)
                                                      ('T
                                                       (SPADCALL
                                                        (SPADCALL |nP|
                                                                  (QREFELT $
                                                                           24))
                                                        (QREFELT $ 25))))
                                                . #7#)))
                                        (LETT #5# |stopDividing| . #7#)
                                        #9=(GO G190) G191 (EXIT NIL))))
                             (LETT #6# (CDR #6#) . #7#) #9# G191 (EXIT NIL))
                        (EXIT
                         (COND
                          ((SPADCALL (SPADCALL |nP| (QREFELT $ 24))
                                     (QREFELT $ 25))
                           (SEQ
                            (LETT |basis| (LIST (CONS 0 (|spadConstant| $ 16)))
                                  . #7#)
                            (EXIT (LETT |terminateWithBasis| 'T . #7#))))
                          ('T
                           (SEQ
                            (LETT |nP|
                                  (SPADCALL
                                   (SPADCALL |nP| |redPols| (QREFELT $ 14))
                                   (QREFELT $ 15))
                                  . #7#)
                            (EXIT
                             (COND
                              ((SPADCALL (SPADCALL |nP| (QREFELT $ 24))
                                         (QREFELT $ 25))
                               (SEQ
                                (LETT |basis|
                                      (LIST (CONS 0 (|spadConstant| $ 16)))
                                      . #7#)
                                (EXIT (LETT |terminateWithBasis| 'T . #7#))))
                              ((NULL
                                (SPADCALL |nP| (|spadConstant| $ 21)
                                          (QREFELT $ 18)))
                               (SEQ
                                (LETT |irreducibleFactors|
                                      (|GBF;createAllFactors| |nP| $) . #7#)
                                (LETT |doSplitting?|
                                      (COND
                                       ((NULL (CDR |irreducibleFactors|)) 'NIL)
                                       ('T 'T))
                                      . #7#)
                                (EXIT
                                 (COND
                                  (|doSplitting?|
                                   (SEQ
                                    (SEQ (LETT |fnP| NIL . #7#)
                                         (LETT #4# |irreducibleFactors| . #7#)
                                         G190
                                         (COND
                                          ((OR (ATOM #4#)
                                               (PROGN
                                                (LETT |fnP| (CAR #4#) . #7#)
                                                NIL))
                                           #8#))
                                         (SEQ
                                          (LETT |fnP|
                                                (SPADCALL
                                                 (SPADCALL |fnP| |redPols|
                                                           (QREFELT $ 14))
                                                 (QREFELT $ 15))
                                                . #7#)
                                          (EXIT
                                           (LETT |allReducedFactors|
                                                 (CONS |fnP|
                                                       |allReducedFactors|)
                                                 . #7#)))
                                         (LETT #4# (CDR #4#) . #7#) #9# G191
                                         (EXIT NIL))
                                    (EXIT
                                     (LETT |allReducedFactors|
                                           (REVERSE |allReducedFactors|)
                                           . #7#))))
                                  ('T
                                   (SEQ
                                    (LETT |nP|
                                          (|SPADfirst| |irreducibleFactors|)
                                          . #7#)
                                    (LETT |lcP|
                                          (|GBF;updateCritPairs| |lcP|
                                           (|GBF;newPairs| |basis| |nP| $) |nP|
                                           $)
                                          . #7#)
                                    (LETT |basis|
                                          (|GBF;updateBasis| |basis| |nP|
                                           (SPADCALL |nP| (QREFELT $ 27)) $)
                                          . #7#)
                                    (EXIT
                                     (LETT |redPols|
                                           (SPADCALL |redPols| |nP|
                                                     (QREFELT $ 28))
                                           . #7#)))))))))))))))))))))))
               NIL #9# G191 (EXIT NIL))
          (EXIT
           (COND
            (|doSplitting?|
             (SEQ
              (SEQ (LETT |fnP| NIL . #7#) (LETT #3# |allReducedFactors| . #7#)
                   G190
                   (COND
                    ((OR (ATOM #3#) (PROGN (LETT |fnP| (CAR #3#) . #7#) NIL))
                     #8#))
                   (SEQ
                    (EXIT
                     (COND
                      ((SPADCALL |fnP| (|spadConstant| $ 16) (QREFELT $ 18))
                       (SEQ
                        (COND
                         (|info|
                          (SPADCALL "we terminated with [1]" (QREFELT $ 32))))
                        (EXIT
                         (LETT |listOfBases|
                               (CONS (LIST (|spadConstant| $ 16))
                                     |listOfBases|)
                               . #7#))))
                      ('T
                       (SEQ
                        (LETT |newInputPolys|
                              (SPADCALL (CONS #'|GBF;createGroebnerBases!0| $)
                                        (CONS |fnP| |inputPolys|)
                                        (QREFELT $ 35))
                              . #7#)
                        (LETT |listOfBases|
                              (|GBF;createGroebnerBases| |basis| |redPols|
                               |nonZeroRestrictions| |newInputPolys| |lcP|
                               |listOfBases| |info| $)
                              . #7#)
                        (EXIT
                         (LETT |nonZeroRestrictions|
                               (CONS |fnP| |nonZeroRestrictions|) . #7#)))))))
                   (LETT #3# (CDR #3#) . #7#) #9# G191 (EXIT NIL))
              (EXIT |listOfBases|)))
            ('T
             (SEQ
              (LETT |newBasis|
                    (SPADCALL
                     (SPADCALL (CONS #'|GBF;createGroebnerBases!1| $)
                               (PROGN
                                (LETT #2# NIL . #7#)
                                (SEQ (LETT |p| NIL . #7#)
                                     (LETT #1# |basis| . #7#) G190
                                     (COND
                                      ((OR (ATOM #1#)
                                           (PROGN
                                            (LETT |p| (CAR #1#) . #7#)
                                            NIL))
                                       #8#))
                                     (SEQ
                                      (EXIT
                                       (LETT #2# (CONS (QCDR |p|) #2#) . #7#)))
                                     (LETT #1# (CDR #1#) . #7#) #9# G191
                                     (EXIT (NREVERSE0 #2#))))
                               (QREFELT $ 35))
                     (QREFELT $ 36))
                    . #7#)
              (COND
               (|info|
                (SEQ
                 (SPADCALL "we found a groebner basis and check whether it "
                           (QREFELT $ 32))
                 (SPADCALL "contains reducible polynomials" (QREFELT $ 32))
                 (EXIT
                  (SPADCALL (SPADCALL |newBasis| (QREFELT $ 37))
                            (QREFELT $ 38))))))
              (EXIT
               (SPADCALL
                (APPEND (SPADCALL |newBasis| |info| (QREFELT $ 40))
                        |listOfBases|)
                (QREFELT $ 41))))))))))) 

(DEFUN |GBF;createGroebnerBases!1| (|x| |y| $)
  (SPADCALL (SPADCALL |y| (QREFELT $ 24)) (SPADCALL |x| (QREFELT $ 24))
            (QREFELT $ 33))) 

(DEFUN |GBF;createGroebnerBases!0| (|x| |y| $)
  (SPADCALL (SPADCALL |y| (QREFELT $ 24)) (SPADCALL |x| (QREFELT $ 24))
            (QREFELT $ 33))) 

(DEFUN |GBF;createAllFactors| (|p| $)
  (PROG (|loF| #1=#:G1875 |el| #2=#:G1874)
    (RETURN
     (SEQ
      (LETT |loF|
            (PROGN
             (LETT #2# NIL . #3=(|GBF;createAllFactors|))
             (SEQ (LETT |el| NIL . #3#)
                  (LETT #1#
                        (SPADCALL (SPADCALL |p| (QREFELT $ 44)) (QREFELT $ 48))
                        . #3#)
                  G190
                  (COND
                   ((OR (ATOM #1#) (PROGN (LETT |el| (CAR #1#) . #3#) NIL))
                    (GO G191)))
                  (SEQ (EXIT (LETT #2# (CONS (QVELT |el| 1) #2#) . #3#)))
                  (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                  (EXIT (NREVERSE0 #2#))))
            . #3#)
      (EXIT
       (SPADCALL (CONS #'|GBF;createAllFactors!0| $) |loF| (QREFELT $ 35))))))) 

(DEFUN |GBF;createAllFactors!0| (|x| |y| $)
  (SPADCALL (SPADCALL |x| (QREFELT $ 24)) (SPADCALL |y| (QREFELT $ 24))
            (QREFELT $ 33))) 

(DEFUN |GBF;newPairs| (|lp| |p| $)
  (PROG (|lcP| #1=#:G1885 |q| #2=#:G1884 |totdegreeOfp|)
    (RETURN
     (SEQ
      (LETT |totdegreeOfp| (SPADCALL |p| (QREFELT $ 27)) . #3=(|GBF;newPairs|))
      (LETT |lcP|
            (PROGN
             (LETT #2# NIL . #3#)
             (SEQ (LETT |q| NIL . #3#) (LETT #1# |lp| . #3#) G190
                  (COND
                   ((OR (ATOM #1#) (PROGN (LETT |q| (CAR #1#) . #3#) NIL))
                    (GO G191)))
                  (SEQ
                   (EXIT
                    (LETT #2#
                          (CONS
                           (SPADCALL |q| |p| |totdegreeOfp| (QREFELT $ 50))
                           #2#)
                          . #3#)))
                  (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                  (EXIT (NREVERSE0 #2#))))
            . #3#)
      (EXIT
       (SPADCALL (SPADCALL (ELT $ 51) |lcP| (QREFELT $ 54)) (QREFELT $ 55))))))) 

(DEFUN |GBF;updateCritPairs| (|oldListOfcritPairs| |newListOfcritPairs| |p| $)
  (SPADCALL |newListOfcritPairs|
            (SPADCALL |p| |oldListOfcritPairs| (QREFELT $ 56)) (QREFELT $ 57))) 

(DEFUN |GBF;updateBasis| (|lp| |p| |deg| $)
  (SPADCALL |p| |deg| |lp| (QREFELT $ 59))) 

(DEFUN |GBF;factorGroebnerBasis;LL;6| (|basis| $)
  (SPADCALL |basis| 'NIL (QREFELT $ 40))) 

(DEFUN |GBF;factorGroebnerBasis;LBL;7| (|basis| |info| $)
  (PROG (|foundAReducible| #1=#:G1902 |el| #2=#:G1901 #3=#:G1900 |p|)
    (RETURN
     (SEQ (LETT |foundAReducible| 'NIL . #4=(|GBF;factorGroebnerBasis;LBL;7|))
          (SEQ (LETT |p| NIL . #4#) (LETT #3# |basis| . #4#) G190
               (COND
                ((OR (ATOM #3#) (PROGN (LETT |p| (CAR #3#) . #4#) NIL)
                     (NULL (COND (|foundAReducible| 'NIL) ('T 'T))))
                 #5=(GO G191)))
               (SEQ
                (EXIT
                 (LETT |foundAReducible|
                       (< 1
                          (LENGTH
                           (PROGN
                            (LETT #2# NIL . #4#)
                            (SEQ (LETT |el| NIL . #4#)
                                 (LETT #1#
                                       (SPADCALL (SPADCALL |p| (QREFELT $ 44))
                                                 (QREFELT $ 48))
                                       . #4#)
                                 G190
                                 (COND
                                  ((OR (ATOM #1#)
                                       (PROGN (LETT |el| (CAR #1#) . #4#) NIL))
                                   #5#))
                                 (SEQ
                                  (EXIT
                                   (LETT #2# (CONS (QVELT |el| 1) #2#) . #4#)))
                                 (LETT #1# (CDR #1#) . #4#) #6=(GO G190) G191
                                 (EXIT (NREVERSE0 #2#))))))
                       . #4#)))
               (LETT #3# (CDR #3#) . #4#) #6# G191 (EXIT NIL))
          (EXIT
           (COND
            (|foundAReducible|
             (SEQ
              (COND
               (|info|
                (SPADCALL
                 "factorGroebnerBasis:        we found reducible polynomials and continue splitting"
                 (QREFELT $ 32))))
              (EXIT
               (|GBF;createGroebnerBases| NIL NIL NIL |basis| NIL NIL |info|
                $))))
            ('T
             (SEQ
              (COND
               (|info|
                (SPADCALL
                 "factorGroebnerBasis: no reducible polynomials in this basis"
                 (QREFELT $ 32))))
              (EXIT (LIST |basis|)))))))))) 

(DEFUN |GBF;groebnerFactorize;2LL;8| (|basis| |nonZeroRestrictions| $)
  (SPADCALL |basis| |nonZeroRestrictions| 'NIL (QREFELT $ 63))) 

(DEFUN |GBF;groebnerFactorize;2LBL;9| (|basis| |nonZeroRestrictions| |info| $)
  (PROG (#1=#:G1912 |p| #2=#:G1911)
    (RETURN
     (SEQ
      (COND ((SPADCALL |basis| NIL (QREFELT $ 65)) (LIST |basis|))
            (#3='T
             (SEQ
              (LETT |basis| (SPADCALL (ELT $ 66) |basis| (QREFELT $ 68))
                    . #4=(|GBF;groebnerFactorize;2LBL;9|))
              (EXIT
               (COND
                ((SPADCALL |basis| NIL (QREFELT $ 65))
                 (LIST (LIST (|spadConstant| $ 21))))
                (#3#
                 (SEQ
                  (LETT |basis|
                        (PROGN
                         (LETT #2# NIL . #4#)
                         (SEQ (LETT |p| NIL . #4#) (LETT #1# |basis| . #4#)
                              G190
                              (COND
                               ((OR (ATOM #1#)
                                    (PROGN (LETT |p| (CAR #1#) . #4#) NIL))
                                (GO G191)))
                              (SEQ
                               (EXIT
                                (LETT #2#
                                      (CONS (SPADCALL |p| (QREFELT $ 15)) #2#)
                                      . #4#)))
                              (LETT #1# (CDR #1#) . #4#) (GO G190) G191
                              (EXIT (NREVERSE0 #2#))))
                        . #4#)
                  (EXIT
                   (COND
                    ((SPADCALL (|spadConstant| $ 16) |basis| (QREFELT $ 69))
                     (LIST (LIST (|spadConstant| $ 16))))
                    (#3#
                     (SEQ
                      (LETT |basis|
                            (SPADCALL
                             (CONS #'|GBF;groebnerFactorize;2LBL;9!0| $)
                             |basis| (QREFELT $ 35))
                            . #4#)
                      (EXIT
                       (|GBF;createGroebnerBases| NIL NIL |nonZeroRestrictions|
                        |basis| NIL NIL |info| $))))))))))))))))) 

(DEFUN |GBF;groebnerFactorize;2LBL;9!0| (|x| |y| $)
  (SPADCALL (SPADCALL |y| (QREFELT $ 24)) (SPADCALL |x| (QREFELT $ 24))
            (QREFELT $ 33))) 

(DEFUN |GBF;groebnerFactorize;LL;10| (|basis| $)
  (SPADCALL |basis| NIL 'NIL (QREFELT $ 63))) 

(DEFUN |GBF;groebnerFactorize;LBL;11| (|basis| |info| $)
  (SPADCALL |basis| NIL |info| (QREFELT $ 63))) 

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

(DEFUN |GroebnerFactorizationPackage;| (|#1| |#2| |#3| |#4|)
  (PROG (|pv$| $ |dv$| DV$4 DV$3 DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|GroebnerFactorizationPackage|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT DV$3 (|devaluate| |#3|) . #1#)
      (LETT DV$4 (|devaluate| |#4|) . #1#)
      (LETT |dv$| (LIST '|GroebnerFactorizationPackage| DV$1 DV$2 DV$3 DV$4)
            . #1#)
      (LETT $ (GETREFV 72) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|GroebnerFactorizationPackage|
                  (LIST DV$1 DV$2 DV$3 DV$4) (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 8 |#3|)
      (QSETREFV $ 9 |#4|)
      $)))) 

(MAKEPROP '|GroebnerFactorizationPackage| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) (|local| |#4|)
              (|Record| (|:| |lcmfij| 7) (|:| |totdeg| 26) (|:| |poli| 9)
                        (|:| |polj| 9))
              (|GroebnerInternalPackage| 6 7 8 9) (0 . |sPol|) (|List| 9)
              (5 . |redPol|) (11 . |hMonic|) (16 . |One|) (|Boolean|) (20 . =)
              (26 . |Zero|) (30 . |Zero|) (34 . |Zero|) (|Union| $ '"failed")
              (38 . |exquo|) (44 . |degree|) (49 . |zero?|)
              (|NonNegativeInteger|) (54 . |virtualDegree|) (59 . |concat|)
              (|Void|) (|String|) (|OutputForm|) (65 . |messagePrint|) (70 . <)
              (|Mapping| 17 9 9) (76 . |sort|) (82 . |minGbasis|)
              (87 . |coerce|) (92 . |print|) (|List| 13)
              |GBF;factorGroebnerBasis;LBL;7| (97 . |removeDuplicates|)
              (|Factored| 9) (|MultivariateFactorize| 8 7 6 9) (102 . |factor|)
              (|Union| '"nil" '"sqfr" '"irred" '"prime")
              (|Record| (|:| |flg| 45) (|:| |fctr| 9) (|:| |xpnt| (|Integer|)))
              (|List| 46) (107 . |factorList|)
              (|Record| (|:| |totdeg| 26) (|:| |pol| 9)) (112 . |makeCrit|)
              (119 . |critpOrder|) (|Mapping| 17 10 10) (|List| 10)
              (125 . |sort|) (131 . |critMTonD1|) (136 . |critBonD|)
              (142 . |updatD|) (|List| 49) (148 . |updatF|)
              |GBF;factorGroebnerBasis;LL;6| (155 . |One|) (159 . |One|)
              |GBF;groebnerFactorize;2LBL;9| |GBF;groebnerFactorize;2LL;8|
              (163 . =) (169 . |zero?|) (|Mapping| 17 9) (174 . |remove|)
              (180 . |member?|) |GBF;groebnerFactorize;LL;10|
              |GBF;groebnerFactorize;LBL;11|)
           '#(|groebnerFactorize| 186 |factorGroebnerBasis| 210) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 71
                                                 '(1 11 9 10 12 2 11 9 9 13 14
                                                   1 11 9 9 15 0 9 0 16 2 9 17
                                                   0 0 18 0 6 0 19 0 7 0 20 0 9
                                                   0 21 2 9 22 0 0 23 1 9 7 0
                                                   24 1 7 17 0 25 1 11 26 9 27
                                                   2 13 0 0 9 28 1 31 29 30 32
                                                   2 7 17 0 0 33 2 13 0 34 0 35
                                                   1 11 13 13 36 1 13 31 0 37 1
                                                   31 29 0 38 1 39 0 0 41 1 43
                                                   42 9 44 1 42 47 0 48 3 11 10
                                                   49 9 26 50 2 11 17 10 10 51
                                                   2 53 0 52 0 54 1 11 53 53 55
                                                   2 11 53 9 53 56 2 11 53 53
                                                   53 57 3 11 58 9 26 58 59 0 6
                                                   0 61 0 42 0 62 2 13 17 0 0
                                                   65 1 9 17 0 66 2 13 0 67 0
                                                   68 2 13 17 9 0 69 2 0 39 13
                                                   13 64 3 0 39 13 13 17 63 2 0
                                                   39 13 17 71 1 0 39 13 70 1 0
                                                   39 13 60 2 0 39 13 17
                                                   40)))))
           '|lookupComplete|)) 
