# Inferring Expected Runtimes Using Sizes

KoAT2 Proof WORST_CASE( ?, 2*Arg_1+2*Arg_2+2/3*Arg_0+2/3*Arg_3 {O(n)})

### Initial Complexity Problem (after preprocessing)

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

### Timebounds:

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

### Expected Timebounds:

Overall expected timebound: inf {Infinity}
0: f->[1:g]: 1 {O(1)}
1: g->[1:h]: inf {Infinity}
2: h->[1/2:g; 1/2:g]: 2*Arg_1+2*Arg_2 {O(n)}
3: h->[1/4:g; 1/4:g; 1/4:g; 1/4:g]: 2/3*Arg_0+2/3*Arg_3 {O(n)}

### Costbounds:

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

### Expected Costbounds:

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

### 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)}
1,1: g->h, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
1,1: g->h, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
1,1: g->h, Arg_2: Arg_2 {O(n)}
1,1: g->h, Arg_3: Arg_3 {O(n)}
2,2: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
2,2: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
2,2: h->g, Arg_2: Arg_2 {O(n)}
2,2: h->g, Arg_3: Arg_3 {O(n)}
3,2: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
3,2: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
3,2: h->g, Arg_2: Arg_2 {O(n)}
3,2: h->g, Arg_3: Arg_3 {O(n)}
4,3: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
4,3: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
4,3: h->g, Arg_2: Arg_2 {O(n)}
4,3: h->g, Arg_3: Arg_3 {O(n)}
5,3: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
5,3: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
5,3: h->g, Arg_2: Arg_2 {O(n)}
5,3: h->g, Arg_3: Arg_3 {O(n)}
6,3: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
6,3: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
6,3: h->g, Arg_2: Arg_2 {O(n)}
6,3: h->g, Arg_3: Arg_3 {O(n)}
7,3: h->g, Arg_0: 6*max([-(Arg_0)+Arg_3, 0])+Arg_0 {O(n)}
7,3: h->g, Arg_1: Arg_1+max([-(Arg_1)+Arg_2, 0]) {O(n)}
7,3: h->g, Arg_2: Arg_2 {O(n)}
7,3: h->g, Arg_3: Arg_3 {O(n)}

### 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)}
(1: g->[1:h], h), Arg_0: 6*(Arg_0+Arg_3)+Arg_0 {O(n)}
(1: g->[1:h], h), Arg_1: 2*Arg_1+Arg_2 {O(n)}
(1: g->[1:h], h), Arg_2: Arg_2 {O(n)}
(1: g->[1:h], h), Arg_3: Arg_3 {O(n)}
(2: h->[1/2:g; 1/2:g], g), Arg_0: 6*(Arg_0+Arg_3)+Arg_0 {O(n)}
(2: h->[1/2:g; 1/2:g], g), Arg_1: 2*Arg_1+Arg_2 {O(n)}
(2: h->[1/2:g; 1/2:g], g), Arg_2: Arg_2 {O(n)}
(2: h->[1/2:g; 1/2:g], g), Arg_3: Arg_3 {O(n)}
(3: h->[1/4:g; 1/4:g; 1/4:g; 1/4:g], g), Arg_0: 6*(Arg_0+Arg_3)+Arg_0 {O(n)}
(3: h->[1/4:g; 1/4:g; 1/4:g; 1/4:g], g), Arg_1: 2*Arg_1+Arg_2 {O(n)}
(3: h->[1/4:g; 1/4:g; 1/4:g; 1/4:g], g), Arg_2: Arg_2 {O(n)}
(3: h->[1/4:g; 1/4:g; 1/4:g; 1/4:g], g), Arg_3: Arg_3 {O(n)}