Runtime Complexity TRS:
The TRS R consists of the following rules:
sort(nil) → nil
sort(cons(x, y)) → insert(x, sort(y))
insert(x, nil) → cons(x, nil)
insert(x, cons(v, w)) → choose(x, cons(v, w), x, v)
choose(x, cons(v, w), y, 0) → cons(x, cons(v, w))
choose(x, cons(v, w), 0, s(z)) → cons(v, insert(x, w))
choose(x, cons(v, w), s(y), s(z)) → choose(x, cons(v, w), y, z)
Renamed function symbols to avoid clashes with predefined symbol.
Runtime Complexity TRS:
The TRS R consists of the following rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Infered types.
Rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Types:
sort' :: nil':cons' → nil':cons'
nil' :: nil':cons'
cons' :: 0':s' → nil':cons' → nil':cons'
insert' :: 0':s' → nil':cons' → nil':cons'
choose' :: 0':s' → nil':cons' → 0':s' → 0':s' → nil':cons'
0' :: 0':s'
s' :: 0':s' → 0':s'
_hole_nil':cons'1 :: nil':cons'
_hole_0':s'2 :: 0':s'
_gen_nil':cons'3 :: Nat → nil':cons'
_gen_0':s'4 :: Nat → 0':s'
Heuristically decided to analyse the following defined symbols:
sort', insert', choose'
They will be analysed ascendingly in the following order:
insert' < sort'
insert' = choose'
Rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Types:
sort' :: nil':cons' → nil':cons'
nil' :: nil':cons'
cons' :: 0':s' → nil':cons' → nil':cons'
insert' :: 0':s' → nil':cons' → nil':cons'
choose' :: 0':s' → nil':cons' → 0':s' → 0':s' → nil':cons'
0' :: 0':s'
s' :: 0':s' → 0':s'
_hole_nil':cons'1 :: nil':cons'
_hole_0':s'2 :: 0':s'
_gen_nil':cons'3 :: Nat → nil':cons'
_gen_0':s'4 :: Nat → 0':s'
Generator Equations:
_gen_nil':cons'3(0) ⇔ nil'
_gen_nil':cons'3(+(x, 1)) ⇔ cons'(0', _gen_nil':cons'3(x))
_gen_0':s'4(0) ⇔ 0'
_gen_0':s'4(+(x, 1)) ⇔ s'(_gen_0':s'4(x))
The following defined symbols remain to be analysed:
choose', sort', insert'
They will be analysed ascendingly in the following order:
insert' < sort'
insert' = choose'
Proved the following rewrite lemma:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(_n6), _gen_0':s'4(_n6)) → cons'(_gen_0':s'4(a), _gen_nil':cons'3(1)), rt ∈ Ω(1 + n6)
Induction Base:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(0), _gen_0':s'4(0)) →RΩ(1)
cons'(_gen_0':s'4(a), cons'(0', _gen_nil':cons'3(0)))
Induction Step:
choose'(_gen_0':s'4(_a8312), _gen_nil':cons'3(1), _gen_0':s'4(+(_$n7, 1)), _gen_0':s'4(+(_$n7, 1))) →RΩ(1)
choose'(_gen_0':s'4(_a8312), cons'(0', _gen_nil':cons'3(0)), _gen_0':s'4(_$n7), _gen_0':s'4(_$n7)) →IH
cons'(_gen_0':s'4(_a8312), _gen_nil':cons'3(1))
We have rt ∈ Ω(n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).
Rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Types:
sort' :: nil':cons' → nil':cons'
nil' :: nil':cons'
cons' :: 0':s' → nil':cons' → nil':cons'
insert' :: 0':s' → nil':cons' → nil':cons'
choose' :: 0':s' → nil':cons' → 0':s' → 0':s' → nil':cons'
0' :: 0':s'
s' :: 0':s' → 0':s'
_hole_nil':cons'1 :: nil':cons'
_hole_0':s'2 :: 0':s'
_gen_nil':cons'3 :: Nat → nil':cons'
_gen_0':s'4 :: Nat → 0':s'
Lemmas:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(_n6), _gen_0':s'4(_n6)) → cons'(_gen_0':s'4(a), _gen_nil':cons'3(1)), rt ∈ Ω(1 + n6)
Generator Equations:
_gen_nil':cons'3(0) ⇔ nil'
_gen_nil':cons'3(+(x, 1)) ⇔ cons'(0', _gen_nil':cons'3(x))
_gen_0':s'4(0) ⇔ 0'
_gen_0':s'4(+(x, 1)) ⇔ s'(_gen_0':s'4(x))
The following defined symbols remain to be analysed:
insert', sort'
They will be analysed ascendingly in the following order:
insert' < sort'
insert' = choose'
Could not prove a rewrite lemma for the defined symbol insert'.
Rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Types:
sort' :: nil':cons' → nil':cons'
nil' :: nil':cons'
cons' :: 0':s' → nil':cons' → nil':cons'
insert' :: 0':s' → nil':cons' → nil':cons'
choose' :: 0':s' → nil':cons' → 0':s' → 0':s' → nil':cons'
0' :: 0':s'
s' :: 0':s' → 0':s'
_hole_nil':cons'1 :: nil':cons'
_hole_0':s'2 :: 0':s'
_gen_nil':cons'3 :: Nat → nil':cons'
_gen_0':s'4 :: Nat → 0':s'
Lemmas:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(_n6), _gen_0':s'4(_n6)) → cons'(_gen_0':s'4(a), _gen_nil':cons'3(1)), rt ∈ Ω(1 + n6)
Generator Equations:
_gen_nil':cons'3(0) ⇔ nil'
_gen_nil':cons'3(+(x, 1)) ⇔ cons'(0', _gen_nil':cons'3(x))
_gen_0':s'4(0) ⇔ 0'
_gen_0':s'4(+(x, 1)) ⇔ s'(_gen_0':s'4(x))
The following defined symbols remain to be analysed:
sort'
Proved the following rewrite lemma:
sort'(_gen_nil':cons'3(_n9555)) → _*5, rt ∈ Ω(n9555)
Induction Base:
sort'(_gen_nil':cons'3(0))
Induction Step:
sort'(_gen_nil':cons'3(+(_$n9556, 1))) →RΩ(1)
insert'(0', sort'(_gen_nil':cons'3(_$n9556))) →IH
insert'(0', _*5)
We have rt ∈ Ω(n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).
Rules:
sort'(nil') → nil'
sort'(cons'(x, y)) → insert'(x, sort'(y))
insert'(x, nil') → cons'(x, nil')
insert'(x, cons'(v, w)) → choose'(x, cons'(v, w), x, v)
choose'(x, cons'(v, w), y, 0') → cons'(x, cons'(v, w))
choose'(x, cons'(v, w), 0', s'(z)) → cons'(v, insert'(x, w))
choose'(x, cons'(v, w), s'(y), s'(z)) → choose'(x, cons'(v, w), y, z)
Types:
sort' :: nil':cons' → nil':cons'
nil' :: nil':cons'
cons' :: 0':s' → nil':cons' → nil':cons'
insert' :: 0':s' → nil':cons' → nil':cons'
choose' :: 0':s' → nil':cons' → 0':s' → 0':s' → nil':cons'
0' :: 0':s'
s' :: 0':s' → 0':s'
_hole_nil':cons'1 :: nil':cons'
_hole_0':s'2 :: 0':s'
_gen_nil':cons'3 :: Nat → nil':cons'
_gen_0':s'4 :: Nat → 0':s'
Lemmas:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(_n6), _gen_0':s'4(_n6)) → cons'(_gen_0':s'4(a), _gen_nil':cons'3(1)), rt ∈ Ω(1 + n6)
sort'(_gen_nil':cons'3(_n9555)) → _*5, rt ∈ Ω(n9555)
Generator Equations:
_gen_nil':cons'3(0) ⇔ nil'
_gen_nil':cons'3(+(x, 1)) ⇔ cons'(0', _gen_nil':cons'3(x))
_gen_0':s'4(0) ⇔ 0'
_gen_0':s'4(+(x, 1)) ⇔ s'(_gen_0':s'4(x))
No more defined symbols left to analyse.
The lowerbound Ω(n) was proven with the following lemma:
choose'(_gen_0':s'4(a), _gen_nil':cons'3(1), _gen_0':s'4(_n6), _gen_0':s'4(_n6)) → cons'(_gen_0':s'4(a), _gen_nil':cons'3(1)), rt ∈ Ω(1 + n6)