Expected Cost | +- [f] | 0 | +- [Program] | 0:While(n ≥ 1) | r :~ {1/2 : 0;1/2 : 1} | n :~ {1 : n + -r} | m :~ {1 : n} | 1:While(m ≥ 1) | Choice | 1/3: m :~ {1 : -1 + m} | 2/3: Skip | Tick(1) | +- While.step | | | +- [Problem] | | 0:While(n ≥ 1) | | r :~ {1/2 : 0;1/2 : 1} | | n :~ {1 : n + -r} | | m :~ {1 : n} | | 1:While(m ≥ 1) | | Choice | | 1/3: m :~ {1 : -1 + m} | | 2/3: Skip | | Tick(1) | | | +- [f] | | 0 | | | +- Expected Cost Body | | | | | +- While.step | | | | | | | +- [Problem] | | | | 1:While(m ≥ 1) | | | | Choice | | | | 1/3: m :~ {1 : -1 + m} | | | | 2/3: Skip | | | | Tick(1) | | | | | | | +- [f] | | | | 0 | | | | | | | +- Expected Cost Body | | | | | | | | | `- [1 | ⊤] | | | | | | | +- linear-template | | | | | | | | | `- 1 + [m | m ≥ 0] | | | | | | | +- [Norms] | | | | [[1 | ⊤],[m | m ≥ 0]] | | | | | | | +- [Invariant] | | | | m ≥ 1 ==> [1 | ⊤] + h([1 | ⊤],1/3·[-1 + m | -1 + m ≥ 0] + 2/3·[m | m ≥ 0]) ≼ h([1 | ⊤],[m | m ≥ 0]) | | | | 1 ≥ 1 + m ==> 0 ≼ h([1 | ⊤],[m | m ≥ 0]) | | | | | | | `- 3·[m | m ≥ 0] | | | | | `- 3/2·[n | n ≥ 0] + 3/2·[-1 + n | -1 + n ≥ 0] | | | +- mixed-iteration-template | | | | | `- [n | n ≥ 0] + [n | n ≥ 0]^2 | | | +- [Norms] | | [[n | n ≥ 0],[n^2 | n ≥ 0]] | | | +- [Invariant] | | n ≥ 1 ==> 3/2·[n | n ≥ 0] + 3/2·[-1 + n | -1 + n ≥ 0] + h(1/2·[n | n ≥ 0] + 1/2·[-1 + n | -1 + n ≥ 0],1/2·[n^2 | n ≥ 0] + 1/2·[1 + -2·(n) + n^2 | -1 + n ≥ 0]) ≼ h([n | n ≥ 0],[n^2 | n ≥ 0]) | | 1 ≥ 1 + n ==> 0 ≼ h([n | n ≥ 0],[n^2 | n ≥ 0]) | | | `- 3·[n^2 | n ≥ 0] | `- 3·[n^2 | n ≥ 0]