
(/VERSIONCHECK 2) 

(PUT '|CARD;Zero;$;1| '|SPADreplace| '(XLAM NIL (CONS -1 0))) 

(DEFUN |CARD;Zero;$;1| ($) (CONS -1 0)) 

(PUT '|CARD;One;$;2| '|SPADreplace| '(XLAM NIL (CONS -1 1))) 

(DEFUN |CARD;One;$;2| ($) (CONS -1 1)) 

(PUT '|CARD;coerce;Nni$;3| '|SPADreplace| '(XLAM (|n|) (CONS -1 |n|))) 

(DEFUN |CARD;coerce;Nni$;3| (|n| $) (CONS -1 |n|)) 

(PUT '|CARD;Aleph;Nni$;4| '|SPADreplace| '(XLAM (|n|) (CONS |n| -1))) 

(DEFUN |CARD;Aleph;Nni$;4| (|n| $) (CONS |n| -1)) 

(DEFUN |CARD;coerce;$Of;5| (|x| $)
  (COND ((EQL (QCAR |x|) -1) (SPADCALL (QCDR |x|) (QREFELT $ 19)))
        ('T
         (SPADCALL (QREFELT $ 16) (LIST (SPADCALL (QCAR |x|) (QREFELT $ 19)))
                   (QREFELT $ 21))))) 

(DEFUN |CARD;=;2$B;6| (|x| |y| $)
  (COND ((NULL (EQL (QCAR |x|) (QCAR |y|))) 'NIL)
        ('T
         (COND ((SPADCALL |x| (QREFELT $ 23)) (EQL (QCDR |x|) (QCDR |y|)))
               ('T 'T))))) 

(DEFUN |CARD;<;2$B;7| (|x| |y| $)
  (COND ((< (QCAR |x|) (QCAR |y|)) 'T)
        ((OR (< (QCAR |y|) (QCAR |x|)) (NULL (SPADCALL |x| (QREFELT $ 23))))
         'NIL)
        ('T (< (QCDR |x|) (QCDR |y|))))) 

(DEFUN |CARD;+;3$;8| (|x| |y| $)
  (SEQ
   (COND
    ((SPADCALL |x| (QREFELT $ 23))
     (COND
      ((SPADCALL |y| (QREFELT $ 23))
       (EXIT (CONS -1 (+ (QCDR |x|) (QCDR |y|))))))))
   (EXIT (SPADCALL |x| |y| (QREFELT $ 26))))) 

(DEFUN |CARD;-;2$U;9| (|x| |y| $)
  (COND ((SPADCALL |x| |y| (QREFELT $ 25)) (CONS 1 "failed"))
        ((SPADCALL |x| (QREFELT $ 23))
         (CONS 0 (CONS -1 (- (QCDR |x|) (QCDR |y|)))))
        ((SPADCALL |y| |x| (QREFELT $ 25)) (CONS 0 |x|))
        ('T (CONS 1 "failed")))) 

(DEFUN |CARD;*;3$;10| (|x| |y| $)
  (SEQ
   (COND
    ((SPADCALL |x| (QREFELT $ 23))
     (COND
      ((SPADCALL |y| (QREFELT $ 23))
       (EXIT (CONS -1 (* (QCDR |x|) (QCDR |y|))))))))
   (COND
    ((OR (SPADCALL |x| (|spadConstant| $ 12) (QREFELT $ 24))
         (SPADCALL |y| (|spadConstant| $ 12) (QREFELT $ 24)))
     (EXIT (|spadConstant| $ 12))))
   (EXIT (SPADCALL |x| |y| (QREFELT $ 26))))) 

(DEFUN |CARD;*;Nni2$;11| (|n| |x| $)
  (COND
   ((SPADCALL |x| (QREFELT $ 23))
    (CONS -1 (SPADCALL |n| (QCDR |x|) (QREFELT $ 31))))
   ((EQL |n| 0) (|spadConstant| $ 12)) ('T |x|))) 

(DEFUN |CARD;^;3$;12| (|x| |y| $)
  (PROG (#1=#:G714)
    (RETURN
     (COND
      ((SPADCALL |y| (|spadConstant| $ 12) (QREFELT $ 24))
       (COND
        ((SPADCALL |x| (|spadConstant| $ 12) (QREFELT $ 24))
         (|error| "0^0 not defined for cardinal numbers."))
        (#2='T (|spadConstant| $ 11))))
      ((SPADCALL |y| (QREFELT $ 23))
       (COND ((NULL (SPADCALL |x| (QREFELT $ 23))) |x|)
             ('T
              (CONS -1
                    (EXPT (QCDR |x|)
                          (PROG1 (LETT #1# (QCDR |y|) |CARD;^;3$;12|)
                            (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|)
                                             #1#)))))))
      ((SPADCALL |x| (|spadConstant| $ 12) (QREFELT $ 24))
       (|spadConstant| $ 12))
      ((SPADCALL |x| (|spadConstant| $ 11) (QREFELT $ 24))
       (|spadConstant| $ 11))
      ((SPADCALL (QREFELT $ 10) (QREFELT $ 33))
       (CONS (+ (MAX (- (QCAR |x|) 1) (QCAR |y|)) 1) -1))
      (#2#
       (|error| "Transfinite exponentiation only implemented under GCH")))))) 

(DEFUN |CARD;finite?;$B;13| (|x| $) (EQL (QCAR |x|) -1)) 

(DEFUN |CARD;countable?;$B;14| (|x| $) (< (QCAR |x|) 1)) 

(DEFUN |CARD;retract;$Nni;15| (|x| $)
  (PROG (#1=#:G723)
    (RETURN
     (COND
      ((SPADCALL |x| (QREFELT $ 23))
       (PROG1 (LETT #1# (QCDR |x|) |CARD;retract;$Nni;15|)
         (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|) #1#)))
      ('T (|error| "Not finite")))))) 

(DEFUN |CARD;retractIfCan;$U;16| (|x| $)
  (PROG (#1=#:G729)
    (RETURN
     (COND
      ((SPADCALL |x| (QREFELT $ 23))
       (CONS 0
             (PROG1 (LETT #1# (QCDR |x|) |CARD;retractIfCan;$U;16|)
               (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|) #1#))))
      ('T (CONS 1 "failed")))))) 

(DEFUN |CARD;generalizedContinuumHypothesisAssumed?;B;17| ($)
  (SPADCALL (QREFELT $ 10) (QREFELT $ 33))) 

(DEFUN |CARD;generalizedContinuumHypothesisAssumed;2B;18| (|b| $)
  (SPADCALL (QREFELT $ 10) |b| (QREFELT $ 40))) 

(DEFUN |CardinalNumber| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G738)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|CardinalNumber|)
                . #3=(|CardinalNumber|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|CardinalNumber|
                         (LIST (CONS NIL (CONS 1 (|CardinalNumber;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#) (HREM |$ConstructorCache| '|CardinalNumber|))))))))))) 

(DEFUN |CardinalNumber;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|CardinalNumber|) . #1=(|CardinalNumber|))
      (LETT $ (GETREFV 45) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|CardinalNumber| NIL (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6
                (|Record| (|:| |order| (|Integer|)) (|:| |ival| (|Integer|))))
      (QSETREFV $ 10 (SPADCALL 'NIL (QREFELT $ 9)))
      (QSETREFV $ 16 "Aleph")
      $)))) 

(MAKEPROP '|CardinalNumber| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL '|Rep| (|Boolean|) (|Reference| 7)
              (0 . |ref|) '|GCHypothesis|
              (CONS IDENTITY (FUNCALL (|dispatchFunction| |CARD;One;$;2|) $))
              (CONS IDENTITY (FUNCALL (|dispatchFunction| |CARD;Zero;$;1|) $))
              (|NonNegativeInteger|) |CARD;coerce;Nni$;3| |CARD;Aleph;Nni$;4|
              '|ALEPHexpr| (|OutputForm|) (|Integer|) (5 . |coerce|) (|List| $)
              (10 . |prefix|) |CARD;coerce;$Of;5| |CARD;finite?;$B;13|
              |CARD;=;2$B;6| |CARD;<;2$B;7| (16 . |max|) |CARD;+;3$;8|
              (|Union| $ '"failed") |CARD;-;2$U;9| |CARD;*;3$;10| (22 . *)
              |CARD;*;Nni2$;11| (28 . |elt|) |CARD;^;3$;12|
              |CARD;countable?;$B;14| |CARD;retract;$Nni;15|
              (|Union| 13 '"failed") |CARD;retractIfCan;$U;16|
              |CARD;generalizedContinuumHypothesisAssumed?;B;17|
              (33 . |setelt|)
              |CARD;generalizedContinuumHypothesisAssumed;2B;18|
              (|PositiveInteger|) (|SingleInteger|) (|String|))
           '#(~= 39 |zero?| 45 |smaller?| 50 |sample| 56 |retractIfCan| 60
              |retract| 65 |recip| 70 |one?| 75 |min| 80 |max| 86 |latex| 92
              |hash| 97 |generalizedContinuumHypothesisAssumed?| 102
              |generalizedContinuumHypothesisAssumed| 106 |finite?| 111
              |countable?| 116 |coerce| 121 ^ 131 |Zero| 149 |One| 153 |Aleph|
              157 >= 162 > 168 = 174 <= 180 < 186 - 192 + 198 * 204)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0 0 0 0 0 0 0 0 0))
                 (CONS
                  '#(|OrderedSet&| |Monoid&| |AbelianMonoid&| NIL |SemiGroup&|
                     |AbelianSemiGroup&| |SetCategory&| NIL |RetractableTo&|
                     |BasicType&| NIL)
                  (CONS
                   '#((|OrderedSet|) (|Monoid|) (|AbelianMonoid|)
                      (|Comparable|) (|SemiGroup|) (|AbelianSemiGroup|)
                      (|SetCategory|) (|CommutativeStar|) (|RetractableTo| 13)
                      (|BasicType|) (|CoercibleTo| 17))
                   (|makeByteWordVec2| 44
                                       '(1 8 0 7 9 1 18 17 0 19 2 17 0 0 20 21
                                         2 0 0 0 0 26 2 18 0 13 0 31 1 8 7 0 33
                                         2 8 7 0 7 40 2 0 7 0 0 1 1 0 7 0 1 2 0
                                         7 0 0 1 0 0 0 1 1 0 37 0 38 1 0 13 0
                                         36 1 0 28 0 1 1 0 7 0 1 2 0 0 0 0 1 2
                                         0 0 0 0 26 1 0 44 0 1 1 0 43 0 1 0 0 7
                                         39 1 0 7 7 41 1 0 7 0 23 1 0 7 0 35 1
                                         0 0 13 14 1 0 17 0 22 2 0 0 0 0 34 2 0
                                         0 0 42 1 2 0 0 0 13 1 0 0 0 12 0 0 0
                                         11 1 0 0 13 15 2 0 7 0 0 1 2 0 7 0 0 1
                                         2 0 7 0 0 24 2 0 7 0 0 1 2 0 7 0 0 25
                                         2 0 28 0 0 29 2 0 0 0 0 27 2 0 0 0 0
                                         30 2 0 0 42 0 1 2 0 0 13 0 32)))))
           '|lookupComplete|)) 

(MAKEPROP '|CardinalNumber| 'NILADIC T) 
