Lexicographic ordering #
theorem
Vector.not_le_iff_gt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
(l₁ l₂ : Vector α n)
:
theorem
Vector.lt_irrefl
{α : Type u_1}
{n : Nat}
[LT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
(l : Vector α n)
:
instance
Vector.ltIrrefl
{α : Type u_1}
{n : Nat}
[LT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
:
Std.Irrefl fun (x1 x2 : Vector α n) => x1 < x2
theorem
Vector.le_refl
{α : Type u_1}
{n : Nat}
[LT α]
[i₀ : Std.Irrefl fun (x1 x2 : α) => x1 < x2]
(l : Vector α n)
:
instance
Vector.instReflLeOfIrreflLt
{α : Type u_1}
{n : Nat}
[LT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
:
instance
Vector.instTransLt
{α : Type u_1}
{n : Nat}
[LT α]
[Trans (fun (x1 x2 : α) => x1 < x2) (fun (x1 x2 : α) => x1 < x2) fun (x1 x2 : α) => x1 < x2]
:
Equations
- Vector.instTransLt = { trans := ⋯ }
theorem
Vector.lt_of_le_of_lt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[i₀ : Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[i₁ : Std.Asymm fun (x1 x2 : α) => x1 < x2]
[i₂ : Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
[i₃ : Trans (fun (x1 x2 : α) => ¬x1 < x2) (fun (x1 x2 : α) => ¬x1 < x2) fun (x1 x2 : α) => ¬x1 < x2]
{l₁ l₂ l₃ : Vector α n}
(h₁ : l₁ ≤ l₂)
(h₂ : l₂ < l₃)
:
theorem
Vector.le_trans
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
[Trans (fun (x1 x2 : α) => ¬x1 < x2) (fun (x1 x2 : α) => ¬x1 < x2) fun (x1 x2 : α) => ¬x1 < x2]
{l₁ l₂ l₃ : Vector α n}
(h₁ : l₁ ≤ l₂)
(h₂ : l₂ ≤ l₃)
:
instance
Vector.instTransLeOfDecidableEqOfDecidableLTOfIrreflOfAsymmOfAntisymmOfNotLt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
[Trans (fun (x1 x2 : α) => ¬x1 < x2) (fun (x1 x2 : α) => ¬x1 < x2) fun (x1 x2 : α) => ¬x1 < x2]
:
Equations
instance
Vector.instAsymmLtOfDecidableEqOfDecidableLT
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
:
theorem
Vector.le_total
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[i : Std.Total fun (x1 x2 : α) => ¬x1 < x2]
(l₁ l₂ : Vector α n)
:
instance
Vector.instTotalLeOfDecidableEqOfDecidableLTOfNotLt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Total fun (x1 x2 : α) => ¬x1 < x2]
:
@[simp]
theorem
Vector.not_le
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
{l₁ l₂ : Vector α n}
:
theorem
Vector.le_of_lt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[i : Std.Total fun (x1 x2 : α) => ¬x1 < x2]
{l₁ l₂ : Vector α n}
(h : l₁ < l₂)
:
theorem
Vector.le_iff_lt_or_eq
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
[Std.Total fun (x1 x2 : α) => ¬x1 < x2]
{l₁ l₂ : Vector α n}
:
@[simp]
theorem
Vector.lex_eq_true_iff_lt
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
{l₁ l₂ : Vector α n}
:
@[simp]
theorem
Vector.lex_eq_false_iff_ge
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
{l₁ l₂ : Vector α n}
:
instance
Vector.instDecidableLTOfDecidableEq
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
:
DecidableLT (Vector α n)
Equations
- l₁.instDecidableLTOfDecidableEq l₂ = decidable_of_iff ((l₁.lex l₂ fun (x1 x2 : α) => decide (x1 < x2)) = true) ⋯
instance
Vector.instDecidableLEOfDecidableEqOfDecidableLT
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
:
DecidableLE (Vector α n)
Equations
- l₁.instDecidableLEOfDecidableEqOfDecidableLT l₂ = decidable_of_iff ((l₂.lex l₁ fun (x1 x2 : α) => decide (x1 < x2)) = false) ⋯
theorem
Vector.lex_eq_true_iff_exists
{α : Type u_1}
{n : Nat}
[BEq α]
(lt : α → α → Bool)
{l₁ l₂ : Vector α n}
:
l₁
is lexicographically less than l₂
if either
l₁
is pairwise equivalent under· == ·
tol₂.take l₁.size
, andl₁
is shorter thanl₂
or- there exists an index
i
such that- for all
j < i
,l₁[j] == l₂[j]
and l₁[i] < l₂[i]
- for all
theorem
Vector.lex_eq_false_iff_exists
{α : Type u_1}
{n : Nat}
[BEq α]
[PartialEquivBEq α]
(lt : α → α → Bool)
(lt_irrefl : ∀ (x y : α), (x == y) = true → lt x y = false)
(lt_asymm : ∀ (x y : α), lt x y = true → lt y x = false)
(lt_antisymm : ∀ (x y : α), lt x y = false → lt y x = false → (x == y) = true)
{l₁ l₂ : Vector α n}
:
l₁
is not lexicographically less than l₂
(which you might think of as "l₂
is lexicographically greater than or equal to l₁
"") if either
l₁
is pairwise equivalent under· == ·
tol₂.take l₁.length
or- there exists an index
i
such that- for all
j < i
,l₁[j] == l₂[j]
and l₂[i] < l₁[i]
- for all
This formulation requires that ==
and lt
are compatible in the following senses:
==
is symmetric (we unnecessarily further assume it is transitive, to make use of the existing typeclasses)lt
is irreflexive with respect to==
(i.e. ifx == y
thenlt x y = false
lt
is asymmmetric (i.e.lt x y = true → lt y x = false
)lt
is antisymmetric with respect to==
(i.e.lt x y = false → lt y x = false → x == y
)
theorem
Vector.le_iff_exists
{α : Type u_1}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
{l₁ l₂ : Vector α n}
:
theorem
Vector.append_left_le
{α : Type u_1}
{n m : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
{l₁ : Vector α n}
{l₂ l₃ : Vector α m}
(h : l₂ ≤ l₃)
:
theorem
Vector.map_le
{α : Type u_1}
{β : Type u_2}
{n : Nat}
[DecidableEq α]
[LT α]
[DecidableLT α]
[DecidableEq β]
[LT β]
[DecidableLT β]
[Std.Irrefl fun (x1 x2 : α) => x1 < x2]
[Std.Asymm fun (x1 x2 : α) => x1 < x2]
[Std.Antisymm fun (x1 x2 : α) => ¬x1 < x2]
[Std.Irrefl fun (x1 x2 : β) => x1 < x2]
[Std.Asymm fun (x1 x2 : β) => x1 < x2]
[Std.Antisymm fun (x1 x2 : β) => ¬x1 < x2]
{l₁ l₂ : Vector α n}
{f : α → β}
(w : ∀ (x y : α), x < y → f x < f y)
(h : l₁ ≤ l₂)
: