This file is indexed.

/usr/share/axiom-20170501/src/algebra/TWOFACT.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
)abbrev package TWOFACT TwoFactorize
++ Authors : P.Gianni, J.H.Davenport
++ Date Created : May 1990
++ Date Last Updated: March 1992
++ Description:
++ A basic package for the factorization of bivariate polynomials 
++ over a finite field.
++ The functions here represent the base step for the multivariate factorizer.
 
TwoFactorize(F) : SIG == CODE where
  F : FiniteFieldCategory

  SUP   ==>  SparseUnivariatePolynomial
  R     ==>  SUP F
  P     ==>  SUP R
  UPCF2 ==>  UnivariatePolynomialCategoryFunctions2
 
  SIG ==> with

    generalTwoFactor : (P) -> Factored P 
      ++ generalTwoFactor(p) returns the factorisation of polynomial p,
      ++ a sparse univariate polynomial (sup) over a
      ++ sup over F.

    generalSqFr : (P) ->  Factored P 
      ++ generalSqFr(p) returns the square-free factorisation of polynomial p,
      ++ a sparse univariate polynomial (sup) over a
      ++ sup over F.

    twoFactor : (P,Integer) -> Factored P 
      ++ twoFactor(p,n) returns the factorisation of polynomial p,
      ++ a sparse univariate polynomial (sup) over a
      ++ sup over F. 
      ++ Also, p is assumed primitive and square-free and n is the 
      ++ degree of the inner variable of p (maximum of the degrees
      ++ of the coefficients of p).
 
  CODE ==> add

    PI ==> PositiveInteger
    NNI ==> NonNegativeInteger
    import CommuteUnivariatePolynomialCategory(F,R,P)

                   ----  Local Functions  ----
    computeDegree  :  (P,Integer,Integer) -> PI
    exchangeVars   :           P          -> P
    exchangeVarTerm:        (R, NNI)      -> P
    pthRoot        :     (R, NNI, NNI)    -> R
 
    -- compute the degree of the extension to reduce the polynomial to a
    -- univariate one
    computeDegree(m : P,mx:Integer,q:Integer): PI ==
      my:=degree m
      n1:Integer:=length(10*mx*my)
      n2:Integer:=length(q)-1
      n:=(n1 quo n2)+1
      n::PI
 
    exchangeVars(p : P) : P ==
       p = 0 => 0
       exchangeVarTerm(leadingCoefficient p, degree p) +
          exchangeVars(reductum p)

    exchangeVarTerm(c:R, e:NNI) : P ==
       c = 0 => 0
       monomial(monomial(leadingCoefficient c, e)$R, degree c)$P + 
          exchangeVarTerm(reductum c, e)

    pthRoot(poly:R,p:NonNegativeInteger,PthRootPow:NonNegativeInteger):R ==
       tmp:=divideExponents(map((x:F):F+->(x::F)**PthRootPow,poly),p)
       tmp case "failed" => error "consistency error in TwoFactor"
       tmp
 
    fUnion ==> Union("nil", "sqfr", "irred", "prime")
    FF     ==> Record(flg:fUnion, fctr:P, xpnt:Integer)

    generalSqFr(m:P): Factored P ==
       m = 0 => 0
       degree m = 0 =>
         l:=squareFree(leadingCoefficient m)
         makeFR(unit(l)::P,[[u.flg,u.fctr::P,u.xpnt] for u in factorList l])
       cont := content m
       m := (m exquo cont)::P
       sqfrm := squareFree m
       pfaclist : List FF := empty()
       unitPart := unit sqfrm
       for u in factorList sqfrm repeat
          u.flg = "nil" =>
             uexp:NNI:=(u.xpnt):NNI
             nfacs:=squareFree(exchangeVars u.fctr)
             for v in factorList nfacs repeat
                pfaclist:=cons([v.flg, exchangeVars v.fctr, v.xpnt*uexp],
                              pfaclist)
             unitPart := unit(nfacs)**uexp * unitPart
          pfaclist := cons(u,pfaclist)
       cont ^= 1 =>
           sqp := squareFree cont
           contlist:=[[w.flg,(w.fctr)::P,w.xpnt] for w in factorList sqp]
           pfaclist:= append(contlist, pfaclist)
           makeFR(unit(sqp)*unitPart,pfaclist)
       makeFR(unitPart,pfaclist)

        
    generalTwoFactor(m:P): Factored P ==
       m = 0 => 0
       degree m = 0 =>
         l:=factor(leadingCoefficient m)$DistinctDegreeFactorize(F,R)
         makeFR(unit(l)::P,[[u.flg,u.fctr::P,u.xpnt] for u in factorList l])
       ll:List FF
       ll:=[]
       unitPart:P
       cont:=content m
       if degree(cont)>0 then 
          m1:=m exquo cont
          m1 case "failed" => error "content doesn't divide"
          m:=m1
          contfact:=factor(cont)$DistinctDegreeFactorize(F,R)
          unitPart:=(unit contfact)::P
          ll:=[[w.flg,(w.fctr)::P,w.xpnt] for w in factorList contfact]
       else
          unitPart:=cont::P
       sqfrm:=squareFree m
       for u in factors sqfrm repeat
           expo:=u.exponent
           if expo < 0 then error "negative exponent in a factorisation"
           expon:NonNegativeInteger:=expo::NonNegativeInteger
           fac:=u.factor
           degree fac = 1 => ll:=[["irred",fac,expon],:ll]
           differentiate fac = 0 =>      
              -- the polynomial is  inseparable w.r.t. its main variable
              map(differentiate,fac) = 0 =>
                p:=characteristic$F
                PthRootPow:=(size$F exquo p)::NonNegativeInteger
                m1:=divideExponents(map(x+->pthRoot(x,p,PthRootPow),fac),p)
                m1 case "failed" => error "consistency error in TwoFactor"
                res:=generalTwoFactor m1
                unitPart:=unitPart*unit(res)**((p*expon)::NNI)
                ll:=
                 [:[[v.flg,v.fctr,expon*p*v.xpnt] for v in factorList res],:ll]
              m2:=generalTwoFactor swap fac
              unitPart:=unitPart*unit(m2)**(expon::NNI)
              ll:=
               [:[[v.flg,swap v.fctr,expon*v.xpnt] for v in factorList m2],:ll]
           ydeg:="max"/[degree w for w in coefficients fac]
           twoF:=twoFactor(fac,ydeg)
           unitPart:=unitPart*unit(twoF)**expon
           ll:=[:[[v.flg,v.fctr,expon*v.xpnt] for v in factorList twoF],
                :ll]
       makeFR(unitPart,ll)
 
    -- factorization of a primitive square-free bivariate polynomial --
    twoFactor(m:P,dx:Integer):Factored P ==
       -- choose the degree for the extension
       n:PI:=computeDegree(m,dx,size()$F)
       -- extend the field
       -- find the substitution for x
       look:Boolean:=true
       dm:=degree m
       try:Integer:=min(5,size()$F)
       i:Integer:=0
       lcm := leadingCoefficient m
       umv : R
       while look and i < try repeat
          vval := random()$F
          i:=i+1
          zero? elt(lcm, vval) => "next value"
          umv := map(x +-> elt(x,vval), m)$UPCF2(R, P, F, R)
          degree(gcd(umv,differentiate umv))^=0 => "next val"
          n := 1
          look := false
       extField:=FiniteFieldExtension(F,n)
       SUEx:=SUP extField
       TP:=SparseUnivariatePolynomial SUEx
       mm:TP:=0
       m1:=m
       while m1^=0 repeat
         mm:=mm+monomial(map(coerce,leadingCoefficient m1)$UPCF2(F,R,
                extField,SUEx),degree m1)
         m1:=reductum m1
       lcmm := leadingCoefficient mm
       val : extField
       umex : SUEx
       if not look then
          val := vval :: extField
          umex := map(coerce, umv)$UPCF2(F, R, extField, SUEx)
       while look repeat
         val:=random()$extField
         i:=i+1
         elt(lcmm,val)=0 => "next value"
         umex := map(x +-> elt(x,val), mm)$UPCF2(SUEx, TP, extField, SUEx)
         degree(gcd(umex,differentiate umex))^=0 => "next val"
         look:=false
       prime:SUEx:=monomial(1,1)-monomial(val,0)
       fumex:=factor(umex)$DistinctDegreeFactorize(extField,SUEx)
       lfact1:=factors fumex

       #lfact1=1 => primeFactor(m,1)
       lfact : List TP :=
          [map(coerce,lf.factor)$UPCF2(extField,SUEx,SUEx,TP)
           for lf in lfact1]
       lfact:=cons(map(coerce,unit fumex)$UPCF2(extField,SUEx,SUEx,TP),
                   lfact)
       import GeneralHenselPackage(SUEx,TP)
       dx1:PI:=(dx+1)::PI
       lfacth:=completeHensel(mm,lfact,prime,dx1)
       lfactk: List P :=[]
       Normp := NormRetractPackage(F, extField, SUEx, TP, n)
      
       while not empty? lfacth repeat
         ff := first lfacth
         lfacth := rest lfacth
         if (c:=leadingCoefficient leadingCoefficient ff) ^=1 then
           ff:=((inv c)::SUEx)* ff
         not ((ffu:= retractIfCan(ff)$Normp) case "failed") =>
                    lfactk := cons(ffu::P, lfactk)
         normfacs := normFactors(ff)$Normp
         lfacth := [g for g in lfacth | not member?(g, normfacs)]
         ffn := */normfacs
         lfactk:=cons(retractIfCan(ffn)$Normp :: P, lfactk)
       */[primeFactor(ff1,1) for ff1 in lfactk]