Elm Exactly

TheoremcopyLoop_least

StandardElmMech/Stat/CopyLoop.lean:251, The invariant · tactic proof

The copies made: the least set of assignments that contains the initial ones and is closed under the requests of the copies it contains (sec:dynamic-core-numbers, A59, A87).

Statement

theorem copyLoop_least {gid : Nat} {tr : Assignment → Except SpecError (Spec (List D.Def))} {fuel : Nat}
    {init : List Assignment} {made : List (Assignment × List D.Def)} {out : List Req}
    (h : copyLoop gid tr fuel init [] [] = .ok (made, out)) :
    (∀ a ∈ init, a ∈ made.map (·.1)) ∧
    (∀ a ∈ made.map (·.1), ∀ s, tr a = .ok s → ∀ r ∈ s.reqs, r.1 = gid → r.2 ∈ made.map (·.1)) ∧
    (∀ M : List Assignment, (∀ a ∈ init, a ∈ M) →
       (∀ a ∈ M, ∀ s, tr a = .ok s → ∀ r ∈ s.reqs, r.1 = gid → r.2 ∈ M) →
       ∀ a ∈ made.map (·.1), a ∈ M)

Proof

by
  obtain ⟨h1, h2, h3⟩ := copyLoop_inv fuel init [] [] made out h
  refine ⟨fun a ha => h1 a (.inl ha), ?_, ?_⟩
  · have hc := h3 (by intro a ha; simp at ha)
    intro a ha s hs r hr hg
    exact hc a ha r.2 ⟨s, hs, r, hr, hg, rfl⟩
  · intro M hM hC
    apply h2 M
    · rintro a (ha | ha)
      · exact hM a ha
      · simp at ha
    · rintro a ha b ⟨s, hs, r, hr, hg, rfl⟩
      exact hC a ha s hs r hr hg

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

Theorems it uses

About rulings A59, A87 of the book, where the implementations disagreed or were silent and the definition decides.

In StandardElmMech/Stat/CopyLoop.lean: The copy loop terminates within 2^k + 1 rounds, makes the least set of copies closed under requests, at most 2^k (copyLoop_fuel, copyLoop_least, copies_le_pow).

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.