Skip to content

Commit

Permalink
feat(data/list): suffix_cons_iff (#7287)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-mehta committed Apr 22, 2021
1 parent 98ccc66 commit a104211
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/data/list/basic.lean
Expand Up @@ -3489,6 +3489,19 @@ theorem suffix_or_suffix_of_suffix {l₁ l₂ l₃ : list α}
(prefix_or_prefix_of_prefix (reverse_prefix.2 h₁) (reverse_prefix.2 h₂)).imp
reverse_prefix.1 reverse_prefix.1

theorem suffix_cons_iff {x : α} {l₁ l₂ : list α} :
l₁ <:+ x :: l₂ ↔ l₁ = x :: l₂ ∨ l₁ <:+ l₂ :=
begin
split,
{ rintro ⟨⟨hd, tl⟩, hl₃⟩,
{ exact or.inl hl₃ },
{ simp only [cons_append] at hl₃,
exact or.inr ⟨_, hl₃.2⟩ } },
{ rintro (rfl | hl₁),
{ exact (x :: l₂).suffix_refl },
{ exact hl₁.trans (l₂.suffix_cons _) } }
end

theorem infix_of_mem_join : ∀ {L : list (list α)} {l}, l ∈ L → l <:+: join L
| (_ :: L) l (or.inl rfl) := infix_append [] _ _
| (l' :: L) l (or.inr h) :=
Expand Down

0 comments on commit a104211

Please sign in to comment.