Church Typing


Church-style typing is a strict approach to assigning types in lambda calculus. It ensures that every variable and function has an explicit type annotation, making the system more structured and predictable.


Basic Notation

Each term in lambda calculus is explicitly typed. The general form is:

λxα.u

This means:

For example, the identity function in Church-style typing:

λxα.x

has the type:

αα

Church Typing Rules

Church-style typing follows strict inference rules to determine the type of expressions.

1. Variable Typing Rule

If x has type α, then in any context Γ, we can state:

Γx:α

Example:

If x is an integer, then:

Γx:int

2. Function Typing (Lambda Abstraction Rule)

If an expression u has type β when x has type α, then the function λx.u has type αβ:

Γ,x:αu:βΓ(λx.u):(αβ)

Example:

For the function:

λxint.ystring

we assign:

intstring

3. Function Application Rule

If u is a function of type αβ, and v has type α, then applying u to v results in type β:

Γu:(αβ),Γv:αΓ(uv):β

Example:

If we have:

(λxint."x") 5

Since λx.x has type intstring, and 5 has type int, the result is a string.


Typing Example: Selecting the First Argument

Consider the function:

λp.λq.p

Step 1: Assigning Types

Notice!

Function λp.λq.p produces another function that selects the first argument p!

Step 2: Typing Derivation

  1. Typing p

    Γ,p:αp:α
  2. Typing λq.p

    Since p has type α, we infer:

    Γ,q:β,p:αq:β

    So,

    Γ,p:α(λq.p):(βα)
  3. Typing the full abstraction λp.λq.p

    Γ(λp.λq.p):(α(βα))

Final Type:

(λp.λq.p):(α(βα))

Why Church Typing is More Restrictive

Church-style typing is more strict than Curry-style typing because:

Feature Church Typing Curry Typing
Explicit types ✅ Required ❌ Inferred
Type annotations ✏️ Written in terms 🚀 Inferred from context
Flexibility ❌ More strict ✅ More flexible
Common in Formal systems, logic Functional programming

🚀 Church typing is stricter but guarantees correctness, while Curry typing allows greater flexibility through type inference!