0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 241 ms)
↳10 BOUNDS(1, n^2)
le(0, y) → true
le(s(x), 0) → false
le(s(x), s(y)) → le(x, y)
int(x, y) → if(le(x, y), x, y)
if(true, x, y) → cons(x, int(s(x), y))
if(false, x, y) → nil
le(0, y) → true [1]
le(s(x), 0) → false [1]
le(s(x), s(y)) → le(x, y) [1]
int(x, y) → if(le(x, y), x, y) [1]
if(true, x, y) → cons(x, int(s(x), y)) [1]
if(false, x, y) → nil [1]
le(0, y) → true [1]
le(s(x), 0) → false [1]
le(s(x), s(y)) → le(x, y) [1]
int(x, y) → if(le(x, y), x, y) [1]
if(true, x, y) → cons(x, int(s(x), y)) [1]
if(false, x, y) → nil [1]
le :: 0:s → 0:s → true:false 0 :: 0:s true :: true:false s :: 0:s → 0:s false :: true:false int :: 0:s → 0:s → cons:nil if :: true:false → 0:s → 0:s → cons:nil cons :: 0:s → cons:nil → cons:nil nil :: cons:nil |
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
true => 1
false => 0
nil => 0
if(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
if(z, z', z'') -{ 1 }→ 1 + x + int(1 + x, y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
int(z, z') -{ 1 }→ if(le(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
le(z, z') -{ 1 }→ le(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
le(z, z') -{ 1 }→ 1 :|: y >= 0, z = 0, z' = y
le(z, z') -{ 1 }→ 0 :|: x >= 0, z = 1 + x, z' = 0
eq(start(V, V1, V8),0,[le(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V8),0,[int(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V8),0,[if(V, V1, V8, Out)],[V >= 0,V1 >= 0,V8 >= 0]). eq(le(V, V1, Out),1,[],[Out = 1,V2 >= 0,V = 0,V1 = V2]). eq(le(V, V1, Out),1,[],[Out = 0,V3 >= 0,V = 1 + V3,V1 = 0]). eq(le(V, V1, Out),1,[le(V4, V5, Ret)],[Out = Ret,V1 = 1 + V5,V4 >= 0,V5 >= 0,V = 1 + V4]). eq(int(V, V1, Out),1,[le(V6, V7, Ret0),if(Ret0, V6, V7, Ret1)],[Out = Ret1,V6 >= 0,V7 >= 0,V = V6,V1 = V7]). eq(if(V, V1, V8, Out),1,[int(1 + V9, V10, Ret11)],[Out = 1 + Ret11 + V9,V1 = V9,V8 = V10,V = 1,V9 >= 0,V10 >= 0]). eq(if(V, V1, V8, Out),1,[],[Out = 0,V1 = V11,V8 = V12,V11 >= 0,V12 >= 0,V = 0]). input_output_vars(le(V,V1,Out),[V,V1],[Out]). input_output_vars(int(V,V1,Out),[V,V1],[Out]). input_output_vars(if(V,V1,V8,Out),[V,V1,V8],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [le/3]
1. recursive : [if/4,int/3]
2. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into le/3
1. SCC is partially evaluated into int/3
2. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations le/3
* CE 10 is refined into CE [11]
* CE 9 is refined into CE [12]
* CE 8 is refined into CE [13]
### Cost equations --> "Loop" of le/3
* CEs [12] --> Loop 8
* CEs [13] --> Loop 9
* CEs [11] --> Loop 10
### Ranking functions of CR le(V,V1,Out)
* RF of phase [10]: [V,V1]
#### Partial ranking functions of CR le(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V
V1
### Specialization of cost equations int/3
* CE 7 is refined into CE [14,15]
* CE 6 is refined into CE [16,17]
### Cost equations --> "Loop" of int/3
* CEs [17] --> Loop 11
* CEs [16] --> Loop 12
* CEs [15] --> Loop 13
* CEs [14] --> Loop 14
### Ranking functions of CR int(V,V1,Out)
* RF of phase [13]: [-V+V1+1]
#### Partial ranking functions of CR int(V,V1,Out)
* Partial RF of phase [13]:
- RF of loop [13:1]:
-V+V1+1
### Specialization of cost equations start/3
* CE 3 is refined into CE [18,19,20]
* CE 2 is refined into CE [21]
* CE 4 is refined into CE [22,23,24,25]
* CE 5 is refined into CE [26,27,28,29,30]
### Cost equations --> "Loop" of start/3
* CEs [24,29] --> Loop 15
* CEs [23,28] --> Loop 16
* CEs [19,25,30] --> Loop 17
* CEs [20] --> Loop 18
* CEs [18] --> Loop 19
* CEs [21,22,26,27] --> Loop 20
### Ranking functions of CR start(V,V1,V8)
#### Partial ranking functions of CR start(V,V1,V8)
Computing Bounds
=====================================
#### Cost of chains of le(V,V1,Out):
* Chain [[10],9]: 1*it(10)+1
Such that:it(10) =< V
with precondition: [Out=1,V>=1,V1>=V]
* Chain [[10],8]: 1*it(10)+1
Such that:it(10) =< V1
with precondition: [Out=0,V1>=1,V>=V1+1]
* Chain [9]: 1
with precondition: [V=0,Out=1,V1>=0]
* Chain [8]: 1
with precondition: [V1=0,Out=0,V>=1]
#### Cost of chains of int(V,V1,Out):
* Chain [[13],11]: 3*it(13)+1*s(1)+1*s(4)+3
Such that:it(13) =< -V+V1+1
s(1) =< V1
aux(1) =< V1+1
s(4) =< it(13)*aux(1)
with precondition: [V>=1,V1>=V,Out+2*V>=3*V1+1]
* Chain [14,[13],11]: 4*it(13)+1*s(4)+6
Such that:aux(1) =< V1+1
aux(2) =< V1
it(13) =< aux(2)
s(4) =< it(13)*aux(1)
with precondition: [V=0,V1>=1,Out>=3*V1]
* Chain [14,12]: 6
with precondition: [V=0,V1=0,Out=1]
* Chain [12]: 3
with precondition: [V1=0,Out=0,V>=1]
* Chain [11]: 1*s(1)+3
Such that:s(1) =< V1
with precondition: [Out=0,V1>=1,V>=V1+1]
#### Cost of chains of start(V,V1,V8):
* Chain [20]: 4*s(7)+1*s(8)+6
Such that:s(6) =< V1
s(5) =< V1+1
s(7) =< s(6)
s(8) =< s(7)*s(5)
with precondition: [V=0,V1>=0]
* Chain [19]: 4
with precondition: [V=1,V8=0,V1>=0]
* Chain [18]: 3*s(9)+1*s(10)+1*s(12)+4
Such that:s(9) =< -V1+V8
s(10) =< V8
s(11) =< V8+1
s(12) =< s(9)*s(11)
with precondition: [V=1,V1>=0,V8>=V1+1]
* Chain [17]: 1*s(13)+1*s(14)+3*s(15)+1*s(16)+1*s(18)+4
Such that:s(15) =< -V+V1+1
s(14) =< V
s(16) =< V1
s(17) =< V1+1
s(13) =< V8
s(18) =< s(15)*s(17)
with precondition: [V>=1,V1>=V]
* Chain [16]: 3
with precondition: [V1=0,V>=1]
* Chain [15]: 2*s(19)+3
Such that:aux(3) =< V1
s(19) =< aux(3)
with precondition: [V1>=1,V>=V1+1]
Closed-form bounds of start(V,V1,V8):
-------------------------------------
* Chain [20] with precondition: [V=0,V1>=0]
- Upper bound: 4*V1+6+ (V1+1)*V1
- Complexity: n^2
* Chain [19] with precondition: [V=1,V8=0,V1>=0]
- Upper bound: 4
- Complexity: constant
* Chain [18] with precondition: [V=1,V1>=0,V8>=V1+1]
- Upper bound: V8+4+ (-V1+V8)* (V8+1)+ (-3*V1+3*V8)
- Complexity: n^2
* Chain [17] with precondition: [V>=1,V1>=V]
- Upper bound: V+V1+4+nat(V8)+ (-V+V1+1)* (V1+1)+ (-3*V+3*V1+3)
- Complexity: n^2
* Chain [16] with precondition: [V1=0,V>=1]
- Upper bound: 3
- Complexity: constant
* Chain [15] with precondition: [V1>=1,V>=V1+1]
- Upper bound: 2*V1+3
- Complexity: n
### Maximum cost of start(V,V1,V8): max([max([1,nat(V8)+1+nat(-V1+V8)*nat(V8+1)+nat(-V1+V8)*3]),max([2*V1+3+ (V1+1)*V1+V1,V+1+nat(V8)+ (V1+1)*nat(-V+V1+1)+nat(-V+V1+1)*3])+V1])+3
Asymptotic class: n^2
* Total analysis performed in 192 ms.