Theoremex_perform
Task.perform identity (Task.succeed 1) evaluates to a task leaf command.
Statement
theorem ex_perform :
∃ w, EvalExp E_ex (ap (qv "Task" "perform") [v "identity", ap (qv "Task" "succeed") [i 1]]) w ∧
∃ t, w = .leaf .task tProof
by
have h : (exValue (ap (qv "Task" "perform") [v "identity", ap (qv "Task" "succeed") [i 1]])).map isTaskLeaf
= some true := by decide +kernel
cases hv : exValue (ap (qv "Task" "perform") [v "identity", ap (qv "Task" "succeed") [i 1]]) with
| none => simp [hv] at h
| some w =>
simp only [hv, Option.map_some, Option.some.injEq] at h
refine ⟨w, exValue_sound hv, ?_⟩
cases w <;> simp [isTaskLeaf] at h
rename_i m t; cases m <;> simp at h
exact ⟨t, rfl⟩Proved by decide +kernel: Lean's kernel itself runs the decision procedure, here the evaluator, and checks that the answer is true, so nothing outside the kernel is trusted.
Theorems it uses
In StandardElmMech/Eff/Examples.lean: Task.perform, Task.sequence of six tasks reduced to its outcome, Task.attempt of a failing task, and the flattening of Cmd.batch [Cmd.none, Cmd.none], by the kernel.
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.