Elm Exactly

TheoremrecvL_sound

StandardElmMech/Eff/Messages.lean:87 · term proof

Statement

theorem recvL_sound {o : Oracle} {n : Nat} : ∀ (c : Val) {x : Input} {k : Nat} {v : Val} {l : Log}
    {k' : Nat}, recvL o n c x k = ⟨.value v, l, k'⟩ → RecvL c x v l
  | .mapE f c, x, k, v, l, k', h => by
    simp only [recvL] at h
    rcases hr : recvL o n c x k with ⟨out, l1, k1⟩
    rw [hr] at h
    cases out with
    | value v' =>
      simp only at h
      rcases ha : appVal o n f v' k1 with ⟨out2, l2, k2⟩
      rw [ha] at h
      cases out2 <;> simp at h
      obtain ⟨rfl, rfl, rfl⟩

Proof

h
      exact .r_e_msg_map_l _ _ _ _ _ _ _ (recvL_sound c hr) (appVal_sound_l ha)
    | stuck => simp at h
    | outOfFuel => simp at h
  | .leaf m w, x, k, v, l, k', h => by
    cases m with
    | task =>
      cases x with
      | val v0 => simp [recvL] at h; obtain ⟨rfl, rfl, -⟩ := h; exact .r_e_msg_task_l _ _
      | port _ _ => unfold recvL at h; simp at h
    | out _ => unfold recvL at h; cases x <;> simp at h
    | inn p τ =>
      cases x with
      | val _ => unfold recvL at h; simp at h
      | port p' j =>
        simp only [recvL] at h
        split at h
        · rename_i hp; subst hp
          cases hd : dec τ j with
          | none => simp [hd] at h
          | some v' =>
            simp only [hd] at h
            exact .r_e_msg_port_l _ _ _ _ _ _ _ ((dec_iff τ j v').mpr hd) (appVal_sound_l h)
        · cases h
  | .unit, _, _, _, _, _, h | .sv _, _, _, _, _, _, h | .basApp _ _, _, _, _, _, _, h
  | .con _ _, _, _, _, _, _, h | .record _, _, _, _, _, _, h | .tuple _ _ _, _, _, _, _, _, h
  | .closure _ _ _ _, _, _, _, _, _, h | .batch _, _, _, _, _, _, h | .prog _, _, _, _, _, _, h
  | .succeed _, _, _, _, _, _, h | .fail _, _, _, _, _, _, h | .andThen _ _, _, _, _, _, _, h
  | .onError _ _, _, _, _, _, _, h | .prim _ _, _, _, _, _, _, h | .pid _, _, _, _, _, _, h
  | .bv _, _, _, _, _, _, h => by unfold recvL at h; simp at h

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

Rules of the book it uses

Theorems it uses

Used by

In StandardElmMech/Eff/Messages.lean: Messages (Recv, 3 rules, r_e_msg_*) and its logged twin, and the executable recvL, sound, complete and unique.

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.