logic and computation
play

Logic and Computation Lecture 2 Zena M. Ariola University of - PowerPoint PPT Presentation

Logic and Computation Lecture 2 Zena M. Ariola University of Oregon 24th Estonian Winter School in Computer Science, EWSCS 19 Curry-Howard isomorphism A correspondence between minimal propositional logic and simply typed lambda-calculus


  1. Logic and Computation Lecture 2 Zena M. Ariola University of Oregon 24th Estonian Winter School in Computer Science, EWSCS ’19

  2. Curry-Howard isomorphism A correspondence between minimal propositional logic and simply typed lambda-calculus Types ( → , + , × ) are Propositions ( → , ∧ , ∨ ) Terms are Proofs Computation is Eliminations of detours Extensionality is Expansion A system is both a programming language and a logic (Coq, Agda, Idris)

  3. Outline Extend the isomorphism to more expressive systems

  4. Outline Extend the isomorphism to more expressive systems Logic Type Theory Second-order propositional logic Polymorphism

  5. Outline Extend the isomorphism to more expressive systems Logic Type Theory Second-order propositional logic Polymorphism Intuitionistic logic λ -calculus + Abort

  6. Outline Extend the isomorphism to more expressive systems Logic Type Theory Second-order propositional logic Polymorphism Intuitionistic logic λ -calculus + Abort Classical logic λ -calculus + Jumps

  7. Outline Extend the isomorphism to more expressive systems Logic Type Theory Second-order propositional logic Polymorphism Intuitionistic logic λ -calculus + Abort Classical logic λ -calculus + Jumps Compilation ≈ logical embeddings

  8. Minimal Second-order Propositional Logic A ⊢ A Ax ⊢ A → A → I

  9. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I

  10. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I

  11. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof?

  12. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I

  13. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I X ⊢ X Ax ⊢ X → X → I ⊢ ∀ X . X → X ∀ I

  14. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I X ⊢ X Ax ⊢ X → X → I ⊢ ∀ X . X → X ∀ I What about this proof? X ⊢ X Ax X ⊢ ∀ X . X ∀ I

  15. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I X ⊢ X Ax ⊢ X → X → I ⊢ ∀ X . X → X ∀ I What about this proof? X ⊢ X X ⊢ ∀ X . X ∀ I ∀ E X ⊢ X Ax X ⊢ B ⊢ X → B → I X ⊢ ∀ X . X ∀ I

  16. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I X ⊢ X Ax ⊢ X → X → I ⊢ ∀ X . X → X ∀ I What about this proof? X ⊢ X X ⊢ ∀ X . X ∀ I ∀ E X ⊢ X Ax X ⊢ B ⊢ X → B → I X ⊢ ∀ X . X ∀ I Γ ⊢ ∀ X . A no variable capture occurs Γ ⊢ A X does not occur free in Γ ∀ ∀ I E Γ ⊢ ∀ X . A Γ ⊢ A [ B / X ]

  17. Minimal Second-order Propositional Logic A ⊢ A Ax A → B ⊢ A → B Ax A ∧ B ⊢ A ∧ B Ax ⊢ A → A → I ⊢ ( A → B ) → ( A → B ) → I ⊢ ( A ∧ B ) → ( A ∧ B ) → I How do we express the fact that they are the same proof? X ⊢ X Ax ⊢ X → X → I X ⊢ X Ax ⊢ X → X → I ⊢ ∀ X . X → X ∀ I What about this proof? X ⊢ X X ⊢ ∀ X . X ∀ I ∀ E X ⊢ X Ax X ⊢ B ⊢ X → B → I X ⊢ ∀ X . X ∀ I Γ ⊢ ∀ X . A no variable capture occurs Γ ⊢ A X does not occur free in Γ ∀ ∀ I E Γ ⊢ ∀ X . A Γ ⊢ A [ B / X ] ⊢ ( ∀ X . X ) → A ⊢ A → ∀ X . (( A → X ) → X ) �⊢ A → ∀ X . X

  18. System F - Jean-Yves Girard, 1972 Girard believed in Howard’s approach that proofs are mathematical objects. He introduced System F as a representations of proofs in second-order propositional logic

  19. System F - Jean-Yves Girard, 1972 Girard believed in Howard’s approach that proofs are mathematical objects. He introduced System F as a representations of proofs in second-order propositional logic A ∧ B = ∀ X . ( A → B → X ) → X A ∨ B = ∀ X . ( A → X ) → ( B → X ) → X ⊥ = ∀ X . X nat = ∀ X . X → ( X → X ) → X = ∀ X . X → X → X bool

  20. System F - Jean-Yves Girard, 1972 Girard believed in Howard’s approach that proofs are mathematical objects. He introduced System F as a representations of proofs in second-order propositional logic A ∧ B = ∀ X . ( A → B → X ) → X A ∨ B = ∀ X . ( A → X ) → ( B → X ) → X ⊥ = ∀ X . X nat = ∀ X . X → ( X → X ) → X = ∀ X . X → X → X bool If Γ ⊢ M : A then it does not exists an infinite reduction starting from M

  21. Programming: Polymorphism The simple type system we have seen so far forces us to duplicate code: sortI: int list -> (int->int->bool)->int list sortR: real list->(real->real->bool)->real list

  22. Programming: Polymorphism The simple type system we have seen so far forces us to duplicate code: sortI: int list -> (int->int->bool)->int list sortR: real list->(real->real->bool)->real list Weaken the type system by introducing a universal type : void qsort (void* base, int num, int size, int (*comparator)(const void*,const void*));

  23. Programming: Polymorphism The simple type system we have seen so far forces us to duplicate code: sortI: int list -> (int->int->bool)->int list sortR: real list->(real->real->bool)->real list Weaken the type system by introducing a universal type : void qsort (void* base, int num, int size, int (*comparator)(const void*,const void*)); Enrich the type system by allowing to express the fact that the function’s behavior is uniform for different type instantiation

  24. Polymorphic lambda calculus - John Reynold, 1974 Given the expressions M = (2+2)+(2+2) and N = (3+3)+(3+3) we are accustomed to abstract over the expressions 2+2 and 3+3 giving the function λ x . x + x so that M =( λ x . x + x ) ( 2+2 ) N =( λ x . x + x ) ( 3+3 ) Given the types : τ = int list -> (int->int->bool)->int list σ = real list->(real->real->bool)->real list why not abstracting over the types int and real giving the function type: forall α.α list -> ( α -> α -> bool) -> α list so that τ = ( forall α.α list -> ( α -> α -> bool) -> α list) int σ = (forall α.α list -> ( α -> α -> bool) -> α list) real The same idea to avoid duplication of code applies to avoid replication at the type level

  25. Polymorphic lambda calculus - John Reynold, 1974 Terms M ::= λ x : σ. M | M M | x | Λ α. M | M [ σ ] Types σ ::= α | σ → σ | ∀ α.σ Type system Γ , x : σ ⊢ x : σ Γ , x : σ ⊢ M : τ Γ ⊢ M : σ → τ Γ ⊢ N : σ Γ ⊢ M N : τ Γ ⊢ λ x : σ. M : σ → τ Γ ⊢ M : σ α not free in Γ Γ ⊢ M : ∀ α.σ Γ ⊢ Λ α. M : ∀ α.σ Γ ⊢ M [ τ ] : σ [ τ/α ] Reduction ( λ x . M ) N → M [ N / x ] (Λ α. M ) [ σ ] → M [ σ/α ] Expansion λ x . M x → M Λ α. M [ α ] → M

  26. Proofs are terms ⊢ ( ∀ X . X ) → A ⊢ A → ∀ X . (( A → X ) → X ) �⊢ A → ∀ X . X ⊢ ( ∀ α.α ) → σ ⊢ σ → ∀ α. (( σ → α ) → α ) �⊢ σ → ∀ α.α z : ∀ α.α ⊢ z : ∀ α.α Ax z : ∀ α.α ⊢ z [ σ ] : σ ∀ E ⊢ λ z : ( ∀ α.α ) . z [ σ ] : ( ∀ α.α ) → σ → I z : σ, y : σ → α ⊢ y : σ → α Ax z : σ, y : σ → α ⊢ z : σ Ax → E z : σ, y : σ → α ⊢ y z : σ z : σ ⊢ λ y : σ → α. y z : ( σ → α ) → α → I z : σ ⊢ Λ α.λ y : σ → α. y z : ∀ α. (( σ → α ) → α ) ∀ I ⊢ λ z : σ. Λ α.λ y : σ → α. y z : σ → ∀ α. (( σ → α ) → α ) → I

  27. Barendregt’s lambda cube λω λ C λ 2 λ P 2 λω λ P ω λ → λ P

  28. Intuitionistic Logic Intuitionistic Logic = Minimal Logic + Ex Falso Qodlibet

  29. Intuitionistic Logic Intuitionistic Logic = Minimal Logic + Ex Falso Qodlibet Formulae: A , B ::= X | A → B | A ∧ B | A ∨ B | ⊥ ¬ A = A → ⊥

  30. Intuitionistic Logic Intuitionistic Logic = Minimal Logic + Ex Falso Qodlibet Formulae: A , B ::= X | A → B | A ∧ B | A ∨ B | ⊥ ¬ A = A → ⊥ No introduction rule for ⊥

  31. Intuitionistic Logic Intuitionistic Logic = Minimal Logic + Ex Falso Qodlibet Formulae: A , B ::= X | A → B | A ∧ B | A ∨ B | ⊥ ¬ A = A → ⊥ No introduction rule for ⊥ One elimination rule for ⊥ (Ex Falso Qodlibet): Γ ⊢ ⊥ Γ ⊢ A EFQ

Recommend


More recommend