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

not(true) → false
not(false) → true
evenodd(x, 0) → not(evenodd(x, s(0)))
evenodd(0, s(0)) → false
evenodd(s(x), s(0)) → evenodd(x, 0)

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:

not(true) → false [1]
not(false) → true [1]
evenodd(x, 0) → not(evenodd(x, s(0))) [1]
evenodd(0, s(0)) → false [1]
evenodd(s(x), s(0)) → evenodd(x, 0) [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:

not(true) → false [1]
not(false) → true [1]
evenodd(x, 0) → not(evenodd(x, s(0))) [1]
evenodd(0, s(0)) → false [1]
evenodd(s(x), s(0)) → evenodd(x, 0) [1]

The TRS has the following type information:
not :: true:false → true:false
true :: true:false
false :: true:false
evenodd :: 0:s → 0:s → true:false
0 :: 0:s
s :: 0:s → 0:s

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:

evenodd(v0, v1) → null_evenodd [0]
not(v0) → null_not [0]

And the following fresh constants:

null_evenodd, null_not

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

not(true) → false [1]
not(false) → true [1]
evenodd(x, 0) → not(evenodd(x, s(0))) [1]
evenodd(0, s(0)) → false [1]
evenodd(s(x), s(0)) → evenodd(x, 0) [1]
evenodd(v0, v1) → null_evenodd [0]
not(v0) → null_not [0]

The TRS has the following type information:
not :: true:false:null_evenodd:null_not → true:false:null_evenodd:null_not
true :: true:false:null_evenodd:null_not
false :: true:false:null_evenodd:null_not
evenodd :: 0:s → 0:s → true:false:null_evenodd:null_not
0 :: 0:s
s :: 0:s → 0:s
null_evenodd :: true:false:null_evenodd:null_not
null_not :: true:false:null_evenodd:null_not

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:

true => 2
false => 1
0 => 0
null_evenodd => 0
null_not => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

evenodd(z, z') -{ 1 }→ not(evenodd(x, 1 + 0)) :|: x >= 0, z = x, z' = 0
evenodd(z, z') -{ 1 }→ evenodd(x, 0) :|: x >= 0, z' = 1 + 0, z = 1 + x
evenodd(z, z') -{ 1 }→ 1 :|: z' = 1 + 0, z = 0
evenodd(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
not(z) -{ 1 }→ 2 :|: z = 1
not(z) -{ 1 }→ 1 :|: z = 2
not(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, V1),0,[not(V, Out)],[V >= 0]).
eq(start(V, V1),0,[evenodd(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(not(V, Out),1,[],[Out = 1,V = 2]).
eq(not(V, Out),1,[],[Out = 2,V = 1]).
eq(evenodd(V, V1, Out),1,[evenodd(V2, 1 + 0, Ret0),not(Ret0, Ret)],[Out = Ret,V2 >= 0,V = V2,V1 = 0]).
eq(evenodd(V, V1, Out),1,[],[Out = 1,V1 = 1,V = 0]).
eq(evenodd(V, V1, Out),1,[evenodd(V3, 0, Ret1)],[Out = Ret1,V3 >= 0,V1 = 1,V = 1 + V3]).
eq(evenodd(V, V1, Out),0,[],[Out = 0,V4 >= 0,V5 >= 0,V = V4,V1 = V5]).
eq(not(V, Out),0,[],[Out = 0,V6 >= 0,V = V6]).
input_output_vars(not(V,Out),[V],[Out]).
input_output_vars(evenodd(V,V1,Out),[V,V1],[Out]).

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

#### Computed strongly connected components
0. non_recursive : [not/2]
1. recursive [non_tail] : [evenodd/3]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into not/2
1. SCC is partially evaluated into evenodd/3
2. SCC is partially evaluated into start/2

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

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


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

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

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


### Specialization of cost equations evenodd/3
* CE 10 is refined into CE [14]
* CE 8 is refined into CE [15]
* CE 9 is refined into CE [16]
* CE 7 is refined into CE [17,18,19]


### Cost equations --> "Loop" of evenodd/3
* CEs [16] --> Loop 12
* CEs [17] --> Loop 13
* CEs [18] --> Loop 14
* CEs [19] --> Loop 15
* CEs [14] --> Loop 16
* CEs [15] --> Loop 17

### Ranking functions of CR evenodd(V,V1,Out)
* RF of phase [12,13,14,15]: [2*V-V1+1]

#### Partial ranking functions of CR evenodd(V,V1,Out)
* Partial RF of phase [12,13,14,15]:
- RF of loop [12:1]:
V
V1 depends on loops [13:1,14:1,15:1]
- RF of loop [13:1,14:1,15:1]:
-V1+1 depends on loops [12:1]


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


### Cost equations --> "Loop" of start/2
* CEs [25] --> Loop 18
* CEs [21] --> Loop 19
* CEs [20] --> Loop 20
* CEs [22,23,24] --> Loop 21

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

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


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

#### Cost of chains of not(V,Out):
* Chain [11]: 1
with precondition: [V=1,Out=2]

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

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


#### Cost of chains of evenodd(V,V1,Out):
* Chain [[12,13,14,15],17]: 1*it(12)+5*it(13)+1
Such that:it(12) =< V
aux(13) =< 2*V-V1+1
it(12) =< aux(13)
it(13) =< aux(13)

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

* Chain [[12,13,14,15],16]: 1*it(12)+5*it(13)+0
Such that:it(12) =< V
aux(9) =< 2*V-V1+1
it(12) =< aux(9)
it(13) =< aux(9)

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

* Chain [17]: 1
with precondition: [V=0,V1=1,Out=1]

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


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

with precondition: [V>=0]

* Chain [20]: 1
with precondition: [V=1]

* Chain [19]: 1
with precondition: [V=2]

* Chain [18]: 1*s(7)+5*s(9)+1
Such that:s(7) =< V
s(8) =< 2*V-V1+1
s(7) =< s(8)
s(9) =< s(8)

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


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [21] with precondition: [V>=0]
- Upper bound: V+1+nat(2*V-V1+1)*5
- Complexity: n
* Chain [20] with precondition: [V=1]
- Upper bound: 1
- Complexity: constant
* Chain [19] with precondition: [V=2]
- Upper bound: 1
- Complexity: constant
* Chain [18] with precondition: [1>=V1,V1>=0,V>=V1]
- Upper bound: 11*V-5*V1+6
- Complexity: n

### Maximum cost of start(V,V1): nat(2*V-V1+1)*5+V+1
Asymptotic class: n
* Total analysis performed in 158 ms.

(10) BOUNDS(1, n^1)