Lexicographic ordering #
instance Array.instIsLinearOrderOfLawfulOrderLT {α : Type u_1} [LT α] [LE α] [Std.LawfulOrderLT α] [Std.IsLinearOrder α] :
theorem Array.lt_irrefl {α : Type u_1} [LT α] [Std.Irrefl fun (x1 x2 : α) => x1 < x2] (xs : Array α) :
instance Array.ltIrrefl {α : Type u_1} [LT α] [Std.Irrefl fun (x1 x2 : α) => x1 < x2] :
Std.Irrefl fun (x1 x2 : Array α) => x1 < x2
theorem Array.le_refl {α : Type u_1} [LT α] [i₀ : Std.Irrefl fun (x1 x2 : α) => x1 < x2] (xs : Array α) :
theorem Array.lt_of_le_of_lt {α : Type u_1} [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearOrder α] {xs ys zs : Array α} (h₁ : xs ≤ ys) (h₂ : ys < zs) :
theorem Array.le_trans {α : Type u_1} [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearOrder α] {xs ys zs : Array α} (h₁ : xs ≤ ys) (h₂ : ys ≤ zs) :
@[instance_reducible]
instance Array.instTransLeOfLawfulOrderLTOfIsLinearOrder {α : Type u_1} [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearOrder α] :
Equations
- Array.instTransLeOfLawfulOrderLTOfIsLinearOrder = { trans := ⋯ }
theorem Array.le_antisymm {α : Type u_1} [LT α] [LE α] [Std.IsLinearOrder α] [Std.LawfulOrderLT α] {xs ys : Array α} :
@[instance_reducible]
instance Array.instDecidableLTOfDecidableEq {α : Type u_1} [DecidableEq α] [LT α] [DecidableLT α] :
DecidableLT (Array α)
Equations
- xs.instDecidableLTOfDecidableEq ys = decidable_of_iff ((xs.lex ys fun (x1 x2 : α) => decide (x1 < x2)) = true) ⋯
@[instance_reducible]
instance Array.instDecidableLEOfDecidableEqOfDecidableLT {α : Type u_1} [DecidableEq α] [LT α] [DecidableLT α] :
DecidableLE (Array α)
Equations
- xs.instDecidableLEOfDecidableEqOfDecidableLT ys = decidable_of_iff ((ys.lex xs fun (x1 x2 : α) => decide (x1 < x2)) = false) ⋯
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
isuch that- for all
j < i,l₁[j] == l₂[j]and l₁[i] < l₂[i]
- for all
theorem Array.lex_eq_false_iff_exists {α : Type u_1} {l₁ l₂ : Array α} [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₁ 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₁.lengthor- there exists an index
isuch 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)ltis irreflexive with respect to==(i.e. ifx == ythenlt x y = falseltis asymmetric (i.e.lt x y = true → lt y x = false)ltis antisymmetric with respect to==(i.e.lt x y = false → lt y x = false → x == y)
theorem Array.le_iff_exists {α : Type u_1} [LT α] [Std.Asymm fun (x1 x2 : α) => x1 < x2] [Std.Trichotomous fun (x1 x2 : α) => x1 < x2] {xs ys : Array α} :
theorem Array.le_append_left {α : Type u_1} [LT α] [Std.Irrefl fun (x1 x2 : α) => x1 < x2] {xs ys : Array α} :
theorem Array.map_le {α : Type u_1} {β : Type u_2} [LT α] [LT β] [Std.Asymm fun (x1 x2 : α) => x1 < x2] [Std.Trichotomous fun (x1 x2 : α) => x1 < x2] [Std.Asymm fun (x1 x2 : β) => x1 < x2] [Std.Trichotomous fun (x1 x2 : β) => x1 < x2] {xs ys : Array α} {f : α → β} (w : ∀ (x y : α), x < y → f x < f y) (h : xs ≤ ys) :
theorem Array.map_lt_map_iff_of_injective {α : Type u_1} {β : Type u_2} [LT α] [LT β] (f : α → β) (hf : ∀ (a b : α), f a < f b ↔ a < b) (hfinj : Function.Injective f) {xs ys : Array α} :
See map_lt_map_iff for a variant with fewer proof obligations for f but with some mild
assumptions on the order on α and β.
theorem Array.map_lt_map_iff {α : Type u_1} {β : Type u_2} [LT α] [Std.Trichotomous fun (x1 x2 : α) => x1 < x2] [LT β] [Std.Asymm fun (x1 x2 : β) => x1 < x2] (f : α → β) (hf : ∀ (a b : α), a < b → f a < f b) {xs ys : Array α} :
See map_lt_map_iff_of_injective for a variant which does not assume anything about the order
on α and β, but with more assumptions on f.
theorem Array.flatMap_lt_flatMap_iff {α : Type u_1} {β : Type u_2} [LT α] [Std.Trichotomous fun (x1 x2 : α) => x1 < x2] [LT β] [Std.Asymm fun (x1 x2 : β) => x1 < x2] (f : α → Array β) (hf : ∀ (a b : α), a < b → f a < f b) (hp : ∀ (a b : α) (zs : Array β), f a ++ zs = f b → a = b) (hx : ∀ (a : α), f a ≠ #[]) {xs ys : Array α} :
theorem Array.flatMap_le_flatMap_iff {α : Type u_1} {β : Type u_2} [LT α] [Std.Trichotomous fun (x1 x2 : α) => x1 < x2] [LT β] [Std.Asymm fun (x1 x2 : β) => x1 < x2] (f : α → Array β) (hf : ∀ (a b : α), a < b → f a < f b) (hp : ∀ (a b : α) (zs : Array β), f a ++ zs = f b → a = b) (hx : ∀ (a : α), f a ≠ #[]) {xs ys : Array α} :