(0) Obligation:
Runtime Complexity TRS:
The TRS R consists of the following rules:
bsort(nil) → nil
bsort(.(x, y)) → last(.(bubble(.(x, y)), bsort(butlast(bubble(.(x, y))))))
bubble(nil) → nil
bubble(.(x, nil)) → .(x, nil)
bubble(.(x, .(y, z))) → if(<=(x, y), .(y, bubble(.(x, z))), .(x, bubble(.(y, z))))
last(nil) → 0
last(.(x, nil)) → x
last(.(x, .(y, z))) → last(.(y, z))
butlast(nil) → nil
butlast(.(x, nil)) → nil
butlast(.(x, .(y, z))) → .(x, butlast(.(y, z)))
Rewrite Strategy: FULL
(1) RenamingProof (EQUIVALENT transformation)
Renamed function symbols to avoid clashes with predefined symbol.
(2) Obligation:
Runtime Complexity Relative TRS:
The TRS R consists of the following rules:
bsort(nil) → nil
bsort(.(x, y)) → last(.(bubble(.(x, y)), bsort(butlast(bubble(.(x, y))))))
bubble(nil) → nil
bubble(.(x, nil)) → .(x, nil)
bubble(.(x, .(y, z))) → if(<=(x, y), .(y, bubble(.(x, z))), .(x, bubble(.(y, z))))
last(nil) → 0'
last(.(x, nil)) → x
last(.(x, .(y, z))) → last(.(y, z))
butlast(nil) → nil
butlast(.(x, nil)) → nil
butlast(.(x, .(y, z))) → .(x, butlast(.(y, z)))
S is empty.
Rewrite Strategy: FULL
(3) SlicingProof (LOWER BOUND(ID) transformation)
Sliced the following arguments:
if/0
<=/0
<=/1
(4) Obligation:
Runtime Complexity Relative TRS:
The TRS R consists of the following rules:
bsort(nil) → nil
bsort(.(x, y)) → last(.(bubble(.(x, y)), bsort(butlast(bubble(.(x, y))))))
bubble(nil) → nil
bubble(.(x, nil)) → .(x, nil)
bubble(.(x, .(y, z))) → if(.(y, bubble(.(x, z))), .(x, bubble(.(y, z))))
last(nil) → 0'
last(.(x, nil)) → x
last(.(x, .(y, z))) → last(.(y, z))
butlast(nil) → nil
butlast(.(x, nil)) → nil
butlast(.(x, .(y, z))) → .(x, butlast(.(y, z)))
S is empty.
Rewrite Strategy: FULL
(5) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)
Infered types.
(6) Obligation:
TRS:
Rules:
bsort(nil) → nil
bsort(.(x, y)) → last(.(bubble(.(x, y)), bsort(butlast(bubble(.(x, y))))))
bubble(nil) → nil
bubble(.(x, nil)) → .(x, nil)
bubble(.(x, .(y, z))) → if(.(y, bubble(.(x, z))), .(x, bubble(.(y, z))))
last(nil) → 0'
last(.(x, nil)) → x
last(.(x, .(y, z))) → last(.(y, z))
butlast(nil) → nil
butlast(.(x, nil)) → nil
butlast(.(x, .(y, z))) → .(x, butlast(.(y, z)))
Types:
bsort :: nil:.:if:0' → nil:.:if:0'
nil :: nil:.:if:0'
. :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
last :: nil:.:if:0' → nil:.:if:0'
bubble :: nil:.:if:0' → nil:.:if:0'
butlast :: nil:.:if:0' → nil:.:if:0'
if :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
0' :: nil:.:if:0'
hole_nil:.:if:0'1_0 :: nil:.:if:0'
gen_nil:.:if:0'2_0 :: Nat → nil:.:if:0'
(7) OrderProof (LOWER BOUND(ID) transformation)
Heuristically decided to analyse the following defined symbols:
bsort,
last,
bubble,
butlastThey will be analysed ascendingly in the following order:
last < bsort
bubble < bsort
butlast < bsort
(8) Obligation:
TRS:
Rules:
bsort(
nil) →
nilbsort(
.(
x,
y)) →
last(
.(
bubble(
.(
x,
y)),
bsort(
butlast(
bubble(
.(
x,
y))))))
bubble(
nil) →
nilbubble(
.(
x,
nil)) →
.(
x,
nil)
bubble(
.(
x,
.(
y,
z))) →
if(
.(
y,
bubble(
.(
x,
z))),
.(
x,
bubble(
.(
y,
z))))
last(
nil) →
0'last(
.(
x,
nil)) →
xlast(
.(
x,
.(
y,
z))) →
last(
.(
y,
z))
butlast(
nil) →
nilbutlast(
.(
x,
nil)) →
nilbutlast(
.(
x,
.(
y,
z))) →
.(
x,
butlast(
.(
y,
z)))
Types:
bsort :: nil:.:if:0' → nil:.:if:0'
nil :: nil:.:if:0'
. :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
last :: nil:.:if:0' → nil:.:if:0'
bubble :: nil:.:if:0' → nil:.:if:0'
butlast :: nil:.:if:0' → nil:.:if:0'
if :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
0' :: nil:.:if:0'
hole_nil:.:if:0'1_0 :: nil:.:if:0'
gen_nil:.:if:0'2_0 :: Nat → nil:.:if:0'
Generator Equations:
gen_nil:.:if:0'2_0(0) ⇔ nil
gen_nil:.:if:0'2_0(+(x, 1)) ⇔ .(nil, gen_nil:.:if:0'2_0(x))
The following defined symbols remain to be analysed:
last, bsort, bubble, butlast
They will be analysed ascendingly in the following order:
last < bsort
bubble < bsort
butlast < bsort
(9) RewriteLemmaProof (LOWER BOUND(ID) transformation)
Proved the following rewrite lemma:
last(
gen_nil:.:if:0'2_0(
+(
1,
n4_0))) →
gen_nil:.:if:0'2_0(
0), rt ∈ Ω(1 + n4
0)
Induction Base:
last(gen_nil:.:if:0'2_0(+(1, 0))) →RΩ(1)
nil
Induction Step:
last(gen_nil:.:if:0'2_0(+(1, +(n4_0, 1)))) →RΩ(1)
last(.(nil, gen_nil:.:if:0'2_0(n4_0))) →IH
gen_nil:.:if:0'2_0(0)
We have rt ∈ Ω(n1) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).
(10) Complex Obligation (BEST)
(11) Obligation:
TRS:
Rules:
bsort(
nil) →
nilbsort(
.(
x,
y)) →
last(
.(
bubble(
.(
x,
y)),
bsort(
butlast(
bubble(
.(
x,
y))))))
bubble(
nil) →
nilbubble(
.(
x,
nil)) →
.(
x,
nil)
bubble(
.(
x,
.(
y,
z))) →
if(
.(
y,
bubble(
.(
x,
z))),
.(
x,
bubble(
.(
y,
z))))
last(
nil) →
0'last(
.(
x,
nil)) →
xlast(
.(
x,
.(
y,
z))) →
last(
.(
y,
z))
butlast(
nil) →
nilbutlast(
.(
x,
nil)) →
nilbutlast(
.(
x,
.(
y,
z))) →
.(
x,
butlast(
.(
y,
z)))
Types:
bsort :: nil:.:if:0' → nil:.:if:0'
nil :: nil:.:if:0'
. :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
last :: nil:.:if:0' → nil:.:if:0'
bubble :: nil:.:if:0' → nil:.:if:0'
butlast :: nil:.:if:0' → nil:.:if:0'
if :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
0' :: nil:.:if:0'
hole_nil:.:if:0'1_0 :: nil:.:if:0'
gen_nil:.:if:0'2_0 :: Nat → nil:.:if:0'
Lemmas:
last(gen_nil:.:if:0'2_0(+(1, n4_0))) → gen_nil:.:if:0'2_0(0), rt ∈ Ω(1 + n40)
Generator Equations:
gen_nil:.:if:0'2_0(0) ⇔ nil
gen_nil:.:if:0'2_0(+(x, 1)) ⇔ .(nil, gen_nil:.:if:0'2_0(x))
The following defined symbols remain to be analysed:
bubble, bsort, butlast
They will be analysed ascendingly in the following order:
bubble < bsort
butlast < bsort
(12) RewriteLemmaProof (EQUIVALENT transformation)
Proved the following rewrite lemma:
bubble(
gen_nil:.:if:0'2_0(
+(
2,
n282_0))) →
*3_0, rt ∈ Ω(2
n)
Induction Base:
bubble(gen_nil:.:if:0'2_0(+(2, 0)))
Induction Step:
bubble(gen_nil:.:if:0'2_0(+(2, +(n282_0, 1)))) →RΩ(1)
if(.(nil, bubble(.(nil, gen_nil:.:if:0'2_0(+(1, n282_0))))), .(nil, bubble(.(nil, gen_nil:.:if:0'2_0(+(1, n282_0)))))) →IH
if(.(nil, *3_0), .(nil, bubble(.(nil, gen_nil:.:if:0'2_0(+(1, n282_0)))))) →IH
if(.(nil, *3_0), .(nil, *3_0))
We have rt ∈ Ω(2n) and sz ∈ O(n). Thus, we have ircR ∈ Ω(2n)
(13) BOUNDS(2^n, INF)
(14) Obligation:
TRS:
Rules:
bsort(
nil) →
nilbsort(
.(
x,
y)) →
last(
.(
bubble(
.(
x,
y)),
bsort(
butlast(
bubble(
.(
x,
y))))))
bubble(
nil) →
nilbubble(
.(
x,
nil)) →
.(
x,
nil)
bubble(
.(
x,
.(
y,
z))) →
if(
.(
y,
bubble(
.(
x,
z))),
.(
x,
bubble(
.(
y,
z))))
last(
nil) →
0'last(
.(
x,
nil)) →
xlast(
.(
x,
.(
y,
z))) →
last(
.(
y,
z))
butlast(
nil) →
nilbutlast(
.(
x,
nil)) →
nilbutlast(
.(
x,
.(
y,
z))) →
.(
x,
butlast(
.(
y,
z)))
Types:
bsort :: nil:.:if:0' → nil:.:if:0'
nil :: nil:.:if:0'
. :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
last :: nil:.:if:0' → nil:.:if:0'
bubble :: nil:.:if:0' → nil:.:if:0'
butlast :: nil:.:if:0' → nil:.:if:0'
if :: nil:.:if:0' → nil:.:if:0' → nil:.:if:0'
0' :: nil:.:if:0'
hole_nil:.:if:0'1_0 :: nil:.:if:0'
gen_nil:.:if:0'2_0 :: Nat → nil:.:if:0'
Lemmas:
last(gen_nil:.:if:0'2_0(+(1, n4_0))) → gen_nil:.:if:0'2_0(0), rt ∈ Ω(1 + n40)
Generator Equations:
gen_nil:.:if:0'2_0(0) ⇔ nil
gen_nil:.:if:0'2_0(+(x, 1)) ⇔ .(nil, gen_nil:.:if:0'2_0(x))
No more defined symbols left to analyse.
(15) LowerBoundsProof (EQUIVALENT transformation)
The lowerbound Ω(n1) was proven with the following lemma:
last(gen_nil:.:if:0'2_0(+(1, n4_0))) → gen_nil:.:if:0'2_0(0), rt ∈ Ω(1 + n40)
(16) BOUNDS(n^1, INF)