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

ge(x, 0) → true
ge(0, s(y)) → false
ge(s(x), s(y)) → ge(x, y)
minus(x, 0) → x
minus(0, y) → 0
minus(s(x), s(y)) → minus(x, y)
id_inc(x) → x
id_inc(x) → s(x)
div(x, y) → if(ge(y, s(0)), ge(x, y), x, y)
if(false, b, x, y) → div_by_zero
if(true, false, x, y) → 0
if(true, true, x, y) → id_inc(div(minus(x, y), 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:

ge(x, 0) → true [1]
ge(0, s(y)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
minus(x, 0) → x [1]
minus(0, y) → 0 [1]
minus(s(x), s(y)) → minus(x, y) [1]
id_inc(x) → x [1]
id_inc(x) → s(x) [1]
div(x, y) → if(ge(y, s(0)), ge(x, y), x, y) [1]
if(false, b, x, y) → div_by_zero [1]
if(true, false, x, y) → 0 [1]
if(true, true, x, y) → id_inc(div(minus(x, y), 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:

ge(x, 0) → true [1]
ge(0, s(y)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
minus(x, 0) → x [1]
minus(0, y) → 0 [1]
minus(s(x), s(y)) → minus(x, y) [1]
id_inc(x) → x [1]
id_inc(x) → s(x) [1]
div(x, y) → if(ge(y, s(0)), ge(x, y), x, y) [1]
if(false, b, x, y) → div_by_zero [1]
if(true, false, x, y) → 0 [1]
if(true, true, x, y) → id_inc(div(minus(x, y), y)) [1]

The TRS has the following type information:
ge :: 0:s:div_by_zero → 0:s:div_by_zero → true:false
0 :: 0:s:div_by_zero
true :: true:false
s :: 0:s:div_by_zero → 0:s:div_by_zero
false :: true:false
minus :: 0:s:div_by_zero → 0:s:div_by_zero → 0:s:div_by_zero
id_inc :: 0:s:div_by_zero → 0:s:div_by_zero
div :: 0:s:div_by_zero → 0:s:div_by_zero → 0:s:div_by_zero
if :: true:false → true:false → 0:s:div_by_zero → 0:s:div_by_zero → 0:s:div_by_zero
div_by_zero :: 0:s:div_by_zero

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:

ge(v0, v1) → null_ge [0]
minus(v0, v1) → null_minus [0]
if(v0, v1, v2, v3) → null_if [0]

And the following fresh constants:

null_ge, null_minus, null_if

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

ge(x, 0) → true [1]
ge(0, s(y)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
minus(x, 0) → x [1]
minus(0, y) → 0 [1]
minus(s(x), s(y)) → minus(x, y) [1]
id_inc(x) → x [1]
id_inc(x) → s(x) [1]
div(x, y) → if(ge(y, s(0)), ge(x, y), x, y) [1]
if(false, b, x, y) → div_by_zero [1]
if(true, false, x, y) → 0 [1]
if(true, true, x, y) → id_inc(div(minus(x, y), y)) [1]
ge(v0, v1) → null_ge [0]
minus(v0, v1) → null_minus [0]
if(v0, v1, v2, v3) → null_if [0]

The TRS has the following type information:
ge :: 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if → true:false:null_ge
0 :: 0:s:div_by_zero:null_minus:null_if
true :: true:false:null_ge
s :: 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if
false :: true:false:null_ge
minus :: 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if
id_inc :: 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if
div :: 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if
if :: true:false:null_ge → true:false:null_ge → 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if → 0:s:div_by_zero:null_minus:null_if
div_by_zero :: 0:s:div_by_zero:null_minus:null_if
null_ge :: true:false:null_ge
null_minus :: 0:s:div_by_zero:null_minus:null_if
null_if :: 0:s:div_by_zero:null_minus:null_if

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
true => 2
false => 1
div_by_zero => 1
null_ge => 0
null_minus => 0
null_if => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

div(z, z') -{ 1 }→ if(ge(y, 1 + 0), ge(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
ge(z, z') -{ 1 }→ ge(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
ge(z, z') -{ 1 }→ 2 :|: x >= 0, z = x, z' = 0
ge(z, z') -{ 1 }→ 1 :|: z' = 1 + y, y >= 0, z = 0
ge(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
id_inc(z) -{ 1 }→ x :|: x >= 0, z = x
id_inc(z) -{ 1 }→ 1 + x :|: x >= 0, z = x
if(z, z', z'', z1) -{ 1 }→ id_inc(div(minus(x, y), y)) :|: z = 2, z1 = y, z' = 2, x >= 0, y >= 0, z'' = x
if(z, z', z'', z1) -{ 1 }→ 1 :|: b >= 0, z1 = y, z = 1, x >= 0, y >= 0, z' = b, z'' = x
if(z, z', z'', z1) -{ 1 }→ 0 :|: z = 2, z1 = y, x >= 0, y >= 0, z'' = x, z' = 1
if(z, z', z'', z1) -{ 0 }→ 0 :|: z1 = v3, v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0, v3 >= 0
minus(z, z') -{ 1 }→ x :|: x >= 0, z = x, z' = 0
minus(z, z') -{ 1 }→ minus(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
minus(z, z') -{ 1 }→ 0 :|: y >= 0, z = 0, z' = y
minus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1

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, V14, V15),0,[ge(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V14, V15),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V14, V15),0,[fun(V, Out)],[V >= 0]).
eq(start(V, V1, V14, V15),0,[div(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V14, V15),0,[if(V, V1, V14, V15, Out)],[V >= 0,V1 >= 0,V14 >= 0,V15 >= 0]).
eq(ge(V, V1, Out),1,[],[Out = 2,V2 >= 0,V = V2,V1 = 0]).
eq(ge(V, V1, Out),1,[],[Out = 1,V1 = 1 + V3,V3 >= 0,V = 0]).
eq(ge(V, V1, Out),1,[ge(V4, V5, Ret)],[Out = Ret,V1 = 1 + V5,V4 >= 0,V5 >= 0,V = 1 + V4]).
eq(minus(V, V1, Out),1,[],[Out = V6,V6 >= 0,V = V6,V1 = 0]).
eq(minus(V, V1, Out),1,[],[Out = 0,V7 >= 0,V = 0,V1 = V7]).
eq(minus(V, V1, Out),1,[minus(V8, V9, Ret1)],[Out = Ret1,V1 = 1 + V9,V8 >= 0,V9 >= 0,V = 1 + V8]).
eq(fun(V, Out),1,[],[Out = V10,V10 >= 0,V = V10]).
eq(fun(V, Out),1,[],[Out = 1 + V11,V11 >= 0,V = V11]).
eq(div(V, V1, Out),1,[ge(V12, 1 + 0, Ret0),ge(V13, V12, Ret11),if(Ret0, Ret11, V13, V12, Ret2)],[Out = Ret2,V13 >= 0,V12 >= 0,V = V13,V1 = V12]).
eq(if(V, V1, V14, V15, Out),1,[],[Out = 1,V16 >= 0,V15 = V17,V = 1,V18 >= 0,V17 >= 0,V1 = V16,V14 = V18]).
eq(if(V, V1, V14, V15, Out),1,[],[Out = 0,V = 2,V15 = V19,V20 >= 0,V19 >= 0,V14 = V20,V1 = 1]).
eq(if(V, V1, V14, V15, Out),1,[minus(V21, V22, Ret00),div(Ret00, V22, Ret01),fun(Ret01, Ret3)],[Out = Ret3,V = 2,V15 = V22,V1 = 2,V21 >= 0,V22 >= 0,V14 = V21]).
eq(ge(V, V1, Out),0,[],[Out = 0,V23 >= 0,V24 >= 0,V = V23,V1 = V24]).
eq(minus(V, V1, Out),0,[],[Out = 0,V25 >= 0,V26 >= 0,V = V25,V1 = V26]).
eq(if(V, V1, V14, V15, Out),0,[],[Out = 0,V15 = V27,V28 >= 0,V14 = V29,V30 >= 0,V = V28,V1 = V30,V29 >= 0,V27 >= 0]).
input_output_vars(ge(V,V1,Out),[V,V1],[Out]).
input_output_vars(minus(V,V1,Out),[V,V1],[Out]).
input_output_vars(fun(V,Out),[V],[Out]).
input_output_vars(div(V,V1,Out),[V,V1],[Out]).
input_output_vars(if(V,V1,V14,V15,Out),[V,V1,V14,V15],[Out]).

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

#### Computed strongly connected components
0. recursive : [ge/3]
1. non_recursive : [fun/2]
2. recursive : [minus/3]
3. recursive [non_tail] : [ (div)/3,if/5]
4. non_recursive : [start/4]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into ge/3
1. SCC is partially evaluated into fun/2
2. SCC is partially evaluated into minus/3
3. SCC is partially evaluated into (div)/3
4. SCC is partially evaluated into start/4

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

### Specialization of cost equations ge/3
* CE 23 is refined into CE [24]
* CE 20 is refined into CE [25]
* CE 21 is refined into CE [26]
* CE 22 is refined into CE [27]


### Cost equations --> "Loop" of ge/3
* CEs [27] --> Loop 16
* CEs [24] --> Loop 17
* CEs [25] --> Loop 18
* CEs [26] --> Loop 19

### Ranking functions of CR ge(V,V1,Out)
* RF of phase [16]: [V,V1]

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


### Specialization of cost equations fun/2
* CE 18 is refined into CE [28]
* CE 19 is refined into CE [29]


### Cost equations --> "Loop" of fun/2
* CEs [28] --> Loop 20
* CEs [29] --> Loop 21

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

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


### Specialization of cost equations minus/3
* CE 10 is refined into CE [30]
* CE 11 is refined into CE [31]
* CE 13 is refined into CE [32]
* CE 12 is refined into CE [33]


### Cost equations --> "Loop" of minus/3
* CEs [33] --> Loop 22
* CEs [30] --> Loop 23
* CEs [31,32] --> Loop 24

### Ranking functions of CR minus(V,V1,Out)
* RF of phase [22]: [V,V1]

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


### Specialization of cost equations (div)/3
* CE 17 is refined into CE [34,35]
* CE 14 is refined into CE [36,37,38,39,40,41,42,43,44,45,46]
* CE 16 is refined into CE [47,48]
* CE 15 is refined into CE [49,50,51,52]


### Cost equations --> "Loop" of (div)/3
* CEs [52] --> Loop 25
* CEs [51] --> Loop 26
* CEs [50] --> Loop 27
* CEs [49] --> Loop 28
* CEs [34,35] --> Loop 29
* CEs [36,37,39] --> Loop 30
* CEs [38,40,41,42,43,44,45,46,47,48] --> Loop 31

### Ranking functions of CR div(V,V1,Out)
* RF of phase [25,26]: [V,V-V1+1]

#### Partial ranking functions of CR div(V,V1,Out)
* Partial RF of phase [25,26]:
- RF of loop [25:1,26:1]:
V
V-V1+1


### Specialization of cost equations start/4
* CE 3 is refined into CE [53,54,55,56,57,58,59,60,61,62,63,64,65,66]
* CE 4 is refined into CE [67]
* CE 2 is refined into CE [68]
* CE 5 is refined into CE [69]
* CE 6 is refined into CE [70,71,72,73,74]
* CE 7 is refined into CE [75,76,77]
* CE 8 is refined into CE [78,79]
* CE 9 is refined into CE [80,81,82,83]


### Cost equations --> "Loop" of start/4
* CEs [71,75,81] --> Loop 32
* CEs [53,54,55,56,57,58,59,60,61,62,63,64,65,66] --> Loop 33
* CEs [67] --> Loop 34
* CEs [69] --> Loop 35
* CEs [68,70,72,73,74,76,77,78,79,80,82,83] --> Loop 36

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

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


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

#### Cost of chains of ge(V,V1,Out):
* Chain [[16],19]: 1*it(16)+1
Such that:it(16) =< V

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

* Chain [[16],18]: 1*it(16)+1
Such that:it(16) =< V1

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

* Chain [[16],17]: 1*it(16)+0
Such that:it(16) =< V1

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

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

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

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


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

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


#### Cost of chains of minus(V,V1,Out):
* Chain [[22],24]: 1*it(22)+1
Such that:it(22) =< V1

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

* Chain [[22],23]: 1*it(22)+1
Such that:it(22) =< V1

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

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

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


#### Cost of chains of div(V,V1,Out):
* Chain [[25,26],31]: 12*it(25)+10*s(3)+4*s(5)+7*s(7)+2*s(32)+4
Such that:aux(1) =< 1
aux(9) =< V-V1+1
aux(3) =< V1
aux(12) =< V
s(3) =< aux(1)
s(7) =< aux(12)
s(5) =< aux(3)
aux(6) =< aux(12)
it(25) =< aux(12)
aux(6) =< aux(9)
it(25) =< aux(9)
s(32) =< aux(6)

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

* Chain [[25,26],28,31]: 12*it(25)+11*s(3)+6*s(5)+2*s(32)+4*s(33)+10
Such that:aux(14) =< 1
aux(8) =< V
aux(9) =< V-V1+1
aux(15) =< V1
aux(16) =< V-V1
s(3) =< aux(14)
s(5) =< aux(15)
aux(6) =< aux(8)
it(25) =< aux(8)
s(34) =< aux(8)
aux(6) =< aux(9)
it(25) =< aux(9)
aux(6) =< aux(16)
it(25) =< aux(16)
s(34) =< aux(16)
s(32) =< aux(6)
s(33) =< s(34)

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

* Chain [[25,26],27,31]: 12*it(25)+11*s(3)+6*s(5)+2*s(32)+4*s(33)+10
Such that:aux(18) =< 1
aux(8) =< V
aux(9) =< V-V1+1
aux(19) =< V1
aux(20) =< V-V1
s(3) =< aux(18)
s(5) =< aux(19)
aux(6) =< aux(8)
it(25) =< aux(8)
s(34) =< aux(8)
aux(6) =< aux(9)
it(25) =< aux(9)
aux(6) =< aux(20)
it(25) =< aux(20)
s(34) =< aux(20)
s(32) =< aux(6)
s(33) =< s(34)

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

* Chain [31]: 10*s(3)+4*s(5)+3*s(7)+4
Such that:aux(1) =< 1
aux(2) =< V
aux(3) =< V1
s(3) =< aux(1)
s(7) =< aux(2)
s(5) =< aux(3)

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

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

* Chain [29]: 4
with precondition: [V1=0,Out=1,V>=0]

* Chain [28,31]: 11*s(3)+6*s(5)+10
Such that:aux(14) =< 1
aux(15) =< V1
s(3) =< aux(14)
s(5) =< aux(15)

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

* Chain [27,31]: 11*s(3)+6*s(5)+10
Such that:aux(18) =< 1
aux(19) =< V1
s(3) =< aux(18)
s(5) =< aux(19)

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


#### Cost of chains of start(V,V1,V14,V15):
* Chain [36]: 36*s(83)+11*s(84)+64*s(91)+24*s(102)+4*s(104)+8*s(105)+12*s(108)+2*s(109)+10
Such that:aux(27) =< 1
aux(28) =< V
aux(29) =< V-V1
aux(30) =< V-V1+1
aux(31) =< V1
s(84) =< aux(28)
s(83) =< aux(31)
s(91) =< aux(27)
s(101) =< aux(28)
s(102) =< aux(28)
s(103) =< aux(28)
s(101) =< aux(30)
s(102) =< aux(30)
s(101) =< aux(29)
s(102) =< aux(29)
s(103) =< aux(29)
s(104) =< s(101)
s(105) =< s(103)
s(107) =< aux(28)
s(108) =< aux(28)
s(107) =< aux(30)
s(108) =< aux(30)
s(109) =< s(107)

with precondition: [V>=0]

* Chain [35]: 1
with precondition: [V=1,V1>=0,V14>=0,V15>=0]

* Chain [34]: 1
with precondition: [V=2,V1=1,V14>=0,V15>=0]

* Chain [33]: 212*s(125)+6*s(127)+92*s(134)+20*s(156)+48*s(173)+8*s(175)+16*s(176)+24*s(179)+4*s(180)+13
Such that:aux(40) =< 1
aux(41) =< V14
aux(42) =< V14-2*V15
aux(43) =< V14-2*V15+1
aux(44) =< V14-V15
aux(45) =< V15
s(125) =< aux(40)
s(127) =< aux(41)
s(134) =< aux(45)
s(156) =< aux(44)
s(172) =< aux(44)
s(173) =< aux(44)
s(174) =< aux(44)
s(172) =< aux(43)
s(173) =< aux(43)
s(172) =< aux(42)
s(173) =< aux(42)
s(174) =< aux(42)
s(175) =< s(172)
s(176) =< s(174)
s(178) =< aux(44)
s(179) =< aux(44)
s(178) =< aux(43)
s(179) =< aux(43)
s(180) =< s(178)

with precondition: [V=2,V1=2,V14>=0,V15>=0]

* Chain [32]: 4
with precondition: [V1=0,V>=0]


Closed-form bounds of start(V,V1,V14,V15):
-------------------------------------
* Chain [36] with precondition: [V>=0]
- Upper bound: 61*V+74+nat(V1)*36
- Complexity: n
* Chain [35] with precondition: [V=1,V1>=0,V14>=0,V15>=0]
- Upper bound: 1
- Complexity: constant
* Chain [34] with precondition: [V=2,V1=1,V14>=0,V15>=0]
- Upper bound: 1
- Complexity: constant
* Chain [33] with precondition: [V=2,V1=2,V14>=0,V15>=0]
- Upper bound: 6*V14+92*V15+225+nat(V14-V15)*120
- Complexity: n
* Chain [32] with precondition: [V1=0,V>=0]
- Upper bound: 4
- Complexity: constant

### Maximum cost of start(V,V1,V14,V15): max([3,61*V+73+nat(V1)*36,nat(V14)*6+224+nat(V15)*92+nat(V14-V15)*120])+1
Asymptotic class: n
* Total analysis performed in 623 ms.

(10) BOUNDS(1, n^1)