Term Rewriting System R:
[X, Y, Z, X1, X2]
primes -> sieve(from(s(s(0))))
from(X) -> cons(X, nfrom(s(X)))
from(X) -> nfrom(X)
head(cons(X, Y)) -> X
tail(cons(X, Y)) -> activate(Y)
if(true, X, Y) -> activate(X)
if(false, X, Y) -> activate(Y)
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), nfilter(s(s(X)), activate(Z)), ncons(Y, nfilter(X, sieve(Y))))
filter(X1, X2) -> nfilter(X1, X2)
sieve(cons(X, Y)) -> cons(X, nfilter(X, sieve(activate(Y))))
cons(X1, X2) -> ncons(X1, X2)
activate(nfrom(X)) -> from(X)
activate(nfilter(X1, X2)) -> filter(X1, X2)
activate(ncons(X1, X2)) -> cons(X1, X2)
activate(X) -> X

Termination of R to be shown.



   R
Dependency Pair Analysis



R contains the following Dependency Pairs:

PRIMES -> SIEVE(from(s(s(0))))
PRIMES -> FROM(s(s(0)))
FROM(X) -> CONS(X, nfrom(s(X)))
TAIL(cons(X, Y)) -> ACTIVATE(Y)
IF(true, X, Y) -> ACTIVATE(X)
IF(false, X, Y) -> ACTIVATE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> IF(divides(s(s(X)), Y), nfilter(s(s(X)), activate(Z)), ncons(Y, nfilter(X, sieve(Y))))
FILTER(s(s(X)), cons(Y, Z)) -> ACTIVATE(Z)
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
SIEVE(cons(X, Y)) -> CONS(X, nfilter(X, sieve(activate(Y))))
SIEVE(cons(X, Y)) -> SIEVE(activate(Y))
SIEVE(cons(X, Y)) -> ACTIVATE(Y)
ACTIVATE(nfrom(X)) -> FROM(X)
ACTIVATE(nfilter(X1, X2)) -> FILTER(X1, X2)
ACTIVATE(ncons(X1, X2)) -> CONS(X1, X2)

Furthermore, R contains one SCC.


   R
DPs
       →DP Problem 1
Non Termination


Dependency Pairs:

FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> ACTIVATE(Z)
ACTIVATE(nfilter(X1, X2)) -> FILTER(X1, X2)
SIEVE(cons(X, Y)) -> ACTIVATE(Y)
SIEVE(cons(X, Y)) -> SIEVE(activate(Y))


Rules:


primes -> sieve(from(s(s(0))))
from(X) -> cons(X, nfrom(s(X)))
from(X) -> nfrom(X)
head(cons(X, Y)) -> X
tail(cons(X, Y)) -> activate(Y)
if(true, X, Y) -> activate(X)
if(false, X, Y) -> activate(Y)
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), nfilter(s(s(X)), activate(Z)), ncons(Y, nfilter(X, sieve(Y))))
filter(X1, X2) -> nfilter(X1, X2)
sieve(cons(X, Y)) -> cons(X, nfilter(X, sieve(activate(Y))))
cons(X1, X2) -> ncons(X1, X2)
activate(nfrom(X)) -> from(X)
activate(nfilter(X1, X2)) -> filter(X1, X2)
activate(ncons(X1, X2)) -> cons(X1, X2)
activate(X) -> X





Found an infinite P-chain over R:
P =

FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> ACTIVATE(Z)
ACTIVATE(nfilter(X1, X2)) -> FILTER(X1, X2)
SIEVE(cons(X, Y)) -> ACTIVATE(Y)
SIEVE(cons(X, Y)) -> SIEVE(activate(Y))

R =

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, nfrom(s(X)))
from(X) -> nfrom(X)
head(cons(X, Y)) -> X
tail(cons(X, Y)) -> activate(Y)
if(true, X, Y) -> activate(X)
if(false, X, Y) -> activate(Y)
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), nfilter(s(s(X)), activate(Z)), ncons(Y, nfilter(X, sieve(Y))))
filter(X1, X2) -> nfilter(X1, X2)
sieve(cons(X, Y)) -> cons(X, nfilter(X, sieve(activate(Y))))
cons(X1, X2) -> ncons(X1, X2)
activate(nfrom(X)) -> from(X)
activate(nfilter(X1, X2)) -> filter(X1, X2)
activate(ncons(X1, X2)) -> cons(X1, X2)
activate(X) -> X

s = SIEVE(activate(nfrom(X''')))
evaluates to t =SIEVE(activate(nfrom(s(X'''))))

Thus, s starts an infinite chain as s matches t.

Non-Termination of R could be shown.
Duration:
0:13 minutes