Elm Exactly

TheoremtaskRed_iff

StandardElmMech/Eff/Task.lean:182, The redex of a task · tactic proof

A reduction is a reduction of the redex, plugged back into the frames.

Statement

theorem taskRed_iff {tk : Val} {a : Option Action} {tk' : Val} :
    TaskRed tk a tk' ↔ ∃ fs r r', focus tk = some (fs, r) ∧ RedexRed r a r' ∧ tk' = plug fs r'

Proof

by
  constructor
  · intro d
    induction d with
    | r_e_task_andthen_succeed f v t h =>
      exact ⟨[], _, _, by simp [focus, Val.isOutcome], .andThenSucceed f v t h, rfl⟩
    | r_e_task_andthen_fail f v => exact ⟨[], _, _, by simp [focus, Val.isOutcome], .andThenFail f v, rfl⟩
    | r_e_task_onerror_fail f v t h =>
      exact ⟨[], _, _, by simp [focus, Val.isOutcome], .onErrorFail f v t h, rfl⟩
    | r_e_task_onerror_succeed f v =>
      exact ⟨[], _, _, by simp [focus, Val.isOutcome], .onErrorSucceed f v, rfl⟩
    | r_e_task_andthen_inner f t t' a d ih =>
      obtain ⟨fs, r, r', hf, hr, rfl⟩ := ih
      have ho : t.isOutcome = false := by
        cases ht : t.isOutcome
        · rfl
        · exact absurd d (taskRed_outcome ht)
      exact ⟨.andThen f :: fs, r, r', by simp [focus, ho, hf], hr, rfl⟩
    | r_e_task_onerror_inner f t t' a d ih =>
      obtain ⟨fs, r, r', hf, hr, rfl⟩ := ih
      have ho : t.isOutcome = false := by
        cases ht : t.isOutcome
        · rfl
        · exact absurd d (taskRed_outcome ht)
      exact ⟨.onError f :: fs, r, r', by simp [focus, ho, hf], hr, rfl⟩
    | r_e_task_prim π vs t h => exact ⟨[], _, _, by simp [focus], .prim π vs t h, rfl⟩
  · rintro ⟨fs, r, r', hf, hr, rfl⟩
    exact taskRed_of_focus tk fs r r' a hf hr

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.