Some Recent Logical Frameworks

Similar documents
HOAS by example What is a Formal System? A Simply Typed Framework What Does it Mean? Canonical LF References HOAS. Randy Pollack

Justifying Algorithms for βη-conversion

On Equivalence and Canonical Forms in the LF Type Theory (Extended Abstract) Robert Harper and Frank Pfenning Department of Computer Science Carnegie

Mechanizing Metatheory in a Logical Framework

Lecture Notes on A Concurrent Logical Framework

Subtyping and Intersection Types Revisited

Lecture Notes on Call-by-Value and Call-by-Name

Strong Normalization with Singleton Types

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

A Bidirectional Refinement Type System for LF

A Logical Framework with Dependently Typed Records

A Concurrent Logical Framework

Candidates for Substitution

07 Equational Logic and Algebraic Reasoning

Mechanizing a Decision Procedure for Coproduct Equality in Twelf

Computer Science at Kent

Focusing on Binding and Computation

The Curry-Howard Isomorphism

Lecture Notes on Intuitionistic Kripke Semantics

The Calculus of Inductive Constructions

On Equivalence and Canonical Forms in the LF Type Theory

A Canonical 1 Local Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

Mode checking in the Concurrent Logical Framework

Lecture Notes on The Concurrent Logical Framework

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge

Termination and Reduction Checking for Higher-Order Logic Programs

A Practical Module System for LF

On a Logical Foundation for Explicit Substitutions

Notes on Logical Frameworks

Properties of Terms in Continuation-Passing Style in an Ordered Logical Framework

A Syntactic Account of Singleton Types via Hereditary Substitution

Algorithms for Equality and Unification in the Presence of Notational Definitions

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

COMP6463: λ-calculus

Theoretical Computer Science. Representing model theory in a type-theoretical logical framework

The Church-Rosser Property for -reduction in Typed -Calculi. Herman Geuvers. University of Nijmegen

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

On Equivalence and Canonical Forms inthelftypetheory

Beyond First-Order Logic

Lecture Notes on Data Abstraction

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

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

Normalization by Evaluation for Intuitionistic Propositional Logic

Meta-reasoning in the concurrent logical framework CLF

Lecture Notes on Combinatory Modal Logic

Intensionality, Extensionality, and Proof Irrelevance in Modal Type Theory

Deductive System: Calculus of axioms and inference rules dening judgments. Used in the presentation of logics and programming derivable Logical Framew

Meta-Reasoning in a Concurrent Logical Framework

Γ is usually left implicit: ϕ

A Proof Theory for Generic Judgments

Consequence Relations and Natural Deduction

Lecture Notes on Heyting Arithmetic

An insider s look at LF type reconstruction:

Explicit Convertibility Proofs in PTSs

Sequent Combinators: A Hilbert System for the Lambda Calculus

Local Representations of Binding

Normalization by Evaluation

Relative Hilbert-Post completeness for exceptions

REFINEMENT TYPES FOR LOGICAL FRAMEWORKS AND THEIR INTERPRETATION AS PROOF IRRELEVANCE

A Concurrent Logical Framework: the Propositional Fragment

LF P A Logical Framework with External Predicates

arxiv: v3 [cs.pl] 15 May 2011

M, N ::= x λp : A.M MN (M, N) () c A. x : b p x : b

Lecture Notes on The Curry-Howard Isomorphism

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

Cubical Type Theory: a constructive interpretation of the univalence axiom

Omitting Types in Fuzzy Predicate Logics

Intensionality, Extensionality, and Proof Irrelevance in Modal Type Theory

Lazy Strong Normalization

Introduction to Logic in Computer Science: Autumn 2006

Type Inference Algorithms

Specification of Core Agda Subtitle

Constructive approach to relevant and affine term calculi

An extension of HM(X) with bounded existential and universal data-types

Natural deduction for propositional logic via truth tables

Supplementary Notes on Inductive Definitions

Structural Foundations for Abstract Mathematics

Mathematical Logics. 12. Soundness and Completeness of tableaux reasoning in first order logic. Luciano Serafini

Simply Typed λ-calculus

Introduction to lambda calculus Part 2

CS522 - Programming Language Semantics

Algebraic Trace Theory

A Concurrent Logical Framework:

Extended Abstract: Reconsidering Intuitionistic Duality

On Equivalence and Canonical Forms inthelftypetheory

Second-Order Equational Logic

Modularity of Confluence: A Simplified Proof

Isomorphism of Finitary Inductive Types

Algebraic Trace Theory

First Order Logic (FOL) 1 znj/dm2017

Classical First-Order Logic

Lectures on The Lambda Calculus (I)

Logic for Computational Effects: work in progress

Type Systems as a Foundation for Reliable Computing

A Terminating and Confluent Linear Lambda Calculus

Diagrams for Meaning Preservation

Tutorial on Semantics Part I

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

Ordinal Strength of Logic-Enriched Type Theories

A concurrent logical framework I: Judgments and properties

Transcription:

Some Recent Logical Frameworks Randy Pollack LFCS, University of Edinburgh Version of September 13, 2010

Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

Edinburgh Logical Framework (ELF) (LICS 1987) Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Reminder by Example: Syntax of FOL i : type. % Individuals zero : i. suc : i -> i. plus : i -> i -> i. o : type. % Propositions imp : o -> o -> o. and : o -> o -> o. or : o -> o -> o. forall : (i -> o) -> o. eq : i -> i -> o. Framework handles binding

Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Reminder by Example: Some Natural Deduction Rules [A] B A B A B B A A A B A B C [A] C [B] C prf : o -> type. impi : {A, B : o} (prf A -> prf B) -> prf (A imp B). impe : prf (A imp B) -> prf A -> prf B. ori1 : prf A -> prf (A or B). ore : prf (A or B) -> (prf A -> prf C) -> (prf B -> prf C) -> prf C. Framework handles hypothetical and schematic judgements.

Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Reminder by Example: Some more rules [ [A] ] A(x) x.a (x fresh) x.a A(t) A B C B C foralli : ({x:i} prf (A x)) -> prf (forall A). foralle : prf (forall A) -> {T:i} prf (A T). -- A Schroeder-Heister version of imp elim SH_impe : prf (A imp B) -> ((prf A -> prf B) -> prf C) -> --------------------------- prf C Framework handles freshness and substitution. The SH rule is clear in the framework (it is third order).

Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Remark on Canonical Forms We want to have a compositional isomorphism between object language expressions and canonical forms of the LF. In order for the framework to handle substitution, we identify meta-terms up to β. But β is not enough, we need η -equivalence in the notion of canonical. Example: the two well-typed LF terms suc [x:i](suc x) represent the same object expression (a function symbol of the language of FOL).

Edinburgh Logical Framework (ELF) (LICS 1987) Some Problems with ELF Some Problems with ELF: η equivalence Problem η reduction of raw ELF terms is not Church Rosser: for x B [x : A]C β [x : A](([x : B]C)x) η [x : B]C where A and B may be anything. Well typed terms are βη -Church Rosser. But equality becomes mutually recursive with the typing relation. Thus, the meta theory of βη -equivalence for the ELF language (with type tags) is complicated. See [Geu93], [Sal], [HP05], [Gog05]. Further, many extensions (singleton types, dependent pairs, linear types,...) interact badly with η. We want equality of raw terms to be decidable.

Edinburgh Logical Framework (ELF) (LICS 1987) Some Problems with ELF Some Problems with ELF: Too many terms are typed The correct ELF terms plus zero eq zero imp A represent no object language term or proposition at all.

Edinburgh Logical Framework (ELF) (LICS 1987) Some Problems with ELF Some Problems with ELF: Too many terms are typed The correct ELF terms plus zero eq zero imp A represent no object language term or proposition at all. We consider some LFs that address these problems. Two related ideas: Canonical Syntax: only canonical terms are syntactically well-formed. Hereditary Substitution: substitution propogates since redexes cannot be formed for syntactic reasons.

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Plotkin s DMBEL: Syntax identifiers types σ, τ ::= S( A ) abstraction types α, β ::= (Γ)σ S (type constants), F (term constants), x (term variables), φ (abstraction variables) terms t, u ::= x F ( A ) φ( t ) abstraction terms A, B ::= (Γ)t contexts Γ, ::= Γ, x:σ abstraction contexts Φ, Ψ ::= Φ, φ:α signatures Σ ::= Σ, S(Φ) Σ, F(Φ):σ Typechecking: abstraction and application arities match. No β or η redexes. Only constants and variables are applied...... and they are fully applied. Equality is identity of raw expressions.

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Example in Plotkin s DMBEL: First order logic Concrete syntax: type constants start with * term constants start with @ abstraction variables start with a capital, X term variables start with lower case, x *i, -- type of individuals @zero : *i, -- order 0 @suc(*i) : *i, -- order 1 *o, -- type of propositions @imp(*o, *o) : *o, -- order 1 @all((*i)*o) : *o, -- order 2 @eq(*i, *i) : *o -- order 1 Partially applied terms, @eq(@zero), are not well-typed

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Example in Plotkin s DMBEL: First order rules *prf(*o), @impi(x Y:*o, (*prf(x))*prf(y)) : *prf(@imp(x, Y)), @impe(x Y:*o, *prf(@imp(x, Y)), *prf(x)) : *prf(y), @alli(p:(*i)*o, (x:*i)*prf(p(x))) : *prf(@all((x:*i)p(x))), -- note eta expansion ^^^^^^^^^^ @alle(p:(*i)*o, X:*i, *prf(@all((x:*i)p(x)))) : *prf(p(x)) The Schroeder Heister rule is not representable in this system requires third order types. This system is not easily represented in itself or any other current LF because of the abstraction/application vectors.

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Plotkin s DMBEL: Judgement Forms Validity of Signatures, Abstraction Contexts and Contexts: Σ Σ Φ Φ Σ Γ Checking correctness of Types and Abstraction Types: Φ ; Γ Σ σ Φ ; Γ Σ α Inferring (Abstraction) Types of (Abstraction) Terms: Φ ; Γ Σ t σ Checking the types of (Abstraction) Records: Φ ; Γ Σ t Φ ; Γ Σ A α Φ ; Γ Σ A Ψ Bi-directional typechecking, completely syntax directed. Cannot infer dependent types of records, as they are not unique. As usual for dependent tuples, e.g. in FOL have (True, id) : (x:o, y:prf(x)) and (True, id) : (x:o, y:prf(true)).

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Plotkin s DMBEL: Typing Rules Types and Abstraction Types Φ ; Γ Σ A Ψ Φ ; Γ Σ S( A ) S(Ψ) Σ Φ ; Γ, Σ σ Φ ; Γ Σ ( )σ Terms Φ Σ Γ Φ ; Γ Σ x σ x:σ Γ Φ ; Γ Σ A Ψ Φ ; Γ Σ F ( A ) σ[ A / φ ] F (Ψ):σ Σ Ψ = φ : α Abstraction Terms Φ ; Γ Σ t Φ ; Γ Σ φ( t ) σ[ t / x ] Φ ; Γ, Σ t σ Φ ; Γ Σ ( )t ( )σ φ:( )σ Φ = x : σ

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Plotkin s DMBEL: Typing Rules Records Φ Σ Γ Φ ; Γ Σ Abstraction Records Φ ; Γ Σ t τ Φ ; Γ Σ u [t/x] Φ ; Γ Σ t, u x:σ, τ = σ Φ Σ Γ Φ ; Γ Σ Φ ; Γ Σ A β Context and Abstraction Context Validity Σ Φ Φ Σ Signature Validity Φ ; Γ Σ σ Φ Σ Γ, x:σ Φ ; Γ Σ B Ψ[A/φ] Φ ; Γ Σ A, B φ:α, Ψ Σ Φ Σ, S(Φ) Σ Σ Φ ; Σ σ Σ, F(Φ):σ Φ ; Σ α Σ Φ, φ:α β = α

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Plotkin s DMBEL: Hereditary Substitution... What is the notion of substitution that appears in these rules? First-order substitution as usual: u[ t / x ], A[ t / x ], σ[ t / x ], α[ t / x ], Γ[ t / x ], congruence, generated by the occurrences of x in terms, termination as usual: structurally decreasing.

Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Plotkin s DMBEL: Hereditary Substitution (cont d) Second-order substitution, _[A/φ]. congruence, generated by the occurrences of φ in terms: x[a/φ] = x F ( B )[A/φ] = F ( B [A/φ]) φ( t )[A/φ] = φ(t 1,..., t n )[(x 1 :σ 1,..., x n :σ n )u/φ] = u[t 1 [A/φ],..., t n [A/φ]/x 1,..., x n ] φ( t )[A/φ ] = φ( t [A/φ ]) (φ φ ) Termination: second order substitutions are structurally decreasing. May give rise to (terminating) first order substutution. Really need a syntactic notion of arity to be precise.

Some Other Frameworks with Arities Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

Some Other Frameworks with Arities Luo s PAL + Developed in late 1990 s; journal version [Luo03]. Named after Automath language PAL A lambda-free version of Luo s LF [Luo94]. Basic principles: parameterisation (with instantiation) and definition. Also allows inductive definition. Parameterisation and instantiation have arities; arities must match. Allowing precise specification of object language, as in DMBEL. Arbitrary orders of types, but no nested parameterisation. Parametric definitions, both local and global. Thus abstraction can be expressed. Has real computation: eta and delta rules. Meta-theory by Typed Operational Semantics: complex. Some work towards support of coercive subtyping.

Some Other Frameworks with Arities Robin Adams Hierarchy of Frameworks, TF Robin Adams thesis [Ada05] precedes Plotkins DMBEL. In his thesis, Adams gives a hierarchy of systems that extend DMBEL to orders 3, 4,.... Adams thesis contains many interesting and explanatory examples.

Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

Accepts exactly the canonical judgements accepted by ELF. Developed by Watkins, Pfenning, and co-workers [WCPW02, HL06]. This work precedes both Adams TF and Plotkin s DMBEL. Only β -normal terms are syntactically formed. Only canonical terms ( η -expanded, β -normal) are well-typed. Equality is syntactic identity of expressions. A notion of hereditary substitution is needed. Bi-directional typechecking: syntax directed and decidable.

: Syntax identifiers a (type constants), c (term constants), x (term variables) kinds K ::= type Πx:A.K types A, B ::= P Πx:A.B atomic types P ::= a P M terms M ::= R λx.m atomic terms R ::= c x R M contexts Γ, ::= Γ, x:a signatures Σ ::= Σ, a:k Σ, c:a

: Judgement Forms Validity of signatures and contexts: Σ sig Σ Γ cxt Checking correctness of kinds and types: Γ Σ K kind Γ Σ A type Inferring kinds of atomic types, and the types of atomic terms: Γ Σ P K Γ Σ R A Checking the types of terms: Γ Σ M A Bi-directional typechecking, completely syntax directed. Cannot infer the type of λx.m : no type annotation on x.

: Rules Signatures sig Contexts Σ sig Σ K kind Σ, a:k sig Σ sig Σ A type Σ, c:a sig Σ sig Σ cxt Σ Γ cxt Γ Σ A type Σ Γ, x:a cxt

: Rules Kinds Types Atomic Types Σ Γ cxt Γ Σ type kind Γ, x:a Σ B type Γ Σ Πx:A.B type Γ, x:a Σ K kind Γ Σ Πx:A.K kind Γ Σ P type Γ Σ P type Σ Γ cxt Γ Σ a K (a:k Σ) Γ Σ P Πx:A.K Γ Σ M A Γ Σ P M [M (A) /x]k

: Rules Terms Γ, x:a Σ M B Γ Σ λx.m Πx:A.B Γ Σ R P Γ Σ R P ( ) Atomic Terms Σ Γ cxt (x:a Γ) Γ Σ x A Σ Γ cxt (c:a Σ) Γ Σ c A Γ Σ R Πx:A.B Γ Σ M A Γ Σ R M [M (A) /x]b ( ) This restriction to atomic types, P, makes judgements canonical.

Hereditary Substitution Hereditary Substitution: Pure λ-terms Let L, M, N be lambda terms. [M /x]x = M [M /x]y = y if x y [M /x](λy.n) = λy.[m /x]n y fresh [M /x](l N) = ([ ˆN /y]m ) if ˆL = (λy.m ) = ˆL ˆN otherwise where ˆL = [M /x]l and ˆN = [M /x]n If M and N have no β -redexes, then [M /x]n is β -equal to the usual substitution M[x/N] contains no β -redexes However [M /x]n may not terminate. We use types to control how deep the substitution goes.

Hereditary Substitution Hereditary Substitution: Simply typed terms [Abe06] Let L, M, N be lambda terms. Let A, B, C be simple types [M A /x]x = M A [M A /x]y = y if x y [M A /x](λy.n) = λy.[m A /x]n y fresh [M A /x](l N) = ([ ˆN B /y]m ) C if ˆL = (λy.m ) B C = ˆL ˆN otherwise where ˆL = [M A /x]l and ˆN = [M A /x]n If M and N have no β -redexes, then [M /x]n is β -equal to the usual substitution M[x/N] contains no β -redexes if the type annotation is correct Always terminates: newly created substitutions operate on subterms, or have syntactically smaller types.

Hereditary Substitution Hereditary Substitution: LF types exactly the same lambda-terms as simple types...... just throw away the dependency. (a) = a (P M) = (P) (Πx:A.B) = (A) (B) Only the shape of the simple type matters: can take (a) =. One more problem: canonical terms cannot contain redexes. Instead of returning a term with a redex (when the given type is incorrect), the canonical hereditary substitution algorithm must return failure. Finally, [M (A) /x]_ is a congruence, generated by the replacement of term variables in terms, as explained above.

Judgements are Canonical Judgements are Canonical by Stratified Syntax We want to know that no two derivable judgements differ only by βη. Let Σ = a:type. (a a) is a non-atomic type, syntactic class A, not class P. Direction : f :(a a) Σ f (a a) is derivable, f :(a a) Σ λx.f x (a a) is not derivable: λx.f x is of class M, not of class R, there are no rules of shape Γ Σ M A.

Judgements are Canonical Judgements are Canonical by Stratified Syntax Direction : f :(a a) Σ f (a a) is not derivable. f is not of shape λx.m and a a is not of shape P, so no rule applies. f :(a a) Σ λx.f x (a a) is derivable: Let Γ = f :(a a), x:a. f :(a a) Σ a type f :(a a) Σ a type ( ) At atomic type. Γ Σ f (a a) f :(a a) Σ λx.f x (a a) Γ Σ x a Γ Σ x a ( ) Γ Σ f x a Γ Σ f x a ( ) [x /_]a = a

References Outline Edinburgh Logical Framework (ELF) (LICS 1987) Reminder by Example Some Problems with ELF Plotkin s DMBEL: Dependent Multi-sorted Binding Equational Logic Syntax and Examples Some Other Frameworks with Arities Hereditary Substitution Judgements are Canonical References

References References [Abe06] [Ada05] [Geu93] [Gog05] [HL06] [HP05] [Luo94] [Luo03] [Sal] [WCPW02] Andreas Abel. Implementing a normalizer using sized heterogeneous types. In Workshop on Mathematically Structured Functional Programming, MSFP 2006. Robin Adams. A Modular Hierarchy of Logical Frameworks). PhD thesis, University of Manchester, 2005. Herman Geuvers. Logics and Type Systems. PhD thesis, Univ. of Nijmegen, 1993. Healfdene Goguen. A syntactic approach to eta equality in type theory. In POPL 2005. Robert Harper and Daniel R. Licata. Mechanizing Metatheory in a Logical Framework. Submitted for publication. Available from http://www.cs.cmu.edu/~drl/, Oct. 2006. Robert Harper and Frank Pfenning. On equivalence and canonical forms in the LF type theory. ACM Trans. on Computational Logic, 6(1), 2005. Z. Luo. Computation and Reasoning: A Type Theory for Computer Science. International Series of Monographs on Computer Science. Oxford Univ. Press, 1994. Zhaohui Luo. PAL + : a lambda-free logical framework. Journal of Functional Programming, 13(2):317 338, 2003. Anne Salvesen. The Church-Rosser theorem for LF with beta/eta reduction. Talk given at First Workshop on Logical Frameworks, Antibes, 1990. Kevin Watkins, Iliano Cervesato, Frank Pfenning, and David Walker. A concurrent logical framework I: Judgments and properties. Technical Report CMU-CS-02-101, Department of Computer Science, Carnegie Mellon University, 2002. Revised May 2003.