TheoremencSeq_of_mapM
Statement
theorem encSeq_of_mapM {τ : PTy} (ih : ∀ v j, enc τ v = some j → Enc τ v j) :
∀ (vs : List Val) (js : List BVal), vs.mapM (enc τ) = some js → EncSeq τ vs (BArr.ofList js)
| [], js, h => by simp at h; subst h; exact .seq_nil τ
| v :: vs, js, h => by
simp only [List.mapM_cons] at h
cases hv : enc τ v with
| none => simp [hv] at h
| some j =>
cases hvs : vs.mapM (enc τ) with
| none => simp [hv, hvs] at h
| some js' =>
simp [hv, hvs] at h; subst h
exact .seq_cons τ v vs j _ (ih v j hv) (encSeq_of_mapM ih vs js' hvs)Proof
Proved by a term, which Lean's kernel checks directly.
In StandardElmMech/Eff/EncDec.lean: The book's relations Enc and Dec (15 and 14 rules, r_e_enc_*, r_e_dec_*), enc_iff, dec_iff, and that both are partial functions.
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.