4 The Curry-Howard correspondence expresses a deep connection between
5 logic, types, and computation. Today we'll discuss how the
6 simply-typed lambda calculus corresponds to intuitionistic logic.
7 This naturally give rise to the question of what sort of computation
8 classical logic corresponds to---as we'll see later, the answer
9 involves continuations.
11 So at this point we have the simply-typed lambda calculus: a set of
12 ground types, a set of functional types, and some typing rules, given
15 If a variable `x` has type σ and term `M` has type τ, then
16 the abstract `\xM` has type σ `-->` τ.
18 If a term `M` has type σ `-->` τ, and a term `N` has type
19 σ, then the application `MN` has type τ.
21 These rules are clearly inverse of one another (in some sense to be
22 made precise): the functional types that abstract builds up are taken
23 apart by application. The intuition that abstraction and application
24 are dual to each other is the heart of the Curry-Howard
27 The next step in making sense out of the Curry-Howard corresponence is
28 to present a logic. It will be a part of intuitionistic logic. We'll
29 start with the implicational fragment, that is, the part of
30 intuitionistic logic that only involves axioms and implications:
38 Γ, A, B, Δ |- C
39 Exchange: ---------------------------
40 Γ, B, A, Δ |- C
43 Contraction: -------------------
47 Weakening: -----------------
53 --> I: -------------------
56 Γ |- A --> B Γ |- A
57 --> E: -----------------------------------
61 `A`, `B`, etc. are variables over formulas.
62 Γ, Δ, etc. are variables over (possibly empty) sequences
63 of formulas. Γ `|- A` is a sequent, and is interpreted as
64 claiming that if each of the formulas in Γ is true, then `A`
67 This logic allows derivations of theorems like the following:
76 ----------------- --> I
80 Should remind you of simple types. (What was `A --> B --> A` the type
83 The easy way to grasp the Curry-Howard correspondence is to *label*
84 the proofs. Since we wish to establish a correspondence between this
85 logic and the lambda calculus, the labels will all be terms from the
86 simply-typed lambda calculus. Here are the labeling rules:
94 Γ, x:A, y:B, Δ |- R:C
95 Exchange: -------------------------------
96 Γ, y:B, x:A, Δ |- R:C
98 Γ, x:A, x:A |- R:B
99 Contraction: --------------------------
103 Weakening: ---------------------
104 Γ, x:A |- R:B [x chosen fresh]
109 --> I: -------------------------
110 Γ |- \xM:A --> B
112 Γ |- f:(A --> B) Γ |- x:A
113 --> E: -------------------------------------
117 In these labeling rules, if a sequence Γ in a premise contains
118 labeled formulas, those labels remain unchanged in the conclusion.
120 What is means for a variable `x` to be chosen *fresh* is that
121 `x` must be distinct from any other variable in any of the labels
122 used in the (sub)proof up to that point.
124 Using these labeling rules, we can label the proof
130 ---------------- Weak
132 ------------------------- --> I
133 x:A |- (\y.x):(B --> A)
134 ---------------------------- --> I
135 |- (\x y. x):A --> B --> A
138 We have derived the *K* combinator, and typed it at the same time!
140 In order to make use of the dual rule, the one for `-->` elimination,
141 we need a context that will entail both `A --> B` and `A`. Here's
142 one, first without labels:
145 ------------------Axiom
147 ---------------------Weak ---------Axiom
148 A --> B, A |- A --> B A |- A
149 ---------------------Exch -----------------Weak
150 A, A --> B |- A --> B A, A --> B |- A
151 -------------------------------------------------- --> E
158 ------------------------Axiom
159 f:A --> B |- f:A --> B
160 ----------------------------Weak -------------Axiom
161 f:A --> B, x:A |- f:A --> B x:A |- x:A
162 ----------------------------Exch ------------------------Weak
163 x:A, f:A --> B |- f:A --> B x:A, f:A --> B |- x:A
164 -------------------------------------------------------------- --> E
165 x:A, f:A --> B |- (fx):B
168 Note that in order for the `--> E` rule to apply, the left context and
169 the right context (the material to the left of each of the turnstiles)
170 must match exactly, in this case, `x:A, f:A --> B`.
172 At this point, an application to natural language will help provide
174 Instead of labelling the proof above with the kinds of symbols we
175 might use in a program, we'll label it with symbols we might use in an
176 English sentence. Instead of a term `f` with type `A --> B`, we'll
177 have the English word `left`; and instead of a term `x` with type `A`,
178 we'll have the English word `John`.
181 -----------------------------Axiom
182 left:e --> t |- left:e --> t
183 --------------------------------------Weak -------------------Axiom
184 left:e --> t, John:e |- left:e --> t John:e |- John:e
185 --------------------------------------Exch --------------------------------Weak
186 John:e, left:e --> t |- left:e --> t John:e, left:e --> t |- John:e
187 ---------------------------------------------------------------------------------- --> E
188 John:e, left:e --> t |- (left John):t
191 This proof illustrates how a logic can
192 provide three things that a complete grammar of a natural language
195 * It characterizes which words and expressions can be combined in
196 order to form a more complex expression. For instance, we've
197 just seen a proof that "left" can combine with "John".
199 * It characterizes the type (the syntactic category) of the result.
200 In the example, an intransitive verb phrase of type `e --> t` combines
201 with a determiner phrase of type `e` to form a sentence of type `t`.
203 * It characterizes the semantic recipe required to compute the meaning
204 of the complex expression based on the meanings of the parts: the
205 way to compute to meaning of the expression "John left" is to take
206 the function denoted by "left" and apply it to the individual
207 denoted by "John", viz., "(left John)".
209 This last point is the truly novel and beautiful part, the part
210 contributed by the Curry-Howard result.
212 [Incidentally, note that this proof also suggests that if we have the
213 expressions "John" followed by "left", we also have a determiner
214 phrase of type `e`. If you want to make sure that the contribution of
215 each word counts (no weakening), you have to use a resource-sensitive
216 approach like Linear Logic or Type Logical Grammar.
218 In this trivial example, it may not be obvious that anything
219 interesting is going on, so let's look at a slightly more complicated
220 example, one that combines abstraction with application.
222 Linguistic assumptions (abundently well-motivated, but we won't pause
223 to review the motivations here):
226 Coordinating conjunctions like *and*, *or*, and *but* require that
227 their two arguments must have the same sytnactic type. Thus we can
231 1. [John left] or [Mary left] coordination of t
232 2. John [left] or [slept] coordination of e -> t
233 3. [John] or [Mary] left coordination of e
237 5. *left or Mary slept.
241 If the two disjuncts have the same type, the coordination is perfectly
242 fine, as (1) through (3) illustrate. But when the disjuncts don't
243 match, as in (4) and (5), the result is ungrammatical (though there
244 are examples that may seem to work; each usually has a linguistic
245 story that needs to be told).
247 In general, then, *and* and *or* are polymorphic, and have the type
248 `and:('a -> 'a -> 'a)`. In the discussion below, we'll use a more
249 specific instance to keep the discussion concrete, and to abstract
250 away from polymorphism.
253 Some determiner phrases do not denote an indivdual of type `e`, and
254 denote only functions of a higher type, typically `(e -> t) -> t` (the
255 type of an (extensional) generalized quantifier). So *John* has type
256 `e`, but *everyone* has type `(e -> t) -> t`.
258 [Excercise: prove using the logic above that *Everyone left* can have
259 `(everyone left)` as its Curry-Howard labeling.]
261 The puzzle, then, is how it can be possible to coordinate generalized
262 quantifier determiner phrases with non-generalized quantifier
265 1. John and every girl laughed.
266 2. Some boy or Mary should leave.
268 The answer involves reasoning about what it means to be an individual.
270 Let the type of *or* in this example be `Q -> Q -> Q`, where
271 `Q` is the type of a generalized quantifier, i.e, `Q = ((e->t)->t`.
274 -----------------Ax -----------------Ax
275 John:e |- John:e P:e->t |- P:e->t
276 --------------------------------------Modus Ponens (proved above)
277 John:e, P:e->t |- (P John):t
278 --------------------------------- --> I
279 John:e |- (\P.P John):(e->t)->t
282 This proof is very interesting: it says that if *John* has type `e`,
283 then *John* automatically can be used as if it also has type
284 `(e->t)->t`, the type of a generalized quantifier.
285 The Curry-Howard labeling is the term `\P.P John`, which is a function
286 from verb phrase meanings to truth values, just as we would need.
288 [John and everyone left]
290 beta reduction = normal proof.
292 [To do: add pairs and destructors; unit and negation...]
294 Excercise: construct a proof whose labeling is the combinator S,
298 --------- Ax --------- Ax ------- Ax
299 !a --> !a !b --> !b c --> c
300 ----------------------- L-> -------- L!
301 !a,!a->!b --> !b !c --> c
302 --------- Ax ---------------------------------- L->
303 !a --> !a !a,!b->!c,!a->!b --> c
304 ------------------------------------------ L->
305 !a,!a,!a->!b->!c,!a->!b --> c
306 ----------------------------- C!
307 !a,!a->!b->!c,!a->!b --> c
308 ------------------------------ L!
309 !a,!a->!b->!c,! (!a->!b) --> c
310 ---------------------------------- L!
311 !a,! (!a->!b->!c),! (!a->!b) --> c
312 ----------------------------------- R!
313 !a,! (!a->!b->!c),! (!a->!b) --> !c
314 ------------------------------------ R->
315 ! (!a->!b->!c),! (!a->!b) --> !a->!c
316 ------------------------------------- R->
317 ! (!a->!b) --> ! (!a->!b->!c)->!a->!c
318 --------------------------------------- R->
319 --> ! (!a->!b)->! (!a->!b->!c)->!a->!c
324 calculus](http://homepages.inf.ed.ac.uk/wadler/papers/dual/dual.pdf), and
325 [[http://en.wikibooks.org/wiki/Haskell/The_Curry-Howard_isomorphism]].