Locally finite orders #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 data.finset.locally_finite
.
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 locally_finite_order
,
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.multiset.Icc
: Closed-closed interval as a multiset.multiset.Ico
: Closed-open interval as a multiset.multiset.Ioc
: Open-closed interval as a multiset.multiset.Ioo
: Open-open interval as a multiset.
In a locally_finite_order_top
,
finset.Ici
: Closed-infinite interval as a finset.finset.Ioi
: Open-infinite interval as a finset.multiset.Ici
: Closed-infinite interval as a multiset.multiset.Ioi
: Open-infinite interval as a multiset.
In a locally_finite_order_bot
,
finset.Iic
: Infinite-open interval as a finset.finset.Iio
: Infinite-closed interval as a finset.multiset.Iic
: Infinite-open interval as a multiset.multiset.Iio
: Infinite-closed interval as a multiset.
Instances #
A locally_finite_order
instance can be built
- for a subtype of a locally finite order. See
subtype.locally_finite_order
. - for the product of two locally finite orders. See
prod.locally_finite_order
. - for any fintype (but not as an instance). See
fintype.to_locally_finite_order
. - from a definition of
finset.Icc
alone. Seelocally_finite_order.of_Icc
. - by pulling back
locally_finite_order β
through an order embeddingf : α →o β
. Seeorder_embedding.locally_finite_order
.
Instances for concrete types are proved in their respective files:
ℕ
is indata.nat.interval
ℤ
is indata.int.interval
ℕ+
is indata.pnat.interval
fin n
is indata.fin.interval
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 locally_finite_order
instance for α ×ₗ β
where locally_finite_order α
and
fintype β
.
Provide the locally_finite_order
instance for α →₀ β
where β
is locally finite. Provide the
locally_finite_order
instance for Π₀ i, β i
where all the β i
are locally finite.
From linear_order α
, no_max_order α
, locally_finite_order α
, we can also define an
order isomorphism α ≃ ℕ
or α ≃ ℤ
, depending on whether we have order_bot α
or
no_min_order α
and nonempty α
. When order_bot α
, we can match a : α
to (Iio a).card
.
We can provide succ_order α
from linear_order α
and locally_finite_order α
using
lemma exists_min_greater [linear_order α] [locally_finite_order α] {x ub : α} (hx : x < ub) :
∃ lub, x < lub ∧ ∀ y, x < y → lub ≤ y :=
begin -- very non golfed
have h : (finset.Ioc x ub).nonempty := ⟨ub, finset.mem_Ioc_iff.2 ⟨hx, le_rfl⟩⟩,
use finset.min' (finset.Ioc x ub) h,
split,
{ have := finset.min'_mem _ h,
simp * at * },
rintro y hxy,
obtain hy | hy := le_total y ub,
apply finset.min'_le,
simp * at *,
exact (finset.min'_le _ _ (finset.mem_Ioc_iff.2 ⟨hx, le_rfl⟩)).trans hy,
end
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 succ_order
, but it's not locally finite
as Icc (-1) 1
is infinite.
- finset_Icc : α → α → finset α
- finset_Ico : α → α → finset α
- finset_Ioc : α → α → finset α
- finset_Ioo : α → α → finset α
- finset_mem_Icc : ∀ (a b x : α), x ∈ locally_finite_order.finset_Icc a b ↔ a ≤ x ∧ x ≤ b
- finset_mem_Ico : ∀ (a b x : α), x ∈ locally_finite_order.finset_Ico a b ↔ a ≤ x ∧ x < b
- finset_mem_Ioc : ∀ (a b x : α), x ∈ locally_finite_order.finset_Ioc a b ↔ a < x ∧ x ≤ b
- finset_mem_Ioo : ∀ (a b x : α), x ∈ locally_finite_order.finset_Ioo a b ↔ a < x ∧ x < b
A locally finite order is an order where bounded intervals are finite. When you don't care too
much about definitional equality, you can use locally_finite_order.of_Icc
or
locally_finite_order.of_finite_Icc
to build a locally finite order from just finset.Icc
.
Instances of this typeclass
Instances of other typeclasses for locally_finite_order
- locally_finite_order.has_sizeof_inst
- locally_finite_order.subsingleton
- finset_Ioi : α → finset α
- finset_Ici : α → finset α
- finset_mem_Ici : ∀ (a x : α), x ∈ locally_finite_order_top.finset_Ici a ↔ a ≤ x
- finset_mem_Ioi : ∀ (a x : α), x ∈ locally_finite_order_top.finset_Ioi a ↔ a < x
A locally finite order top is an order where all intervals bounded above are finite. This is
slightly weaker than locally_finite_order
+ order_top
as it allows empty types.
Instances of this typeclass
Instances of other typeclasses for locally_finite_order_top
- locally_finite_order_top.has_sizeof_inst
- locally_finite_order_top.subsingleton
- finset_Iio : α → finset α
- finset_Iic : α → finset α
- finset_mem_Iic : ∀ (a x : α), x ∈ locally_finite_order_bot.finset_Iic a ↔ x ≤ a
- finset_mem_Iio : ∀ (a x : α), x ∈ locally_finite_order_bot.finset_Iio a ↔ x < a
A locally finite order bot is an order where all intervals bounded below are finite. This is
slightly weaker than locally_finite_order
+ order_bot
as it allows empty types.
Instances of this typeclass
Instances of other typeclasses for locally_finite_order_bot
- locally_finite_order_bot.has_sizeof_inst
- locally_finite_order_bot.subsingleton
A constructor from a definition of finset.Icc
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order.of_Icc
, this one requires decidable_rel (≤)
but
only preorder
.
Equations
- locally_finite_order.of_Icc' α finset_Icc mem_Icc = {finset_Icc := finset_Icc, finset_Ico := λ (a b : α), finset.filter (λ (x : α), ¬b ≤ x) (finset_Icc a b), finset_Ioc := λ (a b : α), finset.filter (λ (x : α), ¬x ≤ a) (finset_Icc a b), finset_Ioo := λ (a b : α), finset.filter (λ (x : α), ¬x ≤ a ∧ ¬b ≤ x) (finset_Icc a b), finset_mem_Icc := mem_Icc, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
A constructor from a definition of finset.Icc
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order.of_Icc
, this one requires partial_order
but only
decidable_eq
.
Equations
- locally_finite_order.of_Icc α finset_Icc mem_Icc = {finset_Icc := finset_Icc, finset_Ico := λ (a b : α), finset.filter (λ (x : α), x ≠ b) (finset_Icc a b), finset_Ioc := λ (a b : α), finset.filter (λ (x : α), a ≠ x) (finset_Icc a b), finset_Ioo := λ (a b : α), finset.filter (λ (x : α), a ≠ x ∧ x ≠ b) (finset_Icc a b), finset_mem_Icc := mem_Icc, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
A constructor from a definition of finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order_top.of_Ici
, this one requires decidable_rel (≤)
but
only preorder
.
Equations
- locally_finite_order_top.of_Ici' α finset_Ici mem_Ici = {finset_Ioi := λ (a : α), finset.filter (λ (x : α), ¬x ≤ a) (finset_Ici a), finset_Ici := finset_Ici, finset_mem_Ici := mem_Ici, finset_mem_Ioi := _}
A constructor from a definition of finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order_top.of_Ici'
, this one requires partial_order
but
only decidable_eq
.
Equations
- locally_finite_order_top.of_Ici α finset_Ici mem_Ici = {finset_Ioi := λ (a : α), finset.filter (λ (x : α), a ≠ x) (finset_Ici a), finset_Ici := finset_Ici, finset_mem_Ici := mem_Ici, finset_mem_Ioi := _}
A constructor from a definition of finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order.of_Icc
, this one requires decidable_rel (≤)
but
only preorder
.
Equations
- locally_finite_order_bot.of_Iic' α finset_Iic mem_Iic = {finset_Iio := λ (a : α), finset.filter (λ (x : α), ¬a ≤ x) (finset_Iic a), finset_Iic := finset_Iic, finset_mem_Iic := mem_Iic, finset_mem_Iio := _}
A constructor from a definition of finset.Iic
alone, the other ones being derived by removing
the ends. As opposed to locally_finite_order_top.of_Ici'
, this one requires partial_order
but
only decidable_eq
.
Equations
- locally_finite_order_top.of_Iic α finset_Iic mem_Iic = {finset_Iio := λ (a : α), finset.filter (λ (x : α), x ≠ a) (finset_Iic a), finset_Iic := finset_Iic, finset_mem_Iic := mem_Iic, finset_mem_Iio := _}
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- is_empty.to_locally_finite_order = {finset_Icc := is_empty_elim (λ (a : α), α → finset α), finset_Ico := is_empty_elim (λ (a : α), α → finset α), finset_Ioc := is_empty_elim (λ (a : α), α → finset α), finset_Ioo := is_empty_elim (λ (a : α), α → finset α), finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- is_empty.to_locally_finite_order_top = {finset_Ioi := is_empty_elim (λ (a : α), finset α), finset_Ici := is_empty_elim (λ (a : α), finset α), finset_mem_Ici := _, finset_mem_Ioi := _}
An empty type is locally finite.
This is not an instance as it would not be defeq to more specific instances.
Equations
- is_empty.to_locally_finite_order_bot = {finset_Iio := is_empty_elim (λ (a : α), finset α), finset_Iic := is_empty_elim (λ (a : α), finset α), finset_mem_Iic := _, finset_mem_Iio := _}
Intervals as finsets #
The finset of elements x
such that a ≤ x
and x ≤ b
. Basically set.Icc a b
as a finset.
Equations
The finset of elements x
such that a ≤ x
and x < b
. Basically set.Ico a b
as a finset.
Equations
The finset of elements x
such that a < x
and x ≤ b
. Basically set.Ioc a b
as a finset.
Equations
The finset of elements x
such that a < x
and x < b
. Basically set.Ioo a b
as a finset.
Equations
The finset of elements x
such that a ≤ x
. Basically set.Ici a
as a finset.
Equations
The finset of elements x
such that a < x
. Basically set.Ioi a
as a finset.
Equations
The finset of elements x
such that a ≤ x
. Basically set.Iic a
as a finset.
Equations
The finset of elements x
such that a < x
. Basically set.Iio a
as a finset.
Equations
Equations
- locally_finite_order.to_locally_finite_order_top = {finset_Ioi := λ (b : α), finset.Ioc b ⊤, finset_Ici := λ (b : α), finset.Icc b ⊤, finset_mem_Ici := _, finset_mem_Ioi := _}
Equations
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)
Intervals as multisets #
The multiset of elements x
such that a ≤ x
and x ≤ b
. Basically set.Icc a b
as a
multiset.
Equations
- multiset.Icc a b = (finset.Icc a b).val
The multiset of elements x
such that a ≤ x
and x < b
. Basically set.Ico a b
as a
multiset.
Equations
- multiset.Ico a b = (finset.Ico a b).val
The multiset of elements x
such that a < x
and x ≤ b
. Basically set.Ioc a b
as a
multiset.
Equations
- multiset.Ioc a b = (finset.Ioc a b).val
The multiset of elements x
such that a < x
and x < b
. Basically set.Ioo a b
as a
multiset.
Equations
- multiset.Ioo a b = (finset.Ioo a b).val
The multiset of elements x
such that a ≤ x
. Basically set.Ici a
as a multiset.
Equations
- multiset.Ici a = (finset.Ici a).val
The multiset of elements x
such that a < x
. Basically set.Ioi a
as a multiset.
Equations
- multiset.Ioi a = (finset.Ioi a).val
The multiset of elements x
such that x ≤ b
. Basically set.Iic b
as a multiset.
Equations
- multiset.Iic b = (finset.Iic b).val
The multiset of elements x
such that x < b
. Basically set.Iio b
as a multiset.
Equations
- multiset.Iio b = (finset.Iio b).val
Equations
- set.fintype_Icc a b = fintype.of_finset (finset.Icc a b) _
Equations
- set.fintype_Ico a b = fintype.of_finset (finset.Ico a b) _
Equations
- set.fintype_Ioc a b = fintype.of_finset (finset.Ioc a b) _
Equations
- set.fintype_Ioo a b = fintype.of_finset (finset.Ioo a b) _
Equations
- set.fintype_Ici a = fintype.of_finset (finset.Ici a) _
Equations
- set.fintype_Ioi a = fintype.of_finset (finset.Ioi a) _
Equations
- set.fintype_Iic b = fintype.of_finset (finset.Iic b) _
Equations
- set.fintype_Iio b = fintype.of_finset (finset.Iio b) _
Equations
- set.fintype_uIcc a b = fintype.of_finset (finset.uIcc a b) _
Instances #
A noncomputable constructor from the finiteness of all closed intervals.
Equations
- locally_finite_order.of_finite_Icc h = locally_finite_order.of_Icc' α (λ (a b : α), _.to_finset) _
A fintype is a locally finite order.
This is not an instance as it would not be defeq to better instances such as
fin.locally_finite_order
.
Equations
- fintype.to_locally_finite_order = {finset_Icc := λ (a b : α), (set.Icc a b).to_finset, finset_Ico := λ (a b : α), (set.Ico a b).to_finset, finset_Ioc := λ (a b : α), (set.Ioc a b).to_finset, finset_Ioo := λ (a b : α), (set.Ioo a b).to_finset, finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
Given an order embedding α ↪o β
, pulls back the locally_finite_order
on β
to α
.
Equations
- f.locally_finite_order = {finset_Icc := λ (a b : α), (finset.Icc (⇑f a) (⇑f b)).preimage ⇑f _, finset_Ico := λ (a b : α), (finset.Ico (⇑f a) (⇑f b)).preimage ⇑f _, finset_Ioc := λ (a b : α), (finset.Ioc (⇑f a) (⇑f b)).preimage ⇑f _, finset_Ioo := λ (a b : α), (finset.Ioo (⇑f a) (⇑f b)).preimage ⇑f _, finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
Note we define Icc (to_dual a) (to_dual b)
as Icc α _ _ b a
(which has type finset α
not
finset αᵒᵈ
!) instead of (Icc b a).map to_dual.to_embedding
as this means the
following is defeq:
lemma this : (Icc (to_dual (to_dual a)) (to_dual (to_dual b)) : _) = (Icc a b : _) := rfl
Equations
- order_dual.locally_finite_order = {finset_Icc := λ (a b : αᵒᵈ), finset.Icc (⇑order_dual.of_dual b) (⇑order_dual.of_dual a), finset_Ico := λ (a b : αᵒᵈ), finset.Ioc (⇑order_dual.of_dual b) (⇑order_dual.of_dual a), finset_Ioc := λ (a b : αᵒᵈ), finset.Ico (⇑order_dual.of_dual b) (⇑order_dual.of_dual a), finset_Ioo := λ (a b : αᵒᵈ), finset.Ioo (⇑order_dual.of_dual b) (⇑order_dual.of_dual a), finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
Note we define Iic (to_dual a)
as Ici a
(which has type finset α
not finset αᵒᵈ
!)
instead of (Ici a).map to_dual.to_embedding
as this means the following is defeq:
lemma this : (Iic (to_dual (to_dual a)) : _) = (Iic a : _) := rfl
Equations
- order_dual.locally_finite_order_bot = {finset_Iio := λ (a : αᵒᵈ), finset.Ioi (⇑order_dual.of_dual a), finset_Iic := λ (a : αᵒᵈ), finset.Ici (⇑order_dual.of_dual a), finset_mem_Iic := _, finset_mem_Iio := _}
Note we define Ici (to_dual a)
as Iic a
(which has type finset α
not finset αᵒᵈ
!)
instead of (Iic a).map to_dual.to_embedding
as this means the following is defeq:
lemma this : (Ici (to_dual (to_dual a)) : _) = (Ici a : _) := rfl
Equations
- order_dual.locally_finite_order_top = {finset_Ioi := λ (a : αᵒᵈ), finset.Iio (⇑order_dual.of_dual a), finset_Ici := λ (a : αᵒᵈ), finset.Iic (⇑order_dual.of_dual a), finset_mem_Ici := _, finset_mem_Ioi := _}
Equations
- prod.locally_finite_order = locally_finite_order.of_Icc' (α × β) (λ (a b : α × β), finset.Icc a.fst b.fst ×ˢ finset.Icc a.snd b.snd) prod.locally_finite_order._proof_1
Equations
- prod.locally_finite_order_top = locally_finite_order_top.of_Ici' (α × β) (λ (a : α × β), finset.Ici a.fst ×ˢ finset.Ici a.snd) prod.locally_finite_order_top._proof_1
Equations
- prod.locally_finite_order_bot = locally_finite_order_bot.of_Iic' (α × β) (λ (a : α × β), finset.Iic a.fst ×ˢ finset.Iic a.snd) prod.locally_finite_order_bot._proof_1
with_top
, with_bot
#
Adding a ⊤
to a locally finite order_top
keeps it locally finite.
Adding a ⊥
to a locally finite order_bot
keeps it locally finite.
Equations
- with_top.locally_finite_order α = {finset_Icc := λ (a b : with_top α), with_top.locally_finite_order._match_1 α a b, finset_Ico := λ (a b : with_top α), with_top.locally_finite_order._match_2 α a b, finset_Ioc := λ (a b : with_top α), with_top.locally_finite_order._match_3 α a b, finset_Ioo := λ (a b : with_top α), with_top.locally_finite_order._match_4 α a b, finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
- with_top.locally_finite_order._match_1 α ↑a ↑b = finset.map function.embedding.coe_option (finset.Icc a b)
- with_top.locally_finite_order._match_1 α ↑a ⊤ = ⇑finset.insert_none (finset.Ici a)
- with_top.locally_finite_order._match_1 α ⊤ ↑b = ∅
- with_top.locally_finite_order._match_1 α ⊤ ⊤ = {⊤}
- with_top.locally_finite_order._match_2 α ↑a ↑b = finset.map function.embedding.coe_option (finset.Ico a b)
- with_top.locally_finite_order._match_2 α ↑a ⊤ = finset.map function.embedding.coe_option (finset.Ici a)
- with_top.locally_finite_order._match_2 α ⊤ _x = ∅
- with_top.locally_finite_order._match_3 α ↑a ↑b = finset.map function.embedding.coe_option (finset.Ioc a b)
- with_top.locally_finite_order._match_3 α ↑a ⊤ = ⇑finset.insert_none (finset.Ioi a)
- with_top.locally_finite_order._match_3 α ⊤ _x = ∅
- with_top.locally_finite_order._match_4 α ↑a ↑b = finset.map function.embedding.coe_option (finset.Ioo a b)
- with_top.locally_finite_order._match_4 α ↑a ⊤ = finset.map function.embedding.coe_option (finset.Ioi a)
- with_top.locally_finite_order._match_4 α ⊤ _x = ∅
Transfer locally finite orders across order isomorphisms #
Transfer locally_finite_order
across an order_iso
.
Equations
- f.locally_finite_order = {finset_Icc := λ (a b : α), finset.map f.symm.to_equiv.to_embedding (finset.Icc (⇑f a) (⇑f b)), finset_Ico := λ (a b : α), finset.map f.symm.to_equiv.to_embedding (finset.Ico (⇑f a) (⇑f b)), finset_Ioc := λ (a b : α), finset.map f.symm.to_equiv.to_embedding (finset.Ioc (⇑f a) (⇑f b)), finset_Ioo := λ (a b : α), finset.map f.symm.to_equiv.to_embedding (finset.Ioo (⇑f a) (⇑f b)), finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
Transfer locally_finite_order_top
across an order_iso
.
Equations
- f.locally_finite_order_top = {finset_Ioi := λ (a : α), finset.map f.symm.to_equiv.to_embedding (finset.Ioi (⇑f a)), finset_Ici := λ (a : α), finset.map f.symm.to_equiv.to_embedding (finset.Ici (⇑f a)), finset_mem_Ici := _, finset_mem_Ioi := _}
Transfer locally_finite_order_bot
across an order_iso
.
Equations
- f.locally_finite_order_bot = {finset_Iio := λ (a : α), finset.map f.symm.to_equiv.to_embedding (finset.Iio (⇑f a)), finset_Iic := λ (a : α), finset.map f.symm.to_equiv.to_embedding (finset.Iic (⇑f a)), finset_mem_Iic := _, finset_mem_Iio := _}
Subtype of a locally finite order #
Equations
- subtype.locally_finite_order p = {finset_Icc := λ (a b : subtype p), finset.subtype p (finset.Icc ↑a ↑b), finset_Ico := λ (a b : subtype p), finset.subtype p (finset.Ico ↑a ↑b), finset_Ioc := λ (a b : subtype p), finset.subtype p (finset.Ioc ↑a ↑b), finset_Ioo := λ (a b : subtype p), finset.subtype p (finset.Ioo ↑a ↑b), finset_mem_Icc := _, finset_mem_Ico := _, finset_mem_Ioc := _, finset_mem_Ioo := _}
Equations
- subtype.locally_finite_order_top p = {finset_Ioi := λ (a : subtype p), finset.subtype p (finset.Ioi ↑a), finset_Ici := λ (a : subtype p), finset.subtype p (finset.Ici ↑a), finset_mem_Ici := _, finset_mem_Ioi := _}
Equations
- subtype.locally_finite_order_bot p = {finset_Iio := λ (a : subtype p), finset.subtype p (finset.Iio ↑a), finset_Iic := λ (a : subtype p), finset.subtype p (finset.Iic ↑a), finset_mem_Iic := _, finset_mem_Iio := _}