0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 7 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 363 ms)
↳10 BOUNDS(1, n^2)
lt(0, s(x)) → true
lt(x, 0) → false
lt(s(x), s(y)) → lt(x, y)
fac(x) → help(x, 0)
help(x, c) → if(lt(c, x), x, c)
if(true, x, c) → times(s(c), help(x, s(c)))
if(false, x, c) → s(0)
lt(0, s(x)) → true [1]
lt(x, 0) → false [1]
lt(s(x), s(y)) → lt(x, y) [1]
fac(x) → help(x, 0) [1]
help(x, c) → if(lt(c, x), x, c) [1]
if(true, x, c) → times(s(c), help(x, s(c))) [1]
if(false, x, c) → s(0) [1]
lt(0, s(x)) → true [1]
lt(x, 0) → false [1]
lt(s(x), s(y)) → lt(x, y) [1]
fac(x) → help(x, 0) [1]
help(x, c) → if(lt(c, x), x, c) [1]
if(true, x, c) → times(s(c), help(x, s(c))) [1]
if(false, x, c) → s(0) [1]
lt :: 0:s:times → 0:s:times → true:false 0 :: 0:s:times s :: 0:s:times → 0:s:times true :: true:false false :: true:false fac :: 0:s:times → 0:s:times help :: 0:s:times → 0:s:times → 0:s:times if :: true:false → 0:s:times → 0:s:times → 0:s:times times :: 0:s:times → 0:s:times → 0:s:times |
lt(v0, v1) → null_lt [0]
if(v0, v1, v2) → null_if [0]
null_lt, null_if
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 => 2
false => 1
null_lt => 0
null_if => 0
fac(z) -{ 1 }→ help(x, 0) :|: x >= 0, z = x
help(z, z') -{ 1 }→ if(lt(c, x), x, c) :|: c >= 0, x >= 0, z' = c, z = x
if(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
if(z, z', z'') -{ 1 }→ 1 + 0 :|: z' = x, c >= 0, z = 1, x >= 0, z'' = c
if(z, z', z'') -{ 1 }→ 1 + (1 + c) + help(x, 1 + c) :|: z = 2, z' = x, c >= 0, x >= 0, z'' = c
lt(z, z') -{ 1 }→ lt(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
lt(z, z') -{ 1 }→ 2 :|: z' = 1 + x, x >= 0, z = 0
lt(z, z') -{ 1 }→ 1 :|: x >= 0, z = x, z' = 0
lt(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
eq(start(V, V1, V9),0,[lt(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V9),0,[fac(V, Out)],[V >= 0]). eq(start(V, V1, V9),0,[help(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V9),0,[if(V, V1, V9, Out)],[V >= 0,V1 >= 0,V9 >= 0]). eq(lt(V, V1, Out),1,[],[Out = 2,V1 = 1 + V2,V2 >= 0,V = 0]). eq(lt(V, V1, Out),1,[],[Out = 1,V3 >= 0,V = V3,V1 = 0]). eq(lt(V, V1, Out),1,[lt(V4, V5, Ret)],[Out = Ret,V1 = 1 + V5,V4 >= 0,V5 >= 0,V = 1 + V4]). eq(fac(V, Out),1,[help(V6, 0, Ret1)],[Out = Ret1,V6 >= 0,V = V6]). eq(help(V, V1, Out),1,[lt(V7, V8, Ret0),if(Ret0, V8, V7, Ret2)],[Out = Ret2,V7 >= 0,V8 >= 0,V1 = V7,V = V8]). eq(if(V, V1, V9, Out),1,[help(V11, 1 + V10, Ret11)],[Out = 2 + Ret11 + V10,V = 2,V1 = V11,V10 >= 0,V11 >= 0,V9 = V10]). eq(if(V, V1, V9, Out),1,[],[Out = 1,V1 = V12,V13 >= 0,V = 1,V12 >= 0,V9 = V13]). eq(lt(V, V1, Out),0,[],[Out = 0,V14 >= 0,V15 >= 0,V = V14,V1 = V15]). eq(if(V, V1, V9, Out),0,[],[Out = 0,V16 >= 0,V9 = V17,V18 >= 0,V = V16,V1 = V18,V17 >= 0]). input_output_vars(lt(V,V1,Out),[V,V1],[Out]). input_output_vars(fac(V,Out),[V],[Out]). input_output_vars(help(V,V1,Out),[V,V1],[Out]). input_output_vars(if(V,V1,V9,Out),[V,V1,V9],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [lt/3]
1. recursive : [help/3,if/4]
2. non_recursive : [fac/2]
3. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into lt/3
1. SCC is partially evaluated into help/3
2. SCC is completely evaluated into other SCCs
3. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations lt/3
* CE 14 is refined into CE [15]
* CE 12 is refined into CE [16]
* CE 11 is refined into CE [17]
* CE 13 is refined into CE [18]
### Cost equations --> "Loop" of lt/3
* CEs [18] --> Loop 10
* CEs [15] --> Loop 11
* CEs [16] --> Loop 12
* CEs [17] --> Loop 13
### Ranking functions of CR lt(V,V1,Out)
* RF of phase [10]: [V,V1]
#### Partial ranking functions of CR lt(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V
V1
### Specialization of cost equations help/3
* CE 10 is refined into CE [19,20]
* CE 9 is refined into CE [21,22]
* CE 8 is refined into CE [23,24,25,26,27]
### Cost equations --> "Loop" of help/3
* CEs [22] --> Loop 14
* CEs [23] --> Loop 15
* CEs [21] --> Loop 16
* CEs [24,25,26,27] --> Loop 17
* CEs [20] --> Loop 18
* CEs [19] --> Loop 19
### Ranking functions of CR help(V,V1,Out)
* RF of phase [18]: [V-V1]
#### Partial ranking functions of CR help(V,V1,Out)
* Partial RF of phase [18]:
- RF of loop [18:1]:
V-V1
### Specialization of cost equations start/3
* CE 4 is refined into CE [28,29,30,31]
* CE 2 is refined into CE [32]
* CE 3 is refined into CE [33]
* CE 5 is refined into CE [34,35,36,37,38]
* CE 6 is refined into CE [39,40,41,42,43]
* CE 7 is refined into CE [44,45,46,47,48,49,50]
### Cost equations --> "Loop" of start/3
* CEs [35,47,48] --> Loop 20
* CEs [28,29,30,31] --> Loop 21
* CEs [33,40,45] --> Loop 22
* CEs [32,34,36,37,38,39,41,42,43,44,46,49,50] --> Loop 23
### Ranking functions of CR start(V,V1,V9)
#### Partial ranking functions of CR start(V,V1,V9)
Computing Bounds
=====================================
#### Cost of chains of lt(V,V1,Out):
* Chain [[10],13]: 1*it(10)+1
Such that:it(10) =< V
with precondition: [Out=2,V>=1,V1>=V+1]
* Chain [[10],12]: 1*it(10)+1
Such that:it(10) =< V1
with precondition: [Out=1,V1>=1,V>=V1]
* Chain [[10],11]: 1*it(10)+0
Such that:it(10) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [13]: 1
with precondition: [V=0,Out=2,V1>=1]
* Chain [12]: 1
with precondition: [V1=0,Out=1,V>=0]
* Chain [11]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of help(V,V1,Out):
* Chain [[18],17]: 3*it(18)+3*s(2)+1*s(7)+2
Such that:it(18) =< V-V1
aux(3) =< V
s(2) =< aux(3)
s(7) =< it(18)*aux(3)
with precondition: [V1>=1,V>=V1+1,Out>=V1+2]
* Chain [[18],14]: 3*it(18)+1*s(7)+1*s(8)+3
Such that:it(18) =< V-V1
aux(4) =< V
s(8) =< aux(4)
s(7) =< it(18)*aux(4)
with precondition: [V1>=1,V>=V1+1,Out+3*V1+1>=4*V]
* Chain [19,[18],17]: 6*it(18)+1*s(7)+5
Such that:aux(5) =< V
it(18) =< aux(5)
s(7) =< it(18)*aux(5)
with precondition: [V1=0,V>=2,Out>=5]
* Chain [19,[18],14]: 4*it(18)+1*s(7)+6
Such that:aux(6) =< V
it(18) =< aux(6)
s(7) =< it(18)*aux(6)
with precondition: [V1=0,V>=2,Out+2>=4*V]
* Chain [19,17]: 2*s(2)+1*s(4)+5
Such that:s(4) =< 1
aux(1) =< V
s(2) =< aux(1)
with precondition: [V1=0,Out=2,V>=1]
* Chain [19,14]: 1*s(8)+6
Such that:s(8) =< 1
with precondition: [V=1,V1=0,Out=3]
* Chain [17]: 2*s(2)+1*s(4)+2
Such that:s(4) =< V1
aux(1) =< V
s(2) =< aux(1)
with precondition: [Out=0,V>=0,V1>=0]
* Chain [16]: 3
with precondition: [V=0,Out=1,V1>=0]
* Chain [15]: 2
with precondition: [V1=0,Out=0,V>=1]
* Chain [14]: 1*s(8)+3
Such that:s(8) =< V
with precondition: [Out=1,V>=1,V1>=V]
#### Cost of chains of start(V,V1,V9):
* Chain [23]: 3*s(26)+22*s(28)+1*s(32)+2*s(37)+6*s(44)+2*s(46)+7
Such that:s(32) =< 1
s(43) =< V-V1
aux(10) =< V
aux(11) =< V1
s(28) =< aux(10)
s(26) =< aux(11)
s(37) =< s(28)*aux(10)
s(44) =< s(43)
s(46) =< s(44)*aux(10)
with precondition: [V>=0]
* Chain [22]: 9
with precondition: [V=1]
* Chain [21]: 1*s(50)+7*s(51)+6*s(55)+2*s(57)+4
Such that:s(54) =< V1-V9
s(50) =< V9+1
aux(13) =< V1
s(51) =< aux(13)
s(55) =< s(54)
s(57) =< s(55)*aux(13)
with precondition: [V=2,V1>=0,V9>=0]
* Chain [20]: 1*s(58)+12*s(60)+2*s(63)+6
Such that:s(58) =< 1
aux(14) =< V
s(60) =< aux(14)
s(63) =< s(60)*aux(14)
with precondition: [V1=0,V>=0]
Closed-form bounds of start(V,V1,V9):
-------------------------------------
* Chain [23] with precondition: [V>=0]
- Upper bound: 22*V+8+2*V*V+2*V*nat(V-V1)+nat(V1)*3+nat(V-V1)*6
- Complexity: n^2
* Chain [22] with precondition: [V=1]
- Upper bound: 9
- Complexity: constant
* Chain [21] with precondition: [V=2,V1>=0,V9>=0]
- Upper bound: 7*V1+4+2*V1*nat(V1-V9)+ (V9+1)+nat(V1-V9)*6
- Complexity: n^2
* Chain [20] with precondition: [V1=0,V>=0]
- Upper bound: 12*V+7+2*V*V
- Complexity: n^2
### Maximum cost of start(V,V1,V9): max([max([5,nat(V1)*2*nat(V1-V9)+nat(V1)*7+nat(V9+1)+nat(V1-V9)*6]),10*V+1+2*V*nat(V-V1)+nat(V1)*3+nat(V-V1)*6+ (12*V+3+2*V*V)])+4
Asymptotic class: n^2
* Total analysis performed in 270 ms.