Floor and ceil #
Summary #
We define the natural- and integer-valued floor and ceil functions on linearly ordered rings.
Main Definitions #
-
floor_semiring: 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. -
floor_ring: A linearly ordered ring with integer-valued floor and ceil. -
int.floor a: Greatest integerzsuch thatz ≤ a. -
int.ceil a: Least integerzsuch thata ≤ z. -
int.fract a: Fractional part ofa, defined asa - floor a.
Notations #
The index ₊ in the notations for nat.floor and nat.ceil is used in analogy to the notation
for nnnorm.
TODO #
Some nat.floor and nat.ceil lemmas require linear_ordered_ring α. Is has_ordered_sub enough?
linear_ordered_ring/linear_ordered_semiring can be relaxed to order_ring/order_semiring in
many lemmas.
Tags #
rounding, floor, ceil
Floor semiring #
- floor : α → ℕ
- ceil : α → ℕ
- floor_of_neg : ∀ {a : α}, a < 0 → floor_semiring.floor a = 0
- gc_floor : ∀ {a : α} {n : ℕ}, 0 ≤ a → (n ≤ floor_semiring.floor a ↔ ↑n ≤ a)
- gc_ceil : galois_connection floor_semiring.ceil coe
A floor_semiring is an ordered semiring over α with a function
floor : α → ℕ satisfying ∀ (n : ℕ) (x : α), n ≤ ⌊x⌋ ↔ (n : α) ≤ x).
Note that many lemmas require a linear_order. Please see the above TODO.
⌊a⌋₊ is the greatest natural n such that n ≤ a. If a is negative, then ⌊a⌋₊ = 0.
Equations
⌈a⌉₊ is the least natural n such that a ≤ n
Equations
Ceil #
Intervals #
Natural division is the floor of field division.
There exists at most one floor_semiring structure on a linear ordered semiring.
Floor rings #
- floor : α → ℤ
- ceil : α → ℤ
- gc_coe_floor : galois_connection coe floor_ring.floor
- gc_ceil_coe : galois_connection floor_ring.ceil coe
A floor_ring is a linear ordered ring over α with a function
floor : α → ℤ satisfying ∀ (z : ℤ) (a : α), z ≤ floor a ↔ (z : α) ≤ a).
Instances
Equations
- int.floor_ring = {floor := id ℤ, ceil := id ℤ, gc_coe_floor := int.floor_ring._proof_1, gc_ceil_coe := int.floor_ring._proof_2}
A floor_ring constructor from the floor function alone.
Equations
- floor_ring.of_floor α floor gc_coe_floor = {floor := floor, ceil := λ (a : α), -floor (-a), gc_coe_floor := gc_coe_floor, gc_ceil_coe := _}
A floor_ring constructor from the ceil function alone.
Equations
- floor_ring.of_ceil α ceil gc_ceil_coe = {floor := λ (a : α), -ceil (-a), ceil := ceil, gc_coe_floor := _, gc_ceil_coe := gc_ceil_coe}
int.floor a is the greatest integer z such that z ≤ a. It is denoted with ⌊a⌋.
Equations
int.ceil a is the smallest integer z such that a ≤ z. It is denoted with ⌈a⌉.
Equations
Floor #
Fractional part #
Ceil #
Intervals #
A floor ring as a floor semiring #
There exists at most one floor_ring structure on a given linear ordered ring.