(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:

first(0, X) → nil
first(s(X), cons(Y, Z)) → cons(Y, n__first(X, activate(Z)))
from(X) → cons(X, n__from(s(X)))
first(X1, X2) → n__first(X1, X2)
from(X) → n__from(X)
activate(n__first(X1, X2)) → first(X1, X2)
activate(n__from(X)) → from(X)
activate(X) → X

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:

first(0, X) → nil [1]
first(s(X), cons(Y, Z)) → cons(Y, n__first(X, activate(Z))) [1]
from(X) → cons(X, n__from(s(X))) [1]
first(X1, X2) → n__first(X1, X2) [1]
from(X) → n__from(X) [1]
activate(n__first(X1, X2)) → first(X1, X2) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [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:

first(0, X) → nil [1]
first(s(X), cons(Y, Z)) → cons(Y, n__first(X, activate(Z))) [1]
from(X) → cons(X, n__from(s(X))) [1]
first(X1, X2) → n__first(X1, X2) [1]
from(X) → n__from(X) [1]
activate(n__first(X1, X2)) → first(X1, X2) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [1]

The TRS has the following type information:
first :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
0 :: 0:s
nil :: nil:cons:n__first:n__from
s :: 0:s → 0:s
cons :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
n__first :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
activate :: nil:cons:n__first:n__from → nil:cons:n__first:n__from
from :: 0:s → nil:cons:n__first:n__from
n__from :: 0:s → nil:cons:n__first:n__from

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:
none

And the following fresh constants: none

(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:

first(0, X) → nil [1]
first(s(X), cons(Y, Z)) → cons(Y, n__first(X, activate(Z))) [1]
from(X) → cons(X, n__from(s(X))) [1]
first(X1, X2) → n__first(X1, X2) [1]
from(X) → n__from(X) [1]
activate(n__first(X1, X2)) → first(X1, X2) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [1]

The TRS has the following type information:
first :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
0 :: 0:s
nil :: nil:cons:n__first:n__from
s :: 0:s → 0:s
cons :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
n__first :: 0:s → nil:cons:n__first:n__from → nil:cons:n__first:n__from
activate :: nil:cons:n__first:n__from → nil:cons:n__first:n__from
from :: 0:s → nil:cons:n__first:n__from
n__from :: 0:s → nil:cons:n__first:n__from

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
nil => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ from(X) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ first(X1, X2) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
first(z, z') -{ 1 }→ 0 :|: z' = X, X >= 0, z = 0
first(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
first(z, z') -{ 1 }→ 1 + Y + (1 + X + activate(Z)) :|: Z >= 0, z = 1 + X, Y >= 0, X >= 0, z' = 1 + Y + Z
from(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
from(z) -{ 1 }→ 1 + X + (1 + (1 + X)) :|: X >= 0, z = X

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, V1),0,[first(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[from(V, Out)],[V >= 0]).
eq(start(V, V1),0,[activate(V, Out)],[V >= 0]).
eq(first(V, V1, Out),1,[],[Out = 0,V1 = X3,X3 >= 0,V = 0]).
eq(first(V, V1, Out),1,[activate(Z1, Ret11)],[Out = 2 + Ret11 + X4 + Y1,Z1 >= 0,V = 1 + X4,Y1 >= 0,X4 >= 0,V1 = 1 + Y1 + Z1]).
eq(from(V, Out),1,[],[Out = 3 + 2*X5,X5 >= 0,V = X5]).
eq(first(V, V1, Out),1,[],[Out = 1 + X11 + X21,X11 >= 0,X21 >= 0,V = X11,V1 = X21]).
eq(from(V, Out),1,[],[Out = 1 + X6,X6 >= 0,V = X6]).
eq(activate(V, Out),1,[first(X12, X22, Ret)],[Out = Ret,X12 >= 0,X22 >= 0,V = 1 + X12 + X22]).
eq(activate(V, Out),1,[from(X7, Ret1)],[Out = Ret1,V = 1 + X7,X7 >= 0]).
eq(activate(V, Out),1,[],[Out = X8,X8 >= 0,V = X8]).
input_output_vars(first(V,V1,Out),[V,V1],[Out]).
input_output_vars(from(V,Out),[V],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).

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

#### Computed strongly connected components
0. non_recursive : [from/2]
1. recursive : [activate/2,first/3]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into from/2
1. SCC is partially evaluated into activate/2
2. SCC is partially evaluated into start/2

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

### Specialization of cost equations from/2
* CE 11 is refined into CE [13]
* CE 12 is refined into CE [14]


### Cost equations --> "Loop" of from/2
* CEs [13] --> Loop 7
* CEs [14] --> Loop 8

### Ranking functions of CR from(V,Out)

#### Partial ranking functions of CR from(V,Out)


### Specialization of cost equations activate/2
* CE 6 is refined into CE [15]
* CE 10 is refined into CE [16]
* CE 8 is refined into CE [17]
* CE 9 is refined into CE [18,19]
* CE 7 is refined into CE [20]


### Cost equations --> "Loop" of activate/2
* CEs [20] --> Loop 9
* CEs [19] --> Loop 10
* CEs [15,16,18] --> Loop 11
* CEs [17] --> Loop 12

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

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


### Specialization of cost equations start/2
* CE 2 is refined into CE [21]
* CE 3 is refined into CE [22,23,24,25,26,27]
* CE 4 is refined into CE [28,29]
* CE 5 is refined into CE [30,31,32,33,34,35]


### Cost equations --> "Loop" of start/2
* CEs [21,22,23,24,25,26,27,28,29,30,31,32,33,34,35] --> Loop 13

### Ranking functions of CR start(V,V1)

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


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

#### Cost of chains of from(V,Out):
* Chain [8]: 1
with precondition: [V+1=Out,V>=0]

* Chain [7]: 1
with precondition: [2*V+3=Out,V>=0]


#### Cost of chains of activate(V,Out):
* Chain [[9],12]: 2*it(9)+2
Such that:it(9) =< V

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

* Chain [[9],11]: 2*it(9)+2
Such that:it(9) =< V

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

* Chain [[9],10]: 2*it(9)+2
Such that:it(9) =< V

with precondition: [3*Out>=2*V+7,2*V>=Out+3]

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

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

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


#### Cost of chains of start(V,V1):
* Chain [13]: 6*s(1)+6*s(4)+3
Such that:aux(1) =< V
aux(2) =< V1
s(4) =< aux(1)
s(1) =< aux(2)

with precondition: [V>=0]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [13] with precondition: [V>=0]
- Upper bound: 6*V+3+nat(V1)*6
- Complexity: n

### Maximum cost of start(V,V1): 6*V+3+nat(V1)*6
Asymptotic class: n
* Total analysis performed in 114 ms.

(10) BOUNDS(1, n^1)