aboutsummaryrefslogtreecommitdiff
path: root/src/algebra
diff options
context:
space:
mode:
Diffstat (limited to 'src/algebra')
-rw-r--r--src/algebra/catdef.spad.pamphlet16
-rw-r--r--src/algebra/integer.spad.pamphlet20
-rw-r--r--src/algebra/si.spad.pamphlet10
3 files changed, 25 insertions, 21 deletions
diff --git a/src/algebra/catdef.spad.pamphlet b/src/algebra/catdef.spad.pamphlet
index 26aa0469..668b63b7 100644
--- a/src/algebra/catdef.spad.pamphlet
+++ b/src/algebra/catdef.spad.pamphlet
@@ -822,14 +822,14 @@ EuclideanDomain(): Category == PrincipalIdealDomain with
u:= extendedEuclidean(first l,v.generator)
[[u.coef1,:[u.coef2*vv for vv in v.coef]],u.generator]
expressIdealMember(l,z) ==
- z = 0 => just [0 for v in l]
+ zero? z => just [0 for v in l]
pid := principalIdeal l
(q := z exquo (pid.generator)) case "failed" => nothing
just [q*v for v in pid.coef]
multiEuclidean(l,z) ==
n := #l
zero? n => error "empty list passed to multiEuclidean"
- n = 1 => [z]
+ one? n => [z]
l1 := copy l
l2 := split!(l1, n quo 2)
u:= extendedEuclidean(*/l1, */l2, z)
@@ -883,7 +883,7 @@ Field(): Category == Join(EuclideanDomain,UniqueFactorizationDomain,
unitCanonical(x) == if zero? x then x else 1
associates?(x,y) == if zero? x then zero? y else not(zero? y)
inv x ==((u:=recip x) case "failed" => error "not invertible"; u)
- x exquo y == (y=0 => "failed"; x / y)
+ x exquo y == (zero? y => "failed"; x / y)
gcd(x,y) == 1
euclideanSize(x) == 0
prime? x == false
@@ -1001,8 +1001,8 @@ GcdDomain(): Category == IntegralDomain with
++ univariate polynomials over the domain
add
lcm(x: %,y: %) ==
- y = 0 => 0
- x = 0 => 0
+ zero? y => 0
+ zero? x => 0
LCM : Union(%,"failed") := y exquo gcd(x,y)
LCM case % => x * LCM
error "bad gcd in lcm computation"
@@ -1021,9 +1021,9 @@ GcdDomain(): Category == IntegralDomain with
p2:=(p2 exquo monomial(1,e2))::SUP %
e1:=min(e1,e2); c1:=gcd(c1,c2)
p1:=
- degree p1 = 0 or degree p2 = 0 => monomial(c1,0)
+ zero? degree p1 or zero? degree p2 => monomial(c1,0)
p:= subResultantGcd(p1,p2)
- degree p = 0 => monomial(c1,0)
+ zero? degree p => monomial(c1,0)
c2:= gcd(leadingCoefficient p1,leadingCoefficient p2)
unitCanonical(c1 * primitivePart(((c2*p) exquo leadingCoefficient p)::SUP %))
zero? e1 => p1
@@ -2014,7 +2014,7 @@ UniqueFactorizationDomain(): Category == GcdDomain with
squareFreePart x ==
unit(s := squareFree x) * _*/[f.factor for f in factors s]
- prime? x == # factorList factor x = 1
+ prime? x == one?(# factorList factor x)
@
diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet
index 0d7e8f0b..cc3fbff5 100644
--- a/src/algebra/integer.spad.pamphlet
+++ b/src/algebra/integer.spad.pamphlet
@@ -88,6 +88,7 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
import %iabs: % -> % from Foreign Builtin
import %irandom: % -> % from Foreign Builtin
import %iodd?: % -> Boolean from Foreign Builtin
+ import %ieven?: % -> Boolean from Foreign Builtin
import %hash: % -> SingleInteger from Foreign Builtin
import %iadd: (%,%) -> % from Foreign Builtin
import %isub: (%,%) -> % from Foreign Builtin
@@ -152,17 +153,17 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
if wholeObj then
OMputEndObject(dev)
- zero? x == x = 0@%
- one? x == x = 1@%
+ zero? x == x = %icst0
+ one? x == x = %icst1
0 == %icst0
1 == %icst1
base() == 2 pretend %
copy x == x
- inc x == x + 1@%
- dec x == x - 1@%
+ inc x == x + %icst1
+ dec x == x - %icst1
hash x == %hash x
- negative? x == x < 0@%
- positive? x == 0 < x
+ negative? x == x < %icst0
+ positive? x == %icst0 < x
coerce(x):OutputForm == outputForm(x pretend Integer)
coerce(m:Integer):% == m pretend %
convert(x:%):Integer == x pretend Integer
@@ -183,7 +184,7 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
latex(x:%):String ==
s : String := convert x
- -1 < x and x < 10 => s
+ -%icst1 < x and x < 10 => s
%strconc("{", %strconc(s, "}"))
positiveRemainder(a, b) ==
@@ -214,6 +215,7 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
(m:Integer) * (y:%) == %imul(m,y) -- for subsumption problem
x ** n == %ipow(x,n)$Foreign(Builtin)
odd? x == %iodd? x
+ even? x == %ieven? x
max(x,y) == %imax(x,y)
min(x,y) == %imin(x,y)
divide(x,y) == %idivide(x,y)$Foreign(Builtin)
@@ -224,8 +226,8 @@ Integer: Join(IntegerNumberSystem, ConvertibleTo String, OpenMath) with
gcd(x,y) == %igcd(x,y)
UCA ==> Record(unit:%,canonical:%,associate:%)
unitNormal x ==
- negative? x => [-1@%,-x,-1@%]$UCA
- [1@%,x,1@%]$UCA
+ negative? x => [-%icst1,-x,-%icst1]$UCA
+ [%icst1,x,%icst1]$UCA
unitCanonical x == abs x
solveLinearPolynomialEquation(lp:List ZP,p:ZP):Union(List ZP,"failed") ==
solveLinearPolynomialEquation(lp pretend List ZZP,
diff --git a/src/algebra/si.spad.pamphlet b/src/algebra/si.spad.pamphlet
index 888a40f3..f8296439 100644
--- a/src/algebra/si.spad.pamphlet
+++ b/src/algebra/si.spad.pamphlet
@@ -226,6 +226,7 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic,OpenMath) w
import %hash: % -> SingleInteger from Foreign Builtin
import %ilength: % -> % from Foreign Builtin
import %iodd?: % -> Boolean from Foreign Builtin
+ import %ieven?: % -> Boolean from Foreign Builtin
import %ieq: (%,%) -> Boolean from Foreign Builtin
import %ilt: (%,%) -> Boolean from Foreign Builtin
import %ile: (%,%) -> Boolean from Foreign Builtin
@@ -319,6 +320,7 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic,OpenMath) w
gcd(x,y) == %igcd(x,y)
abs(x) == %iabs x
odd?(x) == %iodd? x
+ even?(x) == %ieven? x
zero?(x) == %ieq(x,%icst0)
one?(x) == %ieq(x,%icst1)
max(x,y) == %imax(x,y)
@@ -334,7 +336,7 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic,OpenMath) w
(%icstmax - %icstmin + %icst1) pretend NonNegativeInteger
index i == per(i + rep %icstmin - rep %icst1)
lookup x ==
- (x - %icstmin + %icst1) pretend PositiveInteger
+ (rep x - rep %icstmin + rep %icst1) pretend PositiveInteger
reducedSystem(m: Matrix %, v: Vector %) ==
@@ -353,9 +355,9 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic,OpenMath) w
UCA ==> Record(unit:%,canonical:%,associate:%)
unitNormal x ==
- negative? x => [-1@%,-x,-1@%]$UCA
- [1@%,x,1@%]$UCA
- positive? x == 0 < x
+ negative? x => [-%icst1,-x,-%icst1]$UCA
+ [%icst1,x,%icst1]$UCA
+ positive? x == %icst0 < x
@