Mathlib.Data.Rat.Floor
36 declarations. Mathlib docs · Source
Floor Function for Rational Numbers
Summary
We define the FloorRing instance on ℚ. Some technical lemmas relating floor to integer
division and modulo arithmetic are derived as well as some simple inequalities.
Tags
rat, rationals, ℚ, floor
norm_num extension for round
instance Rat.instFloorRing E0 #
FloorRing ℚ
theorem Rat.floor_def' E1 #
∀ {q : ℚ}, ⌊q⌋ = q.num / ↑q.den
This variant of floor_def uses the Int.floor (for any FloorRing) rather than Rat.floor.
theorem Rat.ceil_def' E1 #
∀ (q : ℚ), ⌈q⌉ = -(-q.num / ↑q.den)
This variant of ceil_def uses the Int.ceil (for any FloorRing) rather than Rat.ceil.
theorem Rat.floor_intCast_div_natCast E1 #
∀ (n : ℤ) (d : ℕ), ⌊↑n / ↑d⌋ = n / ↑d
theorem Rat.ceil_intCast_div_natCast E1 #
∀ (n : ℤ) (d : ℕ), ⌈↑n / ↑d⌉ = -(-n / ↑d)
theorem Rat.floor_natCast_div_natCast E1 #
∀ (n d : ℕ), ⌊↑n / ↑d⌋ = ↑n / ↑d
theorem Rat.ceil_natCast_div_natCast E1 #
∀ (n d : ℕ), ⌈↑n / ↑d⌉ = -(-↑n / ↑d)
theorem Rat.natFloor_natCast_div_natCast E1 #
∀ (n d : ℕ), ⌊↑n / ↑d⌋₊ = n / d
theorem Rat.floor_cast E0 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (x : ℚ),
⌊↑x⌋ = ⌊x⌋
theorem Rat.ceil_cast E0 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (x : ℚ),
⌈↑x⌉ = ⌈x⌉
theorem Rat.round_cast E0 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (x : ℚ),
round ↑x = round x
theorem Rat.cast_fract E0 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (x : ℚ),
↑(Int.fract x) = Int.fract ↑x
theorem Rat.den_intFract E0 #
∀ (x : ℚ), (Int.fract x).den = x.den
theorem Rat.isNat_intFloor E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℕ),
Mathlib.Meta.NormNum.IsNat r m → Mathlib.Meta.NormNum.IsNat ⌊r⌋ m
theorem Rat.isInt_intFloor E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℤ),
Mathlib.Meta.NormNum.IsInt r m → Mathlib.Meta.NormNum.IsInt ⌊r⌋ m
theorem Rat.isNat_intFloor_ofIsNNRat E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ), Mathlib.Meta.NormNum.IsNNRat r n d → Mathlib.Meta.NormNum.IsNat ⌊r⌋ (n / d)
theorem Rat.isInt_intFloor_ofIsRat_neg E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ),
Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d → Mathlib.Meta.NormNum.IsInt ⌊r⌋ (Int.negOfNat (-(-↑n / ↑d)).toNat)
def Rat.evalIntFloor E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num extension for Int.floor
theorem Rat.isNat_intCeil E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℕ),
Mathlib.Meta.NormNum.IsNat r m → Mathlib.Meta.NormNum.IsNat ⌈r⌉ m
theorem Rat.isInt_intCeil E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℤ),
Mathlib.Meta.NormNum.IsInt r m → Mathlib.Meta.NormNum.IsInt ⌈r⌉ m
theorem Rat.isNat_intCeil_ofIsNNRat E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ), Mathlib.Meta.NormNum.IsNNRat r n d → Mathlib.Meta.NormNum.IsNat ⌈r⌉ (-(-↑n / ↑d)).toNat
theorem Rat.isInt_intCeil_ofIsRat_neg E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ), Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d → Mathlib.Meta.NormNum.IsInt ⌈r⌉ (Int.negOfNat (n / d))
def Rat.evalIntCeil E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num extension for Int.ceil
theorem Rat.isNat_intFract_of_isNat E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℕ),
Mathlib.Meta.NormNum.IsNat r m → Mathlib.Meta.NormNum.IsNat (Int.fract r) 0
theorem Rat.isNat_intFract_of_isInt E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℤ),
Mathlib.Meta.NormNum.IsInt r m → Mathlib.Meta.NormNum.IsNat (Int.fract r) 0
theorem Rat.isNNRat_intFract_of_isNNRat E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ), Mathlib.Meta.NormNum.IsNNRat r n d → Mathlib.Meta.NormNum.IsNNRat (Int.fract r) (n % d) d
theorem Rat.isRat_intFract_of_isRat_negOfNat E1 #
∀ {α : Type u_1} [inst : Field α] [inst_1 : LinearOrder α] [IsStrictOrderedRing α] [inst_3 : FloorRing α] (r : α)
(n d : ℕ), Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d → Mathlib.Meta.NormNum.IsRat (Int.fract r) (-↑n % ↑d) d
def Rat.evalIntFract E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num extension for Int.fract
theorem Rat.isNat_round E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℕ),
Mathlib.Meta.NormNum.IsNat r m → Mathlib.Meta.NormNum.IsNat (round r) m
theorem Rat.isInt_round E1 #
∀ {R : Type u_2} [inst : Ring R] [inst_1 : LinearOrder R] [inst_2 : FloorRing R] (r : R) (m : ℤ),
Mathlib.Meta.NormNum.IsInt r m → Mathlib.Meta.NormNum.IsInt (round r) m
theorem Rat.IsRat.isInt_round E1 #
∀ {R : Type u_3} [inst : Field R] [inst_1 : LinearOrder R] [IsStrictOrderedRing R] [inst_3 : FloorRing R] (r : R)
(n : ℤ) (d : ℕ) (res : ℤ),
round (↑n / ↑d) = res → Mathlib.Meta.NormNum.IsRat r n d → Mathlib.Meta.NormNum.IsInt (round r) res
def Rat.evalRound E1 #
Mathlib.Meta.NormNum.NormNumExt
norm_num extension for round
theorem Int.mod_nat_eq_sub_mul_floor_rat_div E1 #
∀ {n : ℤ} {d : ℕ}, n % ↑d = n - ↑d * ⌊↑n / ↑d⌋
theorem Nat.coprime_sub_mul_floor_rat_div_of_coprime E1 #
∀ {n d : ℕ}, n.Coprime d → (↑n - ↑d * ⌊↑n / ↑d⌋).natAbs.Coprime d
theorem Rat.num_lt_succ_floor_mul_den E1 #
∀ (q : ℚ), q.num < (⌊q⌋ + 1) * ↑q.den
theorem Rat.fract_inv_num_lt_num_of_pos E1 #
∀ {q : ℚ}, 0 < q → (Int.fract q⁻¹).num < q.num