Boole.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet July 31, 1985 3:03:17 pm PDT
Bertrand Serlet April 2, 1987 9:34:37 pm PST
Barth, August 26, 1986 9:58:59 am PDT
Theory
This interface defines the basic functions for manipulating Boolean expressions.
Expressions may be:
constants among {true, false};
variables: any REF. Variables are tested for equality using the REF Equal predicate, apart from ROPEs which compares using Rope.Equal, and REF INT which compares the INTs.
expressions created by operators such as Not, And, Or, If, etc ... .
Operators returning Expressions
Not:
PROC [expr: Expression]
RETURNS [result: Expression];
And: PROC [expr1, expr2, expr3, expr4, expr5: Expression ← true] RETURNS [result: Expression];
Or: PROC [expr1, expr2, expr3, expr4, expr5: Expression ← false] RETURNS [result: Expression];
Xor: PROC [expr1, expr2, expr3, expr4, expr5: Expression ← false] RETURNS [result: Expression];
Nand: PROC [expr1, expr2, expr3, expr4, expr5: Expression ← true] RETURNS [result: Expression];
Nor:
PROC [expr1, expr2, expr3, expr4, expr5: Expression ← false]
RETURNS [result: Expression];
AndList: PROC [exprs: LIST OF Expression] RETURNS [result: Expression];
OrList: PROC [exprs: LIST OF Expression] RETURNS [result: Expression];
XorList: PROC [exprs: LIST OF Expression] RETURNS [result: Expression];
NandList: PROC [exprs: LIST OF Expression] RETURNS [result: Expression];
NorList:
PROC [exprs:
LIST
OF Expression]
RETURNS [result: Expression];
If:
PROC [cond, then, else: Expression]
RETURNS [result: Expression];
Useful operator computing: Or[And[cond, then], And[Not[cond], else]].
Other operations
EqualVar:
PROC [var1, var2: Variable]
RETURNS [
BOOL];
Equal:
PROC [expr1, expr2: Expression]
RETURNS [
BOOL];
Eval:
PROC [var: Variable, expr: Expression]
RETURNS [whenTrue, whenFalse: Expression];
FullEval:
PROC [expr: Expression, evalVar: EvalVar]
RETURNS [Expression];
EvalVar: TYPE = PROC [Variable] RETURNS [Expression];
NIL means unknown when returned from FullEval or EvalVar.
FindVar:
PROC [expr: Expression]
RETURNS [var: Variable];
NIL if no var found or insignificant.
EnumerateVars:
PROC [expr: Expression, enumVar: EnumVar];
EnumVar: TYPE = PROC [Variable];
HasVar:
PROC [expr: Expression, var: Variable]
RETURNS [found:
BOOL ←
FALSE];
PutExpr:
PROC [out:
IO.
STREAM, expr: Expression, deep:
INT ←
LAST [
INT], putRefAny:
PROC [
IO.
STREAM, Variable] ←
NIL];
Variables which are ROPE or REF INT are handled without calling putRefAny.
GetExpr:
PROC [in:
IO.
STREAM, getRefAny:
PROC [
IO.
STREAM]
RETURNS [Variable] ←
NIL]
RETURNS [expr: Expression];
Variables which are ROPE or REF INT are handled without calling getRefAny
ToRope:
PROC [expr: Expression, deep:
INT ← 5]
RETURNS [Rope.
ROPE];
Short cut for PutExpr
FromRope:
PROC [rope: Rope.
ROPE]
RETURNS [Expression];
Short cut for GetExpr
Private operations that depend on the representation
Case:
PRIVATE
PROC [whenTrue, whenFalse: Expression]
RETURNS [case:
ATOM];
case belongs to {$Case11, $Case00, $Case10, $Case01, $Case1X, $Case0X, $CaseX1, $CaseX0, $CaseXX, $CaseXY}