Lexicographic ordering of lists. #
The lexicographic order on List α is defined by L < M iff
- [] < (a :: L)for any- aand- L,
- (a :: L) < (b :: M)where- a < b, or
- (a :: L) < (a :: M)where- L < M.
See also #
Related files are:
lexicographic ordering #
- 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₂)
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.
Instances For
instance
List.Lex.isOrderConnected
{α : Type u}
(r : α → α → Prop)
[IsOrderConnected α r]
[IsTrichotomous α r]
 :
IsOrderConnected (List α) (List.Lex r)
theorem
List.Lex.isOrderConnected.aux
{α : Type u}
(r : α → α → Prop)
[IsOrderConnected α r]
[IsTrichotomous α r]
 :
instance
List.Lex.isTrichotomous
{α : Type u}
(r : α → α → Prop)
[IsTrichotomous α r]
 :
IsTrichotomous (List α) (List.Lex r)
Equations
instance
List.Lex.isStrictTotalOrder
{α : Type u}
(r : α → α → Prop)
[IsStrictTotalOrder α r]
 :
IsStrictTotalOrder (List α) (List.Lex r)
instance
List.Lex.decidableRel
{α : Type u}
[DecidableEq α]
(r : α → α → Prop)
[DecidableRel r]
 :
DecidableRel (List.Lex r)
Equations
- List.Lex.decidableRel r x [] = isFalse (_ : List.Lex r x [] → False)
- List.Lex.decidableRel r [] (b :: l₂) = isTrue (_ : List.Lex r [] (b :: l₂))
- List.Lex.decidableRel r (a :: l₁) (b :: l₂) = decidable_of_iff (r a b ∨ a = b ∧ List.Lex r l₁ l₂) (_ : r a b ∨ a = b ∧ List.Lex r l₁ l₂ ↔ List.Lex r (a :: l₁) (b :: l₂))
theorem
Decidable.List.Lex.ne_iff
{α : Type u}
[DecidableEq α]
{l₁ : List α}
{l₂ : List α}
(H : List.length l₁ ≤ List.length l₂)
 :
theorem
List.Lex.ne_iff
{α : Type u}
{l₁ : List α}
{l₂ : List α}
(H : List.length l₁ ≤ List.length l₂)
 :
Equations
- List.instLinearOrderList = linearOrderOfSTO (List.Lex fun x x_1 => x < x_1)