# Inferring Expected Runtimes Using Sizes

KoAT2 Proof WORST_CASE( ?, (2+Arg_0+Arg_1)*Arg_1*Arg_1+2*((2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2) {O(n^5)})

### Initial Complexity Problem (after preprocessing)

Start:f
Program_Vars:Arg_0, Arg_1, Arg_2, Arg_3, Arg_4
Temp_Vars:
Locations:f, g, h, i, j
Transitions:
f(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> g(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4)
g(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> h(Arg_0,Arg_1,Arg_2,0,Arg_4) :|: Arg_0<Arg_1
h(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> i(Arg_0,Arg_1,Arg_2,Arg_3+1,0) :|: Arg_3<Arg_0 && 0<=Arg_3 && 1+Arg_0<=Arg_1
i(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -> i(Arg_0,Arg_1,Arg_2+Arg_0Arg_1,Arg_3,Arg_4+1) :|: Arg_4<Arg_1 && Arg_4<=Arg_1 && 0<=Arg_4 && 1<=Arg_3+Arg_4 && 2<=Arg_1+Arg_4 && 1<=Arg_0+Arg_4 && 1+Arg_3<=Arg_1 && Arg_3<=Arg_0 && 1<=Arg_3 && 3<=Arg_1+Arg_3 && 2<=Arg_0+Arg_3 && 2<=Arg_1 && 3<=Arg_0+Arg_1 && 1+Arg_0<=Arg_1 && 1<=Arg_0
i(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> h(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) :|: Arg_1<=Arg_4 && Arg_4<=Arg_1 && 0<=Arg_4 && 1<=Arg_3+Arg_4 && 2<=Arg_1+Arg_4 && 1<=Arg_0+Arg_4 && 1+Arg_3<=Arg_1 && Arg_3<=Arg_0 && 1<=Arg_3 && 3<=Arg_1+Arg_3 && 2<=Arg_0+Arg_3 && 2<=Arg_1 && 3<=Arg_0+Arg_1 && 1+Arg_0<=Arg_1 && 1<=Arg_0
h(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> g(Arg_0+1,Arg_1-1,Arg_2,Arg_3,Arg_4) :|: Arg_0<=Arg_3 && 0<=Arg_3 && 1+Arg_0<=Arg_1
g(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -{0}> j(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) :|: Arg_1<=Arg_0
j(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) -> 1/2:j(Arg_0,Arg_1,Arg_2-1,Arg_3,Arg_4) :+: 1/2:j(Arg_0,Arg_1,Arg_2,Arg_3,Arg_4) :|: 0<Arg_2 && Arg_1<=Arg_0

### Timebounds:

Overall timebound:inf {Infinity}
0,0: f->g: 1 {O(1)}
1,1: g->h: max([-(Arg_0)+2+Arg_1, 0]) {O(n)}
6,6: g->j: 1 {O(1)}
2,2: h->i: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1]) {O(n^2)}
5,5: h->g: max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
3,3: i->i: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1]) {O(n^3)}
4,4: i->h: max([(-1)+Arg_1, 0])*max([-(Arg_0)+2+Arg_1, 0]) {O(n^2)}
7,7: j->j: inf {Infinity}
8,7: j->j: inf {Infinity}

### Expected Timebounds:

Overall expected timebound: (1+Arg_1)*(2+Arg_0+Arg_1)+(2+Arg_0+Arg_1)*Arg_1+(2+Arg_0+Arg_1)*Arg_1*Arg_1+2*((2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2)+3*Arg_0+4+3*Arg_1 {O(n^5)}
0: f->[1:g]: 1 {O(1)}
1: g->[1:h]: 2+Arg_0+Arg_1 {O(n)}
2: h->[1:i]: (2+Arg_0+Arg_1)*Arg_1 {O(n^2)}
3: i->[1:i]: (2+Arg_0+Arg_1)*Arg_1*Arg_1 {O(n^3)}
4: i->[1:h]: (1+Arg_1)*(2+Arg_0+Arg_1) {O(n^2)}
5: h->[1:g]: 2*Arg_0+2*Arg_1 {O(n)}
6: g->[1:j]: 1 {O(1)}
7: j->[1/2:j; 1/2:j]: 2*((2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2) {O(n^5)}

### Costbounds:

Overall costbound: inf {Infinity}
0,0: f->g: inf {Infinity}
1,1: g->h: inf {Infinity}
6,6: g->j: inf {Infinity}
2,2: h->i: inf {Infinity}
5,5: h->g: inf {Infinity}
3,3: i->i: inf {Infinity}
4,4: i->h: inf {Infinity}
7,7: j->j: inf {Infinity}
8,7: j->j: inf {Infinity}

### Expected Costbounds:

Overall expected costbound: (2+Arg_0+Arg_1)*Arg_1*Arg_1+2*((2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2) {O(n^5)}
0: f->[1:g]: 0 {O(1)}
1: g->[1:h]: 0 {O(1)}
2: h->[1:i]: 0 {O(1)}
3: i->[1:i]: (2+Arg_0+Arg_1)*Arg_1*Arg_1 {O(n^3)}
4: i->[1:h]: 0 {O(1)}
5: h->[1:g]: 0 {O(1)}
6: g->[1:j]: 0 {O(1)}
7: j->[1/2:j; 1/2:j]: 2*((2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2) {O(n^5)}

### Sizebounds:

0,0: f->g, Arg_0: Arg_0 {O(n)}
0,0: f->g, Arg_1: Arg_1 {O(n)}
0,0: f->g, Arg_2: Arg_2 {O(n)}
0,0: f->g, Arg_3: Arg_3 {O(n)}
0,0: f->g, Arg_4: Arg_4 {O(n)}
1,1: g->h, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
1,1: g->h, Arg_1: Arg_1 {O(n)}
1,1: g->h, Arg_3: 0 {O(1)}
1,1: g->h, Arg_4: max([Arg_4, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1])]) {O(n^3)}
6,6: g->j, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
6,6: g->j, Arg_1: Arg_1 {O(n)}
6,6: g->j, Arg_3: max([Arg_3, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])]) {O(n^2)}
6,6: g->j, Arg_4: max([Arg_4, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1])]) {O(n^3)}
2,2: h->i, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
2,2: h->i, Arg_1: Arg_1 {O(n)}
2,2: h->i, Arg_3: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1]) {O(n^2)}
2,2: h->i, Arg_4: 0 {O(1)}
5,5: h->g, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
5,5: h->g, Arg_1: Arg_1 {O(n)}
5,5: h->g, Arg_3: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1]) {O(n^2)}
5,5: h->g, Arg_4: max([Arg_4, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1])]) {O(n^3)}
3,3: i->i, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
3,3: i->i, Arg_1: Arg_1 {O(n)}
3,3: i->i, Arg_3: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1]) {O(n^2)}
3,3: i->i, Arg_4: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1]) {O(n^3)}
4,4: i->h, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
4,4: i->h, Arg_1: Arg_1 {O(n)}
4,4: i->h, Arg_3: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1]) {O(n^2)}
4,4: i->h, Arg_4: max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1]) {O(n^3)}
7,7: j->j, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
7,7: j->j, Arg_1: Arg_1 {O(n)}
7,7: j->j, Arg_3: max([Arg_3, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])]) {O(n^2)}
7,7: j->j, Arg_4: max([Arg_4, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1])]) {O(n^3)}
8,7: j->j, Arg_0: Arg_0+max([(-2)*Arg_0+2*Arg_1, 0]) {O(n)}
8,7: j->j, Arg_1: Arg_1 {O(n)}
8,7: j->j, Arg_3: max([Arg_3, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])]) {O(n^2)}
8,7: j->j, Arg_4: max([Arg_4, max([-(Arg_0)+2+Arg_1, 0])*max([0, Arg_1])*max([0, Arg_1])]) {O(n^3)}

### ExpSizeBounds:

(0: f->[1:g], g), Arg_0: Arg_0 {O(n)}
(0: f->[1:g], g), Arg_1: Arg_1 {O(n)}
(0: f->[1:g], g), Arg_2: Arg_2 {O(n)}
(0: f->[1:g], g), Arg_3: Arg_3 {O(n)}
(0: f->[1:g], g), Arg_4: Arg_4 {O(n)}
(1: g->[1:h], h), Arg_0: 2*Arg_1+3*Arg_0 {O(n)}
(1: g->[1:h], h), Arg_1: 2*Arg_0+3*Arg_1 {O(n)}
(1: g->[1:h], h), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+Arg_2 {O(n^5)}
(1: g->[1:h], h), Arg_3: 0 {O(1)}
(1: g->[1:h], h), Arg_4: max([max([(2+Arg_0+Arg_1)*Arg_1*Arg_1, 2]), Arg_4]) {O(n^3)}
(2: h->[1:i], i), Arg_0: 2*Arg_1+3*Arg_0 {O(n)}
(2: h->[1:i], i), Arg_1: Arg_1 {O(n)}
(2: h->[1:i], i), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+Arg_2 {O(n^5)}
(2: h->[1:i], i), Arg_3: (2+Arg_0+Arg_1)*Arg_1 {O(n^2)}
(2: h->[1:i], i), Arg_4: 0 {O(1)}
(3: i->[1:i], i), Arg_0: 2*Arg_1+3*Arg_0 {O(n)}
(3: i->[1:i], i), Arg_1: Arg_1 {O(n)}
(3: i->[1:i], i), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+Arg_2 {O(n^5)}
(3: i->[1:i], i), Arg_3: (2+Arg_0+Arg_1)*Arg_1 {O(n^2)}
(3: i->[1:i], i), Arg_4: (2+Arg_0+Arg_1)*Arg_1*Arg_1 {O(n^3)}
(4: i->[1:h], h), Arg_0: 2*Arg_1+3*Arg_0 {O(n)}
(4: i->[1:h], h), Arg_1: Arg_1 {O(n)}
(4: i->[1:h], h), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+Arg_2 {O(n^5)}
(4: i->[1:h], h), Arg_3: (2+Arg_0+Arg_1)*Arg_1 {O(n^2)}
(4: i->[1:h], h), Arg_4: (2+Arg_0+Arg_1)*Arg_1*Arg_1 {O(n^3)}
(5: h->[1:g], g), Arg_0: 2*Arg_1+3*Arg_0 {O(n)}
(5: h->[1:g], g), Arg_1: 2*Arg_0+3*Arg_1 {O(n)}
(5: h->[1:g], g), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+Arg_2 {O(n^5)}
(5: h->[1:g], g), Arg_3: (2+Arg_0+Arg_1)*Arg_1 {O(n^2)}
(5: h->[1:g], g), Arg_4: max([max([(2+Arg_0+Arg_1)*Arg_1*Arg_1, 2]), Arg_4]) {O(n^3)}
(6: g->[1:j], j), Arg_0: 2*Arg_1+4*Arg_0 {O(n)}
(6: g->[1:j], j), Arg_1: Arg_1 {O(n)}
(6: g->[1:j], j), Arg_2: (2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+2*Arg_2 {O(n^5)}
(6: g->[1:j], j), Arg_3: (2+Arg_0+Arg_1)*Arg_1+Arg_3 {O(n^2)}
(6: g->[1:j], j), Arg_4: max([(2+Arg_0+Arg_1)*Arg_1*Arg_1, Arg_4]) {O(n^3)}
(7: j->[1/2:j; 1/2:j], j), Arg_0: 2*Arg_1+4*Arg_0 {O(n)}
(7: j->[1/2:j; 1/2:j], j), Arg_1: Arg_1 {O(n)}
(7: j->[1/2:j; 1/2:j], j), Arg_2: 2*(2+Arg_0+Arg_1)*Arg_1*Arg_1*Arg_1*Arg_1+4*Arg_2 {O(n^5)}
(7: j->[1/2:j; 1/2:j], j), Arg_3: (2+Arg_0+Arg_1)*Arg_1+Arg_3 {O(n^2)}
(7: j->[1/2:j; 1/2:j], j), Arg_4: max([(2+Arg_0+Arg_1)*Arg_1*Arg_1, Arg_4]) {O(n^3)}