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] - refactor: move Archimedean instances to Order/Archimedean #9950

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Mathlib/Algebra/Order/Archimedean.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Mario Carneiro
-/
import Mathlib.Data.Int.LeastGreatest
import Mathlib.Data.Rat.Floor
import Mathlib.Data.Rat.NNRat

#align_import algebra.order.archimedean from "leanprover-community/mathlib"@"6f413f3f7330b94c92a5a27488fdc74e6d483a78"

Expand Down Expand Up @@ -409,6 +410,15 @@ instance : Archimedean ℤ :=
instance : Archimedean ℚ :=
archimedean_iff_rat_le.2 fun q => ⟨q, by rw [Rat.cast_id]⟩

instance Nonneg.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 : Archimedean NNRat := Nonneg.archimedean

/-- A linear ordered archimedean ring is a floor ring. This is not an `instance` because in some
cases we have a computable `floor` function. -/
noncomputable def Archimedean.floorRing (α) [LinearOrderedRing α] [Archimedean α] : FloorRing α :=
Expand Down
8 changes: 1 addition & 7 deletions Mathlib/Algebra/Order/Nonneg/Floor.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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
-/
import Mathlib.Algebra.Order.Floor
import Mathlib.Algebra.Order.Nonneg.Ring
import Mathlib.Algebra.Order.Archimedean

#align_import algebra.order.nonneg.floor from "leanprover-community/mathlib"@"b3f4f007a962e3787aa0f3b5c7942a1317f7d88e"

Expand All @@ -25,12 +25,6 @@ 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 : α)⌋₊
Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Data/Rat/NNRat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Algebra.Algebra.Basic
import Mathlib.Algebra.Order.Nonneg.Field
import Mathlib.Algebra.Order.Nonneg.Floor
import Mathlib.Data.Int.Lemmas

#align_import data.rat.nnrat from "leanprover-community/mathlib"@"b3f4f007a962e3787aa0f3b5c7942a1317f7d88e"

Expand Down Expand Up @@ -40,7 +40,6 @@ def NNRat := { q : ℚ // 0 ≤ q } deriving
-- instead of `deriving` them
instance : OrderedSub NNRat := Nonneg.orderedSub
instance : DenselyOrdered NNRat := Nonneg.densely_ordered
instance : Archimedean NNRat := Nonneg.archimedean

-- mathport name: nnrat
scoped[NNRat] notation "ℚ≥0" => NNRat
Expand Down
Loading