Theorema86_out_fifo
The values of each outgoing port are delivered in the order in which they joined its queue: over any execution, what is delivered on p, followed by what remains queued, is what was queued at the start followed by what each step appended, in step order.
Statement
theorem a86_out_fifo {PE : PortEnv} {r : List (String × Val)} {hst : Host} {K : Config}
{hs : List BVal} {π : Path} {hs' : List BVal} (h : Exec PE r hst K hs π hs') (p : String) :
outsOn p π ++ (Path.last K π).outq.get p = K.outq.get p ++ appendedOn p K πProof
by
induction h with
| nil K hs => simp [outsOn, Path.last, appendedOn]
| cons K hs a K' hs' π hs'' hst' _ _ ih =>
have hl : Path.last K ((a, K') :: π) = Path.last K' π := rfl
rw [hl]
rcases step_outq hst' p with ⟨ha, hq⟩ | ⟨hna, new, hn⟩
· generalize (K.outq.get p).head! = hd at ha hq
subst ha
have ho : outsOn p ((some (.out p hd), K') :: π) = hd :: outsOn p π := by simp [outsOn]
have hap : appendedOn p K ((some (.out p hd), K') :: π) = appendedOn p K' π := by
simp [appendedOn]
rw [ho, hap, List.cons_append, ih, hq]; rfl
· have hd : (K'.outq.get p).drop (K.outq.get p).length = new := by rw [hn]; simp
have ⟨ho, hap⟩ : outsOn p ((a, K') :: π) = outsOn p π ∧
appendedOn p K ((a, K') :: π) = new ++ appendedOn p K' π := by
rcases a with _ | ⟨q, j⟩ | ⟨q, j⟩ | x | d
· simp [outsOn, appendedOn, hd]
· simp [outsOn, appendedOn, hd]
· by_cases hqp : q = p
· subst hqp; exact absurd rfl (hna j)
· simp [outsOn, appendedOn, hqp, hd]
· simp [outsOn, appendedOn, hd]
· simp [outsOn, appendedOn, hd]
rw [ho, hap, ih, hn, List.append_assoc]Proved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
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.