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 (⇔, 754 ms)
↳10 BOUNDS(1, n^3)
minus(x, y) → if(gt(x, y), x, y)
if(true, x, y) → s(minus(p(x), y))
if(false, x, y) → 0
p(0) → 0
p(s(x)) → x
ge(x, 0) → true
ge(0, s(x)) → false
ge(s(x), s(y)) → ge(x, y)
gt(0, y) → false
gt(s(x), 0) → true
gt(s(x), s(y)) → gt(x, y)
div(x, y) → if1(ge(x, y), x, y)
if1(true, x, y) → if2(gt(y, 0), x, y)
if1(false, x, y) → 0
if2(true, x, y) → s(div(minus(x, y), y))
if2(false, x, y) → 0
minus(x, y) → if(gt(x, y), x, y) [1]
if(true, x, y) → s(minus(p(x), y)) [1]
if(false, x, y) → 0 [1]
p(0) → 0 [1]
p(s(x)) → x [1]
ge(x, 0) → true [1]
ge(0, s(x)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
gt(0, y) → false [1]
gt(s(x), 0) → true [1]
gt(s(x), s(y)) → gt(x, y) [1]
div(x, y) → if1(ge(x, y), x, y) [1]
if1(true, x, y) → if2(gt(y, 0), x, y) [1]
if1(false, x, y) → 0 [1]
if2(true, x, y) → s(div(minus(x, y), y)) [1]
if2(false, x, y) → 0 [1]
minus(x, y) → if(gt(x, y), x, y) [1]
if(true, x, y) → s(minus(p(x), y)) [1]
if(false, x, y) → 0 [1]
p(0) → 0 [1]
p(s(x)) → x [1]
ge(x, 0) → true [1]
ge(0, s(x)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
gt(0, y) → false [1]
gt(s(x), 0) → true [1]
gt(s(x), s(y)) → gt(x, y) [1]
div(x, y) → if1(ge(x, y), x, y) [1]
if1(true, x, y) → if2(gt(y, 0), x, y) [1]
if1(false, x, y) → 0 [1]
if2(true, x, y) → s(div(minus(x, y), y)) [1]
if2(false, x, y) → 0 [1]
minus :: s:0 → s:0 → s:0 if :: true:false → s:0 → s:0 → s:0 gt :: s:0 → s:0 → true:false true :: true:false s :: s:0 → s:0 p :: s:0 → s:0 false :: true:false 0 :: s:0 ge :: s:0 → s:0 → true:false div :: s:0 → s:0 → s:0 if1 :: true:false → s:0 → s:0 → s:0 if2 :: true:false → s:0 → s:0 → s:0 |
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 => 1
false => 0
0 => 0
div(z, z') -{ 1 }→ if1(ge(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
ge(z, z') -{ 1 }→ ge(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
ge(z, z') -{ 1 }→ 1 :|: x >= 0, z = x, z' = 0
ge(z, z') -{ 1 }→ 0 :|: z' = 1 + x, x >= 0, z = 0
gt(z, z') -{ 1 }→ gt(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gt(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
gt(z, z') -{ 1 }→ 0 :|: y >= 0, z = 0, z' = y
if(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
if(z, z', z'') -{ 1 }→ 1 + minus(p(x), y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if1(z, z', z'') -{ 1 }→ if2(gt(y, 0), x, y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if1(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
if2(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
if2(z, z', z'') -{ 1 }→ 1 + div(minus(x, y), y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
minus(z, z') -{ 1 }→ if(gt(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
p(z) -{ 1 }→ x :|: x >= 0, z = 1 + x
p(z) -{ 1 }→ 0 :|: z = 0
eq(start(V, V1, V4),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[if(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[p(V, Out)],[V >= 0]). eq(start(V, V1, V4),0,[ge(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[gt(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[div(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[if1(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[if2(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(minus(V, V1, Out),1,[gt(V2, V3, Ret0),if(Ret0, V2, V3, Ret)],[Out = Ret,V2 >= 0,V3 >= 0,V = V2,V1 = V3]). eq(if(V, V1, V4, Out),1,[p(V5, Ret10),minus(Ret10, V6, Ret1)],[Out = 1 + Ret1,V1 = V5,V4 = V6,V = 1,V5 >= 0,V6 >= 0]). eq(if(V, V1, V4, Out),1,[],[Out = 0,V1 = V7,V4 = V8,V7 >= 0,V8 >= 0,V = 0]). eq(p(V, Out),1,[],[Out = 0,V = 0]). eq(p(V, Out),1,[],[Out = V9,V9 >= 0,V = 1 + V9]). eq(ge(V, V1, Out),1,[],[Out = 1,V10 >= 0,V = V10,V1 = 0]). eq(ge(V, V1, Out),1,[],[Out = 0,V1 = 1 + V11,V11 >= 0,V = 0]). eq(ge(V, V1, Out),1,[ge(V12, V13, Ret2)],[Out = Ret2,V1 = 1 + V13,V12 >= 0,V13 >= 0,V = 1 + V12]). eq(gt(V, V1, Out),1,[],[Out = 0,V14 >= 0,V = 0,V1 = V14]). eq(gt(V, V1, Out),1,[],[Out = 1,V15 >= 0,V = 1 + V15,V1 = 0]). eq(gt(V, V1, Out),1,[gt(V16, V17, Ret3)],[Out = Ret3,V1 = 1 + V17,V16 >= 0,V17 >= 0,V = 1 + V16]). eq(div(V, V1, Out),1,[ge(V18, V19, Ret01),if1(Ret01, V18, V19, Ret4)],[Out = Ret4,V18 >= 0,V19 >= 0,V = V18,V1 = V19]). eq(if1(V, V1, V4, Out),1,[gt(V20, 0, Ret02),if2(Ret02, V21, V20, Ret5)],[Out = Ret5,V1 = V21,V4 = V20,V = 1,V21 >= 0,V20 >= 0]). eq(if1(V, V1, V4, Out),1,[],[Out = 0,V1 = V22,V4 = V23,V22 >= 0,V23 >= 0,V = 0]). eq(if2(V, V1, V4, Out),1,[minus(V24, V25, Ret101),div(Ret101, V25, Ret11)],[Out = 1 + Ret11,V1 = V24,V4 = V25,V = 1,V24 >= 0,V25 >= 0]). eq(if2(V, V1, V4, Out),1,[],[Out = 0,V1 = V26,V4 = V27,V26 >= 0,V27 >= 0,V = 0]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(if(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(p(V,Out),[V],[Out]). input_output_vars(ge(V,V1,Out),[V,V1],[Out]). input_output_vars(gt(V,V1,Out),[V,V1],[Out]). input_output_vars(div(V,V1,Out),[V,V1],[Out]). input_output_vars(if1(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(if2(V,V1,V4,Out),[V,V1,V4],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [ge/3]
1. recursive : [gt/3]
2. non_recursive : [p/2]
3. recursive : [if/4,minus/3]
4. recursive : [ (div)/3,if1/4,if2/4]
5. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into ge/3
1. SCC is partially evaluated into gt/3
2. SCC is partially evaluated into p/2
3. SCC is partially evaluated into minus/3
4. SCC is partially evaluated into (div)/3
5. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations ge/3
* CE 24 is refined into CE [25]
* CE 22 is refined into CE [26]
* CE 23 is refined into CE [27]
### Cost equations --> "Loop" of ge/3
* CEs [26] --> Loop 15
* CEs [27] --> Loop 16
* CEs [25] --> Loop 17
### Ranking functions of CR ge(V,V1,Out)
* RF of phase [17]: [V,V1]
#### Partial ranking functions of CR ge(V,V1,Out)
* Partial RF of phase [17]:
- RF of loop [17:1]:
V
V1
### Specialization of cost equations gt/3
* CE 14 is refined into CE [28]
* CE 13 is refined into CE [29]
* CE 12 is refined into CE [30]
### Cost equations --> "Loop" of gt/3
* CEs [29] --> Loop 18
* CEs [30] --> Loop 19
* CEs [28] --> Loop 20
### Ranking functions of CR gt(V,V1,Out)
* RF of phase [20]: [V,V1]
#### Partial ranking functions of CR gt(V,V1,Out)
* Partial RF of phase [20]:
- RF of loop [20:1]:
V
V1
### Specialization of cost equations p/2
* CE 21 is refined into CE [31]
* CE 20 is refined into CE [32]
### Cost equations --> "Loop" of p/2
* CEs [31] --> Loop 21
* CEs [32] --> Loop 22
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations minus/3
* CE 16 is refined into CE [33,34]
* CE 15 is refined into CE [35,36]
### Cost equations --> "Loop" of minus/3
* CEs [36] --> Loop 23
* CEs [35] --> Loop 24
* CEs [34] --> Loop 25
* CEs [33] --> Loop 26
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [25]: [V-1,V-V1]
* RF of phase [26]: [V]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [25]:
- RF of loop [25:1]:
V-1
V-V1
* Partial RF of phase [26]:
- RF of loop [26:1]:
V
### Specialization of cost equations (div)/3
* CE 17 is refined into CE [37,38]
* CE 19 is refined into CE [39]
* CE 18 is refined into CE [40,41]
### Cost equations --> "Loop" of (div)/3
* CEs [41] --> Loop 27
* CEs [40] --> Loop 28
* CEs [38] --> Loop 29
* CEs [39] --> Loop 30
* CEs [37] --> Loop 31
### Ranking functions of CR div(V,V1,Out)
* RF of phase [27]: [V-1,V-V1]
#### Partial ranking functions of CR div(V,V1,Out)
* Partial RF of phase [27]:
- RF of loop [27:1]:
V-1
V-V1
### Specialization of cost equations start/3
* CE 3 is refined into CE [42,43,44,45,46,47]
* CE 4 is refined into CE [48]
* CE 5 is refined into CE [49,50,51,52,53,54,55,56]
* CE 6 is refined into CE [57,58,59,60,61]
* CE 2 is refined into CE [62]
* CE 7 is refined into CE [63,64,65,66]
* CE 8 is refined into CE [67,68]
* CE 9 is refined into CE [69,70,71,72]
* CE 10 is refined into CE [73,74,75,76]
* CE 11 is refined into CE [77,78,79,80,81,82]
### Cost equations --> "Loop" of start/3
* CEs [44,53] --> Loop 32
* CEs [46,47,55,56,61] --> Loop 33
* CEs [60] --> Loop 34
* CEs [43,52] --> Loop 35
* CEs [45,54] --> Loop 36
* CEs [48,51,59] --> Loop 37
* CEs [58,65,66,68,71,72,75,76,79,80,81,82] --> Loop 38
* CEs [42,49,50,57,64,70,74,78] --> Loop 39
* CEs [62,63,67,69,73,77] --> Loop 40
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of ge(V,V1,Out):
* Chain [[17],16]: 1*it(17)+1
Such that:it(17) =< V
with precondition: [Out=0,V>=1,V1>=V+1]
* Chain [[17],15]: 1*it(17)+1
Such that:it(17) =< V1
with precondition: [Out=1,V1>=1,V>=V1]
* Chain [16]: 1
with precondition: [V=0,Out=0,V1>=1]
* Chain [15]: 1
with precondition: [V1=0,Out=1,V>=0]
#### Cost of chains of gt(V,V1,Out):
* Chain [[20],19]: 1*it(20)+1
Such that:it(20) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[20],18]: 1*it(20)+1
Such that:it(20) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [19]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [18]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of p(V,Out):
* Chain [22]: 1
with precondition: [V=0,Out=0]
* Chain [21]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of minus(V,V1,Out):
* Chain [[26],24]: 4*it(26)+3
Such that:it(26) =< Out
with precondition: [V1=0,V=Out,V>=1]
* Chain [[25],23]: 4*it(25)+1*s(1)+1*s(4)+3
Such that:it(25) =< Out
aux(2) =< V-Out
s(1) =< aux(2)
s(4) =< it(25)*aux(2)
with precondition: [V=Out+V1,V1>=1,V>=V1+1]
* Chain [24]: 3
with precondition: [V=0,Out=0,V1>=0]
* Chain [23]: 1*s(1)+3
Such that:s(1) =< V
with precondition: [Out=0,V>=1,V1>=V]
#### Cost of chains of div(V,V1,Out):
* Chain [[27],29]: 8*it(27)+3*s(5)+4*s(16)+1*s(17)+3
Such that:aux(7) =< V-V1
s(12) =< V1
aux(9) =< V
it(27) =< aux(9)
s(5) =< aux(9)
it(27) =< aux(7)
s(16) =< it(27)*aux(7)
s(17) =< s(16)*s(12)
with precondition: [V1>=1,Out>=1,V>=Out+V1]
* Chain [[27],28,31]: 8*it(27)+2*s(15)+4*s(16)+1*s(17)+2*s(19)+11
Such that:aux(6) =< V
aux(11) =< V-V1
aux(12) =< V1
it(27) =< aux(11)
s(19) =< aux(12)
it(27) =< aux(6)
s(18) =< aux(6)
s(18) =< aux(11)
s(16) =< it(27)*aux(11)
s(15) =< s(18)
s(17) =< s(16)*aux(12)
with precondition: [V1>=1,Out>=2,V+2>=2*V1+Out]
* Chain [31]: 3
with precondition: [V=0,Out=0,V1>=1]
* Chain [30]: 5
with precondition: [V1=0,Out=0,V>=0]
* Chain [29]: 1*s(5)+3
Such that:s(5) =< V
with precondition: [Out=0,V>=1,V1>=V+1]
* Chain [28,31]: 2*s(19)+11
Such that:aux(10) =< V
s(19) =< aux(10)
with precondition: [Out=1,V=V1,V>=1]
#### Cost of chains of start(V,V1,V4):
* Chain [40]: 3
with precondition: [V=0]
* Chain [39]: 4*s(21)+9
Such that:s(21) =< V
with precondition: [V1=0,V>=0]
* Chain [38]: 7*s(22)+4*s(23)+7*s(25)+1*s(26)+16*s(37)+8*s(39)+2*s(40)+2*s(48)+11
Such that:aux(13) =< V
aux(14) =< V-V1
aux(15) =< V1
s(22) =< aux(13)
s(23) =< aux(14)
s(25) =< aux(15)
s(37) =< aux(13)
s(37) =< aux(14)
s(39) =< s(37)*aux(14)
s(40) =< s(39)*aux(15)
s(46) =< aux(13)
s(46) =< aux(14)
s(48) =< s(46)
s(26) =< s(23)*aux(15)
with precondition: [V>=1]
* Chain [37]: 8*s(50)+9
Such that:aux(16) =< V1
s(50) =< aux(16)
with precondition: [V=1,V4=0,V1>=0]
* Chain [36]: 14*s(52)+2*s(55)+17
Such that:aux(19) =< V4
s(52) =< aux(19)
s(55) =< s(52)*aux(19)
with precondition: [V=1,V1=2*V4,V1>=2]
* Chain [35]: 2*s(64)+9
Such that:aux(20) =< V1
s(64) =< aux(20)
with precondition: [V=1,V1>=1,V4>=V1]
* Chain [34]: 1*s(66)+5
Such that:s(66) =< V1
with precondition: [V=1,V1>=2,V4+1>=V1]
* Chain [33]: 26*s(67)+9*s(69)+5*s(70)+32*s(74)+16*s(76)+4*s(77)+4*s(89)+17
Such that:aux(29) =< V1-2*V4
aux(30) =< V1-V4
aux(31) =< V4
s(67) =< aux(30)
s(74) =< aux(30)
s(74) =< aux(29)
s(76) =< s(74)*aux(29)
s(77) =< s(76)*aux(31)
s(69) =< aux(31)
s(70) =< s(67)*aux(31)
s(87) =< aux(30)
s(87) =< aux(29)
s(89) =< s(87)
with precondition: [V=1,V4>=1,V1>=V4+2]
* Chain [32]: 10*s(119)+2*s(121)+2*s(122)+9
Such that:aux(34) =< V1-V4
aux(35) =< V4
s(119) =< aux(34)
s(121) =< aux(35)
s(122) =< s(119)*aux(35)
with precondition: [V=1,2*V4>=V1+1,V1>=V4+1]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [40] with precondition: [V=0]
- Upper bound: 3
- Complexity: constant
* Chain [39] with precondition: [V1=0,V>=0]
- Upper bound: 4*V+9
- Complexity: n
* Chain [38] with precondition: [V>=1]
- Upper bound: 25*V+11+nat(V1)*7+nat(V-V1)*nat(V1)+nat(V1)*2*nat(V-V1)*V+nat(V-V1)*4+nat(V-V1)*8*V
- Complexity: n^3
* Chain [37] with precondition: [V=1,V4=0,V1>=0]
- Upper bound: 8*V1+9
- Complexity: n
* Chain [36] with precondition: [V=1,V1=2*V4,V1>=2]
- Upper bound: 14*V4+17+2*V4*V4
- Complexity: n^2
* Chain [35] with precondition: [V=1,V1>=1,V4>=V1]
- Upper bound: 2*V1+9
- Complexity: n
* Chain [34] with precondition: [V=1,V1>=2,V4+1>=V1]
- Upper bound: V1+5
- Complexity: n
* Chain [33] with precondition: [V=1,V4>=1,V1>=V4+2]
- Upper bound: 62*V1-62*V4+ (9*V4+17+ (V1-V4)* (5*V4)+ (V1-V4)* (4*V4*nat(V1-2*V4)))+ (V1-V4)* (nat(V1-2*V4)*16)
- Complexity: n^3
* Chain [32] with precondition: [V=1,2*V4>=V1+1,V1>=V4+1]
- Upper bound: 10*V1-10*V4+ (2*V4+9+ (V1-V4)* (2*V4))
- Complexity: n^2
### Maximum cost of start(V,V1,V4): max([max([4*V+6,nat(V4)*2+6+max([nat(V4)*2*nat(V1-V4)+nat(V1-V4)*10,nat(V4)*7+8+max([nat(V4)*2*nat(V4)+nat(V4)*5,nat(V4)*4*nat(V1-2*V4)*nat(V1-V4)+nat(V4)*5*nat(V1-V4)+nat(V1-V4)*62+nat(V1-2*V4)*16*nat(V1-V4)])])]),nat(V1)*5+max([nat(V1),25*V+2+nat(V-V1)*nat(V1)+nat(V1)*2*nat(V-V1)*V+nat(V-V1)*4+nat(V-V1)*8*V])+ (nat(V1)+4)+ (nat(V1)+2)])+3
Asymptotic class: n^3
* Total analysis performed in 570 ms.