
(/VERSIONCHECK 2) 

(PUT '|PBWLB;One;$;1| '|SPADreplace| '(XLAM NIL NIL)) 

(DEFUN |PBWLB;One;$;1| ($) NIL) 

(DEFUN |PBWLB;=;2$B;2| (|x| |y| $) (SPADCALL |x| |y| (QREFELT $ 10))) 

(DEFUN |PBWLB;varList;$L;3| (|x| $)
  (PROG (|l| #0=#:G1825 #1=#:G1823 #2=#:G1821 #3=#:G1822 |le|)
    (RETURN
      (SEQ (COND
             ((NULL |x|) NIL)
             (#4='T
              (LETT |le|
                    (PROGN
                      (LETT #3# NIL . #5=(|PBWLB;varList;$L;3|))
                      (SEQ (LETT |l| NIL . #5#) (LETT #0# |x| . #5#)
                           G190
                           (COND
                             ((OR (ATOM #0#)
                                  (PROGN
                                    (LETT |l| (CAR #0#) . #5#)
                                    NIL))
                              (GO G191)))
                           (SEQ (EXIT (PROGN
                                        (LETT #1#
                                         (SPADCALL |l| (QREFELT $ 14)) . #5#)
                                        (COND
                                          (#3#
                                           (LETT #2#
                                            (SPADCALL #2# #1#
                                             (QREFELT $ 15)) . #5#))
                                          ('T
                                           (PROGN
                                             (LETT #2# #1# . #5#)
                                             (LETT #3# 'T . #5#)))))))
                           (LETT #0# (CDR #0#) . #5#) (GO G190) G191
                           (EXIT NIL))
                      (COND
                        (#3# #2#)
                        (#4# (|IdentityError| '|setUnion|)))) . #5#))))))) 

(PUT '|PBWLB;first;$Lw;4| '|SPADreplace| '|SPADfirst|) 

(DEFUN |PBWLB;first;$Lw;4| (|x| $) (|SPADfirst| |x|)) 

(PUT '|PBWLB;rest;2$;5| '|SPADreplace| 'CDR) 

(DEFUN |PBWLB;rest;2$;5| (|x| $) (CDR |x|)) 

(DEFUN |PBWLB;coerce;VarSet$;6| (|v| $)
  (LIST (SPADCALL |v| (QREFELT $ 19)))) 

(PUT '|PBWLB;coerce;Lw$;7| '|SPADreplace| 'LIST) 

(DEFUN |PBWLB;coerce;Lw$;7| (|l| $) (LIST |l|)) 

(PUT '|PBWLB;ListOfTerms;$L;8| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |PBWLB;ListOfTerms;$L;8| (|x| $) |x|) 

(DEFUN |PBWLB;coerce;$Ofm;9| (|x| $)
  (COND
    ((NULL |x|) (|spadConstant| $ 25))
    ('T
     (SPADCALL (SPADCALL (|SPADfirst| |x|) (QREFELT $ 26))
         (SPADCALL (CDR |x|) (QREFELT $ 27)) (QREFELT $ 28))))) 

(DEFUN |PBWLB;coerce;$Of;10| (|x| $)
  (PROG (#0=#:G1835 |l| #1=#:G1836)
    (RETURN
      (SEQ (COND
             ((NULL |x|) (SPADCALL 1 (QREFELT $ 31)))
             ('T
              (SPADCALL (ELT $ 32)
                  (PROGN
                    (LETT #0# NIL . #2=(|PBWLB;coerce;$Of;10|))
                    (SEQ (LETT |l| NIL . #2#) (LETT #1# |x| . #2#) G190
                         (COND
                           ((OR (ATOM #1#)
                                (PROGN (LETT |l| (CAR #1#) . #2#) NIL))
                            (GO G191)))
                         (SEQ (EXIT (LETT #0#
                                     (CONS
                                      (SPADCALL |l| (QREFELT $ 33))
                                      #0#) . #2#)))
                         (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                         (EXIT (NREVERSE0 #0#))))
                  (QREFELT $ 36)))))))) 

(DEFUN |PBWLB;retractable?;$B;11| (|x| $)
  (COND ((NULL |x|) 'NIL) ('T (NULL (CDR |x|))))) 

(DEFUN |PBWLB;retract;$Lw;12| (|x| $)
  (COND
    ((NULL (EQL (LENGTH |x|) 1))
     (|error| "cannot convert to Lyndon word"))
    ('T (|SPADfirst| |x|)))) 

(DEFUN |PBWLB;retractIfCan;$U;13| (|x| $)
  (COND
    ((SPADCALL |x| (QREFELT $ 38)) (CONS 0 (|SPADfirst| |x|)))
    ('T (CONS 1 "failed")))) 

(DEFUN |PBWLB;length;$Nni;14| (|x| $)
  (PROG (|l| #0=#:G1855 #1=#:G1851 #2=#:G1849 #3=#:G1850 |n|
             #4=#:G1852)
    (RETURN
      (SEQ (LETT |n|
                 (PROGN
                   (LETT #3# NIL . #5=(|PBWLB;length;$Nni;14|))
                   (SEQ (LETT |l| NIL . #5#) (LETT #0# |x| . #5#) G190
                        (COND
                          ((OR (ATOM #0#)
                               (PROGN (LETT |l| (CAR #0#) . #5#) NIL))
                           (GO G191)))
                        (SEQ (EXIT (PROGN
                                     (LETT #1#
                                      (SPADCALL |l| (QREFELT $ 43)) . #5#)
                                     (COND
                                       (#3#
                                        (LETT #2# (+ #2# #1#) . #5#))
                                       ('T
                                        (PROGN
                                          (LETT #2# #1# . #5#)
                                          (LETT #3# 'T . #5#)))))))
                        (LETT #0# (CDR #0#) . #5#) (GO G190) G191
                        (EXIT NIL))
                   (COND (#3# #2#) ('T 0))) . #5#)
           (EXIT (PROG1 (LETT #4# |n| . #5#)
                   (|check-subtype| (>= #4# 0) '(|NonNegativeInteger|)
                       #4#))))))) 

(DEFUN |PBWLB;recursif| (|x| |y| $)
  (COND
    ((NULL |y|) 'NIL)
    ((NULL |x|) 'T)
    ('T
     (COND
       ((SPADCALL (|SPADfirst| |x|) (|SPADfirst| |y|) (QREFELT $ 46))
        (|PBWLB;recursif| (SPADCALL |x| (QREFELT $ 18))
            (SPADCALL |y| (QREFELT $ 18)) $))
       ('T
        (SPADCALL (|SPADfirst| |x|) (|SPADfirst| |y|) (QREFELT $ 47))))))) 

(DEFUN |PBWLB;<;2$B;16| (|x| |y| $)
  (PROG (|lx| |ly|)
    (RETURN
      (SEQ (LETT |lx| (SPADCALL |x| (QREFELT $ 45))
                 . #0=(|PBWLB;<;2$B;16|))
           (LETT |ly| (SPADCALL |y| (QREFELT $ 45)) . #0#)
           (EXIT (COND
                   ((EQL |lx| |ly|) (|PBWLB;recursif| |x| |y| $))
                   ('T (< |lx| |ly|)))))))) 

(DEFUN |PoincareBirkhoffWittLyndonBasis| (#0=#:G1860)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1861)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (LIST (|devaluate| #0#))
                       (HGET |$ConstructorCache|
                             '|PoincareBirkhoffWittLyndonBasis|)
                       '|domainEqualList|)
                   . #2=(|PoincareBirkhoffWittLyndonBasis|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (|PoincareBirkhoffWittLyndonBasis;| #0#)
                 (LETT #1# T . #2#))
               (COND
                 ((NOT #1#)
                  (HREM |$ConstructorCache|
                        '|PoincareBirkhoffWittLyndonBasis|))))))))))) 

(DEFUN |PoincareBirkhoffWittLyndonBasis;| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|)
              . #0=(|PoincareBirkhoffWittLyndonBasis|))
        (LETT |dv$|
              (LIST '|PoincareBirkhoffWittLyndonBasis| DV$1) . #0#)
        (LETT $ (GETREFV 51) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache|
            '|PoincareBirkhoffWittLyndonBasis| (LIST DV$1) (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 7 (|List| (|LyndonWord| |#1|)))
        $)))) 

(MAKEPROP '|PoincareBirkhoffWittLyndonBasis| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) '|Rep|
             (CONS IDENTITY
                   (FUNCALL (|dispatchFunction| |PBWLB;One;$;1|) $))
             (|Boolean|) (0 . =) |PBWLB;=;2$B;2| (|List| 6)
             (|LyndonWord| 6) (6 . |varList|) (11 . |setUnion|)
             |PBWLB;varList;$L;3| |PBWLB;first;$Lw;4| |PBWLB;rest;2$;5|
             (17 . |coerce|) |PBWLB;coerce;VarSet$;6|
             |PBWLB;coerce;Lw$;7| (|List| 13) |PBWLB;ListOfTerms;$L;8|
             (|OrderedFreeMonoid| 6) (22 . |One|) (26 . |coerce|)
             |PBWLB;coerce;$Ofm;9| (31 . *) (|Integer|) (|OutputForm|)
             (37 . |outputForm|) (42 . *) (48 . |coerce|)
             (|Mapping| 30 30 30) (|List| 30) (53 . |reduce|)
             |PBWLB;coerce;$Of;10| |PBWLB;retractable?;$B;11|
             |PBWLB;retract;$Lw;12| (|Union| 13 '"failed")
             |PBWLB;retractIfCan;$U;13| (|PositiveInteger|)
             (59 . |length|) (|NonNegativeInteger|)
             |PBWLB;length;$Nni;14| (64 . =) (70 . |lexico|)
             |PBWLB;<;2$B;16| (|SingleInteger|) (|String|))
          '#(~= 76 |varList| 82 |retractable?| 87 |retractIfCan| 92
             |retract| 97 |rest| 102 |min| 107 |max| 113 |length| 119
             |latex| 124 |hash| 129 |first| 134 |coerce| 139 |One| 159
             |ListOfTerms| 163 >= 168 > 174 = 180 <= 186 < 192)
          'NIL
          (CONS (|makeByteWordVec2| 1 '(0 0 0 0 0))
                (CONS '#(|OrderedSet&| |SetCategory&| |BasicType&|
                         |RetractableTo&| NIL)
                      (CONS '#((|OrderedSet|) (|SetCategory|)
                               (|BasicType|)
                               (|RetractableTo| (|LyndonWord| 6))
                               (|CoercibleTo| 30))
                            (|makeByteWordVec2| 50
                                '(2 7 9 0 0 10 1 13 12 0 14 2 12 0 0 0
                                  15 1 13 0 6 19 0 24 0 25 1 13 24 0 26
                                  2 24 0 0 0 28 1 30 0 29 31 2 30 0 0 0
                                  32 1 13 30 0 33 2 35 30 34 0 36 1 13
                                  42 0 43 2 13 9 0 0 46 2 13 9 0 0 47 2
                                  0 9 0 0 1 1 0 12 0 16 1 0 9 0 38 1 0
                                  40 0 41 1 0 13 0 39 1 0 0 0 18 2 0 0
                                  0 0 1 2 0 0 0 0 1 1 0 44 0 45 1 0 50
                                  0 1 1 0 49 0 1 1 0 13 0 17 1 0 24 0
                                  27 1 0 0 6 20 1 0 0 13 21 1 0 30 0 37
                                  0 0 0 8 1 0 22 0 23 2 0 9 0 0 1 2 0 9
                                  0 0 1 2 0 9 0 0 11 2 0 9 0 0 1 2 0 9
                                  0 0 48)))))
          '|lookupComplete|)) 
