Skip to content

[Merged by Bors] - feat: order lemmas for NNRat#13547

Closed
eric-wieser wants to merge 7 commits intomasterfrom
eric-wieser/nnrat-lemmas
Closed

[Merged by Bors] - feat: order lemmas for NNRat#13547
eric-wieser wants to merge 7 commits intomasterfrom
eric-wieser/nnrat-lemmas

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

This copies the API for order lemmas on Rat


Open in Gitpod

@eric-wieser eric-wieser added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. t-order Order theory labels Jun 6, 2024
@eric-wieser eric-wieser requested a review from YaelDillies June 6, 2024 00:12
Comment on lines +201 to +239
@[simp]
theorem preimage_cast_Icc (a b : ℚ≥0) : (↑) ⁻¹' Icc (a : K) b = Icc a b :=
castOrderEmbedding.preimage_Icc ..

@[simp]
theorem preimage_cast_Ico (a b : ℚ≥0) : (↑) ⁻¹' Ico (a : K) b = Ico a b :=
castOrderEmbedding.preimage_Ico ..

@[simp]
theorem preimage_cast_Ioc (a b : ℚ≥0) : (↑) ⁻¹' Ioc (a : K) b = Ioc a b :=
castOrderEmbedding.preimage_Ioc a b

@[simp]
theorem preimage_cast_Ioo (a b : ℚ≥0) : (↑) ⁻¹' Ioo (a : K) b = Ioo a b :=
castOrderEmbedding.preimage_Ioo a b

@[simp]
theorem preimage_cast_Ici (a : ℚ≥0) : (↑) ⁻¹' Ici (a : K) = Ici a :=
castOrderEmbedding.preimage_Ici a

@[simp]
theorem preimage_cast_Iic (a : ℚ≥0) : (↑) ⁻¹' Iic (a : K) = Iic a :=
castOrderEmbedding.preimage_Iic a

@[simp]
theorem preimage_cast_Ioi (a : ℚ≥0) : (↑) ⁻¹' Ioi (a : K) = Ioi a :=
castOrderEmbedding.preimage_Ioi a

@[simp]
theorem preimage_cast_Iio (a : ℚ≥0) : (↑) ⁻¹' Iio (a : K) = Iio a :=
castOrderEmbedding.preimage_Iio a

@[simp]
theorem preimage_cast_uIcc (a b : ℚ≥0) : (↑) ⁻¹' uIcc (a : K) b = uIcc a b :=
(castOrderEmbedding (K := K)).preimage_uIcc a b

@[simp]
theorem preimage_cast_uIoc (a b : ℚ≥0) : (↑) ⁻¹' uIoc (a : K) b = uIoc a b :=
(castOrderEmbedding (K := K)).preimage_uIoc a b
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we have the corresponding image lemmas for NNRat -> Rat?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd claim "out of scope" here too; this PR just duplicates the existing Rat API, rather than adding new API.

Comment on lines +187 to +189
@[simp]
theorem cast_lt_zero {n : ℚ≥0} : (n : K) < 0 ↔ n < 0 := by
norm_cast
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks useless

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd argue that unless the linter complains, it's not!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No but like there's no point blindly copying lemmas from one type to the other if they don't make sense for the new type. Both sides of your iff are always false, so you might as well replace it by Not LHS

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, I guess the linter doesn't tell me when the RHS is further simplified.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've added your suggest but kept my original (without simp), because without this lemma norm_cast leaves some casts around.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Uh okay interesting

norm_cast

@[simp, norm_cast]
theorem cast_min {a b : ℚ≥0} : (↑(min a b) : K) = min (a : K) (b : K) :=
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
theorem cast_min {a b : ℚ≥0} : (↑(min a b) : K) = min (a : K) (b : K) :=
theorem cast_min (a b : ℚ≥0) : (↑(min a b) : K) = min (a : K) (b : K) :=

and below

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is consistent with the Rat versions of the lemmas; I'd prefer to declare this out of scope too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have opened #13644 to make your changes inconsistent with the Rat versions of the lemmas

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd appreciate it if you could push the corresponding changes to this PR once that lands; but it can wait till after your final exam!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(or preferably, delegate this one first so that I can move on to the floorsemiring instance)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure, I guess that's fixable later

maintainer merge

@YaelDillies YaelDillies added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Jun 6, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 8, 2024

PR summary

Import changes

Dependency changes

File Base Count Head Count Change
Mathlib.Data.Rat.Cast.Order 477 479 +2 (+0.42%)

Declarations diff

+ castOrderEmbedding
+ cast_le
+ cast_lt
+ cast_lt_zero
+ cast_max
+ cast_min
+ cast_mono
+ cast_nonpos
+ cast_pos
+ cast_strictMono
+ evalNNRatCast
+ le_def
+ lt_def
+ not_cast_lt_zero
+ preimage_cast_Icc
+ preimage_cast_Ici
+ preimage_cast_Ico
+ preimage_cast_Iic
+ preimage_cast_Iio
+ preimage_cast_Ioc
+ preimage_cast_Ioi
+ preimage_cast_Ioo
+ preimage_cast_uIcc
+ preimage_cast_uIoc

You can run this locally as follows
## summary with just the declaration names:
./scripts/no_lost_declarations.sh short <optional_commit>

## more verbose report:
./scripts/no_lost_declarations.sh <optional_commit>

@eric-wieser eric-wieser added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Jun 8, 2024
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jun 8, 2024
@sgouezel
Copy link
Copy Markdown
Contributor

sgouezel commented Jun 9, 2024

bors r+

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Jun 9, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jun 9, 2024
This copies the API for order lemmas on `Rat`
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jun 9, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: order lemmas for NNRat [Merged by Bors] - feat: order lemmas for NNRat Jun 9, 2024
@mathlib-bors mathlib-bors bot closed this Jun 9, 2024
@mathlib-bors mathlib-bors bot deleted the eric-wieser/nnrat-lemmas branch June 9, 2024 08:12
AntoineChambert-Loir pushed a commit that referenced this pull request Jun 20, 2024
This copies the API for order lemmas on `Rat`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants