Elm Exactly

Theoremdedup_foldl_nodup

StandardElmMech/Eff/MkObj.lean:92, Keeping the last binding of each key · tactic proof

Statement

theorem dedup_foldl_nodup : ∀ (l acc : List Bind), (keysOf (acc ++ l)).Nodup →
    l.foldl (fun acc (k, j) => acc.filter (·.1 != k) ++ [(k, j)]) acc = acc ++ l
  | [], acc, _ => by simp
  | (k, j) :: l, acc, h => by
    simp only [List.foldl_cons]
    have hk : k ∉ keysOf acc

Proof

by
      intro hm
      simp only [keysOf, List.map_append, List.map_cons] at h hm
      exact (List.nodup_append.mp h).2.2 k hm k (List.mem_cons_self) rfl
    rw [dedup_step_nodup acc k j hk, dedup_foldl_nodup l (acc ++ [(k, j)]) (by simpa using h)]
    simp

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

Theorems it uses

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.