
(/VERSIONCHECK 2) 

(DEFUN |HB;lfunc;3I;1| (|d| |n| $)
  (PROG (|m| #0=#:G1829 |sum| #1=#:G1826 |res|)
    (RETURN
      (SEQ (COND
             ((< |n| 0) 0)
             ((EQL |n| 0) 1)
             ((EQL |n| 1) |d|)
             ('T
              (SEQ (LETT |sum| 0 . #2=(|HB;lfunc;3I;1|))
                   (SEQ (LETT |m| 1 . #2#) (LETT #0# (- |n| 1) . #2#)
                        G190 (COND ((QSGREATERP |m| #0#) (GO G191)))
                        (SEQ (EXIT (COND
                                     ((EQL (REMAINDER2 |n| |m|) 0)
                                      (LETT |sum|
                                       (+ |sum|
                                        (SPADCALL |m|
                                         (SPADCALL |d| |m|
                                          (QREFELT $ 7))
                                         (QREFELT $ 9))) . #2#)))))
                        (LETT |m| (QSADD1 |m|) . #2#) (GO G190) G191
                        (EXIT NIL))
                   (EXIT (LETT |res|
                               (QUOTIENT2
                                   (-
                                    (EXPT |d|
                                     (PROG1 (LETT #1# |n| . #2#)
                                       (|check-subtype| (>= #1# 0)
                                        '(|NonNegativeInteger|) #1#)))
                                    |sum|)
                                   |n|) . #2#))))))))) 

(DEFUN |HB;inHallBasis?;4IB;2| (|n| |i| |j| |l| $)
  (COND
    ((< |i| |j|)
     (COND
       ((< |n| |j|) (COND ((< |i| |l|) 'NIL) (#0='T 'T)))
       (#0# 'T)))
    (#0# 'NIL))) 

(DEFUN |HB;generate;2NniV;3| (|n| |c| $)
  (PROG (|gens| |maxweight| |siz| #0=#:G1832 |v| |i| |firstindex| |wt|
                |done| |rightIndex| #1=#:G1845 |newNumComms|
                |leftIndex| |cW| |numComms|)
    (RETURN
      (SEQ (LETT |gens| |n| . #2=(|HB;generate;2NniV;3|))
           (LETT |maxweight| |c| . #2#) (LETT |siz| 0 . #2#)
           (SEQ (LETT |i| 1 . #2#) G190
                (COND ((QSGREATERP |i| |maxweight|) #3=(GO G191)))
                (SEQ (EXIT (LETT |siz|
                                 (+ |siz|
                                    (SPADCALL |gens| |i| (QREFELT $ 7))) . #2#)))
                (LETT |i| (QSADD1 |i|) . #2#) #4=(GO G190) G191
                (EXIT NIL))
           (LETT |v|
                 (SPADCALL
                     (PROG1 (LETT #0# |siz| . #2#)
                       (|check-subtype| (>= #0# 0)
                           '(|NonNegativeInteger|) #0#))
                     NIL (QREFELT $ 14)) . #2#)
           (SEQ (LETT |i| 1 . #2#) G190
                (COND ((QSGREATERP |i| |gens|) #3#))
                (SEQ (EXIT (SPADCALL |v| |i| (LIST 0 1 |i|)
                               (QREFELT $ 15))))
                (LETT |i| (QSADD1 |i|) . #2#) #4# G191 (EXIT NIL))
           (LETT |firstindex|
                 (SPADCALL |maxweight| 0 (QREFELT $ 17)) . #2#)
           (LETT |wt| 1 . #2#)
           (SPADCALL |firstindex| 1 1 (QREFELT $ 18))
           (LETT |numComms| |gens| . #2#)
           (LETT |newNumComms| |numComms| . #2#)
           (LETT |done| 'NIL . #2#)
           (SEQ G190 (COND ((NULL (COND (|done| 'NIL) ('T 'T))) #3#))
                (SEQ (LETT |wt| (+ |wt| 1) . #2#)
                     (EXIT (COND
                             ((< |maxweight| |wt|)
                              (LETT |done| 'T . #2#))
                             ('T
                              (SEQ (SPADCALL |firstindex| |wt|
                                    (+ |newNumComms| 1) (QREFELT $ 18))
                                   (LETT |leftIndex| 1 . #2#)
                                   (LETT |cW| (- |wt| 1) . #2#)
                                   (SEQ G190
                                    (COND
                                      ((NULL
                                        (COND
                                          ((OR
                                            (< |numComms| |leftIndex|)
                                            (< |cW|
                                             (SPADCALL
                                              (SPADCALL |v| |leftIndex|
                                               (QREFELT $ 19))
                                              2 (QREFELT $ 20))))
                                           'NIL)
                                          ('T 'T)))
                                       #3#))
                                    (SEQ
                                     (SEQ
                                      (LETT |rightIndex|
                                       (SPADCALL |firstindex| |cW|
                                        (QREFELT $ 21)) . #2#)
                                      (LETT #1#
                                       (-
                                        (SPADCALL |firstindex|
                                         (+ |cW| 1) (QREFELT $ 21))
                                        1) . #2#)
                                      G190
                                      (COND
                                        ((> |rightIndex| #1#) #3#))
                                      (SEQ
                                       (EXIT
                                        (COND
                                          ((SPADCALL |gens| |leftIndex|
                                            |rightIndex|
                                            (SPADCALL
                                             (SPADCALL |v| |rightIndex|
                                              (QREFELT $ 19))
                                             1 (QREFELT $ 20))
                                            (QREFELT $ 11))
                                           (SEQ
                                            (LETT |newNumComms|
                                             (+ |newNumComms| 1) . #2#)
                                            (EXIT
                                             (SPADCALL |v|
                                              |newNumComms|
                                              (LIST |leftIndex| |wt|
                                               |rightIndex|)
                                              (QREFELT $ 15))))))))
                                      (LETT |rightIndex|
                                       (+ |rightIndex| 1) . #2#)
                                      #4# G191 (EXIT NIL))
                                     (LETT |leftIndex|
                                      (+ |leftIndex| 1) . #2#)
                                     (EXIT
                                      (LETT |cW|
                                       (- |wt|
                                        (SPADCALL
                                         (SPADCALL |v| |leftIndex|
                                          (QREFELT $ 19))
                                         2 (QREFELT $ 20))) . #2#)))
                                    NIL #4# G191 (EXIT NIL))
                                   (EXIT
                                    (LETT |numComms|
                                     |newNumComms| . #2#)))))))
                NIL #4# G191 (EXIT NIL))
           (EXIT |v|))))) 

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

(DEFUN |HallBasis;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT |dv$| '(|HallBasis|) . #0=(|HallBasis|))
        (LETT $ (GETREFV 23) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|HallBasis| NIL (CONS 1 $))
        (|stuffDomainSlots| $)
        $)))) 

(MAKEPROP '|HallBasis| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|Integer|) |HB;lfunc;3I;1|
             (|NonNegativeInteger|) (0 . *) (|Boolean|)
             |HB;inHallBasis?;4IB;2| (|List| 6) (|Vector| 12)
             (6 . |new|) (12 . |setelt|) (|Vector| 6) (19 . |new|)
             (25 . |setelt|) (32 . |elt|) (38 . |elt|) (44 . |elt|)
             |HB;generate;2NniV;3|)
          '#(|lfunc| 50 |inHallBasis?| 56 |generate| 64) 'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 22
                                '(2 6 0 8 0 9 2 13 0 8 12 14 3 13 12 0
                                  6 12 15 2 16 0 8 6 17 3 16 6 0 6 6 18
                                  2 13 12 0 6 19 2 12 6 0 6 20 2 16 6 0
                                  6 21 2 0 6 6 6 7 4 0 10 6 6 6 6 11 2
                                  0 13 8 8 22)))))
          '|lookupComplete|)) 

(MAKEPROP '|HallBasis| 'NILADIC T) 
