Elm Exactly

TheoremdecSeq_of_mapM

StandardElmMech/Eff/EncDec.lean:540, The relations are the functions · term proof

Statement

theorem decSeq_of_mapM {τ : PTy} (ih : ∀ j v, dec τ j = some v → Dec τ j v) :
    ∀ (js : BArr) (vs : List Val), js.toList.mapM (dec τ) = some vs → DecSeq τ js vs
  | .nil, vs, h => by simp [BArr.toList] at h; subst h; exact .seq_nil τ
  | .cons j js, vs, h => by
    simp only [BArr.toList, List.mapM_cons] at h
    cases hj : dec τ j with
    | none => simp [hj] at h
    | some v =>
      cases hjs : js.toList.mapM (dec τ) with
      | none => simp [hj, hjs] at h
      | some vs' =>
        simp [hj, hjs] at h; subst h
        exact .seq_cons τ j js v vs' (ih j v hj) (decSeq_of_mapM ih js vs' hjs)

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.