/usr/share/axiom-20170501/src/algebra/XPR.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 | )abbrev domain XPR XPolynomialRing
++ Author: Michel Petitot petitot@lifl.fr
++ Date Created: 91
++ Date Last Updated: 7 Juillet 92
++ Description:
++ This domain represents generalized polynomials with coefficients
++ (from a not necessarily commutative ring), and words
++ belonging to an arbitrary \spadtype{OrderedMonoid}.
++ This type is used, for instance, by the \spadtype{XDistributedPolynomial}
++ domain constructor where the Monoid is free.
XPolynomialRing(R,E) : SIG == CODE where
R : Ring
E : OrderedMonoid
TERM ==> Record(k: E, c: R)
EX ==> OutputForm
NNI ==> NonNegativeInteger
SIG ==> Join(Ring, XAlgebra(R), FreeModuleCat(R,E)) with
"*" : (%,R) -> %
++ \spad{p*r} returns the product of \spad{p} by \spad{r}.
"#" : % -> NonNegativeInteger
++ \spad{# p} returns the number of terms in \spad{p}.
coerce : E -> %
++ \spad{coerce(e)} returns \spad{1*e}
maxdeg : % -> E
++ \spad{maxdeg(p)} returns the greatest word occurring in the
++ polynomial \spad{p} with a non-zero coefficient.
++ An error is produced if \spad{p} is zero.
mindeg : % -> E
++ \spad{mindeg(p)} returns the smallest word occurring in the
++ polynomial \spad{p} with a non-zero coefficient.
++ An error is produced if \spad{p} is zero.
reductum : % -> %
++ \spad{reductum(p)} returns \spad{p} minus its leading term.
++ An error is produced if \spad{p} is zero.
coef : (%,E) -> R
++ \spad{coef(p,e)} extracts the coefficient of the monomial \spad{e}.
++ Returns zero if \spad{e} is not present.
constant? : % -> Boolean
++ \spad{constant?(p)} tests whether the polynomial \spad{p}
++ belongs to the coefficient ring.
constant : % -> R
++ \spad{constant(p)} return the constant term of \spad{p}.
quasiRegular? : % -> Boolean
++ \spad{quasiRegular?(x)} return true if \spad{constant(p)} is zero.
quasiRegular : % -> %
++ \spad{quasiRegular(x)} return \spad{x} minus its constant term.
map : (R -> R, %) -> %
++ \spad{map(fn,x)} returns \spad{Sum(fn(r_i) w_i)} if \spad{x} writes
++ \spad{Sum(r_i w_i)}.
if R has Field then
"/" : (%,R) -> %
++ \spad{p/r} returns \spad{p*(1/r)}.
--assertions
if R has noZeroDivisors then noZeroDivisors
if R has unitsKnown then unitsKnown
if R has canonicalUnitNormal then canonicalUnitNormal
++ canonicalUnitNormal guarantees that the function
++ unitCanonical returns the same representative for all
++ associates of any particular element.
CODE ==> FreeModule1(R,E) add
--representations
Rep:= List TERM
--uses
repeatMultExpt: (%,NonNegativeInteger) -> %
--define
1 == [[1$E,1$R]]
characteristic == characteristic$R
#x == #$Rep x
maxdeg p == if null p then error " polynome nul !!"
else p.first.k
mindeg p == if null p then error " polynome nul !!"
else (last p).k
coef(p,e) ==
for tm in p repeat
tm.k=e => return tm.c
tm.k < e => return 0$R
0$R
constant? p == (p = 0) or (maxdeg(p) = 1$E)
constant p == coef(p,1$E)
quasiRegular? p == (p=0) or (last p).k ^= 1$E
quasiRegular p ==
quasiRegular?(p) => p
[t for t in p | not(t.k = 1$E)]
recip(p) ==
p=0 => "failed"
p.first.k > 1$E => "failed"
(u:=recip(p.first.c)) case "failed" => "failed"
(u::R)::%
coerce(r:R) == if r=0$R then 0$% else [[1$E,r]]
coerce(n:Integer) == (n::R)::%
if R has noZeroDivisors then
p1:% * p2:% ==
null p1 => 0
null p2 => 0
p1.first.k = 1$E => p1.first.c * p2
p2 = 1 => p1
+/[[[t1.k*t2.k,t1.c*t2.c]$TERM for t2 in p2]
for t1 in p1]
else
p1:% * p2:% ==
null p1 => 0
null p2 => 0
p1.first.k = 1$E => p1.first.c * p2
p2 = 1 => p1
+/[[[t1.k*t2.k,r]$TERM for t2 in p2 | not (r:=t1.c*t2.c) =$R 0]
for t1 in p1]
p:% ** nn:NNI == repeatMultExpt(p,nn)
repeatMultExpt(x,nn) ==
nn = 0 => 1
y:% := x
for i in 2..nn repeat y:= x * y
y
outTerm(r:R, m:E):EX ==
r=1 => m::EX
m=1 => r::EX
r::EX * m::EX
coerce(a:%):EX ==
empty? a => (0$R)::EX
reduce(_+, reverse_! [outTerm(t.c, t.k) for t in a])$List(EX)
if R has Field then
x/r == inv(r)*x
|