AlgebraClasses.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Arnon, March 4, 1986 12:02:24 pm PST
DIRECTORY
SafeStorage,
IO,
Atom,
Rope,
Basics;
AlgebraClasses: CEDAR DEFINITIONS
= BEGIN
Structure Type
Structure: TYPE = REF StructureRec;
StructureRec: TYPE = RECORD [
class: StructureClass,
instanceData: REF
];
Class Record Type
ClassFlavor: TYPE = {group, ring, field, vectorSpace, algebra, divisionAlgebra};
StructureClass: TYPE = REF StructureClassRec;
StructureClassRec: TYPE = RECORD [
Structure properties
flavor: ClassFlavor,
printName: PrintNameProc,
characteristic: StructureRankOp ← NIL, -- rings, fields, vector spaces, algebras, divisionAlgebras only
dimension: StructureRankOp ← NIL,-- vector spaces, algebras, divisionAlgebras only
Test whether a given item belongs to this structure (run-time typechecking)
isElementOf: ElementOfProc ← NIL,
I/O
legalFirstChar: LegalFirstCharOp,
read: ReadOp,
fromRope: FromRopeOp,
toRope: ToRopeOp,
write: WriteOp,
Addition (rings, fields, vectorSpaces, algebras, divisionAlgebras only)
add: BinaryOp ← NIL,
negate: UnaryOp ← NIL,
subtract: BinaryOp ← NIL,
zero: NullaryOp ← NIL,
Multiplication (groups, rings, fields, algebras, divisionAlgebras only)
multiply: BinaryOp, -- assumed associative; commutative or noncommutative ok
commutative: BOOLTRUE,
invert: UnaryOp ← NIL,
divide: BinaryOp ← NIL,
one: NullaryOp,
Scalar multiplication (vectorSpaces, algebras, divisionAlgebras only)
scalarMultiply: BinaryOp ← NIL, -- this is left multiplication, i.e. scalar * vector. The underlying field of a vector space may be commutative or noncommutative.
Equality testing
equal: EqualityOp,
Ordered structure ops (rings, fields, vectorSpaces, algebras, divisionAlgebras only)
ordered: BOOLTRUE,
sign: CompareToZeroOp ← NIL,
abs: UnaryOp ← NIL,
compare: BinaryCompareOp ← NIL,
Some common varieties of rings (and algebras)
integralDomain: BOOLFALSE,
gcdDomain: BOOLFALSE,
gcd: BinaryOp ← NIL, -- gcdDomains only
euclideanDomain: BOOLFALSE,
remainder: BinaryOp ← NIL, -- euclideanDomains only
degree: ElementRankOp ← NIL, -- euclideanDomains only
Some common varieties of fields (and divisionAlgebras)
completeField: BOOLFALSE,
realField: BOOLFALSE,
realClosedField: BOOLFALSE,
algebraicallyClosedField: BOOLFALSE,
Additional ops and properties go on property list, for example:
$PolynomialRing
$MatrixRing
$EuclideanDomainMod
$ExtensionField (ground field cannot be an algebraicallyClosedField)
$RealExtensionField (ground field must be a realField, not also a realClosedField)
$QuotientField
$PowerSeriesRing
propList: Atom.PropList ← NIL
];
Structure Operation Types
PrintNameProc: TYPE = PROC [structure: Structure] RETURNS [Rope.ROPE];
Identify the particular structure to the world.
StructureRankOp: TYPE = PROC [structure: Structure] RETURNS [CARDINAL];
For things like ring characteristic (smallest positive integer k such that k*1 = 0; 0 if k infinite) and vector space dimension.
Structure Element Operation Types
ElementOfProc: TYPE = PROC [item: REF, structure: Structure] RETURNS [BOOL];
True if item is an element of the structure.
LegalFirstCharOp: TYPE = PROC [char: CHAR, structure: Structure] RETURNS [BOOL];
True if char is legal first char in an external rep of a structure element.
ReadOp: TYPE = PROC [in: IO.STREAM, structure: Structure ← NIL] RETURNS [out: REF];
FromRopeOp: TYPE = PROC [in: Rope.ROPE, structure: Structure ← NIL] RETURNS [out: REF];
ToRopeOp: TYPE = PROC [in: REF, structure: Structure ← NIL] RETURNS [out: Rope.ROPE];
WriteOp: TYPE = PROC [stream: IO.STREAM, in: REF, structure: Structure ← NIL];
NullaryOp: TYPE = PROC[structure: Structure ← NIL] RETURNS [result: REF];
Note that since no args, no hooks to structure
UnaryOp: TYPE = PROC [arg: REF, structure: Structure ← NIL] RETURNS [result: REF];
BinaryOp: TYPE = PROC [firstArg, secondArg: REF, structure: Structure ← NIL] RETURNS [result: REF];
EqualityOp: TYPE = PROC [firstArg, secondArg: REF, structure: Structure ← NIL] RETURNS [BOOL];
CompareToZeroOp: TYPE = PROC [arg: REF, structure: Structure ← NIL] RETURNS [Basics.Comparison];
BinaryCompareOp: TYPE = PROC [firstArg, secondArg: REF, structure: Structure ← NIL] RETURNS [Basics.Comparison];
StructuredToGroundOp: TYPE = PROC [structuredElt: REF, structure: Structure ← NIL] RETURNS [groundElement: REF];
For things like determinant and coefficient extraction
ElementRankOp: TYPE = PROC [arg: REF, structure: Structure ← NIL] RETURNS [CARDINAL];
For things like degree functions in euclidean domains, rank of matrices
Miscellaneous Operations
FlavorToRope: PROC [flavor: ClassFlavor] RETURNS [rope: Rope.ROPE];
GetProperty: PROC [structure: Structure, prop: ATOM] RETURNS [val: REF];
Retrieve from property list
END.