Skip to content

Commit

Permalink
feat: generalize mem_dite to Membership α β (#21262)
Browse files Browse the repository at this point in the history
  • Loading branch information
urkud committed Jan 31, 2025
1 parent b8068ea commit 41fd5d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
11 changes: 5 additions & 6 deletions Mathlib/Data/Set/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1763,15 +1763,14 @@ theorem powerset_singleton (x : α) : 𝒫({x} : Set α) = {∅, {x}} := by

/-! ### Sets defined as an if-then-else -/

theorem mem_dite (p : Prop) [Decidable p] (s : p → Set α) (t : ¬ p → Set α) (x : α) :
(x ∈ if h : p then s h else t h) ↔ (∀ h : p, x ∈ s h) ∧ ∀ h : ¬p, x ∈ t h := by
split_ifs with hp
· exact ⟨fun hx => ⟨fun _ => hx, fun hnp => (hnp hp).elim⟩, fun hx => hx.1 hp⟩
· exact ⟨fun hx => ⟨fun h => (hp h).elim, fun _ => hx⟩, fun hx => hx.2 hp⟩
@[deprecated _root_.mem_dite (since := "2025-01-30")]
protected theorem mem_dite (p : Prop) [Decidable p] (s : p → Set α) (t : ¬ p → Set α) (x : α) :
(x ∈ if h : p then s h else t h) ↔ (∀ h : p, x ∈ s h) ∧ ∀ h : ¬p, x ∈ t h :=
_root_.mem_dite

theorem mem_dite_univ_right (p : Prop) [Decidable p] (t : p → Set α) (x : α) :
(x ∈ if h : p then t h else univ) ↔ ∀ h : p, x ∈ t h := by
split_ifs <;> simp_all
simp [mem_dite]

@[simp]
theorem mem_ite_univ_right (p : Prop) [Decidable p] (t : Set α) (x : α) :
Expand Down
24 changes: 23 additions & 1 deletion Mathlib/Logic/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,33 @@ theorem xor_iff_or_and_not_and (a b : Prop) : Xor' a b ↔ (a ∨ b) ∧ (¬ (a

end Propositional

/-! ### Declarations about equality -/
/-! ### Membership -/

alias Membership.mem.ne_of_not_mem := ne_of_mem_of_not_mem
alias Membership.mem.ne_of_not_mem' := ne_of_mem_of_not_mem'

section Membership

variable {α β : Type*} [Membership α β] {p : Prop} [Decidable p]

theorem mem_dite {a : α} {s : p → β} {t : ¬p → β} :
(a ∈ if h : p then s h else t h) ↔ (∀ h, a ∈ s h) ∧ (∀ h, a ∈ t h) := by
by_cases h : p <;> simp [h]

theorem dite_mem {a : p → α} {b : ¬p → α} {s : β} :
(if h : p then a h else b h) ∈ s ↔ (∀ h, a h ∈ s) ∧ (∀ h, b h ∈ s) := by
by_cases h : p <;> simp [h]

theorem mem_ite {a : α} {s t : β} : (a ∈ if p then s else t) ↔ (p → a ∈ s) ∧ (¬p → a ∈ t) :=
mem_dite

theorem ite_mem {a b : α} {s : β} : (if p then a else b) ∈ s ↔ (p → a ∈ s) ∧ (¬p → b ∈ s) :=
dite_mem

end Membership

/-! ### Declarations about equality -/

section Equality

-- todo: change name
Expand Down

0 comments on commit 41fd5d1

Please sign in to comment.