# Documentation

Mathlib.Data.List.Infix

# Prefixes, subfixes, infixes #

• List.prefix: l₁ is a prefix of l₂ if l₂ starts with l₁.
• List.subfix: l₁ is a subfix of l₂ if l₂ ends with l₁.
• List.infix: l₁ is an infix of l₂ if l₁ is a prefix of some subfix of l₂.
• List.inits: The list of prefixes of a list.
• List.tails: The list of prefixes of a list.
• insert on lists

All those (except insert) are defined in Mathlib.Data.List.Defs.

## Notation #

l₁ <+: l₂: l₁ is a prefix of l₂. l₁ <:+ l₂: l₁ is a subfix of l₂. l₁ <:+: l₂: l₁ is an infix of l₂.

### prefix, suffix, infix #

@[simp]
theorem List.prefix_append {α : Type u_1} (l₁ : List α) (l₂ : List α) :
l₁ <+: l₁ ++ l₂
@[simp]
theorem List.suffix_append {α : Type u_1} (l₁ : List α) (l₂ : List α) :
l₂ <:+ l₁ ++ l₂
theorem List.infix_append {α : Type u_1} (l₁ : List α) (l₂ : List α) (l₃ : List α) :
l₂ <:+: l₁ ++ l₂ ++ l₃
@[simp]
theorem List.infix_append' {α : Type u_1} (l₁ : List α) (l₂ : List α) (l₃ : List α) :
l₂ <:+: l₁ ++ (l₂ ++ l₃)
theorem List.isPrefix.isInfix {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <+: l₂l₁ <:+: l₂
theorem List.isSuffix.isInfix {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+ l₂l₁ <:+: l₂
theorem List.nil_prefix {α : Type u_1} (l : List α) :
[] <+: l
theorem List.nil_suffix {α : Type u_1} (l : List α) :
[] <:+ l
theorem List.nil_infix {α : Type u_1} (l : List α) :
[] <:+: l
theorem List.prefix_refl {α : Type u_1} (l : List α) :
l <+: l
theorem List.suffix_refl {α : Type u_1} (l : List α) :
l <:+ l
theorem List.infix_refl {α : Type u_1} (l : List α) :
l <:+: l
theorem List.prefix_rfl {α : Type u_1} {l : List α} :
l <+: l
theorem List.suffix_rfl {α : Type u_1} {l : List α} :
l <:+ l
theorem List.infix_rfl {α : Type u_1} {l : List α} :
l <:+: l
@[simp]
theorem List.suffix_cons {α : Type u_1} (a : α) (l : List α) :
l <:+ a :: l
theorem List.prefix_concat {α : Type u_1} (a : α) (l : List α) :
l <+:
theorem List.infix_cons {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} :
l₁ <:+: l₂l₁ <:+: a :: l₂
theorem List.infix_concat {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} :
l₁ <:+: l₂l₁ <:+: List.concat l₂ a
theorem List.isPrefix.trans {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} :
l₁ <+: l₂l₂ <+: l₃l₁ <+: l₃
theorem List.isSuffix.trans {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} :
l₁ <:+ l₂l₂ <:+ l₃l₁ <:+ l₃
theorem List.isInfix.trans {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} :
l₁ <:+: l₂l₂ <:+: l₃l₁ <:+: l₃
theorem List.isInfix.sublist {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+: l₂List.Sublist l₁ l₂
theorem List.isInfix.subset {α : Type u_1} {l₁ : List α} {l₂ : List α} (hl : l₁ <:+: l₂) :
l₁ l₂
theorem List.isPrefix.sublist {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <+: l₂) :
List.Sublist l₁ l₂
theorem List.isPrefix.subset {α : Type u_1} {l₁ : List α} {l₂ : List α} (hl : l₁ <+: l₂) :
l₁ l₂
theorem List.isSuffix.sublist {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <:+ l₂) :
List.Sublist l₁ l₂
theorem List.isSuffix.subset {α : Type u_1} {l₁ : List α} {l₂ : List α} (hl : l₁ <:+ l₂) :
l₁ l₂
@[simp]
theorem List.reverse_suffix {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <+: l₂
@[simp]
theorem List.reverse_prefix {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+ l₂
@[simp]
theorem List.reverse_infix {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+: l₂
theorem List.isSuffix.reverse {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+ l₂

Alias of the reverse direction of List.reverse_prefix.

theorem List.isPrefix.reverse {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <+: l₂

Alias of the reverse direction of List.reverse_suffix.

theorem List.isInfix.reverse {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+: l₂

Alias of the reverse direction of List.reverse_infix.

theorem List.isInfix.length_le {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <:+: l₂) :
theorem List.isPrefix.length_le {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <+: l₂) :
theorem List.isSuffix.length_le {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <:+ l₂) :
theorem List.eq_nil_of_infix_nil {α : Type u_1} {l : List α} (h : l <:+: []) :
l = []
@[simp]
theorem List.infix_nil_iff {α : Type u_1} {l : List α} :
l <:+: [] l = []
@[simp]
theorem List.prefix_nil_iff {α : Type u_1} {l : List α} :
l <+: [] l = []
@[simp]
theorem List.suffix_nil_iff {α : Type u_1} {l : List α} :
l <:+ [] l = []
theorem List.eq_nil_of_prefix_nil {α : Type u_1} {l : List α} :
l <+: []l = []

Alias of the forward direction of List.prefix_nil_iff.

theorem List.eq_nil_of_suffix_nil {α : Type u_1} {l : List α} :
l <:+ []l = []

Alias of the forward direction of List.suffix_nil_iff.

theorem List.infix_iff_prefix_suffix {α : Type u_1} (l₁ : List α) (l₂ : List α) :
l₁ <:+: l₂ t, l₁ <+: t t <:+ l₂
theorem List.eq_of_infix_of_length_eq {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <:+: l₂) :
= l₁ = l₂
theorem List.eq_of_prefix_of_length_eq {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <+: l₂) :
= l₁ = l₂
theorem List.eq_of_suffix_of_length_eq {α : Type u_1} {l₁ : List α} {l₂ : List α} (h : l₁ <:+ l₂) :
= l₁ = l₂
theorem List.prefix_of_prefix_length_le {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} :
l₁ <+: l₃l₂ <+: l₃ l₁ <+: l₂
theorem List.prefix_or_prefix_of_prefix {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} (h₁ : l₁ <+: l₃) (h₂ : l₂ <+: l₃) :
l₁ <+: l₂ l₂ <+: l₁
theorem List.suffix_of_suffix_length_le {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) (ll : ) :
l₁ <:+ l₂
theorem List.suffix_or_suffix_of_suffix {α : Type u_1} {l₁ : List α} {l₂ : List α} {l₃ : List α} (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) :
l₁ <:+ l₂ l₂ <:+ l₁
theorem List.suffix_cons_iff {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} :
l₁ <:+ a :: l₂ l₁ = a :: l₂ l₁ <:+ l₂
theorem List.infix_cons_iff {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} :
l₁ <:+: a :: l₂ l₁ <+: a :: l₂ l₁ <:+: l₂
theorem List.infix_of_mem_join {α : Type u_1} {l : List α} {L : List (List α)} :
l L
theorem List.prefix_append_right_inj {α : Type u_1} {l₁ : List α} {l₂ : List α} (l : List α) :
l ++ l₁ <+: l ++ l₂ l₁ <+: l₂
theorem List.prefix_cons_inj {α : Type u_1} {l₁ : List α} {l₂ : List α} (a : α) :
a :: l₁ <+: a :: l₂ l₁ <+: l₂
theorem List.take_prefix {α : Type u_1} (n : ) (l : List α) :
<+: l
theorem List.drop_suffix {α : Type u_1} (n : ) (l : List α) :
<:+ l
theorem List.take_sublist {α : Type u_1} (n : ) (l : List α) :
theorem List.drop_sublist {α : Type u_1} (n : ) (l : List α) :
theorem List.take_subset {α : Type u_1} (n : ) (l : List α) :
l
theorem List.drop_subset {α : Type u_1} (n : ) (l : List α) :
l
theorem List.mem_of_mem_take {α : Type u_1} {l : List α} {a : α} {n : } (h : a ) :
a l
theorem List.dropSlice_sublist {α : Type u_1} (n : ) (m : ) (l : List α) :
theorem List.dropSlice_subset {α : Type u_1} (n : ) (m : ) (l : List α) :
l
theorem List.mem_of_mem_dropSlice {α : Type u_1} {n : } {m : } {l : List α} {a : α} (h : a ) :
a l
theorem List.takeWhile_prefix {α : Type u_1} {l : List α} (p : αBool) :
<+: l
theorem List.dropWhile_suffix {α : Type u_1} {l : List α} (p : αBool) :
<:+ l
theorem List.dropLast_prefix {α : Type u_1} (l : List α) :
theorem List.tail_suffix {α : Type u_1} (l : List α) :
<:+ l
theorem List.dropLast_sublist {α : Type u_1} (l : List α) :
theorem List.tail_sublist {α : Type u_1} (l : List α) :
theorem List.dropLast_subset {α : Type u_1} (l : List α) :
theorem List.tail_subset {α : Type u_1} (l : List α) :
l
theorem List.mem_of_mem_dropLast {α : Type u_1} {l : List α} {a : α} (h : ) :
a l
theorem List.mem_of_mem_tail {α : Type u_1} {l : List α} {a : α} (h : a ) :
a l
theorem List.prefix_iff_eq_append {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <+: l₂ l₁ ++ List.drop () l₂ = l₂
theorem List.suffix_iff_eq_append {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+ l₂ List.take ( - ) l₂ ++ l₁ = l₂
theorem List.prefix_iff_eq_take {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <+: l₂ l₁ = List.take () l₂
theorem List.suffix_iff_eq_drop {α : Type u_1} {l₁ : List α} {l₂ : List α} :
l₁ <:+ l₂ l₁ = List.drop ( - ) l₂
instance List.decidablePrefix {α : Type u_1} [inst : ] (l₁ : List α) (l₂ : List α) :
Decidable (l₁ <+: l₂)
Equations
instance List.decidableSuffix {α : Type u_1} [inst : ] (l₁ : List α) (l₂ : List α) :
Decidable (l₁ <:+ l₂)
Equations
instance List.decidableInfix {α : Type u_1} [inst : ] (l₁ : List α) (l₂ : List α) :
Decidable (l₁ <:+: l₂)
Equations
theorem List.prefix_take_le_iff {α : Type u_1} {m : } {n : } {L : List (List ())} (hm : m < ) :
<+: m n
theorem List.cons_prefix_iff {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} {b : α} :
a :: l₁ <+: b :: l₂ a = b l₁ <+: l₂
theorem List.isPrefix.map {α : Type u_1} {β : Type u_2} {l₁ : List α} {l₂ : List α} (h : l₁ <+: l₂) (f : αβ) :
List.map f l₁ <+: List.map f l₂
theorem List.isPrefix.filter_map {α : Type u_1} {β : Type u_2} {l₁ : List α} {l₂ : List α} (h : l₁ <+: l₂) (f : α) :
<+:
theorem List.isPrefix.reduceOption {α : Type u_1} {l₁ : List ()} {l₂ : List ()} (h : l₁ <+: l₂) :
theorem List.isPrefix.filter {α : Type u_1} (p : αBool) ⦃l₁ : List α ⦃l₂ : List α (h : l₁ <+: l₂) :
theorem List.isSuffix.filter {α : Type u_1} (p : αBool) ⦃l₁ : List α ⦃l₂ : List α (h : l₁ <:+ l₂) :
theorem List.isInfix.filter {α : Type u_1} (p : αBool) ⦃l₁ : List α ⦃l₂ : List α (h : l₁ <:+: l₂) :
instance List.instIsPartialOrderListIsPrefix {α : Type u_1} :
IsPartialOrder (List α) fun x x_1 => x <+: x_1
Equations
instance List.instIsPartialOrderListIsSuffix {α : Type u_1} :
IsPartialOrder (List α) fun x x_1 => x <:+ x_1
Equations
instance List.instIsPartialOrderListIsInfix {α : Type u_1} :
IsPartialOrder (List α) fun x x_1 => x <:+: x_1
Equations
@[simp]
theorem List.mem_inits {α : Type u_1} (s : List α) (t : List α) :
s s <+: t
@[simp]
theorem List.mem_tails {α : Type u_1} (s : List α) (t : List α) :
s s <:+ t
theorem List.inits_cons {α : Type u_1} (a : α) (l : List α) :
List.inits (a :: l) = [] :: List.map (fun t => a :: t) ()
theorem List.tails_cons {α : Type u_1} (a : α) (l : List α) :
List.tails (a :: l) = (a :: l) ::
@[simp]
theorem List.inits_append {α : Type u_1} (s : List α) (t : List α) :
List.inits (s ++ t) = ++ List.map (fun l => s ++ l) ()
@[simp]
theorem List.tails_append {α : Type u_1} (s : List α) (t : List α) :
List.tails (s ++ t) = List.map (fun l => l ++ t) () ++
theorem List.inits_eq_tails {α : Type u_1} (l : List α) :
= List.reverse (List.map List.reverse ())
theorem List.tails_eq_inits {α : Type u_1} (l : List α) :
= List.reverse (List.map List.reverse ())
theorem List.inits_reverse {α : Type u_1} (l : List α) :
= List.reverse (List.map List.reverse ())
theorem List.tails_reverse {α : Type u_1} (l : List α) :
= List.reverse (List.map List.reverse ())
theorem List.map_reverse_inits {α : Type u_1} (l : List α) :
List.map List.reverse () =
theorem List.map_reverse_tails {α : Type u_1} (l : List α) :
List.map List.reverse () =
@[simp]
theorem List.length_tails {α : Type u_1} (l : List α) :
= + 1
@[simp]
theorem List.length_inits {α : Type u_1} (l : List α) :
= + 1
@[simp]
theorem List.nth_le_tails {α : Type u_1} (l : List α) (n : ) (hn : n < ) :
List.nthLe () n hn =
@[simp]
theorem List.nth_le_inits {α : Type u_1} (l : List α) (n : ) (hn : n < ) :
List.nthLe () n hn =

### insert #

@[simp]
theorem List.insert_nil {α : Type u_1} [inst : ] (a : α) :
insert a [] = [a]
theorem List.insert.def {α : Type u_1} [inst : ] (a : α) (l : List α) :
insert a l = if a l then l else a :: l
@[simp]
theorem List.suffix_insert {α : Type u_1} [inst : ] (a : α) (l : List α) :
l <:+
theorem List.infix_insert {α : Type u_1} [inst : ] (a : α) (l : List α) :
l <:+:
theorem List.sublist_insert {α : Type u_1} [inst : ] (a : α) (l : List α) :
theorem List.subset_insert {α : Type u_1} [inst : ] (a : α) (l : List α) :
l
theorem List.mem_of_mem_suffix {α : Type u_1} {l₁ : List α} {l₂ : List α} {a : α} (hx : a l₁) (hl : l₁ <:+ l₂) :
a l₂