Mary Southern and Gopalan Nadathur. This work was funded by NSF grant CCF

Similar documents
Mixing Finite Success and Finite Failure. Automated Prover

UNIFORM PROOFS AS A FOUNDATION FOR LOGIC PROGRAMMING. Computer and Information Science Department University of Pennsylvania, Philadelphia, PA 19104

query. The quantification over predicate variables that is permitted and the corresponding enrichment to the term structure are however sufficient to

From Operational Semantics to Abstract Machines

A Formalised Proof of Craig s Interpolation Theorem in Nominal Isabelle

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

Subtyping and Intersection Types Revisited

The Curry-Howard Isomorphism

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

On a computational interpretation of sequent calculus for modal logic S4

1 An Overview of Linear Logic Programming

AN OVERVIEW OF LINEAR LOGIC PROGRAMMING

Notes on Logical Frameworks

First-Order Logic. Chapter Overview Syntax

Logic Programming in a Fragment of Intuitionistic Linear Logic

Mechanizing Metatheory in a Logical Framework

A Multiple-Conclusion Specification Logic

Proof Search Foundations for Logic Programming

Outline. Overview. Syntax Semantics. Introduction Hilbert Calculus Natural Deduction. 1 Introduction. 2 Language: Syntax and Semantics

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

Kleene realizability and negative translations

Advanced Topics in LP and FP

Uniform Schemata for Proof Rules

Higher-Order Horn Clauses

Classical First-Order Logic

Reasoning about Computational Systems using Abella

Structural Foundations for Abstract Mathematics

INDUCTIVE DEFINITION

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

Artificial Intelligence Chapter 7: Logical Agents

Mode checking in the Concurrent Logical Framework

The Bedwyr system for model checking over syntactic expressions

Combining generic judgments with recursive definitions

Third-Order Matching via Explicit Substitutions

Termination and Reduction Checking for Higher-Order Logic Programs

Meta-reasoning in the concurrent logical framework CLF

Consequence Relations and Natural Deduction

The Suspension Notation as a Calculus of Explicit Substitutions

ON SOME APPLIED FIRST-ORDER THEORIES WHICH CAN BE REPRESENTED BY DEFINITIONS

Propositional and Predicate Logic - V

Propositional Logic: Review

Logic (3A) Young W. Lim 11/2/13

Chapter 2: Basic Notions of Predicate Logic

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Candidates for Substitution

Logic (3A) Young W. Lim 10/31/13

Predicate Logic. Xinyu Feng 11/20/2013. University of Science and Technology of China (USTC)

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

Extraction from classical proofs using game models

First-Order Theorem Proving and Vampire

Classical First-Order Logic

Logic (3A) Young W. Lim 10/29/13

Propositional Logic: Logical Agents (Part I)

Propositional Logic: Models and Proofs

Meta-Reasoning in a Concurrent Logical Framework

Hierarchic reasoning in local theory extensions

Introduction to Metalogic

Nunchaku: Flexible Model Finding for Higher-Order Logic

Unicity of type inhabitants; a Work in Progress

COMP2411 Lecture 10: Propositional Logic Programming. Note: This material is not covered in the book. Resolution Applied to Horn Clauses

A Proof Theory for Generic Judgments

Lecture Notes on Focusing

higher-order logic (e:g:, Church's simple theory of types [5]) P must be a simple type. Although CC types include the types of the simply-typed -calcu

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Lazy Strong Normalization

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

Monotonic Learning, Interactive Realizers and Monads

Lecture Notes on Cut Elimination

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

Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics

Brief Introduction to Prolog

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/26)

6. Logical Inference

Software Engineering using Formal Methods

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

hal , version 1-21 Oct 2009

CS 380: ARTIFICIAL INTELLIGENCE

Spreading of Activation

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

Introduction to Artificial Intelligence. Logical Agents

Object Calculi in Linear Logic

Adjunction Based Categorical Logic Programming

Consequence Relations and Natural Deduction

Resolution for Predicate Logic

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC)

A Simplified Suspension Calculus and its Relationship to Other Explicit Substitution Calculi

Kecerdasan Buatan M. Ali Fauzi

1 Differentiable manifolds and smooth maps

Stratification in Logics of Definitions

Introduction to Intuitionistic Logic

Relating Nominal and Higher-Order Pattern Unification

Logic in Logic Programming: Sequent Calculus, Higher-Orders, and Linear Logic

Type Systems Winter Semester 2006

Church s undecidability result

A proposal for broad spectrum proof certificates

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Copatterns Programming Infinite Objects by Observations

chapter 12 MORE MATRIX ALGEBRA 12.1 Systems of Linear Equations GOALS

Fundamentals of Software Engineering

Propositional and Predicate Logic

Transcription:

A Translation-Based Animation of Dependently-Typed Specifications From LF to hohh(and back again) Mary Southern and Gopalan Nadathur Department of Computer Science and Engineering University of Minnesota This work was funded by NSF grant CCF-0917140. 1 / 24

Some Motivation We are interested in formalizing systems that are described in a rule-based and syntax directed fashion Two approaches with complementary benefits exist for formalizing such systems: An approach based on using dependently-typed λ-calculi Primary Virtue: Dependent types are a convenient and widely used means for encoding specifications An approach that uses logical predicates over λ-calculus terms Primary Virtue: Such a logic has an efficient implementation and specifications in it can also be expressively reasoned about Our Goal: To harness the benefits of both approaches Specifically, we want to let the first approach be used for developing specifications use a translation to the second form to realize animation 2 / 24

Map of Talk Motivation Specifications A Translation An Inverse Looking Forward 3 / 24

Edinburgh Logical Framework (LF) Syntax of Expressions Kind Type Object K := Type Πx:A.K A := a M... M Πx:A.A M := c x X λx:a.m M M We are interested in deriving judgments of the form: Γ Σ M : A This is done with respect to: Signature Σ := Σ, c : A Σ, a : K Context Γ := Γ, x : A Meta-Variable Context 4 / 24

Example Specification nat N := 0 S N list L := [] (N :: L) L 1 @ L 2 = L 3 L 1 @ L 2 = L 3 (X :: L 1 ) @ L 2 = (X :: L 3 ) nat : type. list : type. z : nat. nil : list. s : nat nat. cons : nat list list. app : list list list type. app N : ΠL:list.app nil L L. app C : ΠX :nat.πl 1 :list.πl 2 :list.πl 3 :list. ΠA:app L 1 L 2 L 3.app (cons X L 1 ) L 2 (cons X L 3 ) 5 / 24

A Predicate Logic We work with a fragment of the logic of Higher-Order Hereditary Harrop Formulas (hohh) This logic underlies the logic programming language λ Prolog Atomic formulas, A, are constructed using predicate symbols that take simply typed λ-terms as arguments. Formulas D := A G D x.d G := A D G x.g A collection of D-formulas, or Program P, encodes a specification and a G formula corresponds to a query 6 / 24

Logic Programming - Predicate Logic We want to derive sequents of the form: Ξ; P G where Ξ is the signature containing the term constants P is a program (set of D-formulas) G is the goal formula we wish to solve Two main differences from Logic Programming in Prolog: Program can be extended dynamically Ξ; Γ, D G Ξ; Γ D G Signature can be extended dynamically Ξ, c; Γ G[c/x] Ξ; Γ x.g 7 / 24

Map of Talk Motivation Specifications A Translation An Inverse Looking Forward 8 / 24

Overview of Translation The translation is based on a two step process 1. First we map both LF types and objects into simply typed λ-terms. we use hohh terms of type lf-type for LF types we use hohh terms of type lf-obj for LF objects Notice that the LF typing information is lost in this translation and only the functional structure of expressions is retained 2. We then encode LF typing relations in predicates over the hohh terms denoting LF objects and LF types In particular, the predicate hastype : lf-obj lf-type o is used for this. 9 / 24

A Translation 1/2 The encoding of LF terms, is given by the rules below. c := c x := x X := X M N := M N λx:a.m := λx. M The mapping, φ( ) flattens the types of LF terms: φ(type) := lf-type φ(πx:a.b) := φ(a) φ(b) φ(a) := lf-obj when A is a base type Example Encoding nat : lf-type. z : lf-obj. s : lf-obj lf-obj. list : lf-type. nil : lf-obj. cons : lf-obj lf-obj lf-obj. app : lf-obj lf-obj lf-obj lf-type. app N : lf-obj lf-obj. app C : lf-obj lf-obj lf-obj lf-obj lf-obj lf-obj. 10 / 24

A Translation 2/2 Then, LF types are translated as follows: {A } := λm. hastype M A if A is a base type {Πx:A.B } := λm. x. ( {A } x) ( {B } (M x)) For example, consider the translation of ΠL:list.app nil L L: {ΠL:list.app nil L L } λm. L. ( {list } L) ( {app nil L L } (M L)) λm. L. (hastype L list) (hastype (M L) (app nil L L)) Thus, the LF signature item app N : ΠL:list.app nil L L yields the λ-prolog formula L. (hastype L list hastype (app N L) (app nil L L)) 11 / 24

Improving the Translation Consider the constant app C. app C : ΠX :nat.πl 1 :list.πl 2 :list.πl 3 :list.πa:app L 1 L 2 L 3. app (cons X L 1 ) L 2 (cons X L 3 ) Whenever we are matching an instance of this type, we must ensure that the terms being substituted for the Π-bound variables are of the correct type. Certain terms will appear in such a way that we know this to be the case. Consider a well-formed type: app (cons x l1) l2 (cons x l3). Clearly then, whatever the term l1 (resp. l2, l3), it must be of type list Similarly x must be of type nat But is there a term of type app l1 l2 l3? 12 / 24

Characterizing Redundancies This type checking becomes the hastype formula of the Π-bound variable. By categorizing which of these checks is unnecessary, we are able to reduce the number of goals which must be satisfied during proof search. The essential idea is that we do not need to perform such a check when there is an occurrence whose structure is not lost or altered by other substitutions. We define a criterion, called Strictness, which captures this idea. Strictness 1. There is an occurrence, in the head of the type, which does not disappear after performing substitutions for the other Π-quantified variables. 2. This occurrence may only be applied to distinct λ-bound variables. 13 / 24

Strictness There are two main judgments associated with strictness: Γ; x t A and ; δ; x o M Γ collects Π-bound variables contains the Π-bound variables δ collects λ-bound variables Translation now proceeds in two modes: In the positive context we remove the hastype clause for strictly occurring variables. In the negative context we proceed as before. 14 / 24

Example Specification - Translated nat : lf-type. z : lf-obj. s : lf-obj lf-obj. list : lf-type. nil : lf-obj. cons : lf-obj lf-obj lf-obj. app : lf-obj lf-obj lf-obj lf-type. app N : lf-obj lf-obj. app C : lf-obj lf-obj lf-obj lf-obj lf-obj lf-obj. L.hastype (app N L) (app nil L L). X. L 1. L 2. L3. A.hastype A (app L 1 L 2 L 3 ) hastype (app C X L 1 L 2 L 3 A) (app (cons X L 1 ) L 2 (cons X L 3 )). 15 / 24

Map of Talk Motivation Specifications A Translation An Inverse Looking Forward 16 / 24

Dealing with Queries After writing an LF specification, one may want to present and solve queries of the form M : A. We allow logic variables to appear in the type A. LF Query Proof : Πx:nat.app nil (cons z (cons x nil)) (L x) Translated Query x.hastype Proof (app nil (cons z (cons x nil)) (L x)) Solution L = λy.cons z (cons y nil) Proof = λy.app N (cons z (cons y nil)) We would like to now return our solution to LF. There are two concerns we should keep in mind: Under our chosen signature, there may be well-formed STLC terms which have no corresponding LF term. Eg. arrow empty (app unit unit) Alternatively, there may be terms with multiple corresponding LF terms. Eg. (λx.x) 17 / 24

An Inverse Encoding We are not interested in inverting arbitrary terms All terms will correspond to a well-formed LF term. LF typing information ensures a unique inverse. We define the inverse as a relationship between: the λ-term t the LF type A the LF typing information Θ There are two judgments the LF term M inv (t; A; Θ) = M and inv (t; A; Θ) = M The first expects A as input while the second synthesizes A. Returning to our example: Solution LF Solution L = λy.cons z (cons y nil) Proof = λy.app N (cons z (cons y nil)) L = λy:nat.cons z (cons y nil) Proof = λy:nat.app N (cons z (cons y nil)) 18 / 24

Map of Talk Motivation Specifications A Translation An Inverse Looking Forward 19 / 24

Ongoing Work Show correctness of this translation. Developing an implementation of this system. Use this translation to extend Abella for reasoning about LF specifications. 20 / 24

End 21 / 24

Correctness of the Translation We need to show that the substitutions found in LF and under the translation are equivalent. Our approach for this proof is to use simulation. Theorem Let Σ be an LF signature and let A be an LF type that possibly contains meta-variables. 1. If the query M : A is solved with the ground answer substitution σ, then there is an invertible answer substitution θ for the goal {A } M wrt {Σ } such that the inverse θ of θ generalizes σ (i.e. there exists a σ such that σ θ = σ). 2. If θ is an invertible answer substitution for {A } M, then its inverse is an answer substitution for M : A. 22 / 24

Rules for the Strictness Criterion dom(γ); ; x o A i for some A i in A APPt Γ; x t c Γ, y : A; x t B PIt A Γ; x t Πy:A.B Γ 1 ; x t B Γ 1, y : B, Γ 2 ; y t A CTXt Γ 1, y : B, Γ 2 ; x t A y i δ for each y i in y each variable in y is distinct INITo ; δ; x o x y y / and ; δ; x o M i for some M i in M APPo ; δ; x o y M ; δ, y; x o M ABSo ; δ; x o λy:a.m 23 / 24

Rules for the Inverse Encoding X : A inv-var inv (X ; A; Θ) = X inv (M; B; Θ, x : A) = M inv (λx.m; Πx:A.B; Θ) = λx:a.m inv-abs inv (M 1 ; Πx:B.A; Θ) = M 1 inv (M 2 ; B; Θ) = M 2 inv-app inv (M 1 M 2 ; A[M 2 /x]; Θ) = M 1 M 2 u : A Θ inv (u; A; Θ) = u inv-const inv (M; A; Θ) = M inv (M; A; Θ) = M inv-syn 24 / 24