Elm Exactly

Theoremstep_outq

StandardElmMech/Prog/Guarantees.lean:85, Outgoing queues · tactic proof

Each step either delivers the head of p's queue on p, or delivers nothing on p and only appends to p's queue.

Statement

theorem step_outq {PE : PortEnv} {r : List (String × Val)} {K K' : Config} {a : Option Event}
    (h : Step PE r K a K') (p : String) :
    (a = some (.out p (K.outq.get p).head!) ∧ K.outq.get p = (K.outq.get p).head! :: K'.outq.get p) ∨
    ((∀ j, a ≠ some (.out p j)) ∧ ∃ new, K'.outq.get p = K.outq.get p ++ new)

Proof

by
  cases h with
  | r_p_update _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ h7 _ =>
    exact .inr ⟨by simp, dispatch_outq h7 p⟩
  | r_p_proc_step _ _ _ _ _ _ _ _ _ _ _ a =>
    exact .inr ⟨by cases a <;> simp, [], by simp⟩
  | r_p_out _ _ _ _ _ Q _ q j J hq =>
    by_cases hqp : q = p
    · subst hqp
      have hg : Q.get q = j :: J := by simp [OutQ.get, hq]
      refine .inl ⟨?_, ?_⟩
      · rw [hg]; rfl
      · rw [hg, OutQ.get_fmPlus_same]; rfl
    · refine .inr ⟨?_, [], ?_⟩
      · intro j' he; simp at he; exact hqp he.1
      · simp [OutQ.get_fmPlus_other _ _ _ _ hqp]
  | r_p_platform _ _ _ hp => cases hp
  | _ => exact .inr ⟨by simp, [], by simp⟩

Proved with tactics, which Lean expands into a proof term that its kernel checks.

Rules of the book it uses

Theorems it uses

Used by

In StandardElmMech/Prog/Guarantees.lean: The guarantees of A86: a86_step (messages handled one at a time, in queue order, every other step keeps the model and only appends messages) and a86_out_fifo (each outgoing port delivers its values in the order they were queued).

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.