Following the store through sequential assignments

A store assigns a current value to each variable. Write σ(x)\sigma(x) for the value of xx in store σ\sigma. An assignment evaluates its right-hand expression in the current store and then replaces only the named variable:


⟨x:=e,σ⟩⇓σ[x↦v]where v=eval⁡(e,σ).\langle x:=e,\sigma\rangle\Downarrow\sigma[x\mapsto v] \quad\text{where }v=\operatorname{eval}(e,\sigma).

The notation σ[x↦v]\sigma[x\mapsto v] means the same store except that xx now holds vv. Commands separated by semicolons execute in the displayed order, each receiving the store returned by its predecessor.


Initially, x=4x=4 and y=6y=6. Execute this program and complete the table with exact integers. Each checkpoint occurs immediately after the named assignment finishes.


Plain text
x := y + 2;
y := x + 3;
x := x + y


A program starts with x equal to 4 and y equal to 6 and executes three assignments in sequence.


Checkpointxy
After first assignment
After second assignment
After third assignment

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: