1 is a function that applies f once to x: λf.λx.f x
2 is a function that applies f twice to x: λf.λx.f (f x)
n is a function that applies f n times to x: λf.λx.f (f (... (f x) ...)) with n applications
The successor function takes a Church numeral n and returns a Church numeral representing n+1. It should be: λn.λf.λx.f (n f x)
Let me write this out clearly with explanations.
Church Numerals in Lambda Calculus
Church numerals represent natural numbers as functions that apply an operation n times. Here's the encoding:
Basic Definitions
; Zero: apply f zero times to x
0 := λf.λx.x
; One: apply f once to x
1 := λf.λx.f x
; Two: apply f twice to x
2 := λf.λx.f (f x)
; n: apply f n times to x
n := λf.λx.f (f (... (f x) ...)) [f applied n times]
Successor Function
The successor function takes a Church numeral and returns the next one:
SUCC := λn.λf.λx.f (n f x)
How it works:
Takes numeral n which applies f exactly n times
Returns a function that applies f one more time
(n f x) applies f to x n times, then f (...) applies it once more