TheoremmapM_bytes_inv
Statement
theorem mapM_bytes_inv : ∀ {ls : List Val} {os : List Nat}, ls.mapM byteOf? = some os →
ls = os.map (fun (o : Nat) => Val.int (o : Int)) ∧ ∀ o ∈ os, o < 256
| [], os, h => by simp at h; subst h; simp
| l :: ls, os, h => by
simp only [List.mapM_cons] at h
cases hb : byteOf? l with
| none => simp [hb] at h
| some o =>
cases hr : ls.mapM byteOf? with
| none => simp [hb, hr] at h
| some os' =>
simp only [hb, hr, bind, Option.bind, pure, Option.some.injEq] at h
subst h
obtain ⟨rfl, hall⟩Proof
mapM_bytes_inv hr
unfold byteOf? at hb
split at hb
· rename_i n
split at hb
· rename_i hrange
cases hb
have hn : ((n.toNat : Nat) : Int) = n := Int.toNat_of_nonneg hrange.1
refine ⟨?_, ?_⟩
· simp only [List.map_cons, hn]
· intro o' hm
simp only [List.mem_cons] at hm
rcases hm with rfl | hm
· omega
· exact hall o' hm
· cases hb
· cases hbProved 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.