• No results found

Partial Terms

In document Bohm-Like Trees for Rewriting (Page 176-180)

In this section, we define partial higher-order terms in conjunction with a prefix order on these terms. The definition requires the introduction of a fresh function symbol ⊥. Since all function symbols in a higher-order signature need to be typed, ⊥ needs to be typed too.

Although it is very easy to come up with several different typings of ⊥, typing it in such a way that a prefix order can be defined which satisfies a number of desired properties turns out to be not completely straightforward. Taking into account the definition of the prefix order on partial first-order and partial λ-terms (see

Chapter 3) and also the fact that higher-order terms are typed, there are at least four desired properties:

1. Given that ⊥ has type A, the partial order must homomorphically extend the requirement that ⊥ is least among all terms of type A.

2. Terms in which ⊥ does not occur must be incomparable. 3. Terms of different types must be incomparable.

4. For each type there must be a term that is least among all terms of the type. The properties help to ensure that the prefix order is a CUSL with respect to each type, which enables us to define for each type a set of infinite terms by means of ideal completion.

To gain more insight in the reason why it is difficult to type ⊥, we discuss two insufficient typings in Section 9.2.1. The actual typing and prefix order that we employ in the remainder of this chapter are given in Section 9.2.2.

9.2.1 Two Insufficient Typings

We next discuss two typings of ⊥ that each yield a prefix order which does not satisfy all desired properties mentioned above. As such, the typings can be called insufficient.

First Typing. Possibly the most obvious thing to do, is to assign some arbitrary type to ⊥. To see that this do not suffice with respect to properties desired of the prefix order, suppose there exist a base type A and two nullary function symbols aA

1 and aA2. By the second desirable property, the function symbols must be incom-

parable. By the fourth property there must exist some term that is a prefix of both function symbols. Since a1 and a2 have arity zero, it follows by the first property

that only ⊥ suffices. Hence, by the third property ⊥ must have type A, not just some arbitrary type.

Suppose there also exist a base type B and two nullary function symbols bB 1

and bB

2. By repeating the above reasoning, it follows that ⊥ must have type B.

Hence, we can conclude that a single function symbol ⊥ does not suffice; a number of differently typed functions symbols ⊥ are needed.

Second Typing. Given the way in which the previous typing fails, we could in- troduce a function symbol ⊥ for each type. This has at least four disadvantages, the fourth of which has to do with the prefix order. First, since there are infinitely many types, an infinite number of function symbols will be added to the signature even if the assumed signature is finite. This is not very elegant.

Second, ⊥ will not only occur as a nullary function symbol, but also as function symbols of arity greater than zero. Assuming we have at our disposal a base type A, we can now specify terms like ⊥(x), where ⊥ is of type A → A and where x ∈ VA.

Such terms cannot be defined in the first-order case. Hence, to some extent the current typing is incompatible with the first-order approach.

Third, by the assumption that there exists a function symbol ⊥ for each type we can replace each subterm of a term by ⊥. However, doing so not always re- sults in a preterm which is also term. That is, the obtained preterm does not

need to be in β ¯η-normal form. To see that this is possible, consider the signature {cA, f(A→A)→A, gA→A} and the term s = f (λx.g(g(c))). Replacing the subterm

λx.g(g(c)) in s by ⊥A→A yields the preterm f (⊥). This preterm is not in β ¯η- normal form. The following reduction is possible due to the fact that ⊥ has type A → A:

f (⊥) →η¯f (λx.⊥(x)) .

Fourth, given the above signature and terms, it seems obvious that f (⊥) should be a prefix of s = f (λx.g(g(c))), since f (⊥) is obtained by replacing a subterm of s by ⊥. Whence, as f (λx.⊥(x)) is the β ¯η-normal form of f (⊥), it also seems obvious that f (λx.⊥(x)) should be a prefix of s. However, by the first desirable property for the prefix order, this requires x to be a prefix of either g(c) or c, which violates the second desirable property.

9.2.2 Definition

The problems regarding the typing of ⊥, as discussed in the previous section, can be avoided by only introducing a function symbol ⊥ for each base type. Assuming that Σ is an arbitrary signature and that V is a set of variables, we define: Definition 9.2.1. The signature Σ⊥ is defined as Σ ∪ {⊥A| A a base type}. The

set of partial (higher-order) terms is defined as the set of higher-order terms over the signature Σ⊥, i.e., Ter(Σ⊥, V ).

Given some term in Ter(Σ⊥, V ), we always have that some other term in Ter(Σ⊥, V )

is obtained whenever some subterm is replaced by ⊥. The reason is two-fold: First, replacing a subterm by ⊥ does not introduce a β-redex, since λ-abstractions are not of base type. Second, no ¯η-redex is introduced either, because the ¯η-rule does not apply to terms of base type, like ⊥.

Given an HRS H = (Σ, H), we can define the HRS K = (Σ⊥, H). The definition

of K is sound with respect to the rewrite rules of H, as Σ ⊆ Σ⊥. Moreover, K has

the same termination and confluence properties as H, which follows immediately when we consider each ⊥A to be an appropriately typed variable that is singled

out.

Remark 9.2.2. The first two disadvantages of the second typing from Section 9.2.1 do not apply to the above typing: With respect to the first disadvantage, we now have that Σ⊥ is infinite only if either Σ or the number of base types is infinite. In

any other case Σ⊥ is finite.

The second disadvantage does not apply, since each introduced function symbol has arity 0. This implies that ⊥ cannot occur in a subterm of the form ⊥(x).

That the third disadvantage does not apply, is explained below Definition 9.2.1. Moreover, that the problems with respect to the prefix order are also solved, is immediate by Definition 9.2.3 and Lemma 9.2.5 as given below.

Combining the definition of the prefix order on partial first-order and partial λ-terms and taking into account the types, we define the prefix order on partial higher-order preterms as follows:

Definition 9.2.3. Let Σ be a signature and V a set of variables.

1. The prefix order on the preterms over Σ⊥, denoted 4, is the smallest binary

relation, modulo α-equivalence, such that: (a) xA4xA, if x ∈ VA,

(b) fA4fA, if fA∈ Σ,

(c) ⊥A4sA, if A is a base type and sA a preterm,

(d) λx.s 4 λx.t, if x ∈ V and s 4 t, and (e) s1s24t1t2, if s14t1 and s24t2.

2. The strict prefix order on the preterms over Σ⊥, denoted ≺, is the smallest

binary relation such that for all preterms s and t: s ≺ t ⇐⇒ (s 4 t and t 64 s) .

If we have s 4 t, respectively s ≺ t, then we call s a prefix of t, respectively a strict prefix of t. Moreover, by < and  we denote respectively the converse of the prefix order and the strict prefix order.

By the explanation just below Definition 9.2.1, it follows immediately that the above definition carries over from preterms to terms without taking into account either β-reduction or restricted η-expansion.

Example 9.2.4. Given the λβ-encoding from Example 9.1.5, we have the following, where s, t1, and t2 are arbitrary partial terms:

⊥ 4 abs(λx.s) app(⊥, t2) 4 app(t1, t2)

abs(λx.⊥) 4 abs(λx.s) app(t1, ⊥) 4 app(t1, t2)

⊥ 4 app(t1, t2) app(⊥, ⊥) 4 app(t1, t2)

Denoting by Ter(Σ⊥, V )A all terms of type A in Ter(Σ⊥, V ), we have the fol-

lowing lemma with respect to the prefix order and the strict prefix order: Lemma 9.2.5. Let A be a type. It holds that the pairs POA = (Ter(Σ

⊥, V )A, 4)

and SPOA= (Ter(Σ⊥, V )A, ≺) are respectively a CUSL and a strict partial order.

Proof. By induction on the structure of preterms, simultaneous for all types, where the least element of type A is:

1. ⊥A, if A is a base type, and

2. λx.l with l the least element of type C and x ∈ VB, if A = B → C.

The proof is completely analogous to the proof of Lemma 3.2.3. ut Like in the first-order case, we have:

Proposition 9.2.6. Let s, t ∈ Ter(Σ⊥, V ).

1. For all s 4 t it holds that: – Pos(s) ⊆ Pos(t), and

– root(s|p) = root(t|p), if p ∈ Pos(s) and s|p6= ⊥.

2. For all s ≺ t there exist p ∈ Pos(s) such that s|p= ⊥ and t|p6= ⊥.

By the above proposition, we also have the following, where the proof is identical to the proof of Proposition 3.2.5:

Proposition 9.2.7. The strict prefix order on Ter(Σ⊥, V ) is well-founded.

As in the case of partial first-order terms, we can extend the definition of the (strict) prefix order to substitutions by means of a pointwise definition:

Definition 9.2.8. Let σ and τ be substitutions. Define σ 4 τ ⇐⇒ (σ(x) 4 τ (x) for all x ∈ V ) and

σ ≺ τ ⇐⇒ (σ 4 τ and σ(x) ≺ τ (x) for some x ∈ V ) .

The prefix order and the strict prefix order on substitutions are respectively a par- tial order and a strict partial order. This follows immediately by the definitions and the fact that the prefix order and the strict prefix order on terms are respectively a partial order and a strict partial order.

We next define root-stable prefixes:

Definition 9.2.9. Let H = (Σ, H) be an HRS and s, t ∈ Ter(Σ⊥, V ). The term

t is a root-stable prefix of s, given that t 4 s and such that for all t|p 6= ⊥ with

p ∈ Pos(t) it holds that s|p is a root-stable subterm of s.

We can also have the higher-order analogue of Lemma 5.1.2, which we require in Section 9.6:

Lemma 9.2.10. Let s, t ∈ Ter(Σ⊥, V ) with t a linear (rule) pattern. If s 4 τ (t)

for some substitution τ , then there exist s0∈ Ter(Σ

⊥, V ) and substitutions σ0 such

that s = σ0(s0), s04t, σ04τ , and s0 a linear (rule) pattern.

Proof. By induction on the number of positions p ∈ Pos(s) such that s|p = ⊥

and τ (t)|p 6= ⊥. Since t is a pattern, this is completely analogous to the proof in

first-order case. ut

Remark 9.2.11. The previous lemma does not hold in case linear patterns are replaced by linear terms. To understand this, suppose s = f (g(⊥), g(a)) and t = F (G) and also suppose τ (F ) = λx.f (x, x) and τ (G) = g(a). Obviously, τ (t) = f (g(a), g(a)) and s 4 τ (t). However, to satisfy the requirements of the lemma, the only choice for s0is F (G). But then, σ0(G) must both be equal to g(⊥)

and g(a).

In document Bohm-Like Trees for Rewriting (Page 176-180)