Lambda Calculus · v1.1.1
2026-11-02 12:55:42
succ, pred and iszerosucc \(n\) timesrec notationEvery recursive definition has two parts:
Both are required for termination.
Primitive recursion is weaker than general recursion.
Incrementing the first and decrementing the second until the second is zero. Reduction appears to work.
add reappears at every level, so replacement never terminates\(\color{#c0392b}\boldsymbol{\times}\) The definition never becomes a λ expression at all.
A function is used in an application, and the use may be delayed by abstracting at that point:
Reducing add1 add1 gives a body containing:
add1 appears with two arguments where three are neededf, so the function is not passed down\(\color{#c0392b}\boldsymbol{\times}\) The effect required is add1 add1 (succ x) (pred y).
f is passed to the argument itselff f (succ x) (pred y) carries the function down to the next level\(\color{#2e7d32}\checkmark\) Correct, but every recursive call must pass the function to itself explicitly.
Applicative order reduces an argument to a value before substituting it into the function body.
A self-application supplied as an argument is evaluated first, and never finishes.
Add the first number to the product of the first and the decremented second; the product is zero when the second is zero.
mult1 is mult with the self-reference replaced by a bound variablerecursive is a constructor: it builds a recursive function from a non-recursive onerecursive must satisfyReducing recursive mult1 leaves <'f' and copy> x (pred y) in the body, where mult1 <'f' and copy> x (pred y) is required. So:
The base case can stop the reduction before the next self-application is demanded.
rec notationrec adds nothing: the grammar is still three productions and the conversions β, α, η.
A recursive reference is left in place when a definition is expanded or evaluated.
pred returns zero when decrementing zerosub returns zero whenever the second number is larger than the firstThis is natural subtraction.
sub x y is non-zero exactly when \(x > y\)sub y x is zero exactly when \(x \geq y\)Comparison is built from natural subtraction.
div1 counts how often the divisor subtracts from the dividendsub, div and pred each return zero rather than an undefined valuerecursive f = λs.(f (s s)) λs.(f (s s)) routes each replication through frec is sugar over the combinator