Chapter 4

First-order Terms

4.1. Matching and unification

4.1.1. A motivation for searching for a matching algorithm

Imagine that in example 3.9, you are given the first step of an alleged proof:

1) ie121_01.gif

without any justification, and that you (legitimately) wonder: “how can I be sure that this wff is a possible first step of a proof?”.

If formulas (structured strings) are represented as trees, answering this question reduces to finding what replacements should be carried out in the axiom schemas so as to find the desired wff (in a proof, this is the only possibility for the first step). We therefore try the axiom schemas one by one.

equ121_01.gif

We will use X, Y, and Z for the meta-variables that appear in the axiom schemas to better emphasize that they are to be replaced.

equ122_01.gif

It is simple to see that there is no way to replace the variables in (A1) to identify (A1) with (1): we would need to replace X with A (rightmost leaf) and X with A d_arr.gif ((A d_arr.gif A) d_arr.gif A) (leftmost leaf).

Let us try with (A2):

equ122_02.gif

We realize that the trees (1) and (A2) can be identified by replacing:

equ122_03.gif

As a conclusion, (1) can indeed be the first step of a proof in image1.

In this example, we assumed that only one of the trees contained variables. Let us see what we would do if both the two terms to be made identical contained variables. In what follows, x, y, z,… denote variables (they are objects that can be replaced by other objects) and a, b, c,…, f, g,… denote constants (they are objects that cannot be replaced by other objects).

Since we want to design a general algorithm, if f, g,… denote function symbols, then we assume they do not have any particular property (associativity, commutativity, etc.).

equ122_04.gif

These trees can be made identical as follows:

equ122_05.gif

equ123_01.gif

These trees cannot be made identical: we would need to assign ya and yb.

equ123_02.gif

These trees can be made identical by assigning:

equ123_03.gif

Trying to unify the following trees:

equ123_04.gif

poses a problem. Which one?

4.1.2. A classification of trees

Finite trees

EXAMPLE 4.1.–

equ123_05.gif

Rational infinite trees (i.e. with a finite number of subtrees)

EXAMPLE 4.2.–

equ124_01.gif

i.e.:

equ124_02.gif

with a linear notation: f (a, f (a, f (a, …

Non-rational infinite trees

EXAMPLE 4.3.–

equ124_03.gif

with a linear notation: f (a, f (g(a), f(g(g(a))), f(…

In the next section, we will formalize the concepts that have been introduced in an intuitive way.

4.2. First-order terms, substitutions, unification

Let:

v.gif denote a set of variable symbols;

v.gif= {x1, x2,…};

f.gif denote a set of function symbols, containing constants in particular, which are denoted by c.gif, c.gif u.gif f.gif.

An arity (ni ≥ 0; i ≥ 1) is associated with every function symbol (representing the number of its arguments). Constants are of arity 0.

equ125_01.gif

DEFINITION 4.1.– (terms). The set of terms constructed on ie125_01.gif, denoted by ie125_02.gif, is the smallest set such that:

1) if ie125_03.gif, then ie125_04.gif;

2) if ie125_05.gif, then a ie125_06.gif;

3) if ie125_07.gif and t1, …, ie125_08.gif, then ie125_09.gif.

(Note that rule (2) is included in rule (3). It was added here for the sake of clarity).

Terms without any variable (i.e. ie125_10.gif) are called closed terms.

REMARK 4.1.– Infinite trees are not terms.

Unless stated otherwise, we shall note variables u, v, x … and constants a, b, c,…

DEFINITION 4.2.– (variables, constants, depth of a term).

– The set of variables in a term t, denoted by V ar(t) or V (t):

equ125_02.gif

The set of constants in a term t, denoted by Const(t):

equ125_03.gif

– The depth of a term t, denoted by Dpth(t):

equ126_01.gif

It was also possible to choose Dpth (t) = 0 in the first two cases.

DEFINITION 4.3.– (substitution).

– A substitution is an application:

equ126_02.gif

which is the identity on all but a finite number of variables.

The domain of a substitution σ is the set:

equ126_03.gif

and the codomain (or range) of a substitution σ is the set:

equ126_04.gif

Substitutions are represented by the values of the variables in their domain:

equ126_05.gif

or:

equ126_06.gif

A substitution

equ126_07.gif

is closed.

Given a substitution

equ126_08.gif

σ is extended:

equ126_09.gif

as follows:

equ127_01.gif

(It is standard to also denote the extension of σ by σ).

Equality is generally used in the sense of the identity, this is the case, for example, in:

(a + b)2 = a2 + 2ab + b2 (the identity holds for any value of a and b), or it is used conditionally, this is the case for example in:

4 × x =16 × y, where only some values (possibly none at all) satisfy the equality.

Furthermore, when there are many solutions, some are more interesting than the others. For example, if we are interested in the solutions of the equation above that are positive integers, then {x = 4, y = 1}, {x = 8, y = 2}, {x = 12, y = 3}, … are solutions.

The most general solution is {x = × y; rev ieq.

Notation: to emphasize that this is a conditional equality, we shall write ie127_01.gif, and if terms are involved, we shall write ie127_02.gif.

These comments are a motivation for the following definitions.

DEFINITION 4.4.– (ordering on substitutions). A substitution a is more general than a substitution γ iff there exists a substitution λ such that ie127_03.gif, where o denotes the composition of substitutions (i.e. of functions).

DEFINITION 4.5.– (unification). Given the equation ie127_04.gif, where ie127_05.gif, the unification problem consists of finding the most general unifier (mgu) such that:

σ(t1) = σ(t2) (syntactic identity).

If only one term contains variables, (say t1), the problem that consists of finding a σ such that

equ127_02.gif

is the matching problem.

Figure 4.1. The algorithm UNIFICATION

Figure 4.1

Notation: we often denote by mgu(t1, t2) the mgu of t1 and t2, and we write σt instead of σ(t).

The unification algorithm either constructs the mgu of a set of term equations or detects that there is no solution.

EXERCISE 4.1.–

a) Find the solution (if it exists) of equation:

equ128_01.gif

b) Find the solution (if it exists) of equation:

equ128_02.gif

c) Given the substitutions

ie129_01.gif and

equ129_01

Construct the substitution ie129_02.gif.

d) Consider the equation ie129_03.gif where ie129_04.gif

Is the cycle rule of UNIFICATION still necessary? Could you give a sufficient condition guaranteeing the cycle rule is not needed?

EXERCISE 4.2.– In a calculus called the equivalential calculus, the wffs of the language are of the form e(X, Y), where e is a constant symbol (that stands for equivalent), and X, Y (meta)variables that denote wffs of the language (such as A, B, C in S1; see section 3.4).

The only inference rule is:

equ129_02.gif

Question:

Given two wffs

e(X, e(X, e(Y, Y))) and

e(Z, Z)

1) Can CD be applied?

2) If so, what are the possibilities?

3) If CD can be applied, what is(are) the direct consequence(s)?

EXERCISE 4.3.– The algorithm Unification does not assume any property on the functions under consideration, and produce a unique result (substitution), up to a renaming of the variables.

If we assume that (some of) the binary functions under consideration are commutative, for example:

equ129_03.gif

Can you modify the algorithm Unification to take this property into account?

For example, for equation:

equ130_01.gif

UNIFICATION would return ⊥, but once modified, when f and g are commutative, it should produce two solutions:

equ130_02.gif

REMARK 4.2.- Considering function symbols that denote functions with certain properties can turn out to be very complex. For example, if f denotes an operation (function) that is associative-commutative, i.e.

equ130_03.gif

then the equation

equ130_04.gif

has the following solutions:

ie130_01.gif and others.

It is simple to verify that we cannot transform one of these unifiers into another by applying a substitution (as previously). We will keep in mind that the solutions are no longer unique (and there can be many of them).

The following exercise is an example of how the unification algorithm can be adapted to treat data other than terms, by expressing this data as terms and using some ad hoc conventions.

EXERCISE 4.4.- Use the algorithm unification (that was modified in exercise 4.3) to show that, if the unconditional premises (i.e. those that do not contain ieq) are literals, then the rules MP (modusponens) and MT (modus tollens):

equ130_05.gif

are particular cases of the resolution rule:

equ130_06.gif

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.110.155