Term Rewriting Systems SS 11
Exercise Sheet 7 (due June 22nd, 2011)
Marc Brockschmidt, Carsten Fuhs, Thomas Ströder
Prof.aa
Dr. Jürgen Giesl
Notes:
• Please solve these exercises in groups of two!
• The solutions must be handed in directly before (very latest: at the beginning of) the exercise course
on Wednesday, June 22nd, 2011, in lecture hall AH 2. Alternatively you can drop your solutions into a
box which is located right next to Prof. Giesl’s office (until the exercise course starts).
• Please write the names and immatriculation numbers of all (two) students on your solution. Please staple
the individual sheets!
• Exercise 3 (about unification) is only relevant for students attending the V4 (Diplom Informatik and
Diplom Mathematik) version of the lecture. For all other students, this exercise does not contribute to
the overall number of points that will be required for the exam qualification.
• Exercises or exercise parts marked with a star are voluntary challenge exercises with advanced difficulty. However, they do not contribute to the overall number of points that will be required for the exam qualification
or for the Übungsschein, respectively (i.e., you can obtain bonus points for such exercises).
Exercise 1 (Termination Proofs with Advanced Simplification Orders):
points)
(3 + 3 + 3 = 9
Please prove termination of the following TRSs using the LPOS or RPO. If both is not possible, use the RPOS
instead. In this exercise, x, y , and z denote variables while all other identifiers are function symbols. For each
TRS, explicitly state your chosen simplification order (i.e., give its name, the used precedence, and the used
status where appropriate). Use the proof tree notation introduced on the last exercise sheet to prove t1 t2 for
two terms t1 and t2 and ∈ {lpos , rpo , rpos }. You can again refer to the different cases in the definition of
the respective order by their numbers. However, in case t1 emb t2 , you may omit the proof tree for this pair of
terms. To illustrate these notations (especially for multiset comparisons), we give the full solution for the following
example from the lecture:
plus(O, y ) → y
plus(s(x), y ) →
s(plus(y , x))
We choose the RPO with precedence plus A s A O.
s(x) rpo x
emb
{s(x), y }(rpo )mul {y , x}
plus(O, y ) rpo y
emb
mul
plus(s(x), y ) rpo plus(y , x)
3
plus(s(x), y ) rpo s(plus(y , x))
2
a)
times(plus(x, y ), z) →
plus(times(z , x), times(z , y ))
times(x, plus(y , z)) →
plus(times(y , x), times(z , x))
b)
p(a(x), p(b(y ), z))
f(b(x), y )
→ p(b(x), p(a(y ), z))
→ f(y , a(x))
c)
f(leaf)
→ leaf
f(node(x, leaf)) →
f(node(x, node(y , z)))
1
→
node(f(x), leaf)
f(node(node(x, y ), z))
Term Rewriting Systems SS 11
Exercise Sheet 7 (due June 22nd, 2011)
Exercise 2 (Reduction orders):
(3 + 3 + 4 = 10 points)
In this exercise, we will prove termination using the so called polynomial and matrix orders. In a polynomial
order, one uses a polynomial interpretation P that maps each function symbol f of arity n to a polynomial
fP (x1 , . . . , xn ) = c0 + c1 x1 + . . . + cn xn using the variables x1 , . . . , xn and coefficients c0 , . . . , cn from N. Such an
interpretation for function symbols can then be extended to terms using the following rules:
• P(x) := x for all variables x.
• P(f (t1 , . . . , tn )) := fP (P(t1 ), . . . , P(tn )) for all terms f (t1 , . . . , tn ).
As example, consider the term t = minus(s(x), s(y )). We choose sP (x1 ) = 1+x1 and minusP (x1 , x2 ) = 1+x1 +x2 .
Then we have P(s(x)) = 1 + x and thus P(t) = 1 + (1 + x) + (1 + y ) = 3 + x + y .
Using P, we can then define the polynomial order over T (Σ, V) such that s P t holds if and only if P(s) > P(t)
holds for all variable assignments with values from N. As example, consider the rule
minus(s(x), s(y )) → minus(x, y )
and our interpretation from above. We have minus(s(x), s(y )) P minus(x, y ) as P(minus(s(x), s(y ))) = 3 + x +
y > 1 + x + y = P(minus(x, y )) holds for all natural numbers x, y .
Of course, to use P as a reduction order, we need to ensure that it is well founded, stable, and monotonic. To
this end, one requires that in fP (x1 , . . . , xn ) = c0 + c1 x1 + . . . + cn xn , ci > 0 holds for all 1 ≤ i ≤ n. However,
c0 = 0 is allowed.
a) Show termination of the following TRS R1 using a polynomial interpretation P1 :
plus(O, y ) → y
plus(s(x), y ) → s(plus(x, y ))
plus(s(x), y ) → plus(x, s(y ))
The signature of R1 is Σ = Σ0 ∪ Σ1 ∪ Σ2 , where Σ0 = {O}, Σ1 = {s} and Σ2 = {plus}.
Give a polynomial fP1 for each symbol f from Σ and show that l P1 r holds for all l → r ∈ R1 .
Hints:
• You do not need coefficients that are greater than 2.
b) Show termination of the following TRS R2 using a polynomial interpretation P2 :
f(s(s(x)), 42) → f(x, 23)
f(x, 23) → f(s(x), 42)
The signature of R2 is Σ = Σ0 ∪ Σ1 ∪ Σ2 , where Σ0 = {23, 42}, Σ1 = {s} and Σ2 = {f}.
Give a polynomial fP2 for each symbol f from Σ and show that l P2 r holds for all l → r ∈ R2 .
Hints:
• You do not need coefficients that are greater than 3.
c) An extension of polynomial order are matrix orders.1 A matrix interpretation maps each term to a vector
from Nk , where k may be > 1. The coefficients in the interpretations for the function symbols are not
numbers, but instead matrices of numbers.
For example, for k = 2, we define a matrix interpretation M that maps each function symbol f of arity n
to a function
x
x
c0,1
c
c1,2
x
c
cn,2
x
fM ( 1 , . . . , n ) =
+ 1,1
· 1 + . . . + n,1
· n
y1
yn
d0,1
d1,1 d1,2
y1
dn,1 dn,2
yn
using the variables x1 , y1 , . . . , xn , yn and the coefficients ci,j , di,j from N. Here + and · are standard matrix
addition and multiplication, respectively. Similar to polynomial interpretations, such an interpretation for
function symbols can then be extended to terms as follows:
1 This
class of orders was discovered only recently in 2006.
2
Term Rewriting Systems SS 11
Exercise Sheet 7 (due June 22nd, 2011)
• M(x) :=
x1
for all variables x.
x2
• M(f (t1 , . . . , tn )) := fM (M(t1 ), . . . , M(tn )) for all terms f (t1 , . . . , tn ).
To compare vectors, we define
a1
b1
>
a2
b2
iff a1 > b1 and a2 ≥ b2 .2 Using M, we define the matrix order over T (Σ, V) such that s M t holds if and
only if M(s) > M(t) holds for all variable assignments with values from N. To ensure that matrix orders
are reduction orders, we require that in
x1
xn
c0,1
c1,1 c1,2
x1
cn,1 cn,2
x
fM (
,...,
)=
+
·
+ ... +
· n
y1
yn
d0,2
d1,1 d1,2
y1
dn,1 dn,2
yn
ci,1 > 0 holds for all 1 ≤ i ≤ n. All other ci,j , di,j may also be 0.
One can find matrix orders M and terms s, t with s M t although t emb s holds. In other words, matrix
orders are not necessarily simplification orders. We will now benefit from this property of matrix orders to
prove termination of the term rewriting system R3 :
f(f(x)) → f(g(f(x)))
The signature of R3 is Σ = Σ1 , where Σ1 = {f, g}. The TRS R3 was presented in the lecture as an example
for a TRS where termination cannot be proved using any simplification order.
Give a matrix interpretation M3 and show that f(f(x)) M3 f(g(f(x))) holds.
Hints:
• You do not need coefficients that are greater than 1.
• We provide part of a possible solution:
x
0
1
fM3 ( 1 ) =
+
y1
1
b1,1
a1,2
b1,2
x1
0
1
gM3 (
)=
+
d1,1
y1
0
c1,2
d1,2
Exercise 3 (Unification):
x
· 1
y1
x
· 1
y1
(Only relevant for diploma students: 3 + 3 = 6 points)
Apply the algorithm UNIFY from the lecture to compute a most general unifier for the following sets of terms:
i) {f(h(x1 ), f(x3 , x4 )), f(x2 , f(x4 , x2 )), f(x3 , f(x2 , x2 ))}
ii) {f(h(x1 ), f(x3 , x4 )), f(x2 , f(x4 , x2 )), f(x1 , f(x2 , x2 ))}
Include all intermediate sets that are created in the computation and note which rule you applied to generate
each of the sets from its predecessor in the following form:
{h(a) =? h(x)}
=⇒ (term reduction)
?
{a = x}
=⇒ (swap)
?
{x = a}
If the computation fails, note the type of the error.
2 Note
that for well-foundedness, one does not have to require a2 > b2 .
3
Term Rewriting Systems SS 11
Exercise Sheet 7 (due June 22nd, 2011)
Challenge Exercise 4 (Unification):
(4* points)
Apply the algorithm UNIFY from the lecture to compute a most general unifier for the terms
g(x1
, x2
, f(y0 , y0 ), f(y1 , y1 ), f(y2 , y2 ))
g(f(x0 , x0 ), f(x1 , x1 ), y1
, y2
, x2 )
Use the same format as in Exercise 3.
4
© Copyright 2026 Paperzz