
(/VERSIONCHECK 2) 

(DEFUN |EUCDOM-;sizeLess?;2SB;1| (|x| |y| $)
  (COND
    ((SPADCALL |y| (QREFELT $ 8)) 'NIL)
    ((SPADCALL |x| (QREFELT $ 8)) 'T)
    ('T
     (< (SPADCALL |x| (QREFELT $ 10)) (SPADCALL |y| (QREFELT $ 10)))))) 

(DEFUN |EUCDOM-;quo;3S;2| (|x| |y| $)
  (QCAR (SPADCALL |x| |y| (QREFELT $ 13)))) 

(DEFUN |EUCDOM-;rem;3S;3| (|x| |y| $)
  (QCDR (SPADCALL |x| |y| (QREFELT $ 13)))) 

(DEFUN |EUCDOM-;exquo;2SU;4| (|x| |y| $)
  (PROG (|qr|)
    (RETURN
      (SEQ (COND
             ((SPADCALL |y| (QREFELT $ 8)) (CONS 1 "failed"))
             ('T
              (SEQ (LETT |qr| (SPADCALL |x| |y| (QREFELT $ 13))
                         |EUCDOM-;exquo;2SU;4|)
                   (EXIT (COND
                           ((SPADCALL (QCDR |qr|) (QREFELT $ 8))
                            (CONS 0 (QCAR |qr|)))
                           ('T (CONS 1 "failed"))))))))))) 

(DEFUN |EUCDOM-;gcd;3S;5| (|x| |y| $)
  (PROG (|#G13| |#G14|)
    (RETURN
      (SEQ (LETT |x| (SPADCALL |x| (QREFELT $ 18))
                 . #0=(|EUCDOM-;gcd;3S;5|))
           (LETT |y| (SPADCALL |y| (QREFELT $ 18)) . #0#)
           (SEQ G190
                (COND
                  ((NULL (COND
                           ((SPADCALL |y| (QREFELT $ 8)) 'NIL)
                           ('T 'T)))
                   (GO G191)))
                (SEQ (PROGN
                       (LETT |#G13| |y| . #0#)
                       (LETT |#G14|
                             (SPADCALL |x| |y| (QREFELT $ 19)) . #0#)
                       (LETT |x| |#G13| . #0#)
                       (LETT |y| |#G14| . #0#))
                     (EXIT (LETT |y|
                                 (SPADCALL |y| (QREFELT $ 18)) . #0#)))
                NIL (GO G190) G191 (EXIT NIL))
           (EXIT |x|))))) 

(DEFUN |EUCDOM-;unitNormalizeIdealElt| (|s| $)
  (PROG (|#G16| |u| |c| |a|)
    (RETURN
      (SEQ (PROGN
             (LETT |#G16| (SPADCALL (QVELT |s| 2) (QREFELT $ 22))
                   . #0=(|EUCDOM-;unitNormalizeIdealElt|))
             (LETT |u| (QVELT |#G16| 0) . #0#)
             (LETT |c| (QVELT |#G16| 1) . #0#)
             (LETT |a| (QVELT |#G16| 2) . #0#)
             |#G16|)
           (EXIT (COND
                   ((SPADCALL |a| (|spadConstant| $ 23) (QREFELT $ 24))
                    |s|)
                   ('T
                    (VECTOR (SPADCALL |a| (QVELT |s| 0) (QREFELT $ 25))
                            (SPADCALL |a| (QVELT |s| 1) (QREFELT $ 25))
                            |c|)))))))) 

(DEFUN |EUCDOM-;extendedEuclidean;2SR;7| (|x| |y| $)
  (PROG (|s3| |s2| |qr| |s1|)
    (RETURN
      (SEQ (LETT |s1|
                 (|EUCDOM-;unitNormalizeIdealElt|
                     (VECTOR (|spadConstant| $ 23)
                             (|spadConstant| $ 26) |x|)
                     $)
                 . #0=(|EUCDOM-;extendedEuclidean;2SR;7|))
           (LETT |s2|
                 (|EUCDOM-;unitNormalizeIdealElt|
                     (VECTOR (|spadConstant| $ 26)
                             (|spadConstant| $ 23) |y|)
                     $) . #0#)
           (EXIT (COND
                   ((SPADCALL |y| (QREFELT $ 8)) |s1|)
                   ((SPADCALL |x| (QREFELT $ 8)) |s2|)
                   ('T
                    (SEQ (SEQ G190
                              (COND
                                ((NULL (COND
                                         ((SPADCALL (QVELT |s2| 2)
                                           (QREFELT $ 8))
                                          'NIL)
                                         ('T 'T)))
                                 (GO G191)))
                              (SEQ (LETT |qr|
                                    (SPADCALL (QVELT |s1| 2)
                                     (QVELT |s2| 2) (QREFELT $ 13)) . #0#)
                                   (LETT |s3|
                                    (VECTOR
                                     (SPADCALL (QVELT |s1| 0)
                                      (SPADCALL (QCAR |qr|)
                                       (QVELT |s2| 0) (QREFELT $ 25))
                                      (QREFELT $ 27))
                                     (SPADCALL (QVELT |s1| 1)
                                      (SPADCALL (QCAR |qr|)
                                       (QVELT |s2| 1) (QREFELT $ 25))
                                      (QREFELT $ 27))
                                     (QCDR |qr|)) . #0#)
                                   (LETT |s1| |s2| . #0#)
                                   (EXIT
                                    (LETT |s2|
                                     (|EUCDOM-;unitNormalizeIdealElt|
                                      |s3| $) . #0#)))
                              NIL (GO G190) G191 (EXIT NIL))
                         (COND
                           ((NULL (SPADCALL (QVELT |s1| 0)
                                      (QREFELT $ 8)))
                            (COND
                              ((NULL (SPADCALL (QVELT |s1| 0) |y|
                                      (QREFELT $ 28)))
                               (SEQ (LETT |qr|
                                     (SPADCALL (QVELT |s1| 0) |y|
                                      (QREFELT $ 13)) . #0#)
                                    (QSETVELT |s1| 0 (QCDR |qr|))
                                    (QSETVELT |s1| 1
                                     (SPADCALL (QVELT |s1| 1)
                                      (SPADCALL (QCAR |qr|) |x|
                                       (QREFELT $ 25))
                                      (QREFELT $ 29)))
                                    (EXIT
                                     (LETT |s1|
                                      (|EUCDOM-;unitNormalizeIdealElt|
                                       |s1| $) . #0#)))))))
                         (EXIT |s1|))))))))) 

(DEFUN |EUCDOM-;extendedEuclidean;3SU;8| (|x| |y| |z| $)
  (PROG (|s| |w| |qr|)
    (RETURN
      (SEQ (COND
             ((SPADCALL |z| (QREFELT $ 8))
              (CONS 0
                    (CONS (|spadConstant| $ 26) (|spadConstant| $ 26))))
             ('T
              (SEQ (LETT |s| (SPADCALL |x| |y| (QREFELT $ 32))
                         . #0=(|EUCDOM-;extendedEuclidean;3SU;8|))
                   (LETT |w|
                         (SPADCALL |z| (QVELT |s| 2) (QREFELT $ 33)) . #0#)
                   (EXIT (COND
                           ((QEQCAR |w| 1) (CONS 1 "failed"))
                           ((SPADCALL |y| (QREFELT $ 8))
                            (CONS 0
                                  (CONS (SPADCALL (QVELT |s| 0)
                                         (QCDR |w|) (QREFELT $ 25))
                                        (SPADCALL (QVELT |s| 1)
                                         (QCDR |w|) (QREFELT $ 25)))))
                           ('T
                            (SEQ (LETT |qr|
                                       (SPADCALL
                                        (SPADCALL (QVELT |s| 0)
                                         (QCDR |w|) (QREFELT $ 25))
                                        |y| (QREFELT $ 13)) . #0#)
                                 (EXIT (CONS 0
                                        (CONS (QCDR |qr|)
                                         (SPADCALL
                                          (SPADCALL (QVELT |s| 1)
                                           (QCDR |w|) (QREFELT $ 25))
                                          (SPADCALL (QCAR |qr|) |x|
                                           (QREFELT $ 25))
                                          (QREFELT $ 29)))))))))))))))) 

(DEFUN |EUCDOM-;principalIdeal;LR;9| (|l| $)
  (PROG (|uca| |v| |u| #0=#:G1905 |vv| #1=#:G1906)
    (RETURN
      (SEQ (COND
             ((SPADCALL |l| NIL (QREFELT $ 38))
              (|error| "empty list passed to principalIdeal"))
             ((SPADCALL (CDR |l|) NIL (QREFELT $ 38))
              (SEQ (LETT |uca|
                         (SPADCALL (|SPADfirst| |l|) (QREFELT $ 22))
                         . #2=(|EUCDOM-;principalIdeal;LR;9|))
                   (EXIT (CONS (LIST (QVELT |uca| 0)) (QVELT |uca| 1)))))
             ((SPADCALL (CDR (CDR |l|)) NIL (QREFELT $ 38))
              (SEQ (LETT |u|
                         (SPADCALL (|SPADfirst| |l|)
                             (SPADCALL |l| (QREFELT $ 39))
                             (QREFELT $ 32)) . #2#)
                   (EXIT (CONS (LIST (QVELT |u| 0) (QVELT |u| 1))
                               (QVELT |u| 2)))))
             ('T
              (SEQ (LETT |v| (SPADCALL (CDR |l|) (QREFELT $ 42)) . #2#)
                   (LETT |u|
                         (SPADCALL (|SPADfirst| |l|) (QCDR |v|)
                             (QREFELT $ 32)) . #2#)
                   (EXIT (CONS (CONS (QVELT |u| 0)
                                     (PROGN
                                       (LETT #0# NIL . #2#)
                                       (SEQ (LETT |vv| NIL . #2#)
                                        (LETT #1# (QCAR |v|) . #2#)
                                        G190
                                        (COND
                                          ((OR (ATOM #1#)
                                            (PROGN
                                              (LETT |vv|
                                               (CAR #1#) . #2#)
                                              NIL))
                                           (GO G191)))
                                        (SEQ
                                         (EXIT
                                          (LETT #0#
                                           (CONS
                                            (SPADCALL (QVELT |u| 1)
                                             |vv| (QREFELT $ 25))
                                            #0#) . #2#)))
                                        (LETT #1# (CDR #1#) . #2#)
                                        (GO G190) G191
                                        (EXIT (NREVERSE0 #0#)))))
                               (QVELT |u| 2)))))))))) 

(DEFUN |EUCDOM-;expressIdealMember;LSU;10| (|l| |z| $)
  (PROG (#0=#:G1921 #1=#:G1922 |pid| |q| #2=#:G1923 |v| #3=#:G1924)
    (RETURN
      (SEQ (COND
             ((SPADCALL |z| (|spadConstant| $ 26) (QREFELT $ 24))
              (CONS 0
                    (PROGN
                      (LETT #0# NIL
                            . #4=(|EUCDOM-;expressIdealMember;LSU;10|))
                      (SEQ (LETT |v| NIL . #4#) (LETT #1# |l| . #4#)
                           G190
                           (COND
                             ((OR (ATOM #1#)
                                  (PROGN
                                    (LETT |v| (CAR #1#) . #4#)
                                    NIL))
                              #5=(GO G191)))
                           (SEQ (EXIT (LETT #0#
                                       (CONS (|spadConstant| $ 26) #0#) . #4#)))
                           (LETT #1# (CDR #1#) . #4#) #6=(GO G190) G191
                           (EXIT (NREVERSE0 #0#))))))
             (#7='T
              (SEQ (LETT |pid| (SPADCALL |l| (QREFELT $ 42)) . #4#)
                   (LETT |q|
                         (SPADCALL |z| (QCDR |pid|) (QREFELT $ 33)) . #4#)
                   (EXIT (COND
                           ((QEQCAR |q| 1) (CONS 1 "failed"))
                           (#7#
                            (CONS 0
                                  (PROGN
                                    (LETT #2# NIL . #4#)
                                    (SEQ (LETT |v| NIL . #4#)
                                     (LETT #3# (QCAR |pid|) . #4#) G190
                                     (COND
                                       ((OR (ATOM #3#)
                                         (PROGN
                                           (LETT |v| (CAR #3#) . #4#)
                                           NIL))
                                        #5#))
                                     (SEQ
                                      (EXIT
                                       (LETT #2#
                                        (CONS
                                         (SPADCALL (QCDR |q|) |v|
                                          (QREFELT $ 25))
                                         #2#) . #4#)))
                                     (LETT #3# (CDR #3#) . #4#) #6#
                                     G191 (EXIT (NREVERSE0 #2#))))))))))))))) 

(DEFUN |EUCDOM-;multiEuclidean;LSU;11| (|l| |z| $)
  (PROG (|n| |l1| |l2| #0=#:G1815 #1=#:G1943 #2=#:G1930 #3=#:G1928
             #4=#:G1929 #5=#:G1816 #6=#:G1944 #7=#:G1933 #8=#:G1931
             #9=#:G1932 |u| |v1| |v2|)
    (RETURN
      (SEQ (LETT |n| (LENGTH |l|)
                 . #10=(|EUCDOM-;multiEuclidean;LSU;11|))
           (EXIT (COND
                   ((ZEROP |n|)
                    (|error| "empty list passed to multiEuclidean"))
                   ((EQL |n| 1) (CONS 0 (LIST |z|)))
                   ('T
                    (SEQ (LETT |l1|
                               (SPADCALL |l| (QREFELT $ 46)) . #10#)
                         (LETT |l2|
                               (SPADCALL |l1| (QUOTIENT2 |n| 2)
                                   (QREFELT $ 48)) . #10#)
                         (LETT |u|
                               (SPADCALL
                                   (PROGN
                                     (LETT #4# NIL . #10#)
                                     (SEQ (LETT #0# NIL . #10#)
                                      (LETT #1# |l1| . #10#) G190
                                      (COND
                                        ((OR (ATOM #1#)
                                          (PROGN
                                            (LETT #0# (CAR #1#) . #10#)
                                            NIL))
                                         #11=(GO G191)))
                                      (SEQ
                                       (EXIT
                                        (PROGN
                                          (LETT #2# #0# . #10#)
                                          (COND
                                            (#4#
                                             (LETT #3#
                                              (SPADCALL #3# #2#
                                               (QREFELT $ 25)) . #10#))
                                            ('T
                                             (PROGN
                                               (LETT #3# #2# . #10#)
                                               (LETT #4# 'T . #10#)))))))
                                      (LETT #1# (CDR #1#) . #10#)
                                      #12=(GO G190) G191 (EXIT NIL))
                                     (COND
                                       (#4# #3#)
                                       ('T (|spadConstant| $ 23))))
                                   (PROGN
                                     (LETT #9# NIL . #10#)
                                     (SEQ (LETT #5# NIL . #10#)
                                      (LETT #6# |l2| . #10#) G190
                                      (COND
                                        ((OR (ATOM #6#)
                                          (PROGN
                                            (LETT #5# (CAR #6#) . #10#)
                                            NIL))
                                         #11#))
                                      (SEQ
                                       (EXIT
                                        (PROGN
                                          (LETT #7# #5# . #10#)
                                          (COND
                                            (#9#
                                             (LETT #8#
                                              (SPADCALL #8# #7#
                                               (QREFELT $ 25)) . #10#))
                                            ('T
                                             (PROGN
                                               (LETT #8# #7# . #10#)
                                               (LETT #9# 'T . #10#)))))))
                                      (LETT #6# (CDR #6#) . #10#) #12#
                                      G191 (EXIT NIL))
                                     (COND
                                       (#9# #8#)
                                       ('T (|spadConstant| $ 23))))
                                   |z| (QREFELT $ 49)) . #10#)
                         (EXIT (COND
                                 ((QEQCAR |u| 1) (CONS 1 "failed"))
                                 ('T
                                  (SEQ (LETT |v1|
                                        (SPADCALL |l1|
                                         (QCDR (QCDR |u|))
                                         (QREFELT $ 50)) . #10#)
                                       (EXIT
                                        (COND
                                          ((QEQCAR |v1| 1)
                                           (CONS 1 "failed"))
                                          ('T
                                           (SEQ
                                            (LETT |v2|
                                             (SPADCALL |l2|
                                              (QCAR (QCDR |u|))
                                              (QREFELT $ 50)) . #10#)
                                            (EXIT
                                             (COND
                                               ((QEQCAR |v2| 1)
                                                (CONS 1 "failed"))
                                               ('T
                                                (CONS 0
                                                 (SPADCALL (QCDR |v1|)
                                                  (QCDR |v2|)
                                                  (QREFELT $ 51)))))))))))))))))))))) 

(DEFUN |EuclideanDomain&| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|EuclideanDomain&|))
        (LETT |dv$| (LIST '|EuclideanDomain&| DV$1) . #0#)
        (LETT $ (GETREFV 53) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        $)))) 

(MAKEPROP '|EuclideanDomain&| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|Boolean|)
             (0 . |zero?|) (|NonNegativeInteger|) (5 . |euclideanSize|)
             |EUCDOM-;sizeLess?;2SB;1|
             (|Record| (|:| |quotient| $) (|:| |remainder| $))
             (10 . |divide|) |EUCDOM-;quo;3S;2| |EUCDOM-;rem;3S;3|
             (|Union| $ '"failed") |EUCDOM-;exquo;2SU;4|
             (16 . |unitCanonical|) (21 . |rem|) |EUCDOM-;gcd;3S;5|
             (|Record| (|:| |unit| $) (|:| |canonical| $)
                 (|:| |associate| $))
             (27 . |unitNormal|) (32 . |One|) (36 . =) (42 . *)
             (48 . |Zero|) (52 . -) (58 . |sizeLess?|) (64 . +)
             (|Record| (|:| |coef1| $) (|:| |coef2| $)
                 (|:| |generator| $))
             |EUCDOM-;extendedEuclidean;2SR;7|
             (70 . |extendedEuclidean|) (76 . |exquo|)
             (|Record| (|:| |coef1| $) (|:| |coef2| $))
             (|Union| 34 '"failed") |EUCDOM-;extendedEuclidean;3SU;8|
             (|List| 6) (82 . =) (88 . |second|)
             (|Record| (|:| |coef| 41) (|:| |generator| $)) (|List| $)
             (93 . |principalIdeal|) |EUCDOM-;principalIdeal;LR;9|
             (|Union| 41 '"failed") |EUCDOM-;expressIdealMember;LSU;10|
             (98 . |copy|) (|Integer|) (103 . |split!|)
             (109 . |extendedEuclidean|) (116 . |multiEuclidean|)
             (122 . |concat|) |EUCDOM-;multiEuclidean;LSU;11|)
          '#(|sizeLess?| 128 |rem| 134 |quo| 140 |principalIdeal| 146
             |multiEuclidean| 151 |gcd| 157 |extendedEuclidean| 163
             |exquo| 176 |expressIdealMember| 182)
          'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 52
                                '(1 6 7 0 8 1 6 9 0 10 2 6 12 0 0 13 1
                                  6 0 0 18 2 6 0 0 0 19 1 6 21 0 22 0 6
                                  0 23 2 6 7 0 0 24 2 6 0 0 0 25 0 6 0
                                  26 2 6 0 0 0 27 2 6 7 0 0 28 2 6 0 0
                                  0 29 2 6 30 0 0 32 2 6 16 0 0 33 2 37
                                  7 0 0 38 1 37 6 0 39 1 6 40 41 42 1
                                  37 0 0 46 2 37 0 0 47 48 3 6 35 0 0 0
                                  49 2 6 44 41 0 50 2 37 0 0 0 51 2 0 7
                                  0 0 11 2 0 0 0 0 15 2 0 0 0 0 14 1 0
                                  40 41 43 2 0 44 41 0 52 2 0 0 0 0 20
                                  3 0 35 0 0 0 36 2 0 30 0 0 31 2 0 16
                                  0 0 17 2 0 44 41 0 45)))))
          '|lookupComplete|)) 
