Counting paths and outcomes under choice

A command language includes assignments, sequencing, and choose(C,D). A choice executes exactly one of its two commands. Its operational rules are:


⟨C,σ⟩⇓σ′⟨choose⁡(C,D),σ⟩⇓σ′⟨D,σ⟩⇓σ′⟨choose⁡(C,D),σ⟩⇓σ′.\frac{\langle C,\sigma\rangle\Downarrow\sigma'}{\langle\operatorname{choose}(C,D),\sigma\rangle\Downarrow\sigma'} \qquad \frac{\langle D,\sigma\rangle\Downarrow\sigma'}{\langle\operatorname{choose}(C,D),\sigma\rangle\Downarrow\sigma'}.


Here σ\sigma records the current value of xx, and σ′\sigma' records the resulting value. Assignment evaluates its expression using the current value and replaces xx with the result. A semicolon executes the next command using that updated value.


An execution path records which branch was selected at each choice. Two paths remain different when their branch selections differ, even if they finish with the same value. Every branch shown below is available whenever its choice is reached; no probabilities are assigned.


Initially, x=10x=10. Execute:


Plain text
choose(x := x + 2, x := 2*x);
choose(x := x - 4, x := x/2);
choose(x := x + 2, x := x/2)


Arithmetic is exact. Report the number of execution paths, the number of distinct final values of xx, the smallest final value, and the largest final value. Enter all four answers as exact integers.


Three successive commands each offer a choice between two updates to x.


Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Operational Semantics Questions: