Embed
Email

open

Document Sample

Shared by: xiaohuicaicai
Categories
Tags
Stats
views:
2
posted:
10/26/2011
language:
English
pages:
10
Reasoning with Hypothetical Judgments

and Open Terms in Hybrid

Amy P. Felty Alberto Momigliano

School of Information Technology and Engineering School of Informatics, University of Edinburgh

University of Ottawa, Ontario, Canada Scotland, United Kingdom

afelty@site.uottawa.ca amomigl1@inf.ed.ac.uk









Abstract formal systems. This technique is often used within a typed logi-

Hybrid is a system developed to specify and reason about logics, cal framework that supports reasoning about such encodings. One

programming languages, and other formal systems expressed in of the main uses of these logical frameworks is to represent and

higher-order abstract syntax (HOAS). An important goal of Hybrid prove properties about the semantic foundations of declarative pro-

is to exploit the advantages of HOAS within the well-understood gramming languages. Using HOAS, binding constructs in the rep-

setting of higher-order logic as implemented by systems such as resented language (the object logic or OL) are encoded using the

Isabelle and Coq. In this paper, we add new capabilities for reason- binding constructs provided by an underlying λ-calculus or func-

ing by induction on encodings of object-level inference rules. El- tion space of the logical framework (the meta-language). For ex-

egant and succinct specifications of such inference rules can often ample, consider the untyped λ-calculus as an OL. Its terms can

be given using hypothetical and parametric judgments, which are be encoded, for instance, by introducing a type tm and two con-

represented by embedded implication and universal quantification. structors: abs of type (tm → tm) → tm, and app of type

Induction over such judgments is well-known to be problematic. In tm → tm → tm. Using such a representation allows us to delegate

previous work, we showed how to express this kind of judgment us- to the meta-language α-conversion and capture-avoiding substitu-

ing a two-level approach, but reasoning by induction on such judg- tion. Further, object logic substitution can be rendered as meta-level

ments was restricted to closed terms. The new capabilities we add β-conversion.

include techniques for adding arbitrary “new” variables to contexts In addition, in such logical frameworks, embedded implication

and inductively reasoning about open terms. Very little overhead is and universal quantification are often used to represent hypothetical

required, namely a small library of definitions and lemmas, yet the and parametric judgments—following [Miller and Tiu 2005], we

reasoning power of the system and the class of properties that can will also call them generic—which allow elegant and succinct

be proved is significantly increased. We illustrate the approach us- specifications of OL inference rules. For instance, if our example

ing PCF, a simple programming language that serves as the core of OL includes rules for adding types to untyped terms, the following

a variety of functional languages. We encode the typing judgment, rule for the abstraction case:

and prove by induction on this judgment that well-typed PCF terms (x : τ1 )

have unique types. .

.

.

Categories and Subject Descriptors D.3.1 [Programming Lan- M : τ2

guages]: Formal definitions and theory—semantics; F.4.1 [Mathe-

matical Logic]: Lambda Calculus and Related Systems—Mechanical λx.M : τ1 ⇒ τ2

theorem proving, Proof theory; I.2.3 [Artificial Intelligence]: De-

can be expressed using the typeof predicate in the following for-

duction and Theorem Proving—Deduction, Inference engines,

mula:

logic programming, meta theory

∀M : tm → tm.∀τ1 , τ2 : tp.

General Terms Languages, Verification (∀x : tm.(typeof x τ1 ) −→ (typeof (M x) τ2 ))

Keywords higher-order abstract syntax, logical frameworks, name- −→ (typeof (abs M ) (τ1 ⇒ τ2 )).

binding, induction, interactive theorem proving Hybrid [Momigliano et al. 2008] is a system developed to sup-

port HOAS encoding and reasoning. It is implemented in both Is-

1. Introduction abelle/HOL [Nipkow et al. 2002] and Coq [Bertot and Cast´ ran e

2004]. Implementing Hybrid as a tool within such systems allows

Higher-order abstract syntax (HOAS) is a representation technique users wishing to reason with HOAS encodings to draw on the pow-

that allows direct and concise specifications of a wide variety of erful deduction capabilities enjoyed by these systems: rich princi-

ples of (co)induction and tactic-style automation, not to mention

general rewriting, decision procedures, model checking, interface

to automated theorem provers, code generation etc. Hybrid pro-

Permission to make digital or hard copies of all or part of this work for personal or vides additional tool support within this setting to automate tasks

classroom use is granted without fee provided that copies are not made or distributed

for profit or commercial advantage and that copies bear this notice and the full citation

specific to reasoning with HOAS.

on the first page. To copy otherwise, to republish, to post on servers or to redistribute One of the main challenges in developing Hybrid came from the

to lists, requires prior specific permission and/or a fee. presence of negative occurrences in the definitions of the types and

PPDP’09, September 7–9, 2009, Coimbra, Portugal. predicates introduced in HOAS encodings of OL terms and judg-

Copyright c 2009 ACM 978-1-60558-568-0/09/09. . . $5.00 ments (e.g., the underlined occurrences of tm in the type of abs

and of typeof in the formula expressing the typing rule above). of definitions and lemmas that allow reasoning about “arbitrary”

In systems such as Coq and Isabelle/HOL, such encodings cannot variables in such a way that keeps the formal proof close to the

be defined directly using inductive definitions of the metalanguage. informal one, and adds only a surprisingly minimal amount of ad-

Set-theoretically, these definitions do not yield monotone operators ditional infrastructure. In fact, Hybrid has a built in VAR construc-

and cannot be constructed as a least fixed point [Gunter 1992, Paul- tor to allow one to encode free variables of OLs, and a definition

son 1994]. Type-theoretically, they infringe on the strict positivity (newvar) that provides the capability of creating a variable which

requirement [Paulin-Mohring 1993] used to obtain strong normal- is new, in particular w.r.t. a context. Our approach to induction over

ization, and thus are not inductive in any ordinary sense. To over- predicates with hypothetical judgments makes essential and novel

come the problem of negative occurrences in types such as tm, we use of this built-in constructor and definition. In Hybrid’s underly-

introduced a de Bruijn representation of λ-terms that provides a ing language, free variables are essentially represented by natural

definitional layer [Ambler et al. 2002]. Higher-order syntax encod- numbers (VAR takes a natural number argument). One of the main

ings are defined on top of this layer so that they expand to de Bruijn operations involving such variables is to introduce new ones into a

terms. To overcome the problem of negative occurrences in predi- proof, such as x in the above example. To do so, we simply add 1

cates such as typeof , Hybrid adopts the two-level approach first in- to the maximum of the free variables used so far. Reasoning about

N

troduced in the F Oλ∆I logic [McDowell and Miller 2002], later such “fresh” variables is factored into a small number of lemmas.

adapted to Coq [Felty 2002], now applied within a variety of log- The lemmas are relatively simple; no reasoning about substitution

ics [Miller and Tiu 2005, Tiu 2007, Gacek et al. 2008], and imple- or α-conversion is needed as in first-order approaches. In a sense,

mented in the Abella system [Gacek 2008]. In a two-level system, newvar is the “poor man” version of the freshness predicate ( # )

the specification and (inductive) meta-reasoning are done within a of nominal logic [Pitts 2003].

single system but at different levels. An intermediate level is intro- We introduce the approach by formally proving that well-typed

duced by inductively defining a specification logic (SL), and OL terms in PCF [Scott 1993] have unique types (type unicity). The in-

judgments (including hypothetical and parametric judgments) are formal proof is a straightforward induction over the typing deriva-

encoded in the SL. tion that assigns a type to a PCF term. We use this simple exam-

Previous work on Hybrid involved a variety of case studies, ple to illustrate the methodology, though the techniques are gen-

some of them quite large. In [Felty and Momigliano 2008], for eral and should scale to larger case studies. The inductive case for

example, formal proofs of type soundness (subject reduction) for the abstraction operator—and this applies to other binding term

two example OLs and SLs are given, one for a small language to constructors—which uses a rule similar to the one discussed ear-

illustrate the methodology, and another for a more complex one, lier, is the challenging case. We express the induction hypothesis

driven by a sub-structural SL, to illustrate that the approach scales as a “context invariant,” which is a property that must be preserved

well on both sides. Induction over OL judgments is required in such when adding a “fresh” variable to the context, as is required in this

proofs, but in this case induction was on the evaluation judgment, case. The general infrastructure we build is designed so that it is

whose encoding does not use hypothetical or parametric judgments. straightforward to express context invariants and prove that they

In other words, although generic judgments (e.g., typing) were are preserved when adding a “fresh” variable.

crucial for these proofs, namely to provide inversion principles, The paper starts with Section 2 recalling some basic notions

induction over these judgments was not. of the implementation of Hybrid. Section 3 introduces the SL, a

Induction over hypothetical and parametric judgments intro- fragment of second-order minimal logic. Section 4 introduces the

duces new challenges, which is the central issue that we address example OL, in particular, presenting the encodings of the syntax

in this paper. Statements have to be generalized to non-empty con- and typing rules of PCF, and briefly discussing the adequacy of

texts, and these contexts have to be of a certain form, which must these encodings. In Section 5, we present the formal proof of type

enforce the property in question. To try to motivate these chal- unicity for PCF. We discuss related work in Section 6 and conclude

lenges, consider a proof by induction over the typeof predicate.1 in Section 7.

If the case for abstraction is defined as above, the induction hy- Hybrid was first developed in Isabelle/HOL [Ambler et al.

pothesis takes on a similar form, roughly: 2002] and for the sake of this paper, we use a pretty-printed version

of Isabelle/HOL concrete syntax. Note, however, that the proof of

∀x : tm.(P (typeof x τ1 )) −→ (P (typeof (M x) τ2 )). the main result and all the code mentioned in Section 5 were (so

Using this induction hypothesis in a proof requires finding an ap- far) conducted only in Coq, due to some backward compatibility

propriate instantiation term for x. Note that the universal quantifier issues with the current release of Isabelle/HOL. In particular, a type

can be instantiated with any term, which provides the required flex- declaration has the form s :: [ t1 , . . . tn ] ⇒ t. We stick to the usual

ibility in doing proofs using this form of HOAS. On the other hand, logical symbols for connectives and quantifiers (¬, ∧, ∨, −→, ∀,

using the induction hypothesis for the abstraction case in an infor- ∃). Free variables (upper-case) are implicitly universally quantified

mal proof means reasoning about an arbitrary x such that x : τ1 , (from the outside) as in logic programming. The sign == (Isabelle

V

and a term M : τ2 that possibly contains free occurrences of x. meta-equality) is used for equality by definition, and for Isabelle

Thus x is a variable and M is an open term. In a variety of ap- universal meta-quantification. A rule (a sequent) of the schematic

proaches to HOAS that allow definitions in the form of our exam- form H1 ...Hn is represented as [[ H1 ; . . . ; Hn ]] =⇒ C. The key-

C

ple typeof clause above, M is akin to a second-order logic vari- word inductive introduces an inductive relation in Isabelle/HOL,

able, possibly depending on a parameter x. There is no notion of datatype introduces a new datatype, and primrec a primitive recur-

free variables or open terms, so one is required to find some closed sive function. We use the same notation for Coq, though in Coq all

term as the instantiation term for x. (We remark that the induction the arrows map to the same operator, and there is only one univer-

hypothesis takes on a slightly different form in a two-level system, sal quantifier. In addition both inductive and datatype map to Coq’s

but the issues discussed here remain the same.) The contribution of Inductive keyword, and primrec maps to Fixpoint.

the work presented in this paper is a methodology that keeps the Every theorem, lemma, and corollary is machine-checked.

advantages of this form of HOAS, but adds a very small number Source files for the code can be found at:



1 We ask the reader to indulge us, while talking about an induction principle,

which is not inductive in the standard sense [Sch¨ rmann 2001].

u hybrid.dsi.unimi.it/ppdp09 [Hybrid Group 2009].

2. An Introduction to Hybrid third.

At the base level, we start with an inductive definition of de Bruijn inductive lbnd :: [ bnd , expr ⇒ expr , expr ] ⇒ bool

expressions: =⇒ lbnd i (λ v. CON a) (CON a)

=⇒ lbnd i (λ v. v) (BND i)

datatype expr = =⇒ lbnd i (λ v. VAR n) (VAR n)

CON con | VAR var | BND bnd | expr $ expr | ABS expr =⇒ lbnd i (λ v. BND j) (BND j)

[[ lbnd i f s;

In our setting, bnd and var are defined to be the natural numbers, lbnd i g t ]] =⇒ lbnd i (λ v. f v $ g v) (s $ t)

and con is used to represent the constants of an OL. Thus at lbnd (i + 1) f s =⇒ lbnd i (λ v. ABS (f v)) (ABS s)

this level, con is a parameter to this type, and given a particular ¬(ordinary e) =⇒ lbnd i e (BND 0)

instantiation, we will later use a type abbreviation, such as uexp =

= con expr . We now define lbind :: [ bnd, expr ⇒ expr ] ⇒ expr as

Central to our approach is the introduction of a binding operator follows, thus completing the definition of lambda:

called lambda that (1) allows a direct expression of λ-abstraction,

lbind i e == THE s. lbnd i e s

and (2) is defined in such a way that expanding its definition results

in the conversion of a term to its de Bruijn representation. Hybrid where THE is Isabelle’s notation for the definite description opera-

does not contain any axioms requiring external justification as in tor ι. Note that this operator is not available in Coq. The use of this

the Theory of Contexts [Honsell et al. 2001]. operator is the main reason for the differences in the two libraries.

As an example, consider the λ-calculus as an OL and the sample The Coq version instead uses a definite description axiom available

term ΛV1 .(ΛV2 .V1 V2 )V1 V3 , where we use upper case letters for in Coq’s classical reasoning library.

variables and a capital Λ for abstraction. This term is represented Ruling out non-uniform functions, which was mentioned be-

in Hybrid as: fore, is important for a variety of reasons. For example, it is nec-

essary for proving that our encoding adequately represents the λ-

lambda λv1 .(((lambda λv2 .(v1 $ v2 )) $ v1 ) $ VAR 3) calculus. To prove adequacy, we identify a subset of the terms of

type expr such that there is a bijection between this subset and

and expanding definitions results in the de Bruijn term:

the λ-terms that we are encoding. There are two aspects we must

ABS (((ABS (BND 1 $ BND 0)) $ BND 0) $ VAR 3). consider in defining a predicate to identify this subset. First, recall

that BND i corresponds to a bound variable in the λ-calculus, and

In the above, all the variable occurrences bound by the first ABS, VAR i to a free variable; we refer to bound and free indices respec-

which corresponds to the bound variable V1 in the object-level tively. We call a bound index i dangling if i or less ABS labels oc-

term, are underlined. Note that the definition of the lambda op- cur between the index i and the root of the expression tree. We must

erator must expand to a term with ABS at the head. Furthermore, rule out terms with dangling indices. Second, in the presence of the

we must include a definition of a function f such that (lambda e) lambda operator, we may have functions of type (expr ⇒ expr )

is (ABS (f e)) where f replaces occurrences of the bound variable that do not behave uniformly on their arguments. We must rule out

in e with de Bruijn index 0, taking care to increment the index as such functions. We define a predicate proper, which rules out dan-

it descends through inner abstractions. We first define a function gling indices from terms of type expr , and a predicate abstr, which

lbind of two arguments such that formally: rules out dangling indices and exotic terms in functions of type

(expr ⇒ expr ).

(lambda e) == ABS (lbind 0 e) To define proper we first define level. Expression e is said to be

at level l ≥ 0, if enclosing e inside l ABS nodes ensures that the

and (lbind i e) replaces occurrences of the bound variable in e with resulting expression has no dangling indices.

de Bruijn index i, where recursive calls on inner abstractions will

increase the index. inductive level :: [ bnd , expr ] ⇒ bool

We express lbind as a total function operating on all functions =⇒ level i (CON a)

of type (expr ⇒ expr ), even exotic ones, i.e., those that do not =⇒ level i (VAR n)

encode honest-to-goodness λ-terms. For example, we could have j v

Section 1, except that the type of the bound variable is included as 2. ((VAR v) : T ) ∈ Γ =⇒ (nvC Γ) > v

an argument and the encoding uses quantifiers of the SL. In addi-

tion, an abstr assumption is required for the functional argument

E. The clause for rec has similar form to the clause for abs, and The first one states that the natural number associated with a new

expresses the usual typing rule for the recursive function construc- context variable (generated by newvar) is greater than the variable

tor. In Section 2, we discussed the adequacy of the encoding of occuring in the typing judgment at the head of the context. Its proof

λ-terms as terms of type expr . As discussed in [Momigliano et al. follows fairly directly from definitions. Part (2) states that a newly

2008, Felty and Momigliano 2008], it is also important to show generated context variable has a value greater than any variables

that both terms and judgments of an OL are adequately encoded, already occurring in the context. Its proof follows from (1), an

and in a two-level system that the SL is adequately encoded. We induction on lists, and arithmetic on natural numbers. The main

refer the reader to the results discussed there, some of which can result we need in the rest of the development is a direct corollary

be directly applied here. The isterm predicate is an important part of (2): that a new variable is distinct from any already occurring in

of adequacy for our OL. In particular, we can show that there is a the context, i.e., ((VAR v) : T ) ∈ Γ =⇒ (nvC Γ) = v.

bijection between closed object-level terms and terms of type uexp Note that the definition of nvA depends on the OL, and this

for which the judgment isterm is provable. In addition, the dependence comes from the instantiation of atm. For a certain class

following lemmas are an important part of showing the adequacy of OLs, we can describe a general way to define nvA: consider all

of the OL typing judgment. arguments e1 , . . . , en of type uexp in atom a; define (nvA a) to

be the maximum of (newvar e1 ), . . . , (newvar en ). This definition

L EMMA 3. works for OLs where every argument of an atomic predicate is

1. E : T =⇒ proper E either of type uexp (and involved in the calculation) or of some type

2. E : T =⇒ isterm E independent of uexp (and not involved in the calculation, e.g., tp in

our example). For such OLs, the proof of the lemma corresponding

to Lemma 4 should be easy to automate.

The main lemma in the proof of type unicity expresses that the

5. Formal Proof of Type Unicity context invariant is preserved when adding a new (fresh) variable

In this section, we prove that types assigned to PCF terms are (and its type) to the context.

unique. In particular, if E : T and E : T , then T and

T are the same type. As is quite common in formal proofs about L EMMA 5. cxtInv Γ =⇒ cxtInv ((VAR (nvC Γ)) : T ) :: Γ.

semantics of programming languages, we need to consider a more It is easy to see why this lemma holds; if the invariant holds of Γ

general statement involving a non-empty context. This kind of and we add a typing assumption about a new variable, we guarantee

generalization is needed particularly when the induction is on a that there is no other typing assumption about this variable already

deduction judgment in which some rules (such as the typing rules in Γ. The only way to build a deduction that assigns a type to this

for the abs and rec operators) involve adding a new assumption to new variable is to use the SL’s axiom rule, namely the second to

the context.2 We start by formulating the induction hypothesis or

simple (non-inductive) fact that abstr E =⇒ proper (abs xT . E x). The

2 Although both adequacy lemmas above seem to follow this pattern, they second lemma does require generalization, but this does not offer any new

are in fact non-examples of the techniques that we are discussing here. In insight since the isterm predicate is just the typing judgment minus the

the first case, in the critical abs rule the induction is not needed as it is a types.

inductive ←− :: [ atm, oo ] ⇒ bool

=⇒ 0 : num ←− tt

=⇒ t : bl ←− tt

=⇒ f : bl ←− tt

=⇒ (succ E) : num ←− E : num

=⇒ (pred E) : num ←− E : num

=⇒ (is0? E) : bl ←− E : num

=⇒ (if E1 E2 E3 ) : T ←− E1 : bl and E2 : T and E3 : T

=⇒ (E1 @ E2 ) : T ←− E1 : (T ⇒ T ) and E2 : T

[[ abstr E ]] =⇒ (abs xT . E x) : (T ⇒ T ) ←− all x. (x : T ) imp (E x) : T

[[ abstr E ]] =⇒ (rec xT . E x) : T ←− all x. (x : T ) imp (E x) : T



=⇒ isterm 0 ←− tt

=⇒ isterm (succ E) ←− isterm E

=⇒ isterm (if E1 E2 E3 ) ←− isterm E1 and isterm E2 and isterm E3

=⇒ isterm (E1 @ E2 ) ←− isterm E1 and isterm E2

[[ abstr E ]] =⇒ isterm (abs xT . E x) ←− all x. (isterm x) imp isterm (E x)

.

.

.



Figure 2. OL clauses encoding typing and well-formedness of PCF terms





last clause in Figure 1, and thus the new variable must have unique Inversion on the second to last premise, followed by inversion on

type T . the last premise gives us two subgoals:

The generalized form of type unicity is expressed in the follow-

ing theorem. [[ IH[i + 2/n]; cxtInv Γ; Γ i +2 (E1 @ E2 ) : T ;

Γ i E1 : (U ⇒ T ) ; Γ i E2 : U ;

T HEOREM 6. Γ j E1 : (U ⇒ T ) ; Γ j E2 : U ]] =⇒ T = T

[[ cxtInv Γ; Γ n E:T ; Γ n E:T ]] =⇒ T = T . [[ IH[i + 2/n]; cxtInv Γ;

Γ i +2 (E1 @ E2 ) : T ; . . . ;

((E1 @E2 ) : T ) ∈ Γ ]] =⇒ T = T

Proof The proof is by complete induction on n, the height of the The first one follows by the induction hypothesis applied to

first typing derivation. The induction hypothesis IH is:

Γ i E1 : (U ⇒ T ) and Γ j E1 : (U ⇒ T ) ,

∀m {L |- of E T1} ->

main result by taking care of the axiom case in the induction on {L |- of E T2} -> T1 = T2.

the SL derivation.

Even a superficial comparison of proof scripts shows that

Note of course that in both encodings, the SL universal quantifica- Abella’s proofs are shorter and neater than in Hybrid. This is no

tion is mapped to . surprise as Abella is a small dedicated system, tailored to HOAS

In Abella’s concrete syntax, provability in the SL is denoted encodings with a very simple, though effective, tactic language.

by brackets and the numerical information about the height of the The flip side is that everything else needs to be encoded directly,

derivation is kept symbolically, a user-interface that Hybrid should while we have the luxury to rely on Isabelle/HOL and Coq. For

adopt. For the sake of conciseness we restrict ourselves to the example instead of a call to the arithmetic tactic, the Abella user

abstraction/application part of PCF. In particular a well-formed needs to encode Peano axioms as logic programs and establish a

context is defined in LGω as follows, where “of” denotes OL large library of the required lemmas. Note also that while G is based

typability: on (monomorphic) simple types, judgments in Abella are untyped,

Def ctx nil. hence adequacy has to be enforced by predicates, as we do.

Def ctx (of X T :: L) :=

(forall M N, X = M @ N -> false) /\ TU in Twelf. As well-known, in the Twelf methodology [Pfen-

(forall T R, X = abs T R -> false) /\ u

ning and Sch¨ rmann 1999] the LF type theory is used to encode

(forall T’, member (of X T’) L -> false) /\ OLs as judgments and to specify meta-theorems as relations (type

ctx L. families) among them; a logic programming-like interpretation pro-

vides an operational semantics to those relations, so that an exter-

Hence a context is forced to be a list of distinct atoms (of X T) nal check for totality (incorporating termination, well-modedness,

with unique types by ruling out all other possibilities.3 Having done u

and coverage checking [Sch¨ rmann and Pfenning 2003, Pientka

that, the user still needs to prove that these impossibilities hold for 2005]) verifies that the given relation is indeed a realizer for that

every constructor, e.g.: (meta)theorem.

Thm: ctx L -> member (of (M @ N) T) L -> false. The encoding of the typing relation is analogous to ours (and

Abella’s), yet, as Twelf is an intentionally weak framework, does

Clearly this does not scale too well even to a small language such not need to be encapsulated in a SL layer. We recall that curly

as PCF. Note also that, in our proof, this is handled directly by brackets denote the dependent product and that Twelf’s type re-

the invariant; see for example the contradiction subcase in the construction allows the user to omit many arguments.

application case of Theorem 6. Another arguably rather ad hoc fact

about the non-occurrence of nominal constants with a particular tp_abs : of (abs E) (T1 => T2)

kind of scope in a list is needed. of (E x) T2).

tp_app : of (E1 @ E2) T1

Thm nominal_absurd: T1)

nabla x, member (of x (T x)) L -> false. fresh X L -> fresh X E. information in proofs with non-empty contexts.

Because type equality is, in this case study, simply the identity,

Now a context can be defined more succinctly; the fresh X L we choose a “shallow” encoding of it as an identity type family

condition could even be removed to show the cunning resemblance over OL types.

with our Lemma 5.

eq : tp -> tp -> type.

Def ctx nil. refl: eq T T.

Def ctx (of X T :: L) := fresh X L /\ ctx L.

Only one technical lemma is required, connected to point 2. of the We then need some lemmas about equality, such as congruence and

above methodology: inversion w.r.t. the type constructor(s). Although these proofs are

immediate, they cannot be delegated to the system, in contrast with

Thm: ctx L -> member (of E T) L -> name E. Abella and Hybrid.

In both proofs, a final lemma states TU for the element of the well- id_arr_cong: eq T1 S1 -> eq T2 S2 ->

formed context: eq (T1 => T2) (S1 => S2) -> type.

Thm: ctx L -> member (of E T1) L ->

member (of E T2) L -> T1 = T2. id1 : id_arr_cong refl refl refl.



Finally, the statement corresponding to Theorem 6: id_arr_inv: eq (T1 => T2) (S1 => S2) ->

eq T1 S1 -> eq T2 S2 -> type.

3 Note that, in additional contrast, our invariant lets the context contain more

than one occurrence of a variable as long as all are assigned the same type. id2 : id_arr_inv refl refl refl.

Now we can declare the higher-order type family corresponding to judgments adds a significant amount of new reasoning power with a

TU and specify every case in the proof as an inhabitant of such a small amount of new definitions and lemmas. Arguably, these defi-

family. We also add directives for totality checking: nitions and lemmas are fairly simple. Furthermore, various forms of

automated support available in such proof assistants, such as tactic-

tp_uniq: {E:exp} {T1:tp} {T2:tp}

style reasoning and decision procedures, are readily available and

of E T1 -> of E T2 -> eq T1 T2 -> type.

can be augmented with support specific to reasoning about HOAS

specifications.

%mode tp_uniq +E +P1 +P2 -R

Note that by using a well-understood logic and system, and

working in a purely definitional way, we avoid the need to jus-

tu_var: tp_uniq _ P P refl.

tify consistency by syntactic or semantic means. For example, we

do not need to show a cut-elimination theorem for a new logic as

tu_abs: tp_uniq _ (tp_abs P1) (tp_abs P2) EqAbs

in [Gacek et al. 2008],5 nor prove results such as strong normal-

T2)(T1 =>T3)). The case for application is tical side, we envision developing a package similar in spirit to

similar but uses inversion to build the required identity proof. Since the nominal datatype package for Isabelle/HOL [Nominal Meth-

the abs case extends the context, it requires a world declaration. Fi- ods Group 2009]. For Hybrid, such a package would automatically

nally, the relation is proved to be a total function by termination and supply a variety of support from a user specification of an OL, such

coverage checking. as validity predicates like isterm, a series of theorems expressing

This is extremely elegant and terse. However, world checking is freeness of the constructors of such a “type”, namely injectivity

far from simple as worlds have some delicate structural properties and distinctness theorems, and automated generation of the defini-

(weakening, no exchange, strengthening) [Harper and Licata 2007]. tions and lemmas related to newvar. To work at two levels, such

It may also be noted that worlds are in a sense extra-logical w.r.t. a package would include a number of pre-compiled SLs (includ-

the LF type theory.4 Further, as coverage checking is undecidable, ing cut-elimination proofs and other properties) as well as some

the algorithm approximates it, yielding sometimes false positives, lightweight tactics to help with two-level inference.

whose error messages are tricky to understand. It is difficult (and

an object of current work) to compare in a meaningful way a tra-

ditional tactic-based system such as Hybrid with a proof-checker Acknowledgments

plus static analysis system such as Twelf. One has to appreciate The first author’s research is supported in part by the Natural

the succinctness of Twelf encodings and the automation of totality Sciences and Engineering Research Council of Canada. We’d like

checking. Still, an idea such as newvar is arguably easy to under- to thanks Dan Licata for his help with Twelf error messages.

stand for anyone familiar with the problem of bound variable names

and renaming.

References

7. Conclusion and Future Work Simon Ambler, Roy L. Crole, and Alberto Momigliano. Combining higher

order abstract syntax with tactical theorem proving and (co)induction. In

We have presented an approach to reasoning inductively on generic n

Carre˜ o et al. [2002], pages 13–30.

judgments with the Hybrid system, which provides additional sup- Brian E. Aydemir, Aaron Bohannon, Matthew Fairbairn, J. Nathan Foster,

port for reasoning about objects encoded using HOAS. Since our Benjamin C. Pierce, Peter Sewell, Dimitrios Vytiniotis, Geoffrey Wash-

architecture is based on a very small set of theories that definition- burn, Stephanie Weirich, and Steve Zdancewic. Mechanized metathe-

ally builds an HOAS meta-language on top of a standard proof- ory for the masses: the POPLMARK challenge. In Joe Hurd and Tom

assistant, this allows us to do without any axiomatic assumptions, in Melham, editors, 18th International Conference on Theorem Proving in

particular freeness of HOAS constructors and extensionality prop-

erties at higher types, which in our setting are theorems. The ad- 5 Recall that Abella, as a system, supports more than natural number in-

ditional support we provide for inductive reasoning with generic duction of the G logic—incidentally, nested induction is crucial to Gacek’s

solution of the first part of the P OPL M ARK challenge [Aydemir et al. 2005].

4 We are aware that they can be justified in terms of meta-logics over LF, A demonstration of cut-elimination requires extending the already complex

u

see the seminal [Sch¨ rmann 2000]. proof for the Linc logic [Momigliano and Tiu 2003].

Higher Order Logics, volume 3603 of Lecture Notes in Computer Sci- Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. Isabelle/HOL:

ence, pages 50–65. Springer, 2005. A Proof Assistant for Higher-Order Logic, volume 2283 of Lecture Notes

Yves Bertot and Pierre Cast´ ran. Interactive Theorem Proving and Pro-

e in Computer Science. Springer, 2002.

gram Development. Coq’Art: The Calculus of Inductive Constructions. Nominal Methods Group. Nominal Isabelle. isabelle.in.tum.de/nominal/,

Springer, 2004. 2009.

Victor Carre˜ o, C´ sar Mu˜ oz, and Sofi` ne Tashar, editors. 15th Interna-

n e n e Christine Paulin-Mohring. Inductive definitions in the system Coq: Rules

tional Conference on Theorem Proving in Higher Order Logics, volume and properties. In M. Bezem and J.F. Groote, editors, International

2410 of Lecture Notes in Computer Science, 2002. Springer. Conference on Typed Lambda Calculi and Applications, volume 664 of

Jo¨ lle Despeyroux, Amy Felty, and Andr´ Hirschowitz. Higher-order ab-

e e Lecture Notes in Computer Science, pages 328–345. Springer, 1993.

stract syntax in Coq. In 2nd International Conference on Typed Lambda Lawrence C. Paulson. A fixedpoint approach to implementing (co)inductive

Calculi and Applications, volume 902 of Lecture Notes in Computer Sci- definitions. In Alan Bundy, editor, 12th International Conference on Au-

ence, pages 124–138. Springer, 1995. tomated Deduction, volume 814 of Lecture Notes in Computer Science,

Lars-Henrik Eriksson. Pi: an interactive derivation editor for the calculus of pages 148–161. Springer, 1994.

partial inductive definitions. In Alan Bundy, editor, 12th International u

Frank Pfenning and Carsten Sch¨ rmann. System description: Twelf — a

Conference on Automated Deduction, volume 814 of Lecture Notes in meta-logical framework for deductive systems. In H. Ganzinger, editor,

Computer Science, pages 821–825. Springer, 1994. 16th International Conference on Automated Deduction, volume 1632

of Lecture Notes in Computer Science, pages 202–206. Springer, 1999.

n

Amy P. Felty. Two-level meta-reasoning in Coq. In Carre˜ o et al. [2002],

pages 198–213. Brigitte Pientka. Verifying termination and reduction properties about

higher-order logic programs. J. Autom. Reasoning, 34(2):179–207,

Amy P. Felty and Alberto Momigliano. Hybrid: A definitional two-

2005.

level approach to reasoning with higher-order abstract syntax. CoRR,

abs/0811.4367, 2008. Brigitte Pientka. Proof pearl: The power of higher-order encodings in the

logical framework lf. In Klaus Schneider and Jens Brandt, editors, 20th

Andrew Gacek. The Abella interactive theorem prover (system description).

International Conference on Theorem Proving in Higher Order Logics,

In Alessandro Armando, Peter Baumgartner, and Gilles Dowek, editors,

volume 4732 of Lecture Notes in Computer Science, pages 246–261.

4th International Joint Conference on Automated Reasoning, volume

Springer, 2007.

5195 of Lecture Notes in Computer Science, pages 154–161. Springer,

2008. Andrew M. Pitts. Nominal logic, a first order theory of names and binding.

Information and Computation, 186(2):165–193, 2003.

Andrew Gacek, Dale Miller, and Gopalan Nadathur. Combining generic

judgments with recursive definitions. In 23rd Annual IEEE Symposium u

Carsten Sch¨ rmann. Automating the Meta-Theory of Deductive Systems.

on Logic in Computer Science, pages 33–44. IEEE Computer Society, PhD thesis, Carnegie-Mellon University, 2000. CMU-CS-00-146.

2008. u

Carsten Sch¨ rmann. A type-theoretic approach to induction with higher-

Elsa L. Gunter. Why we can’t have SML-style datatype declarations in order encodings. In Robert Nieuwenhuis and Andrei Voronkov, editors,

HOL. In Luc J. M. Claesen and Michael J. C. Gordon, editors, Higher 8th International Conference Logic for Programming, Artificial Intelli-

Order Logic Theorem Proving and its Applications, volume A-20, pages gence, and Reasoning, volume 2250 of Lecture Notes in Computer Sci-

561–568. North-Holland/Elsevier, 1992. ence, pages 266–281. Springer, 2001.

Robert Harper and Daniel R. Licata. Mechanizing metatheory in a logical u

Carsten Sch¨ rmann and Frank Pfenning. A coverage checking algorithm for

framework. J. Funct. Program., 17(4-5):613–673, 2007. LF. In David A. Basin and Burkhart Wolff, editors, 16th International

Conference on Theorem Proving in Higher Order Logics, volume 2758

Furio Honsell, Marino Miculan, and Ivan Scagnetto. An axiomatic ap- of Lecture Notes in Computer Science, pages 120–135. Springer, 2003.

proach to metareasoning on nominal algebras in HOAS. In Fernando

Orejas, Paul G. Spirakis, and Jan van Leeuwen, editors, 28th Interna- Dana S. Scott. A type-theoretical alternative to ISWIM, CUCH, OWHY.

tional Colloquium on Automata, Languages and Programming, volume Theoretical Computer Science, 121 (1-2): 411–440, 1993. doi:

2076 of Lecture Notes in Computer Science, pages 963–978. Springer, http://dx.doi.org/10.1016/0304-3975(93)90095-B.

2001. Alwen Tiu. A logic for reasoning about generic judgments. Electr. Notes

Hybrid Group. Hybrid: A package for higher-order syntax in Isabelle and Theor. Comput. Sci., 174(5):3–18, 2007.

Coq. www.hybrid.dsi.unimi.it, 2009.

Raymond McDowell. Reasoning in a Logic with Definitions and Induction.

PhD thesis, University of Pennsylvania, 1997.

Raymond McDowell and Dale Miller. Reasoning with higher-order abstract

syntax in a logical framework. ACM Trans. Comput. Log., 3(1):80–136,

January 2002.

James McKinna and Robert Pollack. Some lambda calculus and type theory

formalized. J. Autom. Reasoning, 23(3–4):373–409, 1999.

Dale Miller and Alwen Tiu. A proof theory for generic judgments. ACM

Trans. Comput. Logic, 6(4):749–783, 2005.

Dale Miller and Alwen Fernanto Tiu. Encoding generic judgments. In

Manindra Agrawal and Anil Seth, editors, 22nd Conference on Foun-

dations of Software Technology and Theoretical Computer Science, vol-

ume 2556 of Lecture Notes in Computer Science, pages 18–32. Springer,

2002.

Alberto Momigliano and Alwen Fernanto Tiu. Induction and co-induction

in sequent calculus. In Stefano Berardi, Mario Coppo, and Ferruccio

Damiani, editors, Types for Proofs and Programs, International Work-

shop, TYPES 2003, Revised Selected Papers, volume 3085 of Lecture

Notes in Computer Science, pages 293–308. Springer, 2003.

Alberto Momigliano, Alan J. Martin, and Amy P. Felty. Two-level Hybrid:

A system for reasoning using higher-order abstract syntax. Electr. Notes

Theor. Comput. Sci., 196:85–93, 2008.


Shared by: xiaohuicaicai
Other docs by xiaohuicaicai
LOGFRAMES_ MONITORING AND EVALUATION
Views: 0  |  Downloads: 0
JELSApndx3SophLanguage
Views: 0  |  Downloads: 0
1997TrumpetCompetitionNYTimes
Views: 0  |  Downloads: 0
Eng_wk52_31
Views: 0  |  Downloads: 0
ENVIRONMENTAL MONITORING PROGRAMME FOR
Views: 0  |  Downloads: 0
Marketing - Ulster Business School
Views: 0  |  Downloads: 0
speech-swallowing
Views: 1  |  Downloads: 0
May_FY11_Awards_Report_Web
Views: 0  |  Downloads: 0
Related docs
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!