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

22 declarations. Mathlib docs · Source

ctor List.Interleaves.below.nil_nil E0 #

∀ {α : Type u_1} {r : α → α → Prop} {motive : (a a_1 : List α) → List.Interleaves r a a_1 → Prop},
  List.Interleaves.below ⋯

ctor List.Interleaves.below.nil_singleton E0 #

∀ {α : Type u_1} {r : α → α → Prop} {motive : (a a_1 : List α) → List.Interleaves r a a_1 → Prop} (a : α),
  List.Interleaves.below ⋯

ctor List.Interleaves.below.cons_symm E0 #

∀ {α : Type u_1} {r : α → α → Prop} {motive : (a a_1 : List α) → List.Interleaves r a a_1 → Prop} ⦃a b : α⦄
  (hab : r a b) ⦃l₁ l₂ : List α⦄ (hl : List.Interleaves r l₁ (b :: l₂)),
  List.Interleaves.below hl → motive l₁ (b :: l₂) hl → List.Interleaves.below ⋯

inductive List.Interleaves E1 #

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

Relation for interleaving lists. l₁.Interleaves l₂ r means that l₁ r-interleaves l₂, i.e. the length of l₂ is either the length of l₁ or one more and for each i the i-th rightmost element of l₁ is r-related to both the i-th and i + 1-st rightmost elements of l₂, except possibly when i = l₁.length.

For example, [1, 3] (· ≤ ·)-interleaves both of [0, 2, 4] and [0, 2].

See interleaves_iff_length_isChain_interleave for the connection with List.interleave.

theorem List.interleaves_iff E0 #

∀ {α : Type u_1} (r : α → α → Prop) (a a_1 : List α),
  List.Interleaves r a a_1 ↔
    a = [] ∧ a_1 = [] ∨
      (∃ a_2, a = [] ∧ a_1 = [a_2]) ∨
        ∃ a_2 b, r a_2 b ∧ ∃ l₁ l₂, List.Interleaves r l₁ (b :: l₂) ∧ a = b :: l₂ ∧ a_1 = a_2 :: l₁

ctor List.Interleaves.nil_nil E0 #

∀ {α : Type u_1} {r : α → α → Prop}, List.Interleaves r [] []

The empty list interleaves itself.

ctor List.Interleaves.nil_singleton E0 #

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

The empty list interleaves any singleton list.

ctor List.Interleaves.cons_symm E0 #

∀ {α : Type u_1} {r : α → α → Prop} ⦃a b : α⦄,
  r a b → ∀ ⦃l₁ l₂ : List α⦄, List.Interleaves r l₁ (b :: l₂) → List.Interleaves r (b :: l₂) (a :: l₁)

If l₁ interleaves b :: l₂ and a is related to b, then b :: l₂ interleaves a :: l₁.

theorem List.interleaves_nil_cons E0 #

∀ {α : Type u_1} {r : α → α → Prop} {l : List α} {a : α}, List.Interleaves r [] (a :: l) ↔ l = []

theorem List.not_interleaves_cons_nil E0 #

∀ {α : Type u_1} {r : α → α → Prop} {l : List α} {a : α}, ¬List.Interleaves r (a :: l) []

theorem List.interleaves_cons_cons E0 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α} {a b : α},
  List.Interleaves r (a :: l₁) (b :: l₂) ↔ r b a ∧ List.Interleaves r l₂ (a :: l₁)

theorem List.interleaves_singleton_singleton E0 #

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

theorem List.Interleaves.mono E1 #

∀ {α : Type u_1} {r s : α → α → Prop},
  (∀ ⦃a b : α⦄, r a b → s a b) → ∀ (l₁ l₂ : List α), List.Interleaves r l₁ l₂ → List.Interleaves s l₁ l₂

theorem List.interleaves_iff_length_isChain_interleave E1 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α},
  List.Interleaves r l₁ l₂ ↔ l₁.length ⩿ l₂.length ∧ List.IsChain r (l₂.interleave l₁)

theorem List.interleaves_append_singleton_append_singleton_of_length_eq_length E0 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α} {a b : α},
  l₁.length = l₂.length → (List.Interleaves r (l₁ ++ [a]) (l₂ ++ [b]) ↔ r b a ∧ List.Interleaves r l₁ (l₂ ++ [b]))

theorem List.interleaves_append_singleton_append_singleton_of_length_eq_length_add_one E0 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α} {a b : α},
  l₁.length + 1 = l₂.length → (List.Interleaves r (l₁ ++ [a]) (l₂ ++ [b]) ↔ r a b ∧ List.Interleaves r (l₁ ++ [a]) l₂)

theorem List.interleaves_reverse_reverse_of_length_eq_length E1 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α},
  l₁.length = l₂.length → (List.Interleaves r l₁.reverse l₂.reverse ↔ List.Interleaves (Function.swap r) l₂ l₁)

theorem List.interleaves_reverse_reverse_of_length_eq_length_add_one E1 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α},
  l₁.length + 1 = l₂.length → (List.Interleaves r l₁.reverse l₂.reverse ↔ List.Interleaves (Function.swap r) l₁ l₂)

theorem List.interleaves_ofFn_even E1 #

∀ {α : Type u_1} {r : α → α → Prop} {n : ℕ} {f g : Fin n → α},
  List.Interleaves r (List.ofFn f) (List.ofFn g) ↔
    (∀ (i : Fin n), r (g i) (f i)) ∧ ∀ (i : ℕ) (hi : i + 1 < n), r (f ⟨i, ⋯⟩) (g ⟨i + 1, hi⟩)

theorem List.interleaves_ofFn_odd E1 #

∀ {α : Type u_1} {r : α → α → Prop} {n : ℕ} {f : Fin n → α} {g : Fin (n + 1) → α},
  List.Interleaves r (List.ofFn f) (List.ofFn g) ↔
    (∀ (i : Fin n), r (f i) (g i.succ)) ∧ ∀ (i : Fin n), r (g i.castSucc) (f i)

theorem List.Interleaves.pairwise_left E1 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α} [IsTrans α r], List.Interleaves r l₁ l₂ → List.Pairwise r l₁

theorem List.Interleaves.pairwise_right E1 #

∀ {α : Type u_1} {r : α → α → Prop} {l₁ l₂ : List α} [IsTrans α r], List.Interleaves r l₁ l₂ → List.Pairwise r l₂