The Opal Property Language allows to include algebraic laws into the signature or the implementation part. The laws are checked for syntax errors but have no further effect. (We hope that this changes in future versions of Opal.)
The syntax of algebraic laws is
LAW [ name == ] formula
The name is a normal Opal identifier, which is used for identification and
documentation purposes. formula
is a first-order predicate
formula. We distinguish between formulas and boolean expressions: A
boolean expression is true, false or undefined; a formula is
either valid or not valid.
An example formula is the associativity law of addition:
LAW +_assoc == ALL a b c. a + (b + c) === (a + b) + c
Formulas consist of
ALL, EX
AND, OR,
==>
(implies), <=>
(equivalent),
NOT
DFD expr
is valid, if expr
is a defined value.
expr1 === expr2
is valid, if both
expressions are defined and equal, or both expressions are
undefined.
expr
is an abbreviation for
expr === true
. expr
must be a boolean expression.
Further information is given in Appendix A.7 of the Opal Report.