Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012

Similar documents
The Calculus of Inductive Constructions

The Curry-Howard Isomorphism

Categories, Proofs and Programs

Constructive approach to relevant and affine term calculi

Simply Typed λ-calculus

Command = Value Context. Hans-Dieter Hiep. 15th of June, /17

TERMS FOR NATURAL DEDUCTION, SEQUENT CALCULUS AND CUT ELIMINATION IN CLASSICAL LOGIC

If-then-else and other constructive and classical connectives (Or: How to derive natural deduction rules from truth tables)

Propositions as Types

Kleene realizability and negative translations

Lambda Calculus. Week 12 The canonical term models for λ. Henk Barendregt, Freek Wiedijk assisted by Andrew Polonsky

What is a Proof? Jean Gallier and Kurt W.A.J.H.Y. Reillag CIS, Upenn and Hospices de Beaune. Friday, February 22, 13

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule.

Classical Combinatory Logic

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Introduction to Type Theory February 2008 Alpha Lernet Summer School Piriapolis, Uruguay. Herman Geuvers Nijmegen & Eindhoven, NL

Natural deduction for propositional logic via truth tables

Sequent Combinators: A Hilbert System for the Lambda Calculus

The Lambda-Calculus Reduction System

Models of computation

Introduction to Type Theory

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010

The duality of computation

From pre-models to models

Introduction to λ-calculus

Računske interpretacije intuicionističke i klasične logike

Origin in Mathematical Logic

CHAPTER 11. Introduction to Intuitionistic Logic

Teaching Natural Deduction as a Subversive Activity

Non-Idempotent Typing Operators, beyond the λ-calculus

Deriving natural deduction rules from truth tables (Extended version)

Evaluation Driven Proof-Search in Natural Deduction Calculi for Intuitionistic Propositional Logic

Lecture Notes on Combinatory Modal Logic

Subtyping and Intersection Types Revisited

Introduction to Intuitionistic Logic

Extended Abstract: Reconsidering Intuitionistic Duality

Forcing-based cut-elimination for Gentzen-style intuitionistic sequent calculus

Set Theory History. Martin Bunder. September 2015

Silvia Ghilezan and Jelena Ivetić

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands

Rewriting for Fitch style natural deductions

COMP6463: λ-calculus

On a computational interpretation of sequent calculus for modal logic S4

Propositions and Proofs

Sequent Calculi and Abstract Machines

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT

Propositional Logic Language

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

An introduction to classical realizability

A Semantics of Evidence for Classical Arithmetic

Lambda Calculus with Types. Henk Barendregt ICIS Radboud University Nijmegen The Netherlands

Origin in Mathematical Logic

Introduction to dependent type theory. CIRM, May 30

AN ALTERNATIVE NATURAL DEDUCTION FOR THE INTUITIONISTIC PROPOSITIONAL LOGIC

185.A09 Advanced Mathematical Logic

een wetenschappelijke proeve op het gebied van de

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University

Simply Typed λ-calculus

Rules and derivations in an elementary logic course arxiv: v1 [cs.lo] 7 Jan 2016

Type Systems. Lecture 9: Classical Logic. Neel Krishnaswami University of Cambridge

Structuring Logic with Sequent Calculus

3.17 Semantic Tableaux for First-Order Logic

Parallel Reduction in Type Free Lambda-mu- Calculus

Alonzo Church ( ) Lambda Calculus. λ-calculus : syntax. Grammar for terms : Inductive denition for λ-terms

Completeness and Partial Soundness Results for Intersection & Union Typing for λµ µ

Intersection and Singleton Type Assignment Characterizing Finite Böhm-Trees

logical verification lecture program extraction and prop2

Lecture 3. Lambda calculus. Iztok Savnik, FAMNIT. October, 2015.

cse371/mat371 LOGIC Professor Anita Wasilewska Fall 2018

Main Issues in Computer Mathematics. Henk Barendregt Brouwer Institute Radboud University Nijmegen, The Netherlands

Uniform Schemata for Proof Rules

Advanced Lambda Calculus Lecture 5

A Lambda Calculus for Gödel Dummett Logic Capturing Waitfreedom

Truth values algebras and proof normalization

A BRIEF INTRODUCTION TO TYPED PREDICATE LOGIC

CS Lecture 19: Logic To Truth through Proof. Prof. Clarkson Fall Today s music: Theme from Sherlock

Logic and Computation

Nonclassical logics (Nichtklassische Logiken)

Realisability methods of proof and semantics with application to expansion

Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison

A simple proof that super-consistency implies cut elimination

Calculi for Intuitionistic Normal Modal Logic

Typage et déduction dans le calcul de

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

1. each λ-variable is a λρ-term, called atom or atomic term, 2. if M and N are λρ-term then (MN) is a λρ-term called application,

Beyond First-Order Logic

Explicit Convertibility Proofs in PTSs

An overview of Structural Proof Theory and Computing

Chapter 3: Propositional Calculus: Deductive Systems. September 19, 2008

Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl)

Consequence Relations and Natural Deduction

The formal proof sketch challenge

TR : Tableaux for the Logic of Proofs

02 The Axiomatic Method

Proof Theoretical Studies on Semilattice Relevant Logics

Chapter 11: Automated Proof Systems (1)

Subtractive Logic. To appear in Theoretical Computer Science. Tristan Crolard May 3, 1999

Proofs in classical logic as programs: a generalization of lambda calculus. A. Salibra. Università Ca Foscari Venezia

Transcription:

1 λ Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 5, 2012

2 reading Femke van Raamsdonk Logical Verification Course Notes Herman Geuvers Introduction to Type Theory Henk Barendregt Lambda Calculus with Types Cambridge University Press (to appear)

Curry-Howard 3

4 the Curry-Howard isomorphism Haskell Curry William Alvin Howard Nicolaas Govert de Bruijn Per Martin-Löf logics typed lambda calculi isomorphic = type theories formulas types proofs terms

5 logics versus type theories many type theories propositional logic λ predicate logic λp dependent types second order logic λ2 polymorphism Martin-Löf s type theories MLW MLW ext PU <ω CC = calculus of constructions Coq logic pcic = Coq s type theory proof assistant competitor of ZFC set theory

6 why types? semantics λx.xx x dom(x)? Curry-Howard isomorphism logic! termination = SN = strong normalization compute the value of any term

λ 7

8 names for λ Alonzo Church λ Church s type theory simply typed lambda calculus simple type theory simple theory of types STT

9 description of a logic/type theory in general 1 syntax 2 rules terms types formulas sequents Γ A typing judgments Γ M : A... proof rules typing rules... 3 semantics

10 description of λ 1 syntax 2 rules types terms contexts judgments typing rules

11 types grammar of types: function types A ::= a (A A) A, B, C,... a, b, c,... meta-variables for types atomic types a b = type of functions from a to b

12 terms grammar of pseudo-terms: function application M ::= x (MM) (λx : A. M) M, N, F,... variable abstraction λx : A. M λx A M x x A explicitly typed variables = Church-style

13 Curry-style versus Church-style Curry-style: λx.x : a a λx.x : b b λx.x : (a b) (a b) same term with multiple types Church-style: λx : a. x : a a λx : b. x : b b λx : a b. x : (a b) (a b) different terms with each a single type

14 contexts grammar of contexts: Γ ::= Γ, x : A Γ,,... empty context the and possible following comma is not written: x 1 : A 1,..., x n : A n

15 judgments typing judgments: x 1 : A 1,..., x n : A n }{{} Γ M : B in context Γ the term M is well-typed and has type B terms and judgments: equivalence classes up to alpha in rules: all x i are different Barendregt convention

16 typing rules variable rule application rule Γ x : A x : A Γ abstraction rule Γ F : A B Γ M : A Γ FM : B Γ, x : A M : B Γ λx : A. M : A B

17 example: typed K untyped: K λxy.x typed in λ : K λx : a. λy : b. x }{{} : b a : a b a

18 example: type derivation for K }{{} Γ is empty x : a, y : b x : a x : a λy : b. x : b a λx : a. λy : b. x }{{} M : a b a }{{} B

minimal logic 19

20 minimal propositional logic implicational logic only connective is intuitionistic not classical logic styles: 1 Hilbert system 2 sequent calculus 3 natural deduction Gentzen-style Jaśkowsky/Fitch-style ((a b) a) a

21 formulas grammar of formulas: implication A ::= a (A A) A, B, C,... a, b, c,... meta-variables for formulas atomic propositions

22 proof rules implication introduction A A....... B A B I implication elimination = modus ponens. A B B. A E

23 example: proof of a b a if a then it holds that if b then a a implies that b implies a a x b a I y a b a I x

24 proof terms... and now in stereo! logic a x b a I y a b a I x type theory x : a, y : b x : a x : a λy : b. x : b a λx : a. λy : b. x : a b a

25 BHK interpretation Luitzen Egbertus Jan Brouwer Arend Heyting Andrey Kolmogorov intuitionistic interpretation of logical connectives: proof of A B = pair of a proof of A and a proof of B proof of A B = either a proof of A or a proof of B proof of A B = mapping of proofs of A to proofs of B proof of A = proof of A proof of does not exist proof of = the unique proof of

26 intuitionism classical logic A B = at least one of A and B holds x P(x) = there is an x for which P(x) holds (but we might not be able to know which) intuitionistic logic = constructive logic A B = we can compute which of A or B holds x P(x) = we can compute an x for which P(x) holds Luitzen Egbertus Jan Brouwer a a a a ((a b) a) a

27 is classical logic or intuitionistic logic more intuitive? classical: ZF 2 ℵ 0 = ℵ 1 2 ℵ0 ℵ 1 ZF 2 ℵ 0 = ℵ 1 ZF 2 ℵ0 ℵ 1 intuitionistic: M is a Turing machine that looks for a proof of in IZF IZF M M IZF (M M )

styles of logic 28

29 styles of logic 1 Hilbert system David Hilbert 2 sequent calculus Gerhard Gentzen 3 natural deduction Gentzen-style Gerhard Gentzen Jaśkowsky/Fitch-style Stanis law Jaśkowski Frederic Fitch

30 logic style 1: Hilbert system just one proof rule modus ponens. Ạ. A B. B MP axiom schemes A B A K (A B C) (A B) A C S

31 example: proof of a a 1 (a (b a) a) (a b a) a a S 2 a (b a) a K 3 (a b a) a a MP 1,2 4 a b a K 5 a a MP 3,4

32 Curry-Howard for Hilbert system logic type theory Hilbert system typed combinatory logic proof of a a SKK = β I deduction theorem converting lambda terms to combinatory logic

33 logic style 2: sequent calculus sequents: A 1,...,A n B 1,...,B m to be read as: A 1... A n B 1... B m A 1,...,A n and B 1,...,B n are sets, not lists

34 intro/elim versus left/right for each logical connective : natural deduction: intro rules elim rules sequent calculus: left rules right rules I E L R

35 proof rules assumption rule left rule for implication Γ, A A, ass right rule for implication Γ A, Γ, B L Γ, A B Γ, A B, Γ A B, R

36 example: proof of a b a a, b a ass a b a R a b a R

37 cuts cut rule Γ, A A, Γ cut Γ cut elimination theorem: all provable statements can also be proved with a cut-free proof

38 general shape of sequent calculus proof rules rules for : Γ, A Γ, B Γ, A B L Γ A, B, Γ A B, R rules for :............... L............... R

39 Curry-Howard for sequent calculus Michel Parigot λµ Hugo Herbelin λµ µ Curry-Howard for classical logic exceptions: throw/catch variables for continuations

40 intuitionistic sequent calculus system LK: classical sequent calculus system LJ: intuitionistic sequent calculus only sequents with one formula on the right: A 1,...,A n B proof rules adapted accordingly

41 logic style 3a: natural deduction, Gentzen-style this system already has been presented now in sequent presentation instead of formulas: now sequents: B A 1,...,A n B }{{} open assumptions

42 proof rules assumption rule implication introduction Γ A ass A Γ Γ, A B Γ A B I implication elimination Γ A B Γ B Γ A E

43 example: proof of a b a a, b a ass a b a I a b a I

44 general shape of natural deduction proof rules rules for : Γ A Γ A B I l Γ B Γ A B I r Γ A B Γ, A C Γ, B C C E rules for :............ I............ E...

45 intro/elim versus left/right, revisited natural deduction: introduction and elimination rules............... I......... E...... sequent calculus: left and right rules............... L............... R

46 is sequent calculus more attractive...? Γ, A, B Γ, A B L Γ A, Γ B, R Γ A B, Γ, A Γ, B Γ, A B L Γ A, B, Γ A B, R Γ A, Γ, A L Γ, A Γ A, R Γ Γ, L Γ, R Γ, L Γ Γ, R

47... or is natural deduction more attractive? Γ A Γ B I Γ, A B Γ A B Γ A E l Γ A B Γ B E r Γ A Γ A B I l Γ B Γ A B I r Γ A B Γ, A C Γ, B C C E Γ, A Γ A I Γ A Γ A E Γ Γ I Γ Γ A E

48 Curry-Howard for natural deduction, again logic a, b a ass a b a I a b a I type theory x : a, y : b x : a x : a λy : b. x : b a λx : a. λy : b. x : a b a

49 logic style 3b: natural deduction, Jaśkowsky/Fitch-style 1 a ass 2 b ass 3 a copy 1 4 b a I 2 3 5 a b a I 1 4 1 a a ass 2 a, b b ass 3 a, b a weaken 1 4 a b a I 3 5 a b a I 4

detour elimination 50

51 detour elimination detour = intro rule directly followed by corresponding elim rule....... I... E... detours for implication behave like cuts sequent calculus: cut elimination natural deduction: detour elimination detour elimination theorem: all provable statements can also be proved with a detour-free proof

52 example with a detour a y a a I y a x a a a I x E proof term: λx : a. (λy : a. y)x λx. (λy.y)x }{{} redex!

53... written with sequents and with proof terms a, a a ass a a a I a a ass E a a a a I x : a, y : a y : a x : a λy : a. y : a a x : a x : a x : a (λy : a. y)x : a λx : a. (λy : a. y)x : a a

54 detour elimination in general A A....... B A B I B. A E.. A A....... B proof of B using a lemma A

55... written with sequents and with proof terms. Γ, A B Γ A B I Γ B. Γ A E. Γ B. Γ, x : A M : B Γ λx : A. M : A B I Γ (λx : A. M)N : B. Γ N : A E. Γ M[x := N] : B

56 normalization of proofs and terms reduction corresponding to detour elimination: (λx : A. M)N β M[x := N] Curry-Howard: logic type theory proof term detour elimination β-reduction detour-free proof term in β-normal form

consistency 57

58 subject reduction theorem (subject reduction = SR) Γ M : A and M β N then Γ N : A proof: induction on the number of steps in the reduction for a single step: induction on the definition of β using the subsitution lemma below lemma (substitution lemma) Γ, x : B M : A and Γ N : B then Γ M[x := N] : A lemma (weakening) Γ M : A then Γ, x : B M : A lemma (stengthening) Γ, x : B M : A and x FV(M) then Γ M : A

termination and confluence theorem (strong normalization = SN) Γ M : A then there is no infinite M β M 1 β M 2 β... proof later in the course theorem every inhabited type has an inhabitant in β-normal form proof: combine subject reduction and strong normalization theorem (Church-Rosser = CR) M 1 M N M 2 proof: the proof for the untyped case respects types 59

60 long normal forms if M has type A B and x FV(M) then λx : A. Mx η M M η λx : A. Mx long normal form = β η-normal form λf : a b. f λf : a b. λx : a. fx : (a b) a b : (a b) a b theorem every inhabited type has an inhabitant in long normal form

61 consistency definition a logic is called inconsistent if A for all formulas A theorem minimal propositional logic is consistent proof: analyze possibilities for β-normal forms M with M : a β-normal form: both impossible: λx : A. M xm 1...M k a is not a function type no variables in empty context by Curry-Howard: a

62 recap 1 Curry-Howard 2 λ 3 minimal logic 4 styles of logic Hilbert system sequent calculus natural deduction Gentzen-style Jaśkowsky/Fitch-style 5 detour elimination 6 consistency