Theorema76_dec_extra_key
A76: decoding ignores further keys: adding a key absent from the record type leaves the result unchanged.
Statement
theorem a76_dec_extra_key {fs : PFields} {l : String} {j : BVal} {kvs : List Bind}
(hl : l ∉ fs.labels) :
dec (.record fs) (BVal.mkObj ((l, j) :: kvs)) = dec (.record fs) (BVal.mkObj kvs)Proof
by
have hobj : ∀ kvs : List Bind, ∃ o, BVal.mkObj kvs = .obj o := fun kvs => ⟨_, rfl⟩
obtain ⟨o1, h1⟩ := hobj ((l, j) :: kvs)
obtain ⟨o2, h2⟩ := hobj kvs
have e1 := lookup_mkObj ((l, j) :: kvs)
have e2 := lookup_mkObj kvs
rw [h1] at e1 ⊢
rw [h2] at e2 ⊢
simp only at e1 e2
simp only [dec]
rw [decFields_congr fs o1 o2]
intro k hk
have hkl : l ≠ k := fun he => hl (he ▸ hk)
rw [e1, e2]
unfold lookupLast
rw [List.reverse_cons, fmLookup_append']
cases fmLookup kvs.reverse k <;> simp [fmLookup, hkl]Proved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
About ruling A76 of the book, where the implementations disagreed or were silent and the definition decides.
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.