Provide an ADT specification for \(\texttt{Boolean}\) type. By definition, a Boolean is either \(\texttt{true}\) or \(\texttt{false}\). The negation (\(\texttt{Not}\)) of a Boolean is also a Boolean. The \(\texttt{and}\) and \(\texttt{or}\) between two Booleans is also a Boolean.
Difficulty level
This exercise is mostly suitable for students
Type Boolean
Uses
Parameter
FUCNTIONS
true : -> Boolean
false : -> Boolean
not : Boolean -> Boolean
and : Boolean x Boolean -> Boolean
or : Boolean x Boolean -> Boolean
AXIOMES Let X be a variable
[1] not(true) = false
[2] non(false) = true
[3] and(true, X) = X
[4] and(false, X) = false
[5] or(true, X) = true
[6] or(false, X) = X
EXAMPLES
not(or(true , (and(false,not(true))))) ==
not(or(true , (and(false,false)))) (by [1])
== not(or(true , false)) (by [4])
== not(true) (by [5]) == false (by [1]).
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Binary tree mirrors