Conditionals
IF-THEN-ELSE is just application. The boolean IS the conditional.
In most programming languages, IF is a built-in keyword — a special piece of syntax that examines a boolean value and branches accordingly. Lambda calculus has no keywords and no built-in branching. So how does it handle conditionals? The answer is disarmingly simple: it doesn't need to. The boolean already knows how to choose.
IF Is Just Application
Recall that TRUE = λx.λy.x and FALSE = λx.λy.y. Each takes two
arguments and returns one of them. TRUE returns the first; FALSE
returns the second.
This means IF-THEN-ELSE requires no special construct at all. To express "IF b THEN x ELSE y," simply write:
b x y
If b is TRUE, the result is x. If b is FALSE, the result is y.
The boolean itself performs the selection — it was designed to select.
IF TRUE
TRUE = λx.λy.x takes two arguments and returns the first.
So applying TRUE to two branches selects the "then" branch:
TRUE a b
= (λx.λy.x) a b
→β (λy.a) b
→β a
The second argument b is discarded. TRUE always picks the first.
IF FALSE
FALSE = λx.λy.y takes two arguments and returns the second.
So applying FALSE to two branches selects the "else" branch:
FALSE a b
= (λx.λy.y) a b
→β (λy.y) b
→β b
The first argument a is discarded. FALSE always picks the second.
No Separate IF Needed
In most languages, booleans are inert values — tags that say "true" or "false" but do nothing on their own. A separate IF construct inspects the tag and decides which branch to take.
Church booleans work differently. TRUE = λx.λy.x and
FALSE = λx.λy.y are not tags waiting to be inspected. They are
functions that already know how to choose. Apply one to two
arguments and it selects the right one.
A separate IF function would just receive b, x, and y and
then apply b x y — doing exactly what b x y already does.
The extra function adds nothing.
The Boolean IS the Conditional
In most programming languages, booleans and conditionals are separate
things. A boolean is a value (true or false), and a conditional
(if/else) is a control structure that examines the value and picks
a branch.
Church booleans collapse this distinction. TRUE and FALSE are not
values waiting to be examined — they are functions that do the
examining. When you write b x y, the boolean b receives the
two branches and returns one. The data IS the control flow.
This is one of the deepest ideas in lambda calculus: there is no boundary between data and computation. A value can be a function. A function can be data. Choosing is just applying.
IF with Lambda Terms
Church booleans select between any two arguments — not just simple variables. The branches can be lambda terms themselves.
TRUE (λx.x) (λy.y y)
= (λa.λb.a) (λx.x) (λy.y y)
→β (λb.λx.x) (λy.y y)
→β λx.x
TRUE selects its first argument regardless of what that argument is.
The second argument (λy.y y) is discarded entirely.
Why b x y Works as IF-THEN-ELSE
The conditional pattern b x y works because TRUE and FALSE were
defined to be two-argument selector functions:
- TRUE =
λx.λy.x— returns the first of two arguments - FALSE =
λx.λy.y— returns the second of two arguments
This is not a coincidence or a trick. The entire point of these definitions is to make selection possible through application alone. Church chose these definitions precisely so that applying a boolean to two branches would select the correct one.
The result is that branching, selection, and conditional logic all reduce to the most basic operation in lambda calculus: application.
The Conditional Pattern
The conditional pattern in lambda calculus is:
Apply the boolean to the two branches.
b x y — where b is a Church boolean, x is the "then" branch,
and y is the "else" branch.
This works for any expressions as branches:
TRUE a b → aFALSE a b → bTRUE (λx.x) (λy.y y) → λx.xFALSE (λx.x) (λy.y y) → λy.y y
The boolean selects; the branches are just arguments. No special syntax, no IF keyword, no pattern matching. Conditional logic is function application.
Ready to test your understanding?
Bitwit uses spaced repetition to help you truly master concepts like this—not just read about them. Each card generates with different values, so you can't just memorize answers.
Practice Conditionals →