Prefixes, subfixes, infixes #
This file proves properties about
list.prefix:l₁is a prefix ofl₂ifl₂starts withl₁.list.subfix:l₁is a subfix ofl₂ifl₂ends withl₁.list.infix:l₁is an infix ofl₂ifl₁is a prefix of some subfix ofl₂.list.inits: The list of prefixes of a list.list.tails: The list of prefixes of a list.inserton lists
All those (except insert) are defined in 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 #
@[protected]
@[protected]
@[protected]
@[protected, instance]
Equations
- (a :: l₁).decidable_prefix (b :: l₂) = dite (a = b) (λ (h : a = b), decidable_of_decidable_of_iff (l₁.decidable_prefix l₂) _) (λ (h : ¬a = b), is_false _)
- (a :: l₁).decidable_prefix list.nil = is_false _
- list.nil.decidable_prefix l₂ = is_true _
@[protected, instance]
Equations
- (hd :: tl).decidable_suffix (b :: l₂) = decidable_of_decidable_of_iff or.decidable _
- (a :: l₁).decidable_suffix list.nil = is_false _
- list.nil.decidable_suffix (hd :: tl) = is_true _
- list.nil.decidable_suffix list.nil = is_true list.decidable_suffix._main._proof_1
@[protected, instance]
Equations
- (hd :: tl).decidable_infix (b :: l₂) = decidable_of_decidable_of_iff or.decidable _
- (a :: l₁).decidable_infix list.nil = is_false _
- list.nil.decidable_infix (hd :: tl) = is_true _
- list.nil.decidable_infix list.nil = is_true list.decidable_infix._main._proof_1
theorem
list.is_prefix.filter_map
{α : Type u_1}
{β : Type u_2}
{l₁ l₂ : list α}
(h : l₁ <+: l₂)
(f : α → option β) :
list.filter_map f l₁ <+: list.filter_map f l₂
theorem
list.is_prefix.reduce_option
{α : Type u_1}
{l₁ l₂ : list (option α)}
(h : l₁ <+: l₂) :
l₁.reduce_option <+: l₂.reduce_option
theorem
list.is_prefix.filter
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
⦃l₁ l₂ : list α⦄
(h : l₁ <+: l₂) :
list.filter p l₁ <+: list.filter p l₂
theorem
list.is_suffix.filter
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
⦃l₁ l₂ : list α⦄
(h : l₁ <:+ l₂) :
list.filter p l₁ <:+ list.filter p l₂
theorem
list.is_infix.filter
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
⦃l₁ l₂ : list α⦄
(h : l₁ <:+: l₂) :
list.filter p l₁ <:+: list.filter p l₂
@[protected, instance]
@[protected, instance]
@[protected, instance]
insert #
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
list.sublist_insert
{α : Type u_1}
[decidable_eq α]
(a : α)
(l : list α) :
l <+ list.insert a l
theorem
list.subset_insert
{α : Type u_1}
[decidable_eq α]
(a : α)
(l : list α) :
l ⊆ list.insert a l
@[simp]
theorem
list.mem_insert_self
{α : Type u_1}
[decidable_eq α]
(a : α)
(l : list α) :
a ∈ list.insert a l
theorem
list.eq_or_mem_of_mem_insert
{α : Type u_1}
{l : list α}
{a b : α}
[decidable_eq α]
(h : a ∈ insert b l) :
@[simp]
theorem
list.length_insert_of_mem
{α : Type u_1}
{l : list α}
{a : α}
[decidable_eq α]
(h : a ∈ l) :
@[simp]
theorem
list.length_insert_of_not_mem
{α : Type u_1}
{l : list α}
{a : α}
[decidable_eq α]
(h : a ∉ l) :