
(/VERSIONCHECK 2) 

(DEFUN |PERM;smaller?| (|a| |b| $)
  (COND
    ((|HasCategory| (QREFELT $ 6) '(|OrderedSet|))
     (SPADCALL |a| |b| (QREFELT $ 9)))
    ((|HasCategory| (QREFELT $ 6) '(|Finite|))
     (< (SPADCALL |a| (QREFELT $ 11)) (SPADCALL |b| (QREFELT $ 11))))
    ('T 'NIL))) 

(DEFUN |PERM;rotateCycle| (|cyc| $)
  (PROG (|i| #0=#:G1845 |min| |minpos| #1=#:G1841 #2=#:G1842)
    (RETURN
      (SEQ (LETT |min| (|SPADfirst| |cyc|) . #3=(|PERM;rotateCycle|))
           (LETT |minpos| 1 . #3#)
           (SEQ (LETT |i| 2 . #3#)
                (LETT #0# (SPADCALL |cyc| (QREFELT $ 14)) . #3#) G190
                (COND ((QSGREATERP |i| #0#) (GO G191)))
                (SEQ (EXIT (COND
                             ((|PERM;smaller?|
                                  (SPADCALL |cyc| |i| (QREFELT $ 15))
                                  |min| $)
                              (SEQ (LETT |min|
                                    (SPADCALL |cyc| |i| (QREFELT $ 15)) . #3#)
                                   (EXIT (LETT |minpos| |i| . #3#)))))))
                (LETT |i| (QSADD1 |i|) . #3#) (GO G190) G191
                (EXIT NIL))
           (EXIT (COND
                   ((EQL |minpos| 1) |cyc|)
                   ('T
                    (SPADCALL
                        (SPADCALL |cyc|
                            (PROG1 (LETT #1#
                                    (+ (- (LENGTH |cyc|) |minpos|) 1) . #3#)
                              (|check-subtype| (>= #1# 0)
                                  '(|NonNegativeInteger|) #1#))
                            (QREFELT $ 18))
                        (SPADCALL |cyc|
                            (PROG1 (LETT #2# (- |minpos| 1) . #3#)
                              (|check-subtype| (>= #2# 0)
                                  '(|NonNegativeInteger|) #2#))
                            (QREFELT $ 19))
                        (QREFELT $ 20))))))))) 

(DEFUN |PERM;coerceCycle| (|lls| $)
  (PROG (|lists| #0=#:G1849 |perm|)
    (RETURN
      (SEQ (LETT |perm| (|spadConstant| $ 16)
                 . #1=(|PERM;coerceCycle|))
           (SEQ (LETT |lists| NIL . #1#)
                (LETT #0# (REVERSE |lls|) . #1#) G190
                (COND
                  ((OR (ATOM #0#)
                       (PROGN (LETT |lists| (CAR #0#) . #1#) NIL))
                   (GO G191)))
                (SEQ (EXIT (LETT |perm|
                                 (SPADCALL
                                     (SPADCALL |lists| (QREFELT $ 21))
                                     |perm| (QREFELT $ 22)) . #1#)))
                (LETT #0# (CDR #0#) . #1#) (GO G190) G191 (EXIT NIL))
           (EXIT |perm|))))) 

(DEFUN |PERM;smallerCycle?| (|cyca| |cycb| $)
  (PROG (|j| #0=#:G1855 |i| #1=#:G1854 #2=#:G1853 #3=#:G1851)
    (RETURN
      (SEQ (EXIT (COND
                   ((NULL (EQL (LENGTH |cyca|) (LENGTH |cycb|)))
                    (< (LENGTH |cyca|) (LENGTH |cycb|)))
                   ('T
                    (SEQ (SEQ (EXIT (SEQ
                                     (LETT |j| NIL
                                      . #4=(|PERM;smallerCycle?|))
                                     (LETT #0# |cycb| . #4#)
                                     (LETT |i| NIL . #4#)
                                     (LETT #1# |cyca| . #4#) G190
                                     (COND
                                       ((OR (ATOM #1#)
                                         (PROGN
                                           (LETT |i| (CAR #1#) . #4#)
                                           NIL)
                                         (ATOM #0#)
                                         (PROGN
                                           (LETT |j| (CAR #0#) . #4#)
                                           NIL))
                                        (GO G191)))
                                     (SEQ
                                      (EXIT
                                       (COND
                                         ((NULL
                                           (SPADCALL |i| |j|
                                            (QREFELT $ 23)))
                                          (PROGN
                                            (LETT #3#
                                             (PROGN
                                               (LETT #2#
                                                (|PERM;smaller?| |i|
                                                 |j| $) . #4#)
                                               (GO #2#)) . #4#)
                                            (GO #3#))))))
                                     (LETT #1#
                                      (PROG1 (CDR #1#)
                                        (LETT #0# (CDR #0#) . #4#)) . #4#)
                                     (GO G190) G191 (EXIT NIL)))
                              #3# (EXIT #3#))
                         (EXIT 'NIL)))))
           #2# (EXIT #2#))))) 

(DEFUN |PERM;shorterCycle?| (|cyca| |cycb| $)
  (< (LENGTH |cyca|) (LENGTH |cycb|))) 

(DEFUN |PERM;permord| (|pa| |pb| $)
  (PROG (|j| #0=#:G1862 |i| #1=#:G1861 #2=#:G1860 #3=#:G1858)
    (RETURN
      (SEQ (EXIT (SEQ (SEQ (EXIT (SEQ (LETT |j| NIL
                                       . #4=(|PERM;permord|))
                                      (LETT #0# (QCAR |pb|) . #4#)
                                      (LETT |i| NIL . #4#)
                                      (LETT #1# (QCAR |pa|) . #4#) G190
                                      (COND
                                        ((OR (ATOM #1#)
                                          (PROGN
                                            (LETT |i| (CAR #1#) . #4#)
                                            NIL)
                                          (ATOM #0#)
                                          (PROGN
                                            (LETT |j| (CAR #0#) . #4#)
                                            NIL))
                                         (GO G191)))
                                      (SEQ
                                       (EXIT
                                        (COND
                                          ((NULL
                                            (SPADCALL |i| |j|
                                             (QREFELT $ 24)))
                                           (PROGN
                                             (LETT #3#
                                              (PROGN
                                                (LETT #2#
                                                 (|PERM;smallerCycle?|
                                                  |i| |j| $) . #4#)
                                                (GO #2#)) . #4#)
                                             (GO #3#))))))
                                      (LETT #1#
                                       (PROG1 (CDR #1#)
                                         (LETT #0# (CDR #0#) . #4#)) . #4#)
                                      (GO G190) G191 (EXIT NIL)))
                           #3# (EXIT #3#))
                      (EXIT (< (LENGTH (QCAR |pa|))
                               (LENGTH (QCAR |pb|))))))
           #2# (EXIT #2#))))) 

(DEFUN |PERM;coerceToCycle| (|p| |doSorting?| $)
  (PROG (|firstEltInCycle| |i| |preim| |nextEltInCycle| |im|
            |nextCycle| |cycles|)
    (RETURN
      (SEQ (LETT |preim| (SPADCALL |p| 1 (QREFELT $ 25))
                 . #0=(|PERM;coerceToCycle|))
           (LETT |im| (SPADCALL |p| 2 (QREFELT $ 25)) . #0#)
           (LETT |cycles| NIL . #0#)
           (SEQ G190
                (COND
                  ((NULL (COND ((NULL |preim|) 'NIL) ('T 'T)))
                   #1=(GO G191)))
                (SEQ (LETT |firstEltInCycle|
                           (|SPADfirst| |preim|) . #0#)
                     (LETT |nextCycle|
                           (SPADCALL |firstEltInCycle| (QREFELT $ 26)) . #0#)
                     (LETT |preim| (CDR |preim|) . #0#)
                     (LETT |nextEltInCycle| (|SPADfirst| |im|) . #0#)
                     (LETT |im| (CDR |im|) . #0#)
                     (SEQ G190
                          (COND
                            ((NULL (COND
                                     ((SPADCALL |nextEltInCycle|
                                       |firstEltInCycle|
                                       (QREFELT $ 23))
                                      'NIL)
                                     ('T 'T)))
                             #1#))
                          (SEQ (LETT |nextCycle|
                                     (CONS |nextEltInCycle|
                                      |nextCycle|) . #0#)
                               (LETT |i|
                                     (SPADCALL |nextEltInCycle| |preim|
                                      (QREFELT $ 27)) . #0#)
                               (LETT |preim|
                                     (SPADCALL |preim| |i|
                                      (QREFELT $ 28)) . #0#)
                               (LETT |nextEltInCycle|
                                     (SPADCALL |im| |i| (QREFELT $ 15)) . #0#)
                               (EXIT (LETT |im|
                                      (SPADCALL |im| |i|
                                       (QREFELT $ 28)) . #0#)))
                          NIL #2=(GO G190) G191 (EXIT NIL))
                     (LETT |nextCycle| (REVERSE |nextCycle|) . #0#)
                     (EXIT (COND
                             ((NULL (NULL (CDR |nextCycle|)))
                              (SEQ (COND
                                     (|doSorting?|
                                      (COND
                                        ((OR
                                          (|HasCategory| (QREFELT $ 6)
                                           '(|OrderedSet|))
                                          (|HasCategory| (QREFELT $ 6)
                                           '(|Finite|)))
                                         (LETT |nextCycle|
                                          (|PERM;rotateCycle|
                                           |nextCycle| $) . #0#)))))
                                   (EXIT
                                    (LETT |cycles|
                                     (CONS |nextCycle| |cycles|) . #0#)))))))
                NIL #2# G191 (EXIT NIL))
           (EXIT (COND
                   (|doSorting?|
                       (COND
                         ((OR (|HasCategory| (QREFELT $ 6)
                                  '(|OrderedSet|))
                              (|HasCategory| (QREFELT $ 6) '(|Finite|)))
                          (SPADCALL
                              (CONS (|function| |PERM;smallerCycle?|)
                                    $)
                              |cycles| (QREFELT $ 31)))
                         ('T
                          (SPADCALL
                              (CONS (|function| |PERM;shorterCycle?|)
                                    $)
                              |cycles| (QREFELT $ 31)))))
                   ('T |cycles|))))))) 

(DEFUN |PERM;duplicates?| (|ls| $)
  (PROG (#0=#:G1875 |x|)
    (RETURN
      (SEQ (EXIT (SEQ (LETT |x| (SPADCALL |ls| (QREFELT $ 32))
                            . #1=(|PERM;duplicates?|))
                      (SEQ G190
                           (COND
                             ((NULL (COND ((NULL |x|) 'NIL) ('T 'T)))
                              (GO G191)))
                           (SEQ (EXIT (COND
                                        ((SPADCALL (|SPADfirst| |x|)
                                          (CDR |x|) (QREFELT $ 33))
                                         (PROGN
                                           (LETT #0# 'T . #1#)
                                           (GO #0#)))
                                        ('T (LETT |x| (CDR |x|) . #1#)))))
                           NIL (GO G190) G191 (EXIT NIL))
                      (EXIT 'NIL)))
           #0# (EXIT #0#))))) 

(DEFUN |PERM;listRepresentation;$R;9| (|p| $)
  (PROG (|s|)
    (RETURN
      (LETT |s|
            (CONS (SPADCALL |p| 1 (QREFELT $ 25))
                  (SPADCALL |p| 2 (QREFELT $ 25)))
            |PERM;listRepresentation;$R;9|)))) 

(DEFUN |PERM;coercePreimagesImages;L$;10| (|preImageAndImage| $)
  (PROG (|pi| #0=#:G1885 |i| #1=#:G1884 |preImage| |image|)
    (RETURN
      (SEQ (LETT |preImage| NIL
                 . #2=(|PERM;coercePreimagesImages;L$;10|))
           (LETT |image| NIL . #2#)
           (SEQ (LETT |pi| NIL . #2#)
                (LETT #0#
                      (SPADCALL |preImageAndImage| 2 (QREFELT $ 36)) . #2#)
                (LETT |i| NIL . #2#)
                (LETT #1#
                      (SPADCALL |preImageAndImage| 1 (QREFELT $ 36)) . #2#)
                G190
                (COND
                  ((OR (ATOM #1#)
                       (PROGN (LETT |i| (CAR #1#) . #2#) NIL)
                       (ATOM #0#)
                       (PROGN (LETT |pi| (CAR #0#) . #2#) NIL))
                   (GO G191)))
                (SEQ (EXIT (COND
                             ((SPADCALL |i| |pi| (QREFELT $ 37))
                              (SEQ (LETT |preImage|
                                    (CONS |i| |preImage|) . #2#)
                                   (EXIT
                                    (LETT |image|
                                     (CONS |pi| |image|) . #2#)))))))
                (LETT #1#
                      (PROG1 (CDR #1#) (LETT #0# (CDR #0#) . #2#)) . #2#)
                (GO G190) G191 (EXIT NIL))
           (EXIT (VECTOR |preImage| |image|)))))) 

(DEFUN |PERM;movedPoints;$S;11| (|p| $)
  (SPADCALL (SPADCALL |p| 1 (QREFELT $ 25)) (QREFELT $ 40))) 

(DEFUN |PERM;degree;$Nni;12| (|p| $)
  (SPADCALL (SPADCALL |p| (QREFELT $ 41)) (QREFELT $ 42))) 

(DEFUN |PERM;=;2$B;13| (|p| |q| $)
  (PROG (|preimp| |preimq| |i| #0=#:G1894 |pos| #1=#:G1893 #2=#:G1889)
    (RETURN
      (SEQ (EXIT (COND
                   ((NULL (EQL (LENGTH (LETT |preimp|
                                        (SPADCALL |p| 1 (QREFELT $ 25))
                                        . #3=(|PERM;=;2$B;13|)))
                               (LENGTH (LETT |preimq|
                                        (SPADCALL |q| 1 (QREFELT $ 25)) . #3#))))
                    'NIL)
                   ('T
                    (SEQ (SEQ (LETT |i| 1 . #3#)
                              (LETT #0#
                                    (SPADCALL |preimp| (QREFELT $ 14)) . #3#)
                              G190
                              (COND ((QSGREATERP |i| #0#) (GO G191)))
                              (SEQ (LETT |pos|
                                    (SPADCALL
                                     (SPADCALL |preimp| |i|
                                      (QREFELT $ 15))
                                     |preimq| (QREFELT $ 27)) . #3#)
                                   (EXIT
                                    (COND
                                      ((EQL |pos| 0)
                                       (PROGN
                                         (LETT #1# 'NIL . #3#)
                                         (GO #1#)))
                                      ('T
                                       (SEQ
                                        (EXIT
                                         (COND
                                           ((NULL
                                             (SPADCALL
                                              (SPADCALL
                                               (SPADCALL |p| 2
                                                (QREFELT $ 25))
                                               |i| (QREFELT $ 15))
                                              (SPADCALL
                                               (SPADCALL |q| 2
                                                (QREFELT $ 25))
                                               |pos| (QREFELT $ 15))
                                              (QREFELT $ 23)))
                                            (PROGN
                                              (LETT #2#
                                               (PROGN
                                                 (LETT #1# 'NIL . #3#)
                                                 (GO #1#)) . #3#)
                                              (GO #2#)))))
                                        #2# (EXIT #2#))))))
                              (LETT |i| (QSADD1 |i|) . #3#) (GO G190)
                              G191 (EXIT NIL))
                         (EXIT 'T)))))
           #1# (EXIT #1#))))) 

(DEFUN |PERM;orbit;$SS;14| (|p| |el| $)
  (PROG (|out| |el2|)
    (RETURN
      (SEQ (LETT |out|
                 (SPADCALL (SPADCALL |el| (QREFELT $ 26))
                     (QREFELT $ 45))
                 . #0=(|PERM;orbit;$SS;14|))
           (LETT |el2| (SPADCALL |p| |el| (QREFELT $ 46)) . #0#)
           (SEQ G190
                (COND
                  ((NULL (COND
                           ((SPADCALL |el2| |el| (QREFELT $ 23)) 'NIL)
                           ('T 'T)))
                   (GO G191)))
                (SEQ (SPADCALL |el2| |out| (QREFELT $ 47))
                     (EXIT (LETT |el2|
                                 (SPADCALL |p| |el2| (QREFELT $ 46)) . #0#)))
                NIL (GO G190) G191 (EXIT NIL))
           (EXIT |out|))))) 

(DEFUN |PERM;cyclePartition;$P;15| (|p| $)
  (PROG (#0=#:G1901 |c| #1=#:G1902)
    (RETURN
      (SEQ (SPADCALL
               (PROGN
                 (LETT #0# NIL . #2=(|PERM;cyclePartition;$P;15|))
                 (SEQ (LETT |c| NIL . #2#)
                      (LETT #1#
                            (|PERM;coerceToCycle| |p| 'NIL $) . #2#)
                      G190
                      (COND
                        ((OR (ATOM #1#)
                             (PROGN (LETT |c| (CAR #1#) . #2#) NIL))
                         (GO G191)))
                      (SEQ (EXIT (LETT #0#
                                       (CONS (LENGTH |c|) #0#) . #2#)))
                      (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                      (EXIT (NREVERSE0 #0#))))
               (QREFELT $ 51)))))) 

(DEFUN |PERM;order;$Nni;16| (|p| $)
  (PROG (|ord| #0=#:G1903)
    (RETURN
      (SEQ (LETT |ord|
                 (SPADCALL
                     (SPADCALL
                         (SPADCALL (SPADCALL |p| (QREFELT $ 52))
                             (QREFELT $ 53))
                         (QREFELT $ 54))
                     (QREFELT $ 56))
                 . #1=(|PERM;order;$Nni;16|))
           (EXIT (PROG1 (LETT #0# |ord| . #1#)
                   (|check-subtype| (>= #0# 0) '(|NonNegativeInteger|)
                       #0#))))))) 

(DEFUN |PERM;sign;$I;17| (|p| $)
  (COND ((SPADCALL |p| (QREFELT $ 58)) 1) ('T -1))) 

(DEFUN |PERM;even?;$B;18| (|p| $)
  (SPADCALL
      (- (LENGTH (SPADCALL |p| 1 (QREFELT $ 25)))
         (SPADCALL |p| (QREFELT $ 60)))
      (QREFELT $ 61))) 

(DEFUN |PERM;odd?;$B;19| (|p| $)
  (ODDP (- (LENGTH (SPADCALL |p| 1 (QREFELT $ 25)))
           (SPADCALL |p| (QREFELT $ 60))))) 

(DEFUN |PERM;<;2$B;20| (|pa| |pb| $)
  (PROG (|pacyc| |pbcyc| |j| #0=#:G1914 |i| #1=#:G1913 #2=#:G1912
                 #3=#:G1910)
    (RETURN
      (SEQ (EXIT (SEQ (LETT |pacyc| (|PERM;coerceToCycle| |pa| 'T $)
                            . #4=(|PERM;<;2$B;20|))
                      (LETT |pbcyc|
                            (|PERM;coerceToCycle| |pb| 'T $) . #4#)
                      (SEQ (EXIT (SEQ (LETT |j| NIL . #4#)
                                      (LETT #0# |pbcyc| . #4#)
                                      (LETT |i| NIL . #4#)
                                      (LETT #1# |pacyc| . #4#) G190
                                      (COND
                                        ((OR (ATOM #1#)
                                          (PROGN
                                            (LETT |i| (CAR #1#) . #4#)
                                            NIL)
                                          (ATOM #0#)
                                          (PROGN
                                            (LETT |j| (CAR #0#) . #4#)
                                            NIL))
                                         (GO G191)))
                                      (SEQ
                                       (EXIT
                                        (COND
                                          ((NULL
                                            (SPADCALL |i| |j|
                                             (QREFELT $ 24)))
                                           (PROGN
                                             (LETT #3#
                                              (PROGN
                                                (LETT #2#
                                                 (|PERM;smallerCycle?|
                                                  |i| |j| $) . #4#)
                                                (GO #2#)) . #4#)
                                             (GO #3#))))))
                                      (LETT #1#
                                       (PROG1 (CDR #1#)
                                         (LETT #0# (CDR #0#) . #4#)) . #4#)
                                      (GO G190) G191 (EXIT NIL)))
                           #3# (EXIT #3#))
                      (EXIT (< (SPADCALL |pacyc| (QREFELT $ 63))
                               (SPADCALL |pbcyc| (QREFELT $ 63))))))
           #2# (EXIT #2#))))) 

(DEFUN |PERM;coerce;L$;21| (|lls| $) (|PERM;coerceCycle| |lls| $)) 

(DEFUN |PERM;coerce;L$;22| (|ls| $) (SPADCALL |ls| (QREFELT $ 21))) 

(DEFUN |PERM;sort;2L;23| (|inList| $)
  (PROG (|sigma| #0=#:G1925 |ownList| |rec| #1=#:G1926 |outList|)
    (RETURN
      (SEQ (COND
             ((NULL (|HasCategory| (QREFELT $ 6) '(|OrderedSet|)))
              (COND
                ((NULL (|HasCategory| (QREFELT $ 6) '(|Finite|)))
                 (EXIT |inList|)))))
           (LETT |ownList| NIL . #2=(|PERM;sort;2L;23|))
           (SEQ (LETT |sigma| NIL . #2#) (LETT #0# |inList| . #2#) G190
                (COND
                  ((OR (ATOM #0#)
                       (PROGN (LETT |sigma| (CAR #0#) . #2#) NIL))
                   #3=(GO G191)))
                (SEQ (EXIT (LETT |ownList|
                                 (SPADCALL
                                     (CONS
                                      (|PERM;coerceToCycle| |sigma| 'T
                                       $)
                                      |sigma|)
                                     |ownList| (QREFELT $ 69)) . #2#)))
                (LETT #0# (CDR #0#) . #2#) #4=(GO G190) G191
                (EXIT NIL))
           (LETT |ownList|
                 (SPADCALL (CONS (|function| |PERM;permord|) $)
                     |ownList| (QREFELT $ 71)) . #2#)
           (LETT |outList| (SPADCALL (QREFELT $ 73)) . #2#)
           (SEQ (LETT |rec| NIL . #2#) (LETT #1# |ownList| . #2#) G190
                (COND
                  ((OR (ATOM #1#)
                       (PROGN (LETT |rec| (CAR #1#) . #2#) NIL))
                   #3#))
                (SEQ (EXIT (LETT |outList|
                                 (SPADCALL (QCDR |rec|) |outList|
                                     (QREFELT $ 74)) . #2#)))
                (LETT #1# (CDR #1#) . #2#) #4# G191 (EXIT NIL))
           (EXIT (SPADCALL |outList| (QREFELT $ 75))))))) 

(DEFUN |PERM;coerce;$Of;24| (|p| $)
  (PROG (|cycles| |cycle| #0=#:G1933 |elt| #1=#:G1934 |outcycL|
            |outfmL|)
    (RETURN
      (SEQ (LETT |cycles| (|PERM;coerceToCycle| |p| 'T $)
                 . #2=(|PERM;coerce;$Of;24|))
           (LETT |outfmL| NIL . #2#)
           (SEQ (LETT |cycle| NIL . #2#) (LETT #0# |cycles| . #2#) G190
                (COND
                  ((OR (ATOM #0#)
                       (PROGN (LETT |cycle| (CAR #0#) . #2#) NIL))
                   #3=(GO G191)))
                (SEQ (LETT |outcycL| NIL . #2#)
                     (SEQ (LETT |elt| NIL . #2#)
                          (LETT #1# |cycle| . #2#) G190
                          (COND
                            ((OR (ATOM #1#)
                                 (PROGN
                                   (LETT |elt| (CAR #1#) . #2#)
                                   NIL))
                             #3#))
                          (SEQ (EXIT (LETT |outcycL|
                                      (CONS
                                       (SPADCALL |elt| (QREFELT $ 78))
                                       |outcycL|) . #2#)))
                          (LETT #1# (CDR #1#) . #2#) #4=(GO G190) G191
                          (EXIT NIL))
                     (EXIT (LETT |outfmL|
                                 (CONS (SPADCALL
                                        (SPADCALL (REVERSE |outcycL|)
                                         (QREFELT $ 79))
                                        (QREFELT $ 80))
                                       |outfmL|) . #2#)))
                (LETT #0# (CDR #0#) . #2#) #4# G191 (EXIT NIL))
           (EXIT (COND
                   ((NULL |outfmL|) (SPADCALL 1 (QREFELT $ 81)))
                   ((NULL (CDR |outfmL|)) (|SPADfirst| |outfmL|))
                   ('T (SPADCALL (REVERSE |outfmL|) (QREFELT $ 82))))))))) 

(DEFUN |PERM;cycles;L$;25| (|vs| $) (|PERM;coerceCycle| |vs| $)) 

(DEFUN |PERM;cycle;L$;26| (|ls| $)
  (COND
    ((< (LENGTH |ls|) 2) (|spadConstant| $ 16))
    ((|PERM;duplicates?| |ls| $)
     (|error| "cycle: the input contains duplicates"))
    ('T
     (VECTOR |ls|
             (APPEND (CDR |ls|)
                     (SPADCALL (|SPADfirst| |ls|) (QREFELT $ 26))))))) 

(DEFUN |PERM;coerceListOfPairs;L$;27| (|loP| $)
  (PROG (|pair| #0=#:G1947 |preim| |im|)
    (RETURN
      (SEQ (LETT |preim| NIL . #1=(|PERM;coerceListOfPairs;L$;27|))
           (LETT |im| NIL . #1#)
           (SEQ (LETT |pair| NIL . #1#) (LETT #0# |loP| . #1#) G190
                (COND
                  ((OR (ATOM #0#)
                       (PROGN (LETT |pair| (CAR #0#) . #1#) NIL))
                   (GO G191)))
                (SEQ (EXIT (COND
                             ((NULL (SPADCALL (|SPADfirst| |pair|)
                                     (SPADCALL |pair| (QREFELT $ 85))
                                     (QREFELT $ 23)))
                              (SEQ (LETT |preim|
                                    (CONS (|SPADfirst| |pair|) |preim|) . #1#)
                                   (EXIT
                                    (LETT |im|
                                     (CONS
                                      (SPADCALL |pair| (QREFELT $ 85))
                                      |im|) . #1#)))))))
                (LETT #0# (CDR #0#) . #1#) (GO G190) G191 (EXIT NIL))
           (COND
             ((OR (|PERM;duplicates?| |preim| $)
                  (OR (|PERM;duplicates?| |im| $)
                      (NULL (SPADCALL (SPADCALL |preim| (QREFELT $ 45))
                                (SPADCALL |im| (QREFELT $ 45))
                                (QREFELT $ 86)))))
              (EXIT (|error| "coerceListOfPairs: the input cannot be interpreted as a permutation"))))
           (EXIT (VECTOR |preim| |im|)))))) 

(DEFUN |PERM;*;3$;28| (|q| |p| $)
  (PROG (|preimOfp| |imOfp| |i| #0=#:G1956 |j| |el| |preimOfqp|
            |imOfqp| |preimOfq| |imOfq|)
    (RETURN
      (SEQ (LETT |preimOfp|
                 (SPADCALL (SPADCALL |p| 1 (QREFELT $ 25))
                     (QREFELT $ 89))
                 . #1=(|PERM;*;3$;28|))
           (LETT |imOfp|
                 (SPADCALL (SPADCALL |p| 2 (QREFELT $ 25))
                     (QREFELT $ 89)) . #1#)
           (LETT |preimOfq| (SPADCALL |q| 1 (QREFELT $ 25)) . #1#)
           (LETT |imOfq| (SPADCALL |q| 2 (QREFELT $ 25)) . #1#)
           (LETT |preimOfqp| NIL . #1#) (LETT |imOfqp| NIL . #1#)
           (SEQ (LETT |i| 1 . #1#) (LETT #0# (QVSIZE |preimOfp|) . #1#)
                G190 (COND ((QSGREATERP |i| #0#) (GO G191)))
                (SEQ (LETT |j|
                           (SPADCALL
                               (SPADCALL |imOfp| |i| (QREFELT $ 90))
                               |preimOfq| (QREFELT $ 27)) . #1#)
                     (EXIT (COND
                             ((EQL |j| 0)
                              (SEQ (LETT |preimOfqp|
                                    (CONS
                                     (SPADCALL |preimOfp| |i|
                                      (QREFELT $ 90))
                                     |preimOfqp|) . #1#)
                                   (EXIT
                                    (LETT |imOfqp|
                                     (CONS
                                      (SPADCALL |imOfp| |i|
                                       (QREFELT $ 90))
                                      |imOfqp|) . #1#))))
                             ('T
                              (SEQ (LETT |el|
                                    (SPADCALL |imOfq| |j|
                                     (QREFELT $ 15)) . #1#)
                                   (COND
                                     ((NULL
                                       (SPADCALL |el|
                                        (SPADCALL |preimOfp| |i|
                                         (QREFELT $ 90))
                                        (QREFELT $ 23)))
                                      (SEQ
                                       (LETT |preimOfqp|
                                        (CONS
                                         (SPADCALL |preimOfp| |i|
                                          (QREFELT $ 90))
                                         |preimOfqp|) . #1#)
                                       (EXIT
                                        (LETT |imOfqp|
                                         (CONS |el| |imOfqp|) . #1#)))))
                                   (LETT |preimOfq|
                                    (SPADCALL |preimOfq| |j|
                                     (QREFELT $ 28)) . #1#)
                                   (EXIT
                                    (LETT |imOfq|
                                     (SPADCALL |imOfq| |j|
                                      (QREFELT $ 28)) . #1#)))))))
                (LETT |i| (QSADD1 |i|) . #1#) (GO G190) G191
                (EXIT NIL))
           (EXIT (VECTOR (APPEND |preimOfqp| |preimOfq|)
                         (APPEND |imOfqp| |imOfq|))))))) 

(DEFUN |PERM;One;$;29| ($) (SPADCALL 2 NIL (QREFELT $ 91))) 

(DEFUN |PERM;inv;2$;30| (|p| $)
  (VECTOR (SPADCALL |p| 2 (QREFELT $ 25))
          (SPADCALL |p| 1 (QREFELT $ 25)))) 

(DEFUN |PERM;eval;$2S;31| (|p| |el| $)
  (PROG (|pos|)
    (RETURN
      (SEQ (LETT |pos|
                 (SPADCALL |el| (SPADCALL |p| 1 (QREFELT $ 25))
                     (QREFELT $ 27))
                 |PERM;eval;$2S;31|)
           (EXIT (COND
                   ((EQL |pos| 0) |el|)
                   ('T
                    (SPADCALL (SPADCALL |p| 2 (QREFELT $ 25)) |pos|
                        (QREFELT $ 15))))))))) 

(DEFUN |PERM;elt;$2S;32| (|p| |el| $)
  (SPADCALL |p| |el| (QREFELT $ 46))) 

(DEFUN |PERM;numberOfCycles;$Nni;33| (|p| $)
  (LENGTH (|PERM;coerceToCycle| |p| 'NIL $))) 

(DEFUN |PERM;coerceImages;L$;34| (|image| $)
  (PROG (#0=#:G1966 |i| #1=#:G1967 |preImage|)
    (RETURN
      (SEQ (LETT |preImage|
                 (PROGN
                   (LETT #0# NIL . #2=(|PERM;coerceImages;L$;34|))
                   (SEQ (LETT |i| 1 . #2#)
                        (LETT #1#
                              (SPADCALL |image| (QREFELT $ 14)) . #2#)
                        G190 (COND ((QSGREATERP |i| #1#) (GO G191)))
                        (SEQ (EXIT (LETT #0#
                                    (CONS (SPADCALL |i| (QREFELT $ 94))
                                     #0#) . #2#)))
                        (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191
                        (EXIT (NREVERSE0 #0#)))) . #2#)
           (EXIT (SPADCALL (LIST |preImage| |image|) (QREFELT $ 38))))))) 

(DEFUN |PERM;coerceImages;L$;35| (|image| $)
  (PROG (#0=#:G1972 |i| #1=#:G1973 #2=#:G1968 |preImage|)
    (RETURN
      (SEQ (LETT |preImage|
                 (PROGN
                   (LETT #0# NIL . #3=(|PERM;coerceImages;L$;35|))
                   (SEQ (LETT |i| 1 . #3#)
                        (LETT #1#
                              (SPADCALL |image| (QREFELT $ 14)) . #3#)
                        G190 (COND ((QSGREATERP |i| #1#) (GO G191)))
                        (SEQ (EXIT (LETT #0#
                                    (CONS
                                     (SPADCALL
                                      (PROG1 (LETT #2# |i| . #3#)
                                        (|check-subtype| (> #2# 0)
                                         '(|PositiveInteger|) #2#))
                                      (QREFELT $ 96))
                                     #0#) . #3#)))
                        (LETT |i| (QSADD1 |i|) . #3#) (GO G190) G191
                        (EXIT (NREVERSE0 #0#)))) . #3#)
           (EXIT (SPADCALL (LIST |preImage| |image|) (QREFELT $ 38))))))) 

(DEFUN |PERM;fixedPoints;$S;36| (|p| $)
  (SPADCALL (SPADCALL |p| (QREFELT $ 41)) (QREFELT $ 97))) 

(DEFUN |PERM;cyclePartition;$P;37| (|p| $)
  (PROG (#0=#:G1978 |c| #1=#:G1979 |pt|)
    (RETURN
      (SEQ (LETT |pt|
                 (SPADCALL
                     (PROGN
                       (LETT #0# NIL
                             . #2=(|PERM;cyclePartition;$P;37|))
                       (SEQ (LETT |c| NIL . #2#)
                            (LETT #1#
                                  (|PERM;coerceToCycle| |p| 'NIL $) . #2#)
                            G190
                            (COND
                              ((OR (ATOM #1#)
                                   (PROGN
                                     (LETT |c| (CAR #1#) . #2#)
                                     NIL))
                               (GO G191)))
                            (SEQ (EXIT (LETT #0#
                                        (CONS (LENGTH |c|) #0#) . #2#)))
                            (LETT #1# (CDR #1#) . #2#) (GO G190) G191
                            (EXIT (NREVERSE0 #0#))))
                     (QREFELT $ 51)) . #2#)
           (EXIT (SPADCALL |pt|
                     (SPADCALL
                         (SPADCALL
                             (LIST (SPADCALL
                                    (SPADCALL |p| (QREFELT $ 98))
                                    (QREFELT $ 42)))
                             (QREFELT $ 51))
                         (QREFELT $ 99))
                     (QREFELT $ 100))))))) 

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

(DEFUN |Permutation;| (|#1|)
  (PROG (DV$1 |dv$| $ #0=#:G1983 |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #1=(|Permutation|))
        (LETT |dv$| (LIST '|Permutation| DV$1) . #1#)
        (LETT $ (GETREFV 104) . #1#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3
            (LETT |pv$|
                  (|buildPredVector| 0 0
                      (LIST (|HasCategory| |#1| '(|OrderedSet|))
                            (LETT #0#
                                  (|HasCategory| |#1| '(|Finite|)) . #1#)
                            (OR #0#
                                (|HasCategory| |#1| '(|OrderedSet|))))) . #1#))
        (|haddProp| |$ConstructorCache| '|Permutation| (LIST DV$1)
            (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 7 (|Vector| (|List| |#1|)))
        (COND
          ((|HasCategory| |#1| '(|IntegerNumberSystem|))
           (QSETREFV $ 95
               (CONS (|dispatchFunction| |PERM;coerceImages;L$;34|) $))))
        (COND
          ((|testBitVector| |pv$| 2)
           (PROGN
             (QSETREFV $ 95
                 (CONS (|dispatchFunction| |PERM;coerceImages;L$;35|)
                       $))
             (QSETREFV $ 98
                 (CONS (|dispatchFunction| |PERM;fixedPoints;$S;36|) $))
             (QSETREFV $ 52
                 (CONS (|dispatchFunction| |PERM;cyclePartition;$P;37|)
                       $)))))
        $)))) 

(MAKEPROP '|Permutation| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) '|Rep| (|Boolean|)
             (0 . <) (|PositiveInteger|) (6 . |lookup|) (|Integer|)
             (|List| 6) (11 . |maxIndex|) (16 . |elt|)
             (CONS IDENTITY
                   (FUNCALL (|dispatchFunction| |PERM;One;$;29|) $))
             (|NonNegativeInteger|) (22 . |last|) (28 . |first|)
             (34 . |concat|) |PERM;cycle;L$;26| |PERM;*;3$;28| (40 . =)
             (46 . =) (52 . |elt|) (58 . |list|) (63 . |position|)
             (69 . |delete|) (|Mapping| 8 13 13) (|List| 13)
             (75 . |sort|) (81 . |copy|) (86 . |member?|)
             (|Record| (|:| |preimage| 13) (|:| |image| 13))
             |PERM;listRepresentation;$R;9| (92 . |elt|) (98 . ~=)
             |PERM;coercePreimagesImages;L$;10| (|Set| 6)
             (104 . |construct|) |PERM;movedPoints;$S;11| (109 . |#|)
             |PERM;degree;$Nni;12| |PERM;=;2$B;13| (114 . |brace|)
             |PERM;eval;$2S;31| (119 . |insert!|) |PERM;orbit;$SS;14|
             (|List| 12) (|Partition|) (125 . |partition|)
             |PERM;cyclePartition;$P;15| (130 . |convert|)
             (135 . |removeDuplicates|) (|List| $) (140 . |lcm|)
             |PERM;order;$Nni;16| |PERM;even?;$B;18| |PERM;sign;$I;17|
             |PERM;numberOfCycles;$Nni;33| (145 . |even?|)
             |PERM;odd?;$B;19| (150 . |maxIndex|) |PERM;<;2$B;20|
             |PERM;coerce;L$;21| |PERM;coerce;L$;22|
             (|Record| (|:| |cycl| 30) (|:| |permut| $$)) (|List| 67)
             (155 . |cons|) (|Mapping| 8 67 67) (161 . |sort|)
             (|List| $$) (167 . |nil|) (171 . |cons|) (177 . |reverse|)
             |PERM;sort;2L;23| (|OutputForm|) (182 . |coerce|)
             (187 . |blankSeparate|) (192 . |paren|)
             (197 . |outputForm|) (202 . |hconcat|)
             |PERM;coerce;$Of;24| |PERM;cycles;L$;25| (207 . |second|)
             (212 . =) |PERM;coerceListOfPairs;L$;27| (|Vector| 6)
             (218 . |construct|) (223 . |elt|) (229 . |new|)
             |PERM;inv;2$;30| |PERM;elt;$2S;32| (235 . |coerce|)
             (240 . |coerceImages|) (245 . |index|)
             (250 . |complement|) (255 . |fixedPoints|)
             (260 . |conjugate|) (265 . +) (|Union| $ '"failed")
             (|SingleInteger|) (|String|))
          '#(~= 271 |sort| 277 |sign| 282 |sample| 287 |recip| 291
             |order| 296 |orbit| 301 |one?| 307 |odd?| 312
             |numberOfCycles| 317 |movedPoints| 322 |min| 327 |max| 333
             |listRepresentation| 339 |latex| 344 |inv| 349 |hash| 354
             |fixedPoints| 359 |even?| 364 |eval| 369 |elt| 375
             |degree| 381 |cycles| 386 |cyclePartition| 391 |cycle| 396
             |conjugate| 401 |commutator| 407 |coercePreimagesImages|
             413 |coerceListOfPairs| 418 |coerceImages| 423 |coerce|
             428 ^ 443 |One| 461 >= 465 > 471 = 477 <= 483 < 489 / 495
             ** 501 * 519)
          'NIL
          (CONS (|makeByteWordVec2| 3 '(0 0 0 0 3 0 0 0 0))
                (CONS '#(NIL |Group&| |Monoid&| |SemiGroup&|
                         |OrderedSet&| |SetCategory&| |BasicType&| NIL
                         NIL)
                      (CONS '#((|PermutationCategory| 6) (|Group|)
                               (|Monoid|) (|SemiGroup|) (|OrderedSet|)
                               (|SetCategory|) (|BasicType|)
                               (|unitsKnown|) (|CoercibleTo| 77))
                            (|makeByteWordVec2| 103
                                '(2 6 8 0 0 9 1 6 10 0 11 1 13 12 0 14
                                  2 13 6 0 12 15 2 13 0 0 17 18 2 13 0
                                  0 17 19 2 13 0 0 0 20 2 6 8 0 0 23 2
                                  13 8 0 0 24 2 7 13 0 12 25 1 13 0 6
                                  26 2 13 12 6 0 27 2 13 0 0 12 28 2 30
                                  0 29 0 31 1 13 0 0 32 2 13 8 6 0 33 2
                                  30 13 0 12 36 2 6 8 0 0 37 1 39 0 13
                                  40 1 39 17 0 42 1 39 0 13 45 2 39 0 6
                                  0 47 1 50 0 49 51 1 50 49 0 53 1 49 0
                                  0 54 1 12 0 55 56 1 12 8 0 61 1 30 12
                                  0 63 2 68 0 67 0 69 2 68 0 70 0 71 0
                                  72 0 73 2 72 0 2 0 74 1 72 0 0 75 1 6
                                  77 0 78 1 77 0 55 79 1 77 0 0 80 1 77
                                  0 12 81 1 77 0 55 82 1 13 6 0 85 2 39
                                  8 0 0 86 1 88 0 13 89 2 88 6 0 12 90
                                  2 7 0 17 13 91 1 6 0 12 94 1 0 0 13
                                  95 1 6 0 10 96 1 39 0 0 97 1 0 39 0
                                  98 1 50 0 0 99 2 50 0 0 0 100 2 0 8 0
                                  0 1 1 0 55 55 76 1 0 12 0 59 0 0 0 1
                                  1 0 101 0 1 1 0 17 0 57 2 0 39 0 6 48
                                  1 0 8 0 1 1 0 8 0 62 1 0 17 0 60 1 0
                                  39 0 41 2 3 0 0 0 1 2 3 0 0 0 1 1 0
                                  34 0 35 1 0 103 0 1 1 0 0 0 92 1 0
                                  102 0 1 1 2 39 0 98 1 0 8 0 58 2 0 6
                                  0 6 46 2 0 6 0 6 93 1 0 17 0 43 1 0 0
                                  30 84 1 0 50 0 52 1 0 0 13 21 2 0 0 0
                                  0 1 2 0 0 0 0 1 1 0 0 30 38 1 0 0 30
                                  87 1 0 0 13 95 1 0 0 13 66 1 0 0 30
                                  65 1 0 77 0 83 2 0 0 0 12 1 2 0 0 0
                                  17 1 2 0 0 0 10 1 0 0 0 16 2 3 8 0 0
                                  1 2 3 8 0 0 1 2 0 8 0 0 44 2 3 8 0 0
                                  1 2 0 8 0 0 64 2 0 0 0 0 1 2 0 0 0 12
                                  1 2 0 0 0 17 1 2 0 0 0 10 1 2 0 0 0 0
                                  22)))))
          '|lookupComplete|)) 
