Elm Exactly

TheoremrecvL_next

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

The index of the next unread choice only grows.

Statement

theorem recvL_next {o : Oracle} {n : Nat} : ∀ (c : Val) {x : Input} {k : Nat},
    k ≤ (recvL o n c x k).next
  | .mapE f c, x, k => by
    simp only [recvL]
    have h1

Proof

recvL_next (o := o) (n := n) c (x := x) (k := k)
    rcases hr : recvL o n c x k with ⟨out, l1, k1⟩
    rw [hr] at h1; simp only at h1
    cases out with
    | value v' =>
      simp only
      rcases ha : appVal o n f v' k1 with ⟨out2, l2, k2⟩
      have h2 := appVal_next ha; simp only at h2
      cases out2 <;> simp <;> omega
    | stuck => simpa using h1
    | outOfFuel => simpa using h1
  | .leaf m w, x, k => by
    cases m with
    | task => cases x <;> simp [recvL]
    | out _ => unfold recvL; cases x <;> simp
    | inn p τ =>
      cases x with
      | val _ => unfold recvL; simp
      | port p' j =>
        simp only [recvL]
        split
        · cases dec τ j with
          | none => simp
          | some v' => exact appVal_next rfl
        · simp
  | .unit, _, _ | .sv _, _, _ | .basApp _ _, _, _ | .con _ _, _, _ | .record _, _, _
  | .tuple _ _ _, _, _ | .closure _ _ _ _, _, _ | .batch _, _, _ | .prog _, _, _ | .succeed _, _, _
  | .fail _, _, _ | .andThen _ _, _, _ | .onError _ _, _, _ | .prim _ _, _, _ | .pid _, _, _
  | .bv _, _, _ => by unfold recvL; simp

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

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.