0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 CpxWeightedTrsRenamingProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxWeightedTrs
↳5 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳6 CpxTypedWeightedTrs
↳7 CompletionProof (UPPER BOUND(ID), 0 ms)
↳8 CpxTypedWeightedCompleteTrs
↳9 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳10 CpxRNTS
↳11 CompleteCoflocoProof (⇔, 168 ms)
↳12 BOUNDS(1, n^1)
+(X, 0) → X
+(X, s(Y)) → s(+(X, Y))
f(0, s(0), X) → f(X, +(X, X), X)
g(X, Y) → X
g(X, Y) → Y
+(X, 0) → X [1]
+(X, s(Y)) → s(+(X, Y)) [1]
f(0, s(0), X) → f(X, +(X, X), X) [1]
g(X, Y) → X [1]
g(X, Y) → Y [1]
+ => plus |
plus(X, 0) → X [1]
plus(X, s(Y)) → s(plus(X, Y)) [1]
f(0, s(0), X) → f(X, plus(X, X), X) [1]
g(X, Y) → X [1]
g(X, Y) → Y [1]
plus(X, 0) → X [1]
plus(X, s(Y)) → s(plus(X, Y)) [1]
f(0, s(0), X) → f(X, plus(X, X), X) [1]
g(X, Y) → X [1]
g(X, Y) → Y [1]
plus :: 0:s → 0:s → 0:s 0 :: 0:s s :: 0:s → 0:s f :: 0:s → 0:s → 0:s → f g :: g → g → g |
f(v0, v1, v2) → null_f [0]
null_f, const
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_f => 0
const => 0
f(z, z', z'') -{ 1 }→ f(X, plus(X, X), X) :|: z'' = X, X >= 0, z' = 1 + 0, z = 0
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
g(z, z') -{ 1 }→ X :|: z' = Y, Y >= 0, X >= 0, z = X
g(z, z') -{ 1 }→ Y :|: z' = Y, Y >= 0, X >= 0, z = X
plus(z, z') -{ 1 }→ X :|: X >= 0, z = X, z' = 0
plus(z, z') -{ 1 }→ 1 + plus(X, Y) :|: Y >= 0, z' = 1 + Y, X >= 0, z = X
eq(start(V, V1, V2),0,[plus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2),0,[f(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[g(V, V1, Out)],[V >= 0,V1 >= 0]). eq(plus(V, V1, Out),1,[],[Out = X1,X1 >= 0,V = X1,V1 = 0]). eq(plus(V, V1, Out),1,[plus(X2, Y1, Ret1)],[Out = 1 + Ret1,Y1 >= 0,V1 = 1 + Y1,X2 >= 0,V = X2]). eq(f(V, V1, V2, Out),1,[plus(X3, X3, Ret11),f(X3, Ret11, X3, Ret)],[Out = Ret,V2 = X3,X3 >= 0,V1 = 1,V = 0]). eq(g(V, V1, Out),1,[],[Out = X4,V1 = Y2,Y2 >= 0,X4 >= 0,V = X4]). eq(g(V, V1, Out),1,[],[Out = Y3,V1 = Y3,Y3 >= 0,X5 >= 0,V = X5]). eq(f(V, V1, V2, Out),0,[],[Out = 0,V3 >= 0,V2 = V4,V5 >= 0,V = V3,V1 = V5,V4 >= 0]). input_output_vars(plus(V,V1,Out),[V,V1],[Out]). input_output_vars(f(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(g(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [plus/3]
1. recursive : [f/4]
2. non_recursive : [g/3]
3. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into plus/3
1. SCC is partially evaluated into f/4
2. SCC is partially evaluated into g/3
3. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations plus/3
* CE 6 is refined into CE [11]
* CE 5 is refined into CE [12]
### Cost equations --> "Loop" of plus/3
* CEs [12] --> Loop 8
* CEs [11] --> Loop 9
### Ranking functions of CR plus(V,V1,Out)
* RF of phase [9]: [V1]
#### Partial ranking functions of CR plus(V,V1,Out)
* Partial RF of phase [9]:
- RF of loop [9:1]:
V1
### Specialization of cost equations f/4
* CE 8 is refined into CE [13]
* CE 7 is refined into CE [14,15]
### Cost equations --> "Loop" of f/4
* CEs [15] --> Loop 10
* CEs [14] --> Loop 11
* CEs [13] --> Loop 12
### Ranking functions of CR f(V,V1,V2,Out)
#### Partial ranking functions of CR f(V,V1,V2,Out)
### Specialization of cost equations g/3
* CE 10 is refined into CE [16]
* CE 9 is refined into CE [17]
### Cost equations --> "Loop" of g/3
* CEs [16] --> Loop 13
* CEs [17] --> Loop 14
### Ranking functions of CR g(V,V1,Out)
#### Partial ranking functions of CR g(V,V1,Out)
### Specialization of cost equations start/3
* CE 2 is refined into CE [18,19]
* CE 3 is refined into CE [20,21]
* CE 4 is refined into CE [22,23]
### Cost equations --> "Loop" of start/3
* CEs [18] --> Loop 15
* CEs [19,20,21,22,23] --> Loop 16
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of plus(V,V1,Out):
* Chain [[9],8]: 1*it(9)+1
Such that:it(9) =< V1
with precondition: [V+V1=Out,V>=0,V1>=1]
* Chain [8]: 1
with precondition: [V1=0,V=Out,V>=0]
#### Cost of chains of f(V,V1,V2,Out):
* Chain [12]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]
* Chain [11,12]: 2
with precondition: [V=0,V1=1,V2=0,Out=0]
* Chain [10,12]: 1*s(1)+2
Such that:s(1) =< V2
with precondition: [V=0,V1=1,Out=0,V2>=1]
#### Cost of chains of g(V,V1,Out):
* Chain [14]: 1
with precondition: [V=Out,V>=0,V1>=0]
* Chain [13]: 1
with precondition: [V1=Out,V>=0,V1>=0]
#### Cost of chains of start(V,V1,V2):
* Chain [16]: 1*s(2)+1*s(3)+2
Such that:s(2) =< V1
s(3) =< V2
with precondition: [V>=0,V1>=0]
* Chain [15]: 1
with precondition: [V1=0,V>=0]
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [16] with precondition: [V>=0,V1>=0]
- Upper bound: V1+2+nat(V2)
- Complexity: n
* Chain [15] with precondition: [V1=0,V>=0]
- Upper bound: 1
- Complexity: constant
### Maximum cost of start(V,V1,V2): V1+1+nat(V2)+1
Asymptotic class: n
* Total analysis performed in 115 ms.