Elm Exactly

Theoremperm_filter_name

StandardElmMech/Src/AliasOrderProof.lean:46 · tactic proof

A name-distinct list: removing an alias by name removes exactly it.

Statement

theorem perm_filter_name : ∀ {l : List AliasD} {a : AliasD}, (l.map (·.1)).Nodup → a ∈ l →
    l.Perm (a :: l.filter (·.1 != a.1))
  | [], _, _, h => by simp at h
  | b :: l, a, hn, h => by
    simp only [List.map_cons, List.nodup_cons] at hn
    rcases List.mem_cons.mp h with rfl | h
    · have hf : l.filter (·.1 != a.1) = l

Proof

by
        apply List.filter_eq_self.mpr
        intro x hx
        have : x.1 ≠ a.1 := fun he => hn.1 (he ▸ List.mem_map_of_mem hx)
        simpa using this
      simp [hf]
    · have hne : b.1 ≠ a.1 := fun he => hn.1 (he ▸ List.mem_map_of_mem h)
      have hb : (b.1 != a.1) = true := by simpa using hne
      simp only [List.filter_cons, hb, ite_true]
      exact ((perm_filter_name hn.2 h).cons b).trans (List.Perm.swap a b _)

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

Used by

In StandardElmMech/Src/AliasOrderProof.lean: aliasOrder_valid: the canonical order of aliases is one the book allows.

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.