Runtime Complexity TRS:
The TRS R consists of the following rules:

check(0) → zero
check(s(0)) → odd
check(s(s(0))) → even
check(s(s(s(x)))) → check(s(x))
half(0) → 0
half(s(0)) → 0
half(s(s(x))) → s(half(x))
plus(0, y) → y
plus(s(x), y) → s(plus(x, y))
times(x, y) → timesIter(x, y, 0)
timesIter(x, y, z) → if(check(x), x, y, z, plus(z, y))
p(s(x)) → x
p(0) → 0
if(zero, x, y, z, u) → z
if(odd, x, y, z, u) → timesIter(p(x), y, u)
if(even, x, y, z, u) → plus(timesIter(half(x), y, half(z)), timesIter(half(x), y, half(s(z))))

Rewrite Strategy: INNERMOST


Renamed function symbols to avoid clashes with predefined symbol.


Runtime Complexity TRS:
The TRS R consists of the following rules:


check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Rewrite Strategy: INNERMOST


Infered types.


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'


Heuristically decided to analyse the following defined symbols:
check', half', plus', timesIter'

They will be analysed ascendingly in the following order:
check' < timesIter'
half' < timesIter'
plus' < timesIter'


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Generator Equations:
_gen_0':s'3(0) ⇔ 0'
_gen_0':s'3(+(x, 1)) ⇔ s'(_gen_0':s'3(x))

The following defined symbols remain to be analysed:
check', half', plus', timesIter'

They will be analysed ascendingly in the following order:
check' < timesIter'
half' < timesIter'
plus' < timesIter'


Proved the following rewrite lemma:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)

Induction Base:
check'(_gen_0':s'3(+(1, *(2, 0)))) →RΩ(1)
odd'

Induction Step:
check'(_gen_0':s'3(+(1, *(2, +(_$n6, 1))))) →RΩ(1)
check'(s'(_gen_0':s'3(*(2, _$n6)))) →IH
odd'

We have rt ∈ Ω(n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)

Generator Equations:
_gen_0':s'3(0) ⇔ 0'
_gen_0':s'3(+(x, 1)) ⇔ s'(_gen_0':s'3(x))

The following defined symbols remain to be analysed:
half', plus', timesIter'

They will be analysed ascendingly in the following order:
half' < timesIter'
plus' < timesIter'


Proved the following rewrite lemma:
half'(_gen_0':s'3(*(2, _n747))) → _gen_0':s'3(_n747), rt ∈ Ω(1 + n747)

Induction Base:
half'(_gen_0':s'3(*(2, 0))) →RΩ(1)
0'

Induction Step:
half'(_gen_0':s'3(*(2, +(_$n748, 1)))) →RΩ(1)
s'(half'(_gen_0':s'3(*(2, _$n748)))) →IH
s'(_gen_0':s'3(_$n748))

We have rt ∈ Ω(n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)
half'(_gen_0':s'3(*(2, _n747))) → _gen_0':s'3(_n747), rt ∈ Ω(1 + n747)

Generator Equations:
_gen_0':s'3(0) ⇔ 0'
_gen_0':s'3(+(x, 1)) ⇔ s'(_gen_0':s'3(x))

The following defined symbols remain to be analysed:
plus', timesIter'

They will be analysed ascendingly in the following order:
plus' < timesIter'


Proved the following rewrite lemma:
plus'(_gen_0':s'3(_n1544), _gen_0':s'3(b)) → _gen_0':s'3(+(_n1544, b)), rt ∈ Ω(1 + n1544)

Induction Base:
plus'(_gen_0':s'3(0), _gen_0':s'3(b)) →RΩ(1)
_gen_0':s'3(b)

Induction Step:
plus'(_gen_0':s'3(+(_$n1545, 1)), _gen_0':s'3(_b1677)) →RΩ(1)
s'(plus'(_gen_0':s'3(_$n1545), _gen_0':s'3(_b1677))) →IH
s'(_gen_0':s'3(+(_$n1545, _b1677)))

We have rt ∈ Ω(n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)
half'(_gen_0':s'3(*(2, _n747))) → _gen_0':s'3(_n747), rt ∈ Ω(1 + n747)
plus'(_gen_0':s'3(_n1544), _gen_0':s'3(b)) → _gen_0':s'3(+(_n1544, b)), rt ∈ Ω(1 + n1544)

Generator Equations:
_gen_0':s'3(0) ⇔ 0'
_gen_0':s'3(+(x, 1)) ⇔ s'(_gen_0':s'3(x))

The following defined symbols remain to be analysed:
timesIter'


Could not prove a rewrite lemma for the defined symbol timesIter'.


Rules:
check'(0') → zero'
check'(s'(0')) → odd'
check'(s'(s'(0'))) → even'
check'(s'(s'(s'(x)))) → check'(s'(x))
half'(0') → 0'
half'(s'(0')) → 0'
half'(s'(s'(x))) → s'(half'(x))
plus'(0', y) → y
plus'(s'(x), y) → s'(plus'(x, y))
times'(x, y) → timesIter'(x, y, 0')
timesIter'(x, y, z) → if'(check'(x), x, y, z, plus'(z, y))
p'(s'(x)) → x
p'(0') → 0'
if'(zero', x, y, z, u) → z
if'(odd', x, y, z, u) → timesIter'(p'(x), y, u)
if'(even', x, y, z, u) → plus'(timesIter'(half'(x), y, half'(z)), timesIter'(half'(x), y, half'(s'(z))))

Types:
check' :: 0':s' → zero':odd':even'
0' :: 0':s'
zero' :: zero':odd':even'
s' :: 0':s' → 0':s'
odd' :: zero':odd':even'
even' :: zero':odd':even'
half' :: 0':s' → 0':s'
plus' :: 0':s' → 0':s' → 0':s'
times' :: 0':s' → 0':s' → 0':s'
timesIter' :: 0':s' → 0':s' → 0':s' → 0':s'
if' :: zero':odd':even' → 0':s' → 0':s' → 0':s' → 0':s' → 0':s'
p' :: 0':s' → 0':s'
_hole_zero':odd':even'1 :: zero':odd':even'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)
half'(_gen_0':s'3(*(2, _n747))) → _gen_0':s'3(_n747), rt ∈ Ω(1 + n747)
plus'(_gen_0':s'3(_n1544), _gen_0':s'3(b)) → _gen_0':s'3(+(_n1544, b)), rt ∈ Ω(1 + n1544)

Generator Equations:
_gen_0':s'3(0) ⇔ 0'
_gen_0':s'3(+(x, 1)) ⇔ s'(_gen_0':s'3(x))

No more defined symbols left to analyse.


The lowerbound Ω(n) was proven with the following lemma:
check'(_gen_0':s'3(+(1, *(2, _n5)))) → odd', rt ∈ Ω(1 + n5)