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
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)
CanRecast:
AC.BinaryPredicate;
LegalFirstChar:
AC.LegalFirstCharOp;
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;
Intersection:
AC.BinaryOp;
DeleteElement:
AC.BinaryOp;
firstArg is a Set, secondArg an element of it. result is firstArg - {secondArg}. Error if secondArg not an element of firstArg
Difference:
AC.BinaryOp;
firstArg is a Set, secondArg an element of it. result is A - B. ok if B has elements not in A.
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.