The areas / V33. Data structures and computation
Mathlib.Data.List.Infix
55 declarations. Mathlib docs · Source
Prefixes, suffixes, infixes
This file proves properties about
List.isPrefix:l₁is a prefix ofl₂ifl₂starts withl₁.List.isSuffix:l₁is a suffix ofl₂ifl₂ends withl₁.List.isInfix:l₁is an infix ofl₂ifl₁is a prefix of some suffix ofl₂.List.inits: The list of prefixes of a list.List.tails: The list of suffixes of a list.inserton lists
All those (except insert) are defined in Mathlib/Data/List/Defs.lean.
Notation
l₁ <+: l₂:l₁is a prefix ofl₂.l₁ <:+ l₂:l₁is a suffix ofl₂.l₁ <:+: l₂:l₁is an infix ofl₂.
prefix, suffix, infix
insert
theorem List.IsPrefix.take E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <+: l₂ → ∀ (n : ℕ), List.take n l₁ <+: List.take n l₂
theorem List.IsPrefix.drop E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <+: l₂ → ∀ (n : ℕ), List.drop n l₁ <+: List.drop n l₂
theorem List.isPrefix_append_of_length E1 #
∀ {α : Type u_1} {l₁ l₂ l₃ : List α}, l₁.length ≤ l₂.length → (l₁ <+: l₂ ++ l₃ ↔ l₁ <+: l₂)
theorem List.take_isPrefix_take E0 #
∀ {α : Type u_1} {l : List α} {m n : ℕ}, List.take m l <+: List.take n l ↔ m ≤ n ∨ l.length ≤ n
theorem List.IsPrefix.flatten E1 #
∀ {α : Type u_1} {l₁ l₂ : List (List α)}, l₁ <+: l₂ → l₁.flatten <+: l₂.flatten
theorem List.IsPrefix.flatMap E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α},
l₁ <+: l₂ → ∀ (f : α → List β), List.flatMap f l₁ <+: List.flatMap f l₂
theorem List.IsSuffix.flatten E1 #
∀ {α : Type u_1} {l₁ l₂ : List (List α)}, l₁ <:+ l₂ → l₁.flatten <:+ l₂.flatten
theorem List.IsSuffix.flatMap E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α},
l₁ <:+ l₂ → ∀ (f : α → List β), List.flatMap f l₁ <:+ List.flatMap f l₂
theorem List.IsInfix.flatten E1 #
∀ {α : Type u_1} {l₁ l₂ : List (List α)}, l₁ <:+: l₂ → l₁.flatten <:+: l₂.flatten
theorem List.IsInfix.flatMap E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α},
l₁ <:+: l₂ → ∀ (f : α → List β), List.flatMap f l₁ <:+: List.flatMap f l₂
theorem List.dropSlice_sublist E1 #
∀ {α : Type u_1} (n m : ℕ) (l : List α), (List.dropSlice n m l).Sublist l
theorem List.dropSlice_subset E1 #
∀ {α : Type u_1} (n m : ℕ) (l : List α), List.dropSlice n m l ⊆ l
theorem List.mem_of_mem_dropSlice E0 #
∀ {α : Type u_1} {n m : ℕ} {l : List α} {a : α}, a ∈ List.dropSlice n m l → a ∈ l
theorem List.tail_subset E1 #
∀ {α : Type u_1} (l : List α), l.tail ⊆ l
theorem List.mem_of_mem_dropLast E0 #
∀ {α : Type u_1} {l : List α} {a : α}, a ∈ l.dropLast → a ∈ l
theorem List.concat_get_prefix E1 #
∀ {α : Type u_1} {x y : List α}, x <+: y → ∀ (hl : x.length < y.length), x ++ [y.get ⟨x.length, hl⟩] <+: y
theorem List.prefix_append_drop E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <+: l₂ → l₂ = l₁ ++ List.drop l₁.length l₂
instance List.decidableInfix E0 #
{α : Type u_1} → [DecidableEq α] → (l₁ l₂ : List α) → Decidable (l₁ <:+: l₂)
theorem List.IsPrefix.reduceOption E1 #
∀ {α : Type u_1} {l₁ l₂ : List (Option α)}, l₁ <+: l₂ → l₁.reduceOption <+: l₂.reduceOption
theorem List.singleton_infix_iff E0 #
∀ {α : Type u_1} (x : α) (xs : List α), [x] <:+: xs ↔ x ∈ xs
theorem List.singleton_infix_singleton_iff E0 #
∀ {α : Type u_1} {x y : α}, [x] <:+: [y] ↔ x = y
theorem List.infix_singleton_iff E0 #
∀ {α : Type u_1} (xs : List α) (x : α), xs <:+: [x] ↔ xs = [] ∨ xs = [x]
theorem List.infix_antisymm E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <:+: l₂ → l₂ <:+: l₁ → l₁ = l₂
theorem List.IsPrefix.nodup E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <+: l₂ → l₂.Nodup → l₁.Nodup
theorem List.IsInfix.nodup E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <:+: l₂ → l₂.Nodup → l₁.Nodup
theorem List.IsSuffix.nodup E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁ <:+ l₂ → l₂.Nodup → l₁.Nodup
instance List.instIsPartialOrderIsPrefix E0 #
∀ {α : Type u_1}, IsPartialOrder (List α) fun x1 x2 ↦ x1 <+: x2
instance List.instIsPartialOrderIsSuffix E0 #
∀ {α : Type u_1}, IsPartialOrder (List α) fun x1 x2 ↦ x1 <:+ x2
instance List.instIsPartialOrderIsInfix E0 #
∀ {α : Type u_1}, IsPartialOrder (List α) fun x1 x2 ↦ x1 <:+: x2
theorem List.mem_inits E0 #
∀ {α : Type u_1} (s t : List α), s ∈ t.inits ↔ s <+: t
theorem List.mem_tails E0 #
∀ {α : Type u_1} (s t : List α), s ∈ t.tails ↔ s <:+ t
theorem List.inits_cons E1 #
∀ {α : Type u_1} (a : α) (l : List α), (a :: l).inits = [] :: List.map (fun t ↦ a :: t) l.inits
theorem List.tails_cons E1 #
∀ {α : Type u_1} (a : α) (l : List α), (a :: l).tails = (a :: l) :: l.tails
theorem List.inits_append E0 #
∀ {α : Type u_1} (s t : List α), (s ++ t).inits = s.inits ++ List.map (fun l ↦ s ++ l) t.inits.tail
theorem List.tails_append E0 #
∀ {α : Type u_1} (s t : List α), (s ++ t).tails = List.map (fun l ↦ l ++ t) s.tails ++ t.tails.tail
theorem List.inits_eq_tails E1 #
∀ {α : Type u_1} (l : List α), l.inits = (List.map List.reverse l.reverse.tails).reverse
theorem List.tails_eq_inits E1 #
∀ {α : Type u_1} (l : List α), l.tails = (List.map List.reverse l.reverse.inits).reverse
theorem List.inits_reverse E1 #
∀ {α : Type u_1} (l : List α), l.reverse.inits = (List.map List.reverse l.tails).reverse
theorem List.tails_reverse E1 #
∀ {α : Type u_1} (l : List α), l.reverse.tails = (List.map List.reverse l.inits).reverse
theorem List.map_reverse_inits E0 #
∀ {α : Type u_1} (l : List α), List.map List.reverse l.inits = l.reverse.tails.reverse
theorem List.map_reverse_tails E0 #
∀ {α : Type u_1} (l : List α), List.map List.reverse l.tails = l.reverse.inits.reverse
theorem List.length_tails E0 #
∀ {α : Type u_1} (l : List α), l.tails.length = l.length + 1
theorem List.length_inits E0 #
∀ {α : Type u_1} (l : List α), l.inits.length = l.length + 1
theorem List.getElem_tails E0 #
∀ {α : Type u_1} (l : List α) (n : ℕ) (h : n < l.tails.length), l.tails[n] = List.drop n l
theorem List.get_tails E1 #
∀ {α : Type u_1} (l : List α) (n : Fin l.tails.length), l.tails.get n = List.drop (↑n) l
theorem List.getElem_inits E0 #
∀ {α : Type u_1} (l : List α) (n : ℕ) (h : n < l.inits.length), l.inits[n] = List.take n l
theorem List.get_inits E1 #
∀ {α : Type u_1} (l : List α) (n : Fin l.inits.length), l.inits.get n = List.take (↑n) l
theorem List.map_inits E0 #
∀ {α : Type u_1} {l : List α} {β : Type u_3} (g : α → β), (List.map g l).inits = List.map (List.map g) l.inits
theorem List.map_tails E0 #
∀ {α : Type u_1} {l : List α} {β : Type u_3} (g : α → β), (List.map g l).tails = List.map (List.map g) l.tails
theorem List.take_inits E1 #
∀ {α : Type u_1} {l : List α} {n : ℕ}, (List.take n l).inits = List.take (n + 1) l.inits
theorem List.insert_eq_ite E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (l : List α), insert a l = if a ∈ l then l else a :: l
theorem List.suffix_insert E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (l : List α), l <:+ List.insert a l
theorem List.infix_insert E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (l : List α), l <:+: List.insert a l
theorem List.sublist_insert E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (l : List α), l.Sublist (List.insert a l)
theorem List.subset_insert E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (l : List α), l ⊆ List.insert a l