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 (⇔, 421 ms)
↳10 BOUNDS(1, n^2)
minus(x, y) → cond(equal(min(x, y), y), x, y)
cond(true, x, y) → s(minus(x, s(y)))
min(0, v) → 0
min(u, 0) → 0
min(s(u), s(v)) → s(min(u, v))
equal(0, 0) → true
equal(s(x), 0) → false
equal(0, s(y)) → false
equal(s(x), s(y)) → equal(x, y)
minus(x, y) → cond(equal(min(x, y), y), x, y) [1]
cond(true, 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]
equal(0, 0) → true [1]
equal(s(x), 0) → false [1]
equal(0, s(y)) → false [1]
equal(s(x), s(y)) → equal(x, y) [1]
minus(x, y) → cond(equal(min(x, y), y), x, y) [1]
cond(true, 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]
equal(0, 0) → true [1]
equal(s(x), 0) → false [1]
equal(0, s(y)) → false [1]
equal(s(x), s(y)) → equal(x, y) [1]
minus :: s:0 → s:0 → s:0 cond :: true:false → s:0 → s:0 → s:0 equal :: s:0 → s:0 → true:false min :: s:0 → s:0 → s:0 true :: true:false s :: s:0 → s:0 0 :: s:0 false :: true:false |
cond(v0, v1, v2) → null_cond [0]
min(v0, v1) → null_min [0]
equal(v0, v1) → null_equal [0]
null_cond, null_min, null_equal
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 2
0 => 0
false => 1
null_cond => 0
null_min => 0
null_equal => 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 = 2, z' = x, z'' = y, x >= 0, y >= 0
equal(z, z') -{ 1 }→ equal(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
equal(z, z') -{ 1 }→ 2 :|: z = 0, z' = 0
equal(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
equal(z, z') -{ 1 }→ 1 :|: z' = 1 + y, y >= 0, z = 0
equal(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
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(equal(min(x, y), 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(start(V, V1, V4),0,[equal(V, V1, Out)],[V >= 0,V1 >= 0]). eq(minus(V, V1, Out),1,[min(V2, V3, Ret00),equal(Ret00, 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,V = 2,V1 = V5,V4 = V6,V5 >= 0,V6 >= 0]). 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(equal(V, V1, Out),1,[],[Out = 2,V = 0,V1 = 0]). eq(equal(V, V1, Out),1,[],[Out = 1,V11 >= 0,V = 1 + V11,V1 = 0]). eq(equal(V, V1, Out),1,[],[Out = 1,V1 = 1 + V12,V12 >= 0,V = 0]). eq(equal(V, V1, Out),1,[equal(V13, V14, Ret2)],[Out = Ret2,V1 = 1 + V14,V13 >= 0,V14 >= 0,V = 1 + V13]). eq(cond(V, V1, V4, Out),0,[],[Out = 0,V15 >= 0,V4 = V16,V17 >= 0,V = V15,V1 = V17,V16 >= 0]). eq(min(V, V1, Out),0,[],[Out = 0,V18 >= 0,V19 >= 0,V = V18,V1 = V19]). eq(equal(V, V1, Out),0,[],[Out = 0,V20 >= 0,V21 >= 0,V = V20,V1 = V21]). 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]). input_output_vars(equal(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [equal/3]
1. recursive : [min/3]
2. recursive : [cond/4,minus/3]
3. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into equal/3
1. SCC is partially evaluated into min/3
2. SCC is partially evaluated into minus/3
3. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations equal/3
* CE 17 is refined into CE [18]
* CE 14 is refined into CE [19]
* CE 15 is refined into CE [20]
* CE 13 is refined into CE [21]
* CE 16 is refined into CE [22]
### Cost equations --> "Loop" of equal/3
* CEs [22] --> Loop 12
* CEs [18] --> Loop 13
* CEs [19] --> Loop 14
* CEs [20] --> Loop 15
* CEs [21] --> Loop 16
### Ranking functions of CR equal(V,V1,Out)
* RF of phase [12]: [V,V1]
#### Partial ranking functions of CR equal(V,V1,Out)
* Partial RF of phase [12]:
- RF of loop [12:1]:
V
V1
### Specialization of cost equations min/3
* CE 10 is refined into CE [23]
* CE 9 is refined into CE [24]
* CE 12 is refined into CE [25]
* CE 11 is refined into CE [26]
### Cost equations --> "Loop" of min/3
* CEs [26] --> Loop 17
* CEs [23] --> Loop 18
* CEs [24,25] --> Loop 19
### Ranking functions of CR min(V,V1,Out)
* RF of phase [17]: [V,V1]
#### Partial ranking functions of CR min(V,V1,Out)
* Partial RF of phase [17]:
- RF of loop [17:1]:
V
V1
### Specialization of cost equations minus/3
* CE 8 is refined into CE [27,28]
* CE 7 is refined into CE [29,30,31,32,33,34]
### Cost equations --> "Loop" of minus/3
* CEs [29,30,31,32,33,34] --> Loop 20
* CEs [28] --> Loop 21
* CEs [27] --> Loop 22
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [21]: [V-V1+1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [21]:
- RF of loop [21:1]:
V-V1+1
### Specialization of cost equations start/3
* CE 2 is refined into CE [35]
* CE 3 is refined into CE [36,37]
* CE 4 is refined into CE [38,39,40,41]
* CE 5 is refined into CE [42,43]
* CE 6 is refined into CE [44,45,46,47,48,49,50]
### Cost equations --> "Loop" of start/3
* CEs [50] --> Loop 23
* CEs [36,37] --> Loop 24
* CEs [45] --> Loop 25
* CEs [35,38,39,40,41,42,43,44,46,47,48,49] --> Loop 26
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of equal(V,V1,Out):
* Chain [[12],16]: 1*it(12)+1
Such that:it(12) =< V
with precondition: [Out=2,V=V1,V>=1]
* Chain [[12],15]: 1*it(12)+1
Such that:it(12) =< V
with precondition: [Out=1,V>=1,V1>=V+1]
* Chain [[12],14]: 1*it(12)+1
Such that:it(12) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [[12],13]: 1*it(12)+0
Such that:it(12) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [16]: 1
with precondition: [V=0,V1=0,Out=2]
* Chain [15]: 1
with precondition: [V=0,Out=1,V1>=1]
* Chain [14]: 1
with precondition: [V1=0,Out=1,V>=1]
* Chain [13]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of min(V,V1,Out):
* Chain [[17],19]: 1*it(17)+1
Such that:it(17) =< Out
with precondition: [Out>=1,V>=Out,V1>=Out]
* Chain [[17],18]: 1*it(17)+1
Such that:it(17) =< Out
with precondition: [V1=Out,V1>=1,V>=V1]
* Chain [19]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [18]: 1
with precondition: [V1=0,Out=0,V>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[21],20]: 4*it(21)+10*s(4)+3*s(19)+3
Such that:aux(7) =< V+1
aux(5) =< V1+Out
it(21) =< Out
s(4) =< aux(5)
s(20) =< it(21)*aux(7)
s(19) =< s(20)
with precondition: [V1>=1,Out>=1,V+1>=Out+V1]
* Chain [22,[21],20]: 14*it(21)+3*s(19)+7
Such that:aux(7) =< V+1
aux(8) =< Out
it(21) =< aux(8)
s(20) =< it(21)*aux(7)
s(19) =< s(20)
with precondition: [V1=0,Out>=2,V+1>=Out]
* Chain [22,20]: 10*s(4)+7
Such that:aux(5) =< 1
s(4) =< aux(5)
with precondition: [V1=0,Out=1,V>=0]
* Chain [20]: 10*s(4)+3
Such that:aux(5) =< V1
s(4) =< aux(5)
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of start(V,V1,V4):
* Chain [26]: 10*s(22)+24*s(25)+3*s(27)+14*s(29)+4*s(32)+3*s(35)+1*s(39)+7
Such that:s(21) =< 1
s(39) =< V
s(32) =< V-V1+1
aux(11) =< V+1
aux(12) =< V1
s(29) =< aux(12)
s(22) =< s(21)
s(25) =< aux(11)
s(26) =< s(25)*aux(11)
s(27) =< s(26)
s(34) =< s(32)*aux(11)
s(35) =< s(34)
with precondition: [V>=0,V1>=0]
* Chain [25]: 1
with precondition: [V=0,V1>=1]
* Chain [24]: 10*s(42)+4*s(45)+10*s(46)+3*s(48)+4
Such that:aux(13) =< V1+1
s(45) =< V1-V4
s(41) =< V4+1
s(46) =< aux(13)
s(47) =< s(45)*aux(13)
s(48) =< s(47)
s(42) =< s(41)
with precondition: [V=2,V1>=0,V4>=0]
* Chain [23]: 1*s(49)+1
Such that:s(49) =< V1
with precondition: [V=V1,V>=1]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [26] with precondition: [V>=0,V1>=0]
- Upper bound: 25*V+14*V1+41+ (3*V+3)* (V+1)+ (3*V+3)*nat(V-V1+1)+nat(V-V1+1)*4
- Complexity: n^2
* Chain [25] with precondition: [V=0,V1>=1]
- Upper bound: 1
- Complexity: constant
* Chain [24] with precondition: [V=2,V1>=0,V4>=0]
- Upper bound: 10*V1+14+ (3*V1+3)*nat(V1-V4)+ (10*V4+10)+nat(V1-V4)*4
- Complexity: n^2
* Chain [23] with precondition: [V=V1,V>=1]
- Upper bound: V1+1
- Complexity: n
### Maximum cost of start(V,V1,V4): max([10*V1+13+ (3*V1+3)*nat(V1-V4)+nat(V4+1)*10+nat(V1-V4)*4,25*V+13*V1+40+ (3*V+3)* (V+1)+ (3*V+3)*nat(V-V1+1)+nat(V-V1+1)*4+V1])+1
Asymptotic class: n^2
* Total analysis performed in 314 ms.