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:
This means:
is a variable. is its type. is the expression that uses .
For example, the identity function in Church-style typing:
has the type:
Church Typing Rules
Church-style typing follows strict inference rules to determine the type of expressions.
1. Variable Typing Rule
If
Example:
If
2. Function Typing (Lambda Abstraction Rule)
If an expression
Example:
For the function:
we assign:
3. Function Application Rule
If
Example:
If we have:
Since
Typing Example: Selecting the First Argument
Consider the function:
Step 1: Assigning Types
- Assume
has type . - Assume
has type . - Since
returns , it has type . - Then,
has type .
Function
Step 2: Typing Derivation
-
Typing
-
Typing
Since
has type , we infer: So,
-
Typing the full abstraction
✅ Final Type:
Why Church Typing is More Restrictive
Church-style typing is more strict than Curry-style typing because:
- It requires every term to have an explicit type annotation.
- It does not allow implicit type inference, unlike Curry typing.
- It prevents ambiguity in function definitions.
- It ensures that every function has a well-defined type signature.
| 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!