
(/VERSIONCHECK 2) 

(PUT '|ORDCOMP;coerce;R$;1| '|SPADreplace| '(XLAM (|r|) (CONS 0 |r|))) 

(DEFUN |ORDCOMP;coerce;R$;1| (|r| $) (CONS 0 |r|)) 

(DEFUN |ORDCOMP;retract;$R;2| (|x| $)
  (COND ((QEQCAR |x| 0) (CDR |x|)) ('T (|error| "Not finite")))) 

(PUT '|ORDCOMP;finite?;$B;3| '|SPADreplace| '(XLAM (|x|) (QEQCAR |x| 0))) 

(DEFUN |ORDCOMP;finite?;$B;3| (|x| $) (QEQCAR |x| 0)) 

(PUT '|ORDCOMP;infinite?;$B;4| '|SPADreplace| '(XLAM (|x|) (QEQCAR |x| 1))) 

(DEFUN |ORDCOMP;infinite?;$B;4| (|x| $) (QEQCAR |x| 1)) 

(DEFUN |ORDCOMP;plusInfinity;$;5| ($) (CONS 1 'T)) 

(DEFUN |ORDCOMP;minusInfinity;$;6| ($) (CONS 1 'NIL)) 

(DEFUN |ORDCOMP;retractIfCan;$U;7| (|x| $)
  (COND ((QEQCAR |x| 0) (CONS 0 (CDR |x|))) ('T (CONS 1 "failed")))) 

(DEFUN |ORDCOMP;coerce;$Of;8| (|x| $)
  (PROG (#1=#:G674 |e|)
    (RETURN
     (SEQ
      (COND ((QEQCAR |x| 0) (SPADCALL (CDR |x|) (QREFELT $ 18)))
            (#2='T
             (SEQ (LETT |e| "infinity" . #3=(|ORDCOMP;coerce;$Of;8|))
                  (EXIT
                   (COND
                    ((PROG2
                         (LETT #1# |x| . #3#)
                         (QCDR #1#)
                       (|check-union| (QEQCAR #1# 1) (|Boolean|) #1#))
                     (SPADCALL (SPADCALL (QREFELT $ 19)) |e| (QREFELT $ 20)))
                    (#2# (SPADCALL |e| (QREFELT $ 21)))))))))))) 

(DEFUN |ORDCOMP;whatInfinity;$Si;9| (|x| $)
  (PROG (#1=#:G674)
    (RETURN
     (COND ((QEQCAR |x| 0) 0)
           ((PROG2
                (LETT #1# |x| |ORDCOMP;whatInfinity;$Si;9|)
                (QCDR #1#)
              (|check-union| (QEQCAR #1# 1) (|Boolean|) #1#))
            1)
           ('T -1))))) 

(DEFUN |ORDCOMP;=;2$B;10| (|x| |y| $)
  (COND
   ((QEQCAR |x| 1)
    (COND
     ((QEQCAR |y| 1)
      (COND ((SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 25)) 'NIL) (#1='T 'T)))
     (#1# 'NIL)))
   ((QEQCAR |y| 1) 'NIL) (#1# (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 26))))) 

(DEFUN |ORDCOMP;Zero;$;11| ($) (CONS 0 (|spadConstant| $ 28))) 

(DEFUN |ORDCOMP;*;I2$;12| (|n| |x| $)
  (COND
   ((QEQCAR |x| 1)
    (COND ((< 0 |n|) |x|)
          ((< |n| 0) (CONS 1 (COND ((CDR |x|) 'NIL) (#1='T 'T))))
          (#1# (|error| "Undefined product"))))
   (#1# (CONS 0 (SPADCALL |n| (CDR |x|) (QREFELT $ 31)))))) 

(DEFUN |ORDCOMP;-;2$;13| (|x| $)
  (COND ((QEQCAR |x| 1) (CONS 1 (COND ((CDR |x|) 'NIL) (#1='T 'T))))
        (#1# (CONS 0 (SPADCALL (CDR |x|) (QREFELT $ 33)))))) 

(DEFUN |ORDCOMP;+;3$;14| (|x| |y| $)
  (COND
   ((QEQCAR |x| 1)
    (COND
     ((OR (QEQCAR |y| 0) (NULL (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 25))))
      |x|)
     ('T (|error| "Undefined sum"))))
   ((QEQCAR |y| 1) |y|)
   ('T (CONS 0 (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 35)))))) 

(DEFUN |ORDCOMP;One;$;15| ($) (CONS 0 (|spadConstant| $ 37))) 

(DEFUN |ORDCOMP;characteristic;Nni;16| ($) (SPADCALL (QREFELT $ 40))) 

(DEFUN |ORDCOMP;fininf| (|b| |r| $)
  (COND ((SPADCALL (|spadConstant| $ 28) |r| (QREFELT $ 42)) (CONS 1 |b|))
        ((SPADCALL |r| (|spadConstant| $ 28) (QREFELT $ 42))
         (CONS 1 (COND (|b| 'NIL) (#1='T 'T))))
        (#1# (|error| "Undefined product")))) 

(DEFUN |ORDCOMP;*;3$;18| (|x| |y| $)
  (COND
   ((QEQCAR |x| 1)
    (COND
     ((QEQCAR |y| 1)
      (COND
       ((SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 25))
        (SPADCALL (QREFELT $ 14)))
       (#1='T (SPADCALL (QREFELT $ 13)))))
     (#1# (|ORDCOMP;fininf| (CDR |x|) (CDR |y|) $))))
   ((QEQCAR |y| 1) (|ORDCOMP;fininf| (CDR |y|) (CDR |x|) $))
   (#1# (CONS 0 (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 43)))))) 

(DEFUN |ORDCOMP;recip;$U;19| (|x| $)
  (PROG (|u|)
    (RETURN
     (SEQ
      (COND ((QEQCAR |x| 1) (CONS 0 (|spadConstant| $ 29)))
            (#1='T
             (SEQ
              (LETT |u| (SPADCALL (CDR |x|) (QREFELT $ 46))
                    |ORDCOMP;recip;$U;19|)
              (EXIT
               (COND ((QEQCAR |u| 1) (CONS 1 "failed"))
                     (#1# (CONS 0 (CONS 0 (QCDR |u|))))))))))))) 

(DEFUN |ORDCOMP;<;2$B;20| (|x| |y| $)
  (COND
   ((QEQCAR |x| 1)
    (COND
     ((QEQCAR |y| 1)
      (COND ((SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 25)) (CDR |y|))
            (#1='T 'NIL)))
     ((CDR |x|) 'NIL) (#1# 'T)))
   ((QEQCAR |y| 1) (CDR |y|))
   (#1# (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 42))))) 

(DEFUN |ORDCOMP;rational?;$B;21| (|x| $) (SPADCALL |x| (QREFELT $ 11))) 

(DEFUN |ORDCOMP;rational;$F;22| (|x| $)
  (SPADCALL (SPADCALL |x| (QREFELT $ 9)) (QREFELT $ 51))) 

(DEFUN |ORDCOMP;rationalIfCan;$U;23| (|x| $)
  (PROG (|r|)
    (RETURN
     (SEQ
      (LETT |r| (SPADCALL |x| (QREFELT $ 16)) |ORDCOMP;rationalIfCan;$U;23|)
      (EXIT
       (COND ((QEQCAR |r| 1) (CONS 1 "failed"))
             ('T (CONS 0 (SPADCALL (QCDR |r|) (QREFELT $ 51)))))))))) 

(DEFUN |OrderedCompletion| (#1=#:G749)
  (PROG ()
    (RETURN
     (PROG (#2=#:G750)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (LIST (|devaluate| #1#))
                                           (HGET |$ConstructorCache|
                                                 '|OrderedCompletion|)
                                           '|domainEqualList|)
                . #3=(|OrderedCompletion|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT (PROG1 (|OrderedCompletion;| #1#) (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|OrderedCompletion|))))))))))) 

(DEFUN |OrderedCompletion;| (|#1|)
  (PROG (|pv$| #1=#:G748 $ |dv$| DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #2=(|OrderedCompletion|))
      (LETT |dv$| (LIST '|OrderedCompletion| DV$1) . #2#)
      (LETT $ (GETREFV 58) . #2#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3
                (LETT |pv$|
                      (|buildPredVector| 0 0
                                         (LIST
                                          (|HasCategory| |#1| '(|OrderedRing|))
                                          (|HasCategory| |#1|
                                                         '(|RetractableTo|
                                                           (|Fraction|
                                                            (|Integer|))))
                                          (|HasCategory| |#1|
                                                         '(|RetractableTo|
                                                           (|Integer|)))
                                          (|HasCategory| |#1|
                                                         '(|IntegerNumberSystem|))
                                          (OR
                                           (|HasCategory| |#1|
                                                          '(|OrderedRing|))
                                           (|HasCategory| |#1|
                                                          '(|RetractableTo|
                                                            (|Integer|))))
                                          (LETT #1#
                                                (|HasCategory| |#1|
                                                               '(|AbelianGroup|))
                                                . #2#)
                                          (OR #1#
                                              (|HasCategory| |#1|
                                                             '(|OrderedRing|)))))
                      . #2#))
      (|haddProp| |$ConstructorCache| '|OrderedCompletion| (LIST DV$1)
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 (|Union| (|:| |fin| |#1|) (|:| |inf| (|Boolean|))))
      (COND
       ((|testBitVector| |pv$| 6)
        (PROGN
         (QSETREFV $ 29
                   (CONS IDENTITY
                         (FUNCALL (|dispatchFunction| |ORDCOMP;Zero;$;11|) $)))
         (QSETREFV $ 32 (CONS (|dispatchFunction| |ORDCOMP;*;I2$;12|) $))
         (QSETREFV $ 34 (CONS (|dispatchFunction| |ORDCOMP;-;2$;13|) $))
         (QSETREFV $ 36 (CONS (|dispatchFunction| |ORDCOMP;+;3$;14|) $)))))
      (COND
       ((|testBitVector| |pv$| 1)
        (PROGN
         (QSETREFV $ 38
                   (CONS IDENTITY
                         (FUNCALL (|dispatchFunction| |ORDCOMP;One;$;15|) $)))
         (QSETREFV $ 41
                   (CONS (|dispatchFunction| |ORDCOMP;characteristic;Nni;16|)
                         $))
         (QSETREFV $ 44 (CONS (|dispatchFunction| |ORDCOMP;*;3$;18|) $))
         (QSETREFV $ 47 (CONS (|dispatchFunction| |ORDCOMP;recip;$U;19|) $))
         (QSETREFV $ 48 (CONS (|dispatchFunction| |ORDCOMP;<;2$B;20|) $)))))
      (COND
       ((|testBitVector| |pv$| 4)
        (PROGN
         (QSETREFV $ 49
                   (CONS (|dispatchFunction| |ORDCOMP;rational?;$B;21|) $))
         (QSETREFV $ 52 (CONS (|dispatchFunction| |ORDCOMP;rational;$F;22|) $))
         (QSETREFV $ 54
                   (CONS (|dispatchFunction| |ORDCOMP;rationalIfCan;$U;23|)
                         $)))))
      $)))) 

(MAKEPROP '|OrderedCompletion| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) '|Rep|
              |ORDCOMP;coerce;R$;1| |ORDCOMP;retract;$R;2| (|Boolean|)
              |ORDCOMP;finite?;$B;3| |ORDCOMP;infinite?;$B;4|
              |ORDCOMP;plusInfinity;$;5| |ORDCOMP;minusInfinity;$;6|
              (|Union| 6 '"failed") |ORDCOMP;retractIfCan;$U;7| (|OutputForm|)
              (0 . |coerce|) (5 . |empty|) (9 . +) (15 . -)
              |ORDCOMP;coerce;$Of;8| (|SingleInteger|)
              |ORDCOMP;whatInfinity;$Si;9| (20 . |xor|) (26 . =)
              |ORDCOMP;=;2$B;10| (32 . |Zero|) (36 . |Zero|) (|Integer|)
              (40 . *) (46 . *) (52 . -) (57 . -) (62 . +) (68 . +)
              (74 . |One|) (78 . |One|) (|NonNegativeInteger|)
              (82 . |characteristic|) (86 . |characteristic|) (90 . <) (96 . *)
              (102 . *) (|Union| $ '"failed") (108 . |recip|) (113 . |recip|)
              (118 . <) (124 . |rational?|) (|Fraction| 30) (129 . |rational|)
              (134 . |rational|) (|Union| 50 '"failed") (139 . |rationalIfCan|)
              (|PositiveInteger|) (|Union| 30 '"failed") (|String|))
           '#(~= 144 |zero?| 150 |whatInfinity| 155 |subtractIfCan| 160
              |smaller?| 166 |sign| 172 |sample| 177 |retractIfCan| 181
              |retract| 196 |recip| 211 |rationalIfCan| 216 |rational?| 221
              |rational| 226 |positive?| 231 |plusInfinity| 236 |one?| 240
              |negative?| 245 |minusInfinity| 250 |min| 254 |max| 260 |latex|
              266 |infinite?| 271 |hash| 276 |finite?| 281 |coerce| 286
              |characteristic| 306 |abs| 310 ^ 315 |Zero| 327 |One| 331 >= 335
              > 341 = 347 <= 353 < 359 - 365 + 376 * 382)
           'NIL
           (CONS
            (|makeByteWordVec2| 7
                                '(1 1 1 1 1 1 1 7 1 1 7 1 1 1 7 1 1 7 0 0 0 0 0
                                  1 2 3))
            (CONS
             '#(|OrderedRing&| NIL |Ring&| NIL NIL NIL NIL |AbelianGroup&| NIL
                NIL NIL |OrderedSet&| NIL |Monoid&| |AbelianMonoid&| NIL
                |SemiGroup&| |AbelianSemiGroup&| |SetCategory&|
                |FullyRetractableTo&| |BasicType&| |RetractableTo&| NIL NIL
                |RetractableTo&| |RetractableTo&|)
             (CONS
              '#((|OrderedRing|) (|OrderedAbelianGroup|) (|Ring|)
                 (|OrderedCancellationAbelianMonoid|) (|Rng|) (|LeftModule| $$)
                 (|OrderedAbelianMonoid|) (|AbelianGroup|)
                 (|OrderedAbelianSemiGroup|) (|SemiRing|)
                 (|CancellationAbelianMonoid|) (|OrderedSet|) (|SemiRng|)
                 (|Monoid|) (|AbelianMonoid|) (|Comparable|) (|SemiGroup|)
                 (|AbelianSemiGroup|) (|SetCategory|) (|FullyRetractableTo| 6)
                 (|BasicType|) (|RetractableTo| 6) (|CoercibleTo| 17)
                 (|unitsKnown|) (|RetractableTo| 50) (|RetractableTo| 30))
              (|makeByteWordVec2| 57
                                  '(1 6 17 0 18 0 17 0 19 2 17 0 0 0 20 1 17 0
                                    0 21 2 10 0 0 0 25 2 6 10 0 0 26 0 6 0 28 0
                                    0 0 29 2 6 0 30 0 31 2 0 0 30 0 32 1 6 0 0
                                    33 1 0 0 0 34 2 6 0 0 0 35 2 0 0 0 0 36 0 6
                                    0 37 0 0 0 38 0 6 39 40 0 0 39 41 2 6 10 0
                                    0 42 2 6 0 0 0 43 2 0 0 0 0 44 1 6 45 0 46
                                    1 0 45 0 47 2 0 10 0 0 48 1 0 10 0 49 1 6
                                    50 0 51 1 0 50 0 52 1 0 53 0 54 2 0 10 0 0
                                    1 1 6 10 0 1 1 0 23 0 24 2 6 45 0 0 1 2 1
                                    10 0 0 1 1 1 30 0 1 0 6 0 1 1 2 53 0 1 1 3
                                    56 0 1 1 0 15 0 16 1 2 50 0 1 1 3 30 0 1 1
                                    0 6 0 9 1 1 45 0 47 1 4 53 0 54 1 4 10 0 49
                                    1 4 50 0 52 1 1 10 0 1 0 0 0 13 1 1 10 0 1
                                    1 1 10 0 1 0 0 0 14 2 1 0 0 0 1 2 1 0 0 0 1
                                    1 0 57 0 1 1 0 10 0 12 1 0 23 0 1 1 0 10 0
                                    11 1 5 0 30 1 1 2 0 50 1 1 0 0 6 8 1 0 17 0
                                    22 0 1 39 41 1 1 0 0 1 2 1 0 0 39 1 2 1 0 0
                                    55 1 0 6 0 29 0 1 0 38 2 1 10 0 0 1 2 1 10
                                    0 0 1 2 0 10 0 0 27 2 1 10 0 0 1 2 1 10 0 0
                                    48 1 6 0 0 34 2 6 0 0 0 1 2 6 0 0 0 36 2 6
                                    0 55 0 1 2 6 0 39 0 1 2 6 0 30 0 32 2 1 0 0
                                    0 44)))))
           '|lookupComplete|)) 
