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/real/cardinality): cardinalities of intervals of reals #3252

Closed
wants to merge 3 commits into from

Conversation

jsm28
Copy link
Collaborator

@jsm28 jsm28 commented Jul 1, 2020

Use the existing result mk_real to deduce corresponding results for
all eight kinds of intervals of reals.

It's convenient for this result to add a new lemma to
data.set.intervals.image_preimage about the image of an interval
under inv. Just as there are only a few results there about images
of intervals under multiplication rather than a full set, so I just
added the result I needed rather than all the possible variants. (I
think there are something like 36 reasonable variants of that lemma
that could be stated, for (image or preimage - the same thing in this
case, but still separate statements) x (interval in positive or
negative reals) x (end closer to 0 is 0 (open), nonzero (open) or
nonzero (closed)) x (other end is open, closed or infinite).)


Use the existing result `not_countable_real` to deduce corresponding
results for all eight kinds of intervals of reals.

It's convenient for this result to add a new lemma to
`data.set.intervals.image_preimage' about the image of an interval
under `inv`.  Just as there are only a few results there about images
of intervals under multiplication rather than a full set, so I just
added the result I needed rather than all the possible variants.  (I
think there are something like 36 reasonable variants of that lemma
that could be stated, for (image or preimage - the same thing in this
case, but still separate statements) x (interval in positive or
negative reals) x (end closer to 0 is 0 (open), nonzero (open) or
nonzero (closed)) x (other end is open, closed or infinite).)
@bryangingechen bryangingechen added the awaiting-review The author would like community review of the PR label Jul 1, 2020
@urkud
Copy link
Member

urkud commented Jul 1, 2020

It would be nice to have equivs between open intervals (finite or infinite) and the whole line, and equality of cardinalities in other cases. Though feel free to postpone it to another PR.

@fpvandoorn
Copy link
Member

fpvandoorn commented Jul 1, 2020

  • I think it's indeed good to not add all variants of image_inv_Ioo_0_left. (After [Merged by Bors] - feat(algebra/pointwise): make instances global #3240 simp will at least simplify some of the variants)
  • I would prefer if you proved that the cardinality of all these intervals is the continuum (2 ^ omega.{0}), instead of "not countable". That is hopefully not much harder.

@semorrison semorrison 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 Jul 1, 2020
@jsm28
Copy link
Collaborator Author

jsm28 commented Jul 1, 2020

The countable API is convenient for these proofs, using countable.union, countable.image, countable_singleton, countable.mono. To adapt these proofs to show the exact cardinality, we'd need those properties of countable instead for the predicate that a set has cardinality < 2 ^ omega.{0}. Of course they're true for any predicate that the cardinality of a set is less than, or less than or equal to, some given infinite cardinal, but have we got any equivalent of countable.union for that case?

@jcommelin
Copy link
Member

Can't you use Cantor–Bernstein? You need to build an injection from real to Ioo a b, and then you're basically done.

@jsm28
Copy link
Collaborator Author

jsm28 commented Jul 1, 2020

There are plenty of possible ways of proving it, including building up some arbitrary injection piecewise using inv, or proving injectivity of real.tanh as a standard function sometimes used for that purpose, but I was hoping for some argument that's short and not too ugly.

@fpvandoorn
Copy link
Member

fpvandoorn commented Jul 1, 2020

The countable API is convenient for these proofs, using countable.union, countable.image, countable_singleton, countable.mono. To adapt these proofs to show the exact cardinality, we'd need those properties of countable instead for the predicate that a set has cardinality < 2 ^ omega.{0}. Of course they're true for any predicate that the cardinality of a set is less than, or less than or equal to, some given infinite cardinal, but have we got any equivalent of countable.union for that case?

The API for cardinalities is also pretty good. There is (in the cardinal namespace, in set_theory.cardinal): mk_image_le, mk_image_eq (for injective maps), mk_singleton, mk_le_mk_of_subset.
mk_union_le is missing, but should be a one-liner away from mk_union_add_mk_inter (please add it!). This can be used in combination with add_eq_max (in set_theory.ordinal) or one of its corollaries.
There will be some extra work, like proving that 1 < 2 ^ omega.{0} (lt_trans one_lt_omega (cantor _)) and showing actual equalities (using le_antisymm + mk_set_le). But you should be able to use the same proof structure.

@jsm28
Copy link
Collaborator Author

jsm28 commented Jul 2, 2020

Thanks for the hints. I've converted the changes to prove cardinalities rather than "not countable", with the same proof structure. (not_countable_real_Ioo was the actual lemma I wanted originally, but of course it can trivially be deduced from mk_real_Ioo that's now there.)

@jsm28 jsm28 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 Jul 2, 2020
@jsm28 jsm28 changed the title feat(data/real/cardinality): intervals of reals are uncountable feat(data/real/cardinality): cardinalities of intervals of reals Jul 2, 2020
@jcommelin
Copy link
Member

LGTM

src/data/real/cardinality.lean Outdated Show resolved Hide resolved
/-- The cardinality of the interval (a, ∞). -/
lemma mk_real_Ioi (a : ℝ) : mk (Ioi a) = 2 ^ omega.{0} :=
begin
refine le_antisymm (mk_real ▸ mk_set_le _) _,
Copy link
Member

Choose a reason for hiding this comment

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

Just a tip, I don't care if you change it in this PR:
I personally tend to always avoid ; it's a weaker version of rw, and in some cases more brittle (although that is also me as a Lean 2 user talking; since the behavior of was a lot more unpredictable in Lean 2, and proofs could easily break with sequences of these substitutions).
In this case I think you can do:

refine le_antisymm _ _, { rw mk_real, exact mk_set_le _ }

I don't mind if you don't change it in this PR: I don't think it's an actual style guide, and all use cases are single line proof terms in this PR.

@fpvandoorn
Copy link
Member

fpvandoorn commented Jul 2, 2020

bors d+

feel free to merge this after the name changes.

Thanks for changing this to actual cardinal computations!

@bors
Copy link

bors bot commented Jul 2, 2020

✌️ jsm28 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@jsm28
Copy link
Collaborator Author

jsm28 commented Jul 2, 2020

bors r+

bors bot pushed a commit that referenced this pull request Jul 2, 2020
Use the existing result `mk_real` to deduce corresponding results for
all eight kinds of intervals of reals.

It's convenient for this result to add a new lemma to
`data.set.intervals.image_preimage` about the image of an interval
under `inv`.  Just as there are only a few results there about images
of intervals under multiplication rather than a full set, so I just
added the result I needed rather than all the possible variants.  (I
think there are something like 36 reasonable variants of that lemma
that could be stated, for (image or preimage - the same thing in this
case, but still separate statements) x (interval in positive or
negative reals) x (end closer to 0 is 0 (open), nonzero (open) or
nonzero (closed)) x (other end is open, closed or infinite).)
@bors
Copy link

bors bot commented Jul 2, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/real/cardinality): cardinalities of intervals of reals [Merged by Bors] - feat(data/real/cardinality): cardinalities of intervals of reals Jul 2, 2020
@bors bors bot closed this Jul 2, 2020
@bors bors bot deleted the real-interval-uncountable branch July 2, 2020 20:13
@YaelDillies YaelDillies removed the awaiting-review The author would like community review of the PR label Nov 15, 2021
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
…nprover-community#3252)

Use the existing result `mk_real` to deduce corresponding results for
all eight kinds of intervals of reals.

It's convenient for this result to add a new lemma to
`data.set.intervals.image_preimage` about the image of an interval
under `inv`.  Just as there are only a few results there about images
of intervals under multiplication rather than a full set, so I just
added the result I needed rather than all the possible variants.  (I
think there are something like 36 reasonable variants of that lemma
that could be stated, for (image or preimage - the same thing in this
case, but still separate statements) x (interval in positive or
negative reals) x (end closer to 0 is 0 (open), nonzero (open) or
nonzero (closed)) x (other end is open, closed or infinite).)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants