Elm Exactly

TheoremfmLookup_append_single

StandardElmMech/Eff/MkObj.lean:156, Lookups through `mkObj` · tactic proof

Statement

theorem fmLookup_append_single (acc : List Bind) (k k' : String) (j : BVal) :
    fmLookup (acc.filter (·.1 != k') ++ [(k', j)]) k = if k' = k then some j else fmLookup acc k

Proof

by
  induction acc with
  | nil => by_cases h : k' = k <;> simp [fmLookup, h]
  | cons x rest ih =>
    obtain ⟨a, v⟩ := x
    by_cases ha : a = k'
    · subst ha; simp only [List.filter_cons, bne_self_eq_false, Bool.false_eq_true, ite_false]
      rw [ih]
      by_cases h : a = k <;> simp [fmLookup, h]
    · have : (a != k') = true := by simpa using ha
      simp only [List.filter_cons, this, ite_true, List.cons_append, fmLookup]
      rw [ih]
      by_cases h1 : a = k
      · subst h1; simp [Ne.symm ha]
      · have : (a == k) = false := by simpa using h1
        simp [this]

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

Used by

In StandardElmMech/Eff/MkObj.lean: A76: mkObj ignores the order of distinct keys (a76_mkObj_perm), a lookup finds the last binding (lookup_mkObj), and decoding ignores keys outside the record type (a76_dec_extra_key).

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.