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:
lexicographic ordering #
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.
- nil: ∀ {α : Type u} {r : α → α → Prop} {a : α} {l : List α}, List.Lex r [] (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₂)
Instances For
instance
List.Lex.isOrderConnected
{α : Type u}
(r : α → α → Prop)
[IsOrderConnected α r]
[IsTrichotomous α r]
:
IsOrderConnected (List α) (List.Lex r)
Equations
- ⋯ = ⋯
theorem
List.Lex.isOrderConnected.aux
{α : Type u}
(r : α → α → Prop)
[IsOrderConnected α r]
[IsTrichotomous α r]
(x✝ x✝¹ x✝² : List α)
:
instance
List.Lex.isTrichotomous
{α : Type u}
(r : α → α → Prop)
[IsTrichotomous α r]
:
IsTrichotomous (List α) (List.Lex r)
Equations
- ⋯ = ⋯
@[deprecated]
instance
List.Lex.isStrictTotalOrder
{α : Type u}
(r : α → α → Prop)
[IsStrictTotalOrder α r]
:
IsStrictTotalOrder (List α) (List.Lex r)
Equations
- ⋯ = ⋯
instance
List.Lex.decidableRel
{α : Type u}
[DecidableEq α]
(r : α → α → Prop)
[DecidableRel r]
:
DecidableRel (List.Lex r)
Equations
- List.Lex.decidableRel r x [] = isFalse ⋯
- List.Lex.decidableRel r [] (head :: tail) = isTrue ⋯
- List.Lex.decidableRel r (a :: l₁) (b :: l₂) = decidable_of_iff (r a b ∨ a = b ∧ List.Lex r l₁ l₂) ⋯
theorem
Decidable.List.Lex.ne_iff
{α : Type u}
[DecidableEq α]
{l₁ l₂ : List α}
(H : l₁.length ≤ l₂.length)
:
Equations
- List.instLinearOrder = linearOrderOfSTO (List.Lex fun (x1 x2 : α) => x1 < x2)