TheoremofList_of_toList?
Statement
theorem ofList_of_toList? : ∀ {v : Val} {vs : List Val}, v.toList? = some vs → v = Val.ofList vs
| .con c [], vs, h => by
simp only [Val.toList?] at h
split at h
· subst_vars; cases h; rfl
· cases h
| .con c [hd, tl], vs, h => by
simp only [Val.toList?] at h
split at h
· subst_vars
cases ht : tl.toList? with
| none => simp [ht] at h
| some ts =>
simp only [ht, Option.map_some, Option.some.injEq] at h
subst h
simp [Val.ofList, ofList_of_toList? ht]
· cases h
| .unit, _, h | .sv _, _, h | .basApp _ _, _, h | .record _, _, h | .tuple _ _ _, _, h
| .closure _ _ _ _, _, h | .batch _, _, h | .mapE _ _, _, h | .prog _, _, h | .succeed _, _, h
| .fail _, _, h | .andThen _ _, _, h | .onError _ _, _, h | .prim _ _, _, h | .pid _, _, h
| .leaf _ _, _, h | .bv _, _, h => by simp [Val.toList?] at h
| .con _ (_ :: _ :: _ :: _), _, h | .con _ [_], _, h => by simp [Val.toList?] at hProof
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.