ASPowerSetStructure.mesa
Last Edited by: Arnon, November 19, 1987 8:31:50 am PST
Structure Constructor: Power set of argument Structure. Currently, only allows creation of, and can only work with, finite subsets (i.e. finite collections of elements of argument Structure).
DIRECTORY
Rope,
IO,
AlgebraClasses;
ASPowerSetStructure: CEDAR DEFINITIONS
~ BEGIN OPEN Rope, AC: AlgebraClasses;
Element Representation
Set: TYPE = AC.Object;
SetData: TYPE = LIST OF AC.Object;
The elements of SetData are assumed to be distinct.
The empty set is represented by NIL SetData.
Structure Instance Data
PowerSetStructureData: TYPE = REF PowerSetStructureDataRec;
PowerSetStructureDataRec: TYPE = RECORD [
universe: AC.Object -- the elements of the Structure are the subsets of universe
];
Structure Constructor
MakePowerSetStructure: AC.SequenceStructureConstructor;
Record that the resulting Structure is a BooleanAlgebra.
Operations on Power Set Structures
PrintName: AC.ToRopeOp;
ShortPrintName: AC.ToRopeOp;
IsPowerSetStructure: AC.UnaryPredicate;
Universe: AC.UnaryOp;
selector: universe of a Power Set Structure
Conversion and IO for Elements of Power Set Structures (i.e. finite sets)
Recast: AC.BinaryOp;
CanRecast: AC.BinaryPredicate;
ToExpr: AC.ToExprOp;
LegalFirstChar: AC.LegalFirstCharOp;
Read: AC.ReadOp;
FromRope: AC.FromRopeOp;
ToRope: AC.ToRopeOp;
Write: AC.WriteOp;
Element Constructor
MakeSet: AC.ListImbedOp;
I.e. makes a finite set belonging to a particular PowerSetStructure.
Currently no checks for repetitions of elements.
Does check that supplied elements actually belong to universe (recasts if necessary).
data = NIL => empty set.
Predicates for Sets
IsElement: AC.BinaryPredicate;
firstArg is an Object, and secondArg is a Set. Returns TRUE if firstArg is an element of secondArg.
IsSubset: AC.BinaryPredicate;
firstArg and secondArg are Sets. Returns TRUE if firstArg is a subset of secondArg.
Operations on Sets
Cardinality: AC.ElementRankOp;
Equal: AC.BinaryPredicate;
Union: AC.BinaryOp;
Intersection: AC.BinaryOp;
Difference: AC.BinaryOp;
MapUnaryElementOp: AC.BinaryMixedOp;
firstArg is a Set, secondArg is REF to UnaryOp on its elementStructure, result is Set of results of applications of UnaryOp to elements of firstArg.
Note that, by elimination of duplicates, cardinality of result may be less than cardinality of argument.
END.