0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 3 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 180 ms)
↳10 BOUNDS(1, n^1)
half(0) → 0
half(s(0)) → 0
half(s(s(x))) → s(half(x))
bits(0) → 0
bits(s(x)) → s(bits(half(s(x))))
half(0) → 0 [1]
half(s(0)) → 0 [1]
half(s(s(x))) → s(half(x)) [1]
bits(0) → 0 [1]
bits(s(x)) → s(bits(half(s(x)))) [1]
half(0) → 0 [1]
half(s(0)) → 0 [1]
half(s(s(x))) → s(half(x)) [1]
bits(0) → 0 [1]
bits(s(x)) → s(bits(half(s(x)))) [1]
half :: 0:s → 0:s 0 :: 0:s s :: 0:s → 0:s bits :: 0:s → 0:s |
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
bits(z) -{ 1 }→ 0 :|: z = 0
bits(z) -{ 1 }→ 1 + bits(half(1 + x)) :|: x >= 0, z = 1 + x
half(z) -{ 1 }→ 0 :|: z = 0
half(z) -{ 1 }→ 0 :|: z = 1 + 0
half(z) -{ 1 }→ 1 + half(x) :|: x >= 0, z = 1 + (1 + x)
eq(start(V),0,[half(V, Out)],[V >= 0]). eq(start(V),0,[bits(V, Out)],[V >= 0]). eq(half(V, Out),1,[],[Out = 0,V = 0]). eq(half(V, Out),1,[],[Out = 0,V = 1]). eq(half(V, Out),1,[half(V1, Ret1)],[Out = 1 + Ret1,V1 >= 0,V = 2 + V1]). eq(bits(V, Out),1,[],[Out = 0,V = 0]). eq(bits(V, Out),1,[half(1 + V2, Ret10),bits(Ret10, Ret11)],[Out = 1 + Ret11,V2 >= 0,V = 1 + V2]). input_output_vars(half(V,Out),[V],[Out]). input_output_vars(bits(V,Out),[V],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [half/2]
1. recursive : [bits/2]
2. non_recursive : [start/1]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into half/2
1. SCC is partially evaluated into bits/2
2. SCC is partially evaluated into start/1
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations half/2
* CE 6 is refined into CE [9]
* CE 5 is refined into CE [10]
* CE 4 is refined into CE [11]
### Cost equations --> "Loop" of half/2
* CEs [10] --> Loop 7
* CEs [11] --> Loop 8
* CEs [9] --> Loop 9
### Ranking functions of CR half(V,Out)
* RF of phase [9]: [V-1]
#### Partial ranking functions of CR half(V,Out)
* Partial RF of phase [9]:
- RF of loop [9:1]:
V-1
### Specialization of cost equations bits/2
* CE 8 is refined into CE [12,13,14]
* CE 7 is refined into CE [15]
### Cost equations --> "Loop" of bits/2
* CEs [15] --> Loop 10
* CEs [14] --> Loop 11
* CEs [13] --> Loop 12
* CEs [12] --> Loop 13
### Ranking functions of CR bits(V,Out)
* RF of phase [11,12]: [V-1]
#### Partial ranking functions of CR bits(V,Out)
* Partial RF of phase [11,12]:
- RF of loop [11:1]:
V/2-1
- RF of loop [12:1]:
V-1
### Specialization of cost equations start/1
* CE 2 is refined into CE [16,17,18,19]
* CE 3 is refined into CE [20,21,22]
### Cost equations --> "Loop" of start/1
* CEs [18,19,22] --> Loop 14
* CEs [17,21] --> Loop 15
* CEs [16,20] --> Loop 16
### Ranking functions of CR start(V)
#### Partial ranking functions of CR start(V)
Computing Bounds
=====================================
#### Cost of chains of half(V,Out):
* Chain [[9],8]: 1*it(9)+1
Such that:it(9) =< 2*Out
with precondition: [V=2*Out,V>=2]
* Chain [[9],7]: 1*it(9)+1
Such that:it(9) =< 2*Out
with precondition: [V=2*Out+1,V>=3]
* Chain [8]: 1
with precondition: [V=0,Out=0]
* Chain [7]: 1
with precondition: [V=1,Out=0]
#### Cost of chains of bits(V,Out):
* Chain [[11,12],13,10]: 2*it(11)+2*it(12)+2*s(5)+3
Such that:it(11) =< V/2
aux(5) =< V
aux(6) =< 2*V
it(11) =< aux(5)
it(12) =< aux(5)
it(12) =< aux(6)
s(5) =< aux(6)
with precondition: [Out>=2,V+2>=2*Out]
* Chain [13,10]: 3
with precondition: [V=1,Out=1]
* Chain [10]: 1
with precondition: [V=0,Out=0]
#### Cost of chains of start(V):
* Chain [16]: 1
with precondition: [V=0]
* Chain [15]: 3
with precondition: [V=1]
* Chain [14]: 2*s(7)+2*s(9)+2*s(12)+2*s(13)+3
Such that:s(11) =< 2*V
s(9) =< V/2
aux(7) =< V
s(7) =< aux(7)
s(9) =< aux(7)
s(12) =< aux(7)
s(12) =< s(11)
s(13) =< s(11)
with precondition: [V>=2]
Closed-form bounds of start(V):
-------------------------------------
* Chain [16] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [15] with precondition: [V=1]
- Upper bound: 3
- Complexity: constant
* Chain [14] with precondition: [V>=2]
- Upper bound: 9*V+3
- Complexity: n
### Maximum cost of start(V): 9*V+3
Asymptotic class: n
* Total analysis performed in 128 ms.