Alonzo Church defined the boolean values ‘true’ and ‘false’ in lambda calculus as:
- true=λab.a
- false=λab.b
Given a predicate (a function that returns a boolean value) p, the statement that would usually be written ‘if p then E1 else E2’ becomes simply pE1E2.
The various boolean functions are also simple:
- not p=(p)(false)(true)
- a and b=(a)(b)(false)
- a or b=(a)(true)(b)
- a xor b=(a)((b)(false)(true))(b)