ASStructures.mesa
Copyright © 1987 by Xerox Corporation. All rights reserved.
Arnon, November 23, 1987 10:16:20 am PST
Structure Categories
Category: TYPE ~ {set, lattice, group, ring, field, module, vectorSpace, algebra, divisionAlgebra};
Structure Operation Types
PrintNameProc:
TYPE =
PROC [structure: Object]
RETURNS [Rope.
ROPE];
-- redundant with ToRopeOp
Identify the particular structure to the world.
StructureToExprOp:
TYPE =
PROC [structure: Object]
RETURNS [out:
EXPR];
StructureEqualityTest:
TYPE =
PROC [thisStructure, otherStructure: Object]
RETURNS [
BOOL];
Test whether some other structure is the same algebraic domain as this one
StructureRankOp:
TYPE =
PROC [structure: Object]
RETURNS [
CARDINAL];
For things like ring characteristic (smallest positive integer k such that k*1 = 0; 0 if k infinite) and vector space dimension.
ReportOpsProc:
TYPE =
PROC [structure: Object]
RETURNS [opNames:
LIST
OF Rope.
ROPE, refOps:
LIST
OF
REF];
Report structure operations to outside world, e.g. a user interface
Should be made a concrete proc to be applied to method dictionaries
BinaryStructureLUBOp:
TYPE =
PROC [firstStructure, secondStructure: Object]
RETURNS [LUBStructure: Object];
If either Structure NIL, return other
Structure Constructor Types
StructureFromSetConstructor:
TYPE =
PROC [set: Object]
RETURNS [structure: Object];
Make a Structure whose (finite) underlying set is the given argument.
VectorStructureConstructor:
TYPE =
PROC [coordinateStructure: Object, dimension:
NAT, row:
BOOL ←
TRUE]
RETURNS [vectorStructure: Object];
A particular vector structure is defined by its coordinateStructure, which can be any Structure, its dimension, and whether its elements are displayed as rows or columns.
SequenceStructureConstructor:
TYPE =
PROC [elementStructure: Object, row:
BOOL ←
TRUE]
RETURNS [sequenceStructure: Object];
A particular sequence structure is defined by its elementStructure, which can be any Structure, and whether its elements are displayed as rows or columns.
MatrixStructureConstructor:
TYPE =
PROC [elementStructure: Object, nRows, nCols:
NAT]
RETURNS [matrixStructure: Object];
A particular matrix structure is defined by its elementStructure and its nRows, nCols. elementStructure can be a ring, field, algebra, or divisionAlgebra.
PolynomialStructureConstructor:
TYPE =
PROC [coeffRing, variableSeq: Object]
RETURNS [polynomialStructure: Object];
A particular polynomial structure is defined by its coeffRing and its variables.
coeffRing can be a ring, field, algebra, or divisionAlgebra.
variableSeq is a sequence of any length, and the right thing happens.
OrchardStructureConstructor:
TYPE =
PROC [coeffRing, labels: AlgebraClasses.Object, heapOrdered:
BOOL]
RETURNS [orchardStructure: Object];
A particular orchard structure is defined by its coeffRing and labels, and whether or not it is heap ordered.
coeffRing is expected to be either the integers or the reals.
NIL labels iff unlabeled; must be an ASVariableSequences.VariableSequence if non-NIL
Structure Operations
IsCategory:
PROC [structure: Object, category: Category]
RETURNS [
BOOL];
HasProperty:
PROC [structure: Object, property:
ATOM]
RETURNS [
BOOL];
MakeStructure:
PROC [name: Rope.
ROPE, class: Object, instanceData:
REF]
RETURNS[structure: Object];
StructureEqual:
PROC [structure1, structure2: Object]
RETURNS [
BOOL];
RETURN[structure1.name = structure2.name]
LookupMethodInStructure:
PROC [methodSelector:
ATOM, structure: Object]
RETURNS[Method];
LookupMethodInClass[structure.class]
LookupMethodInAllStructures:
PROC [methodSelector:
ATOM]
RETURNS[method: Method, structure: Object];
Linear search of StructureRegistry, LookupMethodForStructure until found or EOF. If found, then structure is Structure where found. Returns [NIL, NIL] if not found.
Structure Registry
Structures have nonNIL names. Mathematically different Structures have different names.
A central registry of Structures is kept, and we never have more than one instance of a given mathematical structure in existence.
ResetStructureRegistry:
PROC[];
InstallStructure:
PROC[structure: Object];
effects: Installs structure in global StructureRegistry database. Replaces existing occurrence of a Structure with same name, if any, and otherwise places structure at the tail of StructureRegistry.
LookupStructure:
PROC[name:
ROPE]
RETURNS[structure: Object];
effects: Returns the Structure Object associated with name.
returns NIL if not found
KillStructure:
PROC[name:
ROPE];
effects: delete structure from global StructureRegistry DataBase, if present. Only needed when want to delete a given Structure name entirely, not if just want to replace.
StructureElement Operation Types
LegalFirstCharOp:
TYPE =
PROC [char:
CHAR, structure: Object]
RETURNS [
BOOL];
True if char is legal first char in an external rep of a structure element.
ReadOp:
TYPE =
PROC [in:
IO.
STREAM, structure: Object ←
NIL]
RETURNS [out: Object];
FromRopeOp:
TYPE =
PROC [in: Rope.
ROPE, structure: Object ←
NIL]
RETURNS [out: Object];
ToRopeOp:
TYPE =
PROC [in: Object]
RETURNS [out: Rope.
ROPE];
WriteOp:
TYPE =
PROC [stream:
IO.
STREAM, in: Object];
FromExprOp:
TYPE =
PROC [in:
EXPR, structure: Object]
RETURNS [out: Object];
ToExprOp:
TYPE =
PROC [in: Object]
RETURNS [out:
EXPR];
FromBOOLOp:
TYPE =
PROC [in:
BOOL, structure: Object ←
NIL]
RETURNS [out: Object];
FromINTOp:
TYPE =
PROC [in:
INT, structure: Object ←
NIL]
RETURNS [out: Object];
NullaryOp:
TYPE =
PROC[structure: Object]
RETURNS [result: Object];
Since no object arg, need a hook to structure
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];
For things like determinant and coefficient extraction
ElementRankOp:
TYPE =
PROC [arg: Object]
RETURNS [
CARDINAL];
For things like degree functions in euclidean domains, rank of matrices
Display2DOp:
TYPE =
PROC [object: Object, context: Imager.Context, dotWidth, segmentWidth:
REAL];
Display an object in a 2D context.
StructureElement Creation Types
UnaryImbedOp:
TYPE =
PROC [in: Object, structure: Object]
RETURNS [out: Object];
Imbed in as an element of structure
BinaryImbedOp:
TYPE =
PROC [data1: Object, data2:
REF, structure: Object]
RETURNS [out: Object];
Construct an element of structure from data1 and data2.
Sample use: constructing a term of a polynomial.
ListImbedOp:
TYPE =
PROC [data:
LIST
OF Object, structure: Object]
RETURNS [out: Object];
Construct an element of a point, sequence, or vector Structure from data
MatrixImbedOp:
TYPE =
PROC [elements:
LIST
OF Object, structure: Object]
RETURNS [out: Object];
Construct an element of a matrix Structure from data. Assumes that correct number of elements supplied, in correct order, and that each element supplied belongs to structure.elementStructure
Variables
Structures: AC.Object; -- public structure
StructuresClass: AC.Object; -- public class; other Structure Impls will add methods to it.