Floor and ceil #
We define the natural- and integer-valued floor and ceil functions on linearly ordered rings.
We also provide positivity extensions to handle floor and ceil.
Main definitions #
FloorSemiring: An ordered semiring with natural-valued floor and ceil.Nat.floor a: Greatest naturalnsuch thatn ≤ a. Equal to0ifa < 0.Nat.ceil a: Least naturalnsuch thata ≤ n.FloorRing: A linearly ordered ring with integer-valued floor and ceil.Int.floor a: Greatest integerzsuch thatz ≤ a.Int.ceil a: Least integerzsuch thata ≤ z.
Notations #
The index ₊ in the notations for Nat.floor and Nat.ceil is used in analogy to the notation
for nnnorm.
TODO #
LinearOrderedRing/LinearOrderedSemiring can be relaxed to OrderedRing/OrderedSemiring in
many lemmas.
Tags #
rounding, floor, ceil
Floor semiring #
A FloorSemiring is an ordered semiring over α with a function
floor : α → ℕ satisfying ∀ (n : ℕ) (x : α), n ≤ ⌊x⌋ ↔ (n : α) ≤ x).
Note that many lemmas require a LinearOrder. Please see the above TODO.
- floor : α → ℕ
FloorSemiring.floor acomputes the greatest naturalnsuch that(n : α) ≤ a. - ceil : α → ℕ
FloorSemiring.ceil acomputes the least naturalnsuch thata ≤ (n : α). FloorSemiring.floorof a negative element is zero.A natural number
nis smaller thanFloorSemiring.floor aiff its coercion toαis smaller thana.- gc_ceil : GaloisConnection ceil Nat.cast
FloorSemiring.ceilis the lower adjoint of the coercion↑ : ℕ → α.
Instances
Equations
- instFloorSemiringNat = { floor := id, ceil := id, floor_of_neg := @instFloorSemiringNat._proof_1, gc_floor := @instFloorSemiringNat._proof_2, gc_ceil := instFloorSemiringNat._proof_3 }
⌊a⌋₊ is the greatest natural n such that n ≤ a. If a is negative, then ⌊a⌋₊ = 0.
Equations
Instances For
⌈a⌉₊ is the least natural n such that a ≤ n
Equations
Instances For
⌊a⌋₊ is the greatest natural n such that n ≤ a. If a is negative, then ⌊a⌋₊ = 0.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⌈a⌉₊ is the least natural n such that a ≤ n
Equations
- One or more equations did not get rendered due to their size.
Instances For
Floor rings #
A FloorRing is a linear ordered ring over α with a function
floor : α → ℤ satisfying ∀ (z : ℤ) (a : α), z ≤ floor a ↔ (z : α) ≤ a).
- floor : α → ℤ
FloorRing.floor acomputes the greatest integerzsuch that(z : α) ≤ a. - ceil : α → ℤ
FloorRing.ceil acomputes the least integerzsuch thata ≤ (z : α). - gc_coe_floor : GaloisConnection Int.cast floor
FloorRing.ceilis the upper adjoint of the coercion↑ : ℤ → α. - gc_ceil_coe : GaloisConnection ceil Int.cast
FloorRing.ceilis the lower adjoint of the coercion↑ : ℤ → α.
Instances
Equations
- instFloorRingInt = { floor := id, ceil := id, gc_coe_floor := instFloorRingInt._proof_1, gc_ceil_coe := instFloorRingInt._proof_2 }
A FloorRing constructor from the floor function alone.
Equations
Instances For
A FloorRing constructor from the ceil function alone.
Equations
Instances For
Int.floor a is the greatest integer z such that z ≤ a. It is denoted with ⌊a⌋.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Int.ceil a is the smallest integer z such that a ≤ z. It is denoted with ⌈a⌉.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Floor #
Ceil #
A floor ring as a floor semiring #
Extension for the positivity tactic: Int.floor is nonnegative if its input is.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Extension for the positivity tactic: Nat.ceil is positive if its input is.
Instances For
Extension for the positivity tactic: Int.ceil is positive/nonnegative if its input is.
Equations
- One or more equations did not get rendered due to their size.