Boole.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet July 31, 1985 3:03:17 pm PDT
Bertrand Serlet March 9, 1986 4:44:10 pm PST
Barth, May 22, 1986 4:05:31 pm PDT
DIRECTORY
Core USING [CellType],
Rope USING [ROPE];
Boole: CEDAR DEFINITIONS = BEGIN
Theory
This interface defines the basic functions for manipulating Boolean expressions.
Common Types
ROPE: TYPE = Rope.ROPE;
Expression Type
Expressions may be:
constants among {true, false};
expressions created by Var, gateway between variables and expressions;
expressions created by operators such as Not, And, Or, If, etc ... .
The public of an Expression contains all the inputs of the Expression, and only the inputs. The structure of this public is flat, and functions returning expressions will generate their own flat public.
Expression: TYPE = Core.CellType;
Constants
true: READONLY Expression;
false: READONLY Expression;
Operators returning Expressions
Var: PROC [var: ROPE] RETURNS [result: Expression];
Case is significant
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
EvalProc: TYPE = PROC [var: ROPE, expr: Expression] RETURNS [whenTrue, whenFalse: Expression];
ToRopeProc: TYPE = PROC [expr: Expression, deep: INT ← 9] RETURNS [ROPE];
FindVarProc: TYPE = PROC [expr: Expression] RETURNS [var: ROPE];
NIL if no var found
Conservative
Eval: EvalProc;
ToRope: ToRopeProc;
FromRope: PROC [er: ROPE] RETURNS [expr: Expression];
FindVar: FindVarProc;
Equal: PROC [expr1, expr2: Expression] RETURNS [BOOL];
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}
END.