/usr/share/axiom-20170501/src/algebra/INT.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 | )abbrev domain INT Integer
++ Author: Mark Botch
++ References:
++ Corl00 According to Abramowitz and Stegun or arccoth needn't be Uncouth
++ Fate01a A Critique of OpenMath and Thoughts on Encoding Mathematics
++ Description:
++ \spadtype{Integer} provides the domain of arbitrary precision integers.
Integer() : SIG == CODE where
SIG ==> Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
random : % -> %
++ random(n) returns a random integer from 0 to \spad{n-1}.
canonical
++ mathematical equality is data structure equality.
canonicalsClosed
++ two positives multiply to give positive.
noetherian
++ ascending chain condition on ideals.
infinite
++ nextItem never returns "failed".
CODE ==> add
ZP ==> SparseUnivariatePolynomial %
ZZP ==> SparseUnivariatePolynomial Integer
x,y: %
n: NonNegativeInteger
writeOMInt(dev: OpenMathDevice, x: %): Void ==
if x < 0 then
OMputApp(dev)
OMputSymbol(dev, "arith1", "unary__minus")
OMputInteger(dev, (-x) pretend Integer)
OMputEndApp(dev)
else
OMputInteger(dev, x pretend Integer)
OMwrite(x: %): String ==
s: String := ""
sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
OMputObject(dev)
writeOMInt(dev, x)
OMputEndObject(dev)
OMclose(dev)
s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
s
OMwrite(x: %, wholeObj: Boolean): String ==
s: String := ""
sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
if wholeObj then
OMputObject(dev)
writeOMInt(dev, x)
if wholeObj then
OMputEndObject(dev)
OMclose(dev)
s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
s
OMwrite(dev: OpenMathDevice, x: %): Void ==
OMputObject(dev)
writeOMInt(dev, x)
OMputEndObject(dev)
OMwrite(dev: OpenMathDevice, x: %, wholeObj: Boolean): Void ==
if wholeObj then
OMputObject(dev)
writeOMInt(dev, x)
if wholeObj then
OMputEndObject(dev)
zero? x ==
ZEROP(x)$Lisp
one? x ==
x = 1
0 ==
0$Lisp
1 ==
1$Lisp
base() ==
2$Lisp
copy x ==
x
inc x ==
x + 1
dec x ==
x - 1
hash x ==
SXHASH(x)$Lisp
negative? x ==
MINUSP(x)$Lisp
coerce(x):OutputForm ==
outputForm(x pretend Integer)
coerce(m:Integer):% ==
m pretend %
convert(x:%):Integer ==
x pretend Integer
length a ==
INTEGER_-LENGTH(a)$Lisp
addmod(a, b, p) ==
(c:=a + b) >= p => c - p
c
submod(a, b, p) ==
(c:=a - b) < 0 => c + p
c
mulmod(a, b, p) ==
(a * b) rem p
convert(x:%):Float ==
coerce(x pretend Integer)$Float
convert(x:%):DoubleFloat ==
coerce(x pretend Integer)$DoubleFloat
convert(x:%):InputForm ==
convert(x pretend Integer)$InputForm
convert(x:%):String ==
string(x pretend Integer)$String
latex(x:%):String ==
s : String := string(x pretend Integer)$String
(-1 < (x pretend Integer)) and ((x pretend Integer) < 10) => s
concat("{", concat(s, "}")$String)$String
positiveRemainder(a, b) ==
negative?(r := a rem b) =>
negative? b => r - b
r + b
r
reducedSystem(m:Matrix %):Matrix(Integer) ==
m pretend Matrix(Integer)
reducedSystem(m:Matrix %, v:Vector %):
Record(mat:Matrix(Integer), vec:Vector(Integer)) ==
[m pretend Matrix(Integer), vec pretend Vector(Integer)]
abs(x) ==
ABS(x)$Lisp
random() ==
random()$Lisp
random(x) ==
RANDOM(x)$Lisp
x = y ==
EQL(x,y)$Lisp
x < y ==
(x<y)$Lisp
- x ==
(-x)$Lisp
x + y ==
(x+y)$Lisp
x - y ==
(x-y)$Lisp
x * y ==
(x*y)$Lisp
(m:Integer) * (y:%) ==
(m*y)$Lisp -- for subsumption problem
x ** n ==
EXPT(x,n)$Lisp
odd? x ==
ODDP(x)$Lisp
max(x,y) ==
MAX(x,y)$Lisp
min(x,y) ==
MIN(x,y)$Lisp
divide(x,y) ==
DIVIDE2(x,y)$Lisp
x quo y ==
QUOTIENT2(x,y)$Lisp
x rem y ==
REMAINDER2(x,y)$Lisp
shift(x, y) ==
ASH(x,y)$Lisp
x exquo y ==
zero? y => "failed"
zero?(x rem y) => x quo y
"failed"
recip(x) ==
if (x = 1) or x=-1 then x else "failed"
gcd(x,y) ==
GCD(x,y)$Lisp
UCA ==> Record(unit:%,canonical:%,associate:%)
unitNormal x ==
x < 0 => [-1,-x,-1]$UCA
[1,x,1]$UCA
unitCanonical x ==
abs x
solveLinearPolynomialEquation(lp:List ZP,p:ZP):Union(List ZP,"failed") ==
solveLinearPolynomialEquation(lp pretend List ZZP,
p pretend ZZP)$IntegerSolveLinearPolynomialEquation pretend
Union(List ZP,"failed")
squareFreePolynomial(p:ZP):Factored ZP ==
squareFree(p)$UnivariatePolynomialSquareFree(%,ZP)
factorPolynomial(p:ZP):Factored ZP ==
-- GaloisGroupFactorizer doesn't factor the content
-- so we have to do this by hand
pp:=primitivePart p
leadingCoefficient pp = leadingCoefficient p =>
factor(p)$GaloisGroupFactorizer(ZP)
mergeFactors(factor(pp)$GaloisGroupFactorizer(ZP),
map((x1:%):ZP+->x1::ZP,
factor((leadingCoefficient p exquo
leadingCoefficient pp)
::%))$FactoredFunctions2(%,ZP)
)$FactoredFunctionUtilities(ZP)
factorSquareFreePolynomial(p:ZP):Factored ZP ==
factorSquareFree(p)$GaloisGroupFactorizer(ZP)
gcdPolynomial(p:ZP, q:ZP):ZP ==
zero? p => unitCanonical q
zero? q => unitCanonical p
gcd([p,q])$HeuGcd(ZP)
|