Skip to content

Commit

Permalink
feat(data/finset): option.to_finset
Browse files Browse the repository at this point in the history
  • Loading branch information
spl committed Sep 4, 2018
1 parent fd43fe0 commit c492e4a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions data/finset.lean
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,24 @@ by simp [or_imp_distrib, forall_and_distrib]

end finset

namespace option

/-- Construct an empty or singleton finset from an `option` -/
def to_finset (o : option α) : finset α :=
match o with
| none := ∅
| some a := finset.singleton a
end

@[simp] theorem to_finset_none : none.to_finset = (∅ : finset α) := rfl

@[simp] theorem to_finset_some {a : α} : (some a).to_finset = finset.singleton a := rfl

@[simp] theorem mem_to_finset {a : α} {o : option α} : a ∈ o.to_finset ↔ a ∈ o :=
by cases o; simp [eq_comm]

end option

/- erase_dup on list and multiset -/

namespace multiset
Expand Down

0 comments on commit c492e4a

Please sign in to comment.