3.7. Separation Logic in WP Style
In the previous chapter we defined Hoare triples semantically: a triple is a statement about all executions of the program. This gave us a clear notion of correctness, but it made proofs laborious, since every specification required an analysis of the execution, and we only managed to prove a weakened version of the frame rule.
In this chapter we take the opposite route, which is the usual one for program logics. We first define triples syntactically, as a system of inference rules (an inductive relation); we then prove that this system is sound with respect to the operational semantics: every derivable triple is semantically valid. The frame rule will be one of the rules of the system, and its soundness will be the most delicate part of the proof.
The rules will be formulated in the weakest precondition (WP) style: the precondition of each instruction rule is exactly the weakest condition that guarantees the validity of the continuation. This makes it possible to compute preconditions automatically by traversing the program backwards, which is the basis of verification condition generators (VCGs).
To keep the chapter self-contained and the proofs simpler, we use an assembly language even smaller than the one in the previous chapters, with natural-number values and no flags. The concepts (heaps, separating conjunction, points-to assertions) are the same as in the previous chapter, now reformulated over complete states.
3.7.1. A minimal language
Registers are identified by a natural-number index, so infinitely many registers are available.
namespace Ch23
/-- Registers, identified by an index in ℕ. -/
inductive Reg : Type where
| r : ℕ → Reg
deriving DecidableEq
The instruction set contains only the essentials: addition, copying between
registers, loading a constant (MOVI), reading and writing memory, and a
conditional jump. Pay attention to the order of the arguments: here the
source comes first and the destination second, as in AT&T syntax; thus
ADD src dest means dest := dest + src, LOAD dst addr means
dst := mem[addr], and STORE src addr means mem[addr] := src. The
instruction JNZ cond target jumps to target if register cond is
nonzero.
/-- Minimal instruction set (ISA). -/
inductive Instr : Type where
-- Arithmetic operations
| ADD (src dest : Reg) : Instr
-- Register transfer
| MOV (src dest : Reg) : Instr
| MOVI (dest : Reg) (val : ℕ) : Instr
-- Memory access
| LOAD (dst addr : Reg) : Instr
| STORE (src addr : Reg) : Instr
-- Control flow
| JNZ (cond : Reg) (target : ℕ) : Instr
deriving DecidableEq
A program is a list of instructions. Since there is no HALT instruction,
the machine stops when the PC leaves the bounds of the program. To fetch
instructions, we define an indexing function by structural recursion,
which is more convenient in proofs than the standard library's indexing:
the equations getI (i :: rest) 0 = some i and
getI (i :: rest) (k + 1) = getI rest k hold by definition.
/-- Fetches the instruction at position n. -/
def getI : List Instr → ℕ → Option Instr
| [], _ => none
| x :: _, 0 => some x
| _ :: rest, n + 1 => getI rest n
/-- A program is a list of instructions indexed by the PC. -/
abbrev Code := List Instr
3.7.2. Heaps and states
As before, a heap is a partial function from addresses to values, now
natural numbers. Besides disjointness and union, we need an operation that
updates a single cell, defined with Mathlib's Function.update.
Union is defined with Option.orElse: the left value applies if
there is one, and the right one otherwise.
/-- The heap is a partial function from addresses to values.
An unallocated cell is represented by `none`. -/
abbrev Heap := ℕ → Option ℕ
namespace Heap
/-- Two heaps are *disjoint* when their domains do not overlap:
for every address `a`, at least one of the heaps does not contain it. -/
def disjoint (h₁ h₂ : Heap) : Prop :=
∀ a, h₁ a = none ∨ h₂ a = none
/-- Union of two heaps, with preference for the left side.
Well defined as a disjoint sum when the heaps are disjoint. -/
def union (h₁ h₂ : Heap) : Heap :=
fun a => (h₁ a).orElse (fun _ => h₂ a)
/-- Updates a cell of the heap. -/
def update (h : Heap) (a v : ℕ) : Heap :=
Function.update h a (some v)
The basic lemmas are similar to those of the previous chapter. Two of them are new and will be crucial in the proof of the frame rule. The first says that updating the left side of a union is the same as updating the union. The second says that if the updated address already belongs to the left heap, the update preserves disjointness. This is the formal foundation of the idea of ownership: a write to an address we own cannot intrude on the memory of another part of the program.
-- Basic lemmas
theorem union_left {h₁ h₂ : Heap} {a v : ℕ} (h : h₁ a = some v) :
(h₁.union h₂) a = some v := h₁:Heaph₂:Heapa:ℕv:ℕh:h₁ a = some v⊢ h₁.union h₂ a = some v
All goals completed! 🐙
theorem union_right {h₁ h₂ : Heap} {a : ℕ} (h : h₁ a = none) :
(h₁.union h₂) a = h₂ a := h₁:Heaph₂:Heapa:ℕh:h₁ a = none⊢ h₁.union h₂ a = h₂ a
All goals completed! 🐙
theorem disjoint_comm {h₁ h₂ : Heap} (hd : disjoint h₁ h₂) : disjoint h₂ h₁ := h₁:Heaph₂:Heaphd:h₁.disjoint h₂⊢ h₂.disjoint h₁
h₁:Heaph₂:Heaphd:h₁.disjoint h₂a:ℕ⊢ h₂ a = none ∨ h₁ a = none; h₁:Heaph₂:Heaphd:h₁.disjoint h₂a:ℕh:h₁ a = none⊢ h₂ a = none ∨ h₁ a = noneh₁:Heaph₂:Heaphd:h₁.disjoint h₂a:ℕh:h₂ a = none⊢ h₂ a = none ∨ h₁ a = none h₁:Heaph₂:Heaphd:h₁.disjoint h₂a:ℕh:h₁ a = none⊢ h₂ a = none ∨ h₁ a = noneh₁:Heaph₂:Heaphd:h₁.disjoint h₂a:ℕh:h₂ a = none⊢ h₂ a = none ∨ h₁ a = none All goals completed! 🐙
/-- Updating the left side of the union is equivalent to updating the result. -/
theorem update_union_left (h₁ h₂ : Heap) (a v : ℕ) :
(h₁.update a v).union h₂ = (h₁.union h₂).update a v := h₁:Heaph₂:Heapa:ℕv:ℕ⊢ (h₁.update a v).union h₂ = (h₁.union h₂).update a v
h₁:Heaph₂:Heapa:ℕv:ℕx:ℕ⊢ (h₁.update a v).union h₂ x = (h₁.union h₂).update a v x; h₁:Heaph₂:Heapa:ℕv:ℕx:ℕ⊢ ((if h : x = a then ⋯ ▸ some v else h₁ x).orElse fun x_1 => h₂ x) =
if h : x = a then ⋯ ▸ some v else (h₁ x).orElse fun x_1 => h₂ x
h₁:Heaph₂:Heapa:ℕv:ℕx:ℕh✝:x = a⊢ ((⋯ ▸ some v).orElse fun x_1 => h₂ x) = ⋯ ▸ some vh₁:Heaph₂:Heapa:ℕv:ℕx:ℕh✝:¬x = a⊢ ((h₁ x).orElse fun x_1 => h₂ x) = (h₁ x).orElse fun x_1 => h₂ x h₁:Heaph₂:Heapa:ℕv:ℕx:ℕh✝:x = a⊢ ((⋯ ▸ some v).orElse fun x_1 => h₂ x) = ⋯ ▸ some vh₁:Heaph₂:Heapa:ℕv:ℕx:ℕh✝:¬x = a⊢ ((h₁ x).orElse fun x_1 => h₂ x) = (h₁ x).orElse fun x_1 => h₂ x All goals completed! 🐙
/-- Updating an address that already *belongs* to the left heap preserves disjointness. -/
theorem disjoint_update_left {h₁ h₂ : Heap} {a : ℕ}
(hd : disjoint h₁ h₂) (hown : h₁ a ≠ none) (v : ℕ) :
disjoint (h₁.update a v) h₂ := h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕ⊢ (h₁.update a v).disjoint h₂
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕ⊢ h₁.update a v x = none ∨ h₂ x = none
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = a⊢ h₁.update a v x = none ∨ h₂ x = noneh₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:¬x = a⊢ h₁.update a v x = none ∨ h₂ x = none
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = a⊢ h₁.update a v x = none ∨ h₂ x = none h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = a⊢ h₂ x = none; h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = a⊢ h₂ a = none
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = ah:h₁ a = none⊢ h₂ a = noneh₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = ah:h₂ a = none⊢ h₂ a = none
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = ah:h₁ a = none⊢ h₂ a = none All goals completed! 🐙
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:x = ah:h₂ a = none⊢ h₂ a = none All goals completed! 🐙
h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:¬x = a⊢ h₁.update a v x = none ∨ h₂ x = none h₁:Heaph₂:Heapa:ℕhd:h₁.disjoint h₂hown:h₁ a ≠ nonev:ℕx:ℕheq:¬x = a⊢ h₁ x = none ∨ h₂ x = none
All goals completed! 🐙
theorem union_assoc (h₁ h₂ h₃ : Heap) :
(h₁.union h₂).union h₃ = h₁.union (h₂.union h₃) := h₁:Heaph₂:Heaph₃:Heap⊢ (h₁.union h₂).union h₃ = h₁.union (h₂.union h₃)
h₁:Heaph₂:Heaph₃:Heapa:ℕ⊢ (h₁.union h₂).union h₃ a = h₁.union (h₂.union h₃) a; h₁:Heaph₂:Heaph₃:Heapa:ℕ⊢ (((h₁ a).orElse fun x => h₂ a).orElse fun x => h₃ a) = (h₁ a).orElse fun x => (h₂ a).orElse fun x => h₃ a; h₁:Heaph₂:Heaph₃:Heapa:ℕ⊢ ((none.orElse fun x => h₂ a).orElse fun x => h₃ a) = none.orElse fun x => (h₂ a).orElse fun x => h₃ ah₁:Heaph₂:Heaph₃:Heapa:ℕval:ℕ⊢ (((some val).orElse fun x => h₂ a).orElse fun x => h₃ a) = (some val).orElse fun x => (h₂ a).orElse fun x => h₃ a h₁:Heaph₂:Heaph₃:Heapa:ℕ⊢ ((none.orElse fun x => h₂ a).orElse fun x => h₃ a) = none.orElse fun x => (h₂ a).orElse fun x => h₃ ah₁:Heaph₂:Heaph₃:Heapa:ℕval:ℕ⊢ (((some val).orElse fun x => h₂ a).orElse fun x => h₃ a) = (some val).orElse fun x => (h₂ a).orElse fun x => h₃ a All goals completed! 🐙
end Heap
The machine state consists only of the register file and the heap; the PC
will be handled separately, as an index of the execution relations. The
two lemmas marked @[simp] record that updating a register does not
change memory, and vice versa.
/-- Machine state: register file and heap. -/
structure State where
regs : Reg → ℕ
mem : Heap
/-- Updates a register (memory is not changed). -/
def State.updateReg (s : State) (r : Reg) (v : ℕ) : State :=
⟨fun r' => if r = r' then v else s.regs r', s.mem⟩
/-- Writes to a memory cell (registers are not changed). -/
def State.updateMem (s : State) (addr v : ℕ) : State :=
⟨s.regs, s.mem.update addr v⟩
@[simp]
theorem State.updateReg_mem (s : State) (r : Reg) (v : ℕ) :
(s.updateReg r v).mem = s.mem := rfl
@[simp]
theorem State.updateMem_regs (s : State) (a v : ℕ) :
(s.updateMem a v).regs = s.regs := rfl
3.7.3. Operational semantics
This time, the step semantics is an inductive relation
Eval code pc s pc' s': executing the instruction at position pc from
state s leads to state s' with next PC pc'. Each constructor
corresponds to an inference rule; for example, for LOAD and for a taken
jump:
\frac{\mathit{code}[pc] = \mathtt{LOAD}\ d\ a \qquad s.\mathit{mem}(s.\mathit{regs}(a)) = \mathsf{some}\ v}{\mathit{Eval}\ \mathit{code}\ pc\ s\ (pc+1)\ (s[d \mapsto v])} \qquad \frac{\mathit{code}[pc] = \mathtt{JNZ}\ c\ t \qquad s.\mathit{regs}(c) \neq 0}{\mathit{Eval}\ \mathit{code}\ pc\ s\ t\ s}
Note that a LOAD from an unallocated address simply has no step: the
machine gets stuck. A STORE, on the other hand, can always take a step.
/-- Single-step semantics:
`Eval code pc s pc' s'` — executing the instruction at `pc` in state `s`
yields state `s'` and next PC `pc'`. -/
inductive Eval (code : Code) : ℕ → State → ℕ → State → Prop where
| add {pc s src dest v}
: getI code pc = some (.ADD src dest)
→ v = s.regs src + s.regs dest
→ Eval code pc s (pc + 1) (s.updateReg dest v)
| mov {pc s src dest v}
: getI code pc = some (.MOV src dest)
→ v = s.regs src
→ Eval code pc s (pc + 1) (s.updateReg dest v)
| movi {pc s dest val}
: getI code pc = some (.MOVI dest val)
→ Eval code pc s (pc + 1) (s.updateReg dest val)
| load {pc s dst addr v val}
: getI code pc = some (.LOAD dst addr)
→ v = s.regs addr
→ s.mem v = some val
→ Eval code pc s (pc + 1) (s.updateReg dst val)
| store {pc s src addr v val}
: getI code pc = some (.STORE src addr)
→ val = s.regs src
→ v = s.regs addr
→ Eval code pc s (pc + 1) (s.updateMem v val)
| jnz_taken {pc s cond target}
: getI code pc = some (.JNZ cond target)
→ s.regs cond ≠ 0
→ Eval code pc s target s
| jnz_not_taken {pc s cond target}
: getI code pc = some (.JNZ cond target)
→ s.regs cond = 0
→ Eval code pc s (pc + 1) s
A PC is halted when there is no instruction to fetch. Multi-step
execution is the reflexive–transitive closure of Eval.
/-- *Halted* PC: there is no instruction to fetch. -/
def Halted (code : Code) (pc : ℕ) : Prop := getI code pc = none
/-- Multi-step execution: reflexive–transitive closure of `Eval`. -/
inductive Exec (code : Code) : ℕ → State → ℕ → State → Prop where
| refl {pc s} : Exec code pc s pc s
| step {pc pc' pc'' s s' s''}
: Eval code pc s pc' s'
→ Exec code pc' s' pc'' s''
→ Exec code pc s pc'' s''
3.7.4. Separating assertions
Assertions are now predicates on complete states, including the registers.
The separating conjunction splits only the heap: both sides see the same
register file, but disjoint portions of memory. The notation
⟨s.regs, h₁⟩ builds the state with the registers of s and the heap
h₁.
s \models P \ast Q \iff \exists h_1\, h_2.\ h_1 \perp h_2 \ \land\ s.\mathit{mem} = h_1 \uplus h_2 \ \land\ \langle s.\mathit{regs}, h_1\rangle \models P \ \land\ \langle s.\mathit{regs}, h_2\rangle \models Q
/-- Assertions are predicates on states. -/
abbrev Assert := State → Prop
namespace Assert
/-- Empty heap: no location is allocated. -/
def emp : Assert := fun s => ∀ a, s.mem a = none
/-- Singleton cell: the heap contains *exactly* the cell (a, v)
and no other.
Notation: `a ↦ v`. -/
def pointsTo (a v : ℕ) : Assert :=
fun s => s.mem a = some v ∧ ∀ b, b ≠ a → s.mem b = none
/-- **Separating conjunction**: the heap of `s` splits into two disjoint parts,
the first satisfying `P` and the second satisfying `Q`.
Notation: `P ∗ Q`. -/
def sep (P Q : Assert) : Assert :=
fun s => ∃ h₁ h₂,
h₁.disjoint h₂ ∧
s.mem = h₁.union h₂ ∧
P ⟨s.regs, h₁⟩ ∧
Q ⟨s.regs, h₂⟩
/-- **Separating implication** (magic wand): every disjoint extension of the heap
that satisfies `P` produces a state satisfying `Q`.
Notation: `P -∗ Q`. -/
def wand (P Q : Assert) : Assert :=
fun s => ∀ h', s.mem.disjoint h' →
P ⟨s.regs, h'⟩ → Q ⟨s.regs, s.mem.union h'⟩
/-- Entailment between assertions. -/
def entails (P Q : Assert) : Prop := ∀ s, P s → Q s
/-- Register substitution: useful for formulating the WP of assignments. -/
def updateReg (P : Assert) (r : Reg) (v : ℕ) : Assert :=
fun s => P (s.updateReg r v)
end Assert
As in the previous chapter, the notations are declared scoped.
scoped notation:50 a " ↦ " v => Assert.pointsTo a v
scoped notation:35 P " ∗ " Q => Assert.sep P Q
scoped notation:25 P " -∗ " Q => Assert.wand P Q
scoped notation:50 P " ⊢ₛ " Q => Assert.entails P Q
scoped notation:50 P " [" r " ↦ᵣ " v "]" => Assert.updateReg P r v
Since registers are shared between the two sides of a \ast, the frame
rule needs a restriction: if the frame R mentioned registers, an
instruction that changes a register could invalidate it. We therefore
require the frame to be heap-only: its truth value cannot depend on the
registers. Both \mathsf{emp} and a \mapsto v have this
property.More elaborate separation logics also treat registers (or
variables) as resources, which eliminates this side condition.
/-- An assertion is **heap-only** if it does not depend on the register file.
This condition is needed in the frame rule: instructions may change
registers, but the frame assertion must remain valid. -/
def HeapOnly (R : Assert) : Prop :=
∀ (regs₁ regs₂ : Reg → ℕ) (m : Heap),
R ⟨regs₁, m⟩ → R ⟨regs₂, m⟩
-- Lemmas about ↦
lemma pointsTo_mem {a v : ℕ} {s : State} (h : (a ↦ v) s) :
s.mem a = some v := h.1
lemma emp_heapOnly : HeapOnly Assert.emp := ⊢ HeapOnly Assert.emp
intro regs₁ regs₁:Reg → ℕregs₂:Reg → ℕ⊢ ∀ (m : Heap), Assert.emp { regs := regs₁, mem := m } → Assert.emp { regs := regs₂, mem := m } regs₁:Reg → ℕregs₂:Reg → ℕm:Heap⊢ Assert.emp { regs := regs₁, mem := m } → Assert.emp { regs := regs₂, mem := m } regs₁:Reg → ℕregs₂:Reg → ℕm:Heaph:Assert.emp { regs := regs₁, mem := m }⊢ Assert.emp { regs := regs₂, mem := m }; All goals completed! 🐙
lemma pointsTo_heapOnly (a v : ℕ) : HeapOnly (a ↦ v) := a:ℕv:ℕ⊢ HeapOnly (a ↦ v)
intro regs₁ a:ℕv:ℕregs₁:Reg → ℕregs₂:Reg → ℕ⊢ ∀ (m : Heap), (a ↦ v) { regs := regs₁, mem := m } → (a ↦ v) { regs := regs₂, mem := m } a:ℕv:ℕregs₁:Reg → ℕregs₂:Reg → ℕm:Heap⊢ (a ↦ v) { regs := regs₁, mem := m } → (a ↦ v) { regs := regs₂, mem := m } a:ℕv:ℕregs₁:Reg → ℕregs₂:Reg → ℕm:Heaph:(a ↦ v) { regs := regs₁, mem := m }⊢ (a ↦ v) { regs := regs₂, mem := m }; All goals completed! 🐙
3.7.5. WP-style triples
We now define triples as an inductive relation. We write
\{P\}\ \mathit{prog} @ pc\ \{Q\} for "starting from PC pc, if the
state satisfies P and execution halts, the final state satisfies
Q". The structural rules are consequence, frame, and the halting rule:
\frac{P' \vdash P \qquad \{P\}\ c @ pc\ \{Q\} \qquad Q \vdash Q'}{\{P'\}\ c @ pc\ \{Q'\}} \qquad \frac{\mathsf{HeapOnly}(R) \qquad \{P\}\ c @ pc\ \{Q\}}{\{P \ast R\}\ c @ pc\ \{Q \ast R\}} \qquad \frac{c[pc] = \mathsf{none}}{\{Q\}\ c @ pc\ \{Q\}}
The instruction rules are written "backwards". For each instruction at
pc, if we already have a triple \{P\}\ c @ (pc+1)\ \{Q\} for the
continuation, we obtain a triple for pc whose precondition is the WP of
the instruction with respect to P. For MOVI and STORE, for example:
\frac{c[pc] = \mathtt{MOVI}\ d\ n \qquad \{P\}\ c @ (pc+1)\ \{Q\}}{\{P[d \mapsto n]\}\ c @ pc\ \{Q\}}
\frac{c[pc] = \mathtt{STORE}\ s\ a \qquad \{P\}\ c @ (pc+1)\ \{Q\}}{\{\lambda \sigma.\ \exists o.\ \sigma.\mathit{mem}(\sigma(a)) = \mathsf{some}\ o \land P(\sigma[\mathit{mem}(\sigma(a)) \mapsto \sigma(s)])\}\ c @ pc\ \{Q\}}
Note the premise \exists o.\ \sigma.\mathit{mem}(\sigma(a)) = \mathsf{some}\ o
in the STORE rule. Semantically, STORE always succeeds; but we require
the address to be in the heap described by the precondition. This
ownership requirement is what makes the frame rule sound: when the
precondition is evaluated over a fragment of the heap, it guarantees that
the write happens inside that fragment.
For JNZ, the rule requires a triple for each of the two branches, adding
to the precondition the information about the tested register.
/-- `Triple P prog pc Q`: `{ P } prog @ pc { Q }` is derivable.
*Backwards* derivation style (WP): the precondition of each rule is
literally the weakest precondition of the continuation, which allows
preconditions to be computed automatically (VCG). -/
inductive Triple : Assert → Code → ℕ → Assert → Prop where
/-- Rule of consequence: weakens P and/or strengthens Q. -/
| conseq {P P' Q Q' prog pc}
: Assert.entails P' P
→ Triple P prog pc Q
→ Assert.entails Q Q'
→ Triple P' prog pc Q'
/-- Frame rule: adds R (heap-only) to the pre- and postcondition.
Allows *local* reasoning about a piece of the heap. -/
| frame {P Q R prog pc}
: HeapOnly R
→ Triple P prog pc Q
→ Triple (P ∗ R) prog pc (Q ∗ R)
/-- Halt: when there is no instruction, the postcondition is the precondition. -/
| halt {Q prog pc}
: getI prog pc = none
→ Triple Q prog pc Q
/-- MOVI dest val: dest := val.
WP: Q with dest replaced by val. -/
| movi {P Q prog pc dest val}
: getI prog pc = some (.MOVI dest val)
→ Triple P prog (pc + 1) Q
→ Triple (fun s => P (s.updateReg dest val)) prog pc Q
/-- ADD src dest: dest := dest + src.
WP: Q with dest replaced by dest + src. -/
| add {P Q prog pc src dest}
: getI prog pc = some (.ADD src dest)
→ Triple P prog (pc + 1) Q
→ Triple (fun s => P (s.updateReg dest (s.regs dest + s.regs src))) prog pc Q
/-- MOV src dest: dest := src.
WP: Q with dest replaced by src. -/
| mov {P Q prog pc src dest}
: getI prog pc = some (.MOV src dest)
→ Triple P prog (pc + 1) Q
→ Triple (fun s => P (s.updateReg dest (s.regs src))) prog pc Q
/-- LOAD dst addr: dst := mem[regs[addr]].
WP: there is a value val at mem[regs[addr]] such that Q holds with dst := val. -/
| load {P Q prog pc dst addr}
: getI prog pc = some (.LOAD dst addr)
→ Triple P prog (pc + 1) Q
→ Triple (fun s => ∃ val, s.mem (s.regs addr) = some val ∧
P (s.updateReg dst val)) prog pc Q
/-- STORE src addr: mem[regs[addr]] := regs[src].
WP: address regs[addr] is already allocated (ownership), and Q holds after the write. -/
| store {P Q prog pc src addr}
: getI prog pc = some (.STORE src addr)
→ Triple P prog (pc + 1) Q
→ Triple (fun s => ∃ old, s.mem (s.regs addr) = some old ∧
P (s.updateMem (s.regs addr) (s.regs src))) prog pc Q
/-- JNZ cond target: branches into two cases.
`htaken`: if regs[cond] ≠ 0, jump to `target`.
`hnot` : if regs[cond] = 0, advance to `pc + 1`. -/
| jnz {P Q prog pc cond target}
: getI prog pc = some (.JNZ cond target)
→ Triple (fun s => s.regs cond ≠ 0 ∧ P s) prog target Q
→ Triple (fun s => s.regs cond = 0 ∧ P s) prog (pc + 1) Q
→ Triple P prog pc Q
We introduce the notation {{* P *}} prog @ pc {{* Q *}} for triples, as
well as two derived forms of the rule of consequence.
scoped notation:25 "{{* " P " *}} " prog:arg " @ " pc:arg " {{* " Q " *}}" => Triple P prog pc Q
-- Derived rule: only weakens the precondition
lemma conseq_pre {P P' Q : Assert} {prog : Code} {pc : ℕ}
(h : P' ⊢ₛ P) (ht : {{* P *}} prog @ pc {{* Q *}}) : {{* P' *}} prog @ pc {{* Q *}} :=
Triple.conseq h ht (fun _ hq => hq)
-- Derived rule: only strengthens the postcondition
lemma conseq_post {P Q Q' : Assert} {prog : Code} {pc : ℕ}
(ht : {{* P *}} prog @ pc {{* Q *}}) (h : Q ⊢ₛ Q') : {{* P *}} prog @ pc {{* Q' *}} :=
Triple.conseq (fun _ hp => hp) ht h
3.7.6. The precondition transformer
The function wp computes the weakest precondition of an instruction with
respect to a postcondition. It coincides exactly with the preconditions of
the Triple rules. For JNZ there is no simple answer (the jump may
create loops, which require invariants), and the definition returns the
postcondition itself; the blocks handled automatically will be jump-free.
The WP of a block of instructions is obtained by composing the WPs from the
last instruction to the first, which is exactly a foldr:
\mathit{blockWP}([i_1, \ldots, i_n], Q) = \mathit{wp}(i_1, \mathit{wp}(i_2, \ldots \mathit{wp}(i_n, Q)))
/-- `wp i Q`: weakest precondition of an instruction `i` for postcondition `Q`. -/
def wp (i : Instr) (Q : Assert) : Assert :=
match i with
| .MOVI dest val =>
fun s => Q (s.updateReg dest val)
| .ADD src dest =>
fun s => Q (s.updateReg dest (s.regs dest + s.regs src))
| .MOV src dest =>
fun s => Q (s.updateReg dest (s.regs src))
| .LOAD dst addr =>
fun s => ∃ v, s.mem (s.regs addr) = some v ∧
Q (s.updateReg dst v)
| .STORE src addr =>
fun s => ∃ old, s.mem (s.regs addr) = some old ∧
Q (s.updateMem (s.regs addr) (s.regs src))
| .JNZ _ _ => Q -- preserves the state; handled by the loop VCG
/-- WP of a sequential block (right to left):
`blockWP [i₁, i₂, …, iₙ] Q = wp i₁ (wp i₂ (… (wp iₙ Q)))`. -/
def blockWP (instrs : List Instr) (Q : Assert) : Assert :=
instrs.foldr wp Q
The lemma wp_sound says that wp is indeed a derivable
precondition: it suffices to apply the rule corresponding to the
instruction.
/-- `wp i P` is a sufficient precondition for `{ P } prog @ (pc+1) { Q }`. -/
theorem wp_sound
(prog : Code) (pc : ℕ) (i : Instr) (P Q : Assert)
(hfetch : getI prog pc = some i)
(hnoJNZ : ∀ cond target, i ≠ .JNZ cond target)
(hcont : {{* P *}} prog @ (pc + 1) {{* Q *}}) :
{{* wp i P *}} prog @ pc {{* Q *}} := prog:Codepc:ℕi:InstrP:AssertQ:Asserthfetch:getI prog pc = some ihnoJNZ:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targethcont:{{* P *}} prog @ (pc + 1) {{* Q *}}⊢ {{* wp i P *}} prog @ pc {{* Q *}}
match i with
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}dest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hnoJNZ:∀ (cond : Reg) (target : ℕ), Instr.MOVI dest val ≠ Instr.JNZ cond target⊢ {{* wp (Instr.MOVI dest val) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}src:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hnoJNZ:∀ (cond : Reg) (target : ℕ), Instr.ADD src dest ≠ Instr.JNZ cond target⊢ {{* wp (Instr.ADD src dest) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}src:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hnoJNZ:∀ (cond : Reg) (target : ℕ), Instr.MOV src dest ≠ Instr.JNZ cond target⊢ {{* wp (Instr.MOV src dest) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}dst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hnoJNZ:∀ (cond : Reg) (target : ℕ), Instr.LOAD dst addr ≠ Instr.JNZ cond target⊢ {{* wp (Instr.LOAD dst addr) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}src:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hnoJNZ:∀ (cond : Reg) (target : ℕ), Instr.STORE src addr ≠ Instr.JNZ cond target⊢ {{* wp (Instr.STORE src addr) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
prog:Codepc:ℕi:InstrP:AssertQ:Asserthcont:{{* P *}} prog @ (pc + 1) {{* Q *}}cond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)hnoJNZ:∀ (cond_1 : Reg) (target_1 : ℕ), Instr.JNZ cond target ≠ Instr.JNZ cond_1 target_1⊢ {{* wp (Instr.JNZ cond target) P *}} prog @ pc {{* Q *}} All goals completed! 🐙
By induction on the list of instructions, we obtain that blockWP is
derivable for any jump-free block. The hypothesis hcode says that the
block appears in the code starting at position pc. In the base case
(empty block), we use the halting rule: position pc is outside the code.
In the inductive case, the first instruction is at pc, the rest of the
block appears starting at pc + 1, and we combine the induction hypothesis
with wp_sound.
lemma get?_nil (k : ℕ) : getI ([] : List Instr) k = none := k:ℕ⊢ getI [] k = none
⊢ getI [] 0 = nonen:ℕ⊢ getI [] (n + 1) = none ⊢ getI [] 0 = nonen:ℕ⊢ getI [] (n + 1) = none All goals completed! 🐙
lemma get?_cons_zero (i : Instr) (rest : List Instr) :
getI (i :: rest) 0 = some i := rfl
lemma get?_cons_succ (i : Instr) (rest : List Instr) (k : ℕ) :
getI (i :: rest) (k + 1) = getI rest k := rfl
/-- **Soundness of `blockWP`**: for JNZ-free blocks, if `code` contains the
instructions of `instrs` starting at PC `pc`, then
`{{* blockWP instrs Q *}} code @ pc {{* Q *}}` is derivable. -/
theorem blockWP_sound (instrs : List Instr) (code : Code) (pc : ℕ) (Q : Assert)
(hcode : ∀ k, getI instrs k = getI code (pc + k))
(hnoJNZ : ∀ k cond target, getI instrs k ≠ some (.JNZ cond target)) :
{{* blockWP instrs Q *}} code @ pc {{* Q *}} := instrs:List Instrcode:Codepc:ℕQ:Asserthcode:∀ (k : ℕ), getI instrs k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI instrs k ≠ some (Instr.JNZ cond target)⊢ {{* blockWP instrs Q *}} code @ pc {{* Q *}}
induction instrs generalizing pc with
code:CodeQ:Assertpc:ℕhcode:∀ (k : ℕ), getI [] k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI [] k ≠ some (Instr.JNZ cond target)⊢ {{* blockWP [] Q *}} code @ pc {{* Q *}}
code:CodeQ:Assertpc:ℕhcode:∀ (k : ℕ), getI [] k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI [] k ≠ some (Instr.JNZ cond target)⊢ getI code pc = none
code:CodeQ:Assertpc:ℕhcode:∀ (k : ℕ), getI [] k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI [] k ≠ some (Instr.JNZ cond target)h:getI [] 0 = getI code (pc + 0)⊢ getI code pc = none
code:CodeQ:Assertpc:ℕhcode:∀ (k : ℕ), getI [] k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI [] k ≠ some (Instr.JNZ cond target)h:none = getI code pc⊢ getI code pc = none
All goals completed! 🐙
code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)⊢ {{* blockWP (i :: rest) Q *}} code @ pc {{* Q *}}
have hfetch : getI code pc = some i := instrs:List Instrcode:Codepc:ℕQ:Asserthcode:∀ (k : ℕ), getI instrs k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI instrs k ≠ some (Instr.JNZ cond target)⊢ {{* blockWP instrs Q *}} code @ pc {{* Q *}}
code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)h:getI (i :: rest) 0 = getI code (pc + 0)⊢ getI code pc = some i; code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)h:some i = getI code pc⊢ getI code pc = some i; All goals completed! 🐙
have hnoJNZ_i : ∀ cond target, i ≠ .JNZ cond target :=
fun cond target heq =>
hnoJNZ 0 cond target (code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some icond:Regtarget:ℕheq:i = Instr.JNZ cond target⊢ getI (i :: rest) 0 = some (Instr.JNZ cond target) All goals completed! 🐙)
have hrest : ∀ k, getI rest k = getI code (pc + 1 + k) := fun k => code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targetk:ℕ⊢ getI rest k = getI code (pc + 1 + k)
code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targetk:ℕh:getI (i :: rest) (k + 1) = getI code (pc + (k + 1))⊢ getI rest k = getI code (pc + 1 + k)
code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targetk:ℕh:getI rest k = getI code (pc + (k + 1))⊢ getI rest k = getI code (pc + 1 + k)
rwa [show pc + 1 + k = pc + (k + 1) from code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targetk:ℕh:getI rest k = getI code (pc + (k + 1))⊢ pc + 1 + k = pc + (k + 1) All goals completed! 🐙code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targetk:ℕh:getI rest k = getI code (pc + (k + 1))⊢ getI rest k = getI code (pc + (k + 1)) at *
have hnoJNZ_rest : ∀ k cond target, getI rest k ≠ some (.JNZ cond target) :=
fun k cond target h =>
hnoJNZ (k + 1) cond target (code:CodeQ:Asserti:Instrrest:List Instrih:∀ (pc : ℕ),
(∀ (k : ℕ), getI rest k = getI code (pc + k)) →
(∀ (k : ℕ) (cond : Reg) (target : ℕ), getI rest k ≠ some (Instr.JNZ cond target)) →
{{* blockWP rest Q *}} code @ pc {{* Q *}}pc:ℕhcode:∀ (k : ℕ), getI (i :: rest) k = getI code (pc + k)hnoJNZ:∀ (k : ℕ) (cond : Reg) (target : ℕ), getI (i :: rest) k ≠ some (Instr.JNZ cond target)hfetch:getI code pc = some ihnoJNZ_i:∀ (cond : Reg) (target : ℕ), i ≠ Instr.JNZ cond targethrest:∀ (k : ℕ), getI rest k = getI code (pc + 1 + k)k:ℕcond:Regtarget:ℕh:getI rest k = some (Instr.JNZ cond target)⊢ getI (i :: rest) (k + 1) = some (Instr.JNZ cond target) All goals completed! 🐙)
All goals completed! 🐙
With this, verifying a jump-free block reduces to proving a single
entailment between assertions: that the desired precondition implies the
computed blockWP. This is the principle behind a VCG.
3.7.7. Soundness of the rule system
So far, Triple is just a formal system. To trust it, we need to
relate it to the operational semantics. A triple is semantically valid
if every execution that starts in a state satisfying P and terminates
(with a halted PC) reaches a state satisfying Q.
-- Semantic validity: used in the statements of full soundness
def ValidTriple (P Q : Assert) (prog : Code) (pc : ℕ) : Prop :=
∀ {s : State}, P s →
∀ {pc_h s_h}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h
The soundness theorem states that every derivable triple is valid. The
proof is by induction on the derivation of the triple. For the instruction
rules, the argument is always the same: since the PC is not halted, the
execution takes at least one step; by determinism of Eval, that
step is the one described by the rule; and we apply the induction
hypothesis to the rest of the execution. The auxiliary lemmas below
capture these three observations.
theorem eval_deterministic {code : Code} {pc : ℕ} {s : State}
{pc₁ s₁ pc₂ s₂}
(h₁ : Eval code pc s pc₁ s₁) (h₂ : Eval code pc s pc₂ s₂) :
pc₁ = pc₂ ∧ s₁ = s₂ := code:Codepc:ℕs:Statepc₁:ℕs₁:Statepc₂:ℕs₂:Stateh₁:Eval code pc s pc₁ s₁h₂:Eval code pc s pc₂ s₂⊢ pc₁ = pc₂ ∧ s₁ = s₂
code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs dest⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs src⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂dest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)⊢ pc + 1 = pc₂ ∧ s.updateReg dest val = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂dst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some val⊢ pc + 1 = pc₂ ∧ s.updateReg dst val = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addr⊢ pc + 1 = pc₂ ∧ s.updateMem v val = s₂code:Codepc:ℕs:Statepc₁:ℕpc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂cond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)⊢ pc₁ = pc₂ ∧ s = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂cond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0⊢ pc + 1 = pc₂ ∧ s = s₂ code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs dest⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs src⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂dest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)⊢ pc + 1 = pc₂ ∧ s.updateReg dest val = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂dst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some val⊢ pc + 1 = pc₂ ∧ s.updateReg dst val = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂src:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addr⊢ pc + 1 = pc₂ ∧ s.updateMem v val = s₂code:Codepc:ℕs:Statepc₁:ℕpc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂cond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)⊢ pc₁ = pc₂ ∧ s = s₂code:Codepc:ℕs:Statepc₂:ℕs₂:Stateh₂:Eval code pc s pc₂ s₂cond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0⊢ pc + 1 = pc₂ ∧ s = s₂ code:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.ADD src dest)a_3:v = s.regs src + s.regs dest⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.MOV src dest)a_3:v = s.regs src⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0dest:Regval:ℕa_2:getI code pc = some (Instr.MOVI dest val)⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest valcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0dst:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.LOAD dst addr)a_3:v = s.regs addra_4:s.mem v = some val⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dst valcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.STORE src addr)a_3:val = s.regs srca_4:v = s.regs addr⊢ pc + 1 = pc + 1 ∧ s = s.updateMem v valcode:Codepc:ℕs:Statepc₂:ℕcond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0cond_1:Rega_3:s.regs cond_1 ≠ 0a_2:getI code pc = some (Instr.JNZ cond_1 pc₂)⊢ pc + 1 = pc₂ ∧ s = scode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0cond_1:Regtarget_1:ℕa_2:getI code pc = some (Instr.JNZ cond_1 target_1)a_3:s.regs cond_1 = 0⊢ pc + 1 = pc + 1 ∧ s = s code:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destsrc_1:Regdest_1:Regv_1:ℕa_2:getI code pc = some (Instr.ADD src_1 dest_1)a_3:v_1 = s.regs src_1 + s.regs dest_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 v_1code:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destsrc_1:Regdest_1:Regv_1:ℕa_2:getI code pc = some (Instr.MOV src_1 dest_1)a_3:v_1 = s.regs src_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 v_1code:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destdest_1:Regval:ℕa_2:getI code pc = some (Instr.MOVI dest_1 val)⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 valcode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destdst:Regaddr:Regv_1:ℕval:ℕa_2:getI code pc = some (Instr.LOAD dst addr)a_3:v_1 = s.regs addra_4:s.mem v_1 = some val⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dst valcode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destsrc_1:Regaddr:Regv_1:ℕval:ℕa_2:getI code pc = some (Instr.STORE src_1 addr)a_3:val = s.regs src_1a_4:v_1 = s.regs addr⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateMem v_1 valcode:Codepc:ℕs:Statepc₂:ℕsrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destcond:Rega_3:s.regs cond ≠ 0a_2:getI code pc = some (Instr.JNZ cond pc₂)⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = scode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs destcond:Regtarget:ℕa_2:getI code pc = some (Instr.JNZ cond target)a_3:s.regs cond = 0⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = scode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srcsrc_1:Regdest_1:Regv_1:ℕa_2:getI code pc = some (Instr.ADD src_1 dest_1)a_3:v_1 = s.regs src_1 + s.regs dest_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 v_1code:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srcsrc_1:Regdest_1:Regv_1:ℕa_2:getI code pc = some (Instr.MOV src_1 dest_1)a_3:v_1 = s.regs src_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 v_1code:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srcdest_1:Regval:ℕa_2:getI code pc = some (Instr.MOVI dest_1 val)⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dest_1 valcode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srcdst:Regaddr:Regv_1:ℕval:ℕa_2:getI code pc = some (Instr.LOAD dst addr)a_3:v_1 = s.regs addra_4:s.mem v_1 = some val⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateReg dst valcode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srcsrc_1:Regaddr:Regv_1:ℕval:ℕa_2:getI code pc = some (Instr.STORE src_1 addr)a_3:val = s.regs src_1a_4:v_1 = s.regs addr⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = s.updateMem v_1 valcode:Codepc:ℕs:Statepc₂:ℕsrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srccond:Rega_3:s.regs cond ≠ 0a_2:getI code pc = some (Instr.JNZ cond pc₂)⊢ pc + 1 = pc₂ ∧ s.updateReg dest v = scode:Codepc:ℕs:Statesrc:Regdest:Regv:ℕa:getI code pc = some (Instr.MOV src dest)a_1:v = s.regs srccond:Regtarget:ℕa_2:getI code pc = some (Instr.JNZ cond target)a_3:s.regs cond = 0⊢ pc + 1 = pc + 1 ∧ s.updateReg dest v = scode:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)src:Regdest_1:Regv:ℕa_1:getI code pc = some (Instr.ADD src dest_1)a_2:v = s.regs src + s.regs dest_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = s.updateReg dest_1 vcode:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)src:Regdest_1:Regv:ℕa_1:getI code pc = some (Instr.MOV src dest_1)a_2:v = s.regs src⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = s.updateReg dest_1 vcode:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)dest_1:Regval_1:ℕa_1:getI code pc = some (Instr.MOVI dest_1 val_1)⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = s.updateReg dest_1 val_1code:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)dst:Regaddr:Regv:ℕval_1:ℕa_1:getI code pc = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some val_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = s.updateReg dst val_1code:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)src:Regaddr:Regv:ℕval_1:ℕa_1:getI code pc = some (Instr.STORE src addr)a_2:val_1 = s.regs srca_3:v = s.regs addr⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = s.updateMem v val_1code:Codepc:ℕs:Statepc₂:ℕdest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)cond:Rega_2:s.regs cond ≠ 0a_1:getI code pc = some (Instr.JNZ cond pc₂)⊢ pc + 1 = pc₂ ∧ s.updateReg dest val = scode:Codepc:ℕs:Statedest:Regval:ℕa:getI code pc = some (Instr.MOVI dest val)cond:Regtarget:ℕa_1:getI code pc = some (Instr.JNZ cond target)a_2:s.regs cond = 0⊢ pc + 1 = pc + 1 ∧ s.updateReg dest val = scode:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valsrc:Regdest:Regv_1:ℕa_3:getI code pc = some (Instr.ADD src dest)a_4:v_1 = s.regs src + s.regs dest⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = s.updateReg dest v_1code:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valsrc:Regdest:Regv_1:ℕa_3:getI code pc = some (Instr.MOV src dest)a_4:v_1 = s.regs src⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = s.updateReg dest v_1code:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valdest:Regval_1:ℕa_3:getI code pc = some (Instr.MOVI dest val_1)⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = s.updateReg dest val_1code:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valdst_1:Regaddr_1:Regv_1:ℕval_1:ℕa_3:getI code pc = some (Instr.LOAD dst_1 addr_1)a_4:v_1 = s.regs addr_1a_5:s.mem v_1 = some val_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = s.updateReg dst_1 val_1code:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valsrc:Regaddr_1:Regv_1:ℕval_1:ℕa_3:getI code pc = some (Instr.STORE src addr_1)a_4:val_1 = s.regs srca_5:v_1 = s.regs addr_1⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = s.updateMem v_1 val_1code:Codepc:ℕs:Statepc₂:ℕdst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valcond:Rega_4:s.regs cond ≠ 0a_3:getI code pc = some (Instr.JNZ cond pc₂)⊢ pc + 1 = pc₂ ∧ s.updateReg dst val = scode:Codepc:ℕs:Statedst:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.LOAD dst addr)a_1:v = s.regs addra_2:s.mem v = some valcond:Regtarget:ℕa_3:getI code pc = some (Instr.JNZ cond target)a_4:s.regs cond = 0⊢ pc + 1 = pc + 1 ∧ s.updateReg dst val = scode:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrsrc_1:Regdest:Regv_1:ℕa_3:getI code pc = some (Instr.ADD src_1 dest)a_4:v_1 = s.regs src_1 + s.regs dest⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = s.updateReg dest v_1code:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrsrc_1:Regdest:Regv_1:ℕa_3:getI code pc = some (Instr.MOV src_1 dest)a_4:v_1 = s.regs src_1⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = s.updateReg dest v_1code:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrdest:Regval_1:ℕa_3:getI code pc = some (Instr.MOVI dest val_1)⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = s.updateReg dest val_1code:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrdst:Regaddr_1:Regv_1:ℕval_1:ℕa_3:getI code pc = some (Instr.LOAD dst addr_1)a_4:v_1 = s.regs addr_1a_5:s.mem v_1 = some val_1⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = s.updateReg dst val_1code:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrsrc_1:Regaddr_1:Regv_1:ℕval_1:ℕa_3:getI code pc = some (Instr.STORE src_1 addr_1)a_4:val_1 = s.regs src_1a_5:v_1 = s.regs addr_1⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = s.updateMem v_1 val_1code:Codepc:ℕs:Statepc₂:ℕsrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrcond:Rega_4:s.regs cond ≠ 0a_3:getI code pc = some (Instr.JNZ cond pc₂)⊢ pc + 1 = pc₂ ∧ s.updateMem v val = scode:Codepc:ℕs:Statesrc:Regaddr:Regv:ℕval:ℕa:getI code pc = some (Instr.STORE src addr)a_1:val = s.regs srca_2:v = s.regs addrcond:Regtarget:ℕa_3:getI code pc = some (Instr.JNZ cond target)a_4:s.regs cond = 0⊢ pc + 1 = pc + 1 ∧ s.updateMem v val = scode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.ADD src dest)a_3:v = s.regs src + s.regs dest⊢ pc₁ = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.MOV src dest)a_3:v = s.regs src⊢ pc₁ = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)dest:Regval:ℕa_2:getI code pc = some (Instr.MOVI dest val)⊢ pc₁ = pc + 1 ∧ s = s.updateReg dest valcode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)dst:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.LOAD dst addr)a_3:v = s.regs addra_4:s.mem v = some val⊢ pc₁ = pc + 1 ∧ s = s.updateReg dst valcode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)src:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.STORE src addr)a_3:val = s.regs srca_4:v = s.regs addr⊢ pc₁ = pc + 1 ∧ s = s.updateMem v valcode:Codepc:ℕs:Statepc₁:ℕpc₂:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)cond_1:Rega_3:s.regs cond_1 ≠ 0a_2:getI code pc = some (Instr.JNZ cond_1 pc₂)⊢ pc₁ = pc₂ ∧ s = scode:Codepc:ℕs:Statepc₁:ℕcond:Rega_1:s.regs cond ≠ 0a:getI code pc = some (Instr.JNZ cond pc₁)cond_1:Regtarget:ℕa_2:getI code pc = some (Instr.JNZ cond_1 target)a_3:s.regs cond_1 = 0⊢ pc₁ = pc + 1 ∧ s = scode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.ADD src dest)a_3:v = s.regs src + s.regs dest⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regdest:Regv:ℕa_2:getI code pc = some (Instr.MOV src dest)a_3:v = s.regs src⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest vcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0dest:Regval:ℕa_2:getI code pc = some (Instr.MOVI dest val)⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dest valcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0dst:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.LOAD dst addr)a_3:v = s.regs addra_4:s.mem v = some val⊢ pc + 1 = pc + 1 ∧ s = s.updateReg dst valcode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0src:Regaddr:Regv:ℕval:ℕa_2:getI code pc = some (Instr.STORE src addr)a_3:val = s.regs srca_4:v = s.regs addr⊢ pc + 1 = pc + 1 ∧ s = s.updateMem v valcode:Codepc:ℕs:Statepc₂:ℕcond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0cond_1:Rega_3:s.regs cond_1 ≠ 0a_2:getI code pc = some (Instr.JNZ cond_1 pc₂)⊢ pc + 1 = pc₂ ∧ s = scode:Codepc:ℕs:Statecond:Regtarget:ℕa:getI code pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0cond_1:Regtarget_1:ℕa_2:getI code pc = some (Instr.JNZ cond_1 target_1)a_3:s.regs cond_1 = 0⊢ pc + 1 = pc + 1 ∧ s = s All goals completed! 🐙
theorem exec_halted {code : Code} {pc pc_h : ℕ} {s s_h : State}
(hexec : Exec code pc s pc_h s_h) (halt : Halted code pc) :
pc_h = pc ∧ s_h = s := code:Codepc:ℕpc_h:ℕs:States_h:Statehexec:Exec code pc s pc_h s_hhalt:Halted code pc⊢ pc_h = pc ∧ s_h = s
cases hexec with
code:Codepc:ℕs:Statehalt:Halted code pc⊢ pc = pc ∧ s = s All goals completed! 🐙
code:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcpc':ℕs':Stateheval:Eval code pc s pc' s'a:Exec code pc' s' pc_h s_h⊢ pc_h = pc ∧ s_h = s code:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regdest:Regv:ℕa_1:getI code pc = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desta:Exec code (pc + 1) (s.updateReg dest v) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regdest:Regv:ℕa_1:getI code pc = some (Instr.MOV src dest)a_2:v = s.regs srca:Exec code (pc + 1) (s.updateReg dest v) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcdest:Regval:ℕa_1:getI code pc = some (Instr.MOVI dest val)a:Exec code (pc + 1) (s.updateReg dest val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcdst:Regaddr:Regv:ℕval:ℕa_1:getI code pc = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some vala:Exec code (pc + 1) (s.updateReg dst val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regaddr:Regv:ℕval:ℕa_1:getI code pc = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addra:Exec code (pc + 1) (s.updateMem v val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcpc':ℕcond:Rega_2:s.regs cond ≠ 0a_1:getI code pc = some (Instr.JNZ cond pc')a:Exec code pc' s pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pccond:Regtarget:ℕa_1:getI code pc = some (Instr.JNZ cond target)a_2:s.regs cond = 0a:Exec code (pc + 1) s pc_h s_h⊢ pc_h = pc ∧ s_h = s code:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regdest:Regv:ℕa_1:getI code pc = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desta:Exec code (pc + 1) (s.updateReg dest v) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regdest:Regv:ℕa_1:getI code pc = some (Instr.MOV src dest)a_2:v = s.regs srca:Exec code (pc + 1) (s.updateReg dest v) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcdest:Regval:ℕa_1:getI code pc = some (Instr.MOVI dest val)a:Exec code (pc + 1) (s.updateReg dest val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcdst:Regaddr:Regv:ℕval:ℕa_1:getI code pc = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some vala:Exec code (pc + 1) (s.updateReg dst val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcsrc:Regaddr:Regv:ℕval:ℕa_1:getI code pc = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addra:Exec code (pc + 1) (s.updateMem v val) pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pcpc':ℕcond:Rega_2:s.regs cond ≠ 0a_1:getI code pc = some (Instr.JNZ cond pc')a:Exec code pc' s pc_h s_h⊢ pc_h = pc ∧ s_h = scode:Codepc:ℕpc_h:ℕs:States_h:Statehalt:Halted code pccond:Regtarget:ℕa_1:getI code pc = some (Instr.JNZ cond target)a_2:s.regs cond = 0a:Exec code (pc + 1) s pc_h s_h⊢ pc_h = pc ∧ s_h = s All goals completed! 🐙
theorem exec_step_of_not_halted {code : Code} {pc pc_h : ℕ} {s s_h : State}
(hexec : Exec code pc s pc_h s_h)
(hhalted : Halted code pc_h) (hnh : ¬Halted code pc) :
∃ pc' s', Eval code pc s pc' s' ∧ Exec code pc' s' pc_h s_h := code:Codepc:ℕpc_h:ℕs:States_h:Statehexec:Exec code pc s pc_h s_hhhalted:Halted code pc_hhnh:¬Halted code pc⊢ ∃ pc' s', Eval code pc s pc' s' ∧ Exec code pc' s' pc_h s_h
cases hexec with
code:Codepc:ℕs:Statehnh:¬Halted code pchhalted:Halted code pc⊢ ∃ pc' s', Eval code pc s pc' s' ∧ Exec code pc' s' pc s All goals completed! 🐙
code:Codepc:ℕpc_h:ℕs:States_h:Statehhalted:Halted code pc_hhnh:¬Halted code pcpc':ℕs':Stateheval:Eval code pc s pc' s'hrest:Exec code pc' s' pc_h s_h⊢ ∃ pc' s', Eval code pc s pc' s' ∧ Exec code pc' s' pc_h s_h All goals completed! 🐙
theorem jnz_inj {c₁ c₂ : Reg} {t₁ t₂ : ℕ}
(h : (Instr.JNZ c₁ t₁ : Instr) = Instr.JNZ c₂ t₂) : c₁ = c₂ ∧ t₁ = t₂ := c₁:Regc₂:Regt₁:ℕt₂:ℕh:Instr.JNZ c₁ t₁ = Instr.JNZ c₂ t₂⊢ c₁ = c₂ ∧ t₁ = t₂
c₁:Regc₂:Regt₁:ℕt₂:ℕh:c₁ = c₂ ∧ t₁ = t₂⊢ c₁ = c₂ ∧ t₁ = t₂; All goals completed! 🐙
3.7.7.1. The difficulty of the frame rule
The hard case is the frame rule. Suppose that \{P\}\ c @ pc\ \{Q\} is
derivable and that the initial state s satisfies P \ast R, that is,
s.\mathit{mem} = h_1 \uplus h_2 with P holding over h_1 and R
over h_2. The induction hypothesis talks about executions that start in
the small state \langle s.\mathit{regs}, h_1\rangle, but the actual
execution starts in the large state s. We need to show two things:
-
the large execution corresponds to a small execution, which uses only
h_1and ends in someh_1'; -
the final heap of the large execution is
h_1' \uplus h_2, that is,h_2was not touched, so thatRstill holds.
Neither claim holds for arbitrary executions: a LOAD or STORE at an
address of h_2 would break both. They hold because the execution was
verified starting from P, and the Triple rules require ownership
of the addresses accessed.
To formalize this, we introduce an auxiliary relation
ExecFP prog h h' pc s pc_h s_h, an execution annotated with its
footprint: it records the owned heap h before the execution and the
owned heap h' at the end, and each LOAD or STORE carries a proof that
the accessed address belongs to the heap owned at that moment. On a
STORE, the owned heap is updated.
inductive ExecFP (prog : Code) : Heap → Heap → ℕ → State → ℕ → State → Prop where
| refl {h pc s} :
ExecFP prog h h pc s pc s
| step_noacc {h h' pc pc' pc_h s s' s_h}
(heval : Eval prog pc s pc' s')
(hno_load : ∀ dst addr, getI prog pc ≠ some (.LOAD dst addr))
(hno_store : ∀ src addr, getI prog pc ≠ some (.STORE src addr))
(hrest : ExecFP prog h h' pc' s' pc_h s_h) :
ExecFP prog h h' pc s pc_h s_h
| step_load {h h' pc pc_h s s_h} {dst addr : Reg} {val : ℕ}
(hfetch : getI prog pc = some (.LOAD dst addr))
(hmem_r : s.mem (s.regs addr) = some val)
(hown : h (s.regs addr) ≠ none)
(hrest : ExecFP prog h h' (pc + 1) (s.updateReg dst val) pc_h s_h) :
ExecFP prog h h' pc s pc_h s_h
| step_store {h h' pc pc_h s s_h} {src addr : Reg}
(hfetch : getI prog pc = some (.STORE src addr))
(hown : h (s.regs addr) ≠ none)
(hrest : ExecFP prog (h.update (s.regs addr) (s.regs src)) h'
(pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h) :
ExecFP prog h h' pc s pc_h s_h
The central lemma shows that an execution with footprint over h_1, run
in a state whose memory is h_1 \uplus h_2, has both desired properties:
the final heap is h_1' \uplus h_2, and the corresponding execution in
the small state exists. The proof is by induction on ExecFP. In
steps without memory access, the small execution takes the same step; in
LOAD steps, we use the fact that the address read belongs to h_1, so
reading the small memory returns the same value; in STORE steps, we use
Heap.update_union_left and Heap.disjoint_update_left to
show that the write happens in h_1 and preserves disjointness.
theorem exec_frame_inv_aux
{prog : Code} {h₁ h₁' : Heap} {pc pc_h : ℕ} {s s_h : State}
(hfp : ExecFP prog h₁ h₁' pc s pc_h s_h) :
∀ {h₂ : Heap},
Heap.disjoint h₁ h₂ → s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc ⟨s.regs, h₁⟩ pc_h ⟨s_h.regs, h₁'⟩ ∧
Heap.disjoint h₁' h₂ := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
induction hfp with
prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Stateh:Heappc_1:ℕs_1:State⊢ ∀ {h₂ : Heap},
h.disjoint h₂ →
s_1.mem = h.union h₂ →
s_1.mem = h.union h₂ ∧
Exec prog pc_1 { regs := s_1.regs, mem := h } pc_1 { regs := s_1.regs, mem := h } ∧ h.disjoint h₂
intro h₂ prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Stateh:Heappc_1:ℕs_1:Stateh₂:Heaphdisj:h.disjoint h₂⊢ s_1.mem = h.union h₂ →
s_1.mem = h.union h₂ ∧
Exec prog pc_1 { regs := s_1.regs, mem := h } pc_1 { regs := s_1.regs, mem := h } ∧ h.disjoint h₂ prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Stateh:Heappc_1:ℕs_1:Stateh₂:Heaphdisj:h.disjoint h₂hmem:s_1.mem = h.union h₂⊢ s_1.mem = h.union h₂ ∧ Exec prog pc_1 { regs := s_1.regs, mem := h } pc_1 { regs := s_1.regs, mem := h } ∧ h.disjoint h₂; All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States':States_h:Stateheval:Eval prog pc s pc' s'hno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)hrest:ExecFP prog h₁ h₁' pc' s' pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s'.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s'.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
intro h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States':States_h:Stateheval:Eval prog pc s pc' s'hno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)hrest:ExecFP prog h₁ h₁' pc' s' pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s'.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s'.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂⊢ s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States':States_h:Stateheval:Eval prog pc s pc' s'hno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)hrest:ExecFP prog h₁ h₁' pc' s' pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s'.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s'.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
have hmem_s' : s'.mem = h₁.union h₂ := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
cases heval with
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕa:getI prog pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs desthrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest v).mem = h₁.union h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕa:getI prog pc = some (Instr.MOV src dest)a_1:v = s.regs srchrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest v).mem = h₁.union h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂dest:Regval:ℕa:getI prog pc = some (Instr.MOVI dest val)hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest val).mem = h₁.union h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂dest:Regval:ℕa:getI prog pc = some (Instr.MOVI dest val)hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest val).mem = h₁.union h₂prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕa:getI prog pc = some (Instr.MOV src dest)a_1:v = s.regs srchrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest v).mem = h₁.union h₂prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕa:getI prog pc = some (Instr.ADD src dest)a_1:v = s.regs src + s.regs desthrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dest v).mem = h₁.union h₂ All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Rega_1:s.regs cond ≠ 0a:getI prog pc = some (Instr.JNZ cond pc')hrest:ExecFP prog h₁ h₁' pc' s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ s.mem = h₁.union h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Regtarget:ℕa:getI prog pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0hrest:ExecFP prog h₁ h₁' (pc + 1) s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ s.mem = h₁.union h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Regtarget:ℕa:getI prog pc = some (Instr.JNZ cond target)a_1:s.regs cond = 0hrest:ExecFP prog h₁ h₁' (pc + 1) s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ s.mem = h₁.union h₂prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Rega_1:s.regs cond ≠ 0a:getI prog pc = some (Instr.JNZ cond pc')hrest:ExecFP prog h₁ h₁' pc' s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ s.mem = h₁.union h₂ All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂dst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a:v = s.regs addra_1:s.mem v = some valhrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateReg dst val).mem = h₁.union h₂ All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a:val = s.regs srca_1:v = s.regs addrhrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateMem v val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateMem v val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateMem v val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ (s.updateMem v val).mem = h₁.union h₂ All goals completed! 🐙
have heval_small : Eval prog pc ⟨s.regs, h₁⟩ pc' ⟨s'.regs, h₁⟩ := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
cases heval with
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕhf:getI prog pc = some (Instr.ADD src dest)hv:v = s.regs src + s.regs desthmem_s':(s.updateReg dest v).mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regdest:Regv:ℕhf:getI prog pc = some (Instr.MOV src dest)hv:v = s.regs srchmem_s':(s.updateReg dest v).mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest v) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest v).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := (s.updateReg dest v).regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂dest:Regval:ℕhf:getI prog pc = some (Instr.MOVI dest val)hmem_s':(s.updateReg dest val).mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dest val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dest val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dest val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := (s.updateReg dest val).regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Reghc:s.regs cond ≠ 0hf:getI prog pc = some (Instr.JNZ cond pc')hrest:ExecFP prog h₁ h₁' pc' s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂hmem_s':s.mem = h₁.union h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } pc' { regs := s.regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂cond:Regtarget:ℕhf:getI prog pc = some (Instr.JNZ cond target)hc:s.regs cond = 0hmem_s':s.mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) s pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := s.regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂dst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a:v = s.regs addra_1:s.mem v = some valhmem_s':(s.updateReg dst val).mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂src:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a:val = s.regs srca_1:v = s.regs addrhmem_s':(s.updateMem v val).mem = h₁.union h₂hrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateMem v val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateMem v val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateMem v val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) { regs := (s.updateMem v val).regs, mem := h₁ } All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc':ℕpc_h:ℕs:States':States_h:Stateheval:Eval prog pc s pc' s'hno_load:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hno_store:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)hrest:ExecFP prog h₁ h₁' pc' s' pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
s'.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc' { regs := s'.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hmem_s':s'.mem = h₁.union h₂heval_small:Eval prog pc { regs := s.regs, mem := h₁ } pc' { regs := s'.regs, mem := h₁ }hmem':s_h.mem = h₁'.union h₂hexec':Exec prog pc' { regs := s'.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' }hdisj':h₁'.disjoint h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
intro h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂⊢ s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
have h₁_read : h₁ (s.regs addr) = some val := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphmem_r:h₁.union h₂ (s.regs addr) = some valhdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂⊢ h₁ (s.regs addr) = some val
cases hh : h₁ (s.regs addr) with
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphmem_r:h₁.union h₂ (s.regs addr) = some valhdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hh:h₁ (s.regs addr) = none⊢ none = some val All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphmem_r:h₁.union h₂ (s.regs addr) = some valhdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂w:ℕhh:h₁ (s.regs addr) = some w⊢ some w = some val All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂h₁_read:h₁ (s.regs addr) = some valheval_small:Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) ({ regs := s.regs, mem := h₁ }.updateReg dst val)⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
have hmem_upd : (s.updateReg dst val).mem = h₁.union h₂ := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂ All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog h₁ h₁' (pc + 1) (s.updateReg dst val) pc_h s_hih:∀ {h₂ : Heap},
h₁.disjoint h₂ →
(s.updateReg dst val).mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂h₁_read:h₁ (s.regs addr) = some valheval_small:Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) ({ regs := s.regs, mem := h₁ }.updateReg dst val)hmem_upd:(s.updateReg dst val).mem = h₁.union h₂hmem':s_h.mem = h₁'.union h₂hexec':Exec prog (pc + 1) { regs := (s.updateReg dst val).regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' }hdisj':h₁'.disjoint h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
intro h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂⊢ s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂ prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hdisj_mid:(h₁.update (s.regs addr) (s.regs src)).disjoint h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
have hmem_s' : (s.updateMem (s.regs addr) (s.regs src)).mem =
(h₁.update (s.regs addr) (s.regs src)).union h₂ := prog:Codeh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog h₁ h₁' pc s pc_h s_h⊢ ∀ {h₂ : Heap},
h₁.disjoint h₂ →
s.mem = h₁.union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hdisj_mid:(h₁.update (s.regs addr) (s.regs src)).disjoint h₂⊢ s.mem.update (s.regs addr) (s.regs src) = (h₁.update (s.regs addr) (s.regs src)).union h₂; All goals completed! 🐙
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hdisj_mid:(h₁.update (s.regs addr) (s.regs src)).disjoint h₂hmem_s':(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂heval_small:Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) ({ regs := s.regs, mem := h₁ }.updateMem (s.regs addr) (s.regs src))⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
prog:Codeh₁✝:Heaph₁'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Stateh₁:Heaph₁':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:h₁ (s.regs addr) ≠ nonehrest:ExecFP prog (h₁.update (s.regs addr) (s.regs src)) h₁' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:∀ {h₂ : Heap},
(h₁.update (s.regs addr) (s.regs src)).disjoint h₂ →
(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂ →
s_h.mem = h₁'.union h₂ ∧
Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' } ∧
h₁'.disjoint h₂h₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hdisj_mid:(h₁.update (s.regs addr) (s.regs src)).disjoint h₂hmem_s':(s.updateMem (s.regs addr) (s.regs src)).mem = (h₁.update (s.regs addr) (s.regs src)).union h₂heval_small:Eval prog pc { regs := s.regs, mem := h₁ } (pc + 1) ({ regs := s.regs, mem := h₁ }.updateMem (s.regs addr) (s.regs src))hmem':s_h.mem = h₁'.union h₂hexec':Exec prog (pc + 1)
{ regs := (s.updateMem (s.regs addr) (s.regs src)).regs, mem := h₁.update (s.regs addr) (s.regs src) } pc_h
{ regs := s_h.regs, mem := h₁' }hdisj':h₁'.disjoint h₂⊢ s_h.mem = h₁'.union h₂ ∧
Exec prog pc { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' } ∧ h₁'.disjoint h₂
All goals completed! 🐙
theorem exec_frame_inv_fp
{prog : Code} {h₁ h₁' h₂ : Heap} {pc pc_h : ℕ} {s s_h : State}
(hdisj : Heap.disjoint h₁ h₂) (hmem : s.mem = h₁.union h₂)
(hfp : ExecFP prog h₁ h₁' pc s pc_h s_h) :
s_h.mem = h₁'.union h₂ ∧
Exec prog pc ⟨s.regs, h₁⟩ pc_h ⟨s_h.regs, h₁'⟩ ∧
Heap.disjoint h₁' h₂ :=
exec_frame_inv_aux hfp hdisj hmem
The next lemma lets us "forget" part of the owned heap: an execution with
footprint over h_a is also an execution with footprint over
h_a \uplus h_b, which is what we need when the frame rule appears
nested.
theorem exec_fp_union_right
{prog : Code} {ha ha' : Heap} {pc pc_h : ℕ} {s s_h : State}
(hfp : ExecFP prog ha ha' pc s pc_h s_h)
{hb : Heap} (hdisj : Heap.disjoint ha hb) :
ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h := prog:Codeha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statehfp:ExecFP prog ha ha' pc s pc_h s_hhb:Heaphdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
induction hfp with
prog:Codeha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statehb:Heaph:Heappc_1:ℕs_1:Statehdisj:h.disjoint hb⊢ ExecFP prog (h.union hb) (h.union hb) pc_1 s_1 pc_1 s_1 All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc':ℕpc_h:ℕs:States':States_h:Stateheval:Eval prog pc s pc' s'hnl:∀ (dst addr : Reg), getI prog pc ≠ some (Instr.LOAD dst addr)hns:∀ (src addr : Reg), getI prog pc ≠ some (Instr.STORE src addr)hrest:ExecFP prog ha ha' pc' s' pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) pc' s' pc_h s_hhdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hb⊢ ha.union hb (s.regs addr) ≠ noneprog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hb⊢ ha.union hb (s.regs addr) ≠ none prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hbheq:ha.union hb (s.regs addr) = none⊢ False
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hbheq:ha.union hb (s.regs addr) = none⊢ ha (s.regs addr) = none
cases hha : ha (s.regs addr) with
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hbheq:ha.union hb (s.regs addr) = nonehha:ha (s.regs addr) = none⊢ none = none All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hbheq:ha.union hb (s.regs addr) = nonev:ℕhha:ha (s.regs addr) = some v⊢ some v = none All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statedst:Regaddr:Regval:ℕhfetch:getI prog pc = some (Instr.LOAD dst addr)hmem_r:s.mem (s.regs addr) = some valhown:ha (s.regs addr) ≠ nonehrest:ExecFP prog ha ha' (pc + 1) (s.updateReg dst val) pc_h s_hih:ha.disjoint hb → ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_hhdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) (pc + 1) (s.updateReg dst val) pc_h s_h All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hb⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ExecFP prog (ha.union hb) (ha'.union hb) pc s pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ha.union hb (s.regs addr) ≠ noneprog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ha.union hb (s.regs addr) ≠ none prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hheq:ha.union hb (s.regs addr) = none⊢ False
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hheq:ha.union hb (s.regs addr) = none⊢ ha (s.regs addr) = none
cases hha : ha (s.regs addr) with
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hheq:ha.union hb (s.regs addr) = nonehha:ha (s.regs addr) = none⊢ none = none All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hheq:ha.union hb (s.regs addr) = nonev:ℕhha:ha (s.regs addr) = some v⊢ some v = none All goals completed! 🐙
prog:Codeha✝:Heapha'✝:Heappc✝:ℕpc_h✝:ℕs✝:States_h✝:Statehb:Heapha:Heapha':Heappc:ℕpc_h:ℕs:States_h:Statesrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hown:ha (s.regs addr) ≠ nonehrest:ExecFP prog (ha.update (s.regs addr) (s.regs src)) ha' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hih:(ha.update (s.regs addr) (s.regs src)).disjoint hb →
ExecFP prog ((ha.update (s.regs addr) (s.regs src)).union hb) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhdisj:ha.disjoint hbhdisj_mid:(ha.update (s.regs addr) (s.regs src)).disjoint hbhkey:ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ExecFP prog ((ha.union hb).update (s.regs addr) (s.regs src)) (ha'.union hb) (pc + 1)
(s.updateMem (s.regs addr) (s.regs src)) pc_h s_h All goals completed! 🐙
Finally, we show that every execution starting from a state whose owned
heap satisfies the precondition of a derivable triple admits a footprint
annotation. The proof is by induction on the derivation of the triple and
follows the pattern already described: in each instruction rule, the first
step of the execution is identified by determinism; for LOAD and
STORE, the precondition of the rule provides the proof of ownership of
the address.
theorem exec_fp_of_triple {P Q : Assert} {prog : Code} {pc : ℕ}
(htriple : {{* P *}} prog @ pc {{* Q *}}) :
∀ {s : State} {h h₂ : Heap},
P ⟨s.regs, h⟩ → s.mem = h.union h₂ →
∀ {pc_h s_h}, Exec prog pc s pc_h s_h →
∃ h', ExecFP prog h h' pc s pc_h s_h := P:AssertQ:Assertprog:Codepc:ℕhtriple:{{* P *}} prog @ pc {{* Q *}}⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
induction htriple with
P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = none⊢ ∀ {s : State} {h h₂ : Heap},
Q_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
intro s P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heap⊢ ∀ {h₂ : Heap},
Q_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heap⊢ Q_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
cases hexec with
P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_1 s All goals completed! 🐙
P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog_1 pc_1 s pc' s'a:Exec prog_1 pc' s' pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕa_1:getI prog_1 pc_1 = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desta:Exec prog_1 (pc_1 + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕa_1:getI prog_1 pc_1 = some (Instr.MOV src dest)a_2:v = s.regs srca:Exec prog_1 (pc_1 + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedest:Regval:ℕa_1:getI prog_1 pc_1 = some (Instr.MOVI dest val)a:Exec prog_1 (pc_1 + 1) (s.updateReg dest val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedst:Regaddr:Regv:ℕval:ℕa_1:getI prog_1 pc_1 = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some vala:Exec prog_1 (pc_1 + 1) (s.updateReg dst val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regaddr:Regv:ℕval:ℕa_1:getI prog_1 pc_1 = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addra:Exec prog_1 (pc_1 + 1) (s.updateMem v val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕcond:Rega_2:s.regs cond ≠ 0a_1:getI prog_1 pc_1 = some (Instr.JNZ cond pc')a:Exec prog_1 pc' s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statecond:Regtarget:ℕa_1:getI prog_1 pc_1 = some (Instr.JNZ cond target)a_2:s.regs cond = 0a:Exec prog_1 (pc_1 + 1) s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕa_1:getI prog_1 pc_1 = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desta:Exec prog_1 (pc_1 + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕa_1:getI prog_1 pc_1 = some (Instr.MOV src dest)a_2:v = s.regs srca:Exec prog_1 (pc_1 + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedest:Regval:ℕa_1:getI prog_1 pc_1 = some (Instr.MOVI dest val)a:Exec prog_1 (pc_1 + 1) (s.updateReg dest val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedst:Regaddr:Regv:ℕval:ℕa_1:getI prog_1 pc_1 = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some vala:Exec prog_1 (pc_1 + 1) (s.updateReg dst val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regaddr:Regv:ℕval:ℕa_1:getI prog_1 pc_1 = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addra:Exec prog_1 (pc_1 + 1) (s.updateMem v val) pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕcond:Rega_2:s.regs cond ≠ 0a_1:getI prog_1 pc_1 = some (Instr.JNZ cond pc')a:Exec prog_1 pc' s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hP:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Stateh:Heaph₂:Heaphp:Q_1 { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statecond:Regtarget:ℕa_1:getI prog_1 pc_1 = some (Instr.JNZ cond target)a_2:s.regs cond = 0a:Exec prog_1 (pc_1 + 1) s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h All goals completed! 🐙
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
P' { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
intro s P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
P' { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heap⊢ P' { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:P' { regs := s.regs, mem := h }⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:P' { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:P' { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:P' { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:P' { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
All goals completed! 🐙
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(P_1 ∗ R) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
intro s P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(P_1 ∗ R) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (P_1 ∗ R) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:(P_1 ∗ R) { regs := s.regs, mem := h }⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:(P_1 ∗ R) { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:(P_1 ∗ R) { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:(P_1 ∗ R) { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphp:(P_1 ∗ R) { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hha:Heaphb:Heaphdisj_ab:ha.disjoint hbhh_eq:{ regs := s.regs, mem := h }.mem = ha.union hbhPa:P_1 { regs := { regs := s.regs, mem := h }.regs, mem := ha }right:R { regs := { regs := s.regs, mem := h }.regs, mem := hb }⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hha:Heaphb:Heaphdisj_ab:ha.disjoint hbhh_eq:{ regs := s.regs, mem := h }.mem = ha.union hbhPa:P_1 { regs := { regs := s.regs, mem := h }.regs, mem := ha }right:R { regs := { regs := s.regs, mem := h }.regs, mem := hb }hh:h = ha.union hb⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heappc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hha:Heaphb:Heaphmem:s.mem = ha.union (hb.union h₂)hdisj_ab:ha.disjoint hbhh_eq:{ regs := s.regs, mem := h }.mem = ha.union hbhPa:P_1 { regs := { regs := s.regs, mem := h }.regs, mem := ha }right:R { regs := { regs := s.regs, mem := h }.regs, mem := hb }hh:h = ha.union hb⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:∀ {s : State} {h h₂ : Heap},
P_1 { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_hs:Stateh:Heaph₂:Heappc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hha:Heaphb:Heaphmem:s.mem = ha.union (hb.union h₂)hdisj_ab:ha.disjoint hbhh_eq:{ regs := s.regs, mem := h }.mem = ha.union hbhPa:P_1 { regs := { regs := s.regs, mem := h }.regs, mem := ha }right:R { regs := { regs := s.regs, mem := h }.regs, mem := hb }hh:h = ha.union hbha':Heaphfp_a:ExecFP prog_1 ha ha' pc_1 s pc_h s_h⊢ ∃ h', ExecFP prog_1 h h' pc_1 s pc_h s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(fun s => P (s.updateReg dest val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(fun s => P (s.updateReg dest val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (fun s => P (s.updateReg dest val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest val)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest val)hpc':pc' = pc + 1hs':s' = s.updateReg dest val⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:States':Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest val)hs':s' = s.updateReg dest valheval:Eval prog pc s (pc + 1) s'hexec_rest:Exec prog (pc + 1) s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest val)heval:Eval prog pc s (pc + 1) (s.updateReg dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
obtain ⟨h', hfp⟩ := ih (s := s.updateReg dest val) (h₂ := h₂) hp (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest val)heval:Eval prog pc s (pc + 1) (s.updateReg dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ (s.updateReg dest val).mem = { regs := s.regs, mem := h }.mem.union h₂ All goals completed! 🐙) hexec_rest
exact ⟨h', ExecFP.step_noacc hstep
(fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest val)heval:Eval prog pc s (pc + 1) (s.updateReg dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest val) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.LOAD x✝¹ x✝)⊢ False All goals completed! 🐙) (fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest val)heval:Eval prog pc s (pc + 1) (s.updateReg dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest val) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.STORE x✝¹ x✝)⊢ False All goals completed! 🐙) hfp⟩
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(fun s => P (s.updateReg dest (s.regs dest + s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(fun s => P (s.updateReg dest (s.regs dest + s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (fun s => P (s.updateReg dest (s.regs dest + s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
have hstep : Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) :=
Eval.add (s := s) (v := s.regs dest + s.regs src) hfetch (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ s.regs dest + s.regs src = s.regs src + s.regs dest All goals completed! 🐙)
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hpc':pc' = pc + 1hs':s' = s.updateReg dest (s.regs dest + s.regs src)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:States':Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hs':s' = s.updateReg dest (s.regs dest + s.regs src)heval:Eval prog pc s (pc + 1) s'hexec_rest:Exec prog (pc + 1) s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
obtain ⟨h', hfp⟩ := ih (s := s.updateReg dest (s.regs dest + s.regs src)) (h₂ := h₂)
hp (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_h⊢ (s.updateReg dest (s.regs dest + s.regs src)).mem = { regs := s.regs, mem := h }.mem.union h₂ All goals completed! 🐙) hexec_rest
exact ⟨h', ExecFP.step_noacc hstep
(fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.LOAD x✝¹ x✝)⊢ False All goals completed! 🐙) (fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P
({ regs := s.regs, mem := h }.updateReg dest
({ regs := s.regs, mem := h }.regs dest + { regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.STORE x✝¹ x✝)⊢ False All goals completed! 🐙) hfp⟩
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(fun s => P (s.updateReg dest (s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(fun s => P (s.updateReg dest (s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (fun s => P (s.updateReg dest (s.regs src))) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hpc':pc' = pc + 1hs':s' = s.updateReg dest (s.regs src)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:States':Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hs':s' = s.updateReg dest (s.regs src)heval:Eval prog pc s (pc + 1) s'hexec_rest:Exec prog (pc + 1) s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
obtain ⟨h', hfp⟩ := ih (s := s.updateReg dest (s.regs src)) (h₂ := h₂)
hp (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_h⊢ (s.updateReg dest (s.regs src)).mem = { regs := s.regs, mem := h }.mem.union h₂ All goals completed! 🐙) hexec_rest
exact ⟨h', ExecFP.step_noacc hstep
(fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.LOAD x✝¹ x✝)⊢ False All goals completed! 🐙) (fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P ({ regs := s.regs, mem := h }.updateReg dest ({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_hh':Heaphfp:ExecFP prog { regs := s.regs, mem := h }.mem h' (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.STORE x✝¹ x✝)⊢ False All goals completed! 🐙) hfp⟩
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(fun s => ∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(fun s => ∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (fun s => ∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)) { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ val,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some val ∧
P ({ regs := s.regs, mem := h }.updateReg dst val)⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ val,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some val ∧
P ({ regs := s.regs, mem := h }.updateReg dst val)hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ val,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some val ∧
P ({ regs := s.regs, mem := h }.updateReg dst val)hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ val,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some val ∧
P ({ regs := s.regs, mem := h }.updateReg dst val)hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ val,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some val ∧
P ({ regs := s.regs, mem := h }.updateReg dst val)hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hval:ℕhmem_h:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some val⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
have hown : h (s.regs addr) ≠ none := P:AssertQ:Assertprog:Codepc:ℕhtriple:{{* P *}} prog @ pc {{* Q *}}⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h All goals completed! 🐙
have hmem_full : s.mem (s.regs addr) = some val := P:AssertQ:Assertprog:Codepc:ℕhtriple:{{* P *}} prog @ pc {{* Q *}}⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ none⊢ h.union h₂ (s.regs addr) = some val; All goals completed! 🐙
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂val:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some val⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some valpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some valpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dst val)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some valpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dst val)hpc':pc' = pc + 1hs':s' = s.updateReg dst val⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some vals':Statehstep:Eval prog pc s (pc + 1) (s.updateReg dst val)hs':s' = s.updateReg dst valheval:Eval prog pc s (pc + 1) s'hexec_rest:Exec prog (pc + 1) s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some valhstep:Eval prog pc s (pc + 1) (s.updateReg dst val)heval:Eval prog pc s (pc + 1) (s.updateReg dst val)hexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
obtain ⟨h', hfp⟩ := ih (s := s.updateReg dst val) (h₂ := h₂) hP' (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateval:ℕhmem_h✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some valhP':P ({ regs := s.regs, mem := h }.updateReg dst val)hmem_h:h (s.regs addr) = some valhown:h (s.regs addr) ≠ nonehmem_full:s.mem (s.regs addr) = some valhstep:Eval prog pc s (pc + 1) (s.updateReg dst val)heval:Eval prog pc s (pc + 1) (s.updateReg dst val)hexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ (s.updateReg dst val).mem = { regs := s.regs, mem := h }.mem.union h₂ All goals completed! 🐙) hexec_rest
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
(fun s => ∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src)))
{ regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
(fun s => ∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src)))
{ regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ (fun s => ∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src)))
{ regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ old,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some old ∧
P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ old,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some old ∧
P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ old,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some old ∧
P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ old,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some old ∧
P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:∃ old,
{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some old ∧
P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hold:ℕhmem_old:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some old⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
have hown : h (s.regs addr) ≠ none := P:AssertQ:Assertprog:Codepc:ℕhtriple:{{* P *}} prog @ pc {{* Q *}}⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h All goals completed! 🐙
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂old:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ none⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hpc':pc' = pc + 1hs':s' = s.updateMem (s.regs addr) (s.regs src)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nones':Statehstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hs':s' = s.updateMem (s.regs addr) (s.regs src)heval:Eval prog pc s (pc + 1) s'hexec_rest:Exec prog (pc + 1) s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonehstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
have hmem_s' : (s.updateMem (s.regs addr) (s.regs src)).mem =
(h.update (s.regs addr) (s.regs src)).union h₂ := P:AssertQ:Assertprog:Codepc:ℕhtriple:{{* P *}} prog @ pc {{* Q *}}⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonehstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ s.mem.update (s.regs addr) (s.regs src) = (h.update (s.regs addr) (s.regs src)).union h₂; All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)hcont:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphmem:s.mem = h.union h₂pc_h:ℕs_h:Stateold:ℕhmem_old✝:{ regs := s.regs, mem := h }.mem ({ regs := s.regs, mem := h }.regs addr) = some oldhP':P
({ regs := s.regs, mem := h }.updateMem ({ regs := s.regs, mem := h }.regs addr)
({ regs := s.regs, mem := h }.regs src))hmem_old:h (s.regs addr) = some oldhown:h (s.regs addr) ≠ nonehstep:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))heval:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_hhmem_s':(s.updateMem (s.regs addr) (s.regs src)).mem = (h.update (s.regs addr) (s.regs src)).union h₂h':Heaphfp:ExecFP prog (h.update (s.regs addr) (s.regs src)) h' (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∀ {s : State} {h h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heap⊢ ∀ {h₂ : Heap},
P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heap⊢ P { regs := s.regs, mem := h } →
s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }⊢ s.mem = h.union h₂ → ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
cases hexec with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂⊢ ∃ h', ExecFP prog h h' pc s pc s All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
cases heval with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statepc':ℕcond_1:Reghcond:s.regs cond_1 ≠ 0hf:getI prog pc = some (Instr.JNZ cond_1 pc')hexec_rest:Exec prog pc' s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehcond:s.regs cond ≠ 0hexec_rest:Exec prog target s pc_h s_hhf:getI prog pc = some (Instr.JNZ cond target)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehcond:s.regs cond ≠ 0hexec_rest:Exec prog target s pc_h s_hhf:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' target s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
exact ⟨h', ExecFP.step_noacc (Eval.jnz_taken hfetch hcond)
(fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehcond:s.regs cond ≠ 0hexec_rest:Exec prog target s pc_h s_hhf✝:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' target s pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.LOAD x✝¹ x✝)⊢ False All goals completed! 🐙) (fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehcond:s.regs cond ≠ 0hexec_rest:Exec prog target s pc_h s_hhf✝:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' target s pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.STORE x✝¹ x✝)⊢ False All goals completed! 🐙) hfp⟩
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statecond_1:Regtarget_1:ℕhf:getI prog pc = some (Instr.JNZ cond_1 target_1)hcond:s.regs cond_1 = 0hexec_rest:Exec prog (pc + 1) s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec_rest:Exec prog (pc + 1) s pc_h s_hhcond:s.regs cond = 0hf:getI prog pc = some (Instr.JNZ cond target)⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec_rest:Exec prog (pc + 1) s pc_h s_hhcond:s.regs cond = 0hf:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' (pc + 1) s pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
exact ⟨h', ExecFP.step_noacc (Eval.jnz_not_taken hfetch hcond)
(fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec_rest:Exec prog (pc + 1) s pc_h s_hhcond:s.regs cond = 0hf✝:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' (pc + 1) s pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.LOAD x✝¹ x✝)⊢ False All goals completed! 🐙) (fun _ _ hf => P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statehexec_rest:Exec prog (pc + 1) s pc_h s_hhcond:s.regs cond = 0hf✝:getI prog pc = some (Instr.JNZ cond target)h':Heaphfp:ExecFP prog h h' (pc + 1) s pc_h s_hx✝¹:Regx✝:Reghf:getI prog pc = some (Instr.STORE x✝¹ x✝)⊢ False All goals completed! 🐙) hfp⟩
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.ADD src dest)a:v = s.regs src + s.regs desthexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.MOV src dest)a:v = s.regs srchexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedest:Regval:ℕhf:getI prog pc = some (Instr.MOVI dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a:v = s.regs addra_1:s.mem v = some valhexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a:val = s.regs srca_1:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a:val = s.regs srca_1:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a:v = s.regs addra_1:s.mem v = some valhexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statedest:Regval:ℕhf:getI prog pc = some (Instr.MOVI dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.MOV src dest)a:v = s.regs srchexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.ADD src dest)a:v = s.regs src + s.regs desthexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ ∃ h', ExecFP prog h h' pc s pc_h s_h
exact absurd (hf.symm.trans hfetch) (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)htaken:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}hnot:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond ≠ 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog target s pc_h s_h → ∃ h', ExecFP prog h h' target s pc_h s_hih_not:∀ {s : State} {h h₂ : Heap},
(fun s => s.regs cond = 0 ∧ P s) { regs := s.regs, mem := h } →
s.mem = h.union h₂ →
∀ {pc_h : ℕ} {s_h : State}, Exec prog (pc + 1) s pc_h s_h → ∃ h', ExecFP prog h h' (pc + 1) s pc_h s_hs:Stateh:Heaph₂:Heaphp:P { regs := s.regs, mem := h }hmem:s.mem = h.union h₂pc_h:ℕs_h:Statesrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a:val = s.regs srca_1:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ ¬some (Instr.STORE src addr) = some (Instr.JNZ cond target) All goals completed! 🐙)
3.7.7.2. The soundness theorem
With all the machinery in place, the soundness proof is an induction on
the derivation of the triple. The frame rule case combines the three
lemmas: we obtain the footprint of the execution
(exec_fp_of_triple), turn the large execution into a small
execution with the final heap decomposed (exec_frame_inv_fp),
apply the induction hypothesis to the small execution, and use
HeapOnly to carry R over to the final state, whose registers
may have changed.
/-- Every derivable triple is semantically valid. -/
theorem triple_sound {P Q : Assert} {prog : Code} {pc : ℕ}
(h : {{* P *}} prog @ pc {{* Q *}}) :
ValidTriple P Q prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc
induction h with
P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = none⊢ ValidTriple Q_1 Q_1 prog_1 pc_1
intro s P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 s⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q_1 s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 spc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q_1 s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 spc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q_1 s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ Halted prog_1 pc_h → Q_1 s_h P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_h⊢ Q_1 s_h
P:AssertQ:Assertprog:Codepc:ℕQ_1:Assertprog_1:List Instrpc_1:ℕhfetch:getI prog_1 pc_1 = nones:Statehp:Q_1 spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_hhs_eq:s_h = s⊢ Q_1 s_h
All goals completed! 🐙
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1⊢ ValidTriple P' Q' prog_1 pc_1
intro s P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehp:P' s⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q' s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehp:P' spc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q' s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehp:P' spc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → Q' s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehp:P' spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ Halted prog_1 pc_h → Q' s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertP':AssertQ_1:AssertQ':Assertprog_1:Codepc_1:ℕhPP':P' ⊢ₛ P_1a:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}hQQ':Q_1 ⊢ₛ Q'ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehp:P' spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_h⊢ Q' s_h
All goals completed! 🐙
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1⊢ ValidTriple (P_1 ∗ R) (Q_1 ∗ R) prog_1 pc_1
intro s P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehs:(P_1 ∗ R) s⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → (Q_1 ∗ R) s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehs:(P_1 ∗ R) spc_h:ℕ⊢ ∀ {s_h : State}, Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → (Q_1 ∗ R) s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehs:(P_1 ∗ R) spc_h:ℕs_h:State⊢ Exec prog_1 pc_1 s pc_h s_h → Halted prog_1 pc_h → (Q_1 ∗ R) s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehs:(P_1 ∗ R) spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_h⊢ Halted prog_1 pc_h → (Q_1 ∗ R) s_h P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statehs:(P_1 ∗ R) spc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_h⊢ (Q_1 ∗ R) s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statepc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_hh₁:Heaph₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hP:P_1 { regs := s.regs, mem := h₁ }hR_holds:R { regs := s.regs, mem := h₂ }⊢ (Q_1 ∗ R) s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statepc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_hh₁:Heaph₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hP:P_1 { regs := s.regs, mem := h₁ }hR_holds:R { regs := s.regs, mem := h₂ }h₁':Heaphfp:ExecFP prog_1 h₁ h₁' pc_1 s pc_h s_h⊢ (Q_1 ∗ R) s_h
P:AssertQ:Assertprog:Codepc:ℕP_1:AssertQ_1:AssertR:Assertprog_1:Codepc_1:ℕhR:HeapOnly Rhcore:{{* P_1 *}} prog_1 @ pc_1 {{* Q_1 *}}ih:ValidTriple P_1 Q_1 prog_1 pc_1s:Statepc_h:ℕs_h:Statehexec:Exec prog_1 pc_1 s pc_h s_hhhalted:Halted prog_1 pc_hh₁:Heaph₂:Heaphdisj:h₁.disjoint h₂hmem:s.mem = h₁.union h₂hP:P_1 { regs := s.regs, mem := h₁ }hR_holds:R { regs := s.regs, mem := h₂ }h₁':Heaphfp:ExecFP prog_1 h₁ h₁' pc_1 s pc_h s_hhmem':s_h.mem = h₁'.union h₂hexec_small:Exec prog_1 pc_1 { regs := s.regs, mem := h₁ } pc_h { regs := s_h.regs, mem := h₁' }hdisj':h₁'.disjoint h₂⊢ (Q_1 ∗ R) s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)⊢ ValidTriple (fun s => P (s.updateReg dest val)) Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhpc':pc' = pc + 1hs':s' = s.updateReg dest val⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕhpc':pc' = pc + 1heval:Eval prog pc s pc' (s.updateReg dest val)hexec_rest:Exec prog pc' (s.updateReg dest val) pc_h s_h⊢ Q s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdest:Regval:ℕhfetch:getI prog pc = some (Instr.MOVI dest val)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcheval:Eval prog pc s (pc + 1) (s.updateReg dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)⊢ ValidTriple (fun s => P (s.updateReg dest (s.regs dest + s.regs src))) Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
have hstep : Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) :=
Eval.add (s := s) (v := s.regs dest + s.regs src) hfetch (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ s.regs dest + s.regs src = s.regs src + s.regs dest All goals completed! 🐙)
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hpc':pc' = pc + 1hs':s' = s.updateReg dest (s.regs dest + s.regs src)⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕhstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hpc':pc' = pc + 1heval:Eval prog pc s pc' (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog pc' (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_h⊢ Q s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.ADD src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs dest + s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pchstep:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))heval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs dest + s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs dest + s.regs src)) pc_h s_h⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)⊢ ValidTriple (fun s => P (s.updateReg dest (s.regs src))) Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhpc':pc' = pc + 1hs':s' = s.updateReg dest (s.regs src)⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕhpc':pc' = pc + 1heval:Eval prog pc s pc' (s.updateReg dest (s.regs src))hexec_rest:Exec prog pc' (s.updateReg dest (s.regs src)) pc_h s_h⊢ Q s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regdest:Reghfetch:getI prog pc = some (Instr.MOV src dest)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:P (s.updateReg dest (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcheval:Eval prog pc s (pc + 1) (s.updateReg dest (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateReg dest (s.regs src)) pc_h s_h⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)⊢ ValidTriple (fun s => ∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)) Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ val, s.mem (s.regs addr) = some val ∧ P (s.updateReg dst val)pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hval:ℕhmem_val:s.mem (s.regs addr) = some valhPs':P (s.updateReg dst val)⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hval:ℕhmem_val:s.mem (s.regs addr) = some valhPs':P (s.updateReg dst val)hnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hval:ℕhmem_val:s.mem (s.regs addr) = some valhPs':P (s.updateReg dst val)hnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhpc':pc' = pc + 1hs':s' = s.updateReg dst val⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hval:ℕhmem_val:s.mem (s.regs addr) = some valhPs':P (s.updateReg dst val)hnh:¬Halted prog pcpc':ℕhpc':pc' = pc + 1heval:Eval prog pc s pc' (s.updateReg dst val)hexec_rest:Exec prog pc' (s.updateReg dst val) pc_h s_h⊢ Q s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕdst:Regaddr:Reghfetch:getI prog pc = some (Instr.LOAD dst addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hval:ℕhmem_val:s.mem (s.regs addr) = some valhPs':P (s.updateReg dst val)hnh:¬Halted prog pcheval:Eval prog pc s (pc + 1) (s.updateReg dst val)hexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)⊢ ValidTriple (fun s => ∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))) Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))pc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))pc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statehp:∃ old, s.mem (s.regs addr) = some old ∧ P (s.updateMem (s.regs addr) (s.regs src))pc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hw:ℕhmem_old:s.mem (s.regs addr) = some whPs':P (s.updateMem (s.regs addr) (s.regs src))⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hw:ℕhmem_old:s.mem (s.regs addr) = some whPs':P (s.updateMem (s.regs addr) (s.regs src))hnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hw:ℕhmem_old:s.mem (s.regs addr) = some whPs':P (s.updateMem (s.regs addr) (s.regs src))hnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_hhpc':pc' = pc + 1hs':s' = s.updateMem (s.regs addr) (s.regs src)⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hw:ℕhmem_old:s.mem (s.regs addr) = some whPs':P (s.updateMem (s.regs addr) (s.regs src))hnh:¬Halted prog pcpc':ℕhpc':pc' = pc + 1heval:Eval prog pc s pc' (s.updateMem (s.regs addr) (s.regs src))hexec_rest:Exec prog pc' (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ Q s_h; P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕsrc:Regaddr:Reghfetch:getI prog pc = some (Instr.STORE src addr)a:{{* P *}} prog @ (pc + 1) {{* Q *}}ih:ValidTriple P Q prog (pc + 1)s:Statepc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hw:ℕhmem_old:s.mem (s.regs addr) = some whPs':P (s.updateMem (s.regs addr) (s.regs src))hnh:¬Halted prog pcheval:Eval prog pc s (pc + 1) (s.updateMem (s.regs addr) (s.regs src))hexec_rest:Exec prog (pc + 1) (s.updateMem (s.regs addr) (s.regs src)) pc_h s_h⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)⊢ ValidTriple P Q prog pc
intro s P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P s⊢ ∀ {pc_h : ℕ} {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕ⊢ ∀ {s_h : State}, Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:State⊢ Exec prog pc s pc_h s_h → Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_h⊢ Halted prog pc_h → Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_h⊢ Q s_h
have hnh : ¬Halted prog pc := P:AssertQ:Assertprog:Codepc:ℕh:{{* P *}} prog @ pc {{* Q *}}⊢ ValidTriple P Q prog pc All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕs':Stateheval:Eval prog pc s pc' s'hexec_rest:Exec prog pc' s' pc_h s_h⊢ Q s_h
cases heval with
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcpc':ℕcond_1:Reghcond:s.regs cond_1 ≠ 0hf:getI prog pc = some (Instr.JNZ cond_1 pc')hexec_rest:Exec prog pc' s pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pchcond:s.regs cond ≠ 0hexec_rest:Exec prog target s pc_h s_hhf:getI prog pc = some (Instr.JNZ cond target)⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pccond_1:Regtarget_1:ℕhf:getI prog pc = some (Instr.JNZ cond_1 target_1)hcond:s.regs cond_1 = 0hexec_rest:Exec prog (pc + 1) s pc_h s_h⊢ Q s_h
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pchexec_rest:Exec prog (pc + 1) s pc_h s_hhcond:s.regs cond = 0hf:getI prog pc = some (Instr.JNZ cond target)⊢ Q s_h
All goals completed! 🐙
P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desthexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.MOV src dest)a_2:v = s.regs srchexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcdest:Regval:ℕhf:getI prog pc = some (Instr.MOVI dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcdst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some valhexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ Q s_h P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ Q s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcdst:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.LOAD dst addr)a_2:v = s.regs addra_3:s.mem v = some valhexec_rest:Exec prog (pc + 1) (s.updateReg dst val) pc_h s_h⊢ Q s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcdest:Regval:ℕhf:getI prog pc = some (Instr.MOVI dest val)hexec_rest:Exec prog (pc + 1) (s.updateReg dest val) pc_h s_h⊢ Q s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.MOV src dest)a_2:v = s.regs srchexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ Q s_hP✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regdest:Regv:ℕhf:getI prog pc = some (Instr.ADD src dest)a_2:v = s.regs src + s.regs desthexec_rest:Exec prog (pc + 1) (s.updateReg dest v) pc_h s_h⊢ Q s_h
exact absurd (hf.symm.trans hfetch) (P✝:AssertQ✝:Assertprog✝:Codepc✝:ℕP:AssertQ:Assertprog:List Instrpc:ℕcond:Regtarget:ℕhfetch:getI prog pc = some (Instr.JNZ cond target)a:{{* fun s => s.regs cond ≠ 0 ∧ P s *}} prog @ target {{* Q *}}a_1:{{* fun s => s.regs cond = 0 ∧ P s *}} prog @ (pc + 1) {{* Q *}}ih_taken:ValidTriple (fun s => s.regs cond ≠ 0 ∧ P s) Q prog targetih_not:ValidTriple (fun s => s.regs cond = 0 ∧ P s) Q prog (pc + 1)s:Statehp:P spc_h:ℕs_h:Statehexec:Exec prog pc s pc_h s_hhhalted:Halted prog pc_hhnh:¬Halted prog pcsrc:Regaddr:Regv:ℕval:ℕhf:getI prog pc = some (Instr.STORE src addr)a_2:val = s.regs srca_3:v = s.regs addrhexec_rest:Exec prog (pc + 1) (s.updateMem v val) pc_h s_h⊢ ¬some (Instr.STORE src addr) = some (Instr.JNZ cond target) All goals completed! 🐙)
3.7.8. Examples
The first example is a direct application of the MOVI rule.
example (Q : Assert) (prog : Code) (pc : ℕ)
(hfetch : getI prog pc = some (.MOVI (.r 0) 42))
(hcont : {{* Q *}} prog @ (pc + 1) {{* Q *}}) :
{{* fun s => Q (s.updateReg (.r 0) 42) *}} prog @ pc {{* Q *}} :=
Triple.movi hfetch hcont
3.7.8.1. Incrementing a memory cell
The program incrMem reads the value pointed to by r0, adds one, and
writes the result to the address pointed to by r1:
0: LOAD r2, r0 -- r2 := mem[r0] 1: MOVI r3, 1 -- r3 := 1 2: ADD r3, r2 -- r2 := r2 + r3 3: STORE r2, r1 -- mem[r1] := r2
The precondition requires r0 to point to the value v and the address
in r1 to be allocated; the postcondition states that this address then
contains v + 1. The proof follows the VCG recipe: by the rule of
consequence, it suffices to prove the triple with the precondition
computed by blockWP, which is given by blockWP_sound, and
to show that the user's precondition implies the computed one. This last
obligation is discharged by simplification: unfolding blockWP and
wp, simp computes the precondition and reduces the comparisons
between registers.
def incrMem : Code :=
[ .LOAD (.r 2) (.r 0)
, .MOVI (.r 3) 1
, .ADD (.r 3) (.r 2)
, .STORE (.r 2) (.r 1)
]
theorem incrMem_correct (v : ℕ) :
{{* fun s => s.mem (s.regs (.r 0)) = some v ∧
∃ old, s.mem (s.regs (.r 1)) = some old *}}
incrMem @ 0
{{* fun s => s.mem (s.regs (.r 1)) = some (v + 1) *}} := v:ℕ⊢ {{* fun s => s.mem (s.regs (Reg.r 0)) = some v ∧ ∃ old, s.mem (s.regs (Reg.r 1)) = some old *}} incrMem @ 0 {{* fun s =>
s.mem (s.regs (Reg.r 1)) = some (v + 1) *}}
v:ℕ⊢ (fun s => s.mem (s.regs (Reg.r 0)) = some v ∧ ∃ old, s.mem (s.regs (Reg.r 1)) = some old) ⊢ₛ
blockWP incrMem fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1)v:ℕ⊢ {{* blockWP incrMem fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1) *}} incrMem @ 0 {{* ?m.38 *}}v:ℕ⊢ ?m.38 ⊢ₛ fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1)v:ℕ⊢ Assert
v:ℕ⊢ (fun s => s.mem (s.regs (Reg.r 0)) = some v ∧ ∃ old, s.mem (s.regs (Reg.r 1)) = some old) ⊢ₛ
blockWP incrMem fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1) -- The user's precondition implies blockWP incrMem Q
intro s v:ℕs:Statehmem0:s.mem (s.regs (Reg.r 0)) = some vold:ℕhmem1:s.mem (s.regs (Reg.r 1)) = some old⊢ blockWP incrMem (fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1)) s
v:ℕs:Statehmem0:s.mem (s.regs (Reg.r 0)) = some vold:ℕhmem1:s.mem (s.regs (Reg.r 1)) = some old⊢ ∃ v_1, s.mem (s.regs (Reg.r 0)) = some v_1 ∧ ∃ old, s.mem (s.regs (Reg.r 1)) = some old ∧ some (v_1 + 1) = some (v + 1)
All goals completed! 🐙
v:ℕ⊢ {{* blockWP incrMem fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1) *}} incrMem @ 0 {{* ?m.38 *}} -- Main triple via blockWP_sound
v:ℕ⊢ ∀ (k : ℕ), getI incrMem k = getI incrMem (0 + k)v:ℕ⊢ ∀ (k : ℕ) (cond : Reg) (target : ℕ), getI incrMem k ≠ some (Instr.JNZ cond target)
v:ℕ⊢ ∀ (k : ℕ), getI incrMem k = getI incrMem (0 + k) v:ℕk:ℕ⊢ getI incrMem k = getI incrMem (0 + k); All goals completed! 🐙
v:ℕ⊢ ∀ (k : ℕ) (cond : Reg) (target : ℕ), getI incrMem k ≠ some (Instr.JNZ cond target) intro k v:ℕk:ℕcond:Reg⊢ ∀ (target : ℕ), getI incrMem k ≠ some (Instr.JNZ cond target) v:ℕk:ℕcond:Regtarget:ℕ⊢ getI incrMem k ≠ some (Instr.JNZ cond target)
match k with
v:ℕk:ℕcond:Regtarget:ℕ⊢ getI incrMem 3 ≠ some (Instr.JNZ cond target)v:ℕk:ℕcond:Regtarget:ℕ⊢ getI incrMem 2 ≠ some (Instr.JNZ cond target)v:ℕk:ℕcond:Regtarget:ℕ⊢ getI incrMem 1 ≠ some (Instr.JNZ cond target)v:ℕk:ℕcond:Regtarget:ℕ⊢ getI incrMem 0 ≠ some (Instr.JNZ cond target) All goals completed! 🐙
v:ℕk✝:ℕcond:Regtarget:ℕk:ℕ⊢ getI incrMem (k + 4) ≠ some (Instr.JNZ cond target) All goals completed! 🐙
v:ℕ⊢ (fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1)) ⊢ₛ fun s => s.mem (s.regs (Reg.r 1)) = some (v + 1) intro s v:ℕs:Statehs:s.mem (s.regs (Reg.r 1)) = some (v + 1)⊢ s.mem (s.regs (Reg.r 1)) = some (v + 1); All goals completed! 🐙
Combining this with the soundness theorem, we obtain a statement about
all executions of incrMem, without having reasoned about any
specific execution:
example (v : ℕ) :
ValidTriple
(fun s => s.mem (s.regs (.r 0)) = some v ∧
∃ old, s.mem (s.regs (.r 1)) = some old)
(fun s => s.mem (s.regs (.r 1)) = some (v + 1))
incrMem 0 :=
triple_sound (incrMem_correct v)
3.7.8.2. Using the frame rule
The last example shows the frame rule in action: a LOAD verified over a
fragment of memory remains correct in the presence of any heap-only frame
R.
example (R : Assert) (hR : HeapOnly R) :
{{* (fun s => ∃ val, s.mem (s.regs (.r 0)) = some val) ∗ R *}}
[ .LOAD (.r 1) (.r 0) ] @ 0
{{* (fun s => ∃ val, s.regs (.r 1) = val) ∗ R *}} := R:AsserthR:HeapOnly R⊢ {{* (fun s => ∃ val, s.mem (s.regs (Reg.r 0)) = some val) ∗ R *}} [Instr.LOAD (Reg.r 1) (Reg.r 0)] @ 0 {{*
(fun s => ∃ val, s.regs (Reg.r 1) = val) ∗ R *}}
R:AsserthR:HeapOnly R⊢ {{* fun s => ∃ val, s.mem (s.regs (Reg.r 0)) = some val *}} [Instr.LOAD (Reg.r 1) (Reg.r 0)] @ 0 {{* fun s =>
∃ val, s.regs (Reg.r 1) = val *}}
-- The precondition of Triple.load requires ∃ val, mem[r₀]=val ∧ P(s[r₁:=val]);
-- we use conseq_pre to rewrite it into the weaker precondition of the statement.
R:AsserthR:HeapOnly R⊢ (fun s => ∃ val, s.mem (s.regs (Reg.r 0)) = some val) ⊢ₛ ?PR:AsserthR:HeapOnly R⊢ {{* ?P *}} [Instr.LOAD (Reg.r 1) (Reg.r 0)] @ 0 {{* fun s => ∃ val, s.regs (Reg.r 1) = val *}}R:AsserthR:HeapOnly R⊢ Assert
R:AsserthR:HeapOnly R⊢ {{* ?P *}} [Instr.LOAD (Reg.r 1) (Reg.r 0)] @ 0 {{* fun s => ∃ val, s.regs (Reg.r 1) = val *}}R:AsserthR:HeapOnly R⊢ (fun s => ∃ val, s.mem (s.regs (Reg.r 0)) = some val) ⊢ₛ ?PR:AsserthR:HeapOnly R⊢ Assert
R:AsserthR:HeapOnly R⊢ {{* ?P *}} [Instr.LOAD (Reg.r 1) (Reg.r 0)] @ 0 {{* fun s => ∃ val, s.regs (Reg.r 1) = val *}} All goals completed! 🐙
R:AsserthR:HeapOnly R⊢ (fun s => ∃ val, s.mem (s.regs (Reg.r 0)) = some val) ⊢ₛ fun s =>
∃ val, s.mem (s.regs (Reg.r 0)) = some val ∧ ∃ val_1, (s.updateReg (Reg.r 1) val).regs (Reg.r 1) = val_1 intro s R:AsserthR:HeapOnly Rs:Stateval:ℕhmem:s.mem (s.regs (Reg.r 0)) = some val⊢ ∃ val, s.mem (s.regs (Reg.r 0)) = some val ∧ ∃ val_1, (s.updateReg (Reg.r 1) val).regs (Reg.r 1) = val_1
R:AsserthR:HeapOnly Rs:Stateval:ℕhmem:s.mem (s.regs (Reg.r 0)) = some val⊢ ∃ val, s.mem (s.regs (Reg.r 0)) = some val ∧ ∃ val_1, val = val_1
All goals completed! 🐙
end Ch23
3.7.9. Exercises
1. Compute by hand blockWP [.MOVI (.r 0) 5, .ADD (.r 0) (.r 1)] Q and check the result with simp [blockWP, wp] in Lean.
2. Prove the triple
{{* fun s => s.regs (.r 1) = 0 *}}
[.MOVI (.r 0) 3, .ADD (.r 0) (.r 1)] @ 0
{{* fun s => s.regs (.r 1) = 3 *}}
using blockWP_sound and the rule of consequence.
3. Write a program swap that exchanges the contents of the addresses pointed to by r0 and r1 (using r2 and r3 as temporaries) and prove its correctness with precondition ((a ↦ x) ∗ (b ↦ y)) and postcondition ((a ↦ y) ∗ (b ↦ x)), assuming s.regs (.r 0) = a and s.regs (.r 1) = b.
4. Prove that HeapOnly is closed under separating conjunction: HeapOnly P → HeapOnly Q → HeapOnly (P ∗ Q).
5. Explain why the frame rule would be unsound without the condition HeapOnly R. Give a counterexample with R := fun s => s.regs (.r 0) = 0.
6. The STORE rule requires the address to be already allocated, even though the semantics allows writing to any address. Show that, without this requirement, the frame rule would be unsound.