Locally finite orders #
This file defines locally finite orders.
A locally finite order is an order for which all bounded intervals are finite. This allows to make
sense of Icc
/Ico
/Ioc
/Ioo
as lists, multisets, or finsets.
Further, if the order is bounded above (resp. below), then we can also make sense of the
"unbounded" intervals Ici
/Ioi
(resp. Iic
/Iio
).
Many theorems about these intervals can be found in Mathlib.Order.Interval.Finset.Basic
.
Examples #
Naturally occurring locally finite orders are ℕ
, ℤ
, ℕ+
, Fin n
, α × β
the product of two
locally finite orders, α →₀ β
the finitely supported functions to a locally finite order β
...
Main declarations #
In a LocallyFiniteOrder
,
Finset.Icc
: Closed-closed interval as a finset.Finset.Ico
: Closed-open interval as a finset.Finset.Ioc
: Open-closed interval as a finset.Finset.Ioo
: Open-open interval as a finset.Finset.uIcc
: Unordered closed interval as a finset.
In a LocallyFiniteOrderTop
,
Finset.Ici
: Closed-infinite interval as a finset.Finset.Ioi
: Open-infinite interval as a finset.
In a LocallyFiniteOrderBot
,
Finset.Iic
: Infinite-open interval as a finset.Finset.Iio
: Infinite-closed interval as a finset.
Instances #
A LocallyFiniteOrder
instance can be built
- for a subtype of a locally finite order. See
Subtype.locallyFiniteOrder
. - for the product of two locally finite orders. See
Prod.locallyFiniteOrder
. - for any fintype (but not as an instance). See
Fintype.toLocallyFiniteOrder
. - from a definition of
Finset.Icc
alone. SeeLocallyFiniteOrder.ofIcc
. - by pulling back
LocallyFiniteOrder β
through an order embeddingf : α →o β
. SeeOrderEmbedding.locallyFiniteOrder
.
Instances for concrete types are proved in their respective files:
ℕ
is inOrder.Interval.Finset.Nat
ℤ
is inData.Int.Interval
ℕ+
is inData.PNat.Interval
Fin n
is inOrder.Interval.Finset.Fin
Finset α
is inData.Finset.Interval
Σ i, α i
is inData.Sigma.Interval
Along, you will find lemmas about the cardinality of those finite intervals.
TODO #
Provide the LocallyFiniteOrder
instance for α ×ₗ β
where LocallyFiniteOrder α
and
Fintype β
.
Provide the LocallyFiniteOrder
instance for α →₀ β
where β
is locally finite. Provide the
LocallyFiniteOrder
instance for Π₀ i, β i
where all the β i
are locally finite.
From LinearOrder α
, NoMaxOrder α
, LocallyFiniteOrder α
, we can also define an
order isomorphism α ≃ ℕ
or α ≃ ℤ
, depending on whether we have OrderBot α
or
NoMinOrder α
and Nonempty α
. When OrderBot α
, we can match a : α
to (Iio a).card
.
We can provide SuccOrder α
from LinearOrder α
and LocallyFiniteOrder α
using
lemma exists_min_greater [LinearOrder α] [LocallyFiniteOrder α] {x ub : α} (hx : x < ub) :
∃ lub, x < lub ∧ ∀ y, x < y → lub ≤ y := by
-- very non golfed
have h : (Finset.Ioc x ub).Nonempty := ⟨ub, Finset.mem_Ioc.2 ⟨hx, le_rfl⟩⟩
use Finset.min' (Finset.Ioc x ub) h
constructor
· exact (Finset.mem_Ioc.mp <| Finset.min'_mem _ h).1
rintro y hxy
obtain hy | hy := le_total y ub
· refine Finset.min'_le (Ioc x ub) y ?_
simp [*] at *
· exact (Finset.min'_le _ _ (Finset.mem_Ioc.2 ⟨hx, le_rfl⟩)).trans hy
Note that the converse is not true. Consider {-2^z | z : ℤ} ∪ {2^z | z : ℤ}
. Any element has a
successor (and actually a predecessor as well), so it is a SuccOrder
, but it's not locally finite
as Icc (-1) 1
is infinite.
This is a mixin class describing a locally finite order,
that is, is an order where bounded intervals are finite.
When you don't care too much about definitional equality, you can use LocallyFiniteOrder.ofIcc
or
LocallyFiniteOrder.ofFiniteIcc
to build a locally finite order from just Finset.Icc
.
- finsetIcc : α → α → Finset α
Left-closed right-closed interval
- finsetIco : α → α → Finset α
Left-closed right-open interval
- finsetIoc : α → α → Finset α
Left-open right-closed interval
- finsetIoo : α → α → Finset α
Left-open right-open interval
x ∈ finsetIcc a b ↔ a ≤ x ∧ x ≤ b
x ∈ finsetIco a b ↔ a ≤ x ∧ x < b
x ∈ finsetIoc a b ↔ a < x ∧ x ≤ b
x ∈ finsetIoo a b ↔ a < x ∧ x < b
Instances
x ∈ finsetIcc a b ↔ a ≤ x ∧ x ≤ b
x ∈ finsetIco a b ↔ a ≤ x ∧ x < b
x ∈ finsetIoc a b ↔ a < x ∧ x ≤ b
x ∈ finsetIoo a b ↔ a < x ∧ x < b
This mixin class describes an order where all intervals bounded below are finite. This is
slightly weaker than LocallyFiniteOrder
+ OrderTop
as it allows empty types.
- finsetIoi : α → Finset α
Left-open right-infinite interval
- finsetIci : α → Finset α
Left-closed right-infinite interval
- finset_mem_Ici : ∀ (a x : α), x ∈ LocallyFiniteOrderTop.finsetIci a ↔ a ≤ x
x ∈ finsetIci a ↔ a ≤ x
- finset_mem_Ioi : ∀ (a x : α), x ∈ LocallyFiniteOrderTop.finsetIoi a ↔ a < x
x ∈ finsetIoi a ↔ a < x
Instances
x ∈ finsetIci a ↔ a ≤ x
x ∈ finsetIoi a ↔ a < x
This mixin class describes an order where all intervals bounded above are finite. This is
slightly weaker than LocallyFiniteOrder
+ OrderBot
as it allows empty types.
- finsetIio : α → Finset α
Left-infinite right-open interval
- finsetIic : α → Finset α
Left-infinite right-closed interval
- finset_mem_Iic : ∀ (a x : α), x ∈ LocallyFiniteOrderBot.finsetIic a ↔ x ≤ a
x ∈ finsetIic a ↔ x ≤ a
- finset_mem_Iio : ∀ (a x : α), x ∈ LocallyFiniteOrderBot.finsetIio a ↔ x < a
x ∈ finsetIio a ↔ x < a
Instances
x ∈ finsetIic a ↔ x ≤ a
x ∈ finsetIio a ↔ x < a
A constructor from a definition of Finset.Icc
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrder.ofIcc
, this one requires DecidableRel (· ≤ ·)
but
only Preorder
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A constructor from a definition of Finset.Icc
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrder.ofIcc'
, this one requires PartialOrder
but only
DecidableEq
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A constructor from a definition of Finset.Ici
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrderTop.ofIci
, this one requires DecidableRel (· ≤ ·)
but
only Preorder
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A constructor from a definition of Finset.Ici
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrderTop.ofIci'
, this one requires PartialOrder
but
only DecidableEq
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A constructor from a definition of Finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrderBot.ofIic
, this one requires DecidableRel (· ≤ ·)
but
only Preorder
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A constructor from a definition of Finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to LocallyFiniteOrderBot.ofIic'
, this one requires PartialOrder
but
only DecidableEq
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- IsEmpty.toLocallyFiniteOrderTop = { finsetIoi := fun (a : α) => isEmptyElim a, finsetIci := fun (a : α) => isEmptyElim a, finset_mem_Ici := ⋯, finset_mem_Ioi := ⋯ }
Instances For
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- IsEmpty.toLocallyFiniteOrderBot = { finsetIio := fun (a : α) => isEmptyElim a, finsetIic := fun (a : α) => isEmptyElim a, finset_mem_Iic := ⋯, finset_mem_Iio := ⋯ }
Instances For
Intervals as finsets #
The finset of elements x
such that a ≤ x
and x ≤ b
. Basically Set.Icc a b
as a finset.
Equations
- Finset.Icc a b = LocallyFiniteOrder.finsetIcc a b
Instances For
The finset of elements x
such that a ≤ x
and x < b
. Basically Set.Ico a b
as a finset.
Equations
- Finset.Ico a b = LocallyFiniteOrder.finsetIco a b
Instances For
The finset of elements x
such that a < x
and x ≤ b
. Basically Set.Ioc a b
as a finset.
Equations
- Finset.Ioc a b = LocallyFiniteOrder.finsetIoc a b
Instances For
The finset of elements x
such that a < x
and x < b
. Basically Set.Ioo a b
as a finset.
Equations
- Finset.Ioo a b = LocallyFiniteOrder.finsetIoo a b
Instances For
Equations
- LocallyFiniteOrder.toLocallyFiniteOrderTop = { finsetIoi := fun (b : α) => Finset.Ioc b ⊤, finsetIci := fun (b : α) => Finset.Icc b ⊤, finset_mem_Ici := ⋯, finset_mem_Ioi := ⋯ }
Equations
- Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot = { finsetIio := Finset.Ico ⊥, finsetIic := Finset.Icc ⊥, finset_mem_Iic := ⋯, finset_mem_Iio := ⋯ }
Finset.uIcc a b
is the set of elements lying between a
and b
, with a
and b
included.
Note that we define it more generally in a lattice as Finset.Icc (a ⊓ b) (a ⊔ b)
. In a
product type, Finset.uIcc
corresponds to the bounding box of the two elements.
Equations
- Finset.uIcc a b = Finset.Icc (a ⊓ b) (a ⊔ b)
Instances For
Finset.uIcc a b
is the set of elements lying between a
and b
, with a
and b
included.
Note that we define it more generally in a lattice as Finset.Icc (a ⊓ b) (a ⊔ b)
. In a
product type, Finset.uIcc
corresponds to the bounding box of the two elements.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Elaborate set builder notation for Finset
.
{x ≤ a | p x}
is elaborated asFinset.filter (fun x ↦ p x) (Finset.Iic a)
if the expected type isFinset ?α
.{x ≥ a | p x}
is elaborated asFinset.filter (fun x ↦ p x) (Finset.Ici a)
if the expected type isFinset ?α
.{x < a | p x}
is elaborated asFinset.filter (fun x ↦ p x) (Finset.Iio a)
if the expected type isFinset ?α
.{x > a | p x}
is elaborated asFinset.filter (fun x ↦ p x) (Finset.Ioi a)
if the expected type isFinset ?α
.
See also
Data.Set.Defs
for theSet
builder notation elaborator that this elaborator partly overrides.Data.Finset.Basic
for theFinset
builder notation elaborator partly overriding this one for syntax of the form{x ∈ s | p x}
.Data.Fintype.Basic
for theFinset
builder notation elaborator handling syntax of the form{x | p x}
,{x : α | p x}
,{x ∉ s | p x}
,{x ≠ a | p x}
.
TODO: Write a delaborator
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Set.fintypeIcc a b = Fintype.ofFinset (Finset.Icc a b) ⋯
Equations
- Set.fintypeIco a b = Fintype.ofFinset (Finset.Ico a b) ⋯
Equations
- Set.fintypeIoc a b = Fintype.ofFinset (Finset.Ioc a b) ⋯
Equations
- Set.fintypeIoo a b = Fintype.ofFinset (Finset.Ioo a b) ⋯
Equations
- Set.fintypeIci a = Fintype.ofFinset (Finset.Ici a) ⋯
Equations
- Set.fintypeIoi a = Fintype.ofFinset (Finset.Ioi a) ⋯
Equations
- Set.fintypeIic b = Fintype.ofFinset (Finset.Iic b) ⋯
Equations
- Set.fintypeIio b = Fintype.ofFinset (Finset.Iio b) ⋯
Equations
- Set.fintypeUIcc a b = Fintype.ofFinset (Finset.uIcc a b) ⋯
Instances #
A noncomputable constructor from the finiteness of all closed intervals.
Equations
- LocallyFiniteOrder.ofFiniteIcc h = LocallyFiniteOrder.ofIcc' α (fun (a b : α) => ⋯.toFinset) ⋯
Instances For
A fintype is a locally finite order.
This is not an instance as it would not be defeq to better instances such as
Fin.locallyFiniteOrder
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Given an order embedding α ↪o β
, pulls back the LocallyFiniteOrder
on β
to α
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Note we define Icc (toDual a) (toDual b)
as Icc α _ _ b a
(which has type Finset α
not
Finset αᵒᵈ
!) instead of (Icc b a).map toDual.toEmbedding
as this means the
following is defeq:
lemma this : (Icc (toDual (toDual a)) (toDual (toDual b)) : _) = (Icc a b : _) := rfl
Equations
- One or more equations did not get rendered due to their size.
Note we define Iic (toDual a)
as Ici a
(which has type Finset α
not Finset αᵒᵈ
!)
instead of (Ici a).map toDual.toEmbedding
as this means the following is defeq:
lemma this : (Iic (toDual (toDual a)) : _) = (Iic a : _) := rfl
Equations
- One or more equations did not get rendered due to their size.
Note we define Ici (toDual a)
as Iic a
(which has type Finset α
not Finset αᵒᵈ
!)
instead of (Iic a).map toDual.toEmbedding
as this means the following is defeq:
lemma this : (Ici (toDual (toDual a)) : _) = (Ici a : _) := rfl
Equations
- One or more equations did not get rendered due to their size.
Equations
- Prod.instLocallyFiniteOrder = LocallyFiniteOrder.ofIcc' (α × β) (fun (x y : α × β) => Finset.Icc x.1 y.1 ×ˢ Finset.Icc x.2 y.2) ⋯
Equations
- Prod.instLocallyFiniteOrderTop = LocallyFiniteOrderTop.ofIci' (α × β) (fun (x : α × β) => Finset.Ici x.1 ×ˢ Finset.Ici x.2) ⋯
Equations
- Prod.instLocallyFiniteOrderBot = LocallyFiniteOrderBot.ofIic' (α × β) (fun (x : α × β) => Finset.Iic x.1 ×ˢ Finset.Iic x.2) ⋯
WithTop
, WithBot
#
Adding a ⊤
to a locally finite OrderTop
keeps it locally finite.
Adding a ⊥
to a locally finite OrderBot
keeps it locally finite.
Equations
- One or more equations did not get rendered due to their size.
Equations
- WithBot.instLocallyFiniteOrder α = OrderDual.instLocallyFiniteOrder
Transfer locally finite orders across order isomorphisms #
Transfer LocallyFiniteOrder
across an OrderIso
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transfer LocallyFiniteOrderTop
across an OrderIso
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transfer LocallyFiniteOrderBot
across an OrderIso
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Subtype of a locally finite order #
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
We make the instances below low priority so when alternative constructions are available they are preferred.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯