Elm Exactly

Theoremkeys_nodup_mem_eq

StandardElmMech/Eff/RoundTrip.lean:109, Lists and their values · term proof

Statement

theorem keys_nodup_mem_eq {β : Type} : ∀ {l : List (String × β)} {a b : String × β},
    (l.map (·.1)).Nodup → a ∈ l → b ∈ l → a.1 = b.1 → a = b
  | [], _, _, _, ha, _, _ => by simp at ha
  | c :: rest, a, b, hn, ha, hb, he => by
    simp only [List.map_cons, List.nodup_cons] at hn
    simp only [List.mem_cons] at ha hb
    have notin : ∀ x ∈ rest, x.1 ≠ c.1

Proof

fun x hx hx' => hn.1 (hx' ▸ List.mem_map_of_mem hx)
    rcases ha with rfl | ha <;> rcases hb with rfl | hb
    · rfl
    · exact absurd he.symm (notin b hb)
    · exact absurd he (notin a ha)
    · exact keys_nodup_mem_eq hn.2 ha hb he

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

Used by

In StandardElmMech/Eff/RoundTrip.lean: The round trip of encoding and decoding (roundtrip), except where A88 says otherwise (NoExc), under the named hypothesis FloatRoundTrip; the exceptions shown to be needed.

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.