
(/VERSIONCHECK 2) 

(DEFUN |QALGSET;factorset| (|y| $)
  (PROG (#1=#:G1826 |j| #2=#:G1825)
    (RETURN
     (SEQ
      (COND ((SPADCALL |y| (QREFELT $ 12)) NIL)
            ('T
             (PROGN
              (LETT #2# NIL . #3=(|QALGSET;factorset|))
              (SEQ (LETT |j| NIL . #3#)
                   (LETT #1#
                         (SPADCALL (SPADCALL |y| (QREFELT $ 15))
                                   (QREFELT $ 18))
                         . #3#)
                   G190
                   (COND
                    ((OR (ATOM #1#) (PROGN (LETT |j| (CAR #1#) . #3#) NIL))
                     (GO G191)))
                   (SEQ (EXIT (LETT #2# (CONS (QCAR |j|) #2#) . #3#)))
                   (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                   (EXIT (NREVERSE0 #2#)))))))))) 

(DEFUN |QALGSET;simplify;2$;2| (|x| $)
  (PROG (#1=#:G1843 #2=#:G1842 #3=#:G1844 #4=#:G1855 #5=#:G1793 |zro|
         #6=#:G1835 #7=#:G1834 #8=#:G1836 #9=#:G1854 #10=#:G1792 #11=#:G1853
         |s| #12=#:G1852 |mset| #13=#:G1851 #14=#:G1850 #15=#:G1849 |p|
         #16=#:G1848 |nzro| |pnzero|)
    (RETURN
     (SEQ
      (COND
       ((QEQCAR (QVELT |x| 0) 1)
        (LETT |x|
              (SPADCALL
               (LETT |zro| (SPADCALL (QVELT |x| 1) (QREFELT $ 21))
                     . #17=(|QALGSET;simplify;2$;2|))
               (SPADCALL (QVELT |x| 2) |zro| (QREFELT $ 23)) (QREFELT $ 24))
              . #17#)))
      (LETT |pnzero| (QVELT |x| 2) . #17#)
      (EXIT
       (COND
        ((SPADCALL |pnzero| (|spadConstant| $ 27) (QREFELT $ 28))
         (SPADCALL (QREFELT $ 29)))
        (#18='T
         (SEQ (LETT |nzro| (|QALGSET;factorset| |pnzero| $) . #17#)
              (LETT |mset|
                    (|QALGSET;minset|
                     (PROGN
                      (LETT #16# NIL . #17#)
                      (SEQ (LETT |p| NIL . #17#)
                           (LETT #15# (QVELT |x| 1) . #17#) G190
                           (COND
                            ((OR (ATOM #15#)
                                 (PROGN (LETT |p| (CAR #15#) . #17#) NIL))
                             #19=(GO G191)))
                           (SEQ
                            (EXIT
                             (LETT #16# (CONS (|QALGSET;factorset| |p| $) #16#)
                                   . #17#)))
                           (LETT #15# (CDR #15#) . #17#) #20=(GO G190) G191
                           (EXIT (NREVERSE0 #16#))))
                     $)
                    . #17#)
              (LETT |mset|
                    (PROGN
                     (LETT #14# NIL . #17#)
                     (SEQ (LETT |s| NIL . #17#) (LETT #13# |mset| . #17#) G190
                          (COND
                           ((OR (ATOM #13#)
                                (PROGN (LETT |s| (CAR #13#) . #17#) NIL))
                            #19#))
                          (SEQ
                           (EXIT
                            (LETT #14#
                                  (CONS (SPADCALL |s| |nzro| (QREFELT $ 30))
                                        #14#)
                                  . #17#)))
                          (LETT #13# (CDR #13#) . #17#) #20# G191
                          (EXIT (NREVERSE0 #14#))))
                    . #17#)
              (LETT |zro|
                    (SPADCALL
                     (PROGN
                      (LETT #12# NIL . #17#)
                      (SEQ (LETT |s| NIL . #17#) (LETT #11# |mset| . #17#) G190
                           (COND
                            ((OR (ATOM #11#)
                                 (PROGN (LETT |s| (CAR #11#) . #17#) NIL))
                             #19#))
                           (SEQ
                            (EXIT
                             (LETT #12#
                                   (CONS
                                    (PROGN
                                     (LETT #6# NIL . #17#)
                                     (SEQ (LETT #10# NIL . #17#)
                                          (LETT #9# |s| . #17#) G190
                                          (COND
                                           ((OR (ATOM #9#)
                                                (PROGN
                                                 (LETT #10# (CAR #9#) . #17#)
                                                 NIL))
                                            #19#))
                                          (SEQ
                                           (EXIT
                                            (PROGN
                                             (LETT #8# #10# . #17#)
                                             (COND
                                              (#6#
                                               (LETT #7#
                                                     (SPADCALL #7# #8#
                                                               (QREFELT $ 31))
                                                     . #17#))
                                              ('T
                                               (PROGN
                                                (LETT #7# #8# . #17#)
                                                (LETT #6# 'T . #17#)))))))
                                          (LETT #9# (CDR #9#) . #17#) #20# G191
                                          (EXIT NIL))
                                     (COND (#6# #7#)
                                           ('T (|spadConstant| $ 32))))
                                    #12#)
                                   . #17#)))
                           (LETT #11# (CDR #11#) . #17#) #20# G191
                           (EXIT (NREVERSE0 #12#))))
                     (QREFELT $ 21))
                    . #17#)
              (EXIT
               (COND
                ((SPADCALL (|spadConstant| $ 32) |zro| (QREFELT $ 33))
                 (SPADCALL (QREFELT $ 29)))
                (#18#
                 (VECTOR (QVELT |x| 0) |zro|
                         (SPADCALL
                          (SPADCALL
                           (PROGN
                            (LETT #1# NIL . #17#)
                            (SEQ (LETT #5# NIL . #17#) (LETT #4# |nzro| . #17#)
                                 G190
                                 (COND
                                  ((OR (ATOM #4#)
                                       (PROGN (LETT #5# (CAR #4#) . #17#) NIL))
                                   #19#))
                                 (SEQ
                                  (EXIT
                                   (PROGN
                                    (LETT #3# #5# . #17#)
                                    (COND
                                     (#1#
                                      (LETT #2#
                                            (SPADCALL #2# #3# (QREFELT $ 31))
                                            . #17#))
                                     ('T
                                      (PROGN
                                       (LETT #2# #3# . #17#)
                                       (LETT #1# 'T . #17#)))))))
                                 (LETT #4# (CDR #4#) . #17#) #20# G191
                                 (EXIT NIL))
                            (COND (#1# #2#) (#18# (|spadConstant| $ 32))))
                           |zro| (QREFELT $ 23))
                          (QREFELT $ 34)))))))))))))) 

(DEFUN |QALGSET;npoly| (|f| $)
  (COND ((SPADCALL |f| (QREFELT $ 36)) (|spadConstant| $ 38))
        ('T
         (SPADCALL
          (SPADCALL (SPADCALL |f| (QREFELT $ 39))
                    (SPADCALL 0 (SPADCALL |f| (QREFELT $ 40)) (QREFELT $ 43))
                    (QREFELT $ 44))
          (|QALGSET;npoly| (SPADCALL |f| (QREFELT $ 45)) $) (QREFELT $ 46))))) 

(DEFUN |QALGSET;oldpoly| (|q| $)
  (PROG (|g| |n| |dq|)
    (RETURN
     (SEQ
      (COND
       ((SPADCALL |q| (|spadConstant| $ 38) (QREFELT $ 47))
        (CONS 0 (|spadConstant| $ 27)))
       (#1='T
        (SEQ (LETT |dq| (SPADCALL |q| (QREFELT $ 48)) . #2=(|QALGSET;oldpoly|))
             (LETT |n| (SPADCALL |dq| (QREFELT $ 49)) . #2#)
             (EXIT
              (COND
               ((EQL |n| 0)
                (SEQ
                 (LETT |g| (|QALGSET;oldpoly| (SPADCALL |q| (QREFELT $ 50)) $)
                       . #2#)
                 (EXIT
                  (COND ((QEQCAR |g| 1) (CONS 1 "failed"))
                        (#1#
                         (CONS 0
                               (SPADCALL
                                (SPADCALL (SPADCALL |q| (QREFELT $ 51))
                                          (SPADCALL |dq| (QREFELT $ 52))
                                          (QREFELT $ 53))
                                (QCDR |g|) (QREFELT $ 54))))))))
               (#1# (CONS 1 "failed"))))))))))) 

(DEFUN |QALGSET;coerce;$Of;5| (|x| $)
  (PROG (#1=#:G1875 |f| #2=#:G1874)
    (RETURN
     (SEQ
      (COND ((SPADCALL (QVELT |x| 0) (CONS 0 'T) (QREFELT $ 56)) "Empty")
            ('T
             (SPADCALL
              (LIST
               (SPADCALL
                (PROGN
                 (LETT #2# NIL . #3=(|QALGSET;coerce;$Of;5|))
                 (SEQ (LETT |f| NIL . #3#) (LETT #1# (QVELT |x| 1) . #3#) G190
                      (COND
                       ((OR (ATOM #1#) (PROGN (LETT |f| (CAR #1#) . #3#) NIL))
                        (GO G191)))
                      (SEQ
                       (EXIT
                        (LETT #2#
                              (CONS
                               (SPADCALL (SPADCALL |f| (QREFELT $ 58)) " = 0"
                                         (QREFELT $ 59))
                               #2#)
                              . #3#)))
                      (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                      (EXIT (NREVERSE0 #2#))))
                (QREFELT $ 61))
               (SPADCALL (SPADCALL (QVELT |x| 2) (QREFELT $ 58)) " != 0"
                         (QREFELT $ 59)))
              (QREFELT $ 63)))))))) 

(DEFUN |QALGSET;empty?;$B;6| (|x| $)
  (PROG (#1=#:G1877)
    (RETURN
     (SEQ
      (COND
       ((QEQCAR (QVELT |x| 0) 1)
        (LETT |x| (SPADCALL |x| (QREFELT $ 65)) . #2=(|QALGSET;empty?;$B;6|))))
      (EXIT
       (PROG2
           (LETT #1# (QVELT |x| 0) . #2#)
           (QCDR #1#)
         (|check-union| (QEQCAR #1# 0) (|Boolean|) #1#))))))) 

(DEFUN |QALGSET;empty;$;7| ($)
  (VECTOR (CONS 0 'T) (LIST (|spadConstant| $ 32)) (|spadConstant| $ 27))) 

(PUT '|QALGSET;status;$U;8| '|SPADreplace| '(XLAM (|x|) (QVELT |x| 0))) 

(DEFUN |QALGSET;status;$U;8| (|x| $) (QVELT |x| 0)) 

(DEFUN |QALGSET;setStatus;$U$;9| (|x| |t| $)
  (VECTOR |t| (QVELT |x| 1) (QVELT |x| 2))) 

(PUT '|QALGSET;definingEquations;$L;10| '|SPADreplace|
     '(XLAM (|x|) (QVELT |x| 1))) 

(DEFUN |QALGSET;definingEquations;$L;10| (|x| $) (QVELT |x| 1)) 

(PUT '|QALGSET;definingInequation;$Dpoly;11| '|SPADreplace|
     '(XLAM (|x|) (QVELT |x| 2))) 

(DEFUN |QALGSET;definingInequation;$Dpoly;11| (|x| $) (QVELT |x| 2)) 

(DEFUN |QALGSET;quasiAlgebraicSet;LDpoly$;12| (|z0| |n0| $)
  (VECTOR (CONS 1 "failed") |z0| |n0|)) 

(DEFUN |QALGSET;idealSimplify;2$;13| (|x| $)
  (PROG (|ngb| |gb| |f| #1=#:G1916 |g| #2=#:G1915 |tp| |n0| |z0|)
    (RETURN
     (SEQ
      (COND ((QEQCAR (QVELT |x| 0) 0) |x|)
            (#3='T
             (SEQ
              (LETT |z0| (QVELT |x| 1) . #4=(|QALGSET;idealSimplify;2$;13|))
              (LETT |n0| (QVELT |x| 2) . #4#)
              (EXIT
               (COND ((NULL |z0|) (VECTOR (CONS 0 'NIL) |z0| |n0|))
                     ((SPADCALL (|spadConstant| $ 32) |z0| (QREFELT $ 33))
                      (SPADCALL (QREFELT $ 29)))
                     (#3#
                      (SEQ
                       (LETT |tp|
                             (SPADCALL
                              (SPADCALL
                               (SPADCALL (|spadConstant| $ 71)
                                         (SPADCALL 1 (|spadConstant| $ 26)
                                                   (QREFELT $ 43))
                                         (QREFELT $ 44))
                               (|QALGSET;npoly| |n0| $) (QREFELT $ 72))
                              (|spadConstant| $ 73) (QREFELT $ 74))
                             . #4#)
                       (LETT |ngb|
                             (SPADCALL
                              (CONS |tp|
                                    (PROGN
                                     (LETT #2# NIL . #4#)
                                     (SEQ (LETT |g| NIL . #4#)
                                          (LETT #1# |z0| . #4#) G190
                                          (COND
                                           ((OR (ATOM #1#)
                                                (PROGN
                                                 (LETT |g| (CAR #1#) . #4#)
                                                 NIL))
                                            #5=(GO G191)))
                                          (SEQ
                                           (EXIT
                                            (LETT #2#
                                                  (CONS (|QALGSET;npoly| |g| $)
                                                        #2#)
                                                  . #4#)))
                                          (LETT #1# (CDR #1#) . #4#)
                                          #6=(GO G190) G191
                                          (EXIT (NREVERSE0 #2#)))))
                              (QREFELT $ 77))
                             . #4#)
                       (EXIT
                        (COND
                         ((SPADCALL (|spadConstant| $ 73) |ngb| (QREFELT $ 78))
                          (SPADCALL (QREFELT $ 29)))
                         (#3#
                          (SEQ (LETT |gb| NIL . #4#)
                               (SEQ G190
                                    (COND
                                     ((NULL (COND ((NULL |ngb|) 'NIL) ('T 'T)))
                                      #5#))
                                    (SEQ
                                     (SEQ
                                      (LETT |f|
                                            (|QALGSET;oldpoly|
                                             (|SPADfirst| |ngb|) $)
                                            . #4#)
                                      (EXIT
                                       (COND
                                        ((QEQCAR |f| 0)
                                         (LETT |gb| (CONS (QCDR |f|) |gb|)
                                               . #4#)))))
                                     (EXIT (LETT |ngb| (CDR |ngb|) . #4#)))
                                    NIL #6# G191 (EXIT NIL))
                               (EXIT
                                (VECTOR (CONS 0 'NIL) |gb|
                                        (SPADCALL
                                         (SPADCALL |n0| |gb| (QREFELT $ 23))
                                         (QREFELT $ 34))))))))))))))))))) 

(DEFUN |QALGSET;minset| (|lset| $)
  (PROG (#1=#:G1922 |s| #2=#:G1921)
    (RETURN
     (SEQ
      (COND ((NULL |lset|) |lset|)
            (#3='T
             (PROGN
              (LETT #2# NIL . #4=(|QALGSET;minset|))
              (SEQ (LETT |s| NIL . #4#) (LETT #1# |lset| . #4#) G190
                   (COND
                    ((OR (ATOM #1#) (PROGN (LETT |s| (CAR #1#) . #4#) NIL))
                     (GO G191)))
                   (SEQ
                    (EXIT
                     (COND
                      ((COND ((|QALGSET;overset?| |s| |lset| $) 'NIL) (#3# 'T))
                       (LETT #2# (CONS |s| #2#) . #4#)))))
                   (LETT #1# (CDR #1#) . #4#) (GO G190) G191
                   (EXIT (NREVERSE0 #2#)))))))))) 

(DEFUN |QALGSET;overset?| (|p| |qlist| $)
  (PROG (#1=#:G1924 #2=#:G1923 #3=#:G1925 #4=#:G1928 |q|)
    (RETURN
     (SEQ
      (COND ((NULL |qlist|) 'NIL)
            (#5='T
             (PROGN
              (LETT #1# NIL . #6=(|QALGSET;overset?|))
              (SEQ (LETT |q| NIL . #6#) (LETT #4# |qlist| . #6#) G190
                   (COND
                    ((OR (ATOM #4#) (PROGN (LETT |q| (CAR #4#) . #6#) NIL))
                     (GO G191)))
                   (SEQ
                    (EXIT
                     (PROGN
                      (LETT #3#
                            (SPADCALL (SPADCALL |q| (QREFELT $ 80))
                                      (SPADCALL |p| (QREFELT $ 80))
                                      (QREFELT $ 81))
                            . #6#)
                      (COND (#1# (LETT #2# (COND (#2# 'T) ('T #3#)) . #6#))
                            ('T
                             (PROGN
                              (LETT #2# #3# . #6#)
                              (LETT #1# 'T . #6#)))))))
                   (LETT #4# (CDR #4#) . #6#) (GO G190) G191 (EXIT NIL))
              (COND (#1# #2#) (#5# 'NIL))))))))) 

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

(DEFUN |QuasiAlgebraicSet;| (|#1| |#2| |#3| |#4|)
  (PROG (|pv$| $ |dv$| DV$4 DV$3 DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|QuasiAlgebraicSet|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT DV$3 (|devaluate| |#3|) . #1#)
      (LETT DV$4 (|devaluate| |#4|) . #1#)
      (LETT |dv$| (LIST '|QuasiAlgebraicSet| DV$1 DV$2 DV$3 DV$4) . #1#)
      (LETT $ (GETREFV 84) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3
                (LETT |pv$|
                      (|buildPredVector| 0 0
                                         (LIST
                                          (AND
                                           (|HasCategory| |#1|
                                                          '(|CharacteristicZero|))
                                           (|HasCategory| |#1|
                                                          '(|EuclideanDomain|)))))
                      . #1#))
      (|haddProp| |$ConstructorCache| '|QuasiAlgebraicSet|
                  (LIST DV$1 DV$2 DV$3 DV$4) (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 8 |#3|)
      (QSETREFV $ 9 |#4|)
      (QSETREFV $ 10
                (|Record| (|:| |status| (|Union| (|Boolean|) "failed"))
                          (|:| |zero| (|List| |#4|)) (|:| |nzero| |#4|)))
      (COND
       ((|HasCategory| |#1| '(|EuclideanDomain|))
        (COND
         ((|HasCategory| |#1| '(|CharacteristicZero|))
          (PROGN
           (QSETREFV $ 35
                     (CONS (|dispatchFunction| |QALGSET;simplify;2$;2|)
                           $)))))))
      $)))) 

(MAKEPROP '|QuasiAlgebraicSet| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) (|local| |#4|) '|Rep| (|Boolean|) (0 . |ground?|)
              (|Factored| 9) (|MultivariateFactorize| 7 8 6 9) (5 . |factor|)
              (|Record| (|:| |factor| 9) (|:| |exponent| (|Integer|)))
              (|List| 16) (10 . |factors|) (|List| 9)
              (|GroebnerPackage| 6 8 7 9) (15 . |groebner|)
              (|GroebnerInternalPackage| 6 8 7 9) (20 . |redPol|)
              |QALGSET;quasiAlgebraicSet;LDpoly$;12| (26 . |Zero|)
              (30 . |Zero|) (34 . |Zero|) (38 . =) |QALGSET;empty;$;7|
              (44 . |setDifference|) (50 . *) (56 . |One|) (60 . |member?|)
              (66 . |primitivePart|) (71 . |simplify|) (76 . |zero?|)
              (|PolynomialRing| 6 42) (81 . |Zero|) (85 . |leadingCoefficient|)
              (90 . |degree|) (|NonNegativeInteger|) (|Product| 41 8)
              (95 . |makeprod|) (101 . |monomial|) (107 . |reductum|) (112 . +)
              (118 . =) (124 . |degree|) (129 . |selectfirst|)
              (134 . |reductum|) (139 . |leadingCoefficient|)
              (144 . |selectsecond|) (149 . |monomial|) (155 . +)
              (|Union| 11 '"failed") (161 . =) (|OutputForm|) (167 . |coerce|)
              (172 . |hconcat|) (|List| 57) (178 . |coerce|) (|List| $)
              (183 . |bracket|) |QALGSET;coerce;$Of;5|
              |QALGSET;idealSimplify;2$;13| |QALGSET;empty?;$B;6|
              |QALGSET;status;$U;8| |QALGSET;setStatus;$U$;9|
              |QALGSET;definingEquations;$L;10|
              |QALGSET;definingInequation;$Dpoly;11| (188 . |One|) (192 . *)
              (198 . |One|) (202 . -) (|List| 37) (|GroebnerPackage| 6 42 7 37)
              (208 . |groebner|) (213 . |member?|) (|Set| 9) (219 . |brace|)
              (224 . <) (|String|) (|SingleInteger|))
           '#(~= 230 |status| 236 |simplify| 241 |setStatus| 246
              |quasiAlgebraicSet| 252 |latex| 258 |idealSimplify| 263 |hash|
              268 |empty?| 273 |empty| 278 |definingInequation| 282
              |definingEquations| 287 |coerce| 292 = 297)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0))
                 (CONS '#(|SetCategory&| |BasicType&| NIL)
                       (CONS
                        '#((|SetCategory|) (|BasicType|) (|CoercibleTo| 57))
                        (|makeByteWordVec2| 83
                                            '(1 9 11 0 12 1 14 13 9 15 1 13 17
                                              0 18 1 20 19 19 21 2 22 9 9 19 23
                                              0 6 0 25 0 8 0 26 0 9 0 27 2 9 11
                                              0 0 28 2 19 0 0 0 30 2 9 0 0 0 31
                                              0 9 0 32 2 19 11 9 0 33 1 9 0 0
                                              34 1 0 0 0 35 1 9 11 0 36 0 37 0
                                              38 1 9 6 0 39 1 9 8 0 40 2 42 0
                                              41 8 43 2 37 0 6 42 44 1 9 0 0 45
                                              2 37 0 0 0 46 2 37 11 0 0 47 1 37
                                              42 0 48 1 42 41 0 49 1 37 0 0 50
                                              1 37 6 0 51 1 42 8 0 52 2 9 0 6 8
                                              53 2 9 0 0 0 54 2 55 11 0 0 56 1
                                              9 57 0 58 2 57 0 0 0 59 1 60 57 0
                                              61 1 57 0 62 63 0 6 0 71 2 37 0 0
                                              0 72 0 37 0 73 2 37 0 0 0 74 1 76
                                              75 75 77 2 75 11 37 0 78 1 79 0
                                              19 80 2 79 11 0 0 81 2 0 11 0 0 1
                                              1 0 55 0 67 1 1 0 0 35 2 0 0 0 55
                                              68 2 0 0 19 9 24 1 0 82 0 1 1 0 0
                                              0 65 1 0 83 0 1 1 0 11 0 66 0 0 0
                                              29 1 0 9 0 70 1 0 19 0 69 1 0 57
                                              0 64 2 0 11 0 0 1)))))
           '|lookupComplete|)) 
