# Inferring Expected Runtimes Using Sizes

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

### Initial Complexity Problem (after preprocessing)

Start:f
Program_Vars:Arg_0, Arg_1
Temp_Vars:
Locations:f, g, i
Transitions:
f(Arg_0,Arg_1) -{0}> g(Arg_0,Arg_1)
g(Arg_0,Arg_1) -> i(Arg_0+1,Arg_1) :|: Arg_0<10+Arg_1
i(Arg_0,Arg_1) -> g(Geometric (1/2),Arg_1+1) :|: Arg_0<=10+Arg_1

### Timebounds:

Overall timebound:1+2*max([-(Arg_0)+10+Arg_1, 0]) {O(n)}
0,0: f->g: 1 {O(1)}
1,1: g->i: max([-(Arg_0)+10+Arg_1, 0]) {O(n)}
2,2: i->g: max([-(Arg_0)+10+Arg_1, 0]) {O(n)}

### Expected Timebounds:

Overall expected timebound: 2*Arg_0+21+2*Arg_1 {O(n)}
0: f->[1:g]: 1 {O(1)}
1: g->[1:i]: 10+Arg_0+Arg_1 {O(n)}
2: i->[1:g]: 10+Arg_0+Arg_1 {O(n)}

### Costbounds:

Overall costbound: inf {Infinity}
0,0: f->g: inf {Infinity}
1,1: g->i: inf {Infinity}
2,2: i->g: inf {Infinity}

### Expected Costbounds:

Overall expected costbound: 2*Arg_0+20+2*Arg_1 {O(n)}
0: f->[1:g]: 0 {O(1)}
1: g->[1:i]: 10+Arg_0+Arg_1 {O(n)}
2: i->[1:g]: 10+Arg_0+Arg_1 {O(n)}

### Sizebounds:

0,0: f->g, Arg_0: Arg_0 {O(n)}
0,0: f->g, Arg_1: Arg_1 {O(n)}
1,1: g->i, Arg_1: Arg_1+max([-(Arg_0)+10+Arg_1, 0]) {O(n)}
2,2: i->g, Arg_1: Arg_1+max([-(Arg_0)+10+Arg_1, 0]) {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)}
(1: g->[1:i], i), Arg_0: 10+2*(10+Arg_0+Arg_1)+Arg_1+2*Arg_0 {O(n)}
(1: g->[1:i], i), Arg_1: 10+Arg_0+2*Arg_1 {O(n)}
(2: i->[1:g], g), Arg_0: 10+2*(10+Arg_0+Arg_1)+Arg_1+2*Arg_0 {O(n)}
(2: i->[1:g], g), Arg_1: 10+Arg_0+2*Arg_1 {O(n)}