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.Pairwise

33 declarations and 1 deprecated aliases. Mathlib docs · Source

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 pairwise property of the list we have so far. It thus yields l' as a maximal sublist of l such that Pairwise R l'.

Tags

sorted, nodup

Pairwise

Pairwise filtering

TFAE

theorem List.pairwise_iff E0 #

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

theorem List.pairwise_iff_forall_infix E1 #

∀ {α : Type u_2} {l : List α} {R : α → α → Prop},
  List.Pairwise R l ↔ ∀ (l' : List α) (h : 1 < l'.length), l' <:+: l → R (l'.head ⋯) (l'.getLast ⋯)

theorem List.Pairwise.forall_of_forall E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Symm R],
  (∀ x ∈ l, R x x) → List.Pairwise R l → ∀ ⦃x : α⦄, x ∈ l → ∀ ⦃y : α⦄, y ∈ l → R x y

theorem List.Pairwise.forall E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Symm R],
  List.Pairwise R l → ∀ ⦃a : α⦄, a ∈ l → ∀ ⦃b : α⦄, b ∈ l → a ≠ b → R a b

theorem List.Pairwise.set_pairwise E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α}, List.Pairwise R l → ∀ [Std.Symm R], {x | x ∈ l}.Pairwise R

theorem List.pairwise_of_reflexive_of_forall_ne E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} [Std.Refl R], (∀ a ∈ l, ∀ b ∈ l, a ≠ b → R a b) → List.Pairwise R l

theorem List.pairwise_append_of_mem E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l₁ l₂ : List α} {a b : α} [Std.Symm R] [IsTrans α R],
  a ∈ l₁ → b ∈ l₂ → (List.Pairwise R (l₁ ++ l₂) ↔ R a b ∧ List.Pairwise R l₁ ∧ List.Pairwise R l₂)

theorem List.pairwise_cons_of_mem E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a b : α} [Std.Symm R] [IsTrans α R],
  b ∈ l → (List.Pairwise R (a :: l) ↔ R a b ∧ List.Pairwise R l)

theorem List.Pairwise.rel_head_tail E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α}, List.Pairwise R l → ∀ (ha : a ∈ l.tail), R (l.head ⋯) a

theorem List.Pairwise.rel_head_of_rel_head_head E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α},
  List.Pairwise R l → ∀ (ha : a ∈ l), R (l.head ⋯) (l.head ⋯) → R (l.head ⋯) a

theorem List.Pairwise.rel_head E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [Std.Refl R],
  List.Pairwise R l → ∀ (ha : a ∈ l), R (l.head ⋯) a

theorem List.Pairwise.rel_dropLast_getLast E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α}, List.Pairwise R l → ∀ (ha : a ∈ l.dropLast), R a (l.getLast ⋯)

theorem List.Pairwise.rel_getLast_of_rel_getLast_getLast E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α},
  List.Pairwise R l → ∀ (ha : a ∈ l), R (l.getLast ⋯) (l.getLast ⋯) → R a (l.getLast ⋯)

theorem List.Pairwise.rel_getLast E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [Std.Refl R],
  List.Pairwise R l → ∀ (ha : a ∈ l), R a (l.getLast ⋯)

theorem List.Pairwise.of_reverse E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α}, List.Pairwise R l.reverse → List.Pairwise (fun a b ↦ R b a) l

Alias of the forward direction of List.pairwise_reverse.

theorem List.Pairwise.reverse E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α}, List.Pairwise (fun a b ↦ R b a) l → List.Pairwise R l.reverse

Alias of the reverse direction of List.pairwise_reverse.

theorem List.Pairwise.head!_le E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α} {a : α} [inst : Inhabited α] [Std.Refl R],
  List.Pairwise R l → a ∈ l → R l.head! a

theorem List.pairwise_replicate_of_refl E1 #

∀ {α : Type u_1} {R : α → α → Prop} {a : α} {n : ℕ} [Std.Refl R], List.Pairwise R (List.replicate n a)

theorem List.Pairwise.pwFilter E1 #

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

Alias of the reverse direction of List.pwFilter_eq_self.

theorem List.pairwise_cons_cons_iff_of_trans E1 #

∀ {α : Type u_1} {R : α → α → Prop} [IsTrans α R] {l : List α} {a b : α},
  List.Pairwise R (a :: b :: l) ↔ R a b ∧ List.Pairwise R (b :: l)

theorem List.Pairwise.cons_cons_of_trans E1 #

∀ {α : Type u_1} {R : α → α → Prop} [IsTrans α R] {l : List α} {a b : α},
  R a b → List.Pairwise R (b :: l) → List.Pairwise R (a :: b :: l)

theorem List.Pairwise.rel_get_of_lt E1 #

∀ {α : Type u_1} {R : α → α → Prop} {l : List α},
  List.Pairwise R l → ∀ {a b : Fin l.length}, a < b → R (l.get a) (l.get b)

theorem List.Pairwise.rel_get_of_le E1 #

∀ {α : Type u_1} {R : α → α → Prop} [Std.Refl R] {l : List α},
  List.Pairwise R l → ∀ {a b : Fin l.length}, a ≤ b → R (l.get a) (l.get b)

theorem List.Pairwise.decide E1 #

∀ {α : Type u_1} {R : α → α → Prop} [inst : DecidableRel R] (l : List α),
  List.Pairwise R l → List.Pairwise (fun a b ↦ decide (R a b) = true) l

theorem List.tfae_iff_pairwise E1 #

∀ {l : List Prop}, l.TFAE ↔ List.Pairwise (fun x1 x2 ↦ x1 ↔ x2) l

theorem List.tfae_append E1 #

∀ {l₁ l₂ : List Prop}, (l₁ ++ l₂).TFAE ↔ l₁.TFAE ∧ l₂.TFAE ∧ ∀ a ∈ l₁, ∀ b ∈ l₂, a ↔ b

theorem List.tfae_append_of_mem E1 #

∀ {a b : Prop} {l₁ l₂ : List Prop}, a ∈ l₁ → b ∈ l₂ → ((l₁ ++ l₂).TFAE ↔ (a ↔ b) ∧ l₁.TFAE ∧ l₂.TFAE)

theorem List.tfae_cons E1 #

∀ {a b : Prop} {l : List Prop}, b ∈ l → ((a :: l).TFAE ↔ (a ↔ b) ∧ l.TFAE)

theorem List.tfae_cons_of_mem E0 #

∀ {a : Prop} {l : List Prop}, a ∈ l → ((a :: l).TFAE ↔ l.TFAE)

theorem List.tfae_concat E1 #

∀ {a b : Prop} {l : List Prop}, b ∈ l → ((l ++ [a]).TFAE ↔ (a ↔ b) ∧ l.TFAE)

theorem List.tfae_concat_of_mem E0 #

∀ {a : Prop} {l : List Prop}, a ∈ l → ((l ++ [a]).TFAE ↔ l.TFAE)

theorem List.tfae_cons_cons E1 #

∀ {a b : Prop} {l : List Prop}, (a :: b :: l).TFAE ↔ (a ↔ b) ∧ (b :: l).TFAE

theorem List.tfae_of_cycle E1 #

∀ {a b : Prop} {l : List Prop},
  List.IsChain (fun x1 x2 ↦ x1 → x2) (a :: b :: l) → (l.getLastD b → a) → (a :: b :: l).TFAE

Deprecated aliases

NameNew nameSince
List.tfae_cons_selfList.tfae_cons_of_mem2026-08-14