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 (⇔, 249 ms)
↳10 BOUNDS(1, n^2)
f(t, x, y) → f(g(x, y), x, s(y))
g(s(x), 0) → t
g(s(x), s(y)) → g(x, y)
f(t, x, y) → f(g(x, y), x, s(y)) [1]
g(s(x), 0) → t [1]
g(s(x), s(y)) → g(x, y) [1]
f(t, x, y) → f(g(x, y), x, s(y)) [1]
g(s(x), 0) → t [1]
g(s(x), s(y)) → g(x, y) [1]
f :: t → s:0 → s:0 → f t :: t g :: s:0 → s:0 → t s :: s:0 → s:0 0 :: s:0 |
g(v0, v1) → null_g [0]
f(v0, v1, v2) → null_f [0]
null_g, null_f
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
t => 1
0 => 0
null_g => 0
null_f => 0
f(z, z', z'') -{ 1 }→ f(g(x, y), x, 1 + y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
g(z, z') -{ 1 }→ g(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
g(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
g(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
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(f(V, V1, V2, Out),1,[g(V3, V4, Ret0),f(Ret0, V3, 1 + V4, Ret)],[Out = Ret,V1 = V3,V2 = V4,V = 1,V3 >= 0,V4 >= 0]). eq(g(V, V1, Out),1,[],[Out = 1,V5 >= 0,V = 1 + V5,V1 = 0]). eq(g(V, V1, Out),1,[g(V6, V7, Ret1)],[Out = Ret1,V1 = 1 + V7,V6 >= 0,V7 >= 0,V = 1 + V6]). eq(g(V, V1, Out),0,[],[Out = 0,V8 >= 0,V9 >= 0,V = V8,V1 = V9]). eq(f(V, V1, V2, Out),0,[],[Out = 0,V10 >= 0,V2 = V11,V12 >= 0,V = V10,V1 = V12,V11 >= 0]). 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 : [g/3]
1. recursive : [f/4]
2. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into g/3
1. SCC is partially evaluated into f/4
2. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations g/3
* CE 8 is refined into CE [9]
* CE 6 is refined into CE [10]
* CE 7 is refined into CE [11]
### Cost equations --> "Loop" of g/3
* CEs [11] --> Loop 7
* CEs [9] --> Loop 8
* CEs [10] --> Loop 9
### Ranking functions of CR g(V,V1,Out)
* RF of phase [7]: [V,V1]
#### Partial ranking functions of CR g(V,V1,Out)
* Partial RF of phase [7]:
- RF of loop [7:1]:
V
V1
### Specialization of cost equations f/4
* CE 5 is refined into CE [12]
* CE 4 is refined into CE [13,14,15]
### Cost equations --> "Loop" of f/4
* CEs [15] --> Loop 10
* CEs [14] --> Loop 11
* CEs [13] --> Loop 12
* CEs [12] --> Loop 13
### Ranking functions of CR f(V,V1,V2,Out)
* RF of phase [10]: [V1-V2]
#### Partial ranking functions of CR f(V,V1,V2,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V1-V2
### Specialization of cost equations start/3
* CE 2 is refined into CE [16]
* CE 3 is refined into CE [17,18,19]
### Cost equations --> "Loop" of start/3
* CEs [16,17,18,19] --> Loop 14
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of g(V,V1,Out):
* Chain [[7],9]: 1*it(7)+1
Such that:it(7) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [[7],8]: 1*it(7)+0
Such that:it(7) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [9]: 1
with precondition: [V1=0,Out=1,V>=1]
* Chain [8]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of f(V,V1,V2,Out):
* Chain [[10],13]: 2*it(10)+1*s(4)+0
Such that:aux(1) =< V1
it(10) =< V1-V2
s(4) =< it(10)*aux(1)
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
* Chain [[10],11,13]: 2*it(10)+1*s(4)+1*s(5)+1
Such that:aux(1) =< V1
s(5) =< V1+1
it(10) =< V1-V2
s(4) =< it(10)*aux(1)
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
* Chain [13]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]
* Chain [12,[10],13]: 2*it(10)+1*s(4)+2
Such that:aux(2) =< V1
it(10) =< aux(2)
s(4) =< it(10)*aux(2)
with precondition: [V=1,V2=0,Out=0,V1>=2]
* Chain [12,[10],11,13]: 2*it(10)+1*s(4)+1*s(5)+3
Such that:s(5) =< V1+1
aux(3) =< V1
it(10) =< aux(3)
s(4) =< it(10)*aux(3)
with precondition: [V=1,V2=0,Out=0,V1>=2]
* Chain [12,13]: 2
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [12,11,13]: 1*s(5)+3
Such that:s(5) =< 2
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [11,13]: 1*s(5)+1
Such that:s(5) =< V2+1
with precondition: [V=1,Out=0,V1>=0,V2>=0]
#### Cost of chains of start(V,V1,V2):
* Chain [14]: 1*s(22)+1*s(23)+2*s(27)+4*s(28)+6*s(29)+2*s(30)+2*s(31)+3
Such that:s(22) =< 2
s(25) =< V1+1
s(26) =< V1-V2
s(23) =< V2+1
aux(7) =< V1
s(29) =< aux(7)
s(27) =< s(25)
s(28) =< s(26)
s(30) =< s(29)*aux(7)
s(31) =< s(28)*aux(7)
with precondition: [V>=0,V1>=0]
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [14] with precondition: [V>=0,V1>=0]
- Upper bound: 6*V1+5+2*V1*V1+2*V1*nat(V1-V2)+ (2*V1+2)+nat(V2+1)+nat(V1-V2)*4
- Complexity: n^2
### Maximum cost of start(V,V1,V2): 6*V1+5+2*V1*V1+2*V1*nat(V1-V2)+ (2*V1+2)+nat(V2+1)+nat(V1-V2)*4
Asymptotic class: n^2
* Total analysis performed in 184 ms.