Elm Exactly

Theorema62_aux

StandardElmMech/Prog/Rulings.lean:20, A62: an update with no result ends message handling; other steps go on · tactic proof

The invariant of an execution in which the head message has no update: the model is K's and the queue of messages is B (K's queue, whose head is that message) followed by others.

Statement

theorem a62_aux {PE : PortEnv} {r : List (String × Val)} {hst : Host} {m fu v1 : Val}
    {B : List Val} (hB : ∃ M, B = v1 :: M) (hfu : field r "update" = some fu)
    (hno : ¬ ∃ v2 w, AppVal fu v1 v2 ∧ AppVal v2 m w) :
    ∀ {K hs π hs'}, Exec PE r hst K hs π hs' → K.model = m → (∃ ms, K.msgs = B ++ ms) →
      ∀ K' ∈ π.map (·.2), K'.model = m ∧ ∃ ms, K'.msgs = B ++ ms

Proof

by
  intro K hs π hs' h
  induction h with
  | nil => intro _ _ K' hK'; simp at hK'
  | cons K hs a K1 hs1 π hs'' hst1 _ _ ih =>
    intro hm hq
    have h1 : K1.model = m ∧ ∃ ms, K1.msgs = B ++ ms := by
      rcases a86_step hst1 with ⟨hm1, ms1, hq1⟩ | ⟨_, v1', fu', v2, cm, cs, L, hq1, hf, ha1, ha2, -⟩
      · obtain ⟨ms, hms⟩ := hq
        exact ⟨hm1.trans hm, ms ++ ms1, by rw [hq1, hms, List.append_assoc]⟩
      · exfalso
        obtain ⟨ms, hms⟩ := hq
        obtain ⟨M, rfl⟩ := hB
        rw [hms] at hq1
        simp only [List.cons_append, List.cons.injEq] at hq1
        obtain ⟨h11, -⟩ := hq1
        subst h11
        have hff : fu' = fu := by rw [hf] at hfu; exact Option.some.inj hfu
        subst hff
        rw [hm] at ha2
        exact hno ⟨v2, _, ha1, ha2⟩
    intro K' hK'
    simp only [List.map_cons, List.mem_cons] at hK'
    rcases hK' with rfl | hK'
    · exact h1
    · exact ih h1.1 h1.2 K' hK'

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

Theorems it uses

Used by

In StandardElmMech/Prog/Rulings.lean: The rulings A62, A72, A77, A79, A80 and A81 as theorems, and a66_batch_order_open: a program whose batch is delivered in either order.

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.