Skip to content

Commit

Permalink
feat(data/set/basic): pair_eq_pair_iff (#17187)
Browse files Browse the repository at this point in the history
Also moved some lemmas about pairs into a new section.
  • Loading branch information
kmill committed Oct 27, 2022
1 parent c571859 commit 324f6d5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/data/set/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,6 @@ theorem mem_singleton_of_eq {x y : α} (H : x = y) : x ∈ ({y} : set α) := H

theorem insert_eq (x : α) (s : set α) : insert x s = ({x} : set α) ∪ s := rfl

@[simp] theorem pair_eq_singleton (a : α) : ({a, a} : set α) = {a} := union_self _

theorem pair_comm (a b : α) : ({a, b} : set α) = {b, a} := union_comm _ _

@[simp] theorem singleton_nonempty (a : α) : ({a} : set α).nonempty :=
⟨a, rfl⟩

Expand Down Expand Up @@ -820,6 +816,22 @@ eq_singleton_iff_unique_mem.trans $ and_congr_left $ λ H, ⟨λ h', ⟨_, h'⟩
-- while `simp` is capable of proving this, it is not capable of turning the LHS into the RHS.
@[simp] lemma default_coe_singleton (x : α) : (default : ({x} : set α)) = ⟨x, rfl⟩ := rfl

/-! ### Lemmas about pairs -/

@[simp] theorem pair_eq_singleton (a : α) : ({a, a} : set α) = {a} := union_self _

theorem pair_comm (a b : α) : ({a, b} : set α) = {b, a} := union_comm _ _

lemma pair_eq_pair_iff {x y z w : α} :
({x, y} : set α) = {z, w} ↔ x = z ∧ y = w ∨ x = w ∧ y = z :=
begin
simp only [set.subset.antisymm_iff, set.insert_subset, set.mem_insert_iff, set.mem_singleton_iff,
set.singleton_subset_iff],
split,
{ tauto! },
{ rintro (⟨rfl,rfl⟩|⟨rfl,rfl⟩); simp }
end

/-! ### Lemmas about sets defined as `{x ∈ s | p x}`. -/

section sep
Expand Down

0 comments on commit 324f6d5

Please sign in to comment.