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 naturaln
such thatn ≤ a
. Equal to0
ifa < 0
. -
Nat.ceil a
: Least naturaln
such thata ≤ n
. -
FloorRing
: A linearly ordered ring with integer-valued floor and ceil. -
Int.floor a
: Greatest integerz
such thatz ≤ a
. -
Int.ceil a
: Least integerz
such 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 #
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 a
computes the greatest naturaln
such that(n : α) ≤ a
. - ceil : α → ℕ
FloorSemiring.ceil a
computes the least naturaln
such thata ≤ (n : α)
. - floor_of_neg : ∀ {a : α}, a < 0 → FloorSemiring.floor a = 0
FloorSemiring.floor
of a negative element is zero. A natural number
n
is smaller thanFloorSemiring.floor a
iff its coercion toα
is smaller thana
.- gc_ceil : GaloisConnection FloorSemiring.ceil Nat.cast
FloorSemiring.ceil
is the lower adjoint of the coercion↑ : ℕ → α
.
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 #
A FloorRing
is a linear ordered ring over α
with a function
floor : α → ℤ
satisfying ∀ (z : ℤ) (a : α), z ≤ floor a ↔ (z : α) ≤ a)
.
- floor : α → ℤ
FloorRing.floor a
computes the greatest integerz
such that(z : α) ≤ a
. - ceil : α → ℤ
FloorRing.ceil a
computes the least integerz
such thata ≤ (z : α)
. - gc_coe_floor : GaloisConnection Int.cast FloorRing.floor
FloorRing.ceil
is the upper adjoint of the coercion↑ : ℤ → α
. - gc_ceil_coe : GaloisConnection FloorRing.ceil Int.cast
FloorRing.ceil
is the lower adjoint of the coercion↑ : ℤ → α
.
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.