feat(init/data/option): option.get
This commit is contained in:
parent
6ebbe40437
commit
558efb33c1
2 changed files with 8 additions and 0 deletions
|
|
@ -27,6 +27,10 @@ def is_none {α : Type u} : option α → bool
|
|||
| (some _) := ff
|
||||
| none := tt
|
||||
|
||||
def get {α : Type u} : Π {o : option α}, is_some o → α
|
||||
| (some x) h := x
|
||||
| none h := false.rec _ $ bool.ff_ne_tt h
|
||||
|
||||
def rhoare {α : Type u} : bool → α → option α
|
||||
| tt a := none
|
||||
| ff a := some a
|
||||
|
|
|
|||
|
|
@ -34,3 +34,7 @@ lemma option.eq_of_eq_some {α : Type u} : Π {x y : option α}, (∀z, x = some
|
|||
| none (some z) h := option.no_confusion ((h z).2 rfl)
|
||||
| (some z) none h := option.no_confusion ((h z).1 rfl)
|
||||
| (some z) (some w) h := option.no_confusion ((h w).2 rfl) (congr_arg some)
|
||||
|
||||
lemma option.eq_some_of_is_some {α : Type u} : Π {o : option α} (h : option.is_some o), o = some (option.get h)
|
||||
| (some x) h := rfl
|
||||
| none h := false.rec _ $ bool.ff_ne_tt h
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue