@@ -90,13 +90,13 @@ theorem prefix_concat_iff {l₁ l₂ : List α} {a : α} :
90
90
#align list.reverse_prefix List.reverse_prefix
91
91
#align list.reverse_infix List.reverse_infix
92
92
93
- alias ⟨_, isSuffix.reverse⟩ := reverse_prefix
93
+ protected alias ⟨_, isSuffix.reverse⟩ := reverse_prefix
94
94
#align list.is_suffix.reverse List.isSuffix.reverse
95
95
96
- alias ⟨_, isPrefix.reverse⟩ := reverse_suffix
96
+ protected alias ⟨_, isPrefix.reverse⟩ := reverse_suffix
97
97
#align list.is_prefix.reverse List.isPrefix.reverse
98
98
99
- alias ⟨_, isInfix.reverse⟩ := reverse_infix
99
+ protected alias ⟨_, isInfix.reverse⟩ := reverse_infix
100
100
#align list.is_infix.reverse List.isInfix.reverse
101
101
102
102
#align list.is_infix.length_le List.IsInfix.length_le
@@ -182,9 +182,10 @@ theorem dropLast_sublist (l : List α) : l.dropLast <+ l :=
182
182
(dropLast_prefix l).sublist
183
183
#align list.init_sublist List.dropLast_sublist
184
184
185
- theorem tail_sublist (l : List α) : l.tail <+ l :=
186
- (tail_suffix l).sublist
187
- #align list.tail_sublist List.tail_sublist
185
+ @[gcongr]
186
+ theorem drop_sublist_drop_left (l : List α) {m n : ℕ} (h : m ≤ n) : drop n l <+ drop m l := by
187
+ rw [← Nat.sub_add_cancel h, drop_add]
188
+ apply drop_sublist
188
189
189
190
theorem dropLast_subset (l : List α) : l.dropLast ⊆ l :=
190
191
(dropLast_sublist l).subset
@@ -202,6 +203,11 @@ theorem mem_of_mem_tail (h : a ∈ l.tail) : a ∈ l :=
202
203
tail_subset l h
203
204
#align list.mem_of_mem_tail List.mem_of_mem_tail
204
205
206
+ @[gcongr]
207
+ protected theorem Sublist.drop : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → ∀ n, l₁.drop n <+ l₂.drop n
208
+ | _, _, h, 0 => h
209
+ | _, _, h, n + 1 => by rw [← drop_tail, ← drop_tail]; exact h.tail.drop n
210
+
205
211
theorem prefix_iff_eq_append : l₁ <+: l₂ ↔ l₁ ++ drop (length l₁) l₂ = l₂ :=
206
212
⟨by rintro ⟨r, rfl⟩; rw [drop_left], fun e => ⟨_, e⟩⟩
207
213
#align list.prefix_iff_eq_append List.prefix_iff_eq_append
0 commit comments