This file is indexed.

/usr/share/axiom-20170501/src/algebra/LAUPOL.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
)abbrev domain LAUPOL LaurentPolynomial
++ Author: Manuel Bronstein
++ Date Created: May 1988
++ Date Last Updated: 26 Apr 1990
++ Description:
++ Univariate polynomials with negative and positive exponents.

LaurentPolynomial(R, UP) : SIG == CODE where
  R : IntegralDomain
  UP : UnivariatePolynomialCategory R
 
  O   ==> OutputForm
  B   ==> Boolean
  N   ==> NonNegativeInteger
  Z   ==> Integer
  RF  ==> Fraction UP
 
  SIG ==> Join(DifferentialExtension UP, IntegralDomain,
          ConvertibleTo RF, FullyRetractableTo R, RetractableTo UP) with

    monomial? : %  -> B
      ++ monomial?(x) is not documented

    degree : %  -> Z
      ++ degree(x) is not documented

    order : %  -> Z
      ++ order(x) is not documented
      ++
      ++X w:SparseUnivariateLaurentSeries(Fraction(Integer),'z,0):=0
      ++X order(w,0)

    reductum : %  -> %
      ++ reductum(x) is not documented

    leadingCoefficient : %  -> R
      ++ leadingCoefficient(p) is not documented

    trailingCoefficient : %  -> R
      ++ trailingCoefficient(p) is not documented

    coefficient : (%, Z) -> R
      ++ coefficient(x,n) is not documented

    monomial : (R, Z) -> %
      ++ monomial(x,n) is not documented

    if R has CharacteristicZero then CharacteristicZero

    if R has CharacteristicNonZero then CharacteristicNonZero

    if R has Field then

      EuclideanDomain

      separate : RF -> Record(polyPart:%, fracPart:RF)
        ++ separate(x) is not documented
 
  CODE ==> add

    Rep := Record(polypart: UP, order0: Z)
 
    poly   : %  -> UP
    check0 : (Z, UP) -> %
    mkgpol : (Z, UP) -> %
    gpol   : (UP, Z) -> %
    toutput: (R, Z, O) -> O
    monTerm: (R, Z, O) -> O
 
    0                == [0, 0]

    1                == [1, 0]

    p = q            == p.order0 = q.order0 and p.polypart = q.polypart

    poly p           == p.polypart

    order p          == p.order0

    gpol(p, n)       == [p, n]

    monomial(r, n)   == check0(n, r::UP)

    coerce(p:UP):%   == mkgpol(0, p)

    reductum p       == check0(order p, reductum poly p)

    n:Z * p:%        == check0(order p, n * poly p)

    characteristic() == characteristic()$R

    coerce(n:Z):%    == n::R::%

    degree p         == degree(poly p)::Z + order p

    monomial? p      == monomial? poly p

    coerce(r:R):%    == gpol(r::UP, 0)

    convert(p:%):RF  == poly(p) * (monomial(1, 1)$UP)::RF ** order p

    p:% * q:%        == check0(order p + order q, poly p * poly q)

    - p              == gpol(- poly p, order p)

    check0(n, p)     == (zero? p => 0; gpol(p, n))

    trailingCoefficient p   == coefficient(poly p, 0)

    leadingCoefficient p    == leadingCoefficient poly p
 
    coerce(p:%):O ==
      zero? p => 0::Z::O
      l := nil()$List(O)
      v := monomial(1, 1)$UP :: O
      while p ^= 0 repeat
        l := concat(l, toutput(leadingCoefficient p, degree p, v))
        p := reductum p
      reduce("+", l)
 
    coefficient(p, n) ==
      (m := n - order p) < 0 => 0
      coefficient(poly p, m::N)
 
    differentiate(p:%, derivation:UP -> UP) ==
      t := monomial(1, 1)$UP
      mkgpol(order(p) - 1,
              derivation(poly p) * t + order(p) * poly(p) * derivation t)
 
    monTerm(r, n, v) ==
      zero? n => r::O
      (n = 1) => v
      v ** (n::O)
 
    toutput(r, n, v) ==
      mon := monTerm(r, n, v)
      zero? n or (r = 1) => mon
      r = -1 => - mon
      r::O * mon
 
    recip p ==
      (q := recip poly p) case "failed" => "failed"
      gpol(q::UP, - order p)
 
    p + q ==
      zero? q => p
      zero? p => q
      (d := order p - order q) > 0 =>
                      gpol(poly(p) * monomial(1, d::N) + poly q, order q)
      d < 0 => gpol(poly(p) + poly(q) * monomial(1, (-d)::N), order p)
      mkgpol(order p, poly(p) + poly q)
 
    mkgpol(n, p) ==
      zero? p => 0
      d := order(p, monomial(1, 1)$UP)
      gpol((p exquo monomial(1, d))::UP, n + d::Z)
 
    p exquo q ==
      (r := poly(p) exquo poly q) case "failed" => "failed"
      check0(order p - order q, r::UP)
 
    retractIfCan(p:%):Union(UP, "failed") ==
      order(p) < 0 => error "Not retractable"
      poly(p) * monomial(1, order(p)::N)$UP
 
    retractIfCan(p:%):Union(R, "failed") ==
      order(p) ^= 0 => "failed"
      retractIfCan poly p
 
    if R has Field then

      gcd(p, q) == gcd(poly p, poly q)::%
 
      separate f ==
        n  := order(q := denom f, monomial(1, 1))
        q  := (q exquo (tn := monomial(1, n)$UP))::UP
        bc := extendedEuclidean(tn,q,numer f)::Record(coef1:UP,coef2:UP)
        qr := divide(bc.coef1, q)
        [mkgpol(-n, bc.coef2 + tn * qr.quotient), qr.remainder / q]
 
      -- returns (z, r) s.t. p = q z + r,
      -- and degree(r) < degree(q), order(r) >= min(order(p), order(q))
      divide(p, q) ==
        c  := min(order p, order q)
        qr := divide(poly(p) * monomial(1, (order p - c)::N)$UP, poly q)
        [mkgpol(c - order q, qr.quotient), mkgpol(c, qr.remainder)]
 
      euclideanSize p == degree poly p

      extendedEuclidean(a, b, c) ==
        (bc := extendedEuclidean(poly a, poly b, poly c)) case "failed"
          => "failed"
        [mkgpol(order c - order a, bc.coef1),
                                     mkgpol(order c - order b, bc.coef2)]