Term Rewriting System R:
[X, Y, Z]
primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

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) -> FROM(s(X))
FILTER(s(s(X)), cons(Y, Z)) -> IF(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(s(s(X)), Z)
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(X, sieve(Y))
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
SIEVE(cons(X, Y)) -> FILTER(X, sieve(Y))
SIEVE(cons(X, Y)) -> SIEVE(Y)

Furthermore, R contains two SCCs.

`   R`
`     ↳DPs`
`       →DP Problem 1`
`         ↳Narrowing Transformation`
`       →DP Problem 2`
`         ↳Remaining`

Dependency Pairs:

SIEVE(cons(X, Y)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(X, sieve(Y))
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(s(s(X)), Z)
SIEVE(cons(X, Y)) -> FILTER(X, sieve(Y))

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

On this DP problem, a Narrowing SCC transformation can be performed.
As a result of transforming the rule

FILTER(s(s(X)), cons(Y, Z)) -> FILTER(X, sieve(Y))
one new Dependency Pair is created:

FILTER(s(s(X)), cons(cons(X'', Y''), Z)) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))

The transformation is resulting in one new DP problem:

`   R`
`     ↳DPs`
`       →DP Problem 1`
`         ↳Nar`
`           →DP Problem 3`
`             ↳Narrowing Transformation`
`       →DP Problem 2`
`         ↳Remaining`

Dependency Pairs:

FILTER(s(s(X)), cons(cons(X'', Y''), Z)) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(s(s(X)), Z)
SIEVE(cons(X, Y)) -> FILTER(X, sieve(Y))
SIEVE(cons(X, Y)) -> SIEVE(Y)

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

On this DP problem, a Narrowing SCC transformation can be performed.
As a result of transforming the rule

SIEVE(cons(X, Y)) -> FILTER(X, sieve(Y))
one new Dependency Pair is created:

SIEVE(cons(X, cons(X'', Y''))) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))

The transformation is resulting in one new DP problem:

`   R`
`     ↳DPs`
`       →DP Problem 1`
`         ↳Nar`
`       →DP Problem 2`
`         ↳Remaining Obligation(s)`

The following remains to be proven:
• Dependency Pairs:

SIEVE(cons(X, cons(X'', Y''))) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))
SIEVE(cons(X, Y)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(s(s(X)), Z)
FILTER(s(s(X)), cons(cons(X'', Y''), Z)) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

• Dependency Pair:

FROM(X) -> FROM(s(X))

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

`   R`
`     ↳DPs`
`       →DP Problem 1`
`         ↳Nar`
`       →DP Problem 2`
`         ↳Remaining Obligation(s)`

The following remains to be proven:
• Dependency Pairs:

SIEVE(cons(X, cons(X'', Y''))) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))
SIEVE(cons(X, Y)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> SIEVE(Y)
FILTER(s(s(X)), cons(Y, Z)) -> FILTER(s(s(X)), Z)
FILTER(s(s(X)), cons(cons(X'', Y''), Z)) -> FILTER(X, cons(X'', filter(X'', sieve(Y''))))

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))
tail(cons(X, Y)) -> Y
if(true, X, Y) -> X
if(false, X, Y) -> Y
filter(s(s(X)), cons(Y, Z)) -> if(divides(s(s(X)), Y), filter(s(s(X)), Z), cons(Y, filter(X, sieve(Y))))
sieve(cons(X, Y)) -> cons(X, filter(X, sieve(Y)))

• Dependency Pair:

FROM(X) -> FROM(s(X))

Rules:

primes -> sieve(from(s(s(0))))
from(X) -> cons(X, from(s(X)))