• Keine Ergebnisse gefunden

A practical view on substitutions

N/A
N/A
Protected

Academic year: 2022

Aktie "A practical view on substitutions"

Copied!
15
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

deposit_hagen

Publikationsserver der Universitätsbibliothek

A practical view on substitutions

Mathematik und

Informatik

Informatik-Berichte 372 – 07/2016

Marija Kulaš

(2)

INFORMATIK

BERICHTE

372 – 07/2016

A practical view on substitutions

Marija Kulaš

Fakultät für Mathematik und Informatik

D-58084 Hagen

(3)

A practical view on substitutions

Marija Kulaˇs

FernUniversit¨at in Hagen, Wissensbasierte Systeme, 58084 Hagen, Germany marija.kulas@fernuni-hagen.de

Abstract

For logic program analysis or formal semantics, the issue of re- naming terms and generally handling substitutions is inevitable.

We revisit substitutions from a practitioner’s point of view, pre- senting concepts we found useful in dealing with operational se- mantics of pure Prolog. A concept ofrelaxed core representationis introduced, upon which a concept ofprenamingis built. Prenam- ing formalizes the intuitive practice of renaming terms and allows for extensibility. A novel algorithm forterm matchingis proposed, which also solves the problem ofsubstitution generality(and thus equivalence), usingwitness termtechnique. The technique aleviates the problem of ad-hoc proofs involving generality.

Categories and Subject Descriptors F.4.1 [Logic and constraint programming]

Keywords substitution, renaming, term matching, generality

1. Introduction

The image of substitutions in logic programming research is a somewhat tainted one. First, it has been pointed out by H.-P. Ko (Shepherdson 1994, p. 148) that the original claim of strong com- pleteness of SLD-resolution needs to be rectified, because of a counter-example using the fact that x

f(y,z)

is not more general than x

f(a,a)

, which admittedly does look rather counter-intuitive, but complies with the definition of substitution generality (Ex- ample 6.10). Second, by composing substitutions, properties like equivalence (Remark 6.13), idempotency (Remark 6.24), or restric- tion (Remark 6.28) are not preserved. Third, due to group structure of renamings, permuting any number of variables amounts to ”do- ing nothing”, as in

x y y x

∼ε(Example 6.12). Such equivalences are also felt to be counter-intuitive. Hence the prevalent sentiments that substitutions are ”quite hard matter to deal with” (Palamidessi 1990) or ”very tricky” (Shepherdson 1994). In an effort to avoid substitutions as much as possible,resultants were proposed (Lloyd and Shepherdson 1991). Still, for almost anyone embarking on a journey of logic program analysis or formal semantics, sooner or later the need for renaming terms and generally handling substitu- tions arises.

In the case of this author, the need arose while trying to prove completeness of an operational semantics for pure Prolog, S1:PP

[Copyright notice will appear here once ’preprint’ option is removed.]

(Kulaˇs 2005), and facing the followingextensibility problem. Start- ing from a pair of variant queries, their respective formal deriva- tions proceed to develop. At each step, new variables may crop up, but the status of being variant should be maintained. This setup is known from the classicalvariant lemma(Legacy 7.3). A new as- pect here is that we need tocollectthe variables, obtaining at each step the temporary variance between the derivations.

How to model this process of accumulating new variables and their correspondence between derivations? Surely by renamings?

Assume the first query isp(z, u)and the secondp(y, z). There is only one relevant renaming,ρ=

z y u z y u

. Now assume in the next step the first derivation acquires the variabley, and the secondx.

The relevant renaming this time would beρ0=

z y u z y x x u

. Clearly, ρ0is not an extension ofρ, which makes it seem unsafe to proceed:

are some properties of the previous step now in danger?

For this reason, in Section 5 we introduce a slight generaliza- tion of renaming, calledprenaming, which can handle extensibility (Theorem 5.17). As a bonus, it is a mathematical underpinning of the intuitive practice of ”renaming” terms by just considering the necessary bindings, and not worrying whether the result is a per- mutation. In the above example that would bez7→y, u7→z. Pre- naming provides finer control of term variance, owing torelaxed core representation, which is nothing else than allowing somex/x pairs alongside ”real” bindings, as placeholders. Prenamings relate to and are inspired by previous work as follows: Asafeprenam- ing is more general thanrenaming for a termfrom (Lloyd 1987), and it maximizesWin the notion ofW-renamingfrom (Eder 1985) (subsection 5.2). Also, prenamings can generalizesubstitution re- namingfrom (Amato and Scozzari 2009).

In Section 7, an application on a nontrivial example is shown (Lemma 7.1), where a propagation claim for logic programming systems has been proved, in a constructive way. As a corollary, a variant lemma (Theorem 7.4) for Prolog is obtained. Underway, we touch on the discrepancy between the rather abundant theory of logic programming and a scarcity of mathematical claims for implemented logic programming systems. While there are some formal proofs of properties like nominal unification (Urban et al.

2004), for logic programming systems or their compilation such are still few and far between, a notable exception being (Pusch 1996).

New concepts like prenaming may help with this. In subsection 7.1 we discuss the question of renaming-compatibility and resolution- compatibility of unification for logic programming systems. Such properties are important for formalizing operational behaviour of Prolog in a compositional way.

In Section 6, we discuss some other notions about substitutions that were needed in the course of work on operational semantics.

A novel algorithm forterm matching, also rooted in the relaxed core idea, is proposed (Algorithm 6.1). It solves the problem of substitution generality(and thus equivalence) as well, usingwitness term(Theorem 6.8). Witness term technique was also used for a direct proof of Legacy 6.27.

(4)

2. Substitution

First we need a bit of notation. Assume two disjoint sets: the set of functors,Fun, and the countably infinite set ofvariables,V.

If W ⊆ V, any mapping F with F(W) ⊆ Vshall be called variable-pure onW. A mapping variable-pure on the whole set of variablesVshall be calledall-varsmapping. IfV\Wis finite,W is said to beco-finite. A mappingFisinjective onW, if whenever F(x) =F(y)forx, y∈Wwe havex=y.

Associated with every functorf shall be a natural numbern denoting its number of arguments,arity. To emphasize this, the notationf/nwill be used. Functors of arity0are calledconstants.

Starting fromVandFunwe build data objects,terms. In Prolog, everything is a term, and so shalltermbe here the topmost syntactic concept. Any variable x ∈ Vis a term. If t1, ..., tn are terms andf/n ∈ Fun, thenf(t1, ..., tn)is atermwithshapef/nand constructorf. In case of f/0, the term shall be written without parentheses. If a termsoccurs within a termt, we writes∈t.

A special kind of term isdotted pair, introduced under the name S-expressionin (McCarthy 1960) and written1ash·t, wherehis called theheadandtis called thetailof the pair. A special dotted pair isnon-empty list, distinguished by its tail being a special term nilcalledempty list, or a non-empty list itself. In Edinburgh Prolog notation, dotted pair would be written[h|t]and empty list as [].

Alist of nelements is the term[t1|[t2|[...[tn|[]]]]], conveniently written as[t1,...,tn].

LetVars(t)be the set of variables in the termt. A term without variables is called a ground term. If the terms s and tshare a variable, that shall be writtens ./ t. Otherwise, we say s, tare variable-disjunct, written ass6./ t. The list of all variables oft, in order of appearance, shall be denoted asVarList(t).

A recurrent theme in this paper shall be relevance, meaning

”no extraneous variables” (relative to some term or terms). The name appears in (Apt 1997, p.˙38), with the unary meaning, i. e.

no extraneous variables relative to (one) term. This usage shall be reflected in the text as follows.

A unifierσof a set of equationsE(Definition 6.14, Legacy 6.27) is arelevant unifier, ifVars(σ) ⊆ Vars(E). A renamingρ embedding a prenamingα(Algorithm 5.1) is arelevantembed- ding, ifVars(ρ)⊆Vars(α).

Additionally, a binary version of relevance, handling two terms, shall also be needed (Algorithm 5.2, Lemma 7.1):

A mappingFisrelevant fort1tot2, ifDom(F)⊆Vars(t1) andRange(F)⊆Vars(t2).

Definition 2.1(substitution). Asubstitutionθis a function map- ping variables to terms, which is identity almost everywhere. In other words, a functionθwith domainDom(θ) =Vsuch that the following requirement holds:

finite action2 The set{x∈V|θ(x)6=x}is finite.

The setCore(θ)··={x∈V|θ(x)6=x}shall be called theactive domain3 orcoreofθ, and its elementsactive variables4ofθ. The setRan(θ)··=θ(Core(θ))is called theactive rangeofθ. The set VarsRan(θ) ··= Vars(θ(Core(θ)))is called theactive variable

1In Definition 2.1, we shall overload the dot operator with composing substitutions, in addition to its rˆole as pair constructor.

2(Gallier 1986) uses the namefinite support.

3Literature traditionally uses the namedomain. However, in the usual mathematical sense it is always the wholeVwhich is the domain of any substitution. It may be less confusing to have boththe domain, which is uniformlyV, andthe coreoractive domain, making it clear that, while every variable can be mapped, onlyactive variablesare of interest.

4The nameactive variableappears in (Jacobs and Langen 1992).

rangeofθ. For completeness, a variablexsuch thatθ(x) =xshall be called apassive variable, or afixpoint, forθ. Also, we say that θisactiveon the variables fromCore(θ), andpassiveon all the other variables.

IfCore(θ) = {x1, ..., xk}, wherex1, ..., xkare pairwise dis- tinct variables, andθ maps each xi to ti, thenθ shall have the core representation{x1/t1, ..., xk/tk}, or the perhaps more visual x

1 t1

...

...

xk tk

. Hence, the above requirement shall also be calledfi- nite core. Each pairxi/tiis called thebindingforxiviaθ, denoted byxi/ti∈θ.

Often we identify a substitution with its core representation, and thus regard it as a syntactical object, a term. So the set of variables of a substitution is defined asVars(θ)··=Core(θ)∪VarsRan(θ).

The notions of restriction and extension of a mapping shall also be transported to core representation: if θ ⊆ σ, we say θ is a restrictionofσ, andσis anextensionofθ. TherestrictionθW

of a substitutionθ on a set of variablesW ⊆ Vis defined as follows: ifx∈WthenθW(x)··=θ(x), otherwiseθW(x)··=x.

The restriction of a substitutionθupon the variables of the term tshall be abbreviated asθt ··= θVars(t). We also writeθ−t to denote the restriction ofθto variables outside oft, likeθ−t ··= θCore(θ)\Vars(t).

Definition of substitution is extended from variables to arbi- trary terms in a structure-preserving way byθ(f(t1, ..., tn)) ··= f(θ(t1), ..., θ(tn)). Ifsis a term,θ(s)is aninstanceofsviaθ.

Thecompositionθ·σof substitutionsθ and σis defined by (θ·σ)(t) ··= θ(σ(t)). Composition may be iterated, written as σn ··= σ·σn−1 forn ≥ 1, andσ0 ··= ε. Hereε ··= ()is the identity function onV. In case an all-vars substitutionρis bijective, its inverse shall be denoted asρ−1. A substitutionθsatisfying the equalityθ·θ=θis calledidempotent.

Example 2.2. xuwvuxwv

·u

x v w x y y u z v w

z

=6u

6u 6v 6v x y y x z w

w z 6x 6u 6w 6v 6u 6x 6v 6w

= x

y y x z w

w z

.

3. Renaming

Definition 3.1(renaming). Arenamingof variables is a bijective all-vars substitution.

In (Eder 1985), it is synonymously called ”permutation”. We shall reserve the word for the general case where infinite move- ments like translation are possible. Here we shall synonymously speak offinite permutationdue to the fact that, being a substitu- tion, any renaming has a finite core, and Legacy 3.4 holds.

From the definition of substitution, we know: if s ∈ t, then σ(s) ∈ σ(t). For bijective substitutions (i. e. renamings), a com- plementary property holds as well:

Lemma 3.2(renaming stability of not-in). Letρbe a renaming ands, tbe terms. Ifs6∈t, thenρ(s)6∈ρ(t).

Proof.Assumeρ(s)∈ρ(t). Thenρ−1(ρ(s))∈ρ−1(ρ(t)). ♦ Corollary 3.3(renaming stability of ”=”, ”∈”, ”./”).6 Letρbe a renaming ands, tbe terms. Thens=t iff ρ(s) =ρ(t), and also s∈t iff ρ(s)∈ρ(t). As a consequence,s6./ t iff ρ(s)./ ρ(t).6 Legacy 3.4((Lassez et al. 1988)). A substitutionρis a renaming iffρ(Core(ρ)) =Core(ρ).

Legacy 3.5((Eder 1985)). Every injective all-vars substitution is a renaming.

So composition of renamings is a renaming. The next property is about cycle decomposition of a finite permutation.

(5)

Lemma 3.6(cycles). Letσbe an all-vars substitution. It is injec- tive iff for everyx∈V, there isn∈Nsuch thatσn(x) =x.

Proof. Assumeσinjective, and choosex0 ∈ V. Ifσ(x0) = x0, we are done. Otherwise,σi(x0)6=σi−1(x0)for alli≥1, due to injectivity. Hence,σi−1(x0)∈Core(σ)for everyi≥1. Because of the finiteness of Core(σ), there is m > k ≥ 1 such that σm(x0) = σk(x0). Due to injectivity,σm−1(x0) = σk−1(x0).

By iteration we getn··=m−k.

For the other direction, assumeσ(x) =σ(y), and minimalm, n such thatσn(x) = x, σm(y) = y. Consider the casem 6= n, saym > n. Thenσm−n(y) = σm−n(x) = σm−nn(x)) = σm−nn(y)) = σm(y) = y, contradicting minimality ofm.

Hencem=n, and sox=σn(x) =σn(y) =y. ♦

4. Relaxed core representation

In Lemma 7.1, we shall have to deal with mappings of variables between two terms. There, it is possible that a variable stays the same, so(x, x)would have to be tolerated as a ”binding”, since we need our mapping to coverallvariables in the two terms. Therefore, we allow the setCto contain some passive variables, raising those above the rest, as it were.

Definition 4.1(relaxed core). IfCore(σ)⊆ {x1, ..., xn}, where variablesx1, ..., xnare pairwise distinct, then{x1, ..., xn}shall be called arelaxed coreand x

1 σ(x1)

...

...

xn σ(xn)

shall be called arelaxed core representationforσ.

If we fix a relaxed core forσ, it shall be denotedC(σ) ··= {x1, ..., xn}. The associated rangeσ(C(σ))we denote asR(σ).

The set of variables ofσis as expected,V(σ) ··=Vars(C(σ))∪ Vars(R(σ)). To get back to the traditional core representation, we denote by[σ]the core representation ofσ.

For extending substitution, we shall employ disjoint union.

Definition 4.2(sum of substitutions). Ifσ=

x1 s1

...

...

xm sm

andθ= y1

t1 ...

...

yn tn

are substitutions in relaxed representation such that {y1, ..., yn} 6./{x1, ..., xm}, thenσ]θ ··=

x1 s1

...

...

xm sm

y1 t1

...

...

yn tn

is thesumofσandθ.

In case{y1, ..., yn}./{x1, ..., xm}but withσ(xi) =θ(yj)on any common variablesxi=yj, we shall simply writeσ∪θ. Also, we shall not be introducing special symbols to denote thatσis an extension ofθ, but simply writeσ⊇θ.

In subsection 7.2, we shall need backward compatibility of an extension. A first stab might be:

Lemma 4.3. If β(t) =t, then(α]β)(t) =α(t).

Proof. For anyx∈Vars(t)∩C(α)by definition(α]β)(x) = α(x). Assume now x ∈ Vars(t)∩C(β). From the condition, β(x) =x, and by definition of extension,x6∈C(α), hence(α] β)(x) =β(x) =x=α(x). Clearly, ifx∈Vars(t)\C(α]β)

the claim also holds. ♦

As an immediate consequence, if a substitutionσiscomplete for a termt, there is no danger that an extension ofσmight mapt differently fromσ.

Definition 4.4(complete for term). Letσbe given in relaxed core representation. We say thatσiscompletefortifVars(t)⊆C(σ).

Corollary 4.5(backward compatibility). Ifσ is complete fort, then for anyθholds(σ]θ)(t) =σ(t).

5. Prenaming

In practice, one would like to change the variables in a term, without bothering to check whether this change is a permutation or not. For example, the termp(z, u, x)can be mapped onp(y, z, x) viaz7→y, u7→z, x7→x.

Let us call such a mappingprenaming5. Like any substitution, a prenamingαshall also be represented finitely, but in relaxed core representation, in order to capture possiblex 7→ xpairings. The setC(α) is fixed by the terms to map. Obviously, injectivity is important for such a mapping, sincep(z, u, x)cannot be mapped onp(y, y, x)without losing a variable. Hence,

Definition 5.1(prenaming). Aprenamingαis an all-vars substi- tution injective on a finite set of variablesC(α)⊇Core(α).

Obviously, any renaming is a prenaming. For Theorem 7.4, we need a possibility to extend a given prenaming by new bindings.

Lemma 5.2 (extension of prenaming). Let α =

x1 y1

...

...

xn yn

andβ =

u1 v1

...

...

uk vk

be prenamings such that{u1, ..., uk} 6./

{x1, ..., xn} and {v1, ..., vk} 6./ {y1, ..., yn}. Then α] β = x1

y1 ...

...

xn yn

u1 v1

...

...

uk vk

is also a prenaming.

Clearly,C(α]β) =C(α)]C(β)andR(α]β) =R(α)] R(β).

5.1 The question of inverse

In practice, a prenaming is more natural, but a ”full” renaming is better mathematically tractable (inverse exists). Hence we want to know whether each prenaming can be embedded in a renaming.

The next property shows how to extend a prenamingαto obtain a renaming, and a relevant one at that, i. e. acting only on the variables fromV(α). The claim is essentially given in (Lloyd and Shepherdson 1991), (Apt 1997) and (Amato and Scozzari 2009) with the emphasis on the existence6of such an extension. In (Eder 1985), the emphasis is on the actual reach7 of the extension. The latter is our concern as well. We formulate the claim around the notion of prenaming, and provide a constructive proof based on Lemma 3.6.

Theorem 5.3(embedding). Letαbe a prenaming. Then there is a renamingρwhich coincides withαonV\(R(α)\C(α))such that Vars(ρ)⊆V(α).

Additionally, ifα(x)6=xonC(α), thenρ(x)6=xonV(α).

Proof.Ifα is a prenaming, thenC(α) =·· C and R(α) =·· R are sets ofndistinct variables each. We shall construct the wanted renaming in Algorithm 5.1, where it is namedα. The idea is to close any open chainsα(x), α2(x), ....

α(x)··=

α(x), ifxC

z, ifxR\Candαm(z) =xfor maximalmn x, outside ofCR

Algorithm 5.1: Closure, the natural relevant embedding

5Finding an appropriate name can be a struggle. Shortlisted were pre- renamingandproto-renaming.

6(Apt 1997, p. 23): ”Every finite 1-1 mappingf fromAontoBcan be extended to a permutationgofAB. Moreover, iffhas no fixpoints, then it can be extended to agwith no fixpoints.”

7(Eder 1985, p. 35): ”Let W be a co-finite set of variables (...) and letσbe a W-renaming. Then there is a permutationπwhich coincides withσon the set W.”

(6)

Let us see if for everyxthere is a j such thatαj(x) = x.

Ifx ∈ C, we start as in the proof of Lemma 3.6, and consider the sequenceα(x), α2(x), .... SinceCis finite, either we get two equals (and proceed as there), or we getαk(x)6∈Cand are stuck.

Fory ··=αk(x)we knowα(y) =z such thatαm(z) = ywith maximalm, som≥k. Therefore,αm(α(y)) =y=αk(x). Due to injectivity ofαon C(α)we getαm−k(α(αk(x))) = x, and henceαm+1(x) =x.

The casesx∈R\Corx6∈C∪Rare easy. By Lemma 3.6,α is injective. By Legacy 3.5,αis a renaming. The discussion of the caseα(x)6=xonC(α)is straightforward. ♦ Definition 5.4 (closure of a prenaming). The renaming α con- structed in Algorithm 5.1 shall be called theclosureofα.

Remark5.5 (relevant embedding is not unique). Letα=

z y u z y x

w1 w2

, and let us embed it in a relevant renaming. The Algorithm 5.1 givesα =

z y u z y x

w1 w2 x u

w2 w1

. Butρ =

z y u z y x

w1 w2

x w1

w2 u

is also a relevant renaming which is embedding α. In the usual nota- tion for cycle decomposition, ρ = {(x, w1, w2, u, z, y)} and α={(x, u, z, y),(w1, w2)}.

If we reverse the prenaming, the closure algorithm shall be closing the same open chains but in the opposite direction, hence Lemma 5.6(reverse prenaming). Letα··=x

1 y1

...

...

xn yn

andβ··= y

1 x1

...

...

yn xn

. Thenβ=α−1.

Remark5.7 (closure is not compositional). Takeα ··= z

y u z y x

andρ··=x

y y x

. Thenα=z

y u z y x x u

, ρ·α= zxuzxu

, ρ·α= z

x u z x y

andρ·α=z

x u z x y y u

.

Remark5.8 (closure is not monotone). Ifα⊇α0, then not always α ⊇ α0. To see this, letα =

z y u z y x

andα0 =

z y u z

. Then α0=

z y u z y u

andα=

z y u z y x x u

. 5.2 Staying safe

Let us look more closely into Remark 5.8:α(y) =xandα(x) = x, soyandxmay not simultaneously occur in the candidate term.

Otherwise, a variable shall be lost, which we callaliasing, like in

y x

(p(x, f(y))) =p(x, f(x)).

Definition 5.9(aliasing). Letαbe a prenaming. Ifx 6= y but α(x) =α(y), then we sayαisaliasingxandy.

So what Remark 5.8 means is: if we want to useαon a larger set thanC(α), then the setPit(α)··=R(α)\C(α)is dangerous to touch. But, luckily, its complement is not:

Lemma 5.10(larger set). A prenamingαis injective on the co- finite setV\Pit(α). The set is maximal containingC(α).

Proof. Letx, y ∈ V\Pit(α). Is it possible thatα(x) = α(y)?

Possible cases: Ifx, y ∈ C(α), then by definition of prenaming α(x) 6= α(y). Ifx, y 6∈ C(α), thenα(x) = x 6= y = α(y).

It remains to consider the mixed casex∈ C(α), y 6∈ C(α). We haveα(x)∈R(α)andα(y) =y. So isα(x) =ypossible? If yes, theny∈R(α), but sincey6∈C(α), that would meany∈Pit(α).

Contradiction.

The set cannot be made larger: ify ∈ Pit(α), then there is x ∈ C(α)withx 6=yandα(x) = y = α(y), so injectivity is

compromised. ♦

Definition 5.11 (injectivity domain). For a prenaming α, let InDom(α) ··= V\Pit(α). SinceInDom(α)is the largest co- finite set containingC(α)on whichαis injective, it shall be called theinjectivity domainofα.

The injectivity domain of a prenaming is clearly the only safe place for it to be mapping terms from. Hence,

Definition 5.12(safety of prenaming). A prenamingsafe8 for a termtis a prenamingαwithVars(t)⊆InDom(α).

Clearly,InDom(α) = C(α)∪(V\R(α)), soαis safe for its relaxed core. Hence, ifαis complete for a term, it is safe for that term. For a prenamingαwith the qualityR(α) =C(α), i. e.

a renaming, it is no surprise thatInDom(α) =Vand hence safety is guaranteed for any term.

A prenaming behaves like a renaming on its injectivity domain, since it coincides with its closure there. This follows immediately from Theorem 5.3:

Corollary 5.13(injectivity domain). Letx∈InDom(α). Then α(x) =α(x).

Corollary 5.14(prenaming stability). A generalization of Corol- lary 3.3 holds: Lets, tbe terms andαbe a prenaming safe fors, t.

Thens =tiffα(s) =α(t)and alsos ∈tiffα(s)∈α(t). As a consequence,s6./ tiffα(s)6./ α(t).

Our definition of prenaming was inspired by the following more general notion from (Eder 1985).

Definition 5.15(W-renaming). LetW ⊆V. A substitutionσis a W-renamingifσis variable-pure onW, andσis injective onW.

With this notion, Lemma 5.10 can be summarized as:InDom(α) is a co-finite set of variables, and the largest setW ⊇C(α)such thatαis a W-renaming.

What about safety of extension? Ifαis safe fort,α]βdoes not have to be, even ifβ(t) =t, as the following example shows:

α··= wv

, β··=

z y u z y x

, t··=p(x). The following two claims try to redress that isssue.

Lemma 5.16(monotonicity). Assumeα]βis defined. Then 1.InDom(α)∪InDom(β) =V

2.InDom(α)∩InDom(β)⊆InDom(α]β)

Proof.Since(V\A)∪(V\B) =V\(A∩B)), andPit(α)6./

Pit(β), we obtainInDom(α)∪InDom(β) =V.

Further,(V\A)∩(V\B) =V\(A∪B)and soPit(α]β) = (R(α)]R(β))\(C(α)]C(β))⊆(R(α)\C(α))∪(R(β)\

C(β)) =Pit(α)∪Pit(β). ♦

In Remark 5.8, Pit(α0) = {y}, Pit( yx

) = {x}, and Pit(α) ={x}, henceInDom(α0) =V\ {y},InDom( yx

) = V\ {x}andInDom(α) =V\ {x}.

By the last claim, staying withinInDom(α) andInDom(β) ensures staying withinInDom(α]β). By assuming a bit more aboutαthan just safety, we may ignore the nature of extensionβ, and still ensure safety and even backward compatibility ofα]β.

This shall be used in Section 7.

Theorem 5.17(extensibility). Assumeα]βis defined.

1. Ifαis safe fort and βis safe fort, thenα]βis safe fort.

8Our definition of safe prenaming is more general than the definition ofrenaming for a termin (Lloyd 1987, p. 22), since we do not require Core(α)Vars(t).

(7)

2. Ifαis complete fort, thenα]βis safe fortand(α]β)(t) = α(t).

The first part follows from Lemma 5.16 and the second from Corol- lary 4.5. Observe the importance ofrelaxed corefor this to work:

otherwise, passive bindingsx/xwould not be accounted for.

5.3 Variant of term and substitution

The traditional notion of term variance, which is term renaming, shall be generalized to prenaming. As a special case, substitution variance is defined, inspired by substitution renaming from (Am- ato and Scozzari 2009). For this, substitution shall be regarded as a special case of term. The term is of course the relaxed core repre- sentation. This concept shall come in handy for proving properties of renamed derivations, as in subsection 7.2.

5.3.1 Term variant

Definition 5.18(term variant). Ifαis a prenaming safe fort, then we also callα(t)avariantoft, and writeα(t)∼=t. The particular variance and the direction of its application may be explicated:

s=αtiffs=α(t).

Ifs∼=t, then there is a uniqueαmappingstotin a complete and relevant9manner, i. e. mapping each variable pair and nothing else, as computed by Algorithm 5.2. The algorithm makes do with only one set for equations and bindings, thanks to different types.

Termination can be seen from the tuple (lfun=(E),card=(E)) decreasing in lexicographic order with each rule application, where lfun=(E)is the number of function symbols in equations inE, and card=(E)is the number of equations inE.

Start from the setE··={s=t}and transform according to the following rules. The transformation is bound to stop. If the stop was not due to failure, then the current setEisPren(s, t).

eliminationE] {x=y} E,ifx/yE

failure: aliasE ] {x = y} failure, if(x/z E, z 6=

y)or(z/yE, z6=x)

binding E]{x=y} E∪{x/y},if(x/ 6∈E)and(/y6∈

E)

failure: instance E] {x=t} failure, ift6∈V;

E] {t=x} failure, ift6∈V

decompositionE] {f(s1, ..., sn) = f(t1, ..., tn)} E {s1=t1, ..., sn=tn}

failure: clashE ] {f(s1, ..., sn) = g(t1, ..., tm)}

failure, iff6=gorm6=n

Algorithm 5.2: Computing the prenaming ofstot Notation 5.19 (epsoid). The prenaming constructed in Algo- rithm 5.2 shall be simply calledthe prenaming ofstot, and denoted Pren(s, t). It is complete forsand relevant forstot.

In cases=t, we obtain forPren(s, t)essentially the identity substitution. However, regarded as prenamings,Pren(t, t)andε are not the same. A prenamingαwith relaxed coreW mapping each variable on itself (in other words,C(α) = W andα = ε) shall be called theW-epsoidand denotedεW. For a term t, we abbreviateεt··=εVars(t).

Regarding composition, an epsoid behaves just likeε. Its use is for providing completeness, and hence extensibility, by means of placeholding pairsx/x.

9for prenaming, we naturally useCforDomandRforRange.

5.3.2 Special case: substitution variant

Even substitutions themselves can be renamed. To rename a sub- stitution, one regards it as a syntactical object, a set of bindings, and renames those bindings. Ifρ is a renaming andσ is a sub- stitution, (Amato and Scozzari 2009) define substitution renaming byρ(σ) ··= {ρ(x)/ρ(σ(x))| x ∈ Core(σ)}. It is easy to see thatρ(σ)is a substitution in core representation. For this we only need two properties ofρ: variable-pure onVars(σ)and injective onVars(σ). These requirements are clearly fulfilled by prenam- ings safe onσas well. Hence,

Definition 5.20(substitution variant). Letσbe a substitution and letαbe a prenaming safe forσ, i. e.Vars(σ)⊆InDom(α). Then avariant ofσbyαis

α(σ)··={α(x)/α(σ(x))|x∈Core(σ)} (1) We may writeθ =α σifθ =α(σ), as with any other terms.

As can be expected, the concept of variance by prenaming is well- defined, owing to safety. Otherwise, the result of prenaming would not even have to be a substitution again, as withα= yx

, σ =

x a y b

.

Lemma 5.21(well-defined). Substitution variant is well-defined, i. e.(1)is a core representation of a substitution, andαdoes not introduce aliasing.

Proof.LetCore(σ) = {x1, ..., xn}. Due to injectivity ofαon Vars(σ), ifα(xi) = α(xj), thenxi = xj, soi = j. To finish the proof that (1) a core representation, observex∈ Core(σ)iff x6=σ(x)iffα(x)6=α(σ(x)), due to injectivity again.

Next, by Corollary 5.14, if α(σ(xi)) ./ α(σ(xj)), then σ(xi)./ σ(xj), meaning thatαdoes not introduce aliasing. ♦

From Definition 5.20 and Corollary 5.13 follows

Lemma 5.22. Letσbe a substitution andα, βbe prenamings such thatα(σ)and(α·β)(σ)are defined. Then

1.(α·β)(σ) =α(β(σ)) 2.α(σ) =α(σ)

For the case of ”full” renaming, there is a way to dissolve the new expression:10

Legacy 5.23((Amato and Scozzari 2009)). For any renamingρ and substitutionσ

ρ(σ) =ρ·σ·ρ−1

Would such a claim hold for the weakened case, prenamings?

Theorem 5.24(substitution variant). Letσbe a substitution andα be a prenaming safe forσ. Then

1.α(σ)·α=α·σ 2.α(σ) =α·σ·α−1

Proof.First part: According to Definition 5.20, for everyx ∈ V holds(α(σ)·α)(x) =α(σ(x)). Since any substitution is structure- preserving, the claim holds for any termtas well.

Second part: From the first part we knowα(σ)·α=α·σ, hence α(σ) =α·σ·α−1. By Corollary 5.13 holdsα(σ) =α(σ), which

completes the proof. ♦

It is known that idempotence and equivalence of substitutions are not compatible with composition (Eder 1985). Luckily, the concept of variance, with constant prenaming, does not share this handicap:

10An immediate consequence of which isρ(σ)6=ρ·σ.

(8)

Theorem 5.25(compositionality). Letσ, θbe substitutions andα be their safe prenaming. Then

α(σ·θ) =α(σ)·α(θ)

Proof. SinceVars(σ·θ)⊆Vars(σ)∪Vars(θ), clearlyVars(σ·θ)⊆ InDom(α). By Theorem 5.24α(σ)·α(θ) =α·σ·α−1·α·θ·α−1=

α·σ·θ·α−1=α(σ·θ). ♦

6. Further topics

Here is a brief overview of other substitution properties that we found useful for analysing the operational semantics S1:PP.

For some properties like Lemma 7.1 and Theorem 7.4 we need the concept of SLD-derivations. Regarding SLD-derivations, we shall for the most part assume traditional concepts as given in (Apt 1997), but with some changes and additions outlined below. The variable names in actual logic programs shall be capitalized, as in Prolog.

Notation6.1 (adapting SLD-derivation). Assume an SLD-derivation forGlikeG ,−.K1:σ1 G1,−.K2:σ2... ,−.Kn:σnGn.

Kiis here theactually usedvariant of a program clause (i. e., the currentinput clause) and not the program clause itself.

The substitutionσn·...·σ1shall be calledthe partial answer at stepnof the derivation.

Recall that a computed answer substitution (c.a.s.) forG is defined as(σn·...·σ1)G, wheneverGn=. For our purposes, the restriction on the variables ofGis not urgent. As an interim step, we define acomplete answer forGto be a final partial answer,σn·...·σ1. A c.a.s. is then a complete answer made relevant by restricting it to query variables.

An input clauseKiobtained from a program clauseK¯by replacing the variables in order of appearance withA1, ..., Anmay be de- noted asKi= ¯K[A1, ..., An]. We also say thatK¯isapplicableon Giwitheffector clauseKi, and thatKiiseffectiveonGiwithσi.

Showing the actually used variants of program clauses (in- stead of program clauses themselves) enables a simple definition of derivation variables.

Definition 6.2(variables of a derivation). AssumeDto be an SLD- derivationG ,−.K1:σ1 G1 ,−.K2:σ2 ... ,−.Kn:σn Gn. We shall define the set of variables ofDas would be natural for a term, i. e.

we regard the annotationsKiias part of the derivation. Hence, Vars(D) ··= (Vars(G)∪...∪Vars(Gn))∪(Vars(σ1)∪...∪ Vars(σn))∪(Vars(K1)∪...∪Vars(Kn)).

One last piece of introductory notation:Head((H ←B))··=H. 6.1 Term matching and subsumption

Considerf(x, y)andf(z, x). Intuitively, they ”match” each other, whilef(x)andg(x)do not. If asked aboutf(x, x)andf(x, y), we may consent that they ”match” only in one direction.

Definition 6.3(term matching). Letgandsbe two terms. If there is a substitutionσsuch thatσ(g) =s, then we saygmatchess, and also thatsis aninstance ofg(as already defined in Definition 2.1).

The substitutionσis then amatcherofgons.

Moreover, ifσ(g) =σ(s) =s, then we saygsubsumess. The substitutionσis then asubsumerofsbyg.

Example:f(x)matchesf(g(x)), but does not subsume it, while f(x, y)subsumesf(x, x). For relation to Prolog see (Neumerkel 2010).

Term matching can be seen as a special case of unification, where any variables on the right-hand side are inactivated by re- placing them with new constants (hence the synonym ”one-sided

unification”). For parallel approach, see e. g. (Dwork et al. 1984).

We propose a one-pass algorithm with a stress on simplicity, Algo- rithm 6.1. It decides generality and equivalence of substitutions as well.

6.1.1 Subterm

Definition 6.4(subterm, occurrence). A character subsequence of the termtwhich is itself a term,s, shall be called anoccurrence of subtermsoft, denoted non-deterministically bys∈ t. This may also be pictured ast= s .

Note that there may be several occurences of the same sub- term in a term. Unlike itsterm representation, theposition(Defini- tion 6.5) of an occurrence determines it uniquely. For disambigua- tion, then-th occurrence ofsintmay be denoted as(s∈t)n.

Terms have atree representationas follows. A variablexis rep- resented by the root labeledx. A termf(t1, ..., tn)is represented by the root labeledfand by trees fort1, ..., tnas subtrees, ordered from left to right. Thus, theroot labelfor a termtistitself, iftis a variable, otherwise the constructor oft.

Access pathshall be defined as a variation of (Apt 1997, p. 27), and used to definependants, which shall be needed for matching, and includedisagreement pairsfrom (Robinson 1965).

Definition 6.5(access path and position of subterm). Lettbe a term and consider an occurrence of its subterms, denoted ass∈t.

Theaccess pathofs ∈ tis defined as follows. Ifs = t, then AP(s∈t)is the root label fort. Ift=f(t1, ..., tn)ands ∈tk, thenAP(s∈t)··=f /k·AP(s∈tk).

By extracting the integers, we obtain thepositionofs∈t. By extracting the labels, save for the last one, we obtain theancestry ofs∈t. Ifs1 ∈t1has the same position and ancestry ass2∈t2, then we says1 ∈ t1 ands2 ∈ t2 are pendants int1 andt2. A disagreement pairbetweent1andt2is a pair of pendants therein differing in the last label.

For example, let t ··= [f(y), z] and s ··= z. There is only one ocurrence s ∈ t. According to list definition, [f(y), z] =

·(f(y),·(z,nil)). Hence,AP(s ∈ t) = (·)/2·(·)/1·z, so the position ofs ∈tis2·1and its ancestry is(·)·(·). An example of pendants:f(y)∈[f(y), z]andg(a, b)∈[g(a, b), h(x)]. This is also a disagreement pair.

6.1.2 A matching algorithm

Owing to the placeholding facility of relaxed core representation, the following algorithm is linear and rather succinct. In fact,with- outthe placeholding facility it would be difficult to capture the error in matchingf(x, x)onf(x, y)in just one pass along the terms and without auxiliary registers.

variableLetLbe a variable. IfL/S δandS 6= R, then stop withFAILURE(”divergence”). Otherwise, Match(L, R, δ)··=δL

R

.

failure: shrinkageIfLis a non-variable, butRis a variable, stop withFAILURE(”shrinkage”).

failure: clashIfLandRare non-variables of different shape, stop withFAILURE(”clash”).

decompositionLetL=f(s1, ..., sn)andR=f(t1, ..., tn).

If there areδ1 ··= Match(s1, t1, δ)and ... andδn ··= Match(sn, tn, δn−1), thenMatch(L, R, δ)··=δn.

Algorithm 6.1: One-pass term matchingMatch(L, R, δ)

(9)

Theorem 6.6 (matching). Algorithm 6.1 solves the problem of matchingL on R: IfMatch(L, R, ε) stops with failure, thenL does not matchR; otherwise, it stops with a substitutionδsuch that[δ]is a relevant matcher ofLonR. This follows from

1. IfMatch(L, R, δ)stops with failure, there is noµwithµ(L) = Randµ⊇δ.

2. IfMatch(L, R, δ) = δ0, then δ0(L) = R and δ0 ⊇ δ. In other words, Match(L, R, δ) is a matcher ofL on R con- tainingδ. Additionally,δ0 is complete forLandVars(δ0) ⊆ Vars((L, R, δ)).

Proof. This algorithm clearly always terminates. For theProof of 1, we need two observations, readily verified by structural induction:

IfµmapsLonR, then it maps anys∈Lon its pendantt∈R.

Each time the algorithm visits one of the cases, the registers L and R denote either the original terms, or some pendants therein.

Thus, in the two middle non-variable cases there can be no matcher for the original terms, notwithstandingδ.

In the variable case, the purported matcherµwould have to map one variable on two different terms (Figure 1).

x x −−−−−→? s r

Figure 1. Divergence: one variable, two terms

Proof of 2:By structural induction. In case of variable, the claim holds. Assume we have a case of decomposition and the claim holds for the argument terms, i. e.δ1(s1) =t1, δ1⊇δ, δ2(s2) = t2, δ2 ⊇ δ1, ..., δn(sn) = tn, δn ⊇ δn−1, and each δi

is complete for si as well as relevant. Due to completeness and Corollary 4.5, fromδn ⊇...⊇δ2 ⊇δ1followsδn(s1) = ...= δ2(s1) =t1and so forth. Hence,δn(L) =R. Clearly,δn⊇δand δnis complete forLand relevant. As a final detail, recall thatδn

may contain passive pairsx/x, which are eliminated in[δn]. ♦ 6.2 Generality

As an application of the matching algorithm Algorithm 6.1, we can solve the problem of generality and equivalence between two substitutions.

Definition 6.7(more general). A substitutionσismore general(or less instantiated)11than a substitutionθ, written asσ ≤ θ,12ifσ is a right-divisor ofθ, i. e. if there exists a substitutionδwith the propertyθ=δ·σ.

How to check whetherσ ≤ θ? One possibility would be to look for a counter-example, i. e. try to find a term w such that for no renaming δ holdsδ(σ(w)) = θ(w). Let us call such a term a witness term. How to obtain a witness term? Intuitively, we may take w to be the list of all variables of σ, θ, denoted w ··= VarList((σ, θ)), and see if we can find an impasse, i. e.

some parts ofσ(w)that cannot possibly simultaneously be mapped on the respective parts ofθ(w). It turns out this is sufficient.

Theorem 6.8(witness). σ ≤ θ iff for somewwithVars(w) = Vars((σ, θ))holds thatσ(w)matchesθ(w).

11It has also been said thatσschematisesθ(Huet 1976).

12Some authors like (Jacobs and Langen 1992) and (Amato and Scozzari 2009) turn the symbol around. Indeed the choice may appear to be abitrary. But we shall stick to the notion that a more general object is

”smaller”, because it correlates with the ”smallness” of the substitution stack.

Proof.Ifδ·σ=θ, then surelyδ(σ(w)) =θ(w).

For the other direction, assume there is µ with µ(σ(w)) = θ(w). By Theorem 6.6, we can choose the matcherµto be relevant, soVars(µ)⊆Vars((σ, θ)). If for somex∈Vholdsµ(σ(x))6= θ(x), then clearlyx6∈Vars((σ, θ)), hence the inequality becomes µ(x)6=x, meaningx∈Core(µ), which is impossible. ♦

As a consequence, we obtain a simple visual criterion.

Corollary 6.9(witness). The relationσ≤θdoes not hold, iff for somewwithVars(w)⊆Vars((σ, θ))any of the following holds:

1. At some corresponding positions,σ(w)exhibits a non-variable, andθ(w)exhibits a variable (”shrinkage”), or a non-variable of a different shape (”clash”).

2.σ(w) exibits two occurrences of variable x, but at the cor- responding positions in θ(w) there are two mutually distinct terms (”divergence”).

The search for an impasse can be performed by Algorithm 6.1 viaMatch(σ(w0), θ(w0), ε), wherew0··=VarList((σ, θ)).

If no impasse is found, the algorithm produces δ such that θ=δ·σ. Some test runs are in Figure 2 and Figure 3.

Example 6.10. The subtlety of the relation ”more general” is illustrated in (Apt 1997) with the following example:σ··=x

y

is more general than xaya

, but not more general thanθ··= xa . The former claim is justified by xaya

= ya

·x

y

. The matcher was here not difficult to guess, but in general may be, and can always be found by Algorithm 6.1 (Figure 2).

The latter is a simplified form of a counter-example by Hai- Ping Ko (reported in (Shepherdson 1994)), which was pivotal in showing that the strong completeness theorem for SLD-derivation from (Lloyd 1987) needed a revision. The Ko example purports thatσ ··=

x f(y,z)

is not more general than θ ··=

x f(a,a)

, wherey, z are distinct variables. For proof, it was observed: if δ·

x f(y,z)

=

x f(a,a)

, theny/a, z/a∈δ, therefore even if one ofy, zis equal tox, at least one of bindingsy/a, z/ahas to be in δ·

x f(y,z)

. To aleviate the need for such ”ad-hoc”, custom-made proofs, Algorithm 6.1 could be used, giving divergence (Figure 3).

[x, y]

+

σ=x

y

QQ

QQθ= xaya s [y, y]

δ= ya → [a, a]

Figure 2. Successfull check on≤

6.3 Equivalence

The set of substitutions is not partially ordered by≤, namely it is possible thatσ ≤ θandθ ≤ σforσ 6= θ. Such cases form an equivalence relation, called simplyequivalence13and denoted by σ∼θ.

The following property, in similar form, has been proven in (Eder 1985); the formulation is from (Apt 1997). The property follows from Theorem 6.8 as well, since the case where one of a pendant pair is a variable and the other a non-variable is clearly not possible (shrinkage failure).

13perhaps a new name likeequigeneralwould be less confusing, in view of counter-intuitive equivalences?

(10)

[x, y]

+

σ= xa QQ

QQθ= x

y

s

[a, y] ×

shrinkage

→ [y, y]

[x, y, z]

+

σ= x

f(y,z)

QQ

QQθ=

x

f(a,a)

s

[f(y, z), y, z] × divergence

→ [f(a, a), y, z]

[x, y]

+

σ=

x f(y)

QQ

QQθ=

x

g(y)

s

[f(y), y] ×

clash

→ [g(y), y]

Figure 3. Failed check on≤

Legacy 6.11(equivalence). θ is more general thanθ0 and θ0 is more general thanθiff for some renamingρsuch thatVars(ρ)⊆ Vars(θ)∪Vars(θ0)holdsρ·θ=θ0.

With some practice, such a renaming ρ can be guessed, or simply constructed by Algorithm 6.1.

Example 6.12. Sincey

x x y

is a renaming andy

x x y

·y

x x y

=ε, we havey

x x y

∼ε. In other words, if we permute two variables, that amounts to ”doing nothing”. This is a much-cited example of counter-intuitive character of equivalence. In fact, due to group structure of finite permutations, any two renamings are bound to be equivalent, so permuting any number of variables amounts to doing nothing.

Remark6.13 (”∼” is not compositional). Equivalence is not com- patible with composition, as shown in (Eder 1985): Letσ··= yx

, σ0 ··=x

y

andθ ··= xz

. Thenσ ∼ σ0, butθ·σ = yzxz 6∼

θ·σ0=x

y

. The non-equivalence is verified by Algorithm 6.1.

6.4 Unification

Definition 6.14(unification). Letsandtbe terms. If there is a substitutionθ such thatθ(s) = θ(t), thensandtare said to be unifiable, andθis theirunifier, the set of all such beingUnif(s, t).

It is arelevant, ifVars(θ) ⊆Vars(s)∪Vars(t). A unifierθof sand tis theirmost general unifier(mgu), if it is more general than any other unifier; the set of all such isMgus(s, t) ··= {θ ∈ Unif(s, t)|for everyα∈Unif(s, t)holdsθ≤α}.

A set of equations {a1=b1, ..., an=bn} may be condensed to one equation likef(a1, ..., an)=f(b1, ..., bn), and vice versa, which shows that unifying two terms and unifying arbitrarily many terms are the same task. So the notions of unifier and mgu can be extended from a single equations=tto a set of equationsE by definingUnif(E)··={θ| for every(s=t)∈Eholdsθ(s) = θ(t)}. Similarly forMgus(E). A set of equations is insolved form if it is of the form{x1=t1, ..., xn=tn}where allxi are distinct and none of them occurs in anytj.

Ifσ ∈ Mgus(s, t), then for any renamingρby Corollary 3.3 ρ·σ∈Mgus(s, t). In fact, any element fromMgus(s, t)has this form, as a consequence of Legacy 6.11:

Legacy 6.15(equivalence of mgus). Letµ ∈ Mgus(E). Then µ0 ∈ Mgus(E)iff there is a renaming ρsuch thatVars(ρ) ⊆ Vars(µ)∪Vars(µ0)andµ0=ρ·µ.

Thus, the setMgus(s, t)is either empty or infinite.14As a meta- function,Mgushas two pleasing properties: it is compatible with renaming and it is compatible with LD-resolution.

Lemma 6.16(renaming compatibility ofMgus). For everyρand EholdsMgus(ρ(E)) =ρ(Mgus(E)).

Proof.This follows from Theorem 5.24 and Corollary 3.3. Assume σ ∈ Mgus(s, t), then ρ(σ)(ρ(s)) = ρ(σ(s)) = ρ(σ(t)) = ρ(σ)(ρ(t)). Further, ifθ is a unifier ofρ(s), ρ(t), thenθ·ρis a unifier ofs, t, hence there is a renamingδwithθ·ρ=δ·σ, giving θ = δ·σ·ρ−1 = δ·ρ−1·ρ·σ·ρ−1 = (δ·ρ−1)·ρ(σ), meaningρ(σ) ∈ Mgus(ρ(E)). For the other direction, observe θ=ρ·ρ−1·δ·σ·ρ−1=ρ(ρ−1·δ·σ). ♦ Compatibility ofMguswith LD-resolution, also callediteration property, is proved in (Apt 1997).

Legacy 6.17(iteration forMgus). 1. LetE1, E2 be sets of equa- tions. Ifσis a mgu ofE1andθis a mgu ofσ(E2), thenθ·σis a mgu ofE1∪E2.

2. Moreover, ifE1∪E2is unifiable, then there exists a mguσof E1, and for each suchσthere exists a mguθofσ(E2).

6.4.1 Unification by algorithm

For any two unifiable termss, tholds thatMgus(s, t)is an infi- nite set. On the other hand, any particular unification algorithmA produces, for the given two unifiable terms, just one deterministic value as their mgu. We shall denote this particular mgu ofsandt asA(s, t), thealgorithmic (or concrete) mguofsandt, produced by algorithmA.

The task of unification was introduced and solved in (Robin- son 1965). Another classical unification algorithm is (Martelli and Montanari 1982), based on (Herbrand 1930), The algorithm is usu- ally given in non-deterministic form, here denoted asAm2, but it can be made deterministic using sequences instead of sets and pick- ing the leftmost equation eligible for a rule application, as observed in (Apt 1997, p. 36). The resulting algorithm shall be denotedAm2. 6.4.2 ... and iteration property

As opposed toMgus, any particular unification algorithm likeAm2

does not have to satisfy the iteration property. But the deterministic versionAm2does.

Example 6.18(no iteration forAm2). LetE1 ··= (x=y, y=x) and E2 ··= (z=f(x)). If we pick the equation y=xfor bind- ing (denoted by underlining), we obtainE1 = {x=y, y=x} {x=x, y=x} {y=x} yx

=··σandσ(E2) z

f(x)

=··

θ. However, for unifying E1 ∪ E2 we may as well pick x=y for binding, and get E1 ∪ E2 = {x=y, y=x, z=f(x)} {x=y, y=y, z=f(y)}

x y

z f(y)

6=θ·σ.

Lemma 6.19(iteration for Am2). Assume σ = Am2(E0) and θ=Am2(σ(E00)). ThenAm2((E0, E00)) =θ·σ.

Proof.By Legacy 6.17, we know thatE0, E00is unifiable.

The deterministic version of Am2 transforms an equation se- quence from left to right. This has the nice consequence thatAm2

chooses the same equations to transform inE0as inE0, E00for so

14Because of the equivalence, the sloppy formulation ”themost general unifier ofsandt” is often used.

Referenzen

ÄHNLICHE DOKUMENTE

The challenge lies in mapping the different virtual networks with all the resources they require into the available physical network, which is the core of the Virtual Network

In the simple case, each query can be answered either without using any index, in a given answer time, or with using one built index, reducing answer time by a gain specified for

The first greedy heuristic for the MCPP is straightfor- ward. One container after the other is filled by going.. through all unpacked items and packing all items not vi- olating

Abstract—We revisit a simple non-deterministic algorithm for term matching given in (Klop and de Vrijer et al. 2003) and em- ploy it for deciding substitution generality (and

If the current tower base may only be placed partly on the real container floor and if there exist feasible placements of tower bases not yet used, the alternative with the largest

Un- der the assumption that the optimal VRPTW solutions remain very good, if not optimal solu- tions to the derived PDPTW instances, each of them provides a high quality upper bound

(8) This problem is known as the single-machine scheduling problem for minimizing the total flowtime with deadlines, and Smith [12] proposed an O(n1og n) time algorithm

Given a directed network with n nodes, a distinguished node called the destination, a set of probabilities {Pij} where arc.. (i,j) is "open" with probability