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 (⇔, 307 ms)
↳10 BOUNDS(1, n^1)
minus(X, 0) → X
minus(s(X), s(Y)) → p(minus(X, Y))
p(s(X)) → X
div(0, s(Y)) → 0
div(s(X), s(Y)) → s(div(minus(X, Y), s(Y)))
minus(X, 0) → X [1]
minus(s(X), s(Y)) → p(minus(X, Y)) [1]
p(s(X)) → X [1]
div(0, s(Y)) → 0 [1]
div(s(X), s(Y)) → s(div(minus(X, Y), s(Y))) [1]
minus(X, 0) → X [1]
minus(s(X), s(Y)) → p(minus(X, Y)) [1]
p(s(X)) → X [1]
div(0, s(Y)) → 0 [1]
div(s(X), s(Y)) → s(div(minus(X, Y), s(Y))) [1]
minus :: 0:s → 0:s → 0:s 0 :: 0:s s :: 0:s → 0:s p :: 0:s → 0:s div :: 0:s → 0:s → 0:s |
minus(v0, v1) → null_minus [0]
p(v0) → null_p [0]
div(v0, v1) → null_div [0]
null_minus, null_p, null_div
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_minus => 0
null_p => 0
null_div => 0
div(z, z') -{ 1 }→ 0 :|: Y >= 0, z' = 1 + Y, z = 0
div(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
div(z, z') -{ 1 }→ 1 + div(minus(X, Y), 1 + Y) :|: z = 1 + X, Y >= 0, z' = 1 + Y, X >= 0
minus(z, z') -{ 1 }→ X :|: X >= 0, z = X, z' = 0
minus(z, z') -{ 1 }→ p(minus(X, Y)) :|: z = 1 + X, Y >= 0, z' = 1 + Y, X >= 0
minus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
p(z) -{ 1 }→ X :|: z = 1 + X, X >= 0
p(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
eq(start(V, V1),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[p(V, Out)],[V >= 0]). eq(start(V, V1),0,[div(V, V1, Out)],[V >= 0,V1 >= 0]). eq(minus(V, V1, Out),1,[],[Out = X1,X1 >= 0,V = X1,V1 = 0]). eq(minus(V, V1, Out),1,[minus(X2, Y1, Ret0),p(Ret0, Ret)],[Out = Ret,V = 1 + X2,Y1 >= 0,V1 = 1 + Y1,X2 >= 0]). eq(p(V, Out),1,[],[Out = X3,V = 1 + X3,X3 >= 0]). eq(div(V, V1, Out),1,[],[Out = 0,Y2 >= 0,V1 = 1 + Y2,V = 0]). eq(div(V, V1, Out),1,[minus(X4, Y3, Ret10),div(Ret10, 1 + Y3, Ret1)],[Out = 1 + Ret1,V = 1 + X4,Y3 >= 0,V1 = 1 + Y3,X4 >= 0]). eq(minus(V, V1, Out),0,[],[Out = 0,V2 >= 0,V3 >= 0,V = V2,V1 = V3]). eq(p(V, Out),0,[],[Out = 0,V4 >= 0,V = V4]). eq(div(V, V1, Out),0,[],[Out = 0,V5 >= 0,V6 >= 0,V = V5,V1 = V6]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(p(V,Out),[V],[Out]). input_output_vars(div(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. non_recursive : [p/2]
1. recursive [non_tail] : [minus/3]
2. recursive : [ (div)/3]
3. non_recursive : [start/2]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into p/2
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into (div)/3
3. SCC is partially evaluated into start/2
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations p/2
* CE 8 is refined into CE [13]
* CE 9 is refined into CE [14]
### Cost equations --> "Loop" of p/2
* CEs [13] --> Loop 9
* CEs [14] --> Loop 10
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations minus/3
* CE 7 is refined into CE [15]
* CE 5 is refined into CE [16]
* CE 6 is refined into CE [17,18]
### Cost equations --> "Loop" of minus/3
* CEs [18] --> Loop 11
* CEs [17] --> Loop 12
* CEs [15] --> Loop 13
* CEs [16] --> Loop 14
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [11]: [V,V1]
* RF of phase [12]: [V,V1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V
V1
* Partial RF of phase [12]:
- RF of loop [12:1]:
V
V1
### Specialization of cost equations (div)/3
* CE 10 is refined into CE [19]
* CE 12 is refined into CE [20]
* CE 11 is refined into CE [21,22,23]
### Cost equations --> "Loop" of (div)/3
* CEs [23] --> Loop 15
* CEs [22] --> Loop 16
* CEs [21] --> Loop 17
* CEs [19,20] --> Loop 18
### Ranking functions of CR div(V,V1,Out)
* RF of phase [15]: [V/3-2/3,V/3-2/3*V1+2/3]
* RF of phase [17]: [V]
#### Partial ranking functions of CR div(V,V1,Out)
* Partial RF of phase [15]:
- RF of loop [15:1]:
V/3-2/3
V/3-2/3*V1+2/3
* Partial RF of phase [17]:
- RF of loop [17:1]:
V
### Specialization of cost equations start/2
* CE 2 is refined into CE [24,25,26]
* CE 3 is refined into CE [27,28]
* CE 4 is refined into CE [29,30,31,32,33]
### Cost equations --> "Loop" of start/2
* CEs [29] --> Loop 19
* CEs [24,25,26,27,28,30,31,32,33] --> Loop 20
### Ranking functions of CR start(V,V1)
#### Partial ranking functions of CR start(V,V1)
Computing Bounds
=====================================
#### Cost of chains of p(V,Out):
* Chain [10]: 0
with precondition: [Out=0,V>=0]
* Chain [9]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of minus(V,V1,Out):
* Chain [[12],[11],14]: 3*it(11)+1
Such that:aux(1) =< V1
it(11) =< aux(1)
with precondition: [Out=0,V1>=2,V>=V1+1]
* Chain [[12],14]: 1*it(12)+1
Such that:it(12) =< V1
with precondition: [Out=0,V1>=1,V>=V1]
* Chain [[12],13]: 1*it(12)+0
Such that:it(12) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [[11],14]: 2*it(11)+1
Such that:it(11) =< V1
with precondition: [V=2*V1+Out,V1>=1,V>=2*V1]
* Chain [14]: 1
with precondition: [V1=0,V=Out,V>=0]
* Chain [13]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of div(V,V1,Out):
* Chain [[17],18]: 2*it(17)+1
Such that:it(17) =< Out
with precondition: [V1=1,Out>=1,V>=Out]
* Chain [[17],16,18]: 2*it(17)+5*s(6)+3
Such that:s(5) =< 1
it(17) =< Out
s(6) =< s(5)
with precondition: [V1=1,Out>=2,V>=Out]
* Chain [[15],18]: 2*it(15)+2*s(9)+1
Such that:it(15) =< V/3-2/3*V1+2/3
s(9) =< 2/3*V-V1/3+2/3
with precondition: [V1>=2,Out>=1,V+4>=3*Out+2*V1]
* Chain [[15],16,18]: 2*it(15)+5*s(6)+2*s(9)+3
Such that:it(15) =< V/3-2/3*V1+2/3
s(9) =< 2/3*V
s(5) =< V1
s(6) =< s(5)
with precondition: [V1>=2,Out>=2,V+6>=3*Out+2*V1]
* Chain [18]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [16,18]: 5*s(6)+3
Such that:s(5) =< V1
s(6) =< s(5)
with precondition: [Out=1,V>=1,V1>=1]
#### Cost of chains of start(V,V1):
* Chain [20]: 17*s(15)+4*s(19)+2*s(20)+2*s(22)+3
Such that:s(22) =< 2/3*V
s(20) =< 2/3*V-V1/3+2/3
aux(4) =< V/3-2/3*V1+2/3
aux(5) =< V1
s(19) =< aux(4)
s(15) =< aux(5)
with precondition: [V>=0]
* Chain [19]: 4*s(27)+5*s(28)+3
Such that:s(25) =< 1
s(26) =< V
s(27) =< s(26)
s(28) =< s(25)
with precondition: [V1=1,V>=1]
Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [20] with precondition: [V>=0]
- Upper bound: nat(V1)*17+3+4/3*V+nat(2/3*V-V1/3+2/3)*2+nat(V/3-2/3*V1+2/3)*4
- Complexity: n
* Chain [19] with precondition: [V1=1,V>=1]
- Upper bound: 4*V+8
- Complexity: n
### Maximum cost of start(V,V1): max([4*V+5,4/3*V+nat(V1)*17+nat(2/3*V-V1/3+2/3)*2+nat(V/3-2/3*V1+2/3)*4])+3
Asymptotic class: n
* Total analysis performed in 247 ms.