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
- (_ : IsOrderConnected (List α) (List.Lex 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
- (_ : IsTrichotomous (List α) (List.Lex r)) = (_ : IsTrichotomous (List α) (List.Lex r))
instance
List.Lex.isStrictTotalOrder
{α : Type u}
(r : α → α → Prop)
[IsStrictTotalOrder α r]
:
IsStrictTotalOrder (List α) (List.Lex r)
Equations
- (_ : IsStrictTotalOrder (List α) (List.Lex 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)
theorem
List.head_le_of_lt
{α : Type u}
[LinearOrder α]
{a : α}
{a' : α}
{l : List α}
{l' : List α}
(h : a' :: l' < a :: l)
:
a' ≤ a
theorem
List.head!_le_of_lt
{α : Type u}
[LinearOrder α]
[Inhabited α]
(l : List α)
(l' : List α)
(h : l' < l)
(hl' : l' ≠ [])
:
List.head! l' ≤ List.head! l
theorem
List.cons_le_cons
{α : Type u}
[LinearOrder α]
(a : α)
{l : List α}
{l' : List α}
(h : l' ≤ l)
: