The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.List.Shortlex

16 declarations. Mathlib docs · Source

Shortlex ordering of lists.

Given a relation r on α, the shortlex order on List α is defined by L < M iff

  • L.length < M.length
  • L.length = M.length and L < M under the lexicographic ordering over r on lists

Main results

We show that if r is well-founded, so too is the shortlex order over r

See also

Related files are:

  • Mathlib/Data/List/Lex.lean: Lexicographic order on List α.
  • Mathlib/Data/DFinsupp/WellFounded.lean: Well-foundedness of lexicographic orders on DFinsupp and Pi.

shortlex ordering

def List.Shortlex E1 #

{α : Type u_1} → (α → α → Prop) → List α → List α → Prop

Given a relation r on α, the shortlex order on List α, for which [a0, ..., an] < [b0, ..., b_k] if n < k or n = k and [a0, ..., an] < [b0, ..., bk] under the lexicographic order induced by r.

theorem List.Shortlex.of_length_lt E1 #

∀ {α : Type u_1} {r : α → α → Prop} {s t : List α}, s.length < t.length → List.Shortlex r s t

If a list s is shorter than a list t, then s is smaller than t under any shortlex order.

theorem List.Shortlex.of_lex E1 #

∀ {α : Type u_1} {r : α → α → Prop} {s t : List α}, s.length = t.length → List.Lex r s t → List.Shortlex r s t

If two lists s and t have the same length, s is smaller than t under the shortlex order over a relation r when s is smaller than t under the lexicographic order over r

theorem List.shortlex_def E0 #

∀ {α : Type u_1} {r : α → α → Prop} {s t : List α},
  List.Shortlex r s t ↔ s.length < t.length ∨ s.length = t.length ∧ List.Lex r s t

theorem List.shortlex_iff_lex E1 #

∀ {α : Type u_1} {r : α → α → Prop} {s t : List α}, s.length = t.length → (List.Shortlex r s t ↔ List.Lex r s t)

If two lists s and t have the same length, s is smaller than t under the shortlex order over a relation r exactly when s is smaller than t under the lexicographic order over r.

theorem List.shortlex_cons_iff E0 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Irrefl r] {a : α} {s t : List α},
  List.Shortlex r (a :: s) (a :: t) ↔ List.Shortlex r s t

theorem List.Shortlex.of_cons E1 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Irrefl r] {a : α} {s t : List α},
  List.Shortlex r (a :: s) (a :: t) → List.Shortlex r s t

Alias of the forward direction of List.shortlex_cons_iff.

theorem List.Shortlex.cons E1 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Irrefl r] {a : α} {s t : List α},
  List.Shortlex r s t → List.Shortlex r (a :: s) (a :: t)

Alias of the reverse direction of List.shortlex_cons_iff.

theorem List.not_shortlex_nil_right E0 #

∀ {α : Type u_1} {r : α → α → Prop} {s : List α}, ¬List.Shortlex r s []

theorem List.shortlex_nil_or_eq_nil E1 #

∀ {α : Type u_1} {r : α → α → Prop} (s : List α), List.Shortlex r [] s ∨ s = []

theorem List.shortlex_singleton_iff E0 #

∀ {α : Type u_1} {r : α → α → Prop} (a b : α), List.Shortlex r [a] [b] ↔ r a b

instance List.Shortlex.trichotomous E0 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Trichotomous r], Std.Trichotomous (List.Shortlex r)

instance List.Shortlex.asymm E0 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Asymm r], Std.Asymm (List.Shortlex r)

theorem List.Shortlex.append_right E1 #

∀ {α : Type u_1} {r : α → α → Prop} {s₁ s₂ : List α} (t : List α), List.Shortlex r s₁ s₂ → List.Shortlex r s₁ (s₂ ++ t)

theorem List.Shortlex.append_left E1 #

∀ {α : Type u_1} {r : α → α → Prop} {t₁ t₂ : List α},
  List.Shortlex r t₁ t₂ → ∀ (s : List α), List.Shortlex r (s ++ t₁) (s ++ t₂)

theorem List.Shortlex.wf E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded r → WellFounded (List.Shortlex r)