
(/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 (|le| #1=#:G1808 #2=#:G1807 #3=#:G1809 #4=#:G1811 |l|)
    (RETURN
     (SEQ
      (COND ((NULL |x|) NIL)
            (#5='T
             (LETT |le|
                   (PROGN
                    (LETT #1# NIL . #6=(|PBWLB;varList;$L;3|))
                    (SEQ (LETT |l| NIL . #6#) (LETT #4# |x| . #6#) G190
                         (COND
                          ((OR (ATOM #4#)
                               (PROGN (LETT |l| (CAR #4#) . #6#) NIL))
                           (GO G191)))
                         (SEQ
                          (EXIT
                           (PROGN
                            (LETT #3# (SPADCALL |l| (QREFELT $ 14)) . #6#)
                            (COND
                             (#1#
                              (LETT #2# (SPADCALL #2# #3# (QREFELT $ 15))
                                    . #6#))
                             ('T
                              (PROGN
                               (LETT #2# #3# . #6#)
                               (LETT #1# 'T . #6#)))))))
                         (LETT #4# (CDR #4#) . #6#) (GO G190) G191 (EXIT NIL))
                    (COND (#1# #2#) (#5# (|IdentityError| '|setUnion|))))
                   . #6#))))))) 

(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 (#1=#:G1824 |l| #2=#:G1823)
    (RETURN
     (SEQ
      (COND ((NULL |x|) (SPADCALL 1 (QREFELT $ 31)))
            ('T
             (SPADCALL (ELT $ 32)
                       (PROGN
                        (LETT #2# NIL . #3=(|PBWLB;coerce;$Of;10|))
                        (SEQ (LETT |l| NIL . #3#) (LETT #1# |x| . #3#) G190
                             (COND
                              ((OR (ATOM #1#)
                                   (PROGN (LETT |l| (CAR #1#) . #3#) NIL))
                               (GO G191)))
                             (SEQ
                              (EXIT
                               (LETT #2#
                                     (CONS (SPADCALL |l| (QREFELT $ 33)) #2#)
                                     . #3#)))
                             (LETT #1# (CDR #1#) . #3#) (GO G190) G191
                             (EXIT (NREVERSE0 #2#))))
                       (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 (#1=#:G1840 |n| #2=#:G1838 #3=#:G1837 #4=#:G1839 #5=#:G1843 |l|)
    (RETURN
     (SEQ
      (LETT |n|
            (PROGN
             (LETT #2# NIL . #6=(|PBWLB;length;$Nni;14|))
             (SEQ (LETT |l| NIL . #6#) (LETT #5# |x| . #6#) G190
                  (COND
                   ((OR (ATOM #5#) (PROGN (LETT |l| (CAR #5#) . #6#) NIL))
                    (GO G191)))
                  (SEQ
                   (EXIT
                    (PROGN
                     (LETT #4# (SPADCALL |l| (QREFELT $ 43)) . #6#)
                     (COND (#2# (LETT #3# (+ #3# #4#) . #6#))
                           ('T
                            (PROGN
                             (LETT #3# #4# . #6#)
                             (LETT #2# 'T . #6#)))))))
                  (LETT #5# (CDR #5#) . #6#) (GO G190) G191 (EXIT NIL))
             (COND (#2# #3#) ('T 0)))
            . #6#)
      (EXIT
       (PROG1 (LETT #1# |n| . #6#)
         (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|) #1#))))))) 

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

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

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

(DEFUN |PoincareBirkhoffWittLyndonBasis;| (|#1|)
  (PROG (|pv$| $ |dv$| DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|PoincareBirkhoffWittLyndonBasis|))
      (LETT |dv$| (LIST '|PoincareBirkhoffWittLyndonBasis| DV$1) . #1#)
      (LETT $ (GETREFV 51) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|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 |smaller?| 87 |retractable?| 93 |retractIfCan|
              98 |retract| 103 |rest| 108 |min| 113 |max| 119 |listOfTerms| 125
              |length| 130 |latex| 135 |hash| 140 |first| 145 |coerce| 150
              |One| 170 >= 174 > 180 = 186 <= 192 < 198)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0 0 0 0))
                 (CONS
                  '#(|OrderedSet&| NIL |SetCategory&| |BasicType&|
                     |RetractableTo&| NIL)
                  (CONS
                   '#((|OrderedSet|) (|Comparable|) (|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 2 0 9 0 0 1 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 22 0 23
                                         1 0 44 0 45 1 0 50 0 1 1 0 49 0 1 1 0
                                         13 0 17 1 0 0 6 20 1 0 24 0 27 1 0 0
                                         13 21 1 0 30 0 37 0 0 0 8 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|)) 
