Elm Exactly

TheoremfmLookup_perm

StandardElmMech/Eff/Properties.lean:63, A76 · tactic proof

Statement

theorem fmLookup_perm {β : Type} : ∀ {r r' : List (String × β)}, r.Perm r' → (r.map (·.1)).Nodup →
    ∀ l, fmLookup r l = fmLookup r' l

Proof

by
  intro r r' hp hnd l
  induction hp with
  | nil => rfl
  | cons x _ ih =>
    obtain ⟨k, v⟩ := x
    simp only [List.map_cons, List.nodup_cons] at hnd
    simp only [fmLookup]
    split
    · rfl
    · exact ih hnd.2
  | swap x y r =>
    obtain ⟨k1, v1⟩ := x; obtain ⟨k2, v2⟩ := y
    simp only [List.map_cons, List.nodup_cons, List.mem_cons, not_or] at hnd
    simp only [fmLookup]
    by_cases h1 : k1 = l <;> by_cases h2 : k2 = l
    · exact absurd (h2.trans h1.symm) hnd.1.1
    · simp [h1, h2]
    · simp [h1, h2]
    · simp [h1, h2]
  | trans h1 _ ih1 ih2 => rw [ih1 hnd, ih2 (by rwa [← (h1.map _).nodup_iff])]

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

In StandardElmMech/Eff/Properties.lean: APPLY of the effect values has one member; the rulings A74, A76, A88 and A92; canonical payload types, the decimality of a float's exact value, and that every value of a payload type has a canonical encoding (enc_total).

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.