Elm Exactly

Theorema81_lower

StandardElmMech/Prog/Rulings.lean:231, A81: sleep · tactic proof

A81: the sleep action is no sooner than max(0, d) after the process reached the sleep.

Statement

theorem a81_lower {PE : PortEnv} {r : List (String × Val)} {K K' : Config} {x : Float} {t : Val}
    {q : Rat} (h : Step PE r K (some (.act ⟨.sleep, [.sv (.float x)], t⟩)) K')
    (hq : floatToRat? x = some q) :
    ∃ n tk s' o, K.procs.get n = some (.live ⟨tk, s', o⟩) ∧ s' + (if q < 0 then 0 else q) ≤ K.time

Proof

by
  generalize hl : some (Event.act ⟨.sleep, [.sv (.float x)], t⟩) = lbl at h
  cases h with
  | r_p_proc_step _ _ _ _ _ _ _ _ _ _ _ a _ _ _ h3 =>
    cases a with
    | none => simp at hl
    | some y => exact absurd (h3 y rfl) (by simp [platPrims])
  | r_p_proc_sleep s _ _ _ _ _ _ n tk s' o _ v' _ hp _ hs =>
    simp only [Option.some.injEq, Event.act.injEq, Action.mk.injEq, List.cons.injEq] at hl
    obtain ⟨-, ⟨rfl, -⟩, -⟩ := hl
    exact ⟨n, tk, s', o, hp, hs x q rfl hq⟩
  | r_p_platform _ _ _ hp => cases hp
  | _ => simp at hl

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

Rules of the book it uses

About ruling A81 of the book, where the implementations disagreed or were silent and the definition decides.

In StandardElmMech/Prog/Rulings.lean: The rulings A62, A72, A77, A79, A80 and A81 as theorems, and a66_batch_order_open: a program whose batch is delivered in either order.

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.