Lexicographic ordering of lists. #
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.sigma.order
: Lexicographic order onΣ i, α i
.order.lexicographic
: 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 = is_false _
- list.lex.decidable_rel r list.nil (b :: l₂) = is_true list.lex.nil
- list.lex.decidable_rel r list.nil list.nil = is_false _
theorem
list.lex.imp
{α : Type u}
{r s : α → α → Prop}
(H : ∀ (a b : α), r a b → s a b)
(l₁ l₂ : list α) :
@[protected, instance]
Equations
@[protected, instance]