Theoreminsert_increasing
Statement
theorem insert_increasing (l : String) (τ : PTy) : ∀ fs : PFields, l ∉ fs.labels →
fs.labels.Pairwise (· < ·) → (PFields.insert l τ fs).labels.Pairwise (· < ·)
| .nil, _, _ => by simp [PFields.insert, PFields.labels]
| .cons l' τ' rest, hn, h => by
simp only [PFields.labels, List.mem_cons, not_or] at hn
unfold PFields.insert
split
· rename_i hlt
simp only [PFields.labels] at h ⊢
refine List.pairwise_cons.mpr ⟨?_, h⟩
intro a ha
simp only [List.mem_cons] at ha
rcases ha with rfl | ha
· exact hlt
· exact String.lt_trans hlt ((List.pairwise_cons.mp h).1 a ha)
· rename_i hlt
have hgt : l' < lProof
by
apply Classical.byContradiction
intro hc
exact hn.1 (String.le_antisymm (String.not_lt.mp hc) (String.not_lt.mp hlt))
simp only [PFields.labels] at h ⊢
have h' := List.pairwise_cons.mp h
refine List.pairwise_cons.mpr ⟨?_, insert_increasing l τ rest hn.2 h'.2⟩
intro a ha
rcases List.mem_cons.mp ((labels_insert_perm l τ rest).mem_iff.mp ha) with rfl | ha
· exact hgt
· exact h'.1 a haProved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
In StandardElmMech/Eff/Normalise.lean: PTy.normalise (record fields sorted by label) and normalise_canon: canonical when each record's labels are distinct.
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.