data.list.rdrop
⟷
Mathlib.Data.List.DropRight
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -213,7 +213,7 @@ theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (
intro h
rw [nth_le_reverse']
· simp
- · rw [← Ne.def, ← pos_iff_ne_zero] at h
+ · rw [← Ne.def, ← pos_iff_ne_zero] at h
simp [tsub_lt_iff_right (Nat.succ_le_of_lt h)]
#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -41,27 +41,27 @@ variable {α : Type _} (p : α → Prop) [DecidablePred p] (l : List α) (n :
namespace List
-#print List.dropRight /-
+#print List.rdrop /-
/-- Drop `n` elements from the tail end of a list. -/
-def dropRight : List α :=
+def rdrop : List α :=
l.take (l.length - n)
-#align list.rdrop List.dropRight
+#align list.rdrop List.rdrop
-/
-#print List.dropRight_nil /-
+#print List.rdrop_nil /-
@[simp]
-theorem dropRight_nil : dropRight ([] : List α) n = [] := by simp [rdrop]
-#align list.rdrop_nil List.dropRight_nil
+theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
+#align list.rdrop_nil List.rdrop_nil
-/
-#print List.dropRight_zero /-
+#print List.rdrop_zero /-
@[simp]
-theorem dropRight_zero : dropRight l 0 = l := by simp [rdrop]
-#align list.rdrop_zero List.dropRight_zero
+theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
+#align list.rdrop_zero List.rdrop_zero
-/
-#print List.dropRight_eq_reverse_drop_reverse /-
-theorem dropRight_eq_reverse_drop_reverse : l.dropRight n = reverse (l.reverse.drop n) :=
+#print List.rdrop_eq_reverse_drop_reverse /-
+theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) :=
by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
@@ -69,37 +69,37 @@ theorem dropRight_eq_reverse_drop_reverse : l.dropRight n = reverse (l.reverse.d
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
-#align list.rdrop_eq_reverse_drop_reverse List.dropRight_eq_reverse_drop_reverse
+#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
-/
-#print List.dropRight_concat_succ /-
+#print List.rdrop_concat_succ /-
@[simp]
-theorem dropRight_concat_succ (x : α) : dropRight (l ++ [x]) (n + 1) = dropRight l n := by
+theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
-#align list.rdrop_concat_succ List.dropRight_concat_succ
+#align list.rdrop_concat_succ List.rdrop_concat_succ
-/
-#print List.takeRight /-
+#print List.rtake /-
/-- Take `n` elements from the tail end of a list. -/
-def takeRight : List α :=
+def rtake : List α :=
l.drop (l.length - n)
-#align list.rtake List.takeRight
+#align list.rtake List.rtake
-/
-#print List.takeRight_nil /-
+#print List.rtake_nil /-
@[simp]
-theorem takeRight_nil : takeRight ([] : List α) n = [] := by simp [rtake]
-#align list.rtake_nil List.takeRight_nil
+theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
+#align list.rtake_nil List.rtake_nil
-/
-#print List.takeRight_zero /-
+#print List.rtake_zero /-
@[simp]
-theorem takeRight_zero : takeRight l 0 = [] := by simp [rtake]
-#align list.rtake_zero List.takeRight_zero
+theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
+#align list.rtake_zero List.rtake_zero
-/
-#print List.takeRight_eq_reverse_take_reverse /-
-theorem takeRight_eq_reverse_take_reverse : l.takeRight n = reverse (l.reverse.take n) :=
+#print List.rtake_eq_reverse_take_reverse /-
+theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) :=
by
rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
@@ -107,84 +107,82 @@ theorem takeRight_eq_reverse_take_reverse : l.takeRight n = reverse (l.reverse.t
· cases n
· simp
· simp [drop_append_eq_append_drop, IH]
-#align list.rtake_eq_reverse_take_reverse List.takeRight_eq_reverse_take_reverse
+#align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse
-/
-#print List.takeRight_concat_succ /-
+#print List.rtake_concat_succ /-
@[simp]
-theorem takeRight_concat_succ (x : α) : takeRight (l ++ [x]) (n + 1) = takeRight l n ++ [x] := by
+theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
-#align list.rtake_concat_succ List.takeRight_concat_succ
+#align list.rtake_concat_succ List.rtake_concat_succ
-/
-#print List.dropRightWhile /-
+#print List.rdropWhile /-
/-- Drop elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
-def dropRightWhile : List α :=
+def rdropWhile : List α :=
reverse (l.reverse.dropWhileₓ p)
-#align list.rdrop_while List.dropRightWhile
+#align list.rdrop_while List.rdropWhile
-/
-#print List.dropRightWhile_nil /-
+#print List.rdropWhile_nil /-
@[simp]
-theorem dropRightWhile_nil : dropRightWhile p ([] : List α) = [] := by
- simp [rdrop_while, drop_while]
-#align list.rdrop_while_nil List.dropRightWhile_nil
+theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdrop_while, drop_while]
+#align list.rdrop_while_nil List.rdropWhile_nil
-/
-#print List.dropRightWhile_concat /-
-theorem dropRightWhile_concat (x : α) :
- dropRightWhile p (l ++ [x]) = if p x then dropRightWhile p l else l ++ [x] :=
+#print List.rdropWhile_concat /-
+theorem rdropWhile_concat (x : α) :
+ rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] :=
by
simp only [rdrop_while, drop_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
-#align list.rdrop_while_concat List.dropRightWhile_concat
+#align list.rdrop_while_concat List.rdropWhile_concat
-/
-#print List.dropRightWhile_concat_pos /-
+#print List.rdropWhile_concat_pos /-
@[simp]
-theorem dropRightWhile_concat_pos (x : α) (h : p x) :
- dropRightWhile p (l ++ [x]) = dropRightWhile p l := by rw [rdrop_while_concat, if_pos h]
-#align list.rdrop_while_concat_pos List.dropRightWhile_concat_pos
+theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
+ rw [rdrop_while_concat, if_pos h]
+#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
-/
-#print List.dropRightWhile_concat_neg /-
+#print List.rdropWhile_concat_neg /-
@[simp]
-theorem dropRightWhile_concat_neg (x : α) (h : ¬p x) : dropRightWhile p (l ++ [x]) = l ++ [x] := by
+theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
rw [rdrop_while_concat, if_neg h]
-#align list.rdrop_while_concat_neg List.dropRightWhile_concat_neg
+#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
-/
-#print List.dropRightWhile_singleton /-
-theorem dropRightWhile_singleton (x : α) : dropRightWhile p [x] = if p x then [] else [x] := by
+#print List.rdropWhile_singleton /-
+theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdrop_while_concat, rdrop_while_nil]
-#align list.rdrop_while_singleton List.dropRightWhile_singleton
+#align list.rdrop_while_singleton List.rdropWhile_singleton
-/
-#print List.dropRightWhile_last_not /-
-theorem dropRightWhile_last_not (hl : l.dropRightWhile p ≠ []) :
- ¬p ((dropRightWhile p l).getLast hl) :=
+#print List.rdropWhile_last_not /-
+theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) :=
by
simp_rw [rdrop_while]
rw [last_reverse]
exact drop_while_nth_le_zero_not _ _ _
-#align list.rdrop_while_last_not List.dropRightWhile_last_not
+#align list.rdrop_while_last_not List.rdropWhile_last_not
-/
-#print List.dropRightWhile_prefix /-
-theorem dropRightWhile_prefix : l.dropRightWhile p <+: l :=
+#print List.rdropWhile_prefix /-
+theorem rdropWhile_prefix : l.rdropWhile p <+: l :=
by
rw [← reverse_suffix, rdrop_while, reverse_reverse]
exact drop_while_suffix _
-#align list.rdrop_while_prefix List.dropRightWhile_prefix
+#align list.rdrop_while_prefix List.rdropWhile_prefix
-/
variable {p} {l}
-#print List.dropRightWhile_eq_nil_iff /-
+#print List.rdropWhile_eq_nil_iff /-
@[simp]
-theorem dropRightWhile_eq_nil_iff : dropRightWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
-#align list.rdrop_while_eq_nil_iff List.dropRightWhile_eq_nil_iff
+theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
+#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
-/
#print List.dropWhile_eq_self_iff /-
@@ -205,9 +203,9 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff
-/
-#print List.dropRightWhile_eq_self_iff /-
+#print List.rdropWhile_eq_self_iff /-
@[simp]
-theorem dropRightWhile_eq_self_iff : dropRightWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
+theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
by
simp only [rdrop_while, reverse_eq_iff, length_reverse, Ne.def, drop_while_eq_self_iff,
last_eq_nth_le, ← length_eq_zero, pos_iff_ne_zero]
@@ -217,7 +215,7 @@ theorem dropRightWhile_eq_self_iff : dropRightWhile p l = l ↔ ∀ hl : l ≠ [
· simp
· rw [← Ne.def, ← pos_iff_ne_zero] at h
simp [tsub_lt_iff_right (Nat.succ_le_of_lt h)]
-#align list.rdrop_while_eq_self_iff List.dropRightWhile_eq_self_iff
+#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
-/
variable (p) (l)
@@ -228,88 +226,87 @@ theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l :=
#align list.drop_while_idempotent List.dropWhile_idempotent
-/
-#print List.dropRightWhile_idempotent /-
-theorem dropRightWhile_idempotent : dropRightWhile p (dropRightWhile p l) = dropRightWhile p l :=
- dropRightWhile_eq_self_iff.mpr (dropRightWhile_last_not _ _)
-#align list.rdrop_while_idempotent List.dropRightWhile_idempotent
+#print List.rdropWhile_idempotent /-
+theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
+ rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
+#align list.rdrop_while_idempotent List.rdropWhile_idempotent
-/
-#print List.takeRightWhile /-
+#print List.rtakeWhile /-
/-- Take elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
-def takeRightWhile : List α :=
+def rtakeWhile : List α :=
reverse (l.reverse.takeWhile p)
-#align list.rtake_while List.takeRightWhile
+#align list.rtake_while List.rtakeWhile
-/
-#print List.takeRightWhile_nil /-
+#print List.rtakeWhile_nil /-
@[simp]
-theorem takeRightWhile_nil : takeRightWhile p ([] : List α) = [] := by
- simp [rtake_while, take_while]
-#align list.rtake_while_nil List.takeRightWhile_nil
+theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by simp [rtake_while, take_while]
+#align list.rtake_while_nil List.rtakeWhile_nil
-/
-#print List.takeRightWhile_concat /-
-theorem takeRightWhile_concat (x : α) :
- takeRightWhile p (l ++ [x]) = if p x then takeRightWhile p l ++ [x] else [] :=
+#print List.rtakeWhile_concat /-
+theorem rtakeWhile_concat (x : α) :
+ rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] :=
by
simp only [rtake_while, take_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
-#align list.rtake_while_concat List.takeRightWhile_concat
+#align list.rtake_while_concat List.rtakeWhile_concat
-/
-#print List.takeRightWhile_concat_pos /-
+#print List.rtakeWhile_concat_pos /-
@[simp]
-theorem takeRightWhile_concat_pos (x : α) (h : p x) :
- takeRightWhile p (l ++ [x]) = takeRightWhile p l ++ [x] := by rw [rtake_while_concat, if_pos h]
-#align list.rtake_while_concat_pos List.takeRightWhile_concat_pos
+theorem rtakeWhile_concat_pos (x : α) (h : p x) : rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] :=
+ by rw [rtake_while_concat, if_pos h]
+#align list.rtake_while_concat_pos List.rtakeWhile_concat_pos
-/
-#print List.takeRightWhile_concat_neg /-
+#print List.rtakeWhile_concat_neg /-
@[simp]
-theorem takeRightWhile_concat_neg (x : α) (h : ¬p x) : takeRightWhile p (l ++ [x]) = [] := by
+theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
rw [rtake_while_concat, if_neg h]
-#align list.rtake_while_concat_neg List.takeRightWhile_concat_neg
+#align list.rtake_while_concat_neg List.rtakeWhile_concat_neg
-/
-#print List.takeRightWhile_suffix /-
-theorem takeRightWhile_suffix : l.takeRightWhile p <:+ l :=
+#print List.rtakeWhile_suffix /-
+theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l :=
by
rw [← reverse_prefix, rtake_while, reverse_reverse]
exact take_while_prefix _
-#align list.rtake_while_suffix List.takeRightWhile_suffix
+#align list.rtake_while_suffix List.rtakeWhile_suffix
-/
variable {p} {l}
-#print List.takeRightWhile_eq_self_iff /-
+#print List.rtakeWhile_eq_self_iff /-
@[simp]
-theorem takeRightWhile_eq_self_iff : takeRightWhile p l = l ↔ ∀ x ∈ l, p x := by
+theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
simp [rtake_while, reverse_eq_iff]
-#align list.rtake_while_eq_self_iff List.takeRightWhile_eq_self_iff
+#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iff
-/
-#print List.takeRightWhile_eq_nil_iff /-
+#print List.rtakeWhile_eq_nil_iff /-
@[simp]
-theorem takeRightWhile_eq_nil_iff : takeRightWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
+theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
induction l using List.reverseRecOn <;> simp [rtake_while]
-#align list.rtake_while_eq_nil_iff List.takeRightWhile_eq_nil_iff
+#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iff
-/
-#print List.mem_takeRightWhile_imp /-
-theorem mem_takeRightWhile_imp {x : α} (hx : x ∈ takeRightWhile p l) : p x :=
+#print List.mem_rtakeWhile_imp /-
+theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x :=
by
suffices x ∈ take_while p l.reverse by exact mem_take_while_imp this
rwa [← mem_reverse, ← rtake_while]
-#align list.mem_rtake_while_imp List.mem_takeRightWhile_imp
+#align list.mem_rtake_while_imp List.mem_rtakeWhile_imp
-/
variable (p) (l)
-#print List.takeRightWhile_idempotent /-
-theorem takeRightWhile_idempotent : takeRightWhile p (takeRightWhile p l) = takeRightWhile p l :=
- takeRightWhile_eq_self_iff.mpr fun _ => mem_takeRightWhile_imp
-#align list.rtake_while_idempotent List.takeRightWhile_idempotent
+#print List.rtakeWhile_idempotent /-
+theorem rtakeWhile_idempotent : rtakeWhile p (rtakeWhile p l) = rtakeWhile p l :=
+ rtakeWhile_eq_self_iff.mpr fun _ => mem_rtakeWhile_imp
+#align list.rtake_while_idempotent List.rtakeWhile_idempotent
-/
end List
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -41,27 +41,27 @@ variable {α : Type _} (p : α → Prop) [DecidablePred p] (l : List α) (n :
namespace List
-#print List.rdrop /-
+#print List.dropRight /-
/-- Drop `n` elements from the tail end of a list. -/
-def rdrop : List α :=
+def dropRight : List α :=
l.take (l.length - n)
-#align list.rdrop List.rdrop
+#align list.rdrop List.dropRight
-/
-#print List.rdrop_nil /-
+#print List.dropRight_nil /-
@[simp]
-theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
-#align list.rdrop_nil List.rdrop_nil
+theorem dropRight_nil : dropRight ([] : List α) n = [] := by simp [rdrop]
+#align list.rdrop_nil List.dropRight_nil
-/
-#print List.rdrop_zero /-
+#print List.dropRight_zero /-
@[simp]
-theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
-#align list.rdrop_zero List.rdrop_zero
+theorem dropRight_zero : dropRight l 0 = l := by simp [rdrop]
+#align list.rdrop_zero List.dropRight_zero
-/
-#print List.rdrop_eq_reverse_drop_reverse /-
-theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) :=
+#print List.dropRight_eq_reverse_drop_reverse /-
+theorem dropRight_eq_reverse_drop_reverse : l.dropRight n = reverse (l.reverse.drop n) :=
by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
@@ -69,37 +69,37 @@ theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) :
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
-#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
+#align list.rdrop_eq_reverse_drop_reverse List.dropRight_eq_reverse_drop_reverse
-/
-#print List.rdrop_concat_succ /-
+#print List.dropRight_concat_succ /-
@[simp]
-theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
+theorem dropRight_concat_succ (x : α) : dropRight (l ++ [x]) (n + 1) = dropRight l n := by
simp [rdrop_eq_reverse_drop_reverse]
-#align list.rdrop_concat_succ List.rdrop_concat_succ
+#align list.rdrop_concat_succ List.dropRight_concat_succ
-/
-#print List.rtake /-
+#print List.takeRight /-
/-- Take `n` elements from the tail end of a list. -/
-def rtake : List α :=
+def takeRight : List α :=
l.drop (l.length - n)
-#align list.rtake List.rtake
+#align list.rtake List.takeRight
-/
-#print List.rtake_nil /-
+#print List.takeRight_nil /-
@[simp]
-theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
-#align list.rtake_nil List.rtake_nil
+theorem takeRight_nil : takeRight ([] : List α) n = [] := by simp [rtake]
+#align list.rtake_nil List.takeRight_nil
-/
-#print List.rtake_zero /-
+#print List.takeRight_zero /-
@[simp]
-theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
-#align list.rtake_zero List.rtake_zero
+theorem takeRight_zero : takeRight l 0 = [] := by simp [rtake]
+#align list.rtake_zero List.takeRight_zero
-/
-#print List.rtake_eq_reverse_take_reverse /-
-theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) :=
+#print List.takeRight_eq_reverse_take_reverse /-
+theorem takeRight_eq_reverse_take_reverse : l.takeRight n = reverse (l.reverse.take n) :=
by
rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
@@ -107,82 +107,84 @@ theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) :
· cases n
· simp
· simp [drop_append_eq_append_drop, IH]
-#align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse
+#align list.rtake_eq_reverse_take_reverse List.takeRight_eq_reverse_take_reverse
-/
-#print List.rtake_concat_succ /-
+#print List.takeRight_concat_succ /-
@[simp]
-theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
+theorem takeRight_concat_succ (x : α) : takeRight (l ++ [x]) (n + 1) = takeRight l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
-#align list.rtake_concat_succ List.rtake_concat_succ
+#align list.rtake_concat_succ List.takeRight_concat_succ
-/
-#print List.rdropWhile /-
+#print List.dropRightWhile /-
/-- Drop elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
-def rdropWhile : List α :=
+def dropRightWhile : List α :=
reverse (l.reverse.dropWhileₓ p)
-#align list.rdrop_while List.rdropWhile
+#align list.rdrop_while List.dropRightWhile
-/
-#print List.rdropWhile_nil /-
+#print List.dropRightWhile_nil /-
@[simp]
-theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdrop_while, drop_while]
-#align list.rdrop_while_nil List.rdropWhile_nil
+theorem dropRightWhile_nil : dropRightWhile p ([] : List α) = [] := by
+ simp [rdrop_while, drop_while]
+#align list.rdrop_while_nil List.dropRightWhile_nil
-/
-#print List.rdropWhile_concat /-
-theorem rdropWhile_concat (x : α) :
- rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] :=
+#print List.dropRightWhile_concat /-
+theorem dropRightWhile_concat (x : α) :
+ dropRightWhile p (l ++ [x]) = if p x then dropRightWhile p l else l ++ [x] :=
by
simp only [rdrop_while, drop_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
-#align list.rdrop_while_concat List.rdropWhile_concat
+#align list.rdrop_while_concat List.dropRightWhile_concat
-/
-#print List.rdropWhile_concat_pos /-
+#print List.dropRightWhile_concat_pos /-
@[simp]
-theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
- rw [rdrop_while_concat, if_pos h]
-#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
+theorem dropRightWhile_concat_pos (x : α) (h : p x) :
+ dropRightWhile p (l ++ [x]) = dropRightWhile p l := by rw [rdrop_while_concat, if_pos h]
+#align list.rdrop_while_concat_pos List.dropRightWhile_concat_pos
-/
-#print List.rdropWhile_concat_neg /-
+#print List.dropRightWhile_concat_neg /-
@[simp]
-theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
+theorem dropRightWhile_concat_neg (x : α) (h : ¬p x) : dropRightWhile p (l ++ [x]) = l ++ [x] := by
rw [rdrop_while_concat, if_neg h]
-#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
+#align list.rdrop_while_concat_neg List.dropRightWhile_concat_neg
-/
-#print List.rdropWhile_singleton /-
-theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
+#print List.dropRightWhile_singleton /-
+theorem dropRightWhile_singleton (x : α) : dropRightWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdrop_while_concat, rdrop_while_nil]
-#align list.rdrop_while_singleton List.rdropWhile_singleton
+#align list.rdrop_while_singleton List.dropRightWhile_singleton
-/
-#print List.rdropWhile_last_not /-
-theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) :=
+#print List.dropRightWhile_last_not /-
+theorem dropRightWhile_last_not (hl : l.dropRightWhile p ≠ []) :
+ ¬p ((dropRightWhile p l).getLast hl) :=
by
simp_rw [rdrop_while]
rw [last_reverse]
exact drop_while_nth_le_zero_not _ _ _
-#align list.rdrop_while_last_not List.rdropWhile_last_not
+#align list.rdrop_while_last_not List.dropRightWhile_last_not
-/
-#print List.rdropWhile_prefix /-
-theorem rdropWhile_prefix : l.rdropWhile p <+: l :=
+#print List.dropRightWhile_prefix /-
+theorem dropRightWhile_prefix : l.dropRightWhile p <+: l :=
by
rw [← reverse_suffix, rdrop_while, reverse_reverse]
exact drop_while_suffix _
-#align list.rdrop_while_prefix List.rdropWhile_prefix
+#align list.rdrop_while_prefix List.dropRightWhile_prefix
-/
variable {p} {l}
-#print List.rdropWhile_eq_nil_iff /-
+#print List.dropRightWhile_eq_nil_iff /-
@[simp]
-theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
-#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
+theorem dropRightWhile_eq_nil_iff : dropRightWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
+#align list.rdrop_while_eq_nil_iff List.dropRightWhile_eq_nil_iff
-/
#print List.dropWhile_eq_self_iff /-
@@ -203,9 +205,9 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff
-/
-#print List.rdropWhile_eq_self_iff /-
+#print List.dropRightWhile_eq_self_iff /-
@[simp]
-theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
+theorem dropRightWhile_eq_self_iff : dropRightWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
by
simp only [rdrop_while, reverse_eq_iff, length_reverse, Ne.def, drop_while_eq_self_iff,
last_eq_nth_le, ← length_eq_zero, pos_iff_ne_zero]
@@ -215,7 +217,7 @@ theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (
· simp
· rw [← Ne.def, ← pos_iff_ne_zero] at h
simp [tsub_lt_iff_right (Nat.succ_le_of_lt h)]
-#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
+#align list.rdrop_while_eq_self_iff List.dropRightWhile_eq_self_iff
-/
variable (p) (l)
@@ -226,87 +228,88 @@ theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l :=
#align list.drop_while_idempotent List.dropWhile_idempotent
-/
-#print List.rdropWhile_idempotent /-
-theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
- rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
-#align list.rdrop_while_idempotent List.rdropWhile_idempotent
+#print List.dropRightWhile_idempotent /-
+theorem dropRightWhile_idempotent : dropRightWhile p (dropRightWhile p l) = dropRightWhile p l :=
+ dropRightWhile_eq_self_iff.mpr (dropRightWhile_last_not _ _)
+#align list.rdrop_while_idempotent List.dropRightWhile_idempotent
-/
-#print List.rtakeWhile /-
+#print List.takeRightWhile /-
/-- Take elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
-def rtakeWhile : List α :=
+def takeRightWhile : List α :=
reverse (l.reverse.takeWhile p)
-#align list.rtake_while List.rtakeWhile
+#align list.rtake_while List.takeRightWhile
-/
-#print List.rtakeWhile_nil /-
+#print List.takeRightWhile_nil /-
@[simp]
-theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by simp [rtake_while, take_while]
-#align list.rtake_while_nil List.rtakeWhile_nil
+theorem takeRightWhile_nil : takeRightWhile p ([] : List α) = [] := by
+ simp [rtake_while, take_while]
+#align list.rtake_while_nil List.takeRightWhile_nil
-/
-#print List.rtakeWhile_concat /-
-theorem rtakeWhile_concat (x : α) :
- rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] :=
+#print List.takeRightWhile_concat /-
+theorem takeRightWhile_concat (x : α) :
+ takeRightWhile p (l ++ [x]) = if p x then takeRightWhile p l ++ [x] else [] :=
by
simp only [rtake_while, take_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
-#align list.rtake_while_concat List.rtakeWhile_concat
+#align list.rtake_while_concat List.takeRightWhile_concat
-/
-#print List.rtakeWhile_concat_pos /-
+#print List.takeRightWhile_concat_pos /-
@[simp]
-theorem rtakeWhile_concat_pos (x : α) (h : p x) : rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] :=
- by rw [rtake_while_concat, if_pos h]
-#align list.rtake_while_concat_pos List.rtakeWhile_concat_pos
+theorem takeRightWhile_concat_pos (x : α) (h : p x) :
+ takeRightWhile p (l ++ [x]) = takeRightWhile p l ++ [x] := by rw [rtake_while_concat, if_pos h]
+#align list.rtake_while_concat_pos List.takeRightWhile_concat_pos
-/
-#print List.rtakeWhile_concat_neg /-
+#print List.takeRightWhile_concat_neg /-
@[simp]
-theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
+theorem takeRightWhile_concat_neg (x : α) (h : ¬p x) : takeRightWhile p (l ++ [x]) = [] := by
rw [rtake_while_concat, if_neg h]
-#align list.rtake_while_concat_neg List.rtakeWhile_concat_neg
+#align list.rtake_while_concat_neg List.takeRightWhile_concat_neg
-/
-#print List.rtakeWhile_suffix /-
-theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l :=
+#print List.takeRightWhile_suffix /-
+theorem takeRightWhile_suffix : l.takeRightWhile p <:+ l :=
by
rw [← reverse_prefix, rtake_while, reverse_reverse]
exact take_while_prefix _
-#align list.rtake_while_suffix List.rtakeWhile_suffix
+#align list.rtake_while_suffix List.takeRightWhile_suffix
-/
variable {p} {l}
-#print List.rtakeWhile_eq_self_iff /-
+#print List.takeRightWhile_eq_self_iff /-
@[simp]
-theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
+theorem takeRightWhile_eq_self_iff : takeRightWhile p l = l ↔ ∀ x ∈ l, p x := by
simp [rtake_while, reverse_eq_iff]
-#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iff
+#align list.rtake_while_eq_self_iff List.takeRightWhile_eq_self_iff
-/
-#print List.rtakeWhile_eq_nil_iff /-
+#print List.takeRightWhile_eq_nil_iff /-
@[simp]
-theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
+theorem takeRightWhile_eq_nil_iff : takeRightWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
induction l using List.reverseRecOn <;> simp [rtake_while]
-#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iff
+#align list.rtake_while_eq_nil_iff List.takeRightWhile_eq_nil_iff
-/
-#print List.mem_rtakeWhile_imp /-
-theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x :=
+#print List.mem_takeRightWhile_imp /-
+theorem mem_takeRightWhile_imp {x : α} (hx : x ∈ takeRightWhile p l) : p x :=
by
suffices x ∈ take_while p l.reverse by exact mem_take_while_imp this
rwa [← mem_reverse, ← rtake_while]
-#align list.mem_rtake_while_imp List.mem_rtakeWhile_imp
+#align list.mem_rtake_while_imp List.mem_takeRightWhile_imp
-/
variable (p) (l)
-#print List.rtakeWhile_idempotent /-
-theorem rtakeWhile_idempotent : rtakeWhile p (rtakeWhile p l) = rtakeWhile p l :=
- rtakeWhile_eq_self_iff.mpr fun _ => mem_rtakeWhile_imp
-#align list.rtake_while_idempotent List.rtakeWhile_idempotent
+#print List.takeRightWhile_idempotent /-
+theorem takeRightWhile_idempotent : takeRightWhile p (takeRightWhile p l) = takeRightWhile p l :=
+ takeRightWhile_eq_self_iff.mpr fun _ => mem_takeRightWhile_imp
+#align list.rtake_while_idempotent List.takeRightWhile_idempotent
-/
end List
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
-import Mathbin.Data.List.Basic
-import Mathbin.Data.List.Infix
+import Data.List.Basic
+import Data.List.Infix
#align_import data.list.rdrop from "leanprover-community/mathlib"@"be24ec5de6701447e5df5ca75400ffee19d65659"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-
-! This file was ported from Lean 3 source module data.list.rdrop
-! leanprover-community/mathlib commit be24ec5de6701447e5df5ca75400ffee19d65659
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.List.Basic
import Mathbin.Data.List.Infix
+#align_import data.list.rdrop from "leanprover-community/mathlib"@"be24ec5de6701447e5df5ca75400ffee19d65659"
+
/-!
# Dropping or taking from lists on the right
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -120,56 +120,75 @@ theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x]
#align list.rtake_concat_succ List.rtake_concat_succ
-/
+#print List.rdropWhile /-
/-- Drop elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
def rdropWhile : List α :=
reverse (l.reverse.dropWhileₓ p)
#align list.rdrop_while List.rdropWhile
+-/
+#print List.rdropWhile_nil /-
@[simp]
theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdrop_while, drop_while]
#align list.rdrop_while_nil List.rdropWhile_nil
+-/
+#print List.rdropWhile_concat /-
theorem rdropWhile_concat (x : α) :
rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] :=
by
simp only [rdrop_while, drop_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
#align list.rdrop_while_concat List.rdropWhile_concat
+-/
+#print List.rdropWhile_concat_pos /-
@[simp]
theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
rw [rdrop_while_concat, if_pos h]
#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
+-/
+#print List.rdropWhile_concat_neg /-
@[simp]
theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
rw [rdrop_while_concat, if_neg h]
#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
+-/
+#print List.rdropWhile_singleton /-
theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdrop_while_concat, rdrop_while_nil]
#align list.rdrop_while_singleton List.rdropWhile_singleton
+-/
+#print List.rdropWhile_last_not /-
theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) :=
by
simp_rw [rdrop_while]
rw [last_reverse]
exact drop_while_nth_le_zero_not _ _ _
#align list.rdrop_while_last_not List.rdropWhile_last_not
+-/
+#print List.rdropWhile_prefix /-
theorem rdropWhile_prefix : l.rdropWhile p <+: l :=
by
rw [← reverse_suffix, rdrop_while, reverse_reverse]
exact drop_while_suffix _
#align list.rdrop_while_prefix List.rdropWhile_prefix
+-/
variable {p} {l}
+#print List.rdropWhile_eq_nil_iff /-
@[simp]
theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
+-/
+#print List.dropWhile_eq_self_iff /-
-- it is in this file because it requires `list.infix`
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) :=
@@ -185,7 +204,9 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
exact (drop_while_suffix _).Sublist
· simp [h]
#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff
+-/
+#print List.rdropWhile_eq_self_iff /-
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
by
@@ -198,73 +219,98 @@ theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (
· rw [← Ne.def, ← pos_iff_ne_zero] at h
simp [tsub_lt_iff_right (Nat.succ_le_of_lt h)]
#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
+-/
variable (p) (l)
+#print List.dropWhile_idempotent /-
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l :=
dropWhile_eq_self_iff.mpr (dropWhile_nthLe_zero_not _ _)
#align list.drop_while_idempotent List.dropWhile_idempotent
+-/
+#print List.rdropWhile_idempotent /-
theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
#align list.rdrop_while_idempotent List.rdropWhile_idempotent
+-/
+#print List.rtakeWhile /-
/-- Take elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
def rtakeWhile : List α :=
reverse (l.reverse.takeWhile p)
#align list.rtake_while List.rtakeWhile
+-/
+#print List.rtakeWhile_nil /-
@[simp]
theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by simp [rtake_while, take_while]
#align list.rtake_while_nil List.rtakeWhile_nil
+-/
+#print List.rtakeWhile_concat /-
theorem rtakeWhile_concat (x : α) :
rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] :=
by
simp only [rtake_while, take_while, reverse_append, reverse_singleton, singleton_append]
split_ifs with h h <;> simp [h]
#align list.rtake_while_concat List.rtakeWhile_concat
+-/
+#print List.rtakeWhile_concat_pos /-
@[simp]
theorem rtakeWhile_concat_pos (x : α) (h : p x) : rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] :=
by rw [rtake_while_concat, if_pos h]
#align list.rtake_while_concat_pos List.rtakeWhile_concat_pos
+-/
+#print List.rtakeWhile_concat_neg /-
@[simp]
theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
rw [rtake_while_concat, if_neg h]
#align list.rtake_while_concat_neg List.rtakeWhile_concat_neg
+-/
+#print List.rtakeWhile_suffix /-
theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l :=
by
rw [← reverse_prefix, rtake_while, reverse_reverse]
exact take_while_prefix _
#align list.rtake_while_suffix List.rtakeWhile_suffix
+-/
variable {p} {l}
+#print List.rtakeWhile_eq_self_iff /-
@[simp]
theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
simp [rtake_while, reverse_eq_iff]
#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iff
+-/
+#print List.rtakeWhile_eq_nil_iff /-
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
induction l using List.reverseRecOn <;> simp [rtake_while]
#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iff
+-/
+#print List.mem_rtakeWhile_imp /-
theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x :=
by
suffices x ∈ take_while p l.reverse by exact mem_take_while_imp this
rwa [← mem_reverse, ← rtake_while]
#align list.mem_rtake_while_imp List.mem_rtakeWhile_imp
+-/
variable (p) (l)
+#print List.rtakeWhile_idempotent /-
theorem rtakeWhile_idempotent : rtakeWhile p (rtakeWhile p l) = rtakeWhile p l :=
rtakeWhile_eq_self_iff.mpr fun _ => mem_rtakeWhile_imp
#align list.rtake_while_idempotent List.rtakeWhile_idempotent
+-/
end List
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -195,7 +195,7 @@ theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (
intro h
rw [nth_le_reverse']
· simp
- · rw [← Ne.def, ← pos_iff_ne_zero] at h
+ · rw [← Ne.def, ← pos_iff_ne_zero] at h
simp [tsub_lt_iff_right (Nat.succ_le_of_lt h)]
#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -120,34 +120,16 @@ theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x]
#align list.rtake_concat_succ List.rtake_concat_succ
-/
-/- warning: list.rdrop_while -> List.rdropWhile is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], (List.{u1} α) -> (List.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}}, (α -> Bool) -> (List.{u1} α) -> (List.{u1} α)
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while List.rdropWhileₓ'. -/
/-- Drop elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
def rdropWhile : List α :=
reverse (l.reverse.dropWhileₓ p)
#align list.rdrop_while List.rdropWhile
-/- warning: list.rdrop_while_nil -> List.rdropWhile_nil is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (List.nil.{u1} α)) (List.nil.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (List.nil.{u1} α)) (List.nil.{u1} α)
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_nil List.rdropWhile_nilₓ'. -/
@[simp]
theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdrop_while, drop_while]
#align list.rdrop_while_nil List.rdropWhile_nil
-/- warning: list.rdrop_while_concat -> List.rdropWhile_concat is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (ite.{succ u1} (List.{u1} α) (p x) (_inst_1 x) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α))))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (ite.{succ u1} (List.{u1} α) (Eq.{1} Bool (p l) Bool.true) (instDecidableEqBool (p l) Bool.true) (List.rdropWhile.{u1} α p _inst_1) (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α))))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_concat List.rdropWhile_concatₓ'. -/
theorem rdropWhile_concat (x : α) :
rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] :=
by
@@ -155,44 +137,20 @@ theorem rdropWhile_concat (x : α) :
split_ifs with h h <;> simp [h]
#align list.rdrop_while_concat List.rdropWhile_concat
-/- warning: list.rdrop_while_concat_pos -> List.rdropWhile_concat_pos is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), (p x) -> (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), (Eq.{1} Bool (p l) Bool.true) -> (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (List.rdropWhile.{u1} α p _inst_1))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_concat_pos List.rdropWhile_concat_posₓ'. -/
@[simp]
theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
rw [rdrop_while_concat, if_pos h]
#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
-/- warning: list.rdrop_while_concat_neg -> List.rdropWhile_concat_neg is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), (Not (p x)) -> (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α))))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), (Not (Eq.{1} Bool (p l) Bool.true)) -> (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α))))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_concat_neg List.rdropWhile_concat_negₓ'. -/
@[simp]
theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
rw [rdrop_while_concat, if_neg h]
#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
-/- warning: list.rdrop_while_singleton -> List.rdropWhile_singleton is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (x : α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (List.cons.{u1} α x (List.nil.{u1} α))) (ite.{succ u1} (List.{u1} α) (p x) (_inst_1 x) (List.nil.{u1} α) (List.cons.{u1} α x (List.nil.{u1} α)))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (List.cons.{u1} α _inst_1 (List.nil.{u1} α))) (ite.{succ u1} (List.{u1} α) (Eq.{1} Bool (p _inst_1) Bool.true) (instDecidableEqBool (p _inst_1) Bool.true) (List.nil.{u1} α) (List.cons.{u1} α _inst_1 (List.nil.{u1} α)))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_singleton List.rdropWhile_singletonₓ'. -/
theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdrop_while_concat, rdrop_while_nil]
#align list.rdrop_while_singleton List.rdropWhile_singleton
-/- warning: list.rdrop_while_last_not -> List.rdropWhile_last_not is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (hl : Ne.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (List.nil.{u1} α)), Not (p (List.getLast.{u1} α (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) hl))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : Ne.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p _inst_1) (List.nil.{u1} α)), Not (Eq.{1} Bool (p (List.getLast.{u1} α (List.rdropWhile.{u1} α p _inst_1) l)) Bool.true)
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_last_not List.rdropWhile_last_notₓ'. -/
theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) :=
by
simp_rw [rdrop_while]
@@ -200,12 +158,6 @@ theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l)
exact drop_while_nth_le_zero_not _ _ _
#align list.rdrop_while_last_not List.rdropWhile_last_not
-/- warning: list.rdrop_while_prefix -> List.rdropWhile_prefix is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α), List.isPrefix.{u1} α (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) l
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α), List.isPrefix.{u1} α (List.rdropWhile.{u1} α p _inst_1) _inst_1
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_prefix List.rdropWhile_prefixₓ'. -/
theorem rdropWhile_prefix : l.rdropWhile p <+: l :=
by
rw [← reverse_suffix, rdrop_while, reverse_reverse]
@@ -214,22 +166,10 @@ theorem rdropWhile_prefix : l.rdropWhile p <+: l :=
variable {p} {l}
-/- warning: list.rdrop_while_eq_nil_iff -> List.rdropWhile_eq_nil_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (List.nil.{u1} α)) (forall (x : α), (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) -> (p x))
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p _inst_1) (List.nil.{u1} α)) (forall (x : α), (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x _inst_1) -> (Eq.{1} Bool (p x) Bool.true))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iffₓ'. -/
@[simp]
theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdrop_while]
#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
-/- warning: list.drop_while_eq_self_iff -> List.dropWhile_eq_self_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.dropWhileₓ.{u1} α p (fun (a : α) => _inst_1 a) l) l) (forall (hl : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (List.length.{u1} α l)), Not (p (List.nthLe.{u1} α l (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) hl)))
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.dropWhile.{u1} α p _inst_1) _inst_1) (forall (hl : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (List.length.{u1} α _inst_1)), Not (Eq.{1} Bool (p (List.nthLe.{u1} α _inst_1 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) hl)) Bool.true))
-Case conversion may be inaccurate. Consider using '#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iffₓ'. -/
-- it is in this file because it requires `list.infix`
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) :=
@@ -246,12 +186,6 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
· simp [h]
#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff
-/- warning: list.rdrop_while_eq_self_iff -> List.rdropWhile_eq_self_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l) l) (forall (hl : Ne.{succ u1} (List.{u1} α) l (List.nil.{u1} α)), Not (p (List.getLast.{u1} α l hl)))
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p _inst_1) _inst_1) (forall (hl : Ne.{succ u1} (List.{u1} α) _inst_1 (List.nil.{u1} α)), Not (Eq.{1} Bool (p (List.getLast.{u1} α _inst_1 hl)) Bool.true))
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iffₓ'. -/
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) :=
by
@@ -267,54 +201,24 @@ theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (
variable (p) (l)
-/- warning: list.drop_while_idempotent -> List.dropWhile_idempotent is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.dropWhileₓ.{u1} α p (fun (a : α) => _inst_1 a) (List.dropWhileₓ.{u1} α p (fun (a : α) => _inst_1 a) l)) (List.dropWhileₓ.{u1} α p (fun (a : α) => _inst_1 a) l)
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.dropWhile.{u1} α p (List.dropWhile.{u1} α p _inst_1)) (List.dropWhile.{u1} α p _inst_1)
-Case conversion may be inaccurate. Consider using '#align list.drop_while_idempotent List.dropWhile_idempotentₓ'. -/
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l :=
dropWhile_eq_self_iff.mpr (dropWhile_nthLe_zero_not _ _)
#align list.drop_while_idempotent List.dropWhile_idempotent
-/- warning: list.rdrop_while_idempotent -> List.rdropWhile_idempotent is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l)) (List.rdropWhile.{u1} α p (fun (a : α) => _inst_1 a) l)
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.rdropWhile.{u1} α p (List.rdropWhile.{u1} α p _inst_1)) (List.rdropWhile.{u1} α p _inst_1)
-Case conversion may be inaccurate. Consider using '#align list.rdrop_while_idempotent List.rdropWhile_idempotentₓ'. -/
theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
#align list.rdrop_while_idempotent List.rdropWhile_idempotent
-/- warning: list.rtake_while -> List.rtakeWhile is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], (List.{u1} α) -> (List.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}}, (α -> Bool) -> (List.{u1} α) -> (List.{u1} α)
-Case conversion may be inaccurate. Consider using '#align list.rtake_while List.rtakeWhileₓ'. -/
/-- Take elements from the tail end of a list that satisfy `p : α → Prop`.
Implemented naively via `list.reverse` -/
def rtakeWhile : List α :=
reverse (l.reverse.takeWhile p)
#align list.rtake_while List.rtakeWhile
-/- warning: list.rtake_while_nil -> List.rtakeWhile_nil is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) (List.nil.{u1} α)) (List.nil.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool), Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (List.nil.{u1} α)) (List.nil.{u1} α)
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_nil List.rtakeWhile_nilₓ'. -/
@[simp]
theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by simp [rtake_while, take_while]
#align list.rtake_while_nil List.rtakeWhile_nil
-/- warning: list.rtake_while_concat -> List.rtakeWhile_concat is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (ite.{succ u1} (List.{u1} α) (p x) (_inst_1 x) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (List.cons.{u1} α x (List.nil.{u1} α))) (List.nil.{u1} α))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (ite.{succ u1} (List.{u1} α) (Eq.{1} Bool (p l) Bool.true) (instDecidableEqBool (p l) Bool.true) (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) (List.rtakeWhile.{u1} α p _inst_1) (List.cons.{u1} α l (List.nil.{u1} α))) (List.nil.{u1} α))
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_concat List.rtakeWhile_concatₓ'. -/
theorem rtakeWhile_concat (x : α) :
rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] :=
by
@@ -322,34 +226,16 @@ theorem rtakeWhile_concat (x : α) :
split_ifs with h h <;> simp [h]
#align list.rtake_while_concat List.rtakeWhile_concat
-/- warning: list.rtake_while_concat_pos -> List.rtakeWhile_concat_pos is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), (p x) -> (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (List.cons.{u1} α x (List.nil.{u1} α))))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), (Eq.{1} Bool (p l) Bool.true) -> (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) (List.rtakeWhile.{u1} α p _inst_1) (List.cons.{u1} α l (List.nil.{u1} α))))
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_concat_pos List.rtakeWhile_concat_posₓ'. -/
@[simp]
theorem rtakeWhile_concat_pos (x : α) (h : p x) : rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] :=
by rw [rtake_while_concat, if_pos h]
#align list.rtake_while_concat_pos List.rtakeWhile_concat_pos
-/- warning: list.rtake_while_concat_neg -> List.rtakeWhile_concat_neg is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α) (x : α), (Not (p x)) -> (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) (Append.append.{u1} (List.{u1} α) (List.hasAppend.{u1} α) l (List.cons.{u1} α x (List.nil.{u1} α)))) (List.nil.{u1} α))
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α) (l : α), (Not (Eq.{1} Bool (p l) Bool.true)) -> (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (HAppend.hAppend.{u1, u1, u1} (List.{u1} α) (List.{u1} α) (List.{u1} α) (instHAppend.{u1} (List.{u1} α) (List.instAppendList.{u1} α)) _inst_1 (List.cons.{u1} α l (List.nil.{u1} α)))) (List.nil.{u1} α))
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_concat_neg List.rtakeWhile_concat_negₓ'. -/
@[simp]
theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
rw [rtake_while_concat, if_neg h]
#align list.rtake_while_concat_neg List.rtakeWhile_concat_neg
-/- warning: list.rtake_while_suffix -> List.rtakeWhile_suffix is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α), List.isSuffix.{u1} α (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l) l
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α), List.isSuffix.{u1} α (List.rtakeWhile.{u1} α p _inst_1) _inst_1
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_suffix List.rtakeWhile_suffixₓ'. -/
theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l :=
by
rw [← reverse_prefix, rtake_while, reverse_reverse]
@@ -358,34 +244,16 @@ theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l :=
variable {p} {l}
-/- warning: list.rtake_while_eq_self_iff -> List.rtakeWhile_eq_self_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l) l) (forall (x : α), (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) -> (p x))
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p _inst_1) _inst_1) (forall (x : α), (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x _inst_1) -> (Eq.{1} Bool (p x) Bool.true))
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iffₓ'. -/
@[simp]
theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
simp [rtake_while, reverse_eq_iff]
#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iff
-/- warning: list.rtake_while_eq_nil_iff -> List.rtakeWhile_eq_nil_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l) (List.nil.{u1} α)) (forall (hl : Ne.{succ u1} (List.{u1} α) l (List.nil.{u1} α)), Not (p (List.getLast.{u1} α l hl)))
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α}, Iff (Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p _inst_1) (List.nil.{u1} α)) (forall (hl : Ne.{succ u1} (List.{u1} α) _inst_1 (List.nil.{u1} α)), Not (Eq.{1} Bool (p (List.getLast.{u1} α _inst_1 hl)) Bool.true))
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iffₓ'. -/
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
induction l using List.reverseRecOn <;> simp [rtake_while]
#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iff
-/- warning: list.mem_rtake_while_imp -> List.mem_rtakeWhile_imp is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : α -> Prop} [_inst_1 : DecidablePred.{succ u1} α p] {l : List.{u1} α} {x : α}, (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l)) -> (p x)
-but is expected to have type
- forall {α : Type.{u1}} {p : α -> Bool} {_inst_1 : List.{u1} α} {l : α}, (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) l (List.rtakeWhile.{u1} α p _inst_1)) -> (Eq.{1} Bool (p l) Bool.true)
-Case conversion may be inaccurate. Consider using '#align list.mem_rtake_while_imp List.mem_rtakeWhile_impₓ'. -/
theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x :=
by
suffices x ∈ take_while p l.reverse by exact mem_take_while_imp this
@@ -394,12 +262,6 @@ theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x :=
variable (p) (l)
-/- warning: list.rtake_while_idempotent -> List.rtakeWhile_idempotent is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] (l : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l)) (List.rtakeWhile.{u1} α p (fun (a : α) => _inst_1 a) l)
-but is expected to have type
- forall {α : Type.{u1}} (p : α -> Bool) (_inst_1 : List.{u1} α), Eq.{succ u1} (List.{u1} α) (List.rtakeWhile.{u1} α p (List.rtakeWhile.{u1} α p _inst_1)) (List.rtakeWhile.{u1} α p _inst_1)
-Case conversion may be inaccurate. Consider using '#align list.rtake_while_idempotent List.rtakeWhile_idempotentₓ'. -/
theorem rtakeWhile_idempotent : rtakeWhile p (rtakeWhile p l) = rtakeWhile p l :=
rtakeWhile_eq_self_iff.mpr fun _ => mem_rtakeWhile_imp
#align list.rtake_while_idempotent List.rtakeWhile_idempotent
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
Remove dependencies on algebra in the Data.List
folder except for:
Data.List.EditDistance
: Actually relies on algebra. Maybe should be moved?Data.List.Card
: Completely unused and redundant.Data.List.Cycle
: Relies on Fintype
, which shouldn't rely on algebra but it's hard to fix right now. Maybe should be moved?Data.List.Func
: Completely unused and redundant.Data.List.Lex
: That's order theory. Could be moved.Data.List.Prime
. That's algebra. Should definitely be moved.Data.List.Sym
: Relies on Multiset
, which shouldn't rely on algebra but it's hard to fix right now. Maybe should be moved?Data.List.ToFinsupp
: That's algebra. Should definitely be moved.As a consequence, move the big operators lemmas that were in there to Algebra.BigOperators.List.Basic
. For the lemmas that were Nat
-specific and not about auxiliary definitions, keep a version of them in the original file but stated using Nat.sum
.
Before
After
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.List.Infix
-import Mathlib.Data.Nat.Order.Basic
#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
@@ -32,6 +31,8 @@ another function that takes a `L : ℕ` and use `L - n`. Under a proof condition
-/
+-- Make sure we don't import algebra
+assert_not_exists Monoid
variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
Removes the insertNth
section of this long file to its own new file. This section seems to be completely independent of the rest of the file, so this is a fairly easy split to make.
@@ -3,7 +3,6 @@ Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
-import Mathlib.Data.List.Basic
import Mathlib.Data.List.Infix
import Mathlib.Data.Nat.Order.Basic
Use Nat
specialized theorems, and omega
, where necessary to avoid needing to import the abstract ordered algebra hierarchy for basic results about List
.
Import graph between Mathlib.Order.Basic
and Mathlib.Data.List.Basic
:
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -5,6 +5,7 @@ Authors: Yakov Pechersky
-/
import Mathlib.Data.List.Basic
import Mathlib.Data.List.Infix
+import Mathlib.Data.Nat.Order.Basic
#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
I think this one should merge cleanly, after which we have some work to do for #9039
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -228,7 +228,7 @@ theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (
induction' l using List.reverseRecOn with l a
· simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
intro f; contradiction
- · simp only [rtakeWhile, reverse_append, takeWhile, reverse_eq_nil, getLast_append, ne_eq,
+ · simp only [rtakeWhile, reverse_append, takeWhile, reverse_eq_nil_iff, getLast_append, ne_eq,
append_eq_nil, and_false, not_false_eq_true, forall_true_left]
refine' ⟨fun h => _ , fun h => _⟩
· intro pa; simp [pa] at h
This is the supremum of
along with some minor fixes from failures on nightly-testing as Mathlib master
is merged into it.
Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.
I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0
branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.
In particular this includes adjustments for the Lean PRs
We can get rid of all the
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)
macros across Mathlib (and in any projects that want to write natural number powers of reals).
Changes the default behaviour of simp
to (config := {decide := false})
. This makes simp
(and consequentially norm_num
) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp
or norm_num
to decide
or rfl
, or adding (config := {decide := true})
.
This changed the behaviour of simp
so that simp [f]
will only unfold "fully applied" occurrences of f
. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true })
. We may in future add a syntax for this, e.g. simp [!f]
; please provide feedback! In the meantime, we have made the following changes:
(config := { unfoldPartialApp := true })
in some places, to recover the old behaviour@[eqns]
to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp
and Function.flip
.This change in Lean may require further changes down the line (e.g. adding the !f
syntax, and/or upstreaming the special treatment for Function.comp
and Function.flip
, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>
@@ -15,12 +15,12 @@ Taking or removing element from the tail end of a list
## Main definitions
-- `dropRight n`: drop `n : ℕ` elements from the tail
-- `takeRight n`: take `n : ℕ` elements from the tail
-- `dropRightWhile p`: remove all the elements from the tail of a list until it finds the first
- element for which `p : α → Bool` returns false. This element and everything before is returned.
-- `takeRightWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool`
- returns true.
+- `rdrop n`: drop `n : ℕ` elements from the tail
+- `rtake n`: take `n : ℕ` elements from the tail
+- `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element
+ for which `p : α → Bool` returns false. This element and everything before is returned.
+- `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns
+ true.
## Implementation detail
@@ -38,113 +38,109 @@ variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
/-- Drop `n` elements from the tail end of a list. -/
-def dropRight : List α :=
+def rdrop : List α :=
l.take (l.length - n)
-#align list.rdrop List.dropRight
+#align list.rdrop List.rdrop
@[simp]
-theorem dropRight_nil : dropRight ([] : List α) n = [] := by simp [dropRight]
-#align list.rdrop_nil List.dropRight_nil
+theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
+#align list.rdrop_nil List.rdrop_nil
@[simp]
-theorem dropRight_zero : dropRight l 0 = l := by simp [dropRight]
-#align list.rdrop_zero List.dropRight_zero
+theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
+#align list.rdrop_zero List.rdrop_zero
-theorem dropRight_eq_reverse_drop_reverse : l.dropRight n = reverse (l.reverse.drop n) := by
- rw [dropRight]
+theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
+ rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
-#align list.rdrop_eq_reverse_drop_reverse List.dropRight_eq_reverse_drop_reverse
+#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
@[simp]
-theorem dropRight_concat_succ (x : α) : dropRight (l ++ [x]) (n + 1) = dropRight l n := by
- simp [dropRight_eq_reverse_drop_reverse]
-#align list.rdrop_concat_succ List.dropRight_concat_succ
+theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
+ simp [rdrop_eq_reverse_drop_reverse]
+#align list.rdrop_concat_succ List.rdrop_concat_succ
/-- Take `n` elements from the tail end of a list. -/
-def takeRight : List α :=
+def rtake : List α :=
l.drop (l.length - n)
-#align list.rtake List.takeRight
+#align list.rtake List.rtake
@[simp]
-theorem takeRight_nil : takeRight ([] : List α) n = [] := by simp [takeRight]
-#align list.rtake_nil List.takeRight_nil
+theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
+#align list.rtake_nil List.rtake_nil
@[simp]
-theorem takeRight_zero : takeRight l 0 = [] := by simp [takeRight]
-#align list.rtake_zero List.takeRight_zero
+theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
+#align list.rtake_zero List.rtake_zero
-theorem takeRight_eq_reverse_take_reverse : l.takeRight n = reverse (l.reverse.take n) := by
- rw [takeRight]
+theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by
+ rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· exact drop_length _
· simp [drop_append_eq_append_drop, IH]
-#align list.rtake_eq_reverse_take_reverse List.takeRight_eq_reverse_take_reverse
+#align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse
@[simp]
-theorem takeRight_concat_succ (x : α) : takeRight (l ++ [x]) (n + 1) = takeRight l n ++ [x] := by
- simp [takeRight_eq_reverse_take_reverse]
-#align list.rtake_concat_succ List.takeRight_concat_succ
+theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
+ simp [rtake_eq_reverse_take_reverse]
+#align list.rtake_concat_succ List.rtake_concat_succ
/-- Drop elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/
-def dropRightWhile : List α :=
+def rdropWhile : List α :=
reverse (l.reverse.dropWhile p)
-#align list.rdrop_while List.dropRightWhile
+#align list.rdrop_while List.rdropWhile
@[simp]
-theorem dropRightWhile_nil : dropRightWhile p ([] : List α) = [] := by
- simp [dropRightWhile, dropWhile]
-#align list.rdrop_while_nil List.dropRightWhile_nil
+theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile]
+#align list.rdrop_while_nil List.rdropWhile_nil
-theorem dropRightWhile_concat (x : α) :
- dropRightWhile p (l ++ [x]) = if p x then dropRightWhile p l else l ++ [x] := by
- simp only [dropRightWhile, dropWhile, reverse_append, reverse_singleton, singleton_append]
+theorem rdropWhile_concat (x : α) :
+ rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by
+ simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append]
split_ifs with h <;> simp [h]
-#align list.rdrop_while_concat List.dropRightWhile_concat
+#align list.rdrop_while_concat List.rdropWhile_concat
@[simp]
-theorem dropRightWhile_concat_pos (x : α) (h : p x) :
- dropRightWhile p (l ++ [x]) = dropRightWhile p l := by
- rw [dropRightWhile_concat, if_pos h]
-#align list.rdrop_while_concat_pos List.dropRightWhile_concat_pos
+theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
+ rw [rdropWhile_concat, if_pos h]
+#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
@[simp]
-theorem dropRightWhile_concat_neg (x : α) (h : ¬p x) : dropRightWhile p (l ++ [x]) = l ++ [x] := by
- rw [dropRightWhile_concat, if_neg h]
-#align list.rdrop_while_concat_neg List.dropRightWhile_concat_neg
+theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
+ rw [rdropWhile_concat, if_neg h]
+#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
-theorem dropRightWhile_singleton (x : α) : dropRightWhile p [x] = if p x then [] else [x] := by
- rw [← nil_append [x], dropRightWhile_concat, dropRightWhile_nil]
-#align list.rdrop_while_singleton List.dropRightWhile_singleton
+theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
+ rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil]
+#align list.rdrop_while_singleton List.rdropWhile_singleton
-theorem dropRightWhile_last_not (hl : l.dropRightWhile p ≠ []) :
- ¬p ((dropRightWhile p l).getLast hl) := by
- simp_rw [dropRightWhile]
+theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by
+ simp_rw [rdropWhile]
rw [getLast_reverse]
exact dropWhile_nthLe_zero_not _ _ _
-#align list.rdrop_while_last_not List.dropRightWhile_last_not
+#align list.rdrop_while_last_not List.rdropWhile_last_not
-theorem dropRightWhile_prefix : l.dropRightWhile p <+: l := by
- rw [← reverse_suffix, dropRightWhile, reverse_reverse]
+theorem rdropWhile_prefix : l.rdropWhile p <+: l := by
+ rw [← reverse_suffix, rdropWhile, reverse_reverse]
exact dropWhile_suffix _
-#align list.rdrop_while_prefix List.dropRightWhile_prefix
+#align list.rdrop_while_prefix List.rdropWhile_prefix
variable {p} {l}
@[simp]
-theorem dropRightWhile_eq_nil_iff : dropRightWhile p l = [] ↔ ∀ x ∈ l, p x := by
- simp [dropRightWhile]
-#align list.rdrop_while_eq_nil_iff List.dropRightWhile_eq_nil_iff
+theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdropWhile]
+#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
-- it is in this file because it requires `List.Infix`
@[simp]
-theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.get ⟨0, hl⟩) := by
+theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
cases' l with hd tl
· simp only [dropWhile, true_iff]
intro h
@@ -153,28 +149,29 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
· rw [dropWhile]
refine' ⟨fun h => _, fun h => _⟩
· intro _ H
- rw [get] at H
+ rw [nthLe, get] at H
refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
rw [← h]
simp only [H]
exact List.IsSuffix.sublist (dropWhile_suffix p)
· have := h (by simp only [length, Nat.succ_pos])
- rw [get] at this
+ rw [nthLe, get] at this
simp_rw [this]
#align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff
/- porting note: This proof is longer than it used to be because `simp` refuses to rewrite
the `l ≠ []` condition if `hl` is not `intro`'d yet -/
@[simp]
-theorem dropRightWhile_eq_self_iff : dropRightWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
- simp only [dropRightWhile._eq_1, reverse_eq_iff, dropWhile_eq_self_iff, length_reverse,
- ←length_pos, ne_eq, Bool.not_eq_true, getLast_eq_get, ge_iff_le]
- refine forall_congr' ?_
- intro h
- rw [get_reverse']
- · simp
- · exact Nat.pred_lt h.ne'
-#align list.rdrop_while_eq_self_iff List.dropRightWhile_eq_self_iff
+theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
+ simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
+ refine' ⟨fun h hl => _, fun h hl => _⟩
+ · rw [← length_pos, ← length_reverse] at hl
+ have := h hl
+ rwa [nthLe, get_reverse'] at this
+ · rw [length_reverse, length_pos] at hl
+ have := h hl
+ rwa [nthLe, get_reverse']
+#align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff
variable (p) (l)
@@ -183,72 +180,70 @@ theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
exact fun h => dropWhile_nthLe_zero_not p l h
#align list.drop_while_idempotent List.dropWhile_idempotent
-theorem dropRightWhile_idempotent : dropRightWhile p (dropRightWhile p l) = dropRightWhile p l :=
- dropRightWhile_eq_self_iff.mpr (dropRightWhile_last_not _ _)
-#align list.rdrop_while_idempotent List.dropRightWhile_idempotent
+theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
+ rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
+#align list.rdrop_while_idempotent List.rdropWhile_idempotent
/-- Take elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/
-def takeRightWhile : List α :=
+def rtakeWhile : List α :=
reverse (l.reverse.takeWhile p)
-#align list.rtake_while List.takeRightWhile
+#align list.rtake_while List.rtakeWhile
@[simp]
-theorem takeRightWhile_nil : takeRightWhile p ([] : List α) = [] := by
- simp [takeRightWhile, takeWhile]
-#align list.rtake_while_nil List.takeRightWhile_nil
+theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by simp [rtakeWhile, takeWhile]
+#align list.rtake_while_nil List.rtakeWhile_nil
-theorem takeRightWhile_concat (x : α) :
- takeRightWhile p (l ++ [x]) = if p x then takeRightWhile p l ++ [x] else [] := by
- simp only [takeRightWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
+theorem rtakeWhile_concat (x : α) :
+ rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] := by
+ simp only [rtakeWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
split_ifs with h <;> simp [h]
-#align list.rtake_while_concat List.takeRightWhile_concat
+#align list.rtake_while_concat List.rtakeWhile_concat
@[simp]
-theorem takeRightWhile_concat_pos (x : α) (h : p x) :
- takeRightWhile p (l ++ [x]) = takeRightWhile p l ++ [x] := by
- rw [takeRightWhile_concat, if_pos h]
-#align list.rtake_while_concat_pos List.takeRightWhile_concat_pos
+theorem rtakeWhile_concat_pos (x : α) (h : p x) :
+ rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] := by rw [rtakeWhile_concat, if_pos h]
+#align list.rtake_while_concat_pos List.rtakeWhile_concat_pos
@[simp]
-theorem takeRightWhile_concat_neg (x : α) (h : ¬p x) : takeRightWhile p (l ++ [x]) = [] := by
- rw [takeRightWhile_concat, if_neg h]
-#align list.rtake_while_concat_neg List.takeRightWhile_concat_neg
+theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
+ rw [rtakeWhile_concat, if_neg h]
+#align list.rtake_while_concat_neg List.rtakeWhile_concat_neg
-theorem takeRightWhile_suffix : l.takeRightWhile p <:+ l := by
- rw [← reverse_prefix, takeRightWhile, reverse_reverse]
+theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l := by
+ rw [← reverse_prefix, rtakeWhile, reverse_reverse]
exact takeWhile_prefix _
-#align list.rtake_while_suffix List.takeRightWhile_suffix
+#align list.rtake_while_suffix List.rtakeWhile_suffix
variable {p} {l}
@[simp]
-theorem takeRightWhile_eq_self_iff : takeRightWhile p l = l ↔ ∀ x ∈ l, p x := by
- simp [takeRightWhile, reverse_eq_iff]
-#align list.rtake_while_eq_self_iff List.takeRightWhile_eq_self_iff
+theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
+ simp [rtakeWhile, reverse_eq_iff]
+#align list.rtake_while_eq_self_iff List.rtakeWhile_eq_self_iff
-- Porting note: This needed a lot of rewriting.
@[simp]
-theorem takeRightWhile_eq_nil_iff : takeRightWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
+theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
induction' l using List.reverseRecOn with l a
- · simp only [takeRightWhile, takeWhile, reverse_nil, true_iff]
+ · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
intro f; contradiction
- · simp only [takeRightWhile, reverse_append, takeWhile, reverse_eq_nil, getLast_append, ne_eq,
- append_eq_nil, and_false, forall_true_left]
+ · simp only [rtakeWhile, reverse_append, takeWhile, reverse_eq_nil, getLast_append, ne_eq,
+ append_eq_nil, and_false, not_false_eq_true, forall_true_left]
refine' ⟨fun h => _ , fun h => _⟩
- · intro pa; simp only [pa] at h
- · simp only [h]
-#align list.rtake_while_eq_nil_iff List.takeRightWhile_eq_nil_iff
+ · intro pa; simp [pa] at h
+ · simp [h]
+#align list.rtake_while_eq_nil_iff List.rtakeWhile_eq_nil_iff
-theorem mem_takeRightWhile_imp {x : α} (hx : x ∈ takeRightWhile p l) : p x := by
- rw [takeRightWhile, mem_reverse] at hx
+theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x := by
+ rw [rtakeWhile, mem_reverse] at hx
exact mem_takeWhile_imp hx
-#align list.mem_rtake_while_imp List.mem_takeRightWhile_imp
+#align list.mem_rtake_while_imp List.mem_rtakeWhile_imp
variable (p) (l)
-theorem takeRightWhile_idempotent : takeRightWhile p (takeRightWhile p l) = takeRightWhile p l :=
- takeRightWhile_eq_self_iff.mpr fun _ => mem_takeRightWhile_imp
-#align list.rtake_while_idempotent List.takeRightWhile_idempotent
+theorem rtakeWhile_idempotent : rtakeWhile p (rtakeWhile p l) = rtakeWhile p l :=
+ rtakeWhile_eq_self_iff.mpr fun _ => mem_rtakeWhile_imp
+#align list.rtake_while_idempotent List.rtakeWhile_idempotent
end List
@@ -153,7 +153,7 @@ theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p
refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
rw [← h]
simp only [H]
- exact List.isSuffix.sublist (dropWhile_suffix p)
+ exact List.IsSuffix.sublist (dropWhile_suffix p)
· have := h (by simp only [length, Nat.succ_pos])
rw [nthLe, get] at this
simp_rw [this]
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -33,7 +33,7 @@ another function that takes a `L : ℕ` and use `L - n`. Under a proof condition
-/
-variable {α : Type _} (p : α → Bool) (l : List α) (n : ℕ)
+variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
@@ -2,14 +2,11 @@
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-
-! This file was ported from Lean 3 source module data.list.rdrop
-! leanprover-community/mathlib commit 26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.List.Basic
import Mathlib.Data.List.Infix
+
+#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
# Dropping or taking from lists on the right
I ran codespell Mathlib
and got tired halfway through the suggestions.
@@ -16,7 +16,7 @@ import Mathlib.Data.List.Infix
Taking or removing element from the tail end of a list
-## Main defintions
+## Main definitions
- `rdrop n`: drop `n : ℕ` elements from the tail
- `rtake n`: take `n : ℕ` elements from the tail
This PR fixes two things:
align
statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align
). This is often seen in the mathport output after ending calc
blocks.#align
statements. (This was needed for a script I wrote for #3630.)@@ -181,7 +181,6 @@ variable (p) (l)
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
simp only [dropWhile_eq_self_iff]
exact fun h => dropWhile_nthLe_zero_not p l h
-
#align list.drop_while_idempotent List.dropWhile_idempotent
theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
@@ -242,7 +241,6 @@ theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (
theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x := by
rw [rtakeWhile, mem_reverse] at hx
exact mem_takeWhile_imp hx
-
#align list.mem_rtake_while_imp List.mem_rtakeWhile_imp
variable (p) (l)
@@ -184,9 +184,9 @@ theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
#align list.drop_while_idempotent List.dropWhile_idempotent
-theorem rdrop_while_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
+theorem rdropWhile_idempotent : rdropWhile p (rdropWhile p l) = rdropWhile p l :=
rdropWhile_eq_self_iff.mpr (rdropWhile_last_not _ _)
-#align list.rdrop_while_idempotent List.rdrop_while_idempotent
+#align list.rdrop_while_idempotent List.rdropWhile_idempotent
/-- Take elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/