
(/VERSIONCHECK 2) 

(PUT '|IPADIC;characteristic;Nni;1| '|SPADreplace| '(XLAM NIL 0)) 

(DEFUN |IPADIC;characteristic;Nni;1| ($) 0) 

(DEFUN |IPADIC;euclideanSize;$Nni;2| (|x| $) (SPADCALL |x| (QREFELT $ 15))) 

(PUT '|IPADIC;stream| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |IPADIC;stream| (|x| $) |x|) 

(PUT '|IPADIC;padic| '|SPADreplace| '(XLAM (|x|) |x|)) 

(DEFUN |IPADIC;padic| (|x| $) |x|) 

(DEFUN |IPADIC;digits;$S;5| (|x| $) (|IPADIC;stream| |x| $)) 

(DEFUN |IPADIC;extend;$I$;6| (|x| |n| $)
  (SPADCALL |x| (+ |n| 1) (QREFELT $ 20))) 

(DEFUN |IPADIC;complete;2$;7| (|x| $) (SPADCALL |x| (QREFELT $ 22))) 

(DEFUN |IPADIC;modP| (|n| $)
  (COND
   ((OR (QREFELT $ 7) (EQL (QREFELT $ 6) 2))
    (SPADCALL |n| (QREFELT $ 6) (QREFELT $ 24)))
   ('T (SPADCALL |n| (QREFELT $ 6) (QREFELT $ 25))))) 

(DEFUN |IPADIC;modPInfo| (|n| $)
  (PROG (|q| |r| |r0| |dv|)
    (RETURN
     (SEQ (LETT |dv| (DIVIDE2 |n| (QREFELT $ 6)) . #1=(|IPADIC;modPInfo|))
          (LETT |r0| (QCDR |dv|) . #1#) (LETT |q| (QCAR |dv|) . #1#)
          (SEQ (LETT |r| (|IPADIC;modP| |r0| $) . #1#)
               (EXIT
                (COND
                 ((NULL (EQL |r| |r0|))
                  (LETT |q| (+ |q| (QUOTIENT2 (- |r0| |r|) (QREFELT $ 6)))
                        . #1#)))))
          (EXIT (CONS |r| |q|)))))) 

(DEFUN |IPADIC;invModP| (|n| $) (SPADCALL |n| (QREFELT $ 6) (QREFELT $ 26))) 

(DEFUN |IPADIC;modulus;I;11| ($) (QREFELT $ 6)) 

(DEFUN |IPADIC;moduloP;$I;12| (|x| $)
  (COND ((SPADCALL |x| (QREFELT $ 29)) 0) ('T (SPADCALL |x| (QREFELT $ 30))))) 

(DEFUN |IPADIC;quotientByP;2$;13| (|x| $)
  (COND ((SPADCALL |x| (QREFELT $ 29)) |x|) ('T (SPADCALL |x| (QREFELT $ 32))))) 

(DEFUN |IPADIC;approximate;$2I;14| (|x| |n| $)
  (SEQ
   (COND ((< 0 |n|) (COND ((SPADCALL |x| (QREFELT $ 29)) (EXIT 0))))
         ('T (EXIT 0)))
   (EXIT
    (+ (SPADCALL |x| (QREFELT $ 30))
       (* (QREFELT $ 6)
          (SPADCALL (SPADCALL |x| (QREFELT $ 32)) (- |n| 1) (QREFELT $ 35))))))) 

(DEFUN |IPADIC;=;2$B;15| (|x| |y| $)
  (PROG (|st| #1=#:G737 |i| |n|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |st| (|IPADIC;stream| (SPADCALL |x| |y| (QREFELT $ 36)) $)
              . #2=(|IPADIC;=;2$B;15|))
        (LETT |n| |$streamCount| . #2#)
        (SEQ (LETT |i| 0 . #2#) G190 (COND ((QSGREATERP |i| |n|) (GO G191)))
             (SEQ
              (EXIT
               (COND
                ((SPADCALL |st| (QREFELT $ 29))
                 (PROGN (LETT #1# 'T . #2#) (GO #1#)))
                ((NULL (EQL (SPADCALL |st| (QREFELT $ 30)) 0))
                 (PROGN (LETT #1# 'NIL . #2#) (GO #1#)))
                ('T (LETT |st| (SPADCALL |st| (QREFELT $ 37)) . #2#)))))
             (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
        (EXIT (SPADCALL |st| (QREFELT $ 29)))))
      #1# (EXIT #1#))))) 

(DEFUN |IPADIC;order;$Nni;16| (|x| $)
  (PROG (|st| #1=#:G743 |i|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (LETT |st| (|IPADIC;stream| |x| $) . #2=(|IPADIC;order;$Nni;16|))
            (SEQ (LETT |i| 0 . #2#) G190
                 (COND ((QSGREATERP |i| 1000) (GO G191)))
                 (SEQ
                  (EXIT
                   (COND
                    ((SPADCALL |st| (QREFELT $ 29))
                     (PROGN (LETT #1# 0 . #2#) (GO #1#)))
                    ((NULL (EQL (SPADCALL |st| (QREFELT $ 30)) 0))
                     (PROGN (LETT #1# |i| . #2#) (GO #1#)))
                    ('T (LETT |st| (SPADCALL |st| (QREFELT $ 32)) . #2#)))))
                 (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
            (EXIT
             (|error| "order: series has more than 1000 leading zero coefs"))))
      #1# (EXIT #1#))))) 

(DEFUN |IPADIC;Zero;$;17| ($)
  (|IPADIC;padic| (SPADCALL 0 (SPADCALL (QREFELT $ 39)) (QREFELT $ 40)) $)) 

(DEFUN |IPADIC;One;$;18| ($)
  (|IPADIC;padic| (SPADCALL 1 (SPADCALL (QREFELT $ 39)) (QREFELT $ 40)) $)) 

(DEFUN |IPADIC;intToPAdic| (|n| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;intToPAdic!0| (VECTOR $ |n|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;intToPAdic!0| ($$)
  (PROG (|n| $)
    (LETT |n| (QREFELT $$ 1) . #1=(|IPADIC;intToPAdic|))
    (LETT $ (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND
           ((SPADCALL |n| (|spadConstant| $ 41) (QREFELT $ 42))
            (SPADCALL (QREFELT $ 39)))
           ('T
            (SEQ (LETT |modp| (|IPADIC;modPInfo| |n| $) NIL)
                 (EXIT
                  (SPADCALL (QCAR |modp|) (|IPADIC;intToPAdic| (QCDR |modp|) $)
                            (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;intPlusPAdic| (|n| |x| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;intPlusPAdic!0| (VECTOR |n| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;intPlusPAdic!0| ($$)
  (PROG (|x| $ |n|)
    (LETT |x| (QREFELT $$ 2) . #1=(|IPADIC;intPlusPAdic|))
    (LETT $ (QREFELT $$ 1) . #1#)
    (LETT |n| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND ((SPADCALL |x| (QREFELT $ 29)) (|IPADIC;intToPAdic| |n| $))
                ('T
                 (SEQ
                  (LETT |modp|
                        (|IPADIC;modPInfo|
                         (SPADCALL |n| (SPADCALL |x| (QREFELT $ 30))
                                   (QREFELT $ 46))
                         $)
                        NIL)
                  (EXIT
                   (SPADCALL (QCAR |modp|)
                             (|IPADIC;intPlusPAdic| (QCDR |modp|)
                              (SPADCALL |x| (QREFELT $ 37)) $)
                             (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;intMinusPAdic| (|n| |x| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;intMinusPAdic!0| (VECTOR |n| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;intMinusPAdic!0| ($$)
  (PROG (|x| $ |n|)
    (LETT |x| (QREFELT $$ 2) . #1=(|IPADIC;intMinusPAdic|))
    (LETT $ (QREFELT $$ 1) . #1#)
    (LETT |n| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND ((SPADCALL |x| (QREFELT $ 29)) (|IPADIC;intToPAdic| |n| $))
                ('T
                 (SEQ
                  (LETT |modp|
                        (|IPADIC;modPInfo|
                         (SPADCALL |n| (SPADCALL |x| (QREFELT $ 30))
                                   (QREFELT $ 48))
                         $)
                        NIL)
                  (EXIT
                   (SPADCALL (QCAR |modp|)
                             (|IPADIC;intMinusPAdic| (QCDR |modp|)
                              (SPADCALL |x| (QREFELT $ 37)) $)
                             (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;plusAux| (|n| |x| |y| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;plusAux!0| (VECTOR |n| |y| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;plusAux!0| ($$)
  (PROG (|x| $ |y| |n|)
    (LETT |x| (QREFELT $$ 3) . #1=(|IPADIC;plusAux|))
    (LETT $ (QREFELT $$ 2) . #1#)
    (LETT |y| (QREFELT $$ 1) . #1#)
    (LETT |n| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND
           ((SPADCALL |x| (QREFELT $ 29))
            (COND
             ((SPADCALL |y| (QREFELT $ 29))
              (EXIT (|IPADIC;intToPAdic| |n| $))))))
          (EXIT
           (COND
            ((SPADCALL |x| (QREFELT $ 29)) (|IPADIC;intPlusPAdic| |n| |y| $))
            ((SPADCALL |y| (QREFELT $ 29)) (|IPADIC;intPlusPAdic| |n| |x| $))
            ('T
             (SEQ
              (LETT |modp|
                    (|IPADIC;modPInfo|
                     (SPADCALL
                      (SPADCALL |n| (SPADCALL |x| (QREFELT $ 30))
                                (QREFELT $ 46))
                      (SPADCALL |y| (QREFELT $ 30)) (QREFELT $ 46))
                     $)
                    NIL)
              (EXIT
               (SPADCALL (QCAR |modp|)
                         (|IPADIC;plusAux| (QCDR |modp|)
                          (SPADCALL |x| (QREFELT $ 37))
                          (SPADCALL |y| (QREFELT $ 37)) $)
                         (QREFELT $ 40)))))))))))))) 

(DEFUN |IPADIC;minusAux| (|n| |x| |y| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;minusAux!0| (VECTOR |n| |y| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;minusAux!0| ($$)
  (PROG (|x| $ |y| |n|)
    (LETT |x| (QREFELT $$ 3) . #1=(|IPADIC;minusAux|))
    (LETT $ (QREFELT $$ 2) . #1#)
    (LETT |y| (QREFELT $$ 1) . #1#)
    (LETT |n| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND
           ((SPADCALL |x| (QREFELT $ 29))
            (COND
             ((SPADCALL |y| (QREFELT $ 29))
              (EXIT (|IPADIC;intToPAdic| |n| $))))))
          (EXIT
           (COND
            ((SPADCALL |x| (QREFELT $ 29)) (|IPADIC;intMinusPAdic| |n| |y| $))
            ((SPADCALL |y| (QREFELT $ 29)) (|IPADIC;intPlusPAdic| |n| |x| $))
            ('T
             (SEQ
              (LETT |modp|
                    (|IPADIC;modPInfo|
                     (SPADCALL
                      (SPADCALL |n| (SPADCALL |x| (QREFELT $ 30))
                                (QREFELT $ 46))
                      (SPADCALL |y| (QREFELT $ 30)) (QREFELT $ 48))
                     $)
                    NIL)
              (EXIT
               (SPADCALL (QCAR |modp|)
                         (|IPADIC;minusAux| (QCDR |modp|)
                          (SPADCALL |x| (QREFELT $ 37))
                          (SPADCALL |y| (QREFELT $ 37)) $)
                         (QREFELT $ 40)))))))))))))) 

(DEFUN |IPADIC;+;3$;24| (|x| |y| $)
  (|IPADIC;padic|
   (|IPADIC;plusAux| 0 (|IPADIC;stream| |x| $) (|IPADIC;stream| |y| $) $) $)) 

(DEFUN |IPADIC;-;3$;25| (|x| |y| $)
  (|IPADIC;padic|
   (|IPADIC;minusAux| 0 (|IPADIC;stream| |x| $) (|IPADIC;stream| |y| $) $) $)) 

(DEFUN |IPADIC;-;2$;26| (|y| $)
  (|IPADIC;padic| (|IPADIC;intMinusPAdic| 0 (|IPADIC;stream| |y| $) $) $)) 

(DEFUN |IPADIC;coerce;I$;27| (|n| $)
  (|IPADIC;padic| (|IPADIC;intToPAdic| |n| $) $)) 

(DEFUN |IPADIC;intMult| (|n| |x| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;intMult!0| (VECTOR |n| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;intMult!0| ($$)
  (PROG (|x| $ |n|)
    (LETT |x| (QREFELT $$ 2) . #1=(|IPADIC;intMult|))
    (LETT $ (QREFELT $$ 1) . #1#)
    (LETT |n| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp|)
        (RETURN
         (SEQ
          (COND ((SPADCALL |x| (QREFELT $ 29)) (SPADCALL (QREFELT $ 39)))
                ('T
                 (SEQ
                  (LETT |modp|
                        (|IPADIC;modPInfo|
                         (SPADCALL |n| (SPADCALL |x| (QREFELT $ 30))
                                   (QREFELT $ 52))
                         $)
                        NIL)
                  (EXIT
                   (SPADCALL (QCAR |modp|)
                             (|IPADIC;intPlusPAdic| (QCDR |modp|)
                              (|IPADIC;intMult| |n|
                               (SPADCALL |x| (QREFELT $ 37)) $)
                              $)
                             (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;*;I2$;29| (|n| |x| $)
  (|IPADIC;padic| (|IPADIC;intMult| |n| (|IPADIC;stream| |x| $) $) $)) 

(DEFUN |IPADIC;timesAux| (|x| |y| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;timesAux!0| (VECTOR |y| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;timesAux!0| ($$)
  (PROG (|x| $ |y|)
    (LETT |x| (QREFELT $$ 2) . #1=(|IPADIC;timesAux|))
    (LETT $ (QREFELT $$ 1) . #1#)
    (LETT |y| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|modp| |car| |cdr|)
        (RETURN
         (SEQ
          (COND
           ((OR (SPADCALL |x| (QREFELT $ 29)) (SPADCALL |y| (QREFELT $ 29)))
            (SPADCALL (QREFELT $ 39)))
           ('T
            (SEQ
             (LETT |modp|
                   (|IPADIC;modPInfo|
                    (SPADCALL (SPADCALL |x| (QREFELT $ 30))
                              (SPADCALL |y| (QREFELT $ 30)) (QREFELT $ 52))
                    $)
                   NIL)
             (LETT |car| (QCAR |modp|) NIL)
             (LETT |cdr|
                   (|IPADIC;plusAux| (QCDR |modp|)
                    (|IPADIC;intMult| (SPADCALL |x| (QREFELT $ 30))
                     (SPADCALL |y| (QREFELT $ 37)) $)
                    (|IPADIC;timesAux| (SPADCALL |x| (QREFELT $ 37)) |y| $) $)
                   NIL)
             (EXIT (SPADCALL |car| |cdr| (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;*;3$;31| (|x| |y| $)
  (|IPADIC;padic|
   (|IPADIC;timesAux| (|IPADIC;stream| |x| $) (|IPADIC;stream| |y| $) $) $)) 

(DEFUN |IPADIC;quotientAux| (|x| |y| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL (CONS #'|IPADIC;quotientAux!0| (VECTOR |y| $ |x|))
                (QREFELT $ 45)))))) 

(DEFUN |IPADIC;quotientAux!0| ($$)
  (PROG (|x| $ |y|)
    (LETT |x| (QREFELT $$ 2) . #1=(|IPADIC;quotientAux|))
    (LETT $ (QREFELT $$ 1) . #1#)
    (LETT |y| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|z0| |yy|)
        (RETURN
         (SEQ
          (COND
           ((SPADCALL |x| (QREFELT $ 29))
            (|error| "quotientAux: first argument"))
           ((SPADCALL |y| (QREFELT $ 29)) (SPADCALL (QREFELT $ 39)))
           ((SPADCALL (|IPADIC;modP| (SPADCALL |x| (QREFELT $ 30)) $)
                      (|spadConstant| $ 41) (QREFELT $ 42))
            (COND
             ((SPADCALL (|IPADIC;modP| (SPADCALL |y| (QREFELT $ 30)) $)
                        (|spadConstant| $ 41) (QREFELT $ 42))
              (|IPADIC;quotientAux| (SPADCALL |x| (QREFELT $ 37))
               (SPADCALL |y| (QREFELT $ 37)) $))
             ('T (|error| "quotient: quotient not integral"))))
           ('T
            (SEQ
             (LETT |z0|
                   (|IPADIC;modP|
                    (SPADCALL
                     (|IPADIC;invModP| (SPADCALL |x| (QREFELT $ 30)) $)
                     (SPADCALL |y| (QREFELT $ 30)) (QREFELT $ 52))
                    $)
                   NIL)
             (LETT |yy|
                   (SPADCALL
                    (|IPADIC;minusAux| (|spadConstant| $ 41) |y|
                     (|IPADIC;intMult| |z0| |x| $) $)
                    (QREFELT $ 55))
                   NIL)
             (EXIT
              (SPADCALL |z0| (|IPADIC;quotientAux| |x| |yy| $)
                        (QREFELT $ 40))))))))))))) 

(DEFUN |IPADIC;recip;$U;33| (|x| $)
  (COND
   ((OR (SPADCALL |x| (QREFELT $ 29))
        (EQL (|IPADIC;modP| (SPADCALL |x| (QREFELT $ 30)) $) 0))
    (CONS 1 "failed"))
   ('T
    (CONS 0
          (|IPADIC;padic|
           (|IPADIC;quotientAux| (|IPADIC;stream| |x| $)
            (SPADCALL 1 (SPADCALL (QREFELT $ 39)) (QREFELT $ 40)) $)
           $))))) 

(DEFUN |IPADIC;iExquo| (|xx| |yy| |n| $)
  (PROG (|rec|)
    (RETURN
     (SEQ
      (COND
       ((< 1000 |n|)
        (|error| "exquo: quotient by series with many leading zero coefs"))
       ((SPADCALL |yy| (QREFELT $ 29)) (CONS 1 "failed"))
       ((SPADCALL |xx| (QREFELT $ 29)) (CONS 0 (|spadConstant| $ 34)))
       ((ZEROP (SPADCALL |yy| (QREFELT $ 30)))
        (COND
         ((ZEROP (SPADCALL |xx| (QREFELT $ 30)))
          (|IPADIC;iExquo| (SPADCALL |xx| (QREFELT $ 32))
           (SPADCALL |yy| (QREFELT $ 32)) (+ |n| 1) $))
         (#1='T (CONS 1 "failed"))))
       (#1#
        (SEQ (LETT |rec| (SPADCALL |yy| (QREFELT $ 57)) |IPADIC;iExquo|)
             (EXIT
              (COND ((QEQCAR |rec| 1) (CONS 1 "failed"))
                    (#1#
                     (CONS 0
                           (SPADCALL |xx| (QCDR |rec|)
                                     (QREFELT $ 54))))))))))))) 

(DEFUN |IPADIC;exquo;2$U;35| (|x| |y| $)
  (|IPADIC;iExquo| (|IPADIC;stream| |x| $) (|IPADIC;stream| |y| $) 0 $)) 

(DEFUN |IPADIC;divide;2$R;36| (|x| |y| $)
  (PROG (|z|)
    (RETURN
     (SEQ (LETT |z| (SPADCALL |x| |y| (QREFELT $ 58)) |IPADIC;divide;2$R;36|)
          (EXIT
           (COND ((QEQCAR |z| 1) (CONS (|spadConstant| $ 34) |x|))
                 ('T (CONS (QCDR |z|) (|spadConstant| $ 34))))))))) 

(DEFUN |IPADIC;iSqrt| (|pn| |an| |bn| |bSt| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL
       (CONS #'|IPADIC;iSqrt!0| (VECTOR (QREFELT $ 6) |an| |pn| |bn| $ |bSt|))
       (QREFELT $ 64)))))) 

(DEFUN |IPADIC;iSqrt!0| ($$)
  (PROG (|bSt| $ |bn| |pn| |an| |p|)
    (LETT |bSt| (QREFELT $$ 5) . #1=(|IPADIC;iSqrt|))
    (LETT $ (QREFELT $$ 4) . #1#)
    (LETT |bn| (QREFELT $$ 3) . #1#)
    (LETT |pn| (QREFELT $$ 2) . #1#)
    (LETT |an| (QREFELT $$ 1) . #1#)
    (LETT |p| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (|bn1| |c| |aa| |nSt|)
        (RETURN
         (SEQ
          (LETT |bn1|
                (COND ((SPADCALL |bSt| (QREFELT $ 29)) |bn|)
                      ('T
                       (SPADCALL |bn|
                                 (SPADCALL |pn| (SPADCALL |bSt| (QREFELT $ 30))
                                           (QREFELT $ 52))
                                 (QREFELT $ 46))))
                NIL)
          (LETT |c|
                (SPADCALL
                 (SPADCALL |bn1| (SPADCALL |an| |an| (QREFELT $ 52))
                           (QREFELT $ 48))
                 |pn| (QREFELT $ 61))
                NIL)
          (LETT |aa|
                (|IPADIC;modP|
                 (SPADCALL |c|
                           (SPADCALL (SPADCALL 2 |an| (QREFELT $ 63)) |p|
                                     (QREFELT $ 26))
                           (QREFELT $ 52))
                 $)
                NIL)
          (LETT |nSt|
                (COND ((SPADCALL |bSt| (QREFELT $ 29)) |bSt|)
                      ('T (SPADCALL |bSt| (QREFELT $ 32))))
                NIL)
          (EXIT
           (SPADCALL |aa|
                     (|IPADIC;iSqrt| (SPADCALL |pn| |p| (QREFELT $ 52))
                      (SPADCALL |an| (SPADCALL |pn| |aa| (QREFELT $ 52))
                                (QREFELT $ 46))
                      |bn1| |nSt| $)
                     (QREFELT $ 47)))))))))) 

(DEFUN |IPADIC;sqrt;$I$;38| (|b| |a| $)
  (PROG (|bb|)
    (RETURN
     (SEQ
      (COND ((EQL (QREFELT $ 6) 2) (|error| "sqrt: no square roots in Z2 yet"))
            ((NULL
              (ZEROP
               (|IPADIC;modP|
                (- (* |a| |a|)
                   (LETT |bb| (SPADCALL |b| (QREFELT $ 31))
                         . #1=(|IPADIC;sqrt;$I$;38|)))
                $)))
             (|error| "sqrt: not a square root (mod p)"))
            ('T
             (SEQ
              (LETT |b|
                    (COND ((SPADCALL |b| (QREFELT $ 29)) |b|)
                          ('T (SPADCALL |b| (QREFELT $ 32))))
                    . #1#)
              (LETT |a| (|IPADIC;modP| |a| $) . #1#)
              (EXIT
               (SPADCALL |a| (|IPADIC;iSqrt| (QREFELT $ 6) |a| |bb| |b| $)
                         (QREFELT $ 47)))))))))) 

(DEFUN |IPADIC;iRoot| (|f| |alpha| |invFpx0| |pPow| $)
  (PROG ()
    (RETURN
     (SEQ
      (SPADCALL
       (CONS #'|IPADIC;iRoot!0|
             (VECTOR (QREFELT $ 6) |invFpx0| |pPow| $ |alpha| |f|))
       (QREFELT $ 45)))))) 

(DEFUN |IPADIC;iRoot!0| ($$)
  (PROG (|f| |alpha| $ |pPow| |invFpx0| |p|)
    (LETT |f| (QREFELT $$ 5) . #1=(|IPADIC;iRoot|))
    (LETT |alpha| (QREFELT $$ 4) . #1#)
    (LETT $ (QREFELT $$ 3) . #1#)
    (LETT |pPow| (QREFELT $$ 2) . #1#)
    (LETT |invFpx0| (QREFELT $$ 1) . #1#)
    (LETT |p| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (PROG (#2=#:G922 |num| |digit|)
        (RETURN
         (SEQ
          (LETT |num|
                (SPADCALL
                 (PROG2
                     (LETT #2#
                           (SPADCALL (SPADCALL |f| |alpha| (QREFELT $ 67))
                                     |pPow| (QREFELT $ 68))
                           NIL)
                     (QCDR #2#)
                   (|check-union| (QEQCAR #2# 0) (|Integer|) #2#))
                 (QREFELT $ 69))
                NIL)
          (LETT |digit|
                (|IPADIC;modP| (SPADCALL |num| |invFpx0| (QREFELT $ 52)) $)
                NIL)
          (EXIT
           (SPADCALL |digit|
                     (|IPADIC;iRoot| |f|
                      (SPADCALL |alpha|
                                (SPADCALL |digit| |pPow| (QREFELT $ 52))
                                (QREFELT $ 46))
                      |invFpx0| (SPADCALL |p| |pPow| (QREFELT $ 52)) $)
                     (QREFELT $ 40)))))))))) 

(DEFUN |IPADIC;root;SupI$;40| (|f| |x0| $)
  (PROG (|invFpx0| |fpx0|)
    (RETURN
     (SEQ (LETT |x0| (|IPADIC;modP| |x0| $) . #1=(|IPADIC;root;SupI$;40|))
          (COND
           ((NULL (ZEROP (|IPADIC;modP| (SPADCALL |f| |x0| (QREFELT $ 67)) $)))
            (EXIT (|error| "root: not a root (mod p)"))))
          (LETT |fpx0|
                (|IPADIC;modP|
                 (SPADCALL (SPADCALL |f| (QREFELT $ 70)) |x0| (QREFELT $ 67))
                 $)
                . #1#)
          (EXIT
           (COND
            ((ZEROP |fpx0|)
             (|error| "root: approximate root must be a simple root (mod p)"))
            ('T
             (SEQ
              (LETT |invFpx0| (|IPADIC;modP| (|IPADIC;invModP| |fpx0| $) $)
                    . #1#)
              (EXIT
               (|IPADIC;padic|
                (SPADCALL |x0|
                          (|IPADIC;iRoot| |f| |x0| |invFpx0| (QREFELT $ 6) $)
                          (QREFELT $ 40))
                $)))))))))) 

(DEFUN |IPADIC;termOutput| (|k| |c| $)
  (PROG (|mon|)
    (RETURN
     (SEQ
      (COND ((EQL |k| 0) (SPADCALL |c| (QREFELT $ 10)))
            (#1='T
             (SEQ
              (LETT |mon|
                    (COND ((EQL |k| 1) (QREFELT $ 11))
                          (#1#
                           (SPADCALL (QREFELT $ 11)
                                     (SPADCALL |k| (QREFELT $ 10))
                                     (QREFELT $ 72))))
                    |IPADIC;termOutput|)
              (EXIT
               (COND ((EQL |c| 1) |mon|)
                     ((EQL |c| -1) (SPADCALL |mon| (QREFELT $ 73)))
                     (#1#
                      (SPADCALL (SPADCALL |c| (QREFELT $ 10)) |mon|
                                (QREFELT $ 74)))))))))))) 

(PUT '|IPADIC;showAll?| '|SPADreplace| '(XLAM NIL 'T)) 

(DEFUN |IPADIC;showAll?| ($) 'T) 

(DEFUN |IPADIC;coerce;$Of;43| (|x| $)
  (PROG (|l| |st| |n| |count|)
    (RETURN
     (SEQ
      (COND
       ((SPADCALL
         (LETT |st| (|IPADIC;stream| |x| $) . #1=(|IPADIC;coerce;$Of;43|))
         (QREFELT $ 29))
        (SPADCALL 0 (QREFELT $ 10)))
       (#2='T
        (SEQ (LETT |count| |$streamCount| . #1#) (LETT |l| NIL . #1#)
             (SEQ (LETT |n| 0 . #1#) G190
                  (COND
                   ((OR (QSGREATERP |n| |count|)
                        (NULL
                         (COND ((SPADCALL |st| (QREFELT $ 29)) 'NIL) ('T 'T))))
                    #3=(GO G191)))
                  (SEQ
                   (COND
                    ((NULL (EQL (SPADCALL |st| (QREFELT $ 30)) 0))
                     (LETT |l|
                           (CONS
                            (|IPADIC;termOutput| |n|
                             (SPADCALL |st| (QREFELT $ 30)) $)
                            |l|)
                           . #1#)))
                   (EXIT (LETT |st| (SPADCALL |st| (QREFELT $ 32)) . #1#)))
                  (LETT |n| (QSADD1 |n|) . #1#) #4=(GO G190) G191 (EXIT NIL))
             (COND
              ((|IPADIC;showAll?| $)
               (SEQ (LETT |n| (+ |count| 1) . #1#) G190
                    (COND
                     ((NULL
                       (COND
                        ((SPADCALL |st| (QREFELT $ 75))
                         (COND
                          ((SPADCALL |st| (SPADCALL |st| (QREFELT $ 32))
                                     (QREFELT $ 76))
                           'NIL)
                          ('T 'T)))
                        ('T 'NIL)))
                      #3#))
                    (SEQ
                     (COND
                      ((NULL (EQL (SPADCALL |st| (QREFELT $ 30)) 0))
                       (LETT |l|
                             (CONS
                              (|IPADIC;termOutput| |n|
                               (SPADCALL |st| (QREFELT $ 30)) $)
                              |l|)
                             . #1#)))
                     (EXIT (LETT |st| (SPADCALL |st| (QREFELT $ 32)) . #1#)))
                    (LETT |n| (+ |n| 1) . #1#) #4# G191 (EXIT NIL))))
             (LETT |l|
                   (COND ((SPADCALL |st| (QREFELT $ 77)) |l|)
                         (#2#
                          (SEQ
                           (COND
                            ((SPADCALL |st| (SPADCALL |st| (QREFELT $ 32))
                                       (QREFELT $ 76))
                             (COND
                              ((EQL (SPADCALL |st| (QREFELT $ 30)) 0)
                               (EXIT |l|)))))
                           (EXIT
                            (CONS
                             (SPADCALL "O"
                                       (LIST
                                        (SPADCALL (QREFELT $ 11)
                                                  (SPADCALL |n| (QREFELT $ 78))
                                                  (QREFELT $ 72)))
                                       (QREFELT $ 80))
                             |l|)))))
                   . #1#)
             (EXIT
              (COND ((NULL |l|) (SPADCALL 0 (QREFELT $ 78)))
                    (#2#
                     (SPADCALL (ELT $ 81) (NREVERSE |l|)
                               (QREFELT $ 84)))))))))))) 

(DEFUN |InnerPAdicInteger| (&REST #1=#:G965)
  (PROG ()
    (RETURN
     (PROG (#2=#:G966)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (|devaluateList| #1#)
                                           (HGET |$ConstructorCache|
                                                 '|InnerPAdicInteger|)
                                           '|domainEqualList|)
                . #3=(|InnerPAdicInteger|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT
              (PROG1 (APPLY (|function| |InnerPAdicInteger;|) #1#)
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|InnerPAdicInteger|))))))))))) 

(DEFUN |InnerPAdicInteger;| (|#1| |#2|)
  (PROG (|pv$| $ |dv$| DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|InnerPAdicInteger|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT |dv$| (LIST '|InnerPAdicInteger| DV$1 DV$2) . #1#)
      (LETT $ (GETREFV 95) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|InnerPAdicInteger| (LIST DV$1 DV$2)
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 11 (SPADCALL |#1| (QREFELT $ 10)))
      (QSETREFV $ 12 (|Stream| (|Integer|)))
      $)))) 

(MAKEPROP '|InnerPAdicInteger| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|OutputForm|) (|Integer|) (0 . |coerce|) 'PEXPR '|Rep|
              (|NonNegativeInteger|) |IPADIC;characteristic;Nni;1|
              |IPADIC;order;$Nni;16| |IPADIC;euclideanSize;$Nni;2| (|Stream| 9)
              |IPADIC;digits;$S;5|
              (CONS IDENTITY
                    (FUNCALL (|dispatchFunction| |IPADIC;One;$;18|) $))
              (5 . |extend|) |IPADIC;extend;$I$;6| (11 . |complete|)
              |IPADIC;complete;2$;7| (16 . |positiveRemainder|)
              (22 . |symmetricRemainder|) (28 . |invmod|) |IPADIC;modulus;I;11|
              (|Boolean|) (34 . |empty?|) (39 . |frst|) |IPADIC;moduloP;$I;12|
              (44 . |rst|) |IPADIC;quotientByP;2$;13|
              (CONS IDENTITY
                    (FUNCALL (|dispatchFunction| |IPADIC;Zero;$;17|) $))
              |IPADIC;approximate;$2I;14| |IPADIC;-;3$;25| (49 . |rst|)
              |IPADIC;=;2$B;15| (54 . |empty|) (58 . |concat|) (64 . |Zero|)
              (68 . =) (74 . |empty|) (|Mapping| $) (78 . |delay|) (83 . +)
              (89 . |concat|) (95 . -) |IPADIC;+;3$;24| |IPADIC;-;2$;26|
              |IPADIC;coerce;I$;27| (101 . *) |IPADIC;*;I2$;29|
              |IPADIC;*;3$;31| (107 . |rest|) (|Union| $ '"failed")
              |IPADIC;recip;$U;33| |IPADIC;exquo;2$U;35|
              (|Record| (|:| |quotient| $) (|:| |remainder| $))
              |IPADIC;divide;2$R;36| (112 . |quo|) (|PositiveInteger|)
              (118 . *) (124 . |delay|) |IPADIC;sqrt;$I$;38|
              (|SparseUnivariatePolynomial| 9) (129 . |elt|) (135 . |exquo|)
              (141 . -) (146 . |differentiate|) |IPADIC;root;SupI$;40|
              (151 . ^) (157 . -) (162 . *) (168 . |explicitEntries?|)
              (173 . |eq?|) (179 . |explicitlyEmpty?|) (184 . |coerce|)
              (|List| $) (189 . |prefix|) (195 . +) (|Mapping| 8 8 8)
              (|List| 8) (201 . |reduce|) |IPADIC;coerce;$Of;43|
              (|Union| 79 '#1="failed")
              (|Record| (|:| |coef1| $) (|:| |coef2| $) (|:| |generator| $))
              (|Record| (|:| |coef1| $) (|:| |coef2| $)) (|Union| 88 '#1#)
              (|Record| (|:| |coef| 79) (|:| |generator| $))
              (|SparseUnivariatePolynomial| $)
              (|Record| (|:| |unit| $) (|:| |canonical| $) (|:| |associate| $))
              (|String|) (|SingleInteger|))
           '#(~= 207 |zero?| 213 |unitNormal| 218 |unitCanonical| 223 |unit?|
              228 |subtractIfCan| 233 |sqrt| 239 |sizeLess?| 245 |sample| 251
              |root| 255 |rem| 261 |recip| 267 |quotientByP| 272 |quo| 277
              |principalIdeal| 283 |order| 288 |one?| 293 |multiEuclidean| 298
              |modulus| 304 |moduloP| 308 |lcm| 313 |latex| 324 |hash| 329
              |gcdPolynomial| 334 |gcd| 340 |extendedEuclidean| 351 |extend|
              364 |exquo| 370 |expressIdealMember| 376 |euclideanSize| 382
              |divide| 387 |digits| 393 |complete| 398 |coerce| 403
              |characteristic| 418 |associates?| 422 |approximate| 428 ^ 434
              |Zero| 446 |One| 450 = 454 - 460 + 471 * 477)
           'NIL
           (CONS
            (|makeByteWordVec2| 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 0))
            (CONS
             '#(NIL |EuclideanDomain&| NIL |GcdDomain&| |IntegralDomain&|
                |Algebra&| NIL NIL NIL |Module&| NIL |Ring&| NIL NIL NIL
                |AbelianGroup&| NIL NIL |AbelianMonoid&| |Monoid&| NIL
                |SemiGroup&| |AbelianSemiGroup&| |SetCategory&| NIL NIL NIL
                |BasicType&| NIL)
             (CONS
              '#((|PAdicIntegerCategory| 6) (|EuclideanDomain|)
                 (|PrincipalIdealDomain|) (|GcdDomain|) (|IntegralDomain|)
                 (|Algebra| $$) (|CommutativeRing|) (|CharacteristicZero|)
                 (|EntireRing|) (|Module| $$) (|BiModule| $$ $$) (|Ring|)
                 (|LeftModule| $$) (|Rng|) (|RightModule| $$) (|AbelianGroup|)
                 (|CancellationAbelianMonoid|) (|SemiRing|) (|AbelianMonoid|)
                 (|Monoid|) (|SemiRng|) (|SemiGroup|) (|AbelianSemiGroup|)
                 (|SetCategory|) (|noZeroDivisors|) (|CommutativeStar|)
                 (|unitsKnown|) (|BasicType|) (|CoercibleTo| 8))
              (|makeByteWordVec2| 94
                                  '(1 9 8 0 10 2 12 0 0 9 20 1 12 0 0 22 2 9 0
                                    0 0 24 2 9 0 0 0 25 2 9 0 0 0 26 1 12 28 0
                                    29 1 12 9 0 30 1 12 0 0 32 1 17 0 0 37 0 17
                                    0 39 2 17 0 9 0 40 0 9 0 41 2 9 28 0 0 42 0
                                    8 0 43 1 17 0 44 45 2 9 0 0 0 46 2 12 0 9 0
                                    47 2 9 0 0 0 48 2 9 0 9 0 52 1 17 0 0 55 2
                                    9 0 0 0 61 2 9 0 62 0 63 1 12 0 44 64 2 66
                                    9 0 9 67 2 9 56 0 0 68 1 9 0 0 69 1 66 0 0
                                    70 2 8 0 0 0 72 1 8 0 0 73 2 8 0 0 0 74 1
                                    12 28 0 75 2 12 28 0 0 76 1 12 28 0 77 1 13
                                    8 0 78 2 8 0 0 79 80 2 8 0 0 0 81 2 83 8 82
                                    0 84 2 0 28 0 0 1 1 0 28 0 1 1 0 92 0 1 1 0
                                    0 0 1 1 0 28 0 1 2 0 56 0 0 1 2 0 0 0 9 65
                                    2 0 28 0 0 1 0 0 0 1 2 0 0 66 9 71 2 0 0 0
                                    0 1 1 0 56 0 57 1 0 0 0 33 2 0 0 0 0 1 1 0
                                    90 79 1 1 0 13 0 15 1 0 28 0 1 2 0 86 79 0
                                    1 0 0 9 27 1 0 9 0 31 2 0 0 0 0 1 1 0 0 79
                                    1 1 0 93 0 1 1 0 94 0 1 2 0 91 91 91 1 2 0
                                    0 0 0 1 1 0 0 79 1 2 0 87 0 0 1 3 0 89 0 0
                                    0 1 2 0 0 0 9 21 2 0 56 0 0 58 2 0 86 79 0
                                    1 1 0 13 0 16 2 0 59 0 0 60 1 0 17 0 18 1 0
                                    0 0 23 1 0 0 0 1 1 0 0 9 51 1 0 8 0 85 0 0
                                    13 14 2 0 28 0 0 1 2 0 9 0 9 35 2 0 0 0 13
                                    1 2 0 0 0 62 1 0 0 0 34 0 0 0 19 2 0 28 0 0
                                    38 2 0 0 0 0 36 1 0 0 0 50 2 0 0 0 0 49 2 0
                                    0 9 0 53 2 0 0 0 0 54 2 0 0 13 0 1 2 0 0 62
                                    0 1)))))
           '|lookupComplete|)) 
