Documentation

Cedar.Thm.Data.Control

This file contains simp lemmas for proofs about code that uses the do notation together with Except and Option.

@[simp]
theorem Except.bind_ok_T {α ε β : Type u_1} (a : α) (f : αExceptT ε Id β) :
ok a >>= f = f a
@[simp]
theorem Except.bind_ok {α : Type u_1} {ε : Type u_2} {β : Type u_1} (a : α) (f : αExcept ε β) :
ok a >>= f = f a
@[simp]
theorem Except.bind_err {ε : Type u_1} {α β : Type u_2} (e : ε) (f : αExcept ε β) :
@[simp]
theorem Option.bind_some_T {α β : Type u_1} (a : α) (f : αOptionT Id β) :
some a >>= f = f a
@[simp]
theorem Option.bind_some_fun {α β : Type u_1} (a : α) (f : αOption β) :
some a >>= f = f a
@[simp]
theorem Option.bind_none_fun {α β : Type u_1} (f : αOption β) :
theorem do_some {α β : Type u_1} {b : β} {opt : Option α} {f : αβ} :
(do let vopt some (f v)) = some b (a : α), opt = some a f a = b
theorem do_error {ε : Type u_1} {α β : Type u_2} {res : Except ε α} {e : ε} {f : αβ} :
(do let vres Except.ok (f v)) = Except.error e res = Except.error e
theorem do_ok_eq_ok {ε : Type u_1} {α β : Type u_2} {b : β} {res : Except ε α} {f : αβ} :
(do let vres Except.ok (f v)) = Except.ok b (a : α), res = Except.ok a f a = b
theorem do_eq_ok {ε : Type u_1} {α β : Type u_2} {b : β} {res : Except ε α} {f : αExcept ε β} :
(do let vres f v) = Except.ok b (a : α), res = Except.ok a f a = Except.ok b
theorem do_eq_ok₂ {ε : Type u_1} {res₁ res₂ : Except ε PUnit} :
(do res₁ res₂) = Except.ok ()res₁ = Except.ok () res₂ = Except.ok ()
theorem to_option_some {α : Type u_1} {ε : Type u_2} {v : α} {res : Except ε α} :
theorem to_option_none {ε : Type u_1} {α : Type u_2} {res : Except ε α} :
res.toOption = none (err : ε), res = Except.error err
theorem to_option_left_ok {α : Type u_1} {ε₁ : Type u_2} {ε₂ : Type u_3} {v : α} {res₁ : Except ε₁ α} {res₂ : Except ε₂ α} :
res₁.toOption = res₂.toOptionres₁ = Except.ok vres₂ = Except.ok v
theorem to_option_right_ok {α : Type u_1} {ε₁ : Type u_2} {ε₂ : Type u_3} {v : α} {res₁ : Except ε₁ α} {res₂ : Except ε₂ α} :
res₁.toOption = res₂.toOptionres₂ = Except.ok vres₁ = Except.ok v
theorem to_option_right_ok' {α : Type u_1} {ε₁ : Type u_2} {ε₂ : Type u_3} {v : α} {res₁ : Except ε₁ α} :
res₁.toOption = (Except.ok v).toOptionres₁ = Except.ok v
theorem to_option_left_ok' {α : Type u_1} {ε₁ : Type u_2} {ε₂ : Type u_3} {v : α} {res₂ : Except ε₂ α} :
(Except.ok v).toOption = res₂.toOptionres₂ = Except.ok v
theorem to_option_left_err {ε₁ : Type u_1} {ε₂ : Type u_2} {α : Type u_3} {err₁ : ε₁} {res₂ : Except ε₂ α} :
(Except.error err₁).toOption = res₂.toOption (err₂ : ε₂), res₂ = Except.error err₂
theorem to_option_right_err {ε₂ : Type u_1} {ε₁ : Type u_2} {α : Type u_3} {err₂ : ε₂} {res₁ : Except ε₁ α} :
res₁.toOption = (Except.error err₂).toOption (err₁ : ε₁), res₁ = Except.error err₁
theorem do_error_to_option {ε : Type u_1} {α : Type u_2} {res : Except ε α} {e : ε} :
(do let __discrres match __discr with | x => Except.error e).toOption = none
theorem do_to_option_none {ε : Type u_1} {α β : Type u_2} {res : Except ε α} {f : αExcept ε β} :
res.toOption = none(do let xres f x).toOption = none
theorem do_to_option_some {ε : Type u_1} {α β : Type u_2} {res : Except ε α} {v : α} {f : αExcept ε β} :
res.toOption = some v(do let xres f x) = f v
theorem to_option_eq_do₁ {α β : Type u_1} {ε : Type u_2} {res₁ res₂ : Except ε α} (f : αExcept ε β) :
res₁.toOption = res₂.toOption(do let xres₁ f x).toOption = (do let xres₂ f x).toOption
theorem to_option_eq_do₂ {α : Type u_1} {ε : Type u_2} {res₁ res₂ res₃ res₄ : Except ε α} (f : ααExcept ε α) :
res₁.toOption = res₃.toOptionres₂.toOption = res₄.toOption(do let xres₁ let yres₂ f x y).toOption = (do let xres₃ let yres₄ f x y).toOption
@[simp]
theorem to_option_distr_map {ε : Type u_1} {α : Type u_2} {β : Type u_3} {x : Except ε α} {f : αβ} :
@[simp]
theorem to_option_distr_fmap {ε : Type u_1} {α β : Type u_2} {x : Except ε α} {f : αβ} :