Boolean operators

There are three built-in boolean operators in Hope: not, and, and or. Now try:
>: not true;
Hope replies:
>> false : bool

and now try:

>: not false;
Hope replies:
>> true : bool

The operator not is a unary boolean operator since it is applied to a single boolean expression. Try:

>: not (not false);
Hope replies:
>> false : bool
Why is this? In order to work out not (not false) hope first evaluates the inner (not false) to give true so the whole expression reduces to not (true) which evaluates to false.

In shorthand we can write:

not (not false) $\rightarrow$ not (true)$\rightarrow$ false.
Similarly: not (not (1<2)) $\rightarrow$ not (not (true)) $\rightarrow$ not (false)$\rightarrow$ true.



s.danicic@gold.ac.uk
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2010-12-29