Rewrite rules for Booleans

Boolean expressions b can be composed of
true false // Constants
!b // Negation
b && b // Conjunction
b || b // Disjunction
and of the usual comparison operations:
e <= e, e >= e, e < e, e > e, e == e, e != e
Here are reduction rules for Boolean expressions (e is an arbitrary expression):
!true --> false
!false --> true
true && e --> e
false && e --> false
true || e --> true
false || e --> e
Note that && and || do not always need their right operand to be evaluated.
We say, these expressions use “short-circuit evaluation”.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala snippets
Sign Up Now
or Subscribe for future quizzes