Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data/finset): new union, set difference, singleton lemmas #1702

Merged
merged 4 commits into from
Nov 18, 2019

Conversation

b-mehta
Copy link
Collaborator

@b-mehta b-mehta commented Nov 17, 2019

TO CONTRIBUTORS:

Make sure you have:

  • reviewed and applied the coding style: coding, naming
  • reviewed and applied the documentation requirements
  • for tactics:
  • make sure definitions and lemmas are put in the right files
  • make sure definitions and lemmas are not redundant

If this PR is related to a discussion on Zulip, please include a link in the discussion.

For reviewers: code review check list

@b-mehta b-mehta changed the title Finset lemmas feat(data/finset): Union and set difference lemmas Nov 17, 2019
@b-mehta b-mehta changed the title feat(data/finset): Union and set difference lemmas feat(data/finset): new union, set difference, singleton lemmas Nov 17, 2019
ChrisHughes24
ChrisHughes24 previously approved these changes Nov 17, 2019
@@ -546,6 +555,16 @@ set.ext $ λ _, mem_sdiff
@[simp] lemma to_set_sdiff (s t : finset α) : (s \ t).to_set = s.to_set \ t.to_set :=
by apply finset.coe_sdiff

theorem union_sdiff_self_eq_union (s t : finset α) : s ∪ (t \ s) = s ∪ t :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be @[simp] with a left and right version

lemma union_sdiff_symm (s t : finset α) : s ∪ (t \ s) = t ∪ (s \ t) :=
by rw [union_sdiff_self_eq_union, union_sdiff_self_eq_union, union_comm]

lemma sdiff_empty_iff_subset (s t : finset α) : s \ t = ∅ ↔ s ⊆ t :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lemma sdiff_empty_iff_subset (s t : finset α) : s \ t = ∅ ↔ s ⊆ t :=
lemma sdiff_eq_empty_iff_subset {s t : finset α} : s \ t = ∅ ↔ s ⊆ t :=

@@ -171,6 +171,15 @@ theorem singleton_inj {a b : α} : ι a = ι b ↔ a = b :=

@[simp] lemma coe_singleton (a : α) : ↑(ι a) = ({a} : set α) := rfl

lemma singleton_iff_unique_mem (s : finset α) : (∃ a, s = finset.singleton a) ↔ ∃! a, a ∈ s :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better stated in a slightly stronger way without the exists.

lemma eq_singleton_iff {s : finset α} {a : α} : 
  s = finset.singleton a ↔ a ∈ s ∧ ∀ x ∈ s, x = a

That way we know both the as are the same, and the stated theorem should be a trivial consequence of this, by simp only [eq_singleton_iff_unique_mem, exists_unique] does the trick.

@ChrisHughes24 ChrisHughes24 dismissed their stale review November 17, 2019 18:07

Didn't mean to approve

@b-mehta
Copy link
Collaborator Author

b-mehta commented Nov 17, 2019

Thanks for the suggestions, I've implemented them all.

@ChrisHughes24 ChrisHughes24 added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Nov 17, 2019
@mergify mergify bot merged commit 0a794fa into leanprover-community:master Nov 18, 2019
@b-mehta b-mehta deleted the finset-lemmas branch November 18, 2019 12:50
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
…rover-community#1702)

* Singleton iff unique element lemma

* Set difference lemmas

* Changes from review
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
…rover-community#1702)

* Singleton iff unique element lemma

* Set difference lemmas

* Changes from review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants