Elm Exactly

Theoremdispatch_outs

StandardElmMech/Prog/Invariant.lean:335, Inversions · term proof

Dispatching out leaves of one port p, whose queue is the only one, appends their values.

Statement

theorem dispatch_outs {s : Time} {p : String} : ∀ {L : List Val} {P : Procs} {js : List BVal}
    {H : Pending} {P' : Procs} {Q' : OutQ} {H' : Pending},
    (∀ c ∈ L, ∃ j, leafCore c = some (.out p, .bv j)) →
    Dispatch s P [(p, js)] H L P' Q' H' → P' = P ∧ H' = H ∧ Q' = [(p, js ++ L.filterMap outValue)]
  | [], P, js, H, P', Q', H', _, h => by
    obtain ⟨rfl, rfl, rfl⟩

Proof

dispatch_nil h
    simp
  | c :: L, P, js, H, P', Q', H', hL, h => by
    obtain ⟨j0, hj0⟩ := hL c (by simp)
    cases h with
    | r_p_disp_task _ _ _ _ _ _ _ _ _ _ hc _ _ => rw [hj0] at hc; cases hc
    | r_p_disp_out _ _ _ _ p' j js' _ _ _ _ hc hq hd =>
      rw [hj0] at hc; cases hc
      simp only [fmLookup, beq_self_eq_true, ite_true, Option.some.injEq] at hq
      subst hq
      have hfm : fmPlus [(p, js)] [(p, js ++ [j0])] = [(p, js ++ [j0])] := by simp [fmPlus]
      rw [hfm] at hd
      obtain ⟨h1, h2, h3⟩ := dispatch_outs (fun c' hc' => hL c' (List.mem_cons_of_mem _ hc')) hd
      refine ⟨h1, h2, ?_⟩
      rw [h3]
      simp [outValue, hj0]
    | r_p_disp_plat _ _ _ _ _ _ _ _ _ _ _ hm _ => simp [platMgrs] at hm

Proved by a term, which Lean's kernel checks directly.

Rules of the book it uses

Theorems it uses

In StandardElmMech/Prog/Invariant.lean: CHECK-NOT as a statement about every execution (WorkerTest.HoldsNot), per-test invariants (TestInv, TestInv.sound, holdsNot_any), and the determinism and inversion lemmas they use.

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.