TheoremtaskRed_of_focus
A reduction of the redex, plugged back into the frames, is a reduction of the task.
Statement
theorem taskRed_of_focus : ∀ (tk : Val) (fs : List Frame) (r r' : Val) (a : Option Action),
focus tk = some (fs, r) → RedexRed r a r' → TaskRed tk a (plug fs r')
| .andThen f t, fs, r, r', a, hf, hr => by
simp only [focus] at hf
split at hf
· simp only [Option.some.injEq, Prod.mk.injEq] at hf
obtain ⟨rfl, rfl⟩Proof
hf
cases hr with
| andThenSucceed _ _ _ h => exact .r_e_task_andthen_succeed _ _ _ h
| andThenFail _ _ => exact .r_e_task_andthen_fail _ _
· cases hft : focus t with
| none => simp [hft] at hf
| some p =>
obtain ⟨fs', r0⟩ := p
simp only [hft, Option.map_some, Option.some.injEq, Prod.mk.injEq] at hf
obtain ⟨rfl, rfl⟩ := hf
exact .r_e_task_andthen_inner _ _ _ _ (taskRed_of_focus t fs' r0 r' a hft hr)
| .onError f t, fs, r, r', a, hf, hr => by
simp only [focus] at hf
split at hf
· simp only [Option.some.injEq, Prod.mk.injEq] at hf
obtain ⟨rfl, rfl⟩ := hf
cases hr with
| onErrorFail _ _ _ h => exact .r_e_task_onerror_fail _ _ _ h
| onErrorSucceed _ _ => exact .r_e_task_onerror_succeed _ _
· cases hft : focus t with
| none => simp [hft] at hf
| some p =>
obtain ⟨fs', r0⟩ := p
simp only [hft, Option.map_some, Option.some.injEq, Prod.mk.injEq] at hf
obtain ⟨rfl, rfl⟩ := hf
exact .r_e_task_onerror_inner _ _ _ _ (taskRed_of_focus t fs' r0 r' a hft hr)
| .prim π vs, fs, r, r', a, hf, hr => by
simp only [focus, Option.some.injEq, Prod.mk.injEq] at hf
obtain ⟨rfl, rfl⟩ := hf
cases hr with
| prim _ _ _ h => exact .r_e_task_prim _ _ _ h
| .unit, _, _, _, _, hf, _ | .sv _, _, _, _, _, hf, _ | .basApp _ _, _, _, _, _, hf, _
| .con _ _, _, _, _, _, hf, _ | .record _, _, _, _, _, hf, _ | .tuple _ _ _, _, _, _, _, hf, _
| .closure _ _ _ _, _, _, _, _, hf, _ | .batch _, _, _, _, _, hf, _ | .mapE _ _, _, _, _, _, hf, _
| .prog _, _, _, _, _, hf, _ | .succeed _, _, _, _, _, hf, _ | .fail _, _, _, _, _, hf, _
| .pid _, _, _, _, _, hf, _ | .leaf _ _, _, _, _, _, hf, _ | .bv _, _, _, _, _, hf, _ => by
simp [focus] at hfProved by a term, which Lean's kernel checks directly.
Rules of the book 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.