
(/VERSIONCHECK 2) 

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

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

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

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

(DEFUN |HallBasis;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|HallBasis|) . #1=(|HallBasis|))
      (LETT $ (GETREFV 21) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|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 . |setelt|)
              (|Vector| 6) (13 . |setelt|) (20 . |elt|) (26 . |elt|)
              (32 . |elt|) |HB;generate;2NniV;3|)
           '#(|lfunc| 38 |inHallBasis?| 44 |generate| 52) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 20
                                                 '(2 6 0 8 0 9 3 13 12 0 6 12
                                                   14 3 15 6 0 6 6 16 2 13 12 0
                                                   6 17 2 12 6 0 6 18 2 15 6 0
                                                   6 19 2 0 6 6 6 7 4 0 10 6 6
                                                   6 6 11 2 0 13 8 8 20)))))
           '|lookupComplete|)) 

(MAKEPROP '|HallBasis| 'NILADIC T) 
