Elm Exactly

TheoremstepTaskL_unique

StandardElmMech/Eff/Task.lean:436, The executable step · tactic proof

When the evaluator reads no choice and the reduction spawns nothing, its step is the only one (a spawn's outcome is any identifier, which the rule leaves free).

Statement

theorem stepTaskL_unique {o : Oracle} {n fr k : Nat} {tk t : Val} {a : Option Action} {l : Log}
    (h : stepTaskL o n fr tk k = ⟨.value (a, t), l, k⟩) (hs : ∀ x, a = some x → x.prim ≠ .spawn) :
    ∀ a' t' l', TaskRedL tk a' t' l' → a' = a ∧ t' = t ∧ l' = l

Proof

by
  intro a' t' l' d
  induction d generalizing a t l with
  | r_e_task_andthen_succeed_l f v w l0 hw =>
    simp only [stepTaskL] at h
    rcases hr : appVal o n f v k with ⟨out, l1, k1⟩
    rw [hr] at h
    cases out <;> simp [Res.mapOut] at h
    obtain ⟨⟨rfl, rfl⟩, rfl, rfl⟩ := h
    obtain ⟨rfl, rfl⟩ := appVal_unique_l hr _ _ hw
    exact ⟨rfl, rfl, rfl⟩
  | r_e_task_andthen_fail_l f v =>
    simp [stepTaskL] at h; obtain ⟨⟨rfl, rfl⟩, rfl⟩ := h; exact ⟨rfl, rfl, rfl⟩
  | r_e_task_onerror_fail_l f v w l0 hw =>
    simp only [stepTaskL] at h
    rcases hr : appVal o n f v k with ⟨out, l1, k1⟩
    rw [hr] at h
    cases out <;> simp [Res.mapOut] at h
    obtain ⟨⟨rfl, rfl⟩, rfl, rfl⟩ := h
    obtain ⟨rfl, rfl⟩ := appVal_unique_l hr _ _ hw
    exact ⟨rfl, rfl, rfl⟩
  | r_e_task_onerror_succeed_l f v =>
    simp [stepTaskL] at h; obtain ⟨⟨rfl, rfl⟩, rfl⟩ := h; exact ⟨rfl, rfl, rfl⟩
  | r_e_task_andthen_inner_l f t0 t0' a0 l0 d ih =>
    rw [stepTaskL_andThen_inner d.not_outcome] at h
    rcases hr : stepTaskL o n fr t0 k with ⟨out, l1, k1⟩
    rw [hr] at h
    rcases out with ⟨a1, t1⟩ | _ | _ <;> simp [Res.mapOut] at h
    obtain ⟨⟨rfl, rfl⟩, rfl, rfl⟩ := h
    obtain ⟨rfl, rfl, rfl⟩ := ih hr hs
    exact ⟨rfl, rfl, rfl⟩
  | r_e_task_onerror_inner_l f t0 t0' a0 l0 d ih =>
    rw [stepTaskL_onError_inner d.not_outcome] at h
    rcases hr : stepTaskL o n fr t0 k with ⟨out, l1, k1⟩
    rw [hr] at h
    rcases out with ⟨a1, t1⟩ | _ | _ <;> simp [Res.mapOut] at h
    obtain ⟨⟨rfl, rfl⟩, rfl, rfl⟩ := h
    obtain ⟨rfl, rfl, rfl⟩ := ih hr hs
    exact ⟨rfl, rfl, rfl⟩
  | r_e_task_prim_l π vs w hout =>
    cases hout with
    | sleep v => simp [stepTaskL] at h; obtain ⟨⟨rfl, rfl⟩, rfl⟩ := h; exact ⟨rfl, rfl, rfl⟩
    | spawn t0 m =>
      simp [stepTaskL] at h; obtain ⟨⟨rfl, rfl⟩, rfl⟩ := h
      exact absurd rfl (hs _ rfl)
    | kill p => simp [stepTaskL] at h; obtain ⟨⟨rfl, rfl⟩, rfl⟩ := h; exact ⟨rfl, rfl, rfl⟩

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

Rules of the book it uses

Theorems it uses

Used by

In StandardElmMech/Eff/Task.lean: Task reduction (TaskRed, 7 rules, r_e_task_*) and its logged twin, focus and plug, the property of task reduction (taskRed_iff, taskRed_outcome, taskRed_kind, taskRed_silent_same, taskRed_none), and the executable step stepTaskL, 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.