Lexicographic ordering of lists. #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
The lexicographic order on list α
is defined by L < M
iff
[] < (a :: L)
for anya
andL
,(a :: L) < (b :: M)
wherea < b
, or(a :: L) < (a :: M)
whereL < M
.
See also #
Related files are:
data.finset.colex
: Colexicographic order on finite sets.data.psigma.order
: Lexicographic order onΣ' i, α i
.data.pi.lex
: Lexicographic order onΠₗ i, α i
.data.sigma.order
: Lexicographic order onΣ i, α i
.data.prod.lex
: Lexicographic order onα × β
.
lexicographic ordering #
- nil : ∀ {α : Type u} {r : α → α → Prop} {a : α} {l : list α}, list.lex r list.nil (a :: l)
- cons : ∀ {α : Type u} {r : α → α → Prop} {a : α} {l₁ l₂ : list α}, list.lex r l₁ l₂ → list.lex r (a :: l₁) (a :: l₂)
- rel : ∀ {α : Type u} {r : α → α → Prop} {a₁ : α} {l₁ : list α} {a₂ : α} {l₂ : list α}, r a₁ a₂ → list.lex r (a₁ :: l₁) (a₂ :: l₂)
Given a strict order <
on α
, the lexicographic strict order on list α
, for which
[a0, ..., an] < [b0, ..., b_k]
if a0 < b0
or a0 = b0
and [a1, ..., an] < [b1, ..., bk]
.
The definition is given for any relation r
, not only strict orders.
@[protected, instance]
def
list.lex.is_order_connected
{α : Type u}
(r : α → α → Prop)
[is_order_connected α r]
[is_trichotomous α r] :
is_order_connected (list α) (list.lex r)
@[protected, instance]
def
list.lex.is_trichotomous
{α : Type u}
(r : α → α → Prop)
[is_trichotomous α r] :
is_trichotomous (list α) (list.lex r)
@[protected, instance]
def
list.lex.is_strict_total_order
{α : Type u}
(r : α → α → Prop)
[is_strict_total_order α r] :
is_strict_total_order (list α) (list.lex r)
@[protected, instance]
Equations
- list.lex.decidable_rel r (a :: l₁) (b :: l₂) = decidable_of_iff (r a b ∨ a = b ∧ list.lex r l₁ l₂) _
- list.lex.decidable_rel r (hd :: tl) list.nil = decidable.is_false _
- list.lex.decidable_rel r list.nil (b :: l₂) = decidable.is_true list.lex.nil
- list.lex.decidable_rel r list.nil list.nil = decidable.is_false _
@[protected, instance]
Equations
@[protected, instance]