Elm Exactly

Theoremdedup_keys_nodup

StandardElmMech/Eff/MkObj.lean:198, Lookups through `mkObj` · term proof

Statement

theorem dedup_keys_nodup : ∀ (l acc : List Bind), (keysOf acc).Nodup →
    (keysOf (l.foldl (fun acc (k, j) => acc.filter (·.1 != k) ++ [(k, j)]) acc)).Nodup
  | [], _, h => h
  | (k, j) :: l, acc, h => by
    simp only [List.foldl_cons]
    apply dedup_keys_nodup l
    simp only [keysOf, List.map_append, List.map_cons, List.map_nil]
    apply List.nodup_append.mpr
    refine ⟨?_, by simp, ?_⟩
    · exact (h.sublist (List.Sublist.map _ (List.filter_sublist)))
    · intro a ha b hb hab
      simp only [List.mem_singleton] at hb
      subst hb hab
      obtain ⟨x, hx, rfl⟩

Proof

List.mem_map.mp ha
      have := (List.mem_filter.mp hx).2
      simp at this

Proved by a term, which Lean's kernel checks directly.

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.