• Aucun résultat trouvé

On Unification of Lambda Terms

N/A
N/A
Protected

Academic year: 2022

Partager "On Unification of Lambda Terms"

Copied!
2
0
0

Texte intégral

(1)

On Unification of Lambda Terms

Giulio Manzonetto

1

Andrew Polonsky

2

1 Universit´e Paris 13, Laboratoire LIPN, CNRS UMR 7030, France

2 Universit´e Paris Diderot, Laboratoire IRIF, CNRS UMR 8243, France

We propose a unification algorithm for the type-free lambda calculus. As an intermediate step in this development, we are led to the following question:

What does it mean to unify untyped higher-order terms?

As an illustrative example, consider the obsevation, due to Visser, that Ω is the onlyλ-term which reduces to itself in a single step (up to a redex-free context around it). Wlog, we may assume that the redex is at the root; then any termM with this property must be a solution to a “unification equation”

M = (λv.X)Y =X[Y/v] (1)

whereX,Y are meta-variables for terms.

(Here and henceforth, “=” denotes syntacticα-equality.)

Note that X = X(v) is a higher-order meta-variable — but it is not a

“context”, because it can have more than one hole.

We may pursue to solve (1) analogously to the usual unification process.

Since the substitution resultX[Y/v]is an application, we have two possibil- ities for X=X(v):

X(v) =

⎧⎪

⎪⎪

v (A)

X1(v)X2(v) (B)

Case (A), together with (1), yields (λv.X)Y = X(Y) =Y, contradicting finiteness of M. (Although, the infinite term Y = (λv.v)Y is a solution of (1), and it is indeed a 1-cycle in the infinitary lambda calculus.)

So(A) is ruled out. Rewriting (1) using (B), we obtain

(λv.X1(v)X2(v))Y = (λv.X)Y =X[Y/v] =X1(Y)X2(Y)

X1(Y) =λv.X1(v)X2(v) (2)

X2(Y) =Y (3)

Next, we can “destruct” X1 according to (2), obtaining two possibilities (X1(v) =v andX1(v) =λv.X10(v, v)), eliminate one, rewrite the other back

1

(2)

into (2), and so forth. Proceeding in this manner, we shall eventually find that the only solution isM = (λx.xx)(λx.xx). (See [2] for other examples.)

In a similar manner, we can enumerate all terms with a specified “subterm pattern”, given by a set of unification constraints. Such an algorithm could be used to enumerate all terms with a particular redex structure (for example, in order to analyze possible standardard reductions of shapeN x↠x(N x)).

It may not be obvious that the above process should always terminate — unlike the case of first-order unification, substituting a meta-variable does not completely eliminate it. Each iteration develops the root symbol only, and may yet introduce new meta-variables, occurring deeper and more often (while substitution proliferates and rearranges existing ones).

Nevertheless, we prove that the above algorithm does terminate, and yields a set of most general solutions. (There are in general many of them.)

At first, our claim appears to contradict the common wisdom that “higher- order unification is undecidable” [1]. Doesn’t it?

First of all, notice that we are working in an untyped setting, whereas higher-order unification is usually considered for simple types. While this does not seem to help much, it may perhaps explain the second difference, which is thatwe do not contract the beta redexes.

Indeed, from the perspective of equational logic, unification is a purely syntactic operation, and is not expected to take into consideration the whole set of axioms a given theory might have.

The lambda calculus is a theory of terms built up with a binary first-order operation and a unary higher-order operation; the beta-rule is merely an axiom of this theory. Generalizing to other higher-order signatures, with perhaps different rewrite rules, one could scarcely hope the generic “unifica- tion algorithm” to subsume all their possible equations.

So we do not solve full second-order unification. At the same time, the higher-order meta variables are not inert, either. In a sense, the substitu- tions being performed at every step are morally contractions of beta-redexes introduced by the algorithm implicitly.

Finally, this approach does not seem to fall under context unification ei- ther, since the occurrence of “holes” can be multiple and unbounded.

In the original spirit of the Types meetings, we hope that our presentation may elicit suggestions from the audience toward how our result relates to the well-known unification paradigms.

References

[1] G. Dowek, Higher-Order Unification and Matching, Handbook of Automated Reasoning, pp. 1009–1062, Elsevier and MIT Press, 2001

[2] M. Venturini Zilli, Reduction Graphs in the Lambda Calculus, Theor. Comput. Sci., Vol.

29, pp. 251–275, 1984.

2

Références

Documents relatifs

In this paper, we define an infinite set S of mute terms, and show that it is graph-easy: for any closed term t of the lambda calculus there exists a graph model equating all the

Thus, in every positions where both the query term and candidate term contain a function symbol, these symbols must be identical, because sub- stitution does not change

Unité de recherche INRIA Rennes : IRISA, Campus universitaire de Beaulieu - 35042 Rennes Cedex (France) Unité de recherche INRIA Rhône-Alpes : 655, avenue de l’Europe -

This proof may be generalize to prove (this result is also well known) the operationnely equiva- lence of two λ-terms where the B˝ohm tree are equal ` a η - infinite expansion

Notwithstanding this distinction, their approach to λ-calculus with linear combinations of terms contrasts with ours: consider terms up to ≡ rather than some variant of =, and

Since the average number of De Bruijn levels of k-colored Motzkin trees of size asymptotic to n is Θ( √ n), the same is true for k-indexed lambda terms, which have just k levels

We don’t apply swapping to hyperlinks representing the bound variables of an abs (the fourth rule in Definition 1) because all bound variables are distinct in hypergraph λ-terms, and

We describe a Prolog-based combined lambda term generator and type-inferrer for closed well-typed terms of a given size, in de Bruijn notation.. By taking advantage of Prolog’s