Skip to content

Commit

Permalink
more option lemmas
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Sep 6, 2024
1 parent 0906bba commit eb1b781
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Init/Data/Option/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,23 @@ end ite
@[simp] theorem pmap_some {p : α → Prop} {f : ∀ (a : α), p a → β} {h}:
pmap f (some a) h = f a (h a (mem_some_self a)) := rfl

@[simp] theorem pmap_eq_none {p : α → Prop} {f : ∀ (a : α), p a → β} {h} :
pmap f o h = none ↔ o = none := by
cases o <;> simp

@[simp] theorem pmap_isSome {p : α → Prop} {f : ∀ (a : α), p a → β} {o : Option α} {h} :
(pmap f o h).isSome = o.isSome := by
cases o <;> simp

@[simp] theorem pmap_eq_some {p : α → Prop} {f : ∀ (a : α), p a → β} {o : Option α} {h} :
pmap f o h = some b ↔ ∃ (a : α) (h : p a), o = some a ∧ b = f a h := by
cases o with
| none => simp
| some a =>
simp only [pmap, eq_comm, some.injEq, exists_and_left, exists_eq_left']
constructor
· exact fun w => ⟨h a rfl, w⟩
· rintro ⟨h, rfl⟩
rfl

end Option

0 comments on commit eb1b781

Please sign in to comment.