
(/VERSIONCHECK 2) 

(DEFUN |IPF;generator;$;1| ($) (|spadConstant| $ 15)) 

(DEFUN |IPF;^;$I$;2| (|x| |n| $)
  (PROG (|r| #1=#:G671)
    (RETURN
     (SEQ
      (COND ((ZEROP |n|) (|spadConstant| $ 15))
            ((SPADCALL |x| (QREFELT $ 18)) (|spadConstant| $ 19))
            ('T
             (SEQ
              (LETT |r|
                    (PROG1
                        (LETT #1#
                              (SPADCALL |n| (- (QREFELT $ 6) 1) (QREFELT $ 21))
                              . #2=(|IPF;^;$I$;2|))
                      (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|) #1#))
                    . #2#)
              (EXIT (SPADCALL |x| |r| (QREFELT $ 23)))))))))) 

(DEFUN |IPF;recip;$U;3| (|x| $)
  (PROG (|y|)
    (RETURN
     (COND
      ((ZEROP (LETT |y| (SPADCALL |x| (QREFELT $ 26)) |IPF;recip;$U;3|))
       (CONS 1 "failed"))
      ('T
       (CONS 0
             (SPADCALL (SPADCALL |y| (QREFELT $ 6) (QREFELT $ 27))
                       (QREFELT $ 28)))))))) 

(DEFUN |IPF;recip;$U;4| (|x| $)
  (PROG (|y|)
    (RETURN
     (COND
      ((QSZEROP
        (LETT |y| (SPADCALL (SPADCALL |x| (QREFELT $ 26)) (QREFELT $ 32))
              |IPF;recip;$U;4|))
       (CONS 1 "failed"))
      ('T
       (CONS 0
             (SPADCALL (SPADCALL |y| (QREFELT $ 33) (QREFELT $ 34))
                       (QREFELT $ 28)))))))) 

(PUT '|IPF;convert;$I;5| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |IPF;convert;$I;5| (|x| $) |x|) 

(DEFUN |IPF;normalElement;$;6| ($) (|spadConstant| $ 15)) 

(DEFUN |IPF;createNormalElement;$;7| ($) (|spadConstant| $ 15)) 

(DEFUN |IPF;characteristic;Nni;8| ($) (QREFELT $ 6)) 

(DEFUN |IPF;factorsOfCyclicGroupSize;L;9| ($)
  (SEQ
   (COND ((EQL (QREFELT $ 6) 2) (QREFELT $ 9))
         ('T
          (SEQ (COND ((NULL (QREFELT $ 9)) (|IPF;initializeElt| $)))
               (EXIT (QREFELT $ 9))))))) 

(PUT '|IPF;representationType;U;10| '|SPADreplace| '(XLAM NIL (CONS 0 "prime"))) 

(DEFUN |IPF;representationType;U;10| ($) (CONS 0 "prime")) 

(DEFUN |IPF;tableForDiscreteLogarithm;IT;11| (|fac| $)
  (PROG (|tbl| #1=#:G709)
    (RETURN
     (SEQ (COND ((QREFELT $ 10) (|IPF;initializeLog| $)))
          (LETT |tbl|
                (SPADCALL
                 (PROG1
                     (LETT #1# |fac|
                           . #2=(|IPF;tableForDiscreteLogarithm;IT;11|))
                   (|check-subtype| (> #1# 0) '(|PositiveInteger|) #1#))
                 (QREFELT $ 14) (QREFELT $ 45))
                . #2#)
          (EXIT
           (COND
            ((QEQCAR |tbl| 1)
             (|error|
              "tableForDiscreteLogarithm: argument must be prime divisor of the order of the multiplicative group"))
            ('T (QCDR |tbl|)))))))) 

(DEFUN |IPF;primitiveElement;$;12| ($)
  (SEQ (COND ((QREFELT $ 11) (|IPF;initializeElt| $)))
       (EXIT (SPADCALL (QREFELT $ 7) (QREFELT $ 48))))) 

(DEFUN |IPF;initializeElt| ($)
  (SEQ
   (SETELT $ 9
           (SPADCALL (SPADCALL (QREFELT $ 8) (QREFELT $ 51)) (QREFELT $ 53)))
   (SETELT $ 7 (SPADCALL (SPADCALL (QREFELT $ 54)) (QREFELT $ 55)))
   (SETELT $ 11 'NIL) (EXIT (SPADCALL (QREFELT $ 57))))) 

(DEFUN |IPF;initializeLog| ($)
  (PROG (#1=#:G730 |a| #2=#:G737 #3=#:G724 |i| |tbl| |n| |d| |l| |base| |fac|
         #4=#:G736 |f| |limit|)
    (RETURN
     (SEQ (COND ((QREFELT $ 11) (|IPF;initializeElt| $)))
          (LETT |limit| 30 . #5=(|IPF;initializeLog|))
          (SEQ (LETT |f| NIL . #5#) (LETT #4# (QREFELT $ 9) . #5#) G190
               (COND
                ((OR (ATOM #4#) (PROGN (LETT |f| (CAR #4#) . #5#) NIL))
                 #6=(GO G191)))
               (SEQ (LETT |fac| (QCAR |f|) . #5#)
                    (LETT |base|
                          (SPADCALL (SPADCALL (QREFELT $ 49))
                                    (QUOTIENT2 (QREFELT $ 8) |fac|)
                                    (QREFELT $ 24))
                          . #5#)
                    (LETT |l| (INTEGER-LENGTH |fac|) . #5#) (LETT |n| 0 . #5#)
                    (COND
                     ((ODDP |l|)
                      (LETT |n| (ASH |fac| (- (QUOTIENT2 |l| 2))) . #5#))
                     ('T (LETT |n| (ASH 1 (QUOTIENT2 |l| 2)) . #5#)))
                    (COND
                     ((< |n| |limit|)
                      (SEQ
                       (LETT |d| (+ (QUOTIENT2 (- |fac| 1) |limit|) 1) . #5#)
                       (EXIT
                        (LETT |n| (+ (QUOTIENT2 (- |fac| 1) |d|) 1) . #5#)))))
                    (LETT |tbl| (SPADCALL (QREFELT $ 58)) . #5#)
                    (LETT |a| (|spadConstant| $ 15) . #5#)
                    (SEQ (LETT |i| 0 . #5#)
                         (LETT #2#
                               (PROG1 (LETT #3# (- |n| 1) . #5#)
                                 (|check-subtype| (>= #3# 0)
                                                  '(|NonNegativeInteger|) #3#))
                               . #5#)
                         G190 (COND ((QSGREATERP |i| #2#) #6#))
                         (SEQ
                          (SPADCALL (CONS (SPADCALL |a| (QREFELT $ 55)) |i|)
                                    |tbl| (QREFELT $ 60))
                          (EXIT
                           (LETT |a| (SPADCALL |a| |base| (QREFELT $ 61))
                                 . #5#)))
                         (LETT |i| (QSADD1 |i|) . #5#) #7=(GO G190) G191
                         (EXIT NIL))
                    (EXIT
                     (SPADCALL
                      (CONS
                       (PROG1 (LETT #1# |fac| . #5#)
                         (|check-subtype| (> #1# 0) '(|PositiveInteger|) #1#))
                       (SPADCALL |tbl| (QREFELT $ 62)))
                      (QREFELT $ 14) (QREFELT $ 64))))
               (LETT #4# (CDR #4#) . #5#) #7# G191 (EXIT NIL))
          (SETELT $ 10 'NIL) (EXIT (SPADCALL (QREFELT $ 57))))))) 

(PUT '|IPF;degree;$Pi;15| '|SPADreplace| '(XLAM (|x|) 1)) 

(DEFUN |IPF;degree;$Pi;15| (|x| $) 1) 

(PUT '|IPF;extensionDegree;Pi;16| '|SPADreplace| '(XLAM NIL 1)) 

(DEFUN |IPF;extensionDegree;Pi;16| ($) 1) 

(PUT '|IPF;inGroundField?;$B;17| '|SPADreplace| '(XLAM (|x|) 'T)) 

(DEFUN |IPF;inGroundField?;$B;17| (|x| $) 'T) 

(DEFUN |IPF;coordinates;$V;18| (|x| $) (SPADCALL 1 |x| (QREFELT $ 69))) 

(DEFUN |IPF;represents;V$;19| (|v| $) (SPADCALL |v| 1 (QREFELT $ 72))) 

(PUT '|IPF;retract;2$;20| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |IPF;retract;2$;20| (|x| $) |x|) 

(PUT '|IPF;retractIfCan;$U;21| '|SPADreplace| '(XLAM (|x|) (CONS 0 |x|))) 

(DEFUN |IPF;retractIfCan;$U;21| (|x| $) (CONS 0 |x|)) 

(DEFUN |IPF;basis;V;22| ($) (SPADCALL 1 (|spadConstant| $ 15) (QREFELT $ 69))) 

(DEFUN |IPF;basis;PiV;23| (|n| $)
  (COND ((EQL |n| 1) (SPADCALL (QREFELT $ 76)))
        ('T (|error| "basis: argument must divide extension degree")))) 

(DEFUN |IPF;definingPolynomial;Sup;24| ($)
  (SPADCALL (SPADCALL (|spadConstant| $ 15) 1 (QREFELT $ 79))
            (SPADCALL (|spadConstant| $ 15) 0 (QREFELT $ 79)) (QREFELT $ 80))) 

(DEFUN |IPF;minimalPolynomial;$Sup;25| (|x| $)
  (SPADCALL (SPADCALL (|spadConstant| $ 15) 1 (QREFELT $ 79))
            (SPADCALL |x| 0 (QREFELT $ 79)) (QREFELT $ 80))) 

(PUT '|IPF;charthRoot;2$;26| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |IPF;charthRoot;2$;26| (|x| $) |x|) 

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

(DEFUN |InnerPrimeField;| (|#1|)
  (PROG (|pv$| $ |dv$| DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|InnerPrimeField|))
      (LETT |dv$| (LIST '|InnerPrimeField| DV$1) . #1#)
      (LETT $ (GETREFV 102) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|InnerPrimeField| (LIST DV$1)
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (AND (|HasCategory| $ '(|CharacteristicZero|)) (|augmentPredVector| $ 1))
      (AND (|HasCategory| $ '(|CharacteristicNonZero|))
           (|augmentPredVector| $ 2))
      (AND (|HasCategory| $ '(|Finite|)) (|augmentPredVector| $ 4))
      (QSETREFV $ 7 1)
      (QSETREFV $ 8 (- |#1| 1))
      (QSETREFV $ 9 NIL)
      (QSETREFV $ 10 'T)
      (QSETREFV $ 11 'T)
      (QSETREFV $ 14 (SPADCALL (QREFELT $ 13)))
      (QSETREFV $ 25 (< MOST-POSITIVE-FIXNUM |#1|))
      (COND
       ((QREFELT $ 25)
        (QSETREFV $ 30 (CONS (|dispatchFunction| |IPF;recip;$U;3|) $)))
       ('T
        (PROGN
         (QSETREFV $ 33 (SPADCALL |#1| (QREFELT $ 32)))
         (QSETREFV $ 30 (CONS (|dispatchFunction| |IPF;recip;$U;4|) $)))))
      $)))) 

(MAKEPROP '|InnerPrimeField| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL (|IntegerMod| 6) (|local| |#1|)
              '|primitiveElt| '|sizeCG| '|facOfGroupSize| '|initlog?|
              '|initelt?| (|Table| 44 46) (0 . |table|) '|discLogTable|
              (4 . |One|) |IPF;generator;$;1| (|Boolean|) (8 . |zero?|)
              (13 . |Zero|) (|Integer|) (17 . |positiveRemainder|)
              (|NonNegativeInteger|) (23 . ^) |IPF;^;$I$;2| '#:G663
              |IPF;convert;$I;5| (29 . |invmod|) (35 . |coerce|)
              (|Union| $ '"failed") (40 . |recip|) (|SingleInteger|)
              (45 . |coerce|) '|q| (50 . |invmod|) |IPF;normalElement;$;6|
              |IPF;createNormalElement;$;7| |IPF;characteristic;Nni;8|
              (|Record| (|:| |factor| 20) (|:| |exponent| 20)) (|List| 38)
              |IPF;factorsOfCyclicGroupSize;L;9|
              (|Union| '"prime" '"polynomial" '"normal" '"cyclic")
              |IPF;representationType;U;10| (|Union| 46 '"failed")
              (|PositiveInteger|) (56 . |search|) (|Table| 44 22)
              |IPF;tableForDiscreteLogarithm;IT;11| (62 . |index|)
              |IPF;primitiveElement;$;12| (|Factored| $) (67 . |factor|)
              (|Factored| 20) (72 . |factors|) (77 . |createPrimitiveElement|)
              (81 . |lookup|) (|Void|) (86 . |void|) (90 . |table|)
              (|Record| (|:| |key| 44) (|:| |entry| 22)) (94 . |insert!|)
              (100 . *) (106 . |copy|)
              (|Record| (|:| |key| 44) (|:| |entry| 46)) (111 . |insert!|)
              |IPF;degree;$Pi;15| |IPF;extensionDegree;Pi;16|
              |IPF;inGroundField?;$B;17| (|Vector| $$) (117 . |new|)
              (|Vector| $) |IPF;coordinates;$V;18| (123 . |elt|)
              |IPF;represents;V$;19| |IPF;retract;2$;20|
              |IPF;retractIfCan;$U;21| |IPF;basis;V;22| |IPF;basis;PiV;23|
              (|SparseUnivariatePolynomial| $$) (129 . |monomial|) (135 . -)
              (|SparseUnivariatePolynomial| $) |IPF;definingPolynomial;Sup;24|
              |IPF;minimalPolynomial;$Sup;25| |IPF;charthRoot;2$;26|
              (|Union| 81 '"failed") (|CardinalNumber|)
              (|OnePointCompletion| 44) (|Matrix| $) (|Union| 70 '"failed")
              (|List| $) (|Union| 22 '"failed") (|Fraction| 20)
              (|Union| 90 '#1="failed")
              (|Record| (|:| |coef1| $) (|:| |coef2| $)) (|Union| 94 '#1#)
              (|Record| (|:| |coef1| $) (|:| |coef2| $) (|:| |generator| $))
              (|Record| (|:| |quotient| $) (|:| |remainder| $))
              (|Record| (|:| |coef| 90) (|:| |generator| $))
              (|Record| (|:| |unit| $) (|:| |canonical| $) (|:| |associate| $))
              (|String|) (|OutputForm|))
           '#(|zero?| 141 |tableForDiscreteLogarithm| 146 |retractIfCan| 151
              |retract| 156 |represents| 161 |representationType| 166 |recip|
              170 |primitiveElement| 175 |normalElement| 179
              |minimalPolynomial| 183 |lookup| 188 |index| 193 |inGroundField?|
              198 |generator| 203 |factorsOfCyclicGroupSize| 207
              |extensionDegree| 211 |degree| 215 |definingPolynomial| 220
              |createPrimitiveElement| 224 |createNormalElement| 228
              |coordinates| 232 |convert| 237 |coerce| 242 |charthRoot| 247
              |characteristic| 252 |basis| 256 ^ 265 |Zero| 271 |One| 275 *
              279)
           'NIL
           (CONS
            (|makeByteWordVec2| 1
                                '(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
                                  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                                  0 0 0))
            (CONS
             '#(|FiniteAlgebraicExtensionField&| |FiniteFieldCategory&|
                |ExtensionField&| |FieldOfPrimeCharacteristic&| |Field&|
                |EuclideanDomain&| NIL |UniqueFactorizationDomain&|
                |GcdDomain&| |DivisionRing&| |IntegralDomain&| |VectorSpace&|
                |Algebra&| |Algebra&| |Module&| |DifferentialRing&| NIL
                |Module&| NIL NIL NIL NIL NIL |Ring&| NIL NIL NIL NIL NIL
                |AbelianGroup&| NIL NIL |AbelianMonoid&| |Monoid&| NIL NIL
                |Finite&| |SemiGroup&| |AbelianSemiGroup&| |SetCategory&| NIL
                |RetractableTo&| NIL NIL NIL NIL NIL |BasicType&| NIL)
             (CONS
              '#((|FiniteAlgebraicExtensionField| $$) (|FiniteFieldCategory|)
                 (|ExtensionField| $$) (|FieldOfPrimeCharacteristic|) (|Field|)
                 (|EuclideanDomain|) (|PrincipalIdealDomain|)
                 (|UniqueFactorizationDomain|) (|GcdDomain|) (|DivisionRing|)
                 (|IntegralDomain|) (|VectorSpace| $$) (|Algebra| 92)
                 (|Algebra| $$) (|Module| $$) (|DifferentialRing|)
                 (|CharacteristicNonZero|) (|Module| 92) (|EntireRing|)
                 (|CommutativeRing|) (|CharacteristicZero|) (|BiModule| $$ $$)
                 (|BiModule| 92 92) (|Ring|) (|LeftModule| $$)
                 (|RightModule| 92) (|LeftModule| 92) (|Rng|)
                 (|RightModule| $$) (|AbelianGroup|)
                 (|CancellationAbelianMonoid|) (|SemiRing|) (|AbelianMonoid|)
                 (|Monoid|) (|SemiRng|) (|StepThrough|) (|Finite|)
                 (|SemiGroup|) (|AbelianSemiGroup|) (|SetCategory|)
                 (|ConvertibleTo| 20) (|RetractableTo| $$) (|canonicalsClosed|)
                 (|canonicalUnitNormal|) (|noZeroDivisors|) (|CommutativeStar|)
                 (|unitsKnown|) (|BasicType|) (|CoercibleTo| 101))
              (|makeByteWordVec2| 84
                                  '(0 12 0 13 0 0 0 15 1 0 17 0 18 0 0 0 19 2
                                    20 0 0 0 21 2 5 0 0 22 23 2 20 0 0 0 27 1 0
                                    0 20 28 1 0 29 0 30 1 31 0 20 32 2 31 0 0 0
                                    34 2 12 43 44 0 45 1 0 0 44 48 1 20 50 0 51
                                    1 52 39 0 53 0 0 0 54 1 0 44 0 55 0 56 0 57
                                    0 46 0 58 2 46 0 59 0 60 2 0 0 0 0 61 1 46
                                    0 0 62 2 12 0 63 0 64 2 68 0 22 2 69 2 68 2
                                    0 20 72 2 78 0 2 22 79 2 78 0 0 0 80 1 0 17
                                    0 18 1 0 46 20 47 1 0 29 0 75 1 0 0 0 74 1
                                    0 0 70 73 0 0 41 42 1 0 29 0 30 0 0 0 49 0
                                    3 0 35 1 0 81 0 83 1 0 44 0 55 1 0 0 44 48
                                    1 0 17 0 67 0 3 0 16 0 0 39 40 0 0 44 66 1
                                    0 44 0 65 0 0 81 82 0 0 0 54 0 3 0 36 1 0
                                    70 0 71 1 0 20 0 26 1 0 0 20 28 1 0 0 0 84
                                    0 0 22 37 1 0 70 44 77 0 0 70 76 2 0 0 0 20
                                    24 0 0 0 19 0 0 0 15 2 0 0 0 0 61)))))
           '|lookupIncomplete|)) 
