<<

The Curry-Howard- and Cartesian Closed Categories

Florian Rabe

Part of the course on Computational Logic by Michael Kohlhase

Fall 2007, Jacobs University Bremen

1 06.11.2007

2 Review: Categories of Contexts

I A recurring pattern in logic

I Essentially the same for FOL and STT; in the following ConSTT(Σ) as an example

I Objects: Contexts x1 : A1,..., xn : An 0 I from Γ = x1 : A1,..., xm : Am to Γ = y1 : B1,..., yn : Bn: tuples (t1,..., tn) such that x1 : A1,..., xm : Am `Σ ti : Bi for i = 1,..., n 0 I (t1,..., tn) from Γ to Γ can be seen as substitutions σ = [t1/y1,..., tn/yn] (where, intutitively, the substitutions go against the morphism direction)

I Identity idx1:A1,...,xm:Am = (x1,..., xm) I Composition σ • (t1,..., tn) = (σ(t1), . . . , σ(tn))

3 References: Curry-Howard-correspondence @Book{ c u r r y , author = ”H. Curry and R. Feys”, title = ”Combinatory Logic”, publisher = ”North−Holland ” , address = ”Amsterdam”, year = ”1958”, }

@InCollection {howard , author = ”W. Howard”, title = ”The formulas −as−types notion of construction ”, booktitle = ”To H.B. Curry: Essays on Combinatory Logic , Lambda−Calculus and Formalism”, editors = ”J. Seldin and J. Hindley”, publisher = ”Academic Press”, year = ”1980”, pages = ”479−−490”, }

4 Review: First-order logic

Summary:

I Inference rules for FOL-fragment consisting of true, conjunction and implication

I Natural deduction with context, e.g., Γ ` A for Γ = A1,..., An

I Rules: truth introduction, conjunction introduction and elimination, implication introduction and elimination

5 Review: Simply-typed lambda calculus

Summary:

I Typing of terms for lambda calculus with unit type, product type, and

I Type inference rules with context, e.g., Γ ` t : A for Γ = x1 : A1,..., xn : An

I Rules: unit element, pairing, projections, lambda abstraction, application

6 The Curry-Howard-correspondence

I Observation: Rules look almost alike

I formulas correspond to types

I context (= list of hypotheses) corresponds to context (= list of variable declarations)

I inference rules correspond to typing rules

I What FOL-entity corresponds to STT-terms? Answer: Proofs.

I Thus: Proof-checking corresppnds to type-checking; proof-search corresponds to type-inhabitation (where a type is inhabited if there is a term of it).

7 Proof term assignment

Summary:

I In the FOL-inference rules, replace A1,..., An ` A with x1 : A1,..., xn : An ` p : A where I xi : names for the assumed proofs of the Ai I p proof of A possibly using the assumed proofs xi , i.e., p is a (proof) term with variables xi

I Give every rule a name, so that a rule becomes a constructor for proof terms. For example, call modus ponens MP.

I Then every proof is a term, for example MP(p1, p2) is a proof of B if p1 is a proof of A → B and p2 is a proof of A.

I Then the rules for FOL with proofs and for STT become the same.

8 07.11.2007

9 Review: Constructions in Categories

I Pairs terminal/initial, product/, pullback/pushout, equalizer/ of dual constructions I All constructions exist in Set. I Results: 0 0 I If U is an X , then: U is an X iff U =∼ U , where X is one of the above constructions. op I If C has all X , then C has all duality partners X .

I If C has a terminal object, then having all pullbacks is equivalent to having all products and all equalizers.

I Dually: If C has an initial object, then having all pushouts is equivalent to having all and all . I I I I I Categories relevant for logic: Sig , Th , ConΣ, Mod (Σ) I Candidates for constructions in the relevant categories I I I Sig and Th : initial - empty, coproduct - union, pushout - union with sharing I I ConΣ: terminal - empty, product - concatenation I I Mod (Σ): terminal - singleton, product - , initial - term model

10 Reference: Cartesian Closed Categories

@book{ ccc , a ut h o r = {J. Lambek and P. Scott } , p u b l i s h e r = { Cambridge University Press } , s e r i e s = { Cambridge Studies in Advanced Mathematics } , t i t l e = { Introduction to Higher−Order Categorical L o g i c } , volume = {7} , y e a r = {1986} } Recommended read: Chapter 6.1 in Steve Awodey’s notes

11 Cartesian Closed Categories

A1,A2 A1,A2 I Assume a C with products (A1 × A2, π1 , π2 ) for all A1, A2 ∈ |C|. I Then for all fi ∈ C (O, Ai ) for i = 1, 2, there is a unique morphism hf1, f2i : C (O, A1 × A2). I For gi ∈ C (Ai , Bi ) for i = 1, 2, we put A1,A2 A1,A2 g1 × g2 := hπ1 • f1, π2 • f2i ∈ C (A1 × A2, B1 × B2). A A,B A,B A  I For A, B ∈ |C|,(B , ) where eval ∈ C B × A, B is called an exponential of A and B iff:   C (Γ × A, B) =∼ C Γ, BA , f 7→ f¯

A,B for all Γ ∈ |C| and (f¯ × idA) • eval = f for all f ∈ C (Γ × A, B). I A category is called cartesian closed if it has a terminal object, products for all pairs of objects, and exponentials for all pairs of objects.

12 Cartesian Closed Categories (2)

I CCC is the category with cartesian closed categories as objects. 0 0 I CCC-morphisms from C to C : F from C to C that preserve CCC-structure, i.e., 0 I F maps the terminal object of C to the terminal object of C , A,B A,B 0 I (F (A × B), F (π1 ), F (π2 )) is a product in C of F (A) and F (B), A A,B 0 I (F (B ), F (eval )) is an exponential in C of F (A) and F (B).

I Identity and composition are as in Cat.

13 Example: Set

I Terminal: Singletons

I Product: Cartesian product with projections I Exponential of A and B: A I B = Set (A, B) A,B I eval :(ϕ, α) 7→ ϕ(α) for ϕ ∈ Set (A, B) and α ∈ A.

14 STT Example: ConΣ

I Here: STT with unit type T , product types A × B, and function types A → B I Only the case with one variable needed because ∼ x1 : A1,..., xm : Am = x : A1 × ... × Am. I Then: Morphisms from x : A to x : B are simply terms t such that x : A ` t : B. I Terminal object is x : T (or isomorphically: empty context). I Product object of x : A and x : B is x : A × B (or isomorphically: x : A, y : B). I Exponential object of x : A and x : B is x : A → B. I Still missing: projection morphisms for the product, evaluation morphism for the exponential I Needed for the proof: unique morphisms into the terminal and product object and the isomorphism from the definition of exponential

15 Example: FOL

I Use the fragment of FOL with truth, conjunction, implication; call it P. I This is even a fragment of propositional logic, i.e., no quantifiers, no terms; signatures contain only nullary predicate symbols. 0 I Let Σ be the STT-signature containing one constant for every inference rule of P. We use one base type for every nullary predicate symbol of Σ. P I Build a category PfΣ I objects are named lists of hypotheses, i.e., x1 : A1,..., xn : Am P for formulas A1,..., Am ∈ Sen (Σ) I morphisms from x1 : A1,..., xn : Am to y1 : B1,..., yn : Bn are tuples (p1,..., pn) where pi is a proof of Bi using the assumptions A1,..., Am STT I identity and composition just like for ConΣ0 P ∼ STT Then clearly: PfΣ = ConΣ0 in CCC.

16