/usr/share/axiom-20170501/src/algebra/PFO.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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | )abbrev package PFO PointsOfFiniteOrder
++ Author: Manuel Bronstein
++ Date Created: 1988
++ Date Last Updated: 22 July 1998
++ Description:
++ This package provides function for testing whether a divisor on a
++ curve is a torsion divisor.
PointsOfFiniteOrder(R0, F, UP, UPUP, R) : SIG == CODE where
R0 : Join(OrderedSet, IntegralDomain, RetractableTo Integer)
F : FunctionSpace R0
UP : UnivariatePolynomialCategory F
UPUP : UnivariatePolynomialCategory Fraction UP
R : FunctionFieldCategory(F, UP, UPUP)
PI ==> PositiveInteger
N ==> NonNegativeInteger
Z ==> Integer
Q ==> Fraction Integer
UPF ==> SparseUnivariatePolynomial F
UPQ ==> SparseUnivariatePolynomial Q
QF ==> Fraction UP
UPUPQ ==> SparseUnivariatePolynomial Fraction UPQ
UP2 ==> SparseUnivariatePolynomial UPQ
UP3 ==> SparseUnivariatePolynomial UP2
FD ==> FiniteDivisor(F, UP, UPUP, R)
K ==> Kernel F
REC ==> Record(ncurve:UP3, disc:Z, dfpoly:UPQ)
RC0 ==> Record(ncurve:UPUPQ, disc:Z)
ID ==> FractionalIdeal(UP, QF, UPUP, R)
SMP ==> SparseMultivariatePolynomial(R0,K)
ALGOP ==> "%alg"
SIG ==> with
order : FD -> Union(N, "failed")
++ order(f) \undocumented
torsion? : FD -> Boolean
++ torsion?(f) \undocumented
torsionIfCan : FD -> Union(Record(order:N, function:R), "failed")
++ torsionIfCan(f)\ undocumented
CODE ==> add
import IntegerPrimesPackage(Z)
import PointsOfFiniteOrderTools(UPQ, UPUPQ)
import UnivariatePolynomialCommonDenominator(Z, Q, UPQ)
cmult: List SMP -> SMP
raise : (UPQ, K) -> F
raise2 : (UP2, K) -> UP
qmod : F -> Q
fmod : UPF -> UPQ
rmod : UP -> UPQ
pmod : UPUP -> UPUPQ
kqmod : (F, K) -> UPQ
krmod : (UP, K) -> UP2
kpmod : (UPUP, K) -> UP3
selectIntegers: K -> REC
selIntegers: () -> RC0
possibleOrder : FD -> N
ratcurve : (FD, RC0) -> N
algcurve : (FD, REC, K) -> N
kbad3Num : (UP3, UPQ) -> Z
kbadBadNum : (UP2, UPQ) -> Z
kgetGoodPrime : (REC, UPQ, UP3, UP2,UP2) -> Record(prime:PI,poly:UPQ)
goodRed : (REC, UPQ, UP3, UP2, UP2, PI) -> Union(UPQ, "failed")
good? : (UPQ, UP3, UP2, UP2, PI, UPQ) -> Boolean
klist : UP -> List K
aklist : R -> List K
alglist : FD -> List K
notIrr? : UPQ -> Boolean
rat : (UPUP, FD, PI) -> N
toQ1 : (UP2, UPQ) -> UP
toQ2 : (UP3, UPQ) -> R
Q2F : Q -> F
Q2UPUP : UPUPQ -> UPUP
q := FunctionSpaceReduce(R0, F)
torsion? d == order(d) case N
Q2F x == numer(x)::F / denom(x)::F
qmod x == bringDown(x)$q
kqmod(x,k) == bringDown(x, k)$q
fmod p == map(qmod, p)$SparseUnivariatePolynomialFunctions2(F, Q)
pmod p == map(qmod, p)$MultipleMap(F, UP, UPUP, Q, UPQ, UPUPQ)
Q2UPUP p == map(Q2F, p)$MultipleMap(Q, UPQ, UPUPQ, F, UP, UPUP)
klist d == "setUnion"/[kernels c for c in coefficients d]
notIrr? d == #(factors factor(d)$RationalFactorize(UPQ)) > 1
kbadBadNum(d, m) == mix [badNum(c rem m) for c in coefficients d]
kbad3Num(h, m) == lcm [kbadBadNum(c, m) for c in coefficients h]
torsionIfCan d ==
zero?(n := possibleOrder(d := reduce d)) => "failed"
(g := generator reduce(n::Z * d)) case "failed" => "failed"
[n, g::R]
UPQ2F(p:UPQ, k:K):F ==
map(Q2F, p)$UnivariatePolynomialCategoryFunctions2(Q, UPQ, F, UP) (k::F)
UP22UP(p:UP2, k:K):UP ==
map((p1:UPQ):F +-> UPQ2F(p1, k), p)_
$UnivariatePolynomialCategoryFunctions2(UPQ,UP2,F,UP)
UP32UPUP(p:UP3, k:K):UPUP ==
map((p1:UP2):QF +-> UP22UP(p1,k)::QF,p)_
$UnivariatePolynomialCategoryFunctions2(UP2, UP3, QF, UPUP)
if R0 has GcdDomain then
cmult(l:List SMP):SMP == lcm l
else
cmult(l:List SMP):SMP == */l
doubleDisc(f:UP3):Z ==
d := discriminant f
g := gcd(d, differentiate d)
d := (d exquo g)::UP2
zero?(e := discriminant d) => 0
gcd [retract(c)@Z for c in coefficients e]
commonDen(p:UP):SMP ==
l1:List F := coefficients p
l2:List SMP := [denom c for c in l1]
cmult l2
polyred(f:UPUP):UPUP ==
cmult([commonDen(retract(c)@UP) for c in coefficients f])::F::UP::QF * f
aklist f ==
(r := retractIfCan(f)@Union(QF, "failed")) case "failed" =>
"setUnion"/[klist(retract(c)@UP) for c in coefficients lift f]
klist(retract(r::QF)@UP)
alglist d ==
n := numer(i := ideal d)
select_!((k1:K):Boolean +-> has?(operator k1, ALGOP),
setUnion(klist denom i,
"setUnion"/[aklist qelt(n,i) for i in minIndex n..maxIndex n]))
krmod(p,k) ==
map(z1 +-> kqmod(z1, k),
p)$UnivariatePolynomialCategoryFunctions2(F, UP, UPQ, UP2)
rmod p ==
map(qmod, p)$UnivariatePolynomialCategoryFunctions2(F, UP, Q, UPQ)
raise(p, k) ==
(map(Q2F, p)$SparseUnivariatePolynomialFunctions2(Q, F)) (k::F)
raise2(p, k) ==
map(z1 +-> raise(z1, k),
p)$UnivariatePolynomialCategoryFunctions2(UPQ, UP2, F, UP)
algcurve(d, rc, k) ==
mn := minIndex(n := numer(i := minimize ideal d))
h := kpmod(lift(hh := n(mn + 1)), k)
b2 := primitivePart
raise2(b := krmod(retract(retract(n.mn)@QF)@UP, k), k)
s := kqmod(resultant(primitivePart separate(raise2(krmod(
retract(norm hh)@UP, k), k), b2).primePart, b2), k)
pr := kgetGoodPrime(rc, s, h, b, dd := krmod(denom i, k))
p := pr.prime
pp := UP32UPUP(rc.ncurve, k)
mm := pr.poly
gf := InnerPrimeField p
m := map((z1:Q):gf +-> retract(z1)@Z :: gf,mm)_
$SparseUnivariatePolynomialFunctions2(Q, gf)
(degree m = 1) =>
alpha := - coefficient(m, 0) / leadingCoefficient m
order(d, pp,
(z1:F):gf +-> (map((q1:Q):gf +-> numer(q1)::gf / denom(q1)::gf,
kqmod(z1,k))$SparseUnivariatePolynomialFunctions2(Q,gf))(alpha)
)$ReducedDivisor(F, UP, UPUP, R, gf)
sae:= SimpleAlgebraicExtension(gf,SparseUnivariatePolynomial gf,m)
order(d, pp,
(z1:F):sae +-> reduce(map((q1:Q):gf +-> numer(q1)::gf / denom(q1)::gf,
kqmod(z1,k))$SparseUnivariatePolynomialFunctions2(Q,gf))$sae
)$ReducedDivisor(F, UP, UPUP, R, sae)
-- returns the potential order of d, 0 if d is of infinite order
ratcurve(d, rc) ==
mn := minIndex(nm := numer(i := minimize ideal d))
h := pmod lift(hh := nm(mn + 1))
b := rmod(retract(retract(nm.mn)@QF)@UP)
s := separate(rmod(retract(norm hh)@UP), b).primePart
bd := badNum rmod denom i
r := resultant(s, b)
bad := lcm [rc.disc, numer r,denom r, bd.den*bd.gcdnum, badNum h]$List(Z)
pp := Q2UPUP(rc.ncurve)
n := rat(pp, d, p := getGoodPrime bad)
-- if n > 1 then it's cheaper to compute the order modulo a second prime,
-- since computing n * d could be very expensive
(n = 1) => n
m := rat(pp, d, getGoodPrime(p * bad))
n = m => n
0
-- returns the order of d mod p
rat(pp, d, p) ==
gf := InnerPrimeField p
order(d, pp,
(q1:F):gf +-> (qq := qmod q1;numer(qq)::gf / denom(qq)::gf)
)$ReducedDivisor(F, UP, UPUP, R, gf)
-- returns the potential order of d, 0 if d is of infinite order
possibleOrder d ==
zero?(genus()) or (#(numer ideal d) = 1) => 1
empty?(la := alglist d) => ratcurve(d, selIntegers())
not(empty? rest la) =>
error "PFO::possibleOrder: more than 1 algebraic constant"
algcurve(d, selectIntegers first la, first la)
selIntegers():RC0 ==
f := definingPolynomial()$R
while zero?(d := doubleDisc(r := polyred pmod f)) repeat newReduc()$q
[r, d]
selectIntegers(k:K):REC ==
g := polyred(f := definingPolynomial()$R)
p := minPoly k
while zero?(d := doubleDisc(r := kpmod(g, k))) or (notIrr? fmod p)
repeat newReduc()$q
[r, d, splitDenominator(fmod p).num]
toQ1(p, d) ==
map((p1:UPQ):F +-> Q2F(retract(p1 rem d)@Q),
p)$UnivariatePolynomialCategoryFunctions2(UPQ, UP2, F, UP)
toQ2(p, d) ==
reduce map((p1:UP2):QF +-> toQ1(p1, d)::QF,
p)$UnivariatePolynomialCategoryFunctions2(UP2, UP3, QF, UPUP)
kpmod(p, k) ==
map((p1:QF):UP2 +-> krmod(retract(p1)@UP, k),
p)$UnivariatePolynomialCategoryFunctions2(QF, UPUP, UP2, UP3)
order d ==
zero?(n := possibleOrder(d := reduce d)) => "failed"
principal? reduce(n::Z * d) => n
"failed"
kgetGoodPrime(rec, res, h, b, d) ==
p:PI := 3
while (u := goodRed(rec, res, h, b, d, p)) case "failed" repeat
p := nextPrime(p::Z)::PI
[p, u::UPQ]
goodRed(rec, res, h, b, d, p) ==
zero?(rec.disc rem p) => "failed"
gf := InnerPrimeField p
l := [f.factor for f in factors
factor(map((z1:Q):gf +-> retract(z1)@Z :: gf,
rec.dfpoly)$SparseUnivariatePolynomialFunctions2(Q,
gf))$DistinctDegreeFactorize(gf,
SparseUnivariatePolynomial gf) | (f.exponent = 1)]
empty? l => "failed"
mdg := first l
for ff in rest l repeat
if degree(ff) < degree(mdg) then mdg := ff
md := map((z1:gf):Q +-> convert(z1)@Z :: Q,
mdg)$SparseUnivariatePolynomialFunctions2(gf, Q)
good?(res, h, b, d, p, md) => md
"failed"
good?(res, h, b, d, p, m) ==
bd := badNum(res rem m)
not (zero?(bd.den rem p) or zero?(bd.gcdnum rem p) or
zero?(kbadBadNum(b,m) rem p) or zero?(kbadBadNum(d,m) rem p)
or zero?(kbad3Num(h, m) rem p))
|