Back to Program Verification Index | Previous: (y-09) Ultimate Referee | Next: (y-11) Nondeterminism: Havoc and Assume

The 2026 deck covers this material as the Arrays section (pp 246-272). The axioms also appear in §4 First-Order Theories for reference.

Mental Model for Arrays

  • Arrays as Maps: In formal verification, an array is not a block of memory; it is a Function (or Map) from indices to values.
  • Select and Store: We interact with this map using two operations: select(a, i) (reading) and store(a, i, v) (writing).
  • Immutable Updates: store does not “change” an array. It returns a new array that is identical to the old one except at index .
  • Axiomatic Reasoning: We reason about arrays using the Read-over-Write axioms, which tell us exactly what happens to an index after a store operation.

The SMT Theory of Arrays ()

The signature includes .

Key Axioms

  1. Read-over-Write (Hit):
    • Intuition: If you write to index and then read from , you are guaranteed to get .
  2. Read-over-Write (Miss):
    • Intuition: Writing to index does not change the value at any other index .
  3. Extensionality:
    • Intuition: Two arrays and are the same array object if and only if they map every index to the same value.

Arrays in Boostan

We extend Boostan to support array assignments like a[i] := expr.

1. Syntax Extension

  • Left-hand side (LHS): Can now be a variable x or an array access a[i].
  • Grammar: .

2. Relational Semantics

The relation for a[i] := expr is defined by:

  • For all other variables and arrays, .

Array Assignment in Hoare Logic

We add a new rule to the Hoare Proof System to handle array updates:

Array Assignment Axiom (arrassig)

The formal rule is:

💡 Substitution Example

To prove that { \text{select}(a, 5) = 42 } is a postcondition for a[5] := 42, we find the weakest precondition:

  1. Postcondition :
  2. Substitute with :
  3. Simplify using Read-over-Write (Hit):
  4. Result: The precondition is simply True.

Summary

  1. Verification Arrays are total maps from indices to values.
  2. Select is for reading; Store is for writing.
  3. Read-over-Write axioms allow a computer to “calculate” the effect of an array update.
  4. Extensionality allows us to prove that two arrays are identical.
  5. Hoare Logic handles arrays by treating the update as a substitution of the entire array object.

Self-Check

  1. Why does verification model arrays as total maps from indices to values, rather than as blocks of memory?
  1. State the two read-over-write axioms and what each one guarantees.
  1. What does the extensionality axiom let you prove about arrays?
  1. State the array-assignment axiom of Hoare logic and explain its substitution.
  1. Use the array-assignment rule to derive the weakest precondition of a[5] := 42 for the postcondition .

Back to Program Verification Index | Previous: (y-09) Ultimate Referee | Next: (y-11) Nondeterminism: Havoc and Assume | (y) Return to Notes | (y) Return to Home