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

nonZero(0) → false
nonZero(s(x)) → true
p(s(0)) → 0
p(s(s(x))) → s(p(s(x)))
id_inc(x) → x
id_inc(x) → s(x)
random(x) → rand(x, 0)
rand(x, y) → if(nonZero(x), x, y)
if(false, x, y) → y
if(true, x, y) → rand(p(x), id_inc(y))

Rewrite Strategy: INNERMOST


Renamed function symbols to avoid clashes with predefined symbol.


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


nonZero'(0') → false'
nonZero'(s'(x)) → true'
p'(s'(0')) → 0'
p'(s'(s'(x))) → s'(p'(s'(x)))
id_inc'(x) → x
id_inc'(x) → s'(x)
random'(x) → rand'(x, 0')
rand'(x, y) → if'(nonZero'(x), x, y)
if'(false', x, y) → y
if'(true', x, y) → rand'(p'(x), id_inc'(y))

Rewrite Strategy: INNERMOST


Infered types.


Rules:
nonZero'(0') → false'
nonZero'(s'(x)) → true'
p'(s'(0')) → 0'
p'(s'(s'(x))) → s'(p'(s'(x)))
id_inc'(x) → x
id_inc'(x) → s'(x)
random'(x) → rand'(x, 0')
rand'(x, y) → if'(nonZero'(x), x, y)
if'(false', x, y) → y
if'(true', x, y) → rand'(p'(x), id_inc'(y))

Types:
nonZero' :: 0':s' → false':true'
0' :: 0':s'
false' :: false':true'
s' :: 0':s' → 0':s'
true' :: false':true'
p' :: 0':s' → 0':s'
id_inc' :: 0':s' → 0':s'
random' :: 0':s' → 0':s'
rand' :: 0':s' → 0':s' → 0':s'
if' :: false':true' → 0':s' → 0':s' → 0':s'
_hole_false':true'1 :: false':true'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'


Heuristically decided to analyse the following defined symbols:
p', rand'

They will be analysed ascendingly in the following order:
p' < rand'


Rules:
nonZero'(0') → false'
nonZero'(s'(x)) → true'
p'(s'(0')) → 0'
p'(s'(s'(x))) → s'(p'(s'(x)))
id_inc'(x) → x
id_inc'(x) → s'(x)
random'(x) → rand'(x, 0')
rand'(x, y) → if'(nonZero'(x), x, y)
if'(false', x, y) → y
if'(true', x, y) → rand'(p'(x), id_inc'(y))

Types:
nonZero' :: 0':s' → false':true'
0' :: 0':s'
false' :: false':true'
s' :: 0':s' → 0':s'
true' :: false':true'
p' :: 0':s' → 0':s'
id_inc' :: 0':s' → 0':s'
random' :: 0':s' → 0':s'
rand' :: 0':s' → 0':s' → 0':s'
if' :: false':true' → 0':s' → 0':s' → 0':s'
_hole_false':true'1 :: false':true'
_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:
p', rand'

They will be analysed ascendingly in the following order:
p' < rand'


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

Induction Base:
p'(_gen_0':s'3(+(1, 0))) →RΩ(1)
0'

Induction Step:
p'(_gen_0':s'3(+(1, +(_$n6, 1)))) →RΩ(1)
s'(p'(s'(_gen_0':s'3(_$n6)))) →IH
s'(_gen_0':s'3(_$n6))

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


Rules:
nonZero'(0') → false'
nonZero'(s'(x)) → true'
p'(s'(0')) → 0'
p'(s'(s'(x))) → s'(p'(s'(x)))
id_inc'(x) → x
id_inc'(x) → s'(x)
random'(x) → rand'(x, 0')
rand'(x, y) → if'(nonZero'(x), x, y)
if'(false', x, y) → y
if'(true', x, y) → rand'(p'(x), id_inc'(y))

Types:
nonZero' :: 0':s' → false':true'
0' :: 0':s'
false' :: false':true'
s' :: 0':s' → 0':s'
true' :: false':true'
p' :: 0':s' → 0':s'
id_inc' :: 0':s' → 0':s'
random' :: 0':s' → 0':s'
rand' :: 0':s' → 0':s' → 0':s'
if' :: false':true' → 0':s' → 0':s' → 0':s'
_hole_false':true'1 :: false':true'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
p'(_gen_0':s'3(+(1, _n5))) → _gen_0':s'3(_n5), 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:
rand'


Proved the following rewrite lemma:
rand'(_gen_0':s'3(_n383), _gen_0':s'3(b)) → _gen_0':s'3(b), rt ∈ Ω(1 + n383 + n3832)

Induction Base:
rand'(_gen_0':s'3(0), _gen_0':s'3(b)) →RΩ(1)
if'(nonZero'(_gen_0':s'3(0)), _gen_0':s'3(0), _gen_0':s'3(b)) →RΩ(1)
if'(false', _gen_0':s'3(0), _gen_0':s'3(b)) →RΩ(1)
_gen_0':s'3(b)

Induction Step:
rand'(_gen_0':s'3(+(_$n384, 1)), _gen_0':s'3(_b581)) →RΩ(1)
if'(nonZero'(_gen_0':s'3(+(_$n384, 1))), _gen_0':s'3(+(_$n384, 1)), _gen_0':s'3(_b581)) →RΩ(1)
if'(true', _gen_0':s'3(+(1, _$n384)), _gen_0':s'3(_b581)) →RΩ(1)
rand'(p'(_gen_0':s'3(+(1, _$n384))), id_inc'(_gen_0':s'3(_b581))) →LΩ(1 + $n384)
rand'(_gen_0':s'3(_$n384), id_inc'(_gen_0':s'3(_b581))) →RΩ(1)
rand'(_gen_0':s'3(_$n384), _gen_0':s'3(_b581)) →IH
_gen_0':s'3(_b581)

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


Rules:
nonZero'(0') → false'
nonZero'(s'(x)) → true'
p'(s'(0')) → 0'
p'(s'(s'(x))) → s'(p'(s'(x)))
id_inc'(x) → x
id_inc'(x) → s'(x)
random'(x) → rand'(x, 0')
rand'(x, y) → if'(nonZero'(x), x, y)
if'(false', x, y) → y
if'(true', x, y) → rand'(p'(x), id_inc'(y))

Types:
nonZero' :: 0':s' → false':true'
0' :: 0':s'
false' :: false':true'
s' :: 0':s' → 0':s'
true' :: false':true'
p' :: 0':s' → 0':s'
id_inc' :: 0':s' → 0':s'
random' :: 0':s' → 0':s'
rand' :: 0':s' → 0':s' → 0':s'
if' :: false':true' → 0':s' → 0':s' → 0':s'
_hole_false':true'1 :: false':true'
_hole_0':s'2 :: 0':s'
_gen_0':s'3 :: Nat → 0':s'

Lemmas:
p'(_gen_0':s'3(+(1, _n5))) → _gen_0':s'3(_n5), rt ∈ Ω(1 + n5)
rand'(_gen_0':s'3(_n383), _gen_0':s'3(b)) → _gen_0':s'3(b), rt ∈ Ω(1 + n383 + n3832)

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 Ω(n2) was proven with the following lemma:
rand'(_gen_0':s'3(_n383), _gen_0':s'3(b)) → _gen_0':s'3(b), rt ∈ Ω(1 + n383 + n3832)