<> <> <> <<>> DIRECTORY SafeStorage, IO, Atom, Rope, Basics, MathExpr; AlgebraClasses: CEDAR DEFINITIONS = BEGIN <> Object: TYPE = REF ObjectRec; ObjectRec: TYPE = RECORD [ name: Rope.ROPE _ NIL, -- hook onto this particular object structure: Structure, propList: Atom.PropList _ NIL, data: REF _ NIL ]; <> Structure: TYPE = REF StructureRec; StructureRec: TYPE = RECORD [ class: StructureClass, instanceData: REF _ NIL ]; <> Category: TYPE = {set, lattice, group, ring, field, module, vectorSpace, algebra, divisionAlgebra}; StructureClass: TYPE = REF StructureClassRec; StructureClassRec: TYPE = RECORD [ <> category: Category, flavor: Rope.ROPE _ NIL, <> <<"Ints">> <<"BigRats">> <<"Points">> <<"Polynomials">> <<"Matrices">> <<"Quotients">> printName: PrintNameProc, shortPrintName: PrintNameProc, -- if none, should be set to printName hashCode: CARDINAL _ 0, -- for quick checks of structure equality structureEqual: StructureEqualityTest, characteristic: StructureRankOp _ NIL, -- rings, fields, modules, vector spaces, algebras, divisionAlgebras only dimension: StructureRankOp _ NIL,-- modules, vector spaces, algebras, divisionAlgebras only <> isElementOf: ElementOfProc, <> legalFirstChar: LegalFirstCharOp, read: ReadOp, fromRope: FromRopeOp, toRope: ToRopeOp, write: WriteOp, fromExpr: FromExprOp _ NIL, toExpr: ToExprOp _ NIL, recast: UnaryImbedOp _ NIL, -- convert an element of a structure that conforms to this one (should be a noop on elements of this structure). Should use fastest available determination of structure, e.g. hashCode or shortPrintName. <> add: BinaryOp _ NIL, negate: UnaryOp _ NIL, subtract: BinaryOp _ NIL, zero: NullaryOp _ NIL, <> multiply: BinaryOp _ NIL, -- assumed associative; commutative or noncommutative ok commutative: BOOL _ TRUE, invert: UnaryOp _ NIL, divide: BinaryOp _ NIL, -- (lattices only) set difference operation goes here if appropriate one: NullaryOp, <> equal: EqualityOp _ NIL, -- need not be present in sets and lattices <> rightModule: BOOL _ FALSE, -- modules are left modules by default <<>> <> scalarMultiply: BinaryOp _ NIL, -- unless rightModule, this is left multiplication, i.e. scalar * vector. The underlying field of a vector space may be commutative or noncommutative. <> booleanAlgebra: BOOL _ FALSE, complement: UnaryOp _ NIL, <> ordered: BOOL _ FALSE, 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]; <> StructureEqualityTest: TYPE = PROC [thisStructure, otherStructure: Structure] RETURNS [BOOL]; <> defaultStructureEqualityTest: StructureEqualityTest; StructureRankOp: TYPE = PROC [structure: Structure] RETURNS [CARDINAL]; <> <<>> StructureCategoryToRope: PROC [category: Category] RETURNS [rope: Rope.ROPE]; GetProperty: PROC [structure: Structure, prop: ATOM] RETURNS [val: REF]; <> <> ElementOfProc: TYPE = PROC [item: Object, structure: Structure] RETURNS [BOOL]; << True if item is an element of the structure.>> <<>> defaultElementOfProc: ElementOfProc; 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] RETURNS [out: Object]; FromRopeOp: TYPE = PROC [in: Rope.ROPE, structure: Structure] RETURNS [out: Object]; ToRopeOp: TYPE = PROC [in: Object] RETURNS [out: Rope.ROPE]; WriteOp: TYPE = PROC [stream: IO.STREAM, in: Object]; FromExprOp: TYPE = PROC [in: MathExpr.EXPR, structure: Structure] RETURNS [out: Object]; ToExprOp: TYPE = PROC [in: Object] RETURNS [out: MathExpr.EXPR]; NullaryOp: TYPE = PROC[structure: Structure] RETURNS [result: Object]; <> UnaryOp: TYPE = PROC [arg: Object] RETURNS [result: Object]; BinaryOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [result: Object]; EqualityOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [BOOL]; CompareToZeroOp: TYPE = PROC [arg: Object] RETURNS [Basics.Comparison]; BinaryCompareOp: TYPE = PROC [firstArg, secondArg: Object] RETURNS [Basics.Comparison]; StructuredToGroundOp: TYPE = PROC [structuredElt: Object] RETURNS [groundElement: Object]; <> <<>> ElementRankOp: TYPE = PROC [arg: Object] RETURNS [CARDINAL]; <> <> <> << >> UnaryImbedOp: TYPE = PROC [in: Object, structure: Structure] RETURNS [out: Object]; <> <<>> BinaryImbedOp: TYPE = PROC [data1: Object, data2: REF, structure: Structure] RETURNS [out: Object]; <> END.