(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(s(X)) → f(X)
g(cons(0, Y)) → g(Y)
g(cons(s(X), Y)) → s(X)
h(cons(X, Y)) → h(g(cons(X, Y)))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(s(X)) → f(X) [1]
g(cons(0, Y)) → g(Y) [1]
g(cons(s(X), Y)) → s(X) [1]
h(cons(X, Y)) → h(g(cons(X, Y))) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(s(X)) → f(X) [1]
g(cons(0, Y)) → g(Y) [1]
g(cons(s(X), Y)) → s(X) [1]
h(cons(X, Y)) → h(g(cons(X, Y))) [1]

The TRS has the following type information:
f :: s:0:cons → f
s :: s:0:cons → s:0:cons
g :: s:0:cons → s:0:cons
cons :: s:0:cons → s:0:cons → s:0:cons
0 :: s:0:cons
h :: s:0:cons → h

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

f(v0) → null_f [0]
g(v0) → null_g [0]
h(v0) → null_h [0]

And the following fresh constants:

null_f, null_g, null_h

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(s(X)) → f(X) [1]
g(cons(0, Y)) → g(Y) [1]
g(cons(s(X), Y)) → s(X) [1]
h(cons(X, Y)) → h(g(cons(X, Y))) [1]
f(v0) → null_f [0]
g(v0) → null_g [0]
h(v0) → null_h [0]

The TRS has the following type information:
f :: s:0:cons:null_g → null_f
s :: s:0:cons:null_g → s:0:cons:null_g
g :: s:0:cons:null_g → s:0:cons:null_g
cons :: s:0:cons:null_g → s:0:cons:null_g → s:0:cons:null_g
0 :: s:0:cons:null_g
h :: s:0:cons:null_g → null_h
null_f :: null_f
null_g :: s:0:cons:null_g
null_h :: null_h

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
null_f => 0
null_g => 0
null_h => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

f(z) -{ 1 }→ f(X) :|: z = 1 + X, X >= 0
f(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
g(z) -{ 1 }→ g(Y) :|: Y >= 0, z = 1 + 0 + Y
g(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
g(z) -{ 1 }→ 1 + X :|: z = 1 + (1 + X) + Y, Y >= 0, X >= 0
h(z) -{ 1 }→ h(g(1 + X + Y)) :|: Y >= 0, z = 1 + X + Y, X >= 0
h(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V),0,[f(V, Out)],[V >= 0]).
eq(start(V),0,[g(V, Out)],[V >= 0]).
eq(start(V),0,[h(V, Out)],[V >= 0]).
eq(f(V, Out),1,[f(X1, Ret)],[Out = Ret,V = 1 + X1,X1 >= 0]).
eq(g(V, Out),1,[g(Y1, Ret1)],[Out = Ret1,Y1 >= 0,V = 1 + Y1]).
eq(g(V, Out),1,[],[Out = 1 + X2,V = 2 + X2 + Y2,Y2 >= 0,X2 >= 0]).
eq(h(V, Out),1,[g(1 + X3 + Y3, Ret0),h(Ret0, Ret2)],[Out = Ret2,Y3 >= 0,V = 1 + X3 + Y3,X3 >= 0]).
eq(f(V, Out),0,[],[Out = 0,V1 >= 0,V = V1]).
eq(g(V, Out),0,[],[Out = 0,V2 >= 0,V = V2]).
eq(h(V, Out),0,[],[Out = 0,V3 >= 0,V = V3]).
input_output_vars(f(V,Out),[V],[Out]).
input_output_vars(g(V,Out),[V],[Out]).
input_output_vars(h(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [f/2]
1. recursive : [g/2]
2. recursive : [h/2]
3. non_recursive : [start/1]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into f/2
1. SCC is partially evaluated into g/2
2. SCC is partially evaluated into h/2
3. SCC is partially evaluated into start/1

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations f/2
* CE 6 is refined into CE [12]
* CE 5 is refined into CE [13]


### Cost equations --> "Loop" of f/2
* CEs [13] --> Loop 9
* CEs [12] --> Loop 10

### Ranking functions of CR f(V,Out)
* RF of phase [9]: [V]

#### Partial ranking functions of CR f(V,Out)
* Partial RF of phase [9]:
- RF of loop [9:1]:
V


### Specialization of cost equations g/2
* CE 8 is refined into CE [14]
* CE 9 is refined into CE [15]
* CE 7 is refined into CE [16]


### Cost equations --> "Loop" of g/2
* CEs [16] --> Loop 11
* CEs [14] --> Loop 12
* CEs [15] --> Loop 13

### Ranking functions of CR g(V,Out)
* RF of phase [11]: [V]

#### Partial ranking functions of CR g(V,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V


### Specialization of cost equations h/2
* CE 11 is refined into CE [17]
* CE 10 is refined into CE [18,19]


### Cost equations --> "Loop" of h/2
* CEs [19] --> Loop 14
* CEs [18] --> Loop 15
* CEs [17] --> Loop 16

### Ranking functions of CR h(V,Out)
* RF of phase [14]: [V-1]

#### Partial ranking functions of CR h(V,Out)
* Partial RF of phase [14]:
- RF of loop [14:1]:
V-1


### Specialization of cost equations start/1
* CE 2 is refined into CE [20]
* CE 3 is refined into CE [21,22]
* CE 4 is refined into CE [23]


### Cost equations --> "Loop" of start/1
* CEs [20,21,22,23] --> Loop 17

### Ranking functions of CR start(V)

#### Partial ranking functions of CR start(V)


Computing Bounds
=====================================

#### Cost of chains of f(V,Out):
* Chain [[9],10]: 1*it(9)+0
Such that:it(9) =< V

with precondition: [Out=0,V>=1]

* Chain [10]: 0
with precondition: [Out=0,V>=0]


#### Cost of chains of g(V,Out):
* Chain [[11],13]: 1*it(11)+0
Such that:it(11) =< V

with precondition: [Out=0,V>=1]

* Chain [[11],12]: 1*it(11)+1
Such that:it(11) =< V-Out

with precondition: [Out>=1,V>=Out+2]

* Chain [13]: 0
with precondition: [Out=0,V>=0]

* Chain [12]: 1
with precondition: [Out>=1,V>=Out+1]


#### Cost of chains of h(V,Out):
* Chain [[14],16]: 3*it(14)+0
Such that:aux(3) =< V
it(14) =< aux(3)

with precondition: [Out=0,V>=2]

* Chain [[14],15,16]: 4*it(14)+1
Such that:aux(4) =< V
it(14) =< aux(4)

with precondition: [Out=0,V>=2]

* Chain [16]: 0
with precondition: [Out=0,V>=0]

* Chain [15,16]: 1*s(7)+1
Such that:s(7) =< V

with precondition: [Out=0,V>=1]


#### Cost of chains of start(V):
* Chain [17]: 11*s(13)+1
Such that:aux(6) =< V
s(13) =< aux(6)

with precondition: [V>=0]


Closed-form bounds of start(V):
-------------------------------------
* Chain [17] with precondition: [V>=0]
- Upper bound: 11*V+1
- Complexity: n

### Maximum cost of start(V): 11*V+1
Asymptotic class: n
* Total analysis performed in 116 ms.

(10) BOUNDS(1, n^1)