Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a104211

Browse files
committed
feat(data/list): suffix_cons_iff (#7287)
1 parent 98ccc66 commit a104211

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/data/list/basic.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,19 @@ theorem suffix_or_suffix_of_suffix {l₁ l₂ l₃ : list α}
34893489
(prefix_or_prefix_of_prefix (reverse_prefix.2 h₁) (reverse_prefix.2 h₂)).imp
34903490
reverse_prefix.1 reverse_prefix.1
34913491

3492+
theorem suffix_cons_iff {x : α} {l₁ l₂ : list α} :
3493+
l₁ <:+ x :: l₂ ↔ l₁ = x :: l₂ ∨ l₁ <:+ l₂ :=
3494+
begin
3495+
split,
3496+
{ rintro ⟨⟨hd, tl⟩, hl₃⟩,
3497+
{ exact or.inl hl₃ },
3498+
{ simp only [cons_append] at hl₃,
3499+
exact or.inr ⟨_, hl₃.2⟩ } },
3500+
{ rintro (rfl | hl₁),
3501+
{ exact (x :: l₂).suffix_refl },
3502+
{ exact hl₁.trans (l₂.suffix_cons _) } }
3503+
end
3504+
34923505
theorem infix_of_mem_join : ∀ {L : list (list α)} {l}, l ∈ L → l <:+: join L
34933506
| (_ :: L) l (or.inl rfl) := infix_append [] _ _
34943507
| (l' :: L) l (or.inr h) :=

0 commit comments

Comments
 (0)