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 (⇔, 269 ms)
↳10 BOUNDS(1, n^2)
minus(x, y) → cond(min(x, y), x, y)
cond(y, x, y) → s(minus(x, s(y)))
min(0, v) → 0
min(u, 0) → 0
min(s(u), s(v)) → s(min(u, v))
minus(x, y) → cond(min(x, y), x, y) [1]
cond(y, x, y) → s(minus(x, s(y))) [1]
min(0, v) → 0 [1]
min(u, 0) → 0 [1]
min(s(u), s(v)) → s(min(u, v)) [1]
minus(x, y) → cond(min(x, y), x, y) [1]
cond(y, x, y) → s(minus(x, s(y))) [1]
min(0, v) → 0 [1]
min(u, 0) → 0 [1]
min(s(u), s(v)) → s(min(u, v)) [1]
minus :: s:0 → s:0 → s:0 cond :: s:0 → s:0 → s:0 → s:0 min :: s:0 → s:0 → s:0 s :: s:0 → s:0 0 :: s:0 |
cond(v0, v1, v2) → null_cond [0]
min(v0, v1) → null_min [0]
null_cond, null_min
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
null_cond => 0
null_min => 0
cond(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
cond(z, z', z'') -{ 1 }→ 1 + minus(x, 1 + y) :|: z' = x, z'' = y, y >= 0, x >= 0, z = y
min(z, z') -{ 1 }→ 0 :|: v >= 0, z' = v, z = 0
min(z, z') -{ 1 }→ 0 :|: z = u, z' = 0, u >= 0
min(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
min(z, z') -{ 1 }→ 1 + min(u, v) :|: v >= 0, z' = 1 + v, z = 1 + u, u >= 0
minus(z, z') -{ 1 }→ cond(min(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
eq(start(V, V1, V4),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[cond(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[min(V, V1, Out)],[V >= 0,V1 >= 0]). eq(minus(V, V1, Out),1,[min(V2, V3, Ret0),cond(Ret0, V2, V3, Ret)],[Out = Ret,V2 >= 0,V3 >= 0,V = V2,V1 = V3]). eq(cond(V, V1, V4, Out),1,[minus(V5, 1 + V6, Ret1)],[Out = 1 + Ret1,V1 = V5,V4 = V6,V6 >= 0,V5 >= 0,V = V6]). eq(min(V, V1, Out),1,[],[Out = 0,V7 >= 0,V1 = V7,V = 0]). eq(min(V, V1, Out),1,[],[Out = 0,V = V8,V1 = 0,V8 >= 0]). eq(min(V, V1, Out),1,[min(V9, V10, Ret11)],[Out = 1 + Ret11,V10 >= 0,V1 = 1 + V10,V = 1 + V9,V9 >= 0]). eq(cond(V, V1, V4, Out),0,[],[Out = 0,V11 >= 0,V4 = V12,V13 >= 0,V = V11,V1 = V13,V12 >= 0]). eq(min(V, V1, Out),0,[],[Out = 0,V14 >= 0,V15 >= 0,V = V14,V1 = V15]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(cond(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(min(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [min/3]
1. recursive : [cond/4,minus/3]
2. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into min/3
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations min/3
* CE 9 is refined into CE [12]
* CE 8 is refined into CE [13]
* CE 11 is refined into CE [14]
* CE 10 is refined into CE [15]
### Cost equations --> "Loop" of min/3
* CEs [15] --> Loop 7
* CEs [12] --> Loop 8
* CEs [13,14] --> Loop 9
### Ranking functions of CR min(V,V1,Out)
* RF of phase [7]: [V,V1]
#### Partial ranking functions of CR min(V,V1,Out)
* Partial RF of phase [7]:
- RF of loop [7:1]:
V
V1
### Specialization of cost equations minus/3
* CE 7 is refined into CE [16,17]
* CE 6 is refined into CE [18,19]
### Cost equations --> "Loop" of minus/3
* CEs [18,19] --> Loop 10
* CEs [17] --> Loop 11
* CEs [16] --> Loop 12
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [11]: [V-V1+1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V-V1+1
### Specialization of cost equations start/3
* CE 2 is refined into CE [20]
* CE 3 is refined into CE [21,22]
* CE 4 is refined into CE [23,24,25,26]
* CE 5 is refined into CE [27,28]
### Cost equations --> "Loop" of start/3
* CEs [21,22] --> Loop 13
* CEs [20,23,24,25,26,27,28] --> Loop 14
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of min(V,V1,Out):
* Chain [[7],9]: 1*it(7)+1
Such that:it(7) =< Out
with precondition: [Out>=1,V>=Out,V1>=Out]
* Chain [[7],8]: 1*it(7)+1
Such that:it(7) =< Out
with precondition: [V1=Out,V1>=1,V>=V1]
* Chain [9]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [8]: 1
with precondition: [V1=0,Out=0,V>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[11],10]: 3*it(11)+2*s(4)+2*s(9)+2
Such that:aux(2) =< V+1
s(3) =< V1+Out
it(11) =< Out
s(4) =< s(3)
s(10) =< it(11)*aux(2)
s(9) =< s(10)
with precondition: [V1>=1,Out>=1,V+1>=Out+V1]
* Chain [12,[11],10]: 5*it(11)+2*s(9)+5
Such that:aux(2) =< V+1
aux(3) =< Out
it(11) =< aux(3)
s(10) =< it(11)*aux(2)
s(9) =< s(10)
with precondition: [V1=0,Out>=2,V+1>=Out]
* Chain [12,10]: 2*s(4)+5
Such that:s(3) =< 1
s(4) =< s(3)
with precondition: [V1=0,Out=1,V>=0]
* Chain [10]: 2*s(4)+2
Such that:s(3) =< V1
s(4) =< s(3)
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of start(V,V1,V4):
* Chain [14]: 2*s(12)+7*s(15)+2*s(17)+4*s(19)+3*s(22)+2*s(25)+5
Such that:s(11) =< 1
s(22) =< V-V1+1
aux(6) =< V+1
aux(7) =< V1
s(12) =< s(11)
s(15) =< aux(6)
s(16) =< s(15)*aux(6)
s(17) =< s(16)
s(24) =< s(22)*aux(6)
s(25) =< s(24)
s(19) =< aux(7)
with precondition: [V>=0,V1>=0]
* Chain [13]: 2*s(29)+3*s(32)+2*s(33)+2*s(35)+3
Such that:s(28) =< V+1
aux(8) =< V1+1
s(32) =< V1-V4
s(29) =< s(28)
s(33) =< aux(8)
s(34) =< s(32)*aux(8)
s(35) =< s(34)
with precondition: [V=V4,V>=0,V1>=0]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [14] with precondition: [V>=0,V1>=0]
- Upper bound: 7*V+4*V1+14+ (2*V+2)* (V+1)+ (2*V+2)*nat(V-V1+1)+nat(V-V1+1)*3
- Complexity: n^2
* Chain [13] with precondition: [V=V4,V>=0,V1>=0]
- Upper bound: 2*V+2*V1+7+ (2*V1+2)*nat(V1-V4)+nat(V1-V4)*3
- Complexity: n^2
### Maximum cost of start(V,V1,V4): 2*V+5+max([2*V1+2+ (2*V1+2)*nat(V1-V4)+nat(V1-V4)*3,5*V+4*V1+9+ (2*V+2)* (V+1)+ (2*V+2)*nat(V-V1+1)+nat(V-V1+1)*3])
Asymptotic class: n^2
* Total analysis performed in 189 ms.