Documentation

Mathlib.Data.List.Pairwise

Pairwise relations on a list #

This file provides basic results about List.Pairwise and List.pwFilter (definitions are in Data.List.Defs). Pairwise R [a 0, ..., a (n - 1)] means ∀ i j, i < j → R (a i) (a j). For example, Pairwise (≠) l means that all elements of l are distinct, and Pairwise (<) l means that l is strictly increasing. pwFilter R l is the list obtained by iteratively adding each element of l that doesn't break the pairwiseness of the list we have so far. It thus yields l' a maximal sublist of l such that Pairwise R l'.

Tags #

sorted, nodup

theorem List.pairwise_iff {α : Type u} (R : α → α → Prop) (a✝ : List α) :
Pairwise R a✝ ↔ a✝ = [] ∨ ∃ (a : α), ∃ (l : List α), (∀ (a' : α), a' ∈ l → R a a') ∧ Pairwise R l ∧ a✝ = a :: l

Pairwise #

theorem List.Pairwise.forall_of_forall {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Symm R] (H₁ : ∀ (x : α), x ∈ l → R x x) (H₂ : Pairwise R l) ⦃x : α⦄ :
x ∈ l → ∀ ⦃y : α⦄, y ∈ l → R x y
theorem List.Pairwise.forall {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Symm R] (hl : Pairwise R l) ⦃a : α⦄ :
a ∈ l → ∀ ⦃b : α⦄, b ∈ l → a ≠ b → R a b
theorem List.Pairwise.set_pairwise {α : Type u_1} {R : α → α → Prop} {l : List α} (hl : Pairwise R l) [Std.Symm R] :
{x : α | x ∈ l}.Pairwise R
theorem List.pairwise_of_reflexive_of_forall_ne {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Refl R] (h : ∀ (a : α), a ∈ l → ∀ (b : α), b ∈ l → a ≠ b → R a b) :
theorem List.Pairwise.rel_head_tail {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} (h₁ : Pairwise R l) (ha : a ∈ l.tail) :
R (l.head ⋯) a
theorem List.Pairwise.rel_head_of_rel_head_head {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} (h₁ : Pairwise R l) (ha : a ∈ l) (hhead : R (l.head ⋯) (l.head ⋯)) :
R (l.head ⋯) a
theorem List.Pairwise.rel_head {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [Std.Refl R] (h₁ : Pairwise R l) (ha : a ∈ l) :
R (l.head ⋯) a
theorem List.Pairwise.rel_dropLast_getLast {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} (h : Pairwise R l) (ha : a ∈ l.dropLast) :
R a (l.getLast ⋯)
theorem List.Pairwise.rel_getLast_of_rel_getLast_getLast {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} (h₁ : Pairwise R l) (ha : a ∈ l) (hlast : R (l.getLast ⋯) (l.getLast ⋯)) :
R a (l.getLast ⋯)
theorem List.Pairwise.rel_getLast {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [Std.Refl R] (h₁ : Pairwise R l) (ha : a ∈ l) :
R a (l.getLast ⋯)
theorem List.Pairwise.reverse {α : Type u_1} {R : α → α → Prop} {l : List α} :
Pairwise (fun (a b : α) => R b a) l → Pairwise R l.reverse

Alias of the reverse direction of List.pairwise_reverse.

theorem List.Pairwise.of_reverse {α : Type u_1} {R : α → α → Prop} {l : List α} :
Pairwise R l.reverse → Pairwise (fun (a b : α) => R b a) l

Alias of the forward direction of List.pairwise_reverse.

theorem List.Pairwise.head!_le {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [Inhabited α] [Std.Refl R] (h : Pairwise R l) (ha : a ∈ l) :
R l.head! a
theorem List.pairwise_replicate_of_refl {α : Type u_1} {R : α → α → Prop} {a : α} {n : ℕ} [Std.Refl R] :

Pairwise filtering #

theorem List.Pairwise.pwFilter {α : Type u_1} {R : α → α → Prop} [DecidableRel R] {l : List α} :
Pairwise R l → pwFilter R l = l

Alias of the reverse direction of List.pwFilter_eq_self.

theorem List.pairwise_cons_cons_iff_of_trans {α : Type u_1} {R : α → α → Prop} [IsTrans α R] {l : List α} {a b : α} :
Pairwise R (a :: b :: l) ↔ R a b ∧ Pairwise R (b :: l)
theorem List.Pairwise.cons_cons_of_trans {α : Type u_1} {R : α → α → Prop} [IsTrans α R] {l : List α} {a b : α} :
R a b → Pairwise R (b :: l) → Pairwise R (a :: b :: l)
theorem List.Pairwise.rel_get_of_lt {α : Type u_1} {R : α → α → Prop} {l : List α} (h : Pairwise R l) {a b : Fin l.length} (hab : a < b) :
R (l.get a) (l.get b)
theorem List.Pairwise.rel_get_of_le {α : Type u_1} {R : α → α → Prop} [Std.Refl R] {l : List α} (h : Pairwise R l) {a b : Fin l.length} (hab : a ≤ b) :
R (l.get a) (l.get b)
theorem List.Pairwise.decide {α : Type u_1} {R : α → α → Prop} [DecidableRel R] (l : List α) (h : Pairwise R l) :
Pairwise (fun (a b : α) => Decidable.decide (R a b) = true) l