Propositions As Types

Propositions As Types

Chapter udf Propositions as Types This is a very experimental draft of a chapter on the Curry-Howard correspondence. It needs more explanation and motivation, and there are probably errors and omissions. The proof of normalization should be reviewed and expanded. There are no examples for the product type. Permuation and simplification conversions are not covered. It will make a lot more sense once there is also material on the (typed) lambda calculus which is basically presupposed here. Use with extreme caution. pty.1 Introduction int:pty:int: Historically the lambda calculus and intuitionistic logic were developed sepa- sec rately. Haskell Curry and William Howard independently discovered a close similarity: types in a typed lambda calculus correspond to formulas in intu- itionistic logic in such a way thata derivation ofa formula corresponds directly to a typed lambda term with that formula as its type. Moreover, beta reduc- tion in the typed lambda calculus corresponds to certain transformations of derivations. For instance,a derivation of '! corresponds to a term λx':N , which has the function type ' ! . The inference rules of natural deduction correspond to typing rules in the typed lambda calculus, e.g., [']x x : ' ) N : x !Intro λ ' ! corresponds to ) λx':N : ' ! where the rule on the right means that if x is of type ' and N is of type , then λx':N is of type ' ! . The !Elim rule corresponds to the typing rule for composition terms, i.e., 1 ' ! ' !Elim corresponds to ) P : ' ! ) Q : ' app ) P '! Q' : If a !Intro rule is followed immediately by a !Elim rule, the derivation can be simplified: [']x ' −! x !Intro ' ! ' !Elim which corresponds to the beta reduction of lambda terms (λx':P )Q −! P [Q=x]: Similar correspondences hold between the rules for ^ and \product" types, and between the rules for _ and \sum" types. This correspondence between terms in the simply typed lambda calculus and natural deduction derivations is called the \Curry-Howard", or \proposi- tions as types" correspondence. In addition to formulas (propositions) corre- sponding to types, and proofs to terms, we can summarize the correspondences as follows: logic program proposition type proof term assumption variable discharged assumption bind variable not discharged assumption free variable implication function type conjunction product type disjunction sum type absurdity bottom type The Curry-Howard correspondence is one of the cornerstones of automated proof assistants and type checkers for programs, since checking a proof witness- ing a proposition (as we did above) amounts to checking if a program (term) has the declared type. pty.2 Sequent Natural Deduction Let us write Γ ) ' if there is a natural deduction derivation with Γ as undis- int:pty:snd: charged assumptions and ' as conclusion; or ) ' if Γ is empty. sec 2 propositions-as-types rev: c8c9782 (2021-09-28) by OLP/ CC{BY We write Γ; '1;:::;'n for Γ [ f'1;:::;'ng, and Γ; ∆ for Γ [ ∆. Observe that when we have Γ ) ' ^ ', meaning we havea derivation with Γ as undischarged assumptions and ' ^ ' as end-formula, then by applying ^Elim at the bottom, we can geta derivation with the same undischarged assumptions and ' as conclusion. In other words, if Γ ) ' ^ , then Γ ) '. Γ ) ' ^ Γ ) ' ^ ^Elim ^Elim Γ ) ' Γ ) The label ^Elim hints at the relation with the rule of the same name in natural deduction. Likewise, suppose we have Γ; ' ) , meaning we havea derivation with undischarged assumptions Γ; ' and end-formula . If we apply the !Intro rule, we havea derivation with Γ as undischarged assumptions and ' ! as the end-formula, i.e., Γ ) ' ! . Note how this has made the discharge of assumptions more explicit. Γ; ' ) !Intro Γ ) ' ! We can draw conclusions from other rules in the same fashion, which is spelled out as follows: Γ ) ' ∆ ) ^Intro Γ; ∆ ) ' ^ Γ ) ' ^ Γ ) ' ^ ^Elim ^Elim Γ ) ' 1 Γ ) 2 Γ ) ' Γ ) _Intro _Intro Γ ) ' _ 1 Γ ) ' _ 2 Γ ) ' _ ∆, ' ) χ ∆0; ) χ _Elim Γ; ∆, ∆0 ) χ Γ; ' ) ∆ ) ' ! Γ ) ' !Intro !Elim Γ ) ' ! Γ; ∆ ) Γ )? ? Γ ) ' I Any assumption by itself isa derivation of ' from ', i.e., we always have ' ) '. ' ) ' Together, these rules can be taken as a calculus about what natural de- duction derivations exist. They can also be taken as a notational variant of natural deduction, in which each step records not only the formula derived but also the undischarged assumptions from which it was derived. propositions-as-types rev: c8c9782 (2021-09-28) by OLP/ CC{BY 3 ' ) ' ' ) ' _ (' !?) ) '; !)? ( ) ' !? ( ) ' _ (' !?)( ) ( )? ) !? where is short for (' _ (' !?)) !?. pty.3 Proof Terms We give the definition of proof terms, and then establish its relation with int:pty:ter: natural deduction derivations. sec Definition pty.1 (Proof terms). Proof terms are inductively generated by the following rules: 1. A single variable x is a proof term. 2. If P and Q are proof terms, then PQ is also a proof term. 3. If x is a variable, ' isa formula, and N is a proof term, then λx':N is also a proof term. 4. If P and Q are proof terms, then hP; Qi is a proof term. 5. If M is a proof term, then pi(M) is also a proof term, where i is 1 or 2. ' 6. If M is a proof term, and ' is a formula, then ini (M) is a proof term, where i is 1 or 2. 7. If M; N1;N2 is proof terms, and x1; x2 are variables, then case(M; x1:N1; x2:N2) is a proof term. 8. If M is a proof term and ' is a formula, then contr'(M) is proof term. Each of the above rules corresponds to an inference rule in natural deduc- tion. Thus we can inductively assign proof terms to the formulas ina deriva- tion. To make this assignment unique, we must distinguish between the two versions of ^Elim and of _Intro. For instance, the proof terms assigned to the conclusion of _Intro must carry the information whether ' _ is inferred from ' or from . Suppose M is the term assigned to 'from which ' _ is inferred. ' Then the proof term assigned to ' _ is in1 (M). If we instead infer _ ' ' then the proof term assigned is in2 (M). The term λx':N is assigned to the conclusion of !Intro. The ' represents the assumption being discharged; only have we included it can we infer the formula of λx':N based on the formula of N. 4 propositions-as-types rev: c8c9782 (2021-09-28) by OLP/ CC{BY Definition pty.2 (Typing context). A typing context is a mapping from variables to formulas. We will call it simply the \context" if there is no confu- sion. We write a context Γ as a set of pairs hx; 'i. A pair Γ ) M where M is a proof term representsa derivation of a formula with context Γ . Definition pty.3 (Typing pair). A typing pair is a pair hΓ; Mi, where Γ is a typing context and M is a proof term. Since in general terms only make sense with specific contexts, we will speak simply of \terms" from now on instead of \typing pair"; and it will be apparent when we are talking about the literal term M. pty.4 Converting Derivations to Proof Terms int:pty:pt: We will describe the process of converting natural deduction derivations to sec pairs. We will write a proof term to the left of each formula in the derivation, resulting in expressions of the form M : '. We'll then say that, M witnesses '. Let's call such an expression a judgment. First let us assign to each assumption a variable, with the following con- straints: 1. Assumptions discharged in the same step (that is, with the same number on the square bracket) must be assigned the same variable. 2. For assumptions not discharged, assumptions of different formulas should be assigned different variables. Such an assignment translates all assumptions of the form ' into x : ': With assumptions all associated with variables (which are terms), we can now inductively translate the rest of the deduction tree. The modified natural deduction rules taking into account context and proof terms are given below. Given the proof terms for the premise(s), we obtain the corresponding proof term for conclusion. M1 : '1 M2 : '2 ^Intro hM1;M2i : '1 ^ '2 M : '1 ^ '2 M : '1 ^ '2 ^Elim1 ^Elim2 pi(M): '1 pi(M): '2 In ^Intro we assume we have '1 witnessed by term M1 and '2 witnessed by term M2. We pack up the two terms into a pair hM1;M2i which witnesses '1 ^ '2. propositions-as-types rev: c8c9782 (2021-09-28) by OLP/ CC{BY 5 In ^Elimi we assume that M witnesses '1 ^ '2. The term witnessing 'i is pi(M). Note that M is not necessary of the form hM1;M2i, so we cannot simply assign M1 to the conclusion 'i. Note how this coincides with the BHK interpretation. What the BHK interpretation does not specify is how the function used as proof for ' ! is supposed to be obtained. If we think of proof terms as proofs or functions of proofs, we can be more explicit. [x : '] P : ' ! Q : ' !Elim PQ : N : !Intro λx':N : ' ! The λ notation should be understood as the same as in the lambda calculus, and PQ means applying P to Q. M1 : '1 M2 : '2 _Intro _Intro '1 1 '2 2 in1 (M1): '1 _ '2 in2 (M2): '1 _ '2 [x1 : '1] [x2 : '2] M : A1 _ '2 N1 : χ N2 : χ _Elim case(M; x1:N1; x2:N2): χ '1 The proof term in1 (M1) is a term witnessing '1 _ '2, where M1 witnesses '1.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us