Interleaving lists #
This file defines interleaving of lists as a relation.
See also #
Interleaving of lists as an operation is defined in Batteries/Data/List/Interleave.lean.
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.
- nil_nil {α : Type u_1} {r : α → α → Prop} : Interleaves r [] []
The empty list interleaves itself.
- nil_singleton {α : Type u_1} {r : α → α → Prop} (a : α) : Interleaves r [] [a]
The empty list interleaves any singleton list.
- cons_symm {α : Type u_1} {r : α → α → Prop} ⦃a b : α⦄ (hab : r a b) ⦃l₁ l₂ : List α⦄ (hl : Interleaves r l₁ (b :: l₂)) : Interleaves r (b :: l₂) (a :: l₁)
If
l₁interleavesb :: l₂andais related tob, thenb :: l₂interleavesa :: l₁.