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
FloorSemiring.floor
of a negative element is zero.
A natural number n
is smaller than FloorSemiring.floor a
iff its coercion to α
is
smaller than a
.
FloorSemiring.ceil
is the lower adjoint of the coercion ↑ : ℕ → α
.
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
- 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
Alias of Nat.floor_natCast
.
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
FloorRing.ceil
is the upper adjoint of the coercion ↑ : ℤ → α
.
FloorRing.ceil
is the lower adjoint of the coercion ↑ : ℤ → α
.
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
- FloorRing.ofFloor α floor gc_coe_floor = { floor := floor, ceil := fun (a : α) => -floor (-a), gc_coe_floor := gc_coe_floor, gc_ceil_coe := ⋯ }
Instances For
A FloorRing
constructor from the ceil
function alone.
Equations
- FloorRing.ofCeil α ceil gc_ceil_coe = { floor := fun (a : α) => -ceil (-a), ceil := ceil, gc_coe_floor := ⋯, gc_ceil_coe := gc_ceil_coe }
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 #
Alias of Int.ofNat_floor_eq_floor
.
Alias of Int.ofNat_ceil_eq_ceil
.
Alias of natCast_floor_eq_intCast_floor
.
Alias of natCast_ceil_eq_intCast_ceil
.
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.