Floor and ceil #
Summary #
We define the natural- and integer-valued floor and ceil functions on linearly ordered rings.
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. -
round a: Nearest integer toa. It rounds halves towards infinity.
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 #
- floor : α → ℕ
FloorSemiring.floor acomputes the greatest naturalnsuch that(n : α) ≤ a. - ceil : α → ℕ
FloorSemiring.ceil acomputes the least naturalnsuch thata ≤ (n : α). - floor_of_neg : ∀ {a : α}, a < 0 → FloorSemiring.floor a = 0
FloorSemiring.floorof a negative element is zero. A natural number
nis smaller thanFloorSemiring.floor aiff its coercion toαis smaller thana.- gc_ceil : GaloisConnection FloorSemiring.ceil Nat.cast
FloorSemiring.ceilis the lower adjoint of the coercion↑ : ℕ → α.
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.
Instances
Equations
- One or more equations did not get rendered due to their size.
⌊a⌋₊ is the greatest natural n such that n ≤ a. If a is negative, then ⌊a⌋₊ = 0.
Equations
- Nat.floor = FloorSemiring.floor
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
Ceil #
Intervals #
Natural division is the floor of field division.
There exists at most one FloorSemiring structure on a linear ordered semiring.
Floor rings #
- 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 FloorRing.floor
FloorRing.ceilis the upper adjoint of the coercion↑ : ℤ → α. - gc_ceil_coe : GaloisConnection FloorRing.ceil Int.cast
FloorRing.ceilis the lower adjoint of the coercion↑ : ℤ → α.
A FloorRing is a linear ordered ring over α with a function
floor : α → ℤ satisfying ∀ (z : ℤ) (a : α), z ≤ floor a ↔ (z : α) ≤ a).
Instances
Equations
- One or more equations did not get rendered due to their size.
A FloorRing constructor from the floor function alone.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A FloorRing constructor from the ceil function alone.
Equations
- One or more equations did not get rendered due to their size.
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 #
Fractional part #
Ceil #
Intervals #
Round #
A floor ring as a floor semiring #
Equations
- One or more equations did not get rendered due to their size.
There exists at most one FloorRing structure on a given linear ordered ring.
Extension for the positivity tactic: Int.floor is nonnegative if its input is.
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.