DIRECTORY SafeStorage, IO, Atom, Rope, Basics; AlgebraClasses: CEDAR DEFINITIONS = BEGIN Structure: TYPE = REF StructureRec; StructureRec: TYPE = RECORD [ class: StructureClass, instanceData: REF ]; ClassFlavor: TYPE = {group, ring, field, vectorSpace, algebra, divisionAlgebra}; StructureClass: TYPE = REF StructureClassRec; StructureClassRec: TYPE = RECORD [ flavor: ClassFlavor, printName: PrintNameProc, characteristic: StructureRankOp _ NIL, -- rings, fields, vector spaces, algebras, divisionAlgebras only dimension: StructureRankOp _ NIL,-- vector spaces, algebras, divisionAlgebras only isElementOf: ElementOfProc _ NIL, legalFirstChar: LegalFirstCharOp, read: ReadOp, fromRope: FromRopeOp, toRope: ToRopeOp, write: WriteOp, add: BinaryOp _ NIL, negate: UnaryOp _ NIL, subtract: BinaryOp _ NIL, zero: NullaryOp _ NIL, multiply: BinaryOp, -- assumed associative; commutative or noncommutative ok commutative: BOOL _ TRUE, invert: UnaryOp _ NIL, divide: BinaryOp _ NIL, one: NullaryOp, scalarMultiply: BinaryOp _ NIL, -- this is left multiplication, i.e. scalar * vector. The underlying field of a vector space may be commutative or noncommutative. equal: EqualityOp, ordered: BOOL _ TRUE, sign: CompareToZeroOp _ NIL, abs: UnaryOp _ NIL, compare: BinaryCompareOp _ NIL, integralDomain: BOOL _ FALSE, gcdDomain: BOOL _ FALSE, gcd: BinaryOp _ NIL, -- gcdDomains only euclideanDomain: BOOL _ FALSE, remainder: BinaryOp _ NIL, -- euclideanDomains only degree: ElementRankOp _ NIL, -- euclideanDomains only completeField: BOOL _ FALSE, realField: BOOL _ FALSE, realClosedField: BOOL _ FALSE, algebraicallyClosedField: BOOL _ FALSE, propList: Atom.PropList _ NIL ]; PrintNameProc: TYPE = PROC [structure: Structure] RETURNS [Rope.ROPE]; StructureRankOp: TYPE = PROC [structure: Structure] RETURNS [CARDINAL]; ElementOfProc: TYPE = PROC [item: REF, structure: Structure] RETURNS [BOOL]; LegalFirstCharOp: TYPE = PROC [char: CHAR, structure: Structure] RETURNS [BOOL]; 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]; 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]; ElementRankOp: TYPE = PROC [arg: REF, structure: Structure _ NIL] RETURNS [CARDINAL]; FlavorToRope: PROC [flavor: ClassFlavor] RETURNS [rope: Rope.ROPE]; GetProperty: PROC [structure: Structure, prop: ATOM] RETURNS [val: REF]; END. AlgebraClasses.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Arnon, March 4, 1986 12:02:24 pm PST Structure Type Class Record Type Structure properties Test whether a given item belongs to this structure (run-time typechecking) I/O Addition (rings, fields, vectorSpaces, algebras, divisionAlgebras only) Multiplication (groups, rings, fields, algebras, divisionAlgebras only) Scalar multiplication (vectorSpaces, algebras, divisionAlgebras only) Equality testing Ordered structure ops (rings, fields, vectorSpaces, algebras, divisionAlgebras only) Some common varieties of rings (and algebras) Some common varieties of fields (and divisionAlgebras) 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 Structure Operation Types Identify the particular structure to the world. 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 True if item is an element of the structure. True if char is legal first char in an external rep of a structure element. Note that since no args, no hooks to structure For things like determinant and coefficient extraction For things like degree functions in euclidean domains, rank of matrices Miscellaneous Operations Retrieve from property list Κ– "Mesa" style˜codešœΟc™Kšœ Οmœ1™