-
Notifications
You must be signed in to change notification settings - Fork 892
[Merged by Bors] - chore: Split off and golf ulift field instances
#2911
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e7ae7cf
chore: Split off and golf `ulift` field instances
YaelDillies 23e0460
add todo
YaelDillies 40c9a4a
port, update SHAs
YaelDillies 5d276ed
update Mathlib
YaelDillies 0bd7a33
restore old proof
YaelDillies 1e03d01
remove TODO
YaelDillies 67c8a53
fix
YaelDillies d918aaa
add missing imports
eric-wieser 84b9f6a
Update Mathlib/Algebra/Order/Nonneg/Field.lean
eric-wieser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /- | ||
| Copyright (c) 2023 Yaël Dillies. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Yaël Dillies | ||
|
|
||
| ! This file was ported from Lean 3 source module algebra.field.ulift | ||
| ! leanprover-community/mathlib commit 13e18cfa070ea337ea960176414f5ae3a1534aae | ||
| ! Please do not edit these lines, except to modify the commit id | ||
| ! if you have ported upstream changes. | ||
| -/ | ||
| import Mathlib.Algebra.Field.Basic | ||
| import Mathlib.Algebra.Ring.ULift | ||
|
|
||
| /-! | ||
| # Field instances for `ULift` | ||
|
|
||
| This file defines instances for field, semifield and related structures on `ULift` types. | ||
|
|
||
| (Recall `ULift α` is just a "copy" of a type `α` in a higher universe.) | ||
| -/ | ||
|
|
||
| universe u v | ||
| variable {α : Type u} {x y : ULift.{v} α} | ||
|
|
||
| namespace ULift | ||
|
|
||
| instance [RatCast α] : RatCast (ULift α) := ⟨λ a ↦ up a⟩ | ||
|
|
||
| @[simp, norm_cast] | ||
| theorem up_ratCast [RatCast α] (q : ℚ) : up (q : α) = q := | ||
| rfl | ||
| #align ulift.up_rat_cast ULift.up_ratCast | ||
|
|
||
| @[simp, norm_cast] | ||
| theorem down_ratCast [RatCast α] (q : ℚ) : down (q : ULift α) = q := | ||
| rfl | ||
| #align ulift.down_rat_cast ULift.down_ratCast | ||
|
|
||
| instance divisionSemiring [DivisionSemiring α] : DivisionSemiring (ULift α) := by | ||
| refine' down_injective.divisionSemiring down .. <;> intros <;> rfl | ||
| #align ulift.division_semiring ULift.divisionSemiring | ||
|
|
||
| instance semifield [Semifield α] : Semifield (ULift α) := | ||
| { ULift.divisionSemiring, ULift.commGroupWithZero with } | ||
| #align ulift.semifield ULift.semifield | ||
|
|
||
| instance divisionRing [DivisionRing α] : DivisionRing (ULift α) := by | ||
| refine' down_injective.divisionRing down .. <;> intros <;> rfl | ||
| #align ulift.division_ring ULift.divisionRing | ||
|
|
||
| instance field [Field α] : Field (ULift α) := | ||
| { ULift.semifield, ULift.divisionRing with } | ||
| #align ulift.field ULift.field | ||
|
|
||
| end ULift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /- | ||
| Copyright (c) 2021 Floris van Doorn. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Floris van Doorn | ||
|
|
||
| ! This file was ported from Lean 3 source module algebra.order.nonneg.floor | ||
| ! leanprover-community/mathlib commit b3f4f007a962e3787aa0f3b5c7942a1317f7d88e | ||
| ! Please do not edit these lines, except to modify the commit id | ||
| ! if you have ported upstream changes. | ||
| -/ | ||
| import Mathlib.Algebra.Order.Nonneg.Ring | ||
| import Mathlib.Algebra.Order.Archimedean | ||
|
|
||
| /-! | ||
| # Nonnegative elements are archimedean | ||
|
|
||
| This file defines instances and prove some properties about the nonnegative elements | ||
| `{x : α // 0 ≤ x}` of an arbitrary type `α`. | ||
|
|
||
| This is used to derive algebraic structures on `ℝ≥0` and `ℚ≥0` automatically. | ||
|
|
||
| ## Main declarations | ||
|
|
||
| * `{x : α // 0 ≤ x}` is a `floor_semiring` if `α` is. | ||
| -/ | ||
|
|
||
| namespace Nonneg | ||
|
|
||
| variable {α : Type _} | ||
|
|
||
| instance archimedean [OrderedAddCommMonoid α] [Archimedean α] : Archimedean { x : α // 0 ≤ x } := | ||
| ⟨fun x y hy => | ||
| let ⟨n, hr⟩ := Archimedean.arch (x : α) (hy : (0 : α) < y) | ||
| ⟨n, show (x : α) ≤ (n • y : { x : α // 0 ≤ x }) by simp [*, -nsmul_eq_mul, nsmul_coe]⟩⟩ | ||
| #align nonneg.archimedean Nonneg.archimedean | ||
|
|
||
| instance floorSemiring [OrderedSemiring α] [FloorSemiring α] : | ||
| FloorSemiring { r : α // 0 ≤ r } where | ||
| floor a := ⌊(a : α)⌋₊ | ||
| ceil a := ⌈(a : α)⌉₊ | ||
| floor_of_neg ha := FloorSemiring.floor_of_neg ha | ||
| gc_floor ha := FloorSemiring.gc_floor (Subtype.coe_le_coe.2 ha) | ||
| gc_ceil a n := FloorSemiring.gc_ceil (a : α) n | ||
| #align nonneg.floor_semiring Nonneg.floorSemiring | ||
|
|
||
| @[norm_cast] | ||
| theorem nat_floor_coe [OrderedSemiring α] [FloorSemiring α] (a : { r : α // 0 ≤ r }) : | ||
| ⌊(a : α)⌋₊ = ⌊a⌋₊ := | ||
| rfl | ||
| #align nonneg.nat_floor_coe Nonneg.nat_floor_coe | ||
|
|
||
| @[norm_cast] | ||
| theorem nat_ceil_coe [OrderedSemiring α] [FloorSemiring α] (a : { r : α // 0 ≤ r }) : | ||
| ⌈(a : α)⌉₊ = ⌈a⌉₊ := | ||
| rfl | ||
| #align nonneg.nat_ceil_coe Nonneg.nat_ceil_coe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it
nat_cast?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess it depends where your coin flip landed so this is out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...