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

[Merged by Bors] - feat(data/set/ncard): noncomputable set cardinality #18576

Closed
wants to merge 23 commits into from

Conversation

apnelson1
Copy link
Collaborator

This PR introduces a function set.ncard that (noncomputably) gives the cardinality of a finite set, or zero if the set is infinite. The intention is to give a way to reason about set cardinality that avoids data and going between set and finset. This is especially useful for reasoning about sets in a finite type.

The added file is somewhat large, but it is essentially just duplicating the API in data.finset.card (minus the induction lemmas).


Open in Gitpod

@apnelson1 apnelson1 added the awaiting-review The author would like community review of the PR label Mar 13, 2023
@eric-wieser eric-wieser added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Mar 14, 2023
@apnelson1 apnelson1 added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Mar 15, 2023
src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Outdated Show resolved Hide resolved
({a} : set α).ncard = 1 :=
by simp [ncard_eq_to_finset_card]

lemma ncard_singleton_inter : ({a} ∩ s).ncard ≤ 1 :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be best to first prove a subsingleton set has cardinality ≤1, then use that a subsingleton subset is a subsingleton.

src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Outdated Show resolved Hide resolved
src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Show resolved Hide resolved
src/data/set/ncard.lean Outdated Show resolved Hide resolved
@riccardobrasca riccardobrasca requested a review from kmill May 26, 2023 16:21
Copy link
Member

@riccardobrasca riccardobrasca left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Let's just wait for @kmill to have a look (who knows finite set in Lean better than me).

@riccardobrasca
Copy link
Member

I think it's reasonable to merge this, we can always change it later if needed, thanks!

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels May 30, 2023
bors bot pushed a commit that referenced this pull request May 30, 2023
This PR introduces a function `set.ncard` that (noncomputably) gives the cardinality of a finite `set`, or zero if the set is infinite. The intention is to give a way to reason about set cardinality that avoids data and going between `set` and `finset`.  This is especially useful for reasoning about sets in a `finite` type.

The added file is somewhat large, but it is essentially just duplicating the API in `data.finset.card` (minus the induction lemmas). 



Co-authored-by: Peter Nelson <71660771+apnelson1@users.noreply.github.com>
@bors
Copy link

bors bot commented May 30, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title feat(data/set/ncard): noncomputable set cardinality [Merged by Bors] - feat(data/set/ncard): noncomputable set cardinality May 30, 2023
@bors bors bot closed this May 30, 2023
@bors bors bot deleted the ncard branch May 30, 2023 15:08
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

6 participants