Documentation

Mathlib.Data.Rat.Floor

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

@[implicit_reducible]
instance Rat.instFloorRing :
FloorRing โ„š
theorem Rat.floor_def' {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' (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 (n : โ„ค) (d : โ„•) :
โŒŠโ†‘n / โ†‘dโŒ‹ = n / โ†‘d
theorem Rat.ceil_intCast_div_natCast (n : โ„ค) (d : โ„•) :
โŒˆโ†‘n / โ†‘dโŒ‰ = -(-n / โ†‘d)
theorem Rat.floor_natCast_div_natCast (n d : โ„•) :
โŒŠโ†‘n / โ†‘dโŒ‹ = โ†‘n / โ†‘d
theorem Rat.ceil_natCast_div_natCast (n d : โ„•) :
โŒˆโ†‘n / โ†‘dโŒ‰ = -(-โ†‘n / โ†‘d)
theorem Rat.natFloor_natCast_div_natCast (n d : โ„•) :
โŒŠโ†‘n / โ†‘dโŒ‹โ‚Š = n / d
@[simp]
theorem Rat.floor_cast {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (x : โ„š) :
@[simp]
theorem Rat.ceil_cast {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (x : โ„š) :
@[simp]
theorem Rat.round_cast {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (x : โ„š) :
round โ†‘x = round x
@[simp]
theorem Rat.cast_fract {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (x : โ„š) :
โ†‘(Int.fract x) = Int.fract โ†‘x
@[simp]
theorem Rat.den_intFract (x : โ„š) :
(Int.fract x).den = x.den
theorem Rat.isNat_intFloor_ofIsNNRat {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (r : ฮฑ) (n d : โ„•) :
theorem Rat.isInt_intFloor_ofIsRat_neg {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (r : ฮฑ) (n d : โ„•) :
Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d โ†’ Mathlib.Meta.NormNum.IsInt โŒŠrโŒ‹ (Int.negOfNat (-(-โ†‘n / โ†‘d)).toNat)
theorem Rat.isNat_intCeil_ofIsNNRat {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [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 {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (r : ฮฑ) (n d : โ„•) :
Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d โ†’ Mathlib.Meta.NormNum.IsInt โŒˆrโŒ‰ (Int.negOfNat (n / d))
theorem Rat.isNNRat_intFract_of_isNNRat {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (r : ฮฑ) (n d : โ„•) :
theorem Rat.isRat_intFract_of_isRat_negOfNat {ฮฑ : Type u_1} [Field ฮฑ] [LinearOrder ฮฑ] [IsStrictOrderedRing ฮฑ] [FloorRing ฮฑ] (r : ฮฑ) (n d : โ„•) :
Mathlib.Meta.NormNum.IsRat r (Int.negOfNat n) d โ†’ Mathlib.Meta.NormNum.IsRat (Int.fract r) (-โ†‘n % โ†‘d) d

norm_num extension for round #

theorem Rat.IsRat.isInt_round {R : Type u_3} [Field R] [LinearOrder R] [IsStrictOrderedRing R] [FloorRing R] (r : R) (n : โ„ค) (d : โ„•) (res : โ„ค) (hres : round (โ†‘n / โ†‘d) = res) :
theorem Int.mod_nat_eq_sub_mul_floor_rat_div {n : โ„ค} {d : โ„•} :
n % โ†‘d = n - โ†‘d * โŒŠโ†‘n / โ†‘dโŒ‹
theorem Nat.coprime_sub_mul_floor_rat_div_of_coprime {n d : โ„•} (n_coprime_d : n.Coprime d) :
(โ†‘n - โ†‘d * โŒŠโ†‘n / โ†‘dโŒ‹).natAbs.Coprime d
theorem Rat.num_lt_succ_floor_mul_den (q : โ„š) :
q.num < (โŒŠqโŒ‹ + 1) * โ†‘q.den
theorem Rat.fract_inv_num_lt_num_of_pos {q : โ„š} (q_pos : 0 < q) :