/usr/share/axiom-20170501/src/algebra/DIRRING.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 | )abbrev domain DIRRING DirichletRing
++ Author: Martin Rubey
++ Description:
++ DirichletRing is the ring of arithmetical functions
++ with Dirichlet convolution as multiplication
DirichletRing(Coef) : SIG == CODE where
Coef : Ring
PI ==> PositiveInteger
FUN ==> PI -> Coef
SIG ==> Join(Ring, Eltable(PI, Coef)) with
if Coef has CommutativeRing then
IntegralDomain
if Coef has CommutativeRing then
Algebra Coef
coerce : FUN -> %
coerce : % -> FUN
coerce : Stream Coef -> %
coerce : % -> Stream Coef
zeta : constant -> %
++ zeta() returns the function which is constantly one
multiplicative? : (%, PI) -> Boolean
++ multiplicative?(a, n) returns true if the first
++ n coefficients of a are multiplicative
additive? : (%, PI) -> Boolean
++ additive?(a, n) returns true if the first
++ n coefficients of a are additive
CODE ==> add
Rep := Record(function: FUN)
per(f: Rep): % == f pretend %
rep(a: %): Rep == a pretend Rep
elt(a: %, n: PI): Coef ==
f: FUN := (rep a).function
f n
coerce(a: %): FUN == (rep a).function
coerce(f: FUN): % == per [f]
indices: Stream Integer
:= integers(1)$StreamTaylorSeriesOperations(Integer)
coerce(a: %): Stream Coef ==
f: FUN := (rep a).function
map((n: Integer): Coef +-> f(n::PI), indices)
$StreamFunctions2(Integer, Coef)
coerce(f: Stream Coef): % ==
((n: PI): Coef +-> f.(n::Integer))::%
coerce(f: %): OutputForm == f::Stream Coef::OutputForm
1: % ==
((n: PI): Coef +-> (if one? n then 1$Coef else 0$Coef))::%
0: % ==
((n: PI): Coef +-> 0$Coef)::%
zeta: % ==
((n: PI): Coef +-> 1$Coef)::%
(f: %) + (g: %) ==
((n: PI): Coef +-> f(n)+g(n))::%
- (f: %) ==
((n: PI): Coef +-> -f(n))::%
(a: Integer) * (f: %) ==
((n: PI): Coef +-> a*f(n))::%
(a: Coef) * (f: %) ==
((n: PI): Coef +-> a*f(n))::%
import IntegerNumberTheoryFunctions
(f: %) * (g: %) ==
conv := (n: PI): Coef +-> _
reduce((a: Coef, b: Coef): Coef +-> a + b, _
[f(d::PI) * g((n quo d)::PI) for d in divisors(n::Integer)], 0)
$ListFunctions2(Coef, Coef)
conv::%
unit?(a: %): Boolean == not (recip(a(1$PI))$Coef case "failed")
qrecip: (%, Coef, PI) -> Coef
qrecip(f: %, f1inv: Coef, n: PI): Coef ==
if one? n then f1inv
else
-f1inv * reduce(_+, [f(d::PI) * qrecip(f, f1inv, (n quo d)::PI) _
for d in rest divisors(n)], 0) _
$ListFunctions2(Coef, Coef)
recip f ==
if (f1inv := recip(f(1$PI))$Coef) case "failed" then "failed"
else
mp := (n: PI): Coef +-> qrecip(f, f1inv, n)
mp::%::Union(%, "failed")
multiplicative?(a, n) ==
for i in 2..n repeat
fl := factors(factor i)$Factored(Integer)
rl := [a.(((f.factor)::PI)**((f.exponent)::PI)) for f in fl]
if a.(i::PI) ~= reduce((r:Coef, s:Coef):Coef +-> r*s, rl)
then
output(i::OutputForm)$OutputPackage
output(rl::OutputForm)$OutputPackage
return false
true
additive?(a, n) ==
for i in 2..n repeat
fl := factors(factor i)$Factored(Integer)
rl := [a.(((f.factor)::PI)**((f.exponent)::PI)) for f in fl]
if a.(i::PI) ~= reduce((r:Coef, s:Coef):Coef +-> r+s, rl)
then
output(i::OutputForm)$OutputPackage
output(rl::OutputForm)$OutputPackage
return false
true
|