Time-bounded Hoare triples for the planar RAM
DefinitionWilliamsonShmoys_RAMSpecTime-bounded Hoare-style specifications for the unit-cost RAM of this mission (PlanarRAMInstruction, planarRAMRun).
For a program , a state , a predicate on states and a bound , RAMReachesWithin p s Q t means that some state reached by running from satisfies within operations:
RAMSpec p P Q t is the corresponding triple : from every state satisfying , running reaches a state satisfying within operations. Entry and exit locations of a code fragment are expressed through the program counter inside and , and parameter-dependent costs are expressed by quantifying the triple over ghost parameters.
These predicates are the interface for building the mission's RAM programs compositionally (sequencing, loops, subroutine calls), instead of reasoning about planarRAMRun directly.
import Definitions.Def_WilliamsonShmoys_PlanarIndependentSetRAM
set_option autoImplicit false
namespace WilliamsonShmoys
/-- Running `program` from `s`, some state satisfying `Q` is reached after at most `t`
operations (counted by `planarRAMRun`). -/
def RAMReachesWithin (program : List PlanarRAMInstruction) (s : PlanarRAMState)
(Q : PlanarRAMState → Prop) (t : ℕ) : Prop :=
∃ τ, τ ≤ t ∧ Q (planarRAMRun program s τ)
/-- Hoare-style specification with a time bound: from every state satisfying `P`, running
`program` reaches a state satisfying `Q` within `t` operations. Program-counter conditions
(the entry and exit locations of a code fragment) are expressed inside `P` and `Q`. -/
def RAMSpec (program : List PlanarRAMInstruction) (P Q : PlanarRAMState → Prop) (t : ℕ) : Prop :=
∀ s, P s → RAMReachesWithin program s Q t
end WilliamsonShmoys