/usr/share/axiom-20170501/src/algebra/MODRING.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 | )abbrev domain MODRING ModularRing
++ Author: P.Gianni, B.Trager
++ Description:
++ These domains are used for the factorization and gcds
++ of univariate polynomials over the integers in order to work modulo
++ different primes.
++ See \spadtype{EuclideanModularRing} ,\spadtype{ModularField}
ModularRing(R,Mod,reduction,merge,exactQuo) : SIG == CODE where
R : CommutativeRing
Mod : AbelianMonoid
reduction : (R,Mod) -> R
merge : (Mod,Mod) -> Union(Mod,"failed")
exactQuo : (R,R,Mod) -> Union(R,"failed")
SIG ==> Ring with
modulus : % -> Mod
++ modulus(x) is not documented
coerce : % -> R
++ coerce(x) is not documented
reduce : (R,Mod) -> %
++ reduce(r,m) is not documented
exQuo : (%,%) -> Union(%,"failed")
++ exQuo(x,y) is not documented
recip : % -> Union(%,"failed")
++ recip(x) is not documented
inv : % -> %
++ inv(x) is not documented
CODE ==> add
Rep:= Record(val:R,modulo:Mod)
x,y: %
modulus(x) == x.modulo
coerce(x) == x.val
coerce(i:Integer):% == [i::R,0]$Rep
i:Integer * x:% == (i::%)*x
coerce(x):OutputForm == (x.val)::OutputForm
reduce (a:R,m:Mod) == [reduction(a,m),m]$Rep
characteristic():NonNegativeInteger == characteristic()$R
0 == [0$R,0$Mod]$Rep
1 == [1$R,0$Mod]$Rep
zero? x == zero? x.val
one? x == (x.val = 1)
newmodulo(m1:Mod,m2:Mod) : Mod ==
r:=merge(m1,m2)
r case "failed" => error "incompatible moduli"
r::Mod
x=y ==
x.val = y.val => true
x.modulo = y.modulo => false
(x-y).val = 0
x+y == reduce((x.val +$R y.val),newmodulo(x.modulo,y.modulo))
x-y == reduce((x.val -$R y.val),newmodulo(x.modulo,y.modulo))
-x == reduce ((-$R x.val),x.modulo)
x*y == reduce((x.val *$R y.val),newmodulo(x.modulo,y.modulo))
exQuo(x,y) ==
xm:=x.modulo
if xm ^=$Mod y.modulo then xm:=newmodulo(xm,y.modulo)
r:=exactQuo(x.val,y.val,xm)
r case "failed"=> "failed"
[r::R,xm]$Rep
--if R has EuclideanDomain then
recip x ==
r:=exactQuo(1$R,x.val,x.modulo)
r case "failed" => "failed"
[r,x.modulo]$Rep
inv x ==
if (u:=recip x) case "failed" then error("not invertible")
else u::%
|