TheoreminsertByKey_sorted
Statement
theorem insertByKey_sorted (b : Bind) : ∀ l : List Bind, l.Pairwise KeyLe →
(insertByKey b l).Pairwise KeyLe
| [], _ => by simp [insertByKey]
| c :: rest, h => by
unfold insertByKey
rw [List.pairwise_cons] at h
split
· rename_i hbc
have hbc : b.1 ≤ c.1Proof
of_decide_eq_true hbc
refine List.pairwise_cons.mpr ⟨?_, List.pairwise_cons.mpr h⟩
intro x hx
simp only [List.mem_cons] at hx
rcases hx with rfl | hx
· exact hbc
· exact String.le_trans hbc (h.1 x hx)
· rename_i hbc
have hcb : c.1 ≤ b.1 := by
rcases String.le_total b.1 c.1 with h' | h'
· exact absurd (decide_eq_true h') hbc
· exact h'
refine List.pairwise_cons.mpr ⟨?_, insertByKey_sorted b rest h.2⟩
intro x hx
rcases List.mem_cons.mp ((insertByKey_perm b rest).mem_iff.mp hx) with rfl | hx
· exact hcb
· exact h.1 x hxProved by a term, which Lean's kernel checks directly.
Theorems it uses
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.