Encoding Generic Judgments ^{⋆}

Dale Miller^{1} and Alwen Tiu^{2}

1 INRIA-FUTURS and Ècole Polytechnique

                    dale.miller@inria.fr,

2 Pennsylvania State University and Ècole Polytechnique

                       tiu@cse.psu.edu

Abstract. The operational semantics of a computation system is often presented as inference rules or, equivalently, as logical theories. Specifications can be made more declarative and high-level if syntactic details concerning bound variables and substitutions are encoded directly into the logic using term-level abstractions (λ-abstraction) and proof-level abstractions (eigenvariables). When one wishes to reason about relations defined using term-level abstractions, generic judgment are generally required. Care must be taken, however, so that generic judgments are not uniformly handled using proof-level abstractions. Instead, we present a technique for encoding generic judgments and show two examples where generic judgments need to be treated at the term level: one example is an interpreter for Horn clauses extended with universal quantified bodies and the other example is that of the π-calculus.

1 Introduction

The operational semantics of a programming or specification language is often given in a relational style using inference rules following a small-step approach (a.k.a., structured operational semantic [Plo81]) or big-step approach (a.k.a. natural semantics [Kah87]). In either case, algebraic (first-order) terms can be used to encode the language being specified and the first-order theory of Horn can be used to formalize and interpret such semantic specifications. For example, consider the following natural semantics specification of a conditional expression for a functional programming language:

{B ⇓ true  M ⇓ V \atop (if B M N) ⇓ V}  {B ⇓ false  N ⇓ V \atop (if B M N) ⇓ V}

These two inference figures can also be seen as two first-order Horn clauses:

∀B∀M∀N∀V [B ⇓ true ∧ M ⇓ V ⊃ (if B M N) ⇓ V]
∀B∀M∀N∀V [B ⇓ false ∧ N ⇓ V ⊃ (if B M N) ⇓ V]

Here, the down arrow is a non-logical, predicate symbol and an expression such as N ⇓ V is an atomic formula.

⋆ An earlier draft of this paper appeared in MERLIN 2001 [Mil01].

Of course, once a specification is made, one might want to reason about it. For example, if these two rules are the only rules describing the evaluation of the conditional, then it should follow that if (if B M M) ⇓ V is provable then so is M ⇓ V. In what logic can this be formalized and proved? For example, how might we prove the sequent

(if B M M) ⇓ V ⟶ M ⇓ V,

where B, M, and V are eigenvariables (universally quantified)? Since such a sequent contains no logical connectives, the standard sequent inference rules that introduce logical connective will not directly help here. One natural extension of the sequent calculus is then to add left and right introduction rules for atoms. Hallnäs and Schroeder-Heister [HSH91,SH93], Girard [Gir92], and more recently, McDowell and Miller [MM97,MM00] have all considered just such introduction rules for non-logical constants, using a notion of definition.

2 A proof theoretic notion of definitions

A definition is a finite collection of definition clauses of the form ∀x̄[H =^{△} B], where H is an atomic formula (the one being defined), every free variable of the formula B is also free in H, and all variables free in H are contained in the list x̄ of variables. Since all free variables in H and B are universally quantified, we often leave these quantifiers implicit when displaying definition clauses. The atomic formula H is called the head of the clause, and the formula B is called the body. The symbol =^{△} is used simply to indicate a definition clause: it is not a logical connective. The same predicate may occur in the head of multiple clauses of a definition: it is best to think of a definition as a mutually recursive definition of the predicates in the heads of the clauses. Let H, B, and x̄ be restricted as above. If we assume further that the only logical connectives that may occur in B are ∃, ⊤, and ∧, then we say that the formula ∀x̄[B ⊃ H] is a Horn clause and the definition clause ∀x̄[H =^{△} B] is a Horn definition clause.

Given a definition, the following two inference rules are used to introduce defined predicates. The right introduction rule is

{Γ ⟶ Bθ \atop Γ ⟶ A} defR ,

provided that there is a clause ∀x̄[H =^{△} B] in the given definition such that A is equal to Hθ. The left-introduction rule is

{Bθ, Γ θ ⟶ Cθ | θ ∈ CSU(A, H) for some clause ∀x̄[H =^{△} B]}

A, Γ ⟶ C defL ,

where the variables x̄ are chosen (via α-conversion) to be distinct from the (eigen)variables free in the lower sequent of the rule. The set CSU(A, H) denotes a complete set of unifiers for A and H: when the CSUs and definition are finite, this rule will have a finite number of premises. (A set S of unifiers for t and u is complete if for every unifier ρ of t and u there is a unifier θ ∈ S such that ρ is θ ∘ σ for some substitution σ [Hue75].) There are many important situations where CSUs are not only finite but are also singleton (containing a most general unifier) whenever terms are unifiable: in particular, first-order unification and the higher-order pattern unification [Mil91a], where the application of functional variables are restricted to distinct bound variables.

We must also restrict the use of implication in the bodies of definition clauses, otherwise cut-elimination does not hold [SH92]. To that end we assume that each predicate symbol p in the language is associated with it a natural number lvl(p), the level of the predicate. We then extend the notion of level to formulas and derivations. Given a formula B, its level lvl(B) is defined as follows:

1. lvl(p t̄) = lvl(p)

2. lvl(⊥) = lvl(⊤) = 0

3. lvl(B ∧ C) = lvl(B ∨ C) = max(lvl(B), lvl(C))

4. lvl(B ⊃ C) = max(lvl(B) + 1, lvl(C))

5. lvl(∀x.B) = lvl(∃x.B) = lvl(B).

We now require that for every definition clause ∀x̄[p t̄ =^{△} B], lvl(B) ≤ lvl(p). (If a definition is restricted to the Horn case, then this restriction is trivial to satisfy.) Cut-elimination for this use of definition within intuitionistic logic was proved in [McD97,MM00]. In fact, that proof was for a logic that also included a formulation of induction.

Definitions are a way to introduce logical equivalences so that we do not introduce into proof search meaningless cycles: for example, if our specification contains the equivalence H ≡ B, then when proving a sequent containing H, we could replace it with B, which could then be replaced with H, etc.

To illustrate the strengthening of logic that can result from adding definitions in this way, consider our first example sequent above. We first convert the two Horn clauses representing the evaluation rules for the conditional into the following definition clauses.

(if B M N) ⇓ V =^{△} B ⇓ true ∧ M ⇓ V.
(if B M N) ⇓ V =^{△} B ⇓ false ∧ N ⇓ V.

This sequent then has the following simple and immediate proof.

B ⇓ true, M ⇓ V ⟶ M ⇓ V initial

B ⇓ true ∧ M ⇓ V ⟶ M ⇓ V ∧L

B ⇓ false, M ⇓ V ⟶ M ⇓ V initial

B ⇓ false ∧ M ⇓ V ⟶ M ⇓ V ∧L

(if B M M) ⇓ V ⟶ M ⇓ V defL

In the paper [MMP01], the expressive strength of definitions was studied in greater depth. One example considered there involved attempting to capture the notion of simulation and bisimulation for labeled transition systems. In partic-

ular, assume that P ⟶^{A} P′ is defined via clauses to which are added the two

sim P Q =^{△} ∀A∀P′. P ⟶^{A} P′ ⊃ ∃Q′. Q ⟶^{A} Q′ ∧ sim P′ Q′

bisim P Q =^{△} [∀A∀P′.P ⟶^{A} P′ ⊃ ∃Q′.Q ⟶^{A} Q′ ∧ bisim P′ Q′] ∧ [∀A∀Q′.Q ⟶^{A} Q′ ⊃ ∃P′.P ⟶^{A} P′ ∧ bisim Q′ P′]

Fig. 1. Simulation and bisimulation as definitions.

clauses in Figure 1. These two clauses are a direct encoding of the closure conditions for simulation and bisimulation. (To satisfy the restrictions on levels, the level given to the predicate · ⟶^{·} · must be less than the level given to either predicate sim or bisim.) In [MMP01] it was proved that if the labeled transition system is finite (noetherian) then simulation and bisimulation coincided exactly with provability of sim P Q and bisim P Q. Since provability characterizes the least fixed point and simulation and bisimulation are characterized using the greatest fixed point, the restriction to noetherian transition systems is necessary since noetherian guarantees that these two fixed points are the same.

In Section 4 we show how we can capture simulation and bisimulation for the (finite) π-calculus in a similar style.

3 λ-tree syntax and generic judgments

It is a common observation that first-order terms are not expressive enough to capture rich syntactic structures declaratively. In particular, such terms do not permit a direct encoding of the syntactic category of “abstraction” and the associated notions of α-conversion and substitution.

3.1 Syntactic representation of abstractions

The encoding style called higher-order abstract syntax [PE88] views such abstractions as functional expressions that rely on the full power of β-conversion in a typed λ-calculus setting to perform substitutions. The computer systems λProlog, Elf, Isabelle, and Coq, to name a few, all implement a form of HOAS and many earlier papers have appeared exploiting this style of syntactic representation [MN85,MN86,MN87,Pau89]. Since the earliest papers, however, there has been a tendency to consider richer λ-calculi as foundations for HOAS, moving away from the simply typed λ-calculus setting where it was first exploited. Trying to encode a syntactic category of abstraction by placing it within a rich function spaces can cause significant problems (undecidable unification, exotic terms, etc) that might seem rather inappropriate if one is only trying to develop a simple treatment of syntax.

The notion of λ-tree syntax [MP99,Mil00] was introduced to work around these complexities. Here, λ-abstractions are not general functions: they can only be applied to other, internally bound variables. Substitution of general values is not part of the equality theory in the λ-term syntax approach: it must be coded as a separate judgment via logic. This weaker approach notion of equality gives rise to L_{λ} unification (also, higher-order pattern unification) [Mil91a,Nip91], which is decidable and unary. The relationship between the λ-tree approach where abstractions are applied to only internally bound variable and HOAS where abstractions can be applied to general terms is rather similar to the distinctions made in the π-calculus between π_{I}, which only allows “internal mobility” [San96] and the full π-calculus, where “external mobility” is also allowed (via general substitutions). In Section 4, we will see that this comparison is not accidental.

3.2 When no object-level abstractions are present

To help illustrate the special needs of reasoning about syntax that contains abstractions, we start with an example in which such abstractions are not present.

Consider the specification of an interpreter for object-level Horn clauses. We shall use the type o to denote meta-level logical expressions and obj to denote object-level logical expressions. The meta-logic denotes universal and existential quantification at type σ as ∀_{σ} and ∃_{σ} (both of type (σ → o) → o) and denotes conjunction and disjunction as ∧ and ⊃ (both of type o → o → o). The objectlogic denotes universal and existential quantification by ˆ∀_{σ} and ˆ∃_{σ} (both of type (σ → obj) → obj), conjunction and implication by & and ⇒ (both of type obj → obj → obj), and truth by ˆ⊤ (of type obj). Following usual conventions: type subscripts on quantifiers will often be dropped if they can be easily inferred or are not important, and if a quantifier is followed by a lambda abstraction, the lambda is dropped; eg, ˆ∀ λx will be abbreviated as simply ˆ∀ x.

To encode the provability relation for the object-logic, we exploit the completeness of goal-directed proofs for our object-logic [Mil90]. Provability can be specified as an interpreter using the following four (meta-level) predicates: provability is denoted by ▷ and has type obj → o, backchaining is denoted by the infix symbol ◁ and has type obj → obj → o, atomic of type obj → o decides if an object-level formula is atomic, and prog, also of type obj → o, decides if a formula is an object-level assumption (object-level logic program). The definition in Figure 2 is an interpreter for object-level Horn clause.

Completing the specification of the interpreter requires additional definition clauses for specifying what are atomic object-level formulas and what formulas constitute the object-level Horn clause specification. Examples of such clauses are given in Figure 3. Here, ⇓ has type tm → tm → obj, where tm is the type of the programming language for which evaluation is being specified. It is possible to now prove the sequent

▷(if B M M) ⇓ V ⟶ ▷ M ⇓ V

using the definition clauses in Figures 2 and 3. In fact, the proof of this sequent follows the same structure as the proof of this sequent when it is considered at the meta-level only (as in Section 2). That is, although the proof using the meta-level/object-level distinctions is more complex and detailed, no interesting information is uncovered by these additional complexities. The reason to present

\begin{matrix}▷ ˆ⊤ =^{△} & ⊤. & A ◁ A =^{△} & atomic A. \\ ▷(G & G′) =^{△} & ▷ G ∧ ▷ G′. & (G ⇒ D) ◁ A =^{△} & D ◁ A ∧ ▷ G. \\ ▷(ˆ∃_{σ} G) =^{△} & ∃_{σ}x. ▷(Gx) & (ˆ∀_{σ} D) ◁ A =^{△} & ∃_{σ}t. (D t ◁ A). \end{matrix}

▷ A =^{△} ∃D(atomic A ∧ prog D ∧ D ◁ A).

Fig. 2. Interpreter for object-level specifications.

atomic (M ⇓ V) =^{△} ⊤.
prog (ˆ∀ B ˆ∀ M ˆ∀ N ˆ∀ V [B ⇓ true & M ⇓ V ⇒ (if B M N) ⇓ V]) =^{△} ⊤.
prog (ˆ∀ B ˆ∀ M ˆ∀ N ˆ∀ V [B ⇓ false & N ⇓ V ⇒ (if B M N) ⇓ V]) =^{△} ⊤.

Fig. 3. Examples of object-level Horn clauses.

this interpreter here is so that we may elaborate it in the next section to help capture reasoning about generic judgments.

3.3 Generic judgments as atomic meta-level judgments

When using HOAS or λ-tree syntax representations, inference rules of the form

{ˆ∀ x.Gx \atop A} are often encountered. If one were to capture this in the interpreter

described in Figure 2, there would need to be a way to interpret universally quantified goals. One obvious such interpretation is via the clause

▷(ˆ∀_{σ} x.G x) =^{△} ∀_{σ}x[▷ G x],  (1)

That is, the object-level universal quantifier would be interpreted using the metalevel universal quantifier. While this is a common approach to dealing with object-level universal quantification, this encoding causes some problems when attempting to reason about logic specifications containing generic judgments.

For example, consider proving the query ∀y_{1}∀y_{2}[q ⟨y_{1}, t_{1}⟩ ⟨y_{2}, t_{2}⟩ ⟨y_{2}, t_{3}⟩], where ⟨·, ·⟩ is used to form pairs, from the three clauses q X X Y, q X Y X and q Y X X. This query succeeds only if t_{2} and t_{3} are equal. In particular, we would like to prove the sequent

▷(ˆ∀ y_{1} ˆ∀ y_{2}[q ⟨y_{1}, t_{1}⟩ ⟨y_{2}, t_{2}⟩ ⟨y_{2}, t_{3}⟩]) ⟶ t_{2} = t_{3},

where t_{1}, t_{2}, and t_{3} are eigenvariables and with a definition that consists of the clause (1), those clauses in Figure 2, and the following clauses:

X = X =^{△} ⊤

atomic (q X Y Z) =^{△} ⊤

prog (ˆ∀ X ˆ∀ Y q X X Y) =^{△} ⊤

prog (ˆ∀ X ˆ∀ Y q X Y X) =^{△} ⊤

prog (ˆ∀ X ˆ∀ Y q Y X X) =^{△} ⊤

Using these definitional clauses, this sequent reduces to

▷(q ⟨s_{1}, t_{1}⟩ ⟨s_{2}, t_{2}⟩ ⟨s_{2}, t_{3}⟩) ⟶ t_{2} = t_{3},

for some terms s_{1} and s_{2}. This latter sequent is provable only if s_{1} and s_{2} are chosen to be two non-unifiable terms. This style proof is quite unnatural and it also depends on the fact that the underlying type that is quantified in ∀y_{1}∀y_{2} contains at least two distinct elements.

Additionally, if we consider a broader class of computational systems, other than conventional logical systems, a similar issue appears when we try to encode their term-level abstractions at the meta-level. For systems where names can be given scope and can be compared (the π-calculus, for example), interpreting object-level abstraction via universal quantifier may not be appropriate in certain cases. In the case of π-calculus, consider encoding the one-step transition semantics for the restriction operator:

(x)P x ⟶^{A} (x)P′x =^{△} ∀x.P x ⟶^{A} P′x.

If the atomic judgment (x)P x ⟶^{A} (x)P′x is provable, then the meta-level

atomic formula P t ⟶^{A} P′t is provable for all names t. This is certainly not true in the present of match or mismatch operator in P. (We return to the π-calculus in more detail in Section 4.)

For these reasons, the uniform analysis of an object-level universal quantifier with a universal quantifier in (1) should be judged inappropriate. We now look for a different approach for encoding object logics.

A universal formula can be proved by an inference rule such as

{Γ, c : σ ⊢ P c \atop Γ ⊢ ˆ∀_{σ} x.P x} ,

where P is a variable of higher type, Γ is a set of distinct typed variables, and c is a variable that is not free in the Γ nor in ˆ∀_{σ} x.P x. When we map the judgment Γ ⊢ ˆ∀_{σ} x.P x into the meta-logic, the entire judgment will be seen as an atomic meta-level formula: that is, we do not encode just ▷(ˆ∀_{σ} x.P x) but rather the entire judgment ▷(Γ ⊢ ˆ∀_{σ} x.P x).

We consider two encodings of the judgment x_{1}, …, x_{n} ⊢ (P x_{1} … x_{n}), where the variables on the left are all distinct. The first encoding introduces a “local” binders using a family of constants, say, loc_{σ} of type (σ → obj) → obj. The above expression would be something of the form

loc_{σ_{1}}λx_{1} … loc_{σ_{n}}λx_{n}. P x_{1} … x_{n},

where, for i = 1, …, n, σ_{i} is the type of the variable x_{i}. While this encoding is natural, it hides the top-level structure of P x_{1} … x_{n} under a prefix of varying length. Unification and matching, which are central to the functioning of the definition introduction rules, does not directly access that top-level

▷_{l}( ˆ⊤) =^{△} ⊤.
▷_{l}((G l) & (G′ l)) =^{△} ▷_{l}(Gl) ∧ ▷_{l}(G′l).
▷_{l}(ˆ∃_{σ} w.(G l w)) =^{△} ∃_{evs→σ}t. ▷_{l}(G l (t l)).
▷_{l}(ˆ∀_{σ} w.(G l w)) =^{△} ▷_{l}(G(ρ̂l)(ρ_{σ}l)).
▷_{l}(Al) =^{△} ∃D.(atomic A ∧ progD ∧ (Dl) ◁_{l} (Al)).
(Al) ◁_{l} (Al) =^{△} atomic A.
((G l) ⇒ (D l)) ◁_{l} (Al) =^{△} (Dl) ◁_{l} (Al) ∧ ▷_{l}(Gl).
(ˆ∀_{σ} w.(D l w)) ◁_{l} (Al) =^{△} ∃_{evs→σ}t.(D l (t l) ◁_{l} (Al)).

Fig. 4. An interpreter for simple generic judgments.

structure. The second alternative employs a coding technique used by McDowell [McD97,MM02]. Here, one abstraction, say for a variable l of type evs (eigenvariables), is always written over the judgment and is used to denote the list of distinct variables x_{1}, …, x_{n}. Individual variables are then accessed via the projections ρ_{σ} of type evs → σ and ρ̂ of type evs → evs. For example, the judgment x : a, y : b, z : c ⊢ P xyz could be encoded as either the expression loc_{a}λxloc_{b}λyloc_{c}λz.P xyz, or as λl(P (ρ_{a}l)(ρ_{b}(ρ̂l))(ρ_{c}(ρ̂(ρ̂l)))). In this second, preferred encoding, the abstraction l denotes a list of variables, the first variable being of type a, the second being of type b, and the third of type c.

3.4 An interpreter for generic judgments

To illustrate this style encoding of generic judgments, consider the interpreter displayed in Figure 4. This interpreter specifies provability for object-level Horn clauses in which the body of clauses may have occurrences of the universal quantifiers (as well as true, conjunction, and the existential quantifier) and generalizes the previous interpreter (Figure 2). Here, the three meta-level predicates atomic ·, prog ·, and ▷ · all have the type (evs → obj) → o while ·◁· has the type (evs → obj) → (evs → obj) → o. The evs abstractions in these predicates are abbreviated as the subscript l next to the predicates, so the expression ▷((λl.G l)& (λl.G′ l)) is written simply as ▷_{l}((G l) & (G′ l)). Notice that the technique of replacing the abstraction λl. ˆ∀_{σ} λw.(G l w)) with λl.G(ρ̂l)(ρl)) corresponds to replacing the judgment x_{1}, …, x_{n} ⊢ ∀y(P yx_{1} … x_{n}) with x_{1}, …, x_{n}, x_{n+1} ⊢ (P x_{1} … x_{n}x_{n+1}).

Notice that proof search using this interpreter will generate more than L_{λ} unification problems (via the left and right definition rules) for two reasons. First, the definition clause for interpreting (λl. ˆ∀_{σ} w.(G l w)) contains the expression (λl.G(ρ̂l)(ρ_{σ}l)) and the subterms (ρ̂l) and (ρ_{σ}l) are not distinct bound variables. However, the technical definition of L_{λ} can be extended to allow for this style of encoding of object-level variables, while still preserving the decidability and the mgu property of the unification problems [Tiu02]. A second reason that this interpreter is not in L_{λ} is the definition clause for backchaining over (λl. ˆ∀_{σ} w.(D l w)) since this clause contains the expression (λl.D l (t l)), which requires applying an abstraction to a general (external) term t. Such a specification can be made into an L_{λ} specification by encoding object-level substitution as an explicit judgment [Mil91b]. The fact that this specification is not in L_{λ} simply means that when we apply the left-introduction rule for definitions, unification may not produce a most general unifier.

See [MM02] for the correctness proofs of this encoding of generic judgments. Other judgments besides generic judgments can be encoded similarly. For example, in [McD97,MM02], hypothetical as well as linear logic judgments were encoded along these lines. The main objective in those papers is to encode an object-level sequent as atomic judgments in a meta-logic.

4 The π-calculus

To illustrate the use of this style of representation of universal judgments, we turn, as many others have done [MP99,HMS01,Des00,RHB01], to consider encoding the π-calculus. In particular, we follow the encoding in [MP99] for the syntax and one-step operational semantics.

Following the presentation of the π-calculus given in [MPW92], we shall require three primitive syntactic categories: name for channels, proc for processes, and action for actions. The output prefix is the constructor out of type name → name → proc → proc and the input prefix is the constructor in of type name → (name → proc) → proc: the π-calculus expressions x̄y.P and x(y).P are represented as (out x y P) and (in x λy.P), respectively. We use | and +, both of type proc → proc → proc and written as infix, to denote parallel composition and summation, and ν of type (name → proc) → proc to denote restriction. The π-calculus expression (x)P will be encoded as νλn.P, which itself is abbreviated as simply νx.P. The match operator, [· = ·]· is of type name → name → proc → proc. When τ is written as a prefix, it has type proc → proc. When τ is written as an action, it has type action. The symbols ↓ and ↑, both of type name → name → action, denote the input and output actions, respectively, on a named channel with a named value.

We shall deal with only finite π-calculus expression, that is, expressions without ! or defined constants. Extending this work to infinite process expressions can be done using induction, as outlined in [MMP01] or by adding an explicit co-induction proof rule dual to the induction rule. Fortunately, the finite expressions are rich enough to illustrate the issues regarding syntax and abstractions that are the focus of this paper.

Proposition 1. Let P be a finite π-calculus expression using the syntax of [MPW92]. If the free names of P are admitted as constants of type name then P corresponds uniquely to a βη-equivalence class of terms of type proc.

We first consider the encoding of one-step transition semantics of π-calculus. As we did with the encoding of object logics, we explicitly encode the “signatures” of π-calculus expressions (i.e., the names) as abstractions of type evs. The encoding uses two predicates: · ⟶^{·} · of type (evs → proc) → (evs → action) → (evs → proc) → o; and · −⇀^{·} · of type (evs → proc) → (evs → name → action) → (evs → name → proc) → o. The first of these predicates encodes transitions involving free values and the second encodes transitions involving bound values.

Figures 5, 6 and 7 present the transition semantics as Horn specification. We omit the evs abstraction for simplicity of presentation. We shall see later how to translate this specification into Horn definition clauses. Figure 5 specifies the one step transition system for the “core” π-calculus. Figure 6 provides the increment to the core rules to get the late transition system, and Figure 7 gives the increment to the core to get the early transition system. Note that all the rules in the core system belong to the L_{λ} subset of logic specifications: that is, abstractions are applied to only abstracted variables (either bound by a λabstraction or bound by a universally quantifier in the premise of the rule). Furthermore, note that each of the increments for the late and early systems involve at least one clause that is not in L_{λ}.

\overline{τ.P ⟶^{τ} P} τ  \frac{P ⟶^{A} Q}{[x = x]P ⟶^{A} Q} match  \frac{P −⇀^{A} Q}{[x = x]P −⇀^{A} Q} match

\frac{P ⟶^{A} R}{P + Q ⟶^{A} R} sum \frac{Q ⟶^{A} R}{P + Q ⟶^{A} R} sum \frac{P −⇀^{A} R}{P + Q −⇀^{A} R} sum \frac{Q −⇀^{A} R}{P + Q −⇀^{A} R} sum

\frac{P ⟶^{A} P′}{P |Q ⟶^{A} P′|Q} par  \frac{Q ⟶^{A} Q′}{P |Q ⟶^{A} P |Q′} par

\frac{P −⇀^{A} M}{P |Q −⇀^{A} λn(Mn|Q)} par  \frac{Q −⇀^{A} N}{P |Q −⇀^{A} λn(P |Nn)} par

\frac{∀n(P n ⟶^{A} P′n)}{νn.P n ⟶^{A} νn.P′n} res  \frac{∀n(P n −⇀^{A} P′n)}{νn.P n −⇀^{A} λm νn.(P′nm)} res
\overline{out x y P ⟶^{↑xy} P} output  \overline{in x M −⇀^{↓x} M} input

\frac{∀y(My ⟶^{↑xy} M′y)}{νy.My −⇀^{↑x} M′} open

\frac{P −⇀^{↓x} M  Q −⇀^{↑x} N}{P |Q ⟶^{τ} νn.(Mn|Nn)} close  \frac{P −⇀^{↑x} M  Q −⇀^{↓x} N}{P |Q ⟶^{τ} νn.(Mn|Nn)} close

Fig. 5. The core π-calculus in λ-tree syntax.

Sangiorgi has also motivated the same core system of rules [San96] and named them π_{I}: this subset of the π-calculus allows for “internal” mobility of names, that is, local (restricted) names only being passed to abstractions (via β_{0} reductions), and disallows “external” mobility (via the more general β reduction rules).

\frac{P −⇀^{↓x} M  Q ⟶^{↑xy} Q′}{P |Q ⟶^{τ} (My)|Q′} L-com  \frac{P ⟶^{↑xy} P′  Q −⇀^{↓x} N}{P |Q ⟶^{τ} P′|(Ny)} L-com

Fig. 6. The additional rules for late π-calculus.

\overline{in x M ⟶^{↓xy} My} E-input

\frac{P ⟶^{↑xy} P′  Q ⟶^{↓xy} Q′}{P |Q ⟶^{τ} P′|Q′} E-com  \frac{Q ⟶^{↓xy} Q′  P ⟶^{↑xy} P′}{P |Q ⟶^{τ} P′|Q′} E-com

Fig. 7. The additional rules for early π-calculus.

One advantage of this style of specification over the traditional one [MPW92] is the absence of complicated side-conditions on variables: they are handled directly by the treatment of abstractions by logic.

Universally quantified premises, of which there are three in Figure 5, is one of the logical features that aids in encoding abstractions. When the inference rules in these figures are written as formulas, cut-free provability of the judgments

P ⟶^{A} Q and P −⇀^{A} Q corresponds to one-step transitions for the π-calculus. While the right-introduction rule for the universal quantifiers that appears in these premises is correct, the corresponding left-introduction rule (which does not appear in cut-free proofs of just one-step transitions) for universal quantifiers is not always appropriate. It is the left-hand introduction rules for universal quantifiers that allow for arbitrary substitutions for abstractions, and, as suggested in Section 3.3, this property is certainly undesirable if we wish to extend our specification of the π-calculus, for example, to include the mismatch operator. We can also encode these Horn clauses as prog clauses in an object-logic interpreter like the one we defined in Section 3.4. This style of encoding inherits similar substitution properties of the object-logic.

One way to address this problem of the universal quantifier is to translate these inference rules into Horn definitions using the technique described in the previous section. We first need to make explicit the object-level eigenvariables by writing down the evs abstractions. Then, it is almost straightforward to rewrite these inference rule into Horn definitions, except for the cases involving the restriction operator which we will show here for the rules res and open.

\begin{matrix}res: & νn.P ln ⟶_{l}^{Al} νn.P′ln & =^{△} & P (ρ̂l)(ρl) ⟶_{l}^{A(ρ̂l)} P′(ρ̂l)(ρl) \\ open: & νy.Mly −⇀_{l}^{↑(xl)} M′l & =^{△} & M(ρ̂l)(ρl) ⟶_{l}^{↑(x(ρ̂l))(ρl)} M′(ρl) \end{matrix}

sim_{l} (P l) (Ql) =^{△} ∀A∀P′[(P l ⟶_{l}^{Al} P′l) ⊃ ∃Q′ \begin{matrix}(Ql ⟶_{l}^{Al} Q′l)∧ \\ sim_{l} (P′l) (Q′l)] ∧ \end{matrix} ∀X∀P′[(P l −⇀_{l}^{↓(Xl)} P′l) ⊃ ∃Q′ \begin{matrix}(Ql −⇀_{l}^{↓(Xl)} Q′l)∧ \\ ∀w sim_{l} (P′l(wl)) (Q′l(wl))] ∧ \end{matrix} ∀X∀P′[(P l −⇀_{l}^{↑(Xl)} P′l) ⊃ ∃Q′ \begin{matrix}(Ql −⇀_{l}^{↑(Xl)} Q′l)∧ \\ sim_{l} (P′(ρ̂l)(ρl)) (Q′(ρ̂l)(ρl))] \end{matrix}

Fig. 8. Definition clause for simulation of π-calculus

Here, the expression λl.P l ⟶_{l}^{λl.Al} λl.P′l is abbreviated as P l ⟶_{l}^{Al} P′l.

Proposition 2. Let P ⟶^{A} Q be provable in late (resp., early) transition system

of [MPW92]. If A is either τ or ↓ xy or ↑ xy then P l ⟶_{l}^{Al} Ql is provable from the definition clauses encoding late (resp., early) transitions. (Here, P, A, and Q are all translated to the corresponding logic-level term.) If A is x(y) then

P l −⇀_{l}^{↓(xl)} Rl and if A is x̄(y) then P l −⇀_{l}^{↑(xl)} Rl. Here, R is the representation of the λ-abstraction of y over Q.

Since the types of P and P′ are different in the expression P −⇀^{A} P′, we cannot immediately form the transitive closure of this relationship to give a notion of a sequence of transitions. It is necessary to lower the type of P′ first by applying it to a term of type name. How this is done, depends on what we are trying to model. To illustrate two such choices, we now consider encoding simulation.

For simplicity, we shall consider only simulation and not bisimulation: extending to bisimulation is not difficult (see Figure 1) but does introduce several more cases and make our examples more difficult to read. Figure 8 presents a definition clause for simulation. Here, the predicate sim is of type (evs → proc) → (evs → proc) → o and again, we abbreviate the expression sim (λl.P l) (λl.Ql) as sim_{l}(P l)(Ql). Here, X has type evs → name, P has type evs → proc, and P′ has two different types, evs → proc and evs → name → proc. Since the only occurrence of ρ_{σ} is such that σ is name, we shall drop the subscript on ρ. Notice also that for this set of clauses to be successfully stratified, the level of sim must be strictly greater than the level of all the other predicates of the one-step transitions (which can all be equal).

The first conjunct in the body of the clause in Figure 8 deals with the case where a process makes either a τ step or a free input or output action. In these cases, the variable A would be bound to either λl.τ (in the first case) or λl. ↓ (N l)(M l) or λl. ↑ (N l)(M l), in which cases, N and M would be of the form λl.ρ(ρ̂^{i}l) for some non-negative integer i.

The last two cases correspond to when a bounded input or output action is done. In the case of the bounded input (the second conjunct), a universal quantifier, ∀w, is used to instantiate the abstractions (P′ and Q′), whereas in the bounded output case (the third conjunct), a term-level abstraction is emulated: such an internal abstraction is immediately replaced by using a new variable in the context, via the use of ρ and ρ̂. This one definition clause thus illustrates an important distinction between term-level and proof-level abstractions: in particular, they reflect the different behaviors of name-binding constructs in input prefix and restriction operator of π-calculus.

5 Related and future work

Of course, the value of this approach to encoding object-logics and the πcalculus comes, in part, from the ability to automate proofs using such definitions. Jeremie Wajs and Miller have been developing a tactic-style theorem prover for a logic with induction and definitions [Waj02]. This system, called Iris, is written entirely in Nadathur’s Teyjus implementation [NM99] of λProlog and appears to be the first theorem proving system to be written entirely using higher-order abstract syntax (parser, printer, top-level, tactics, tacticals, etc). Example proofs that we have done by hand come out as expected: they are rather natural and immediate, although the encoding of object-level signature as a single abstraction makes expressions rather awkward to read. Fortunately, simple printing and parsing conventions can improve readability greatly. Given that the interpreter in Figure 4 is based on Horn clauses definitions, it is possible to employ well known induction principles for Horn clauses to help prove properties of the object logics/systems.

There are various other calculi, such as the join and ambient calculi, in which names and name restriction are prominent and we plan to test this style of encoding with them. Generic judgments have been used to model names for references and exceptions [Mil96,Chi95] and it would be interesting to see if this style of encoding can help in reasoning about programming language semantics containing such features. Comparing this particular encoding of the π-calculus with those of others, for example, [HMS01,Des00,RHB01], should be done in some detail.

Finally, the approach to encoding syntax and operational semantics used here is strongly motivated by proof theoretic considerations. There has been much work lately on using a more model-theoretic or categorical-theoretic approaches for such syntactic representations, see for example [FPT99,GP99,Hof99]. Comparing those two approaches should be illuminating.

Acknowledgments. Catuscia Palamidessi has made a number of comments on a draft of this paper. Anonymous reviewers for MERLIN 2001 also made several corrections to the presentation of this paper. This work is funded in part by NSF grants CCR-9912387, CCR-9803971, INT-9815645, and INT-9815731.

References

[Chi95] Jawahar Chirimar. Proof Theoretic Approach to Specification Languages. PhD thesis, University of Pennsylvania, February 1995.

[Des00] Jolle Despeyroux. A higher-order specification of the π-calculus. In Proc. of the IFIP International Conference on Theoretical Computer Science, IFIP TCS’2000, Sendai, Japan, August 17-19, 2000., August 2000.

[FPT99] M. P. Fiore, G. D. Plotkin, and D. Turi. Abstract syntax and variable binding. In 14th Annual Symposium on Logic in Computer Science, pages 193–202. IEEE Computer Society Press, 1999.

[Gir92] Jean-Yves Girard. A fixpoint theorem in linear logic. Email to the linear@cs.stanford.edu mailing list, February 1992.

[GP99] M. J. Gabbay and A. M. Pitts. A new approach to abstract syntax involving binders. In 14th Annual Symposium on Logic in Computer Science, pages 214–224. IEEE Computer Society Press, 1999.

[HMS01] Furio Honsell, Marino Miculan, and Ivan Scagnetto. Pi-calculus in (co)inductive type theory. TCS, 253(2):239–285, 2001.

[Hof99] M. Hofmann. Semantical analysis of higher-order abstract syntax. In 14th Annual Symposium on Logic in Computer Science, pages 204–213. IEEE Computer Society Press, 1999.

[HSH91] Lars Hallnäs and Peter Schroeder-Heister. A proof-theoretic approach to logic programming. ii. Programs as definitions. Journal of Logic and Computation, 1(5):635–660, October 1991.

[Hue75] Gérard Huet. A unification algorithm for typed λ-calculus. TCS, 1:27–57, 1975.

[Kah87] Gilles Kahn. Natural semantics. In Proc. of the Symposium on Theoretical Aspects of Computer Science, volume 247 of LNCS, pages 22–39. March 1987.

[McD97] Raymond McDowell. Reasoning in a Logic with Definitions and Induction. PhD thesis, University of Pennsylvania, December 1997.

[Mil90] Dale Miller. Abstractions in logic programming. In Piergiorgio Odifreddi, editor, Logic and Computer Science, pages 329–359. Academic Press, 1990.

[Mil91a] Dale Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. Journal of Logic and Computation, 1(4):497–536, 1991.

[Mil91b] Dale Miller. Unification of simply typed lambda-terms as logic programming. In Eighth International Logic Programming Conference, pages 255– 269, Paris, France, June 1991. MIT Press.

[Mil96] Dale Miller. Forum: A multiple-conclusion specification language. TCS, 165(1):201–232, September 1996.

[Mil00] Dale Miller. Abstract syntax for variable binders: An overview. In John Lloyd and et. al., editors, Computational Logic - CL 2000, number 1861 in LNAI, pages 239–253. Springer, 2000.

[Mil01] Dale Miller. Encoding generic judgments: Preliminary results. In R.L. Crole S.J. Ambler and A. Momigliano, editors, ENTCS, volume 58. Elsevier, 2001. Proceedings of the MERLIN 2001 Workshop, Siena.

[MM97] Raymond McDowell and Dale Miller. A logic for reasoning with higherorder abstract syntax. In Glynn Winskel, editor, Proceedings, Twelfth Annual IEEE Symposium on Logic in Computer Science, pages 434–445, Warsaw, Poland, July 1997. IEEE Computer Society Press.

[MM00] Raymond McDowell and Dale Miller. Cut-elimination for a logic with definitions and induction. TCS, 232:91–119, 2000.

[MM02] Raymond McDowell and Dale Miller. Reasoning with higher-order abstract syntax in a logical framework. ACM Transactions on Computational Logic, 3(1):80–136, January 2002.

[MMP01] Raymond McDowell, Dale Miller, and Catuscia Palamidessi. Encoding transition systems in sequent calculus. TCS, 197(1-2), 2001. To appear.

[MN85] Dale Miller and Gopalan Nadathur. A computational logic approach to syntax and semantics. Presented at the Tenth Symposium of the Mathematical Foundations of Computer Science, IBM Japan, May 1985.

[MN86] Dale Miller and Gopalan Nadathur. Some uses of higher-order logic in computational linguistics. In Proceedings of the 24th Annual Meeting of the Association for Computational Linguistics, pages 247–255. Association for Computational Linguistics, Morristown, New Jersey, 1986.

[MN87] Dale Miller and Gopalan Nadathur. A logic programming approach to manipulating formulas and programs. In Seif Haridi, editor, IEEE Symposium on Logic Programming, pages 379–388, San Francisco, September 1987.

[MP99] Dale Miller and Catuscia Palamidessi. Foundational aspects of syntax. In Pierpaolo Degano, Roberto Gorrieri, Alberto Marchetti-Spaccamela, and Peter Wegner, editors, ACM Computing Surveys Symposium on Theoretical Computer Science: A Perspective, volume 31. ACM, Sep 1999.

[MPW92] Robin Milner, Joachim Parrow, and David Walker. A calculus of mobile processes, Part II. Information and Computation, pages 41–77, 1992.

[Nip91] Tobias Nipkow. Higher-order critical pairs. In G. Kahn, editor, LICS91, pages 342–349. IEEE, July 1991.

[NM99] Gopalan Nadathur and Dustin J. Mitchell. System description: Teyjus—a compiler and abstract machine based implementation of Lambda Prolog. In H. Ganzinger, ed., CADE16, pages 287–291, Trento, Italy, July 1999. LNCS.

[Pau89] Lawrence C. Paulson. The foundation of a generic theorem prover. Journal of Automated Reasoning, 5:363–397, September 1989.

[PE88] Frank Pfenning and Conal Elliott. Higher-order abstract syntax. In Proceedings of the ACM-SIGPLAN Conference on Programming Language Design and Implementation, pages 199–208. ACM Press, June 1988.

[Plo81] G. Plotkin. A structural approach to operational semantics. DAIMI FN-19, Aarhus University, Aarhus, Denmark, September 1981.

[RHB01] C. Röckl, D. Hirschkoff, and S. Berghofer. Higher-order abstract syntax with induction in Isabelle/HOL: Formalizing the pi-calculus and mechanizing the theory of contexts. In Proceedings of FOSSACS’01, LNCS, 2001.

[San96] Davide Sangiorgi. π-calculus, internal mobility and agent-passing calculi. TCS, 167(2):235–274, 1996.

[SH92] Peter Schroeder-Heister. Cut-elimination in logics with definitional reflection. In D. Pearce and H. Wansing, editors, Nonclassical Logics and Information Processing, volume 619 of LNCS, pages 146–171. Springer, 1992.

[SH93] Peter Schroeder-Heister. Rules of definitional reflection. In M. Vardi, editor, Eighth Annual Symposium on Logic in Computer Science, pages 222–232. IEEE Computer Society Press, IEEE, June 1993.

[Tiu02] Alwen F. Tiu. An extension of L-lambda unification. Draft, available via

http://www.cse.psu.edu/~tiu/llambdaext.pdf, September 2002.

[Waj02] Jérémie D. Wajs. Reasoning about Logic Programs Using Definitions and Induction. PhD thesis, Pennsylvania State University, 2002.