Lightweight Lemmas in Λprolog

Total Page:16

File Type:pdf, Size:1020Kb

Lightweight Lemmas in Λprolog Lightweight Lemmas in λProlog Andrew W. Appel Amy P. Felty Bell Laboratories and Princeton University Bell Laboratories May 14, 1999 Abstract Def'n λProlog is known to be well-suited for expressing and Lemma implementing logics and inference systems. We show Lemma that lemmas and definitions in such logics can be imple- mented with a great economy of expression. The terms of the meta-language (λProlog) can be used to express the Proof Theorem statement of a lemma, and the type checking of the meta- language can directly implement the type checking of the lemma. The ML-style prenex polymorphism of λProlog EM allows easy expression of polymorphic inference rules, L M A E M C C Logic but a more general polymorphism would be necessary to O A express polymorphic lemmas directly. We discuss both the Terzo and Teyjus implementations of λProlog as well as related systems such as Elf. Trusted code base Figure 1: Lemma machinery is inside the TCB. 1 Introduction It has long been the goal of mathematicians to minimize Definitions and lemmas are essential in constructing the set of assumptions and axioms in their systems. Im- proofs of reasonable size and clarity. A proof system plementers of theorem provers use this principle: they use should have machinery for checking lemmas, and apply- a logic with as few inference rules as possible, and prove ing lemmas and definitions, in the checking of proofs. lemmas outside the core logic in preference to adding new This machinery also is within the TCB; see Figure 1. inference rules. In applications of logic to computer secu- Many theorem-provers support definitions and lemmas rity – such as proof-carrying code [Nec97] and distributed and provide a variety of advanced features designed to authentication frameworks [AF99] – the implementation help with tasks such as organizing definitions and lem- of the core logic is inside the trusted code base (TCB), mas into libraries, keeping track of dependencies, and while proofs need not be in the TCB because they can be providing modularization etc.; in our work we are particu- checked. larly concerned with separating that part of the machinery Two aspects of the core logic are in the TCB: a set of necessary for proof checking (i.e., in the TCB) from the logical connectives and inference rules, and a program in programming-environment support that is used in proof some underlying programming language that implements development. In this paper we will demonstrate a defini- proof-checking – that is, interpreting the inference rules tion/lemma implementation that is about two dozen lines and matching them against a theorem and its proof. of code. 1 kind form type. 2 A core logic kind proof type. The clauses we present use the syntax of the Terzo im- type eq A→A→form. plementation of λProlog [Wic99]. λProlog is a higher- type and form→form→form. type imp form→form→form. order logic programming language which extends Prolog type forall (A→form)→form. in essentially two ways. First, it replaces first-order terms with the more expressive simply-typed λ-terms. Both type proves proof→form→o. Terzo and Teyjus [NM99] (which we discuss later) extend simple types to include ML-style prenex polymorphism infixl and 7. [DM82], which we make use of in our implementation. infixr imp 8. Second, it permits implication and universal quantifica- infix proves 5. tion over objects of any type. We introduce new types and new constants using kind → type assume form o. and type declarations, respectively. For example, a new primitive type t and a new constant f of type t → t → t type initial proof. type and_l form→form→proof are declared as follows: → proof. kind t type. → → type and_r proof proof proof. type f t -> t -> t. type imp_r proof→proof. type imp_l form→form→proof→proof Capital letters in type declarations denote type variables →proof. and are used in representing polymorphic types. In pro- type forall_r (A→proof)→proof. gram goals and clauses, tokens with initial capital letters → → → type forall_l (A form) A proof will denote either bound or free variables. All other to- →proof. kens will denote constants. λ-abstraction is written us- type cut proof→proof→form \ →proof. ing backslash as an infix operator. Universal quantifica- type congr proof→proof tion is written using the constant pi in conjunction with →(A→form)→A→A→proof. a λ-abstraction, eg., pi X\ represents universal quantifi- type refl proof. cation over variable X. The symbols , and => represent conjunction and implication, respectively. The symbol :- denotes the converse of => and is used to write the top- Program 2: Type declarations for core logic. level implication in clauses. The type o is the type of clauses and goals of λProlog. We usually omit universal quantifiers at the top level in definite clauses, and assume implicit quantification over all free variables. The λProlog language [NM88] also has several fea- We will use a running example based on a tiny core tures that allow concise and clean implementation of log- logic of a sequent calculus for a higher-order logic, il- ics, proof checkers, and theorem provers [Fel93]. We use lustrated in Program 2 and 3. We call this the object λProlog [NM88], but the ideas should also be applicable logic to distinguish it from the metalogic implemented by to logical frameworks such as Elf/Twelf [Pfe91, PS99]. λProlog. An important purpose of this paper is to show which To implement assumptions (that is, formulas to the left language features allow a small TCB and efficient rep- of the sequent arrow) we use implication. The goal A => resentation of proofs. We will discuss higher-order ab- B adds clause A to the Prolog clause database, evaluates stract syntax, dynamically constructed clauses, dynam- B, and then (upon either the success or failure of B) re- ically constructed goals, metalevel formulas as terms, moves A from the clause database. It is a dynamically prenex and non-prenex polymorphism, nonparametricity, scoped version of Prolog’s assert and retract.For and type abbreviations. example, suppose we use imp_r(initial) to prove 2 ((eq x y) imp (eq x y)); then λProlog will ex- A,Γ A ecute the (instantiated) body of the imp_r clause: initial proves A :- assume A. assume (eq x y) => Γ A Γ B initial proves (eq x y) Γ A ∧ B (and_r Q1 Q2) proves (A and B) :- This adds assume (eq x y) to the database; then the Q1 proves A, Q2 proves B. subgoal A,Γ B initial proves (eq x y) Γ A → B (imp_r Q) proves (A imp B) :- generates a subgoal assume (eq x y) which assume A => Q proves B. matches our dynamically added clause. A,B,Γ C In our forall_r, forall_l, and congr rules for (A ∧ B),Γ C universal quantification and congruence we take advan- (and_l A B Q) proves C :- tage of λProlog’s higher-order data structures. That is, in assume (A and B), the formula forall A, the term A is a lambda expres- assume A => assume B => Q proves C. sion taking a bound variable and returning a formula; in Γ AB,Γ C this case the bound variable is intended to be the quanti- (A → B),Γ C fied variable. An example of its use is (imp_l A B Q1 Q2) proves C :- forall (X\ forall (Y\ assume (A imp B), Q1 proves A, (eq X Y) imp (eq Y X))) assume B => Q2 proves C. Γ A(Y) for any Y not in the conclusion The parser uses the usual rule for the syntactic extent of a lambda, so this expression is equivalent to Γ ∀x. A(x) (forall_r Q) proves (forall A) :- forall X\ forall Y\ eq X Y imp eq Y X pi Y\ ((Q Y) proves (A Y)). This use of higher-order data structures is called higher- A(T),Γ C order abstract syntax [PE88]; it is very valuable as a (∀x. A(x)), Γ C mechanism for avoiding the need to describe the mechan- (forall_l A T Q) proves C :- ics of substitution explicitly in the object logic [Fel93]. assume (forall A), λ assume (A T) => Q proves C. We have used Prolog’s ML-style prenex polymor- phism to reduce the number of inference rules in the TCB. Γ AA,Γ C Instead of a different forall constructor at each type – C and a corresponding pair of inference rules – we have a (cut Q1 Q2 A) proves C :- single polymorphic forall constructor. Our full core Q1 proves A, logic (not shown in this paper) uses a base type exp of assume A => Q2 proves C. machine integers, and a type exp→exp of functions, Γ X = Z Γ H(Z) so if we desire quantification both at expressions and at Γ H(X) predicates we have already saved one constructor and two (congr Q P H X Z) proves H X :- inference rules! But the user of our logic may wish to Q proves (eq X Z), P proves (H Z). construct a proof that uses universal quantification at an arbitrary higher-order type, so we cannot possibly antic- Γ X = X ipate all the types at which monomorphic forall con- refl proves (eq X X). structors would be needed. Therefore, polymorphism is not just a syntactic convenience – it makes the logic more expressive. Program 3: Inference rules of core logic. 3 We have also used polymorphism to define a general type lemma (A→o)→A→(A→proof)→proof. congruence rule on the eq operator, from which many (lemma Inference Proof Rest) proves C :- other desirable facts (transitivity and symmetry of equal- pi Name\ ity, congruence at specific functions) may be proved as (valid_clause (Inference Name), lemmas.
Recommended publications
  • Foundational Proof Checkers with Small Witnesses
    Foundational Proof Checkers with Small Witnesses Dinghao Wu Andrew W. Appel Aaron Stump Princeton University Washington University in St. Louis dinghao,appel @cs.princeton.edu [email protected] f g ABSTRACT tion of the proof witness to the size of the binary machine- Proof checkers for proof-carrying code (and similar) systems language program. Necula's LFi proof witnesses were about can suffer from two problems: huge proof witnesses and un- 4 times as big as the programs whose properties they proved. trustworthy proof rules. No previous design has addressed both of these problems simultaneously. We show the theory, Pfenning's Elf and Twelf systems [14, 15] are implementa- design, and implementation of a proof-checker that permits tions of the Edinburgh Logical Framework. In these sys- small proof witnesses and machine-checkable proofs of the tems, proof-search engines can be represented as logic pro- soundness of the system. grams, much like (dependently typed, higher-order) Prolog. Elf and Twelf build proof witnesses automatically; if each logic-program clause is viewed as an inference rule, then the 1. INTRODUCTION proof witness is a trace of the successful goals and subgoals In a proof-carrying code (PCC) system [10], or in other executed by the logic program. That is, the proof witness proof-carrying applications [3], an untrusted prover must is a tree whose nodes are the names of clauses and whose convince a trusted checker of the validity of a theorem by subtrees correspond to the subgoals of these clauses. sending a proof. Two of the potential problems with this approach are that the proofs might be too large, and that Necula's theorem provers were written in this style, origi- the checker might not be trustworthy.
    [Show full text]
  • Functions-As-Constructors Higher-Order Unification
    Functions-as-constructors Higher-order Unification Tomer Libal and Dale Miller Inria Saclay & LIX/École Polytechnique, Palaiseau, France Abstract Unification is a central operation in the construction of a range of computational logic systems based on first-order and higher-order logics. First-order unification has a number of properties that dominates the way it is incorporated within such systems. In particular, first-order unifi- cation is decidable, unary, and can be performed on untyped term structures. None of these three properties hold for full higher-order unification: unification is undecidable, unifiers can be incomparable, and term-level typing can dominate the search for unifiers. The so-called pattern subset of higher-order unification was designed to be a small extension to first-order unification that respected the basic laws governing λ-binding (the equalities of α, β, and η-conversion) but which also satisfied those three properties. While the pattern fragment of higher-order unification has been popular in various implemented systems and in various theoretical considerations, it is too weak for a number of applications. In this paper, we define an extension of pattern unifica- tion that is motivated by some existing applications and which satisfies these three properties. The main idea behind this extension is that the arguments to a higher-order, free variable can be more than just distinct bound variables: they can also be terms constructed from (sufficient numbers of) such variables using term constructors and where no argument is a subterm of any other argument. We show that this extension to pattern unification satisfies the three properties mentioned above.
    [Show full text]
  • A Survey of Engineering of Formally Verified Software
    The version of record is available at: http://dx.doi.org/10.1561/2500000045 QED at Large: A Survey of Engineering of Formally Verified Software Talia Ringer Karl Palmskog University of Washington University of Texas at Austin [email protected] [email protected] Ilya Sergey Milos Gligoric Yale-NUS College University of Texas at Austin and [email protected] National University of Singapore [email protected] Zachary Tatlock University of Washington [email protected] arXiv:2003.06458v1 [cs.LO] 13 Mar 2020 Errata for the present version of this paper may be found online at https://proofengineering.org/qed_errata.html The version of record is available at: http://dx.doi.org/10.1561/2500000045 Contents 1 Introduction 103 1.1 Challenges at Scale . 104 1.2 Scope: Domain and Literature . 105 1.3 Overview . 106 1.4 Reading Guide . 106 2 Proof Engineering by Example 108 3 Why Proof Engineering Matters 111 3.1 Proof Engineering for Program Verification . 112 3.2 Proof Engineering for Other Domains . 117 3.3 Practical Impact . 124 4 Foundations and Trusted Bases 126 4.1 Proof Assistant Pre-History . 126 4.2 Proof Assistant Early History . 129 4.3 Proof Assistant Foundations . 130 4.4 Trusted Computing Bases of Proofs and Programs . 137 5 Between the Engineer and the Kernel: Languages and Automation 141 5.1 Styles of Automation . 142 5.2 Automation in Practice . 156 The version of record is available at: http://dx.doi.org/10.1561/2500000045 6 Proof Organization and Scalability 162 6.1 Property Specification and Encodings .
    [Show full text]
  • Efficient Verification Techniques For
    Overcoming performance barries: efficient verification techniques for logical frameworks Brigitte Pientka School of Computer Science McGill University Montreal, Canada [email protected] Abstract. In recent years, logical frameworks which support formalizing language specifications to- gether with their meta-theory have been pervasively used in small and large-scale applications, from certifying code [2] to advocating a general infrastructure for formalizing the meta-theory and semantics of programming languages [5]. In particular, the logical framework LF [9], based on the dependently typed lambda-calculus, and light-weight variants of it like LFi [17] have played a major role in these applications. While the acceptance of logical framework technology has grown and they have matured, one of the most criticized points is concerned with the run-time performance. In this tutorial we give a brief introduction to logical frameworks, describe its state-of-the art and present recent advances in addressing some of the existing performance issues. 1 Introduction Logical frameworks [9] provide an experimental platform to specify, and implement formal systems together with the proofs about them. One of its applications lies in proof-carrying code, where it is successfully used to specify and verify formal guarantees about the run-time behavior of programs. More generally, logical frameworks provide an elegant language for encoding and mechanizing the meta-theory and semantics of programming languages. This idea has recently found strong advocates among programming languages researchers who proposed the POPLmark challenge, a set of benchmarks to evaluate and compare tool support to experiment with programming language design, and mechanize the reasoning about programming languages [5].
    [Show full text]
  • Type Theory and Applications
    Type Theory and Applications Harley Eades [email protected] 1 Introduction There are two major problems growing in two areas. The first is in Computer Science, in particular software engineering. Software is becoming more and more complex, and hence more susceptible to software defects. Software bugs have two critical repercussions: they cost companies lots of money and time to fix, and they have the potential to cause harm. The National Institute of Standards and Technology estimated that software errors cost the United State's economy approximately sixty billion dollars annually, while the Federal Bureau of Investigations estimated in a 2005 report that software bugs cost U.S. companies approximately sixty-seven billion a year [90, 108]. Software bugs have the potential to cause harm. In 2010 there were a approximately a hundred reports made to the National Highway Traffic Safety Administration of potential problems with the braking system of the 2010 Toyota Prius [17]. The problem was that the anti-lock braking system would experience a \short delay" when the brakes where pressed by the driver of the vehicle [106]. This actually caused some crashes. Toyota found that this short delay was the result of a software bug, and was able to repair the the vehicles using a software update [91]. Another incident where substantial harm was caused was in 2002 where two planes collided over Uberlingen¨ in Germany. A cargo plane operated by DHL collided with a passenger flight holding fifty-one passengers. Air-traffic control did not notice the intersecting traffic until less than a minute before the collision occurred.
    [Show full text]
  • Twelf User's Guide
    Twelf User’s Guide Version 1.4 Frank Pfenning and Carsten Schuermann Copyright c 1998, 2000, 2002 Frank Pfenning and Carsten Schuermann Chapter 1: Introduction 1 1 Introduction Twelf is the current version of a succession of implementations of the logical framework LF. Previous systems include Elf (which provided type reconstruction and the operational semantics reimplemented in Twelf) and MLF (which implemented module-level constructs loosely based on the signatures and functors of ML still missing from Twelf). Twelf should be understood as research software. This means comments, suggestions, and bug reports are extremely welcome, but there are no guarantees regarding response times. The same remark applies to these notes which constitute the only documentation on the present Twelf implementation. For current information including download instructions, publications, and mailing list, see the Twelf home page at http://www.cs.cmu.edu/~twelf/. This User’s Guide is pub- lished as Frank Pfenning and Carsten Schuermann Twelf User’s Guide Technical Report CMU-CS-98-173, Department of Computer Science, Carnegie Mellon University, November 1998. Below we state the typographic conventions in this manual. code for Twelf or ML code ‘samp’ for characters and small code fragments metavar for placeholders in code keyboard for input in verbatim examples hkeyi for keystrokes math for mathematical expressions emph for emphasized phrases File names for examples given in this guide are relative to the main directory of the Twelf installation. For example ‘examples/guide/nd.elf’ may be found in ‘/usr/local/twelf/examples/guide/nd.elf’ if Twelf was installed into the ‘/usr/local/’ directory.
    [Show full text]
  • A Meta-Programming Approach to Realizing Dependently Typed Logic Programming
    A Meta-Programming Approach to Realizing Dependently Typed Logic Programming Zach Snow David Baelde Gopalan Nadathur Computer Science and Eng. Computer Science and Eng. Computer Science and Eng. University of Minnesota University of Minnesota University of Minnesota [email protected] [email protected] [email protected] ABSTRACT in an elegant way through type dependencies, and they for- Dependently typed lambda calculi such as the Logical Frame- malize the authentication of proofs through type-checking. work (LF) can encode relationships between terms in types Such calculi can also be assigned a logic programming in- and can naturally capture correspondences between formu- terpretation by exploiting the well-known isomorphism be- las and their proofs. Such calculi can also be given a logic tween formulas and types [12]. The Twelf system [17] that programming interpretation: the Twelf system is based on we consider in this paper exploits this possibility relative such an interpretation of LF. We consider here whether a to LF. As such, it has been used successfully in specifying conventional logic programming language can provide the and prototyping varied formal systems and mechanisms have benefits of a Twelf-like system for encoding type and proof- also been built into it to reason about these specifications. and-formula dependencies. In particular, we present a sim- Predicate logics provide the basis for logic programming ple mapping from LF specifications to a set of formulas in languages that are also capable of encoding rule-based spec- the higher-order hereditary Harrop (hohh) language, that ifications. Within this framework, the logic of higher-order relates derivations and proof-search between the two frame- hereditary Harrop (hohh) formulas [13] that underlies the works.
    [Show full text]
  • Twelf User's Guide
    Twelf User’s Guide Version 1.3 Frank Pfenning and Carsten Schuermann Copyright c 1998 Frank Pfenning and Carsten Schuermann Chapter 1: Introduction 1 1 Introduction Twelf is the current version of a succession of implementations of the logical framework LF. Previous systems include Elf (which provided type reconstruction and the operational semantics reimplemented in Twelf) and MLF (which implemented module-level constructs loosely based on the signatures and functors of ML still missing from Twelf). Twelf should be understood as research software. This means comments, suggestions, and bug reports are extremely welcome, but there are no guarantees regarding response times. The same remark applies to these notes which constitute the only documentation on the present Twelf implementation. For current information including download instructions, publications, and mailing list, see the Twelf home page at http://www.cs.cmu.edu/~twelf/. This User’s Guide is published as Frank Pfenning and Carsten Schuermann Twelf User’s Guide Technical Report CMU-CS-98-173, Department of Computer Science, Carnegie Mellon University, November 1998. Below we state the typographic conventions in this manual. code for Twelf or ML code ‘samp’ for characters and small code fragments metavar for placeholders in code keyboard for input in verbatim examples KEY for keystrokes math for mathematical expressions emph for emphasized phrases File names for examples given in this guide are relative to the main directory of the Twelf in- stallation. For example ‘examples/guide/nd.elf’ may be found in ‘/usr/local/twelf/examples/guide/nd.elf’ if Twelf was installed into the ‘/usr/local/’ direc- tory.
    [Show full text]
  • A Simple Module System for Twelf
    15-819K: Logic Programming Final Project Report A Simple Module System for Twelf Dan Licata, Rob Simmons, Daniel Lee December 15, 2006 Abstract Twelf is an implementation of the LF logical framework and the Elf logic programming language that provides several automated analy- ses of Elf programs. It is increasingly used in the development and study of large deductive systems, such as programming languages and logics. Such large projects would benefit from language exten- sions that facilitate extensible code reuse and modular development. Drawing on prior work with module systems for LF and Elf, have de- signed and prototyped a simple module system for Twelf. The mod- ule system supports namespace management and simple forms of pa- rameterization and reuse. It is defined by elaboration into the current Twelf implementation. 1 Introduction LF [Harper et al., 1993] is a logical framework used to represent deductive systems such as programming languages and logics. Elf [Pfenning, 1989] is a logic programming language that endows LF with an operational se- mantics based on proof search. Twelf [Pfenning and Schurmann,¨ 1999] is an implementation of LF and Elf that provides various analyses, such as mode, coverage, and termination, of Elf programs. Metatheorems1 about deductive systems can be represented in Twelf as logic programs that sat- isfy certain totality analyses. Consequently, Twelf’s analyses simultane- 1In this report, we will use the words “directive”, “analysis”, and “assertion” for Twelf directives such as mode, worlds, and totality, whereas we will use the word “metatheorem” more broadly to refer to any proposition about a deductive system. FINAL PROJECT REPORT DECEMBER 15, 2006 ASimpleModuleSystemforTwelf 2 ously ensure that logic programs will run correctly and verify metatheo- retic properties of deductive systems.
    [Show full text]
  • Celf – a Logical Framework for Deductive and Concurrent Systems
    Short Talk: Celf – A Logical Framework for Deductive and Concurrent Systems Anders Schack-Nielsen and Carsten Sch¨urmann IT University of Copenhagen Denmark Abstract. CLF (Concurrent LF) [?] is a logical framework for specify- ing and implementing deductive and concurrent systems from areas, such as programming language theory, security protocol analysis, process al- gebras, and logics. Celf is an implementation of the CLF type theory that extends the LF type theory by linear types to support representation of state and a monad to support representation of concurrency. The Celf system is a tool for experimenting with deductive and concurrent systems prevalent in programming language theory, security protocol analysis, process algebras, and logics. It supports the specification of object language syn- tax and semantics through a combination of deductive methods and resource- aware concurrent multiset transition systems. Furthermore it supports the ex- perimentation with those specifications through concurrent logic programming based on multiset rewriting with constraints. Many case studies have been conducted in Celf including all of the motivating examples that were described in the original CLF technical report [?]. In par- ticular, Celf has been successfully employed for experimenting with concurrent ML, its type system, and a destination passing style operational semantics that includes besides the pure core a clean encoding of Haskell-style suspensions with memoizations, futures, mutable references, and concurrency omitting negative acknowledgments. Other examples include various encodings of the π-calculus, security protocols, petri-nets, etc. CLF is a conservative extension over LF, which implies that Celf’s function- ality is compatible with that of Twelf [?]. With a few syntactic modifications Twelf signatures can be read, type checked, and queries can be executed.
    [Show full text]
  • A New Higher-Order Unification Algorithm for Kanren
    A New Higher-order Unification Algorithm for _Kanren WEIXI MA, Indiana University DANIEL P. FRIEDMAN, Indiana University _Kanren, adapted from _Prolog, extends miniKanren with higher-order logic programming. The existing higher-order unification algorithms, however, are neither sound nor complete w.r.t. an “intuitive” under- standing of U-equivalence. This paper shows these gaps and proposes a new method tohandle U-equivalence in higher-order unification. ACM Reference Format: Weixi Ma and Daniel P. Friedman. 2021. A New Higher-order Unification Algorithm for _Kanren. 1, 1 (Au- gust 2021), 10 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn 1 BACKGROUND Is there a world where true is equal to false? Indeed, there is, if higher-order unification [13] and miniKanren [9] meet each other. Even if all components are already well-established, it may still end up with unnatural or even absurd results, if we combine them naively. This paper unveils the difficulties in handling binders with standard higher-order unification. To solve these problems, we propose a new unification formulation. Higher-order unification [13] solves equations among _-terms modulo UV[-equivalence [3]. Miller [19] finds a decidable fragment of higher-order unification problems by restricting theap- plication forms of the input terms. For an application form 퐹 0, if 퐹 is a unification variable, then 0 must be a list of zero or more distinct bound variables. Such restricted application forms are called patterns and we hereafter refer to the problem identified by Miller as pattern unification. Pattern unification then becomes the coreof _Prolog [20]. _Prolog implements a more expres- sive logic [21] than Prolog does.
    [Show full text]
  • Mechanizing Metatheory in a Logical Framework
    Under consideration for publication in J. Functional Programming 1 Mechanizing Metatheory in a Logical Framework Robert Harper and Daniel R. Licata Carnegie Mellon University (e-mail: frwh,[email protected]) Abstract The LF logical framework codifies a methodology for representing deductive systems, such as programming languages and logics, within a dependently typed λ-calculus. In this methodology, the syntactic and deductive apparatus of a system is encoded as the canonical forms of associated LF types; an encoding is correct (adequate) if and only if it defines a compositional bijection between the apparatus of the deductive system and the associated canonical forms. Given an adequate encoding, one may establish metatheoretic properties of a deductive system by reasoning about the associated LF representation. The Twelf implementation of the LF logical framework is a convenient and powerful tool for putting this methodology into practice. Twelf supports both the representation of a deductive system and the mechanical verification of proofs of metatheorems about it. The purpose of this paper is to provide an up-to-date overview of the LF λ-calculus, the LF methodology for adequate representation, and the Twelf methodology for mechanizing metatheory. We begin by defining a variant of the original LF language, called Canonical LF, in which only canonical forms (long βη-normal forms) are permitted. This variant is parameterized by a subordination relation, which enables modular reasoning about LF representations. We then give an adequate representation of a simply typed λ-calculus in Canonical LF, both to illustrate adequacy and to serve as an object of analysis. Using this representation, we formalize and verify the proofs of some metatheoretic results, including preservation, determinacy, and strengthening.
    [Show full text]