
(/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=#:G1804 |e|)
    (RETURN
     (SEQ
      (COND ((QEQCAR |x| 0) (SPADCALL (CDR |x|) (QREFELT $ 18)))
            (#2='T
             (SEQ
              (LETT |e| (SPADCALL '|infinity| (QREFELT $ 20))
                    . #3=(|ORDCOMP;coerce;$Of;8|))
              (EXIT
               (COND
                ((PROG2
                     (LETT #1# |x| . #3#)
                     (QCDR #1#)
                   (|check-union| (QEQCAR #1# 1) (|Boolean|) #1#))
                 (SPADCALL (SPADCALL (QREFELT $ 21)) |e| (QREFELT $ 22)))
                (#2# (SPADCALL |e| (QREFELT $ 23)))))))))))) 

(DEFUN |ORDCOMP;whatInfinity;$Si;9| (|x| $)
  (PROG (#1=#:G1804)
    (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 $ 27)) 'NIL) (#1='T 'T)))
     (#1# 'NIL)))
   ((QEQCAR |y| 1) 'NIL) (#1# (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 28))))) 

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

(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 $ 33)))))) 

(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 $ 35)))))) 

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

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

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

(DEFUN |ORDCOMP;fininf| (|b| |r| $)
  (COND ((SPADCALL (|spadConstant| $ 30) |r| (QREFELT $ 44)) (CONS 1 |b|))
        ((SPADCALL |r| (|spadConstant| $ 30) (QREFELT $ 44))
         (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 $ 27))
        (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 $ 45)))))) 

(DEFUN |ORDCOMP;recip;$U;19| (|x| $)
  (PROG (|u|)
    (RETURN
     (SEQ
      (COND ((QEQCAR |x| 1) (CONS 0 (|spadConstant| $ 31)))
            (#1='T
             (SEQ
              (LETT |u| (SPADCALL (CDR |x|) (QREFELT $ 48))
                    |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 $ 27)) (CDR |y|))
            (#1='T 'NIL)))
     ((CDR |x|) 'NIL) (#1# 'T)))
   ((QEQCAR |y| 1) (CDR |y|))
   (#1# (SPADCALL (CDR |x|) (CDR |y|) (QREFELT $ 44))))) 

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

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

(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 $ 53)))))))))) 

(DEFUN |OrderedCompletion| (#1=#:G1894)
  (PROG ()
    (RETURN
     (PROG (#2=#:G1895)
       (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=#:G1893 $ |dv$| DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #2=(|OrderedCompletion|))
      (LETT |dv$| (LIST '|OrderedCompletion| DV$1) . #2#)
      (LETT $ (GETREFV 60) . #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|
                                                          '(|RetractableTo|
                                                            (|Integer|)))
                                           (|HasCategory| |#1|
                                                          '(|OrderedRing|)))
                                          (LETT #1#
                                                (|HasCategory| |#1|
                                                               '(|AbelianGroup|))
                                                . #2#)
                                          (OR #1#
                                              (|HasCategory| |#1|
                                                             '(|OrderedRing|)))))
                      . #2#))
      (|haddProp| |$ConstructorCache| '|OrderedCompletion| (LIST DV$1)
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (SETF |pv$| (QREFELT $ 3))
      (QSETREFV $ 7 (|Union| (|:| |fin| |#1|) (|:| |inf| (|Boolean|))))
      (COND
       ((|testBitVector| |pv$| 6)
        (PROGN
         (QSETREFV $ 31
                   (CONS IDENTITY
                         (FUNCALL (|dispatchFunction| |ORDCOMP;Zero;$;11|) $)))
         (QSETREFV $ 34 (CONS (|dispatchFunction| |ORDCOMP;*;I2$;12|) $))
         (QSETREFV $ 36 (CONS (|dispatchFunction| |ORDCOMP;-;2$;13|) $))
         (QSETREFV $ 38 (CONS (|dispatchFunction| |ORDCOMP;+;3$;14|) $)))))
      (COND
       ((|testBitVector| |pv$| 1)
        (PROGN
         (QSETREFV $ 40
                   (CONS IDENTITY
                         (FUNCALL (|dispatchFunction| |ORDCOMP;One;$;15|) $)))
         (QSETREFV $ 43
                   (CONS (|dispatchFunction| |ORDCOMP;characteristic;Nni;16|)
                         $))
         (QSETREFV $ 46 (CONS (|dispatchFunction| |ORDCOMP;*;3$;18|) $))
         (QSETREFV $ 49 (CONS (|dispatchFunction| |ORDCOMP;recip;$U;19|) $))
         (QSETREFV $ 50 (CONS (|dispatchFunction| |ORDCOMP;<;2$B;20|) $)))))
      (COND
       ((|testBitVector| |pv$| 4)
        (PROGN
         (QSETREFV $ 51
                   (CONS (|dispatchFunction| |ORDCOMP;rational?;$B;21|) $))
         (QSETREFV $ 54 (CONS (|dispatchFunction| |ORDCOMP;rational;$F;22|) $))
         (QSETREFV $ 56
                   (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|) (|Symbol|) (5 . |coerce|) (10 . |empty|) (14 . +)
              (20 . -) |ORDCOMP;coerce;$Of;8| (|SingleInteger|)
              |ORDCOMP;whatInfinity;$Si;9| (25 . |xor|) (31 . =)
              |ORDCOMP;=;2$B;10| (37 . |Zero|) (41 . |Zero|) (|Integer|)
              (45 . *) (51 . *) (57 . -) (62 . -) (67 . +) (73 . +)
              (79 . |One|) (83 . |One|) (|NonNegativeInteger|)
              (87 . |characteristic|) (91 . |characteristic|) (95 . <)
              (101 . *) (107 . *) (|Union| $ '"failed") (113 . |recip|)
              (118 . |recip|) (123 . <) (129 . |rational?|) (|Fraction| 32)
              (134 . |rational|) (139 . |rational|) (|Union| 52 '"failed")
              (144 . |rationalIfCan|) (|PositiveInteger|)
              (|Union| 32 '"failed") (|String|))
           '#(~= 149 |zero?| 155 |whatInfinity| 160 |subtractIfCan| 165
              |smaller?| 171 |sign| 177 |sample| 182 |retractIfCan| 186
              |retract| 201 |recip| 216 |rationalIfCan| 221 |rational?| 226
              |rational| 231 |positive?| 236 |plusInfinity| 241 |one?| 245
              |negative?| 250 |minusInfinity| 255 |min| 259 |max| 265 |latex|
              271 |infinite?| 276 |hash| 281 |finite?| 286 |coerce| 291
              |characteristic| 311 |abs| 315 ^ 320 |Zero| 332 |One| 336 >= 340
              > 346 = 352 <= 358 < 364 - 370 + 381 * 387)
           '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| 52) (|RetractableTo| 32))
              (|makeByteWordVec2| 59
                                  '(1 6 17 0 18 1 19 17 0 20 0 17 0 21 2 17 0 0
                                    0 22 1 17 0 0 23 2 10 0 0 0 27 2 6 10 0 0
                                    28 0 6 0 30 0 0 0 31 2 6 0 32 0 33 2 0 0 32
                                    0 34 1 6 0 0 35 1 0 0 0 36 2 6 0 0 0 37 2 0
                                    0 0 0 38 0 6 0 39 0 0 0 40 0 6 41 42 0 0 41
                                    43 2 6 10 0 0 44 2 6 0 0 0 45 2 0 0 0 0 46
                                    1 6 47 0 48 1 0 47 0 49 2 0 10 0 0 50 1 0
                                    10 0 51 1 6 52 0 53 1 0 52 0 54 1 0 55 0 56
                                    2 0 10 0 0 1 1 6 10 0 1 1 0 25 0 26 2 6 47
                                    0 0 1 2 1 10 0 0 1 1 1 32 0 1 0 6 0 1 1 2
                                    55 0 1 1 3 58 0 1 1 0 15 0 16 1 2 52 0 1 1
                                    3 32 0 1 1 0 6 0 9 1 1 47 0 49 1 4 55 0 56
                                    1 4 10 0 51 1 4 52 0 54 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 59 0 1 1 0 10 0 12 1 0 25 0
                                    1 1 0 10 0 11 1 5 0 32 1 1 2 0 52 1 1 0 0 6
                                    8 1 0 17 0 24 0 1 41 43 1 1 0 0 1 2 1 0 0
                                    57 1 2 1 0 0 41 1 0 6 0 31 0 1 0 40 2 1 10
                                    0 0 1 2 1 10 0 0 1 2 0 10 0 0 29 2 1 10 0 0
                                    1 2 1 10 0 0 50 2 6 0 0 0 1 1 6 0 0 36 2 6
                                    0 0 0 38 2 6 0 57 0 1 2 6 0 41 0 1 2 6 0 32
                                    0 34 2 1 0 0 0 46)))))
           '|lookupComplete|)) 
