Skip to content

Commit

Permalink
feat(logic/embedding): embedding into option
Browse files Browse the repository at this point in the history
  • Loading branch information
spl committed Sep 4, 2018
1 parent fd43fe0 commit 9133a80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/option.lean
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ option.some.inj $ ha.symm.trans hb

theorem some_inj {a b : α} : some a = some b ↔ a = b := by simp

theorem injective_some (α : Type*) : function.injective (@some α) :=
λ _ _, some_inj.mp

theorem ext : ∀ {o₁ o₂ : option α}, (∀ a, a ∈ o₁ ↔ a ∈ o₂) → o₁ = o₂
| none none H := rfl
| (some a) o H := ((H _).1 rfl).symm
Expand Down
4 changes: 4 additions & 0 deletions logic/embedding.lean
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ begin
apply classical.some_spec h
end

/-- Embedding into `option` -/
protected def some {α} : α ↪ option α :=
⟨some, option.injective_some α⟩

def subtype {α} (p : α → Prop) : subtype p ↪ α :=
⟨subtype.val, λ _ _, subtype.eq'⟩

Expand Down

0 comments on commit 9133a80

Please sign in to comment.