data.stream.init
⟷
Mathlib.Data.Stream.Init
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)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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
@@ -168,7 +168,7 @@ theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a =
fun ⟨n, h⟩ => by
cases' n with n'
· left; exact h
- · right; rw [nth_succ, tail_cons] at h ; exact ⟨n', h⟩
+ · right; rw [nth_succ, tail_cons] at h; exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
-/
@@ -325,7 +325,7 @@ theorem const_eq (a : α) : const a = a::const a :=
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print Stream'.tail_const /-
theorem tail_const (a : α) : tail (const a) = const a :=
- suffices tail (a::const a) = const a by rwa [← const_eq] at this
+ suffices tail (a::const a) = const a by rwa [← const_eq] at this
rfl
#align stream.tail_const Stream'.tail_const
-/
@@ -361,8 +361,8 @@ theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (
induction' n with n' ih
· rfl
· unfold tail iterate
- unfold tail iterate at ih
- rw [add_one] at ih ; dsimp at ih
+ unfold tail iterate at ih
+ rw [add_one] at ih; dsimp at ih
rw [add_one]; dsimp; rw [ih]
#align stream.tail_iterate Stream'.tail_iterate
-/
@@ -466,7 +466,7 @@ theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate
induction' n with n' ih
· rfl
· unfold map iterate nth; dsimp
- unfold map iterate nth at ih ; dsimp at ih
+ unfold map iterate nth at ih; dsimp at ih
rw [ih]
#align stream.map_iterate Stream'.map_iterate
-/
@@ -782,7 +782,7 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
by
intro h; apply Stream'.ext; intro n
induction' n with n ih
- · have aux := h 1; simp [take] at aux ; exact aux
+ · have aux := h 1; simp [take] at aux; exact aux
· have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)) := by
rw [← nth_take_succ, ← nth_take_succ, h (succ (succ n))]
injection h₁
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -38,11 +38,11 @@ protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print Stream'.nth_zero_cons /-
+#print Stream'.get_zero_cons /-
@[simp]
-theorem nth_zero_cons (a : α) (s : Stream' α) : nth (a::s) 0 = a :=
+theorem get_zero_cons (a : α) (s : Stream' α) : get (a::s) 0 = a :=
rfl
-#align stream.nth_zero_cons Stream'.nth_zero_cons
+#align stream.nth_zero_cons Stream'.get_zero_cons
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -65,10 +65,10 @@ theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s)
#align stream.tail_drop Stream'.tail_drop
-/
-#print Stream'.nth_drop /-
-theorem nth_drop (n m : Nat) (s : Stream' α) : nth (drop m s) n = nth s (n + m) :=
+#print Stream'.get_drop /-
+theorem get_drop (n m : Nat) (s : Stream' α) : get (drop m s) n = get s (n + m) :=
rfl
-#align stream.nth_drop Stream'.nth_drop
+#align stream.nth_drop Stream'.get_drop
-/
#print Stream'.tail_eq_drop /-
@@ -83,18 +83,18 @@ theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m
#align stream.drop_drop Stream'.drop_drop
-/
-#print Stream'.nth_succ /-
-theorem nth_succ (n : Nat) (s : Stream' α) : nth s (succ n) = nth (tail s) n :=
+#print Stream'.get_succ /-
+theorem get_succ (n : Nat) (s : Stream' α) : get s (succ n) = get (tail s) n :=
rfl
-#align stream.nth_succ Stream'.nth_succ
+#align stream.nth_succ Stream'.get_succ
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print Stream'.nth_succ_cons /-
+#print Stream'.get_succ_cons /-
@[simp]
-theorem nth_succ_cons (n : Nat) (s : Stream' α) (x : α) : nth (x::s) n.succ = nth s n :=
+theorem get_succ_cons (n : Nat) (s : Stream' α) (x : α) : get (x::s) n.succ = get s n :=
rfl
-#align stream.nth_succ_cons Stream'.nth_succ_cons
+#align stream.nth_succ_cons Stream'.get_succ_cons
-/
#print Stream'.drop_succ /-
@@ -106,13 +106,13 @@ theorem drop_succ (n : Nat) (s : Stream' α) : drop (succ n) s = drop n (tail s)
#print Stream'.head_drop /-
@[simp]
theorem head_drop {α} (a : Stream' α) (n : ℕ) : (a.drop n).headI = a.get? n := by
- simp only [drop, head, Nat.zero_add, Stream'.nth]
+ simp only [drop, head, Nat.zero_add, Stream'.get]
#align stream.head_drop Stream'.head_drop
-/
#print Stream'.ext /-
@[ext]
-protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, nth s₁ n = nth s₂ n) → s₁ = s₂ := fun h =>
+protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, get s₁ n = get s₂ n) → s₁ = s₂ := fun h =>
funext h
#align stream.ext Stream'.ext
-/
@@ -137,13 +137,13 @@ theorem cons_injective_right (x : α) : Function.Injective (cons x) :=
-/
#print Stream'.all_def /-
-theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (nth s n) :=
+theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (get s n) :=
rfl
#align stream.all_def Stream'.all_def
-/
#print Stream'.any_def /-
-theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (nth s n) :=
+theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (get s n) :=
rfl
#align stream.any_def Stream'.any_def
-/
@@ -172,10 +172,10 @@ theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a =
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
-/
-#print Stream'.mem_of_nth_eq /-
-theorem mem_of_nth_eq {n : Nat} {s : Stream' α} {a : α} : a = nth s n → a ∈ s := fun h =>
+#print Stream'.mem_of_get_eq /-
+theorem mem_of_get_eq {n : Nat} {s : Stream' α} {a : α} : a = get s n → a ∈ s := fun h =>
Exists.intro n h
-#align stream.mem_of_nth_eq Stream'.mem_of_nth_eq
+#align stream.mem_of_nth_eq Stream'.mem_of_get_eq
-/
section Map
@@ -188,10 +188,10 @@ theorem drop_map (n : Nat) (s : Stream' α) : drop n (map f s) = map f (drop n s
#align stream.drop_map Stream'.drop_map
-/
-#print Stream'.nth_map /-
-theorem nth_map (n : Nat) (s : Stream' α) : nth (map f s) n = f (nth s n) :=
+#print Stream'.get_map /-
+theorem get_map (n : Nat) (s : Stream' α) : get (map f s) n = f (get s n) :=
rfl
-#align stream.nth_map Stream'.nth_map
+#align stream.nth_map Stream'.get_map
-/
#print Stream'.tail_map /-
@@ -247,7 +247,7 @@ theorem mem_map {a : α} {s : Stream' α} : a ∈ s → f a ∈ map f s := fun
#print Stream'.exists_of_mem_map /-
theorem exists_of_mem_map {f} {b : β} {s : Stream' α} : b ∈ map f s → ∃ a, a ∈ s ∧ f a = b :=
- fun ⟨n, h⟩ => ⟨nth s n, ⟨n, rfl⟩, h.symm⟩
+ fun ⟨n, h⟩ => ⟨get s n, ⟨n, rfl⟩, h.symm⟩
#align stream.exists_of_mem_map Stream'.exists_of_mem_map
-/
@@ -264,11 +264,11 @@ theorem drop_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
#align stream.drop_zip Stream'.drop_zip
-/
-#print Stream'.nth_zip /-
-theorem nth_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
- nth (zip f s₁ s₂) n = f (nth s₁ n) (nth s₂ n) :=
+#print Stream'.get_zip /-
+theorem get_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
+ get (zip f s₁ s₂) n = f (get s₁ n) (get s₂ n) :=
rfl
-#align stream.nth_zip Stream'.nth_zip
+#align stream.nth_zip Stream'.get_zip
-/
#print Stream'.head_zip /-
@@ -292,11 +292,11 @@ theorem zip_eq (s₁ : Stream' α) (s₂ : Stream' β) :
#align stream.zip_eq Stream'.zip_eq
-/
-#print Stream'.nth_enum /-
+#print Stream'.get_enum /-
@[simp]
-theorem nth_enum (s : Stream' α) (n : ℕ) : nth (enum s) n = (n, s.get? n) :=
+theorem get_enum (s : Stream' α) (n : ℕ) : get (enum s) n = (n, s.get? n) :=
rfl
-#align stream.nth_enum Stream'.nth_enum
+#align stream.nth_enum Stream'.get_enum
-/
#print Stream'.enum_eq_zip /-
@@ -336,10 +336,10 @@ theorem map_const (f : α → β) (a : α) : map f (const a) = const (f a) :=
#align stream.map_const Stream'.map_const
-/
-#print Stream'.nth_const /-
-theorem nth_const (n : Nat) (a : α) : nth (const a) n = a :=
+#print Stream'.get_const /-
+theorem get_const (n : Nat) (a : α) : get (const a) n = a :=
rfl
-#align stream.nth_const Stream'.nth_const
+#align stream.nth_const Stream'.get_const
-/
#print Stream'.drop_const /-
@@ -376,16 +376,16 @@ theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) :
#align stream.iterate_eq Stream'.iterate_eq
-/
-#print Stream'.nth_zero_iterate /-
-theorem nth_zero_iterate (f : α → α) (a : α) : nth (iterate f a) 0 = a :=
+#print Stream'.get_zero_iterate /-
+theorem get_zero_iterate (f : α → α) (a : α) : get (iterate f a) 0 = a :=
rfl
-#align stream.nth_zero_iterate Stream'.nth_zero_iterate
+#align stream.nth_zero_iterate Stream'.get_zero_iterate
-/
-#print Stream'.nth_succ_iterate /-
-theorem nth_succ_iterate (n : Nat) (f : α → α) (a : α) :
- nth (iterate f a) (succ n) = nth (iterate f (f a)) n := by rw [nth_succ, tail_iterate]
-#align stream.nth_succ_iterate Stream'.nth_succ_iterate
+#print Stream'.get_succ_iterate /-
+theorem get_succ_iterate (n : Nat) (f : α → α) (a : α) :
+ get (iterate f a) (succ n) = get (iterate f (f a)) n := by rw [nth_succ, tail_iterate]
+#align stream.nth_succ_iterate Stream'.get_succ_iterate
-/
section Bisim
@@ -400,20 +400,20 @@ def IsBisimulation :=
#align stream.is_bisimulation Stream'.IsBisimulation
-/
-#print Stream'.nth_of_bisim /-
-theorem nth_of_bisim (bisim : IsBisimulation R) :
- ∀ {s₁ s₂} (n), s₁ ~ s₂ → nth s₁ n = nth s₂ n ∧ drop (n + 1) s₁ ~ drop (n + 1) s₂
+#print Stream'.get_of_bisim /-
+theorem get_of_bisim (bisim : IsBisimulation R) :
+ ∀ {s₁ s₂} (n), s₁ ~ s₂ → get s₁ n = get s₂ n ∧ drop (n + 1) s₁ ~ drop (n + 1) s₂
| s₁, s₂, 0, h => bisim h
| s₁, s₂, n + 1, h =>
match bisim h with
| ⟨h₁, trel⟩ => nth_of_bisim n trel
-#align stream.nth_of_bisim Stream'.nth_of_bisim
+#align stream.nth_of_bisim Stream'.get_of_bisim
-/
#print Stream'.eq_of_bisim /-
-- If two streams are bisimilar, then they are equal
theorem eq_of_bisim (bisim : IsBisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ := fun s₁ s₂ r =>
- Stream'.ext fun n => And.left (nth_of_bisim R bisim n r)
+ Stream'.ext fun n => And.left (get_of_bisim R bisim n r)
#align stream.eq_of_bisim Stream'.eq_of_bisim
-/
@@ -518,19 +518,19 @@ theorem unfolds_eq (g : α → β) (f : α → α) (a : α) : unfolds g f a = g
#align stream.unfolds_eq Stream'.unfolds_eq
-/
-#print Stream'.nth_unfolds_head_tail /-
-theorem nth_unfolds_head_tail :
- ∀ (n : Nat) (s : Stream' α), nth (unfolds head tail s) n = nth s n :=
+#print Stream'.get_unfolds_head_tail /-
+theorem get_unfolds_head_tail :
+ ∀ (n : Nat) (s : Stream' α), get (unfolds head tail s) n = get s n :=
by
intro n; induction' n with n' ih
· intro s; rfl
· intro s; rw [nth_succ, nth_succ, unfolds_eq, tail_cons, ih]
-#align stream.nth_unfolds_head_tail Stream'.nth_unfolds_head_tail
+#align stream.nth_unfolds_head_tail Stream'.get_unfolds_head_tail
-/
#print Stream'.unfolds_head_eq /-
theorem unfolds_head_eq : ∀ s : Stream' α, unfolds head tail s = s := fun s =>
- Stream'.ext fun n => nth_unfolds_head_tail n s
+ Stream'.ext fun n => get_unfolds_head_tail n s
#align stream.unfolds_head_eq Stream'.unfolds_head_eq
-/
@@ -554,26 +554,26 @@ theorem interleave_tail_tail (s₁ s₂ : Stream' α) : tail s₁ ⋈ tail s₂
#align stream.interleave_tail_tail Stream'.interleave_tail_tail
-/
-#print Stream'.nth_interleave_left /-
-theorem nth_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α), nth (s₁ ⋈ s₂) (2 * n) = nth s₁ n
+#print Stream'.get_interleave_left /-
+theorem get_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α), get (s₁ ⋈ s₂) (2 * n) = get s₁ n
| 0, s₁, s₂ => rfl
| succ n, s₁, s₂ =>
by
change nth (s₁ ⋈ s₂) (succ (succ (2 * n))) = nth s₁ (succ n)
rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons, nth_interleave_left]
rfl
-#align stream.nth_interleave_left Stream'.nth_interleave_left
+#align stream.nth_interleave_left Stream'.get_interleave_left
-/
-#print Stream'.nth_interleave_right /-
-theorem nth_interleave_right : ∀ (n : Nat) (s₁ s₂ : Stream' α), nth (s₁ ⋈ s₂) (2 * n + 1) = nth s₂ n
+#print Stream'.get_interleave_right /-
+theorem get_interleave_right : ∀ (n : Nat) (s₁ s₂ : Stream' α), get (s₁ ⋈ s₂) (2 * n + 1) = get s₂ n
| 0, s₁, s₂ => rfl
| succ n, s₁, s₂ =>
by
change nth (s₁ ⋈ s₂) (succ (succ (2 * n + 1))) = nth s₂ (succ n)
rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons, nth_interleave_right]
rfl
-#align stream.nth_interleave_right Stream'.nth_interleave_right
+#align stream.nth_interleave_right Stream'.get_interleave_right
-/
#print Stream'.mem_interleave_left /-
@@ -644,19 +644,19 @@ theorem interleave_even_odd (s₁ : Stream' α) : even s₁ ⋈ odd s₁ = s₁
#align stream.interleave_even_odd Stream'.interleave_even_odd
-/
-#print Stream'.nth_even /-
-theorem nth_even : ∀ (n : Nat) (s : Stream' α), nth (even s) n = nth s (2 * n)
+#print Stream'.get_even /-
+theorem get_even : ∀ (n : Nat) (s : Stream' α), get (even s) n = get s (2 * n)
| 0, s => rfl
| succ n, s => by
change nth (Even s) (succ n) = nth s (succ (succ (2 * n)))
rw [nth_succ, nth_succ, tail_even, nth_even]; rfl
-#align stream.nth_even Stream'.nth_even
+#align stream.nth_even Stream'.get_even
-/
-#print Stream'.nth_odd /-
-theorem nth_odd : ∀ (n : Nat) (s : Stream' α), nth (odd s) n = nth s (2 * n + 1) := fun n s => by
+#print Stream'.get_odd /-
+theorem get_odd : ∀ (n : Nat) (s : Stream' α), get (odd s) n = get s (2 * n + 1) := fun n s => by
rw [odd_eq, nth_even]; rfl
-#align stream.nth_odd Stream'.nth_odd
+#align stream.nth_odd Stream'.get_odd
-/
#print Stream'.mem_of_mem_even /-
@@ -759,7 +759,7 @@ theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
-/
#print Stream'.get?_take_succ /-
-theorem get?_take_succ : ∀ (n : Nat) (s : Stream' α), List.get? (take (succ n) s) n = some (nth s n)
+theorem get?_take_succ : ∀ (n : Nat) (s : Stream' α), List.get? (take (succ n) s) n = some (get s n)
| 0, s => rfl
| n + 1, s => by rw [take_succ, add_one, List.get?, nth_take_succ]; rfl
#align stream.nth_take_succ Stream'.get?_take_succ
@@ -834,13 +834,13 @@ theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
#align stream.tails_eq Stream'.tails_eq
-/
-#print Stream'.nth_tails /-
-theorem nth_tails : ∀ (n : Nat) (s : Stream' α), nth (tails s) n = drop n (tail s) :=
+#print Stream'.get_tails /-
+theorem get_tails : ∀ (n : Nat) (s : Stream' α), get (tails s) n = drop n (tail s) :=
by
intro n; induction' n with n' ih
· intros; rfl
· intro s; rw [nth_succ, drop_succ, tails_eq, tail_cons, ih]
-#align stream.nth_tails Stream'.nth_tails
+#align stream.nth_tails Stream'.get_tails
-/
#print Stream'.tails_eq_iterate /-
@@ -873,25 +873,25 @@ theorem inits_tail (s : Stream' α) : inits (tail s) = initsCore [head (tail s)]
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print Stream'.cons_nth_inits_core /-
-theorem cons_nth_inits_core :
+#print Stream'.cons_get_inits_core /-
+theorem cons_get_inits_core :
∀ (a : α) (n : Nat) (l : List α) (s : Stream' α),
- (a::nth (initsCore l s) n) = nth (initsCore (a::l) s) n :=
+ (a::get (initsCore l s) n) = get (initsCore (a::l) s) n :=
by
intro a n
induction' n with n' ih
· intros; rfl
· intro l s; rw [nth_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]; rfl
-#align stream.cons_nth_inits_core Stream'.cons_nth_inits_core
+#align stream.cons_nth_inits_core Stream'.cons_get_inits_core
-/
-#print Stream'.nth_inits /-
-theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ n) s :=
+#print Stream'.get_inits /-
+theorem get_inits : ∀ (n : Nat) (s : Stream' α), get (inits s) n = take (succ n) s :=
by
intro n; induction' n with n' ih
· intros; rfl
· intros; rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
-#align stream.nth_inits Stream'.nth_inits
+#align stream.nth_inits Stream'.get_inits
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -946,10 +946,10 @@ theorem map_eq_apply (f : α → β) (s : Stream' α) : map f s = pure f ⊛ s :
#align stream.map_eq_apply Stream'.map_eq_apply
-/
-#print Stream'.nth_nats /-
-theorem nth_nats (n : Nat) : nth nats n = n :=
+#print Stream'.get_nats /-
+theorem get_nats (n : Nat) : get nats n = n :=
rfl
-#align stream.nth_nats Stream'.nth_nats
+#align stream.nth_nats Stream'.get_nats
-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
-import Mathbin.Data.Stream.Defs
-import Mathbin.Tactic.Ext
-import Mathbin.Logic.Function.Basic
+import Data.Stream.Defs
+import Tactic.Ext
+import Logic.Function.Basic
#align_import data.stream.init from "leanprover-community/mathlib"@"c3291da49cfa65f0d43b094750541c0731edc932"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-
-! This file was ported from Lean 3 source module data.stream.init
-! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Stream.Defs
import Mathbin.Tactic.Ext
import Mathbin.Logic.Function.Basic
+#align_import data.stream.init from "leanprover-community/mathlib"@"c3291da49cfa65f0d43b094750541c0731edc932"
+
/-!
# Streams a.k.a. infinite lists a.k.a. infinite sequences
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -395,7 +395,6 @@ section Bisim
variable (R : Stream' α → Stream' α → Prop)
--- mathport name: «expr ~ »
local infixl:50 " ~ " => R
#print Stream'.IsBisimulation /-
@@ -825,9 +824,11 @@ theorem mem_cycle {a : α} {l : List α} : ∀ h : l ≠ [], a ∈ l → a ∈ c
#align stream.mem_cycle Stream'.mem_cycle
-/
+#print Stream'.cycle_singleton /-
theorem cycle_singleton (a : α) (h : [a] ≠ []) : cycle [a] h = const a :=
coinduction rfl fun β fr ch => by rwa [cycle_eq, const_eq]
#align stream.cycle_singleton Stream'.cycle_singleton
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print Stream'.tails_eq /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -171,7 +171,7 @@ theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a =
fun ⟨n, h⟩ => by
cases' n with n'
· left; exact h
- · right; rw [nth_succ, tail_cons] at h; exact ⟨n', h⟩
+ · right; rw [nth_succ, tail_cons] at h ; exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
-/
@@ -328,7 +328,7 @@ theorem const_eq (a : α) : const a = a::const a :=
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print Stream'.tail_const /-
theorem tail_const (a : α) : tail (const a) = const a :=
- suffices tail (a::const a) = const a by rwa [← const_eq] at this
+ suffices tail (a::const a) = const a by rwa [← const_eq] at this
rfl
#align stream.tail_const Stream'.tail_const
-/
@@ -364,8 +364,8 @@ theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (
induction' n with n' ih
· rfl
· unfold tail iterate
- unfold tail iterate at ih
- rw [add_one] at ih; dsimp at ih
+ unfold tail iterate at ih
+ rw [add_one] at ih ; dsimp at ih
rw [add_one]; dsimp; rw [ih]
#align stream.tail_iterate Stream'.tail_iterate
-/
@@ -470,7 +470,7 @@ theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate
induction' n with n' ih
· rfl
· unfold map iterate nth; dsimp
- unfold map iterate nth at ih; dsimp at ih
+ unfold map iterate nth at ih ; dsimp at ih
rw [ih]
#align stream.map_iterate Stream'.map_iterate
-/
@@ -786,7 +786,7 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
by
intro h; apply Stream'.ext; intro n
induction' n with n ih
- · have aux := h 1; simp [take] at aux; exact aux
+ · have aux := h 1; simp [take] at aux ; exact aux
· have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)) := by
rw [← nth_take_succ, ← nth_take_succ, h (succ (succ n))]
injection h₁
@@ -813,8 +813,8 @@ theorem cycle_eq : ∀ (l : List α) (h : l ≠ []), cycle l h = l ++ₛ cycle l
by
intro l'
induction' l' with a₁ l₁ ih
- · intros ; rw [corec_eq]; rfl
- · intros ; rw [corec_eq, Stream'.cycle_g_cons, ih a₁]; rfl
+ · intros; rw [corec_eq]; rfl
+ · intros; rw [corec_eq, Stream'.cycle_g_cons, ih a₁]; rfl
gen l a
#align stream.cycle_eq Stream'.cycle_eq
-/
@@ -840,7 +840,7 @@ theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
theorem nth_tails : ∀ (n : Nat) (s : Stream' α), nth (tails s) n = drop n (tail s) :=
by
intro n; induction' n with n' ih
- · intros ; rfl
+ · intros; rfl
· intro s; rw [nth_succ, drop_succ, tails_eq, tail_cons, ih]
#align stream.nth_tails Stream'.nth_tails
-/
@@ -882,7 +882,7 @@ theorem cons_nth_inits_core :
by
intro a n
induction' n with n' ih
- · intros ; rfl
+ · intros; rfl
· intro l s; rw [nth_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]; rfl
#align stream.cons_nth_inits_core Stream'.cons_nth_inits_core
-/
@@ -891,8 +891,8 @@ theorem cons_nth_inits_core :
theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ n) s :=
by
intro n; induction' n with n' ih
- · intros ; rfl
- · intros ; rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
+ · intros; rfl
+ · intros; rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
#align stream.nth_inits Stream'.nth_inits
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -825,12 +825,6 @@ theorem mem_cycle {a : α} {l : List α} : ∀ h : l ≠ [], a ∈ l → a ∈ c
#align stream.mem_cycle Stream'.mem_cycle
-/
-/- warning: stream.cycle_singleton -> Stream'.cycle_singleton is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (a : α) (h : Ne.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)), Eq.{succ u1} (Stream'.{u1} α) (Stream'.cycle.{u1} α (List.cons.{u1} α a (List.nil.{u1} α)) h) (Stream'.const.{u1} α a)
-but is expected to have type
- forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Stream'.{u1} α) (Stream'.cycle.{u1} α (List.cons.{u1} α a (List.nil.{u1} α)) (of_eq_true (Not (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α))) (Eq.trans.{1} Prop (Not (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α))) (Not False) True (congrArg.{1, 1} Prop Prop (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) False Not (eq_false' (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) (fun (h : Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) => List.noConfusion.{0, u1} α False (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α) h))) not_false_eq_true))) (Stream'.const.{u1} α a)
-Case conversion may be inaccurate. Consider using '#align stream.cycle_singleton Stream'.cycle_singletonₓ'. -/
theorem cycle_singleton (a : α) (h : [a] ≠ []) : cycle [a] h = const a :=
coinduction rfl fun β fr ch => by rwa [cycle_eq, const_eq]
#align stream.cycle_singleton Stream'.cycle_singleton
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -170,11 +170,8 @@ theorem mem_cons_of_mem {a : α} {s : Stream' α} (b : α) : a ∈ s → a ∈ b
theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a = b ∨ a ∈ s :=
fun ⟨n, h⟩ => by
cases' n with n'
- · left
- exact h
- · right
- rw [nth_succ, tail_cons] at h
- exact ⟨n', h⟩
+ · left; exact h
+ · right; rw [nth_succ, tail_cons] at h; exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
-/
@@ -368,11 +365,8 @@ theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (
· rfl
· unfold tail iterate
unfold tail iterate at ih
- rw [add_one] at ih
- dsimp at ih
- rw [add_one]
- dsimp
- rw [ih]
+ rw [add_one] at ih; dsimp at ih
+ rw [add_one]; dsimp; rw [ih]
#align stream.tail_iterate Stream'.tail_iterate
-/
@@ -475,10 +469,8 @@ theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate
funext n
induction' n with n' ih
· rfl
- · unfold map iterate nth
- dsimp
- unfold map iterate nth at ih
- dsimp at ih
+ · unfold map iterate nth; dsimp
+ unfold map iterate nth at ih; dsimp at ih
rw [ih]
#align stream.map_iterate Stream'.map_iterate
-/
@@ -535,10 +527,8 @@ theorem nth_unfolds_head_tail :
∀ (n : Nat) (s : Stream' α), nth (unfolds head tail s) n = nth s n :=
by
intro n; induction' n with n' ih
- · intro s
- rfl
- · intro s
- rw [nth_succ, nth_succ, unfolds_eq, tail_cons, ih]
+ · intro s; rfl
+ · intro s; rw [nth_succ, nth_succ, unfolds_eq, tail_cons, ih]
#align stream.nth_unfolds_head_tail Stream'.nth_unfolds_head_tail
-/
@@ -784,10 +774,8 @@ theorem append_take_drop : ∀ (n : Nat) (s : Stream' α), appendStream' (take n
by
intro n
induction' n with n' ih
- · intro s
- rfl
- · intro s
- rw [take_succ, drop_succ, cons_append_stream, ih (tail s), Stream'.eta]
+ · intro s; rfl
+ · intro s; rw [take_succ, drop_succ, cons_append_stream, ih (tail s), Stream'.eta]
#align stream.append_take_drop Stream'.append_take_drop
-/
@@ -798,9 +786,7 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
by
intro h; apply Stream'.ext; intro n
induction' n with n ih
- · have aux := h 1
- simp [take] at aux
- exact aux
+ · have aux := h 1; simp [take] at aux; exact aux
· have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)) := by
rw [← nth_take_succ, ← nth_take_succ, h (succ (succ n))]
injection h₁
@@ -827,12 +813,8 @@ theorem cycle_eq : ∀ (l : List α) (h : l ≠ []), cycle l h = l ++ₛ cycle l
by
intro l'
induction' l' with a₁ l₁ ih
- · intros
- rw [corec_eq]
- rfl
- · intros
- rw [corec_eq, Stream'.cycle_g_cons, ih a₁]
- rfl
+ · intros ; rw [corec_eq]; rfl
+ · intros ; rw [corec_eq, Stream'.cycle_g_cons, ih a₁]; rfl
gen l a
#align stream.cycle_eq Stream'.cycle_eq
-/
@@ -864,10 +846,8 @@ theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
theorem nth_tails : ∀ (n : Nat) (s : Stream' α), nth (tails s) n = drop n (tail s) :=
by
intro n; induction' n with n' ih
- · intros
- rfl
- · intro s
- rw [nth_succ, drop_succ, tails_eq, tail_cons, ih]
+ · intros ; rfl
+ · intro s; rw [nth_succ, drop_succ, tails_eq, tail_cons, ih]
#align stream.nth_tails Stream'.nth_tails
-/
@@ -908,11 +888,8 @@ theorem cons_nth_inits_core :
by
intro a n
induction' n with n' ih
- · intros
- rfl
- · intro l s
- rw [nth_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]
- rfl
+ · intros ; rfl
+ · intro l s; rw [nth_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]; rfl
#align stream.cons_nth_inits_core Stream'.cons_nth_inits_core
-/
@@ -920,10 +897,8 @@ theorem cons_nth_inits_core :
theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ n) s :=
by
intro n; induction' n with n' ih
- · intros
- rfl
- · intros
- rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
+ · intros ; rfl
+ · intros ; rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
#align stream.nth_inits Stream'.nth_inits
-/
@@ -934,8 +909,7 @@ theorem inits_eq (s : Stream' α) : inits s = [head s]::map (List.cons (head s))
apply Stream'.ext; intro n
cases n
· rfl
- · rw [nth_inits, nth_succ, tail_cons, nth_map, nth_inits]
- rfl
+ · rw [nth_inits, nth_succ, tail_cons, nth_map, nth_inits]; rfl
#align stream.inits_eq Stream'.inits_eq
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/f8c79b0a623404854a2902b836eac32156fd7712
@@ -843,11 +843,15 @@ theorem mem_cycle {a : α} {l : List α} : ∀ h : l ≠ [], a ∈ l → a ∈ c
#align stream.mem_cycle Stream'.mem_cycle
-/
-#print Stream'.cycle_singleton /-
+/- warning: stream.cycle_singleton -> Stream'.cycle_singleton is a dubious translation:
+lean 3 declaration is
+ forall {α : Type.{u1}} (a : α) (h : Ne.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)), Eq.{succ u1} (Stream'.{u1} α) (Stream'.cycle.{u1} α (List.cons.{u1} α a (List.nil.{u1} α)) h) (Stream'.const.{u1} α a)
+but is expected to have type
+ forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Stream'.{u1} α) (Stream'.cycle.{u1} α (List.cons.{u1} α a (List.nil.{u1} α)) (of_eq_true (Not (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α))) (Eq.trans.{1} Prop (Not (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α))) (Not False) True (congrArg.{1, 1} Prop Prop (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) False Not (eq_false' (Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) (fun (h : Eq.{succ u1} (List.{u1} α) (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α)) => List.noConfusion.{0, u1} α False (List.cons.{u1} α a (List.nil.{u1} α)) (List.nil.{u1} α) h))) not_false_eq_true))) (Stream'.const.{u1} α a)
+Case conversion may be inaccurate. Consider using '#align stream.cycle_singleton Stream'.cycle_singletonₓ'. -/
theorem cycle_singleton (a : α) (h : [a] ≠ []) : cycle [a] h = const a :=
coinduction rfl fun β fr ch => by rwa [cycle_eq, const_eq]
#align stream.cycle_singleton Stream'.cycle_singleton
--/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
#print Stream'.tails_eq /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -326,7 +326,9 @@ theorem bisim_simple (s₁ s₂ : Stream' α) :
head s₁ = head s₂ → s₁ = tail s₁ → s₂ = tail s₂ → s₁ = s₂ := fun hh ht₁ ht₂ =>
eq_of_bisim (fun s₁ s₂ => head s₁ = head s₂ ∧ s₁ = tail s₁ ∧ s₂ = tail s₂)
(fun s₁ s₂ ⟨h₁, h₂, h₃⟩ => by
- constructor; exact h₁; rw [← h₂, ← h₃]
+ constructor
+ · exact h₁
+ rw [← h₂, ← h₃]
(repeat' constructor) <;> assumption)
(And.intro hh (And.intro ht₁ ht₂))
#align stream.bisim_simple Stream'.bisim_simple
@@ -761,7 +763,9 @@ theorem get_nats (n : Nat) : get nats n = n :=
theorem nats_eq : nats = cons 0 (map succ nats) := by
apply Stream'.ext; intro n
- cases n; rfl; rw [get_succ]; rfl
+ cases n
+ · rfl
+ rw [get_succ]; rfl
#align stream.nats_eq Stream'.nats_eq
end Stream'
Make use of Nat
-specific lemmas from Std rather than the general ones provided by mathlib. Also reverse the dependency between Multiset.Nodup
/Multiset.dedup
and Multiset.sum
since only the latter needs algebra. Also rename Algebra.BigOperators.Multiset.Abs
to Algebra.BigOperators.Multiset.Order
and move some lemmas from Algebra.BigOperators.Multiset.Basic
to it.
The ultimate goal here is to carve out Data
, Algebra
and Order
sublibraries.
@@ -69,7 +69,7 @@ theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m
@[simp] theorem get_tail {s : Stream' α} : s.tail.get n = s.get (n + 1) := rfl
@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
- ext; simp [add_comm, add_assoc, Nat.add_left_comm]
+ ext; simp [Nat.add_comm, Nat.add_assoc, Nat.add_left_comm]
@[simp] theorem drop_tail' {s : Stream' α} : drop i (tail s) = s.drop (i+1) := rfl
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>
@@ -69,7 +69,7 @@ theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m
@[simp] theorem get_tail {s : Stream' α} : s.tail.get n = s.get (n + 1) := rfl
@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
- ext; simp [add_comm, add_assoc, add_left_comm]
+ ext; simp [add_comm, add_assoc, Nat.add_left_comm]
@[simp] theorem drop_tail' {s : Stream' α} : drop i (tail s) = s.drop (i+1) := rfl
@@ -587,8 +587,8 @@ theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
@[simp]
theorem take_take {s : Stream' α} : ∀ {m n}, (s.take n).take m = s.take (min n m)
- | 0, n => by rw [min_zero, List.take_zero, take_zero]
- | m, 0 => by rw [zero_min, take_zero, List.take_nil]
+ | 0, n => by rw [Nat.min_zero, List.take_zero, take_zero]
+ | m, 0 => by rw [Nat.zero_min, take_zero, List.take_nil]
| m+1, n+1 => by rw [take_succ, List.take_cons, Nat.succ_min_succ, take_succ, take_take]
@[simp] theorem concat_take_get {s : Stream' α} : s.take n ++ [s.get n] = s.take (n+1) :=
This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0
branch as we update to intermediate nightlies.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>
@@ -3,7 +3,6 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
-import Std.Tactic.Ext
import Mathlib.Data.Stream.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Init.Data.List.Basic
cases x with | ...
instead of cases x; case => ...
(#9321)
This converts usages of the pattern
cases h
case inl h' => ...
case inr h' => ...
which derive from mathported code, to the "structured cases
" syntax:
cases h with
| inl h' => ...
| inr h' => ...
The case where the subgoals are handled with ·
instead of case
is more contentious (and much more numerous) so I left those alone. This pattern also appears with cases'
, induction
, induction'
, and rcases
. Furthermore, there is a similar transformation for by_cases
:
by_cases h : cond
case pos => ...
case neg => ...
is replaced by:
if h : cond then
...
else
...
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -606,8 +606,9 @@ theorem get?_take_succ (n : Nat) (s : Stream' α) :
@[simp] theorem dropLast_take {xs : Stream' α} :
(Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
- cases n; case zero => simp
- case succ n => rw [take_succ', List.dropLast_concat, Nat.add_one_sub_one]
+ cases n with
+ | zero => simp
+ | succ n => rw [take_succ', List.dropLast_concat, Nat.add_one_sub_one]
@[simp]
theorem append_take_drop : ∀ (n : Nat) (s : Stream' α),
bump/v4.5.0
branch. (#9188)
This PR:
v4.5.0-rc1
v4.5.0-rc1
bump/v4.5.0
branch
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -432,7 +432,6 @@ theorem get_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α),
| n + 1, s₁, s₂ => by
change get (s₁ ⋈ s₂) (succ (succ (2 * n))) = get s₁ (succ n)
rw [get_succ, get_succ, interleave_eq, tail_cons, tail_cons]
- have : n < succ n := Nat.lt_succ_self n
rw [get_interleave_left n (tail s₁) (tail s₂)]
rfl
#align stream.nth_interleave_left Stream'.get_interleave_left
@@ -627,7 +627,8 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
intro h; apply Stream'.ext; intro n
induction' n with n _
· have aux := h 1
- simp [take] at aux
+ simp? [take] at aux says
+ simp only [take, List.cons.injEq, and_true] at aux
exact aux
· have h₁ : some (get s₁ (succ n)) = some (get s₂ (succ n)) := by
rw [← get?_take_succ, ← get?_take_succ, h (succ (succ n))]
@@ -608,7 +608,7 @@ theorem get?_take_succ (n : Nat) (s : Stream' α) :
@[simp] theorem dropLast_take {xs : Stream' α} :
(Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
cases n; case zero => simp
- case succ n => rw [take_succ', List.dropLast_concat, Nat.succ_sub_one]
+ case succ n => rw [take_succ', List.dropLast_concat, Nat.add_one_sub_one]
@[simp]
theorem append_take_drop : ∀ (n : Nat) (s : Stream' α),
@@ -591,7 +591,7 @@ theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
theorem take_take {s : Stream' α} : ∀ {m n}, (s.take n).take m = s.take (min n m)
| 0, n => by rw [min_zero, List.take_zero, take_zero]
| m, 0 => by rw [zero_min, take_zero, List.take_nil]
- | m+1, n+1 => by rw [take_succ, List.take_cons, Nat.min_succ_succ, take_succ, take_take]
+ | m+1, n+1 => by rw [take_succ, List.take_cons, Nat.succ_min_succ, take_succ, take_take]
@[simp] theorem concat_take_get {s : Stream' α} : s.take n ++ [s.get n] = s.take (n+1) :=
(take_succ' n).symm
Stream'.nth
to Stream'.get
(#7514)
Many of nth
(e.g. list.nth
, stream.seq.nth
) are renamed to get?
in Mathlib 4, but Stream'.nth
had been remained as it.
@@ -34,14 +34,14 @@ protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
#align stream.eta Stream'.eta
@[ext]
-protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, nth s₁ n = nth s₂ n) → s₁ = s₂ :=
+protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, get s₁ n = get s₂ n) → s₁ = s₂ :=
fun h => funext h
#align stream.ext Stream'.ext
@[simp]
-theorem nth_zero_cons (a : α) (s : Stream' α) : nth (a::s) 0 = a :=
+theorem get_zero_cons (a : α) (s : Stream' α) : get (a::s) 0 = a :=
rfl
-#align stream.nth_zero_cons Stream'.nth_zero_cons
+#align stream.nth_zero_cons Stream'.get_zero_cons
@[simp]
theorem head_cons (a : α) (s : Stream' α) : head (a::s) = a :=
@@ -54,9 +54,9 @@ theorem tail_cons (a : α) (s : Stream' α) : tail (a::s) = s :=
#align stream.tail_cons Stream'.tail_cons
@[simp]
-theorem nth_drop (n m : Nat) (s : Stream' α) : nth (drop m s) n = nth s (n + m) :=
+theorem get_drop (n m : Nat) (s : Stream' α) : get (drop m s) n = get s (n + m) :=
rfl
-#align stream.nth_drop Stream'.nth_drop
+#align stream.nth_drop Stream'.get_drop
theorem tail_eq_drop (s : Stream' α) : tail s = drop 1 s :=
rfl
@@ -67,7 +67,7 @@ theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m
ext; simp [Nat.add_assoc]
#align stream.drop_drop Stream'.drop_drop
-@[simp] theorem nth_tail {s : Stream' α} : s.tail.nth n = s.nth (n + 1) := rfl
+@[simp] theorem get_tail {s : Stream' α} : s.tail.get n = s.get (n + 1) := rfl
@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
ext; simp [add_comm, add_assoc, add_left_comm]
@@ -77,14 +77,14 @@ theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m
theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s) := by simp
#align stream.tail_drop Stream'.tail_drop
-theorem nth_succ (n : Nat) (s : Stream' α) : nth s (succ n) = nth (tail s) n :=
+theorem get_succ (n : Nat) (s : Stream' α) : get s (succ n) = get (tail s) n :=
rfl
-#align stream.nth_succ Stream'.nth_succ
+#align stream.nth_succ Stream'.get_succ
@[simp]
-theorem nth_succ_cons (n : Nat) (s : Stream' α) (x : α) : nth (x::s) n.succ = nth s n :=
+theorem get_succ_cons (n : Nat) (s : Stream' α) (x : α) : get (x::s) n.succ = get s n :=
rfl
-#align stream.nth_succ_cons Stream'.nth_succ_cons
+#align stream.nth_succ_cons Stream'.get_succ_cons
@[simp] theorem drop_zero {s : Stream' α} : s.drop 0 = s := rfl
@@ -92,12 +92,12 @@ theorem drop_succ (n : Nat) (s : Stream' α) : drop (succ n) s = drop n (tail s)
rfl
#align stream.drop_succ Stream'.drop_succ
-theorem head_drop (a : Stream' α) (n : ℕ) : (a.drop n).head = a.nth n := by simp
+theorem head_drop (a : Stream' α) (n : ℕ) : (a.drop n).head = a.get n := by simp
#align stream.head_drop Stream'.head_drop
theorem cons_injective2 : Function.Injective2 (cons : α → Stream' α → Stream' α) := fun x y s t h =>
- ⟨by rw [← nth_zero_cons x s, h, nth_zero_cons],
- Stream'.ext fun n => by rw [← nth_succ_cons n _ x, h, nth_succ_cons]⟩
+ ⟨by rw [← get_zero_cons x s, h, get_zero_cons],
+ Stream'.ext fun n => by rw [← get_succ_cons n _ x, h, get_succ_cons]⟩
#align stream.cons_injective2 Stream'.cons_injective2
theorem cons_injective_left (s : Stream' α) : Function.Injective fun x => cons x s :=
@@ -108,11 +108,11 @@ theorem cons_injective_right (x : α) : Function.Injective (cons x) :=
cons_injective2.right _
#align stream.cons_injective_right Stream'.cons_injective_right
-theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (nth s n) :=
+theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (get s n) :=
rfl
#align stream.all_def Stream'.all_def
-theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (nth s n) :=
+theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (get s n) :=
rfl
#align stream.any_def Stream'.any_def
@@ -122,7 +122,7 @@ theorem mem_cons (a : α) (s : Stream' α) : a ∈ a::s :=
#align stream.mem_cons Stream'.mem_cons
theorem mem_cons_of_mem {a : α} {s : Stream' α} (b : α) : a ∈ s → a ∈ b::s := fun ⟨n, h⟩ =>
- Exists.intro (succ n) (by rw [nth_succ, tail_cons, h])
+ Exists.intro (succ n) (by rw [get_succ, tail_cons, h])
#align stream.mem_cons_of_mem Stream'.mem_cons_of_mem
theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a = b ∨ a ∈ s :=
@@ -131,13 +131,13 @@ theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a =
· left
exact h
· right
- rw [nth_succ, tail_cons] at h
+ rw [get_succ, tail_cons] at h
exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
-theorem mem_of_nth_eq {n : Nat} {s : Stream' α} {a : α} : a = nth s n → a ∈ s := fun h =>
+theorem mem_of_get_eq {n : Nat} {s : Stream' α} {a : α} : a = get s n → a ∈ s := fun h =>
Exists.intro n h
-#align stream.mem_of_nth_eq Stream'.mem_of_nth_eq
+#align stream.mem_of_nth_eq Stream'.mem_of_get_eq
section Map
@@ -148,9 +148,9 @@ theorem drop_map (n : Nat) (s : Stream' α) : drop n (map f s) = map f (drop n s
#align stream.drop_map Stream'.drop_map
@[simp]
-theorem nth_map (n : Nat) (s : Stream' α) : nth (map f s) n = f (nth s n) :=
+theorem get_map (n : Nat) (s : Stream' α) : get (map f s) n = f (get s n) :=
rfl
-#align stream.nth_map Stream'.nth_map
+#align stream.nth_map Stream'.get_map
theorem tail_map (s : Stream' α) : tail (map f s) = map f (tail s) := rfl
#align stream.tail_map Stream'.tail_map
@@ -184,11 +184,11 @@ theorem map_tail (s : Stream' α) : map f (tail s) = tail (map f s) :=
#align stream.map_tail Stream'.map_tail
theorem mem_map {a : α} {s : Stream' α} : a ∈ s → f a ∈ map f s := fun ⟨n, h⟩ =>
- Exists.intro n (by rw [nth_map, h])
+ Exists.intro n (by rw [get_map, h])
#align stream.mem_map Stream'.mem_map
theorem exists_of_mem_map {f} {b : β} {s : Stream' α} : b ∈ map f s → ∃ a, a ∈ s ∧ f a = b :=
- fun ⟨n, h⟩ => ⟨nth s n, ⟨n, rfl⟩, h.symm⟩
+ fun ⟨n, h⟩ => ⟨get s n, ⟨n, rfl⟩, h.symm⟩
#align stream.exists_of_mem_map Stream'.exists_of_mem_map
end Map
@@ -203,10 +203,10 @@ theorem drop_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
#align stream.drop_zip Stream'.drop_zip
@[simp]
-theorem nth_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
- nth (zip f s₁ s₂) n = f (nth s₁ n) (nth s₂ n) :=
+theorem get_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
+ get (zip f s₁ s₂) n = f (get s₁ n) (get s₂ n) :=
rfl
-#align stream.nth_zip Stream'.nth_zip
+#align stream.nth_zip Stream'.get_zip
theorem head_zip (s₁ : Stream' α) (s₂ : Stream' β) : head (zip f s₁ s₂) = f (head s₁) (head s₂) :=
rfl
@@ -223,9 +223,9 @@ theorem zip_eq (s₁ : Stream' α) (s₂ : Stream' β) :
#align stream.zip_eq Stream'.zip_eq
@[simp]
-theorem nth_enum (s : Stream' α) (n : ℕ) : nth (enum s) n = (n, s.nth n) :=
+theorem get_enum (s : Stream' α) (n : ℕ) : get (enum s) n = (n, s.get n) :=
rfl
-#align stream.nth_enum Stream'.nth_enum
+#align stream.nth_enum Stream'.get_enum
theorem enum_eq_zip (s : Stream' α) : enum s = zip Prod.mk nats s :=
rfl
@@ -255,9 +255,9 @@ theorem map_const (f : α → β) (a : α) : map f (const a) = const (f a) :=
#align stream.map_const Stream'.map_const
@[simp]
-theorem nth_const (n : Nat) (a : α) : nth (const a) n = a :=
+theorem get_const (n : Nat) (a : α) : get (const a) n = a :=
rfl
-#align stream.nth_const Stream'.nth_const
+#align stream.nth_const Stream'.get_const
@[simp]
theorem drop_const (n : Nat) (a : α) : drop n (const a) = const a :=
@@ -269,15 +269,15 @@ theorem head_iterate (f : α → α) (a : α) : head (iterate f a) = a :=
rfl
#align stream.head_iterate Stream'.head_iterate
-theorem nth_succ_iterate' (n : Nat) (f : α → α) (a : α) :
- nth (iterate f a) (succ n) = f (nth (iterate f a) n) := rfl
+theorem get_succ_iterate' (n : Nat) (f : α → α) (a : α) :
+ get (iterate f a) (succ n) = f (get (iterate f a) n) := rfl
theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (f a) := by
ext n
- rw [nth_tail]
+ rw [get_tail]
induction' n with n' ih
· rfl
- · rw [nth_succ_iterate', ih, nth_succ_iterate']
+ · rw [get_succ_iterate', ih, get_succ_iterate']
#align stream.tail_iterate Stream'.tail_iterate
theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) := by
@@ -286,13 +286,13 @@ theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) :
#align stream.iterate_eq Stream'.iterate_eq
@[simp]
-theorem nth_zero_iterate (f : α → α) (a : α) : nth (iterate f a) 0 = a :=
+theorem get_zero_iterate (f : α → α) (a : α) : get (iterate f a) 0 = a :=
rfl
-#align stream.nth_zero_iterate Stream'.nth_zero_iterate
+#align stream.nth_zero_iterate Stream'.get_zero_iterate
-theorem nth_succ_iterate (n : Nat) (f : α → α) (a : α) :
- nth (iterate f a) (succ n) = nth (iterate f (f a)) n := by rw [nth_succ, tail_iterate]
-#align stream.nth_succ_iterate Stream'.nth_succ_iterate
+theorem get_succ_iterate (n : Nat) (f : α → α) (a : α) :
+ get (iterate f a) (succ n) = get (iterate f (f a)) n := by rw [get_succ, tail_iterate]
+#align stream.nth_succ_iterate Stream'.get_succ_iterate
section Bisim
@@ -308,17 +308,17 @@ def IsBisimulation :=
head s₁ = head s₂ ∧ tail s₁ ~ tail s₂
#align stream.is_bisimulation Stream'.IsBisimulation
-theorem nth_of_bisim (bisim : IsBisimulation R) :
- ∀ {s₁ s₂} (n), s₁ ~ s₂ → nth s₁ n = nth s₂ n ∧ drop (n + 1) s₁ ~ drop (n + 1) s₂
+theorem get_of_bisim (bisim : IsBisimulation R) :
+ ∀ {s₁ s₂} (n), s₁ ~ s₂ → get s₁ n = get s₂ n ∧ drop (n + 1) s₁ ~ drop (n + 1) s₂
| _, _, 0, h => bisim h
| _, _, n + 1, h =>
match bisim h with
- | ⟨_, trel⟩ => nth_of_bisim bisim n trel
-#align stream.nth_of_bisim Stream'.nth_of_bisim
+ | ⟨_, trel⟩ => get_of_bisim bisim n trel
+#align stream.nth_of_bisim Stream'.get_of_bisim
-- If two streams are bisimilar, then they are equal
theorem eq_of_bisim (bisim : IsBisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ := fun r =>
- Stream'.ext fun n => And.left (nth_of_bisim R bisim n r)
+ Stream'.ext fun n => And.left (get_of_bisim R bisim n r)
#align stream.eq_of_bisim Stream'.eq_of_bisim
end Bisim
@@ -361,8 +361,8 @@ theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate
funext n
induction' n with n' ih
· rfl
- · unfold map iterate nth
- rw [map, nth] at ih
+ · unfold map iterate get
+ rw [map, get] at ih
rw [iterate]
exact congrArg f ih
#align stream.map_iterate Stream'.map_iterate
@@ -399,17 +399,17 @@ theorem unfolds_eq (g : α → β) (f : α → α) (a : α) : unfolds g f a = g
unfold unfolds; rw [corec_eq]
#align stream.unfolds_eq Stream'.unfolds_eq
-theorem nth_unfolds_head_tail : ∀ (n : Nat) (s : Stream' α),
- nth (unfolds head tail s) n = nth s n := by
+theorem get_unfolds_head_tail : ∀ (n : Nat) (s : Stream' α),
+ get (unfolds head tail s) n = get s n := by
intro n; induction' n with n' ih
· intro s
rfl
· intro s
- rw [nth_succ, nth_succ, unfolds_eq, tail_cons, ih]
-#align stream.nth_unfolds_head_tail Stream'.nth_unfolds_head_tail
+ rw [get_succ, get_succ, unfolds_eq, tail_cons, ih]
+#align stream.nth_unfolds_head_tail Stream'.get_unfolds_head_tail
theorem unfolds_head_eq : ∀ s : Stream' α, unfolds head tail s = s := fun s =>
- Stream'.ext fun n => nth_unfolds_head_tail n s
+ Stream'.ext fun n => get_unfolds_head_tail n s
#align stream.unfolds_head_eq Stream'.unfolds_head_eq
theorem interleave_eq (s₁ s₂ : Stream' α) : s₁ ⋈ s₂ = head s₁::head s₂::(tail s₁ ⋈ tail s₂) := by
@@ -426,33 +426,33 @@ theorem interleave_tail_tail (s₁ s₂ : Stream' α) : tail s₁ ⋈ tail s₂
rw [interleave_eq s₁ s₂]; rfl
#align stream.interleave_tail_tail Stream'.interleave_tail_tail
-theorem nth_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α),
- nth (s₁ ⋈ s₂) (2 * n) = nth s₁ n
+theorem get_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α),
+ get (s₁ ⋈ s₂) (2 * n) = get s₁ n
| 0, s₁, s₂ => rfl
| n + 1, s₁, s₂ => by
- change nth (s₁ ⋈ s₂) (succ (succ (2 * n))) = nth s₁ (succ n)
- rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons]
+ change get (s₁ ⋈ s₂) (succ (succ (2 * n))) = get s₁ (succ n)
+ rw [get_succ, get_succ, interleave_eq, tail_cons, tail_cons]
have : n < succ n := Nat.lt_succ_self n
- rw [nth_interleave_left n (tail s₁) (tail s₂)]
+ rw [get_interleave_left n (tail s₁) (tail s₂)]
rfl
-#align stream.nth_interleave_left Stream'.nth_interleave_left
+#align stream.nth_interleave_left Stream'.get_interleave_left
-theorem nth_interleave_right : ∀ (n : Nat) (s₁ s₂ : Stream' α),
- nth (s₁ ⋈ s₂) (2 * n + 1) = nth s₂ n
+theorem get_interleave_right : ∀ (n : Nat) (s₁ s₂ : Stream' α),
+ get (s₁ ⋈ s₂) (2 * n + 1) = get s₂ n
| 0, s₁, s₂ => rfl
| n + 1, s₁, s₂ => by
- change nth (s₁ ⋈ s₂) (succ (succ (2 * n + 1))) = nth s₂ (succ n)
- rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons,
- nth_interleave_right n (tail s₁) (tail s₂)]
+ change get (s₁ ⋈ s₂) (succ (succ (2 * n + 1))) = get s₂ (succ n)
+ rw [get_succ, get_succ, interleave_eq, tail_cons, tail_cons,
+ get_interleave_right n (tail s₁) (tail s₂)]
rfl
-#align stream.nth_interleave_right Stream'.nth_interleave_right
+#align stream.nth_interleave_right Stream'.get_interleave_right
theorem mem_interleave_left {a : α} {s₁ : Stream' α} (s₂ : Stream' α) : a ∈ s₁ → a ∈ s₁ ⋈ s₂ :=
- fun ⟨n, h⟩ => Exists.intro (2 * n) (by rw [h, nth_interleave_left])
+ fun ⟨n, h⟩ => Exists.intro (2 * n) (by rw [h, get_interleave_left])
#align stream.mem_interleave_left Stream'.mem_interleave_left
theorem mem_interleave_right {a : α} {s₁ : Stream' α} (s₂ : Stream' α) : a ∈ s₂ → a ∈ s₁ ⋈ s₂ :=
- fun ⟨n, h⟩ => Exists.intro (2 * n + 1) (by rw [h, nth_interleave_right])
+ fun ⟨n, h⟩ => Exists.intro (2 * n + 1) (by rw [h, get_interleave_right])
#align stream.mem_interleave_right Stream'.mem_interleave_right
theorem odd_eq (s : Stream' α) : odd s = even (tail s) :=
@@ -498,23 +498,23 @@ theorem interleave_even_odd (s₁ : Stream' α) : even s₁ ⋈ odd s₁ = s₁
rfl
#align stream.interleave_even_odd Stream'.interleave_even_odd
-theorem nth_even : ∀ (n : Nat) (s : Stream' α), nth (even s) n = nth s (2 * n)
+theorem get_even : ∀ (n : Nat) (s : Stream' α), get (even s) n = get s (2 * n)
| 0, s => rfl
| succ n, s => by
- change nth (even s) (succ n) = nth s (succ (succ (2 * n)))
- rw [nth_succ, nth_succ, tail_even, nth_even n]; rfl
-#align stream.nth_even Stream'.nth_even
+ change get (even s) (succ n) = get s (succ (succ (2 * n)))
+ rw [get_succ, get_succ, tail_even, get_even n]; rfl
+#align stream.nth_even Stream'.get_even
-theorem nth_odd : ∀ (n : Nat) (s : Stream' α), nth (odd s) n = nth s (2 * n + 1) := fun n s => by
- rw [odd_eq, nth_even]; rfl
-#align stream.nth_odd Stream'.nth_odd
+theorem get_odd : ∀ (n : Nat) (s : Stream' α), get (odd s) n = get s (2 * n + 1) := fun n s => by
+ rw [odd_eq, get_even]; rfl
+#align stream.nth_odd Stream'.get_odd
theorem mem_of_mem_even (a : α) (s : Stream' α) : a ∈ even s → a ∈ s := fun ⟨n, h⟩ =>
- Exists.intro (2 * n) (by rw [h, nth_even])
+ Exists.intro (2 * n) (by rw [h, get_even])
#align stream.mem_of_mem_even Stream'.mem_of_mem_even
theorem mem_of_mem_odd (a : α) (s : Stream' α) : a ∈ odd s → a ∈ s := fun ⟨n, h⟩ =>
- Exists.intro (2 * n + 1) (by rw [h, nth_odd])
+ Exists.intro (2 * n + 1) (by rw [h, get_odd])
#align stream.mem_of_mem_odd Stream'.mem_of_mem_odd
theorem nil_append_stream (s : Stream' α) : appendStream' [] s = s :=
@@ -578,9 +578,9 @@ theorem take_succ (n : Nat) (s : Stream' α) : take (succ n) s = head s::take n
@[simp] theorem take_succ_cons (n : Nat) (s : Stream' α) : take (n+1) (a::s) = a :: take n s := rfl
-theorem take_succ' {s : Stream' α} : ∀ n, s.take (n+1) = s.take n ++ [s.nth n]
+theorem take_succ' {s : Stream' α} : ∀ n, s.take (n+1) = s.take n ++ [s.get n]
| 0 => rfl
- | n+1 => by rw [take_succ, take_succ' n, ← List.cons_append, ← take_succ, nth_tail]
+ | n+1 => by rw [take_succ, take_succ' n, ← List.cons_append, ← take_succ, get_tail]
@[simp]
theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
@@ -593,15 +593,15 @@ theorem take_take {s : Stream' α} : ∀ {m n}, (s.take n).take m = s.take (min
| m, 0 => by rw [zero_min, take_zero, List.take_nil]
| m+1, n+1 => by rw [take_succ, List.take_cons, Nat.min_succ_succ, take_succ, take_take]
-@[simp] theorem concat_take_nth {s : Stream' α} : s.take n ++ [s.nth n] = s.take (n+1) :=
+@[simp] theorem concat_take_get {s : Stream' α} : s.take n ++ [s.get n] = s.take (n+1) :=
(take_succ' n).symm
-theorem get?_take {s : Stream' α} : ∀ {k n}, k < n → (s.take n).get? k = s.nth k
+theorem get?_take {s : Stream' α} : ∀ {k n}, k < n → (s.take n).get? k = s.get k
| 0, n+1, _ => rfl
- | k+1, n+1, h => by rw [take_succ, List.get?, get?_take (Nat.lt_of_succ_lt_succ h), nth_succ]
+ | k+1, n+1, h => by rw [take_succ, List.get?, get?_take (Nat.lt_of_succ_lt_succ h), get_succ]
theorem get?_take_succ (n : Nat) (s : Stream' α) :
- List.get? (take (succ n) s) n = some (nth s n) :=
+ List.get? (take (succ n) s) n = some (get s n) :=
get?_take (Nat.lt_succ_self n)
#align stream.nth_take_succ Stream'.get?_take_succ
@@ -629,7 +629,7 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
· have aux := h 1
simp [take] at aux
exact aux
- · have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)) := by
+ · have h₁ : some (get s₁ (succ n)) = some (get s₂ (succ n)) := by
rw [← get?_take_succ, ← get?_take_succ, h (succ (succ n))]
injection h₁
#align stream.take_theorem Stream'.take_theorem
@@ -669,13 +669,13 @@ theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
#align stream.tails_eq Stream'.tails_eq
@[simp]
-theorem nth_tails : ∀ (n : Nat) (s : Stream' α), nth (tails s) n = drop n (tail s) := by
+theorem get_tails : ∀ (n : Nat) (s : Stream' α), get (tails s) n = drop n (tail s) := by
intro n; induction' n with n' ih
· intros
rfl
· intro s
- rw [nth_succ, drop_succ, tails_eq, tail_cons, ih]
-#align stream.nth_tails Stream'.nth_tails
+ rw [get_succ, drop_succ, tails_eq, tail_cons, ih]
+#align stream.nth_tails Stream'.get_tails
theorem tails_eq_iterate (s : Stream' α) : tails s = iterate tail (tail s) :=
rfl
@@ -697,39 +697,39 @@ theorem inits_tail (s : Stream' α) : inits (tail s) = initsCore [head (tail s)]
rfl
#align stream.inits_tail Stream'.inits_tail
-theorem cons_nth_inits_core :
+theorem cons_get_inits_core :
∀ (a : α) (n : Nat) (l : List α) (s : Stream' α),
- (a::nth (initsCore l s) n) = nth (initsCore (a::l) s) n := by
+ (a::get (initsCore l s) n) = get (initsCore (a::l) s) n := by
intro a n
induction' n with n' ih
· intros
rfl
· intro l s
- rw [nth_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]
+ rw [get_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]
rfl
-#align stream.cons_nth_inits_core Stream'.cons_nth_inits_core
+#align stream.cons_nth_inits_core Stream'.cons_get_inits_core
@[simp]
-theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ n) s := by
+theorem get_inits : ∀ (n : Nat) (s : Stream' α), get (inits s) n = take (succ n) s := by
intro n; induction' n with n' ih
· intros
rfl
· intros
- rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
-#align stream.nth_inits Stream'.nth_inits
+ rw [get_succ, take_succ, ← ih, tail_inits, inits_tail, cons_get_inits_core]
+#align stream.nth_inits Stream'.get_inits
theorem inits_eq (s : Stream' α) :
inits s = [head s]::map (List.cons (head s)) (inits (tail s)) := by
apply Stream'.ext; intro n
cases n
· rfl
- · rw [nth_inits, nth_succ, tail_cons, nth_map, nth_inits]
+ · rw [get_inits, get_succ, tail_cons, get_map, get_inits]
rfl
#align stream.inits_eq Stream'.inits_eq
theorem zip_inits_tails (s : Stream' α) : zip appendStream' (inits s) (tails s) = const s := by
apply Stream'.ext; intro n
- rw [nth_zip, nth_inits, nth_tails, nth_const, take_succ, cons_append_stream, append_take_drop,
+ rw [get_zip, get_inits, get_tails, get_const, take_succ, cons_append_stream, append_take_drop,
Stream'.eta]
#align stream.zip_inits_tails Stream'.zip_inits_tails
@@ -755,13 +755,13 @@ theorem map_eq_apply (f : α → β) (s : Stream' α) : map f s = pure f ⊛ s :
rfl
#align stream.map_eq_apply Stream'.map_eq_apply
-theorem nth_nats (n : Nat) : nth nats n = n :=
+theorem get_nats (n : Nat) : get nats n = n :=
rfl
-#align stream.nth_nats Stream'.nth_nats
+#align stream.nth_nats Stream'.get_nats
theorem nats_eq : nats = cons 0 (map succ nats) := by
apply Stream'.ext; intro n
- cases n; rfl; rw [nth_succ]; rfl
+ cases n; rfl; rw [get_succ]; rfl
#align stream.nats_eq Stream'.nats_eq
end Stream'
@@ -362,7 +362,6 @@ theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate
induction' n with n' ih
· rfl
· unfold map iterate nth
- dsimp
rw [map, nth] at ih
rw [iterate]
exact congrArg f ih
Autoimplicits are highly controversial and also defeat the performance-improving work in #6474.
The intent of this PR is to make autoImplicit
opt-in on a per-file basis, by disabling it in the lakefile and enabling it again with set_option autoImplicit true
in the few files that rely on it.
That also keeps this PR small, as opposed to attempting to "fix" files to not need it any more.
I claim that many of the uses of autoImplicit
in these files are accidental; situations such as:
variables
are in scope, but pasting the lemma in the wrong sectionHaving set_option autoImplicit false
as the default prevents these types of mistake being made in the 90% of files where autoImplicit
s are not used at all, and causes them to be caught by CI during review.
I think there were various points during the port where we encouraged porters to delete the universes u v
lines; I think having autoparams for universe variables only would cover a lot of the cases we actually use them, while avoiding any real shortcomings.
A Zulip poll (after combining overlapping votes accordingly) was in favor of this change with 5:5:18
as the no:dontcare:yes
vote ratio.
While this PR was being reviewed, a handful of files gained some more likely-accidental autoImplicits. In these places, set_option autoImplicit true
has been placed locally within a section, rather than at the top of the file.
@@ -18,6 +18,8 @@ Porting note:
This file used to be in the core library. It was moved to `mathlib` and renamed to `init` to avoid
name clashes. -/
+set_option autoImplicit true
+
open Nat Function Option
namespace Stream'
@@ -2,11 +2,6 @@
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-
-! This file was ported from Lean 3 source module data.stream.init
-! leanprover-community/mathlib commit 207cfac9fcd06138865b5d04f7091e46d9320432
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Std.Tactic.Ext
import Mathlib.Data.Stream.Defs
@@ -14,6 +9,8 @@ import Mathlib.Logic.Function.Basic
import Mathlib.Init.Data.List.Basic
import Mathlib.Data.List.Basic
+#align_import data.stream.init from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
+
/-!
# Streams a.k.a. infinite lists a.k.a. infinite sequences
@@ -318,7 +318,7 @@ theorem nth_of_bisim (bisim : IsBisimulation R) :
#align stream.nth_of_bisim Stream'.nth_of_bisim
-- If two streams are bisimilar, then they are equal
-theorem eq_of_bisim (bisim : IsBisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ := fun r =>
+theorem eq_of_bisim (bisim : IsBisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ := fun r =>
Stream'.ext fun n => And.left (nth_of_bisim R bisim n r)
#align stream.eq_of_bisim Stream'.eq_of_bisim
Alongside any necessary spacing/flow changes to accommodate their removal.
@@ -328,7 +328,7 @@ theorem bisim_simple (s₁ s₂ : Stream' α) :
head s₁ = head s₂ → s₁ = tail s₁ → s₂ = tail s₂ → s₁ = s₂ := fun hh ht₁ ht₂ =>
eq_of_bisim (fun s₁ s₂ => head s₁ = head s₂ ∧ s₁ = tail s₁ ∧ s₂ = tail s₂)
(fun s₁ s₂ ⟨h₁, h₂, h₃⟩ => by
- constructor; exact h₁; rw [← h₂, ← h₃];
+ constructor; exact h₁; rw [← h₂, ← h₃]
(repeat' constructor) <;> assumption)
(And.intro hh (And.intro ht₁ ht₂))
#align stream.bisim_simple Stream'.bisim_simple
@@ -467,13 +467,13 @@ theorem head_even (s : Stream' α) : head (even s) = head s :=
#align stream.head_even Stream'.head_even
theorem tail_even (s : Stream' α) : tail (even s) = even (tail (tail s)) := by
- unfold even;
- rw [corec_eq];
+ unfold even
+ rw [corec_eq]
rfl
#align stream.tail_even Stream'.tail_even
theorem even_cons_cons (a₁ a₂ : α) (s : Stream' α) : even (a₁::a₂::s) = a₁::even s := by
- unfold even;
+ unfold even
rw [corec_eq]; rfl
#align stream.even_cons_cons Stream'.even_cons_cons
@@ -685,13 +685,13 @@ theorem tails_eq_iterate (s : Stream' α) : tails s = iterate tail (tail s) :=
theorem inits_core_eq (l : List α) (s : Stream' α) :
initsCore l s = l::initsCore (l ++ [head s]) (tail s) := by
- unfold initsCore corecOn;
+ unfold initsCore corecOn
rw [corec_eq]
#align stream.inits_core_eq Stream'.inits_core_eq
theorem tail_inits (s : Stream' α) :
tail (inits s) = initsCore [head s, head (tail s)] (tail (tail s)) := by
- unfold inits;
+ unfold inits
rw [inits_core_eq]; rfl
#align stream.tail_inits Stream'.tail_inits
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -667,7 +667,7 @@ theorem cycle_singleton (a : α) : cycle [a] (by simp) = const a :=
#align stream.cycle_singleton Stream'.cycle_singleton
theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
- unfold tails ; rw [corec_eq] ; rfl
+ unfold tails; rw [corec_eq]; rfl
#align stream.tails_eq Stream'.tails_eq
@[simp]
We disable the "relaxed" auto-implicit feature, so only single character identifiers become eligible as auto-implicits. See discussion on zulip and 2.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
@@ -607,7 +607,8 @@ theorem get?_take_succ (n : Nat) (s : Stream' α) :
get?_take (Nat.lt_succ_self n)
#align stream.nth_take_succ Stream'.get?_take_succ
-@[simp] theorem dropLast_take : (Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
+@[simp] theorem dropLast_take {xs : Stream' α} :
+ (Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
cases n; case zero => simp
case succ n => rw [take_succ', List.dropLast_concat, Nat.succ_sub_one]
This marks many existing lemmas for Stream'
as simp, and adds a few new ones. Notably, I've removed the simp attribute from take_succ
because that lemma can result in huge goal states (since it duplicates the stream).
@@ -21,40 +21,40 @@ Porting note:
This file used to be in the core library. It was moved to `mathlib` and renamed to `init` to avoid
name clashes. -/
-
open Nat Function Option
-universe u v w
-
namespace Stream'
variable {α : Type u} {β : Type v} {δ : Type w}
-instance {α} [Inhabited α] : Inhabited (Stream' α) :=
+instance [Inhabited α] : Inhabited (Stream' α) :=
⟨Stream'.const default⟩
protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
funext fun i => by cases i <;> rfl
#align stream.eta Stream'.eta
+@[ext]
+protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, nth s₁ n = nth s₂ n) → s₁ = s₂ :=
+ fun h => funext h
+#align stream.ext Stream'.ext
+
@[simp]
theorem nth_zero_cons (a : α) (s : Stream' α) : nth (a::s) 0 = a :=
rfl
#align stream.nth_zero_cons Stream'.nth_zero_cons
+@[simp]
theorem head_cons (a : α) (s : Stream' α) : head (a::s) = a :=
rfl
#align stream.head_cons Stream'.head_cons
+@[simp]
theorem tail_cons (a : α) (s : Stream' α) : tail (a::s) = s :=
rfl
#align stream.tail_cons Stream'.tail_cons
-theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s) :=
- funext fun i => by
- unfold tail drop; simp [nth, Nat.add_comm, Nat.add_left_comm, Nat.add_assoc]
-#align stream.tail_drop Stream'.tail_drop
-
+@[simp]
theorem nth_drop (n m : Nat) (s : Stream' α) : nth (drop m s) n = nth s (n + m) :=
rfl
#align stream.nth_drop Stream'.nth_drop
@@ -63,10 +63,21 @@ theorem tail_eq_drop (s : Stream' α) : tail s = drop 1 s :=
rfl
#align stream.tail_eq_drop Stream'.tail_eq_drop
-theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s :=
- funext fun i => by unfold drop; rw [Nat.add_assoc]
+@[simp]
+theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s := by
+ ext; simp [Nat.add_assoc]
#align stream.drop_drop Stream'.drop_drop
+@[simp] theorem nth_tail {s : Stream' α} : s.tail.nth n = s.nth (n + 1) := rfl
+
+@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
+ ext; simp [add_comm, add_assoc, add_left_comm]
+
+@[simp] theorem drop_tail' {s : Stream' α} : drop i (tail s) = s.drop (i+1) := rfl
+
+theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s) := by simp
+#align stream.tail_drop Stream'.tail_drop
+
theorem nth_succ (n : Nat) (s : Stream' α) : nth s (succ n) = nth (tail s) n :=
rfl
#align stream.nth_succ Stream'.nth_succ
@@ -76,20 +87,15 @@ theorem nth_succ_cons (n : Nat) (s : Stream' α) (x : α) : nth (x::s) n.succ =
rfl
#align stream.nth_succ_cons Stream'.nth_succ_cons
+@[simp] theorem drop_zero {s : Stream' α} : s.drop 0 = s := rfl
+
theorem drop_succ (n : Nat) (s : Stream' α) : drop (succ n) s = drop n (tail s) :=
rfl
#align stream.drop_succ Stream'.drop_succ
-@[simp]
-theorem head_drop {α} (a : Stream' α) (n : ℕ) : (a.drop n).head = a.nth n := by
- simp only [drop, head, Nat.zero_add, Stream'.nth]
+theorem head_drop (a : Stream' α) (n : ℕ) : (a.drop n).head = a.nth n := by simp
#align stream.head_drop Stream'.head_drop
-@[ext]
-protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, nth s₁ n = nth s₂ n) → s₁ = s₂ :=
- fun h => funext h
-#align stream.ext Stream'.ext
-
theorem cons_injective2 : Function.Injective2 (cons : α → Stream' α → Stream' α) := fun x y s t h =>
⟨by rw [← nth_zero_cons x s, h, nth_zero_cons],
Stream'.ext fun n => by rw [← nth_succ_cons n _ x, h, nth_succ_cons]⟩
@@ -111,6 +117,7 @@ theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (nth s n
rfl
#align stream.any_def Stream'.any_def
+@[simp]
theorem mem_cons (a : α) (s : Stream' α) : a ∈ a::s :=
Exists.intro 0 rfl
#align stream.mem_cons Stream'.mem_cons
@@ -141,13 +148,15 @@ theorem drop_map (n : Nat) (s : Stream' α) : drop n (map f s) = map f (drop n s
Stream'.ext fun _ => rfl
#align stream.drop_map Stream'.drop_map
+@[simp]
theorem nth_map (n : Nat) (s : Stream' α) : nth (map f s) n = f (nth s n) :=
rfl
#align stream.nth_map Stream'.nth_map
-theorem tail_map (s : Stream' α) : tail (map f s) = map f (tail s) := by rw [tail_eq_drop]; rfl
+theorem tail_map (s : Stream' α) : tail (map f s) = map f (tail s) := rfl
#align stream.tail_map Stream'.tail_map
+@[simp]
theorem head_map (s : Stream' α) : head (map f s) = f (head s) :=
rfl
#align stream.head_map Stream'.head_map
@@ -160,14 +169,17 @@ theorem map_cons (a : α) (s : Stream' α) : map f (a::s) = f a::map f s := by
rw [← Stream'.eta (map f (a::s)), map_eq]; rfl
#align stream.map_cons Stream'.map_cons
+@[simp]
theorem map_id (s : Stream' α) : map id s = s :=
rfl
#align stream.map_id Stream'.map_id
+@[simp]
theorem map_map (g : β → δ) (f : α → β) (s : Stream' α) : map g (map f s) = map (g ∘ f) s :=
rfl
#align stream.map_map Stream'.map_map
+@[simp]
theorem map_tail (s : Stream' α) : map f (tail s) = tail (map f s) :=
rfl
#align stream.map_tail Stream'.map_tail
@@ -191,6 +203,7 @@ theorem drop_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
Stream'.ext fun _ => rfl
#align stream.drop_zip Stream'.drop_zip
+@[simp]
theorem nth_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
nth (zip f s₁ s₂) n = f (nth s₁ n) (nth s₂ n) :=
rfl
@@ -221,6 +234,7 @@ theorem enum_eq_zip (s : Stream' α) : enum s = zip Prod.mk nats s :=
end Zip
+@[simp]
theorem mem_const (a : α) : a ∈ const a :=
Exists.intro 0 rfl
#align stream.mem_const Stream'.mem_const
@@ -230,36 +244,41 @@ theorem const_eq (a : α) : const a = a::const a := by
cases n <;> rfl
#align stream.const_eq Stream'.const_eq
+@[simp]
theorem tail_const (a : α) : tail (const a) = const a :=
suffices tail (a::const a) = const a by rwa [← const_eq] at this
rfl
#align stream.tail_const Stream'.tail_const
+@[simp]
theorem map_const (f : α → β) (a : α) : map f (const a) = const (f a) :=
rfl
#align stream.map_const Stream'.map_const
+@[simp]
theorem nth_const (n : Nat) (a : α) : nth (const a) n = a :=
rfl
#align stream.nth_const Stream'.nth_const
+@[simp]
theorem drop_const (n : Nat) (a : α) : drop n (const a) = const a :=
Stream'.ext fun _ => rfl
#align stream.drop_const Stream'.drop_const
+@[simp]
theorem head_iterate (f : α → α) (a : α) : head (iterate f a) = a :=
rfl
#align stream.head_iterate Stream'.head_iterate
+theorem nth_succ_iterate' (n : Nat) (f : α → α) (a : α) :
+ nth (iterate f a) (succ n) = f (nth (iterate f a) n) := rfl
+
theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (f a) := by
- funext n
+ ext n
+ rw [nth_tail]
induction' n with n' ih
· rfl
- · unfold tail iterate
- rw [Nat.add, Nat.add_zero (succ n')]
- rw [tail, iterate] at ih
- rw [iterate]
- congr
+ · rw [nth_succ_iterate', ih, nth_succ_iterate']
#align stream.tail_iterate Stream'.tail_iterate
theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) := by
@@ -267,6 +286,7 @@ theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) :
rw [tail_iterate]; rfl
#align stream.iterate_eq Stream'.iterate_eq
+@[simp]
theorem nth_zero_iterate (f : α → α) (a : α) : nth (iterate f a) 0 = a :=
rfl
#align stream.nth_zero_iterate Stream'.nth_zero_iterate
@@ -333,6 +353,7 @@ theorem coinduction {s₁ s₂ : Stream' α} :
(And.intro hh ht)
#align stream.coinduction Stream'.coinduction
+@[simp]
theorem iterate_id (a : α) : iterate id a = const a :=
coinduction rfl fun β fr ch => by rw [tail_iterate, tail_const]; exact ch
#align stream.iterate_id Stream'.iterate_id
@@ -440,6 +461,7 @@ theorem odd_eq (s : Stream' α) : odd s = even (tail s) :=
rfl
#align stream.odd_eq Stream'.odd_eq
+@[simp]
theorem head_even (s : Stream' α) : head (even s) = head s :=
rfl
#align stream.head_even Stream'.head_even
@@ -549,23 +571,47 @@ theorem take_zero (s : Stream' α) : take 0 s = [] :=
rfl
#align stream.take_zero Stream'.take_zero
-@[simp]
+-- This lemma used to be simp, but we removed it from the simp set because:
+-- 1) It duplicates the (often large) `s` term, resulting in large tactic states.
+-- 2) It conflicts with the very useful `dropLast_take` lemma below (causing nonconfluence).
theorem take_succ (n : Nat) (s : Stream' α) : take (succ n) s = head s::take n (tail s) :=
rfl
#align stream.take_succ Stream'.take_succ
+@[simp] theorem take_succ_cons (n : Nat) (s : Stream' α) : take (n+1) (a::s) = a :: take n s := rfl
+
+theorem take_succ' {s : Stream' α} : ∀ n, s.take (n+1) = s.take n ++ [s.nth n]
+ | 0 => rfl
+ | n+1 => by rw [take_succ, take_succ' n, ← List.cons_append, ← take_succ, nth_tail]
+
@[simp]
theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
- induction n generalizing s <;> simp [*]
+ induction n generalizing s <;> simp [*, take_succ]
#align stream.length_take Stream'.length_take
-theorem get?_take_succ : ∀ (n : Nat) (s : Stream' α),
- List.get? (take (succ n) s) n = some (nth s n)
- | 0, s => rfl
- | n + 1, s => by
- rw [take_succ, add_one, List.get?, get?_take_succ n]; rfl
+@[simp]
+theorem take_take {s : Stream' α} : ∀ {m n}, (s.take n).take m = s.take (min n m)
+ | 0, n => by rw [min_zero, List.take_zero, take_zero]
+ | m, 0 => by rw [zero_min, take_zero, List.take_nil]
+ | m+1, n+1 => by rw [take_succ, List.take_cons, Nat.min_succ_succ, take_succ, take_take]
+
+@[simp] theorem concat_take_nth {s : Stream' α} : s.take n ++ [s.nth n] = s.take (n+1) :=
+ (take_succ' n).symm
+
+theorem get?_take {s : Stream' α} : ∀ {k n}, k < n → (s.take n).get? k = s.nth k
+ | 0, n+1, _ => rfl
+ | k+1, n+1, h => by rw [take_succ, List.get?, get?_take (Nat.lt_of_succ_lt_succ h), nth_succ]
+
+theorem get?_take_succ (n : Nat) (s : Stream' α) :
+ List.get? (take (succ n) s) n = some (nth s n) :=
+ get?_take (Nat.lt_succ_self n)
#align stream.nth_take_succ Stream'.get?_take_succ
+@[simp] theorem dropLast_take : (Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
+ cases n; case zero => simp
+ case succ n => rw [take_succ', List.dropLast_concat, Nat.succ_sub_one]
+
+@[simp]
theorem append_take_drop : ∀ (n : Nat) (s : Stream' α),
appendStream' (take n s) (drop n s) = s := by
intro n
@@ -614,7 +660,8 @@ theorem mem_cycle {a : α} {l : List α} : ∀ h : l ≠ [], a ∈ l → a ∈ c
rw [cycle_eq]; exact mem_append_stream_left _ ainl
#align stream.mem_cycle Stream'.mem_cycle
-theorem cycle_singleton (a : α) (h : [a] ≠ []) : cycle [a] h = const a :=
+@[simp]
+theorem cycle_singleton (a : α) : cycle [a] (by simp) = const a :=
coinduction rfl fun β fr ch => by rwa [cycle_eq, const_eq]
#align stream.cycle_singleton Stream'.cycle_singleton
@@ -622,6 +669,7 @@ theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
unfold tails ; rw [corec_eq] ; rfl
#align stream.tails_eq Stream'.tails_eq
+@[simp]
theorem nth_tails : ∀ (n : Nat) (s : Stream' α), nth (tails s) n = drop n (tail s) := by
intro n; induction' n with n' ih
· intros
@@ -662,6 +710,7 @@ theorem cons_nth_inits_core :
rfl
#align stream.cons_nth_inits_core Stream'.cons_nth_inits_core
+@[simp]
theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ n) s := by
intro n; induction' n with n' ih
· intros
by
s! (#3825)
This PR puts, with one exception, every single remaining by
that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh
. The exception is when the by
begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.
Essentially this is s/\n *by$/ by/g
, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated by
s".
@@ -597,11 +597,8 @@ protected theorem cycle_g_cons (a : α) (a₁ : α) (l₁ : List α) (a₀ : α)
theorem cycle_eq : ∀ (l : List α) (h : l ≠ []), cycle l h = l ++ₛ cycle l h
| [], h => absurd rfl h
| List.cons a l, _ =>
- have gen :
- ∀ l' a',
- corec Stream'.cycleF Stream'.cycleG (a', l', a, l) =
- (a'::l') ++ₛ corec Stream'.cycleF Stream'.cycleG (a, l, a, l) :=
- by
+ have gen : ∀ l' a', corec Stream'.cycleF Stream'.cycleG (a', l', a, l) =
+ (a'::l') ++ₛ corec Stream'.cycleF Stream'.cycleG (a, l, a, l) := by
intro l'
induction' l' with a₁ l₁ ih
· intros
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.)@@ -448,8 +448,6 @@ theorem tail_even (s : Stream' α) : tail (even s) = even (tail (tail s)) := by
unfold even;
rw [corec_eq];
rfl
-
-
#align stream.tail_even Stream'.tail_even
theorem even_cons_cons (a₁ a₂ : α) (s : Stream' α) : even (a₁::a₂::s) = a₁::even s := by
@@ -485,7 +483,6 @@ theorem nth_even : ∀ (n : Nat) (s : Stream' α), nth (even s) n = nth s (2 * n
| succ n, s => by
change nth (even s) (succ n) = nth s (succ (succ (2 * n)))
rw [nth_succ, nth_succ, tail_even, nth_even n]; rfl
-
#align stream.nth_even Stream'.nth_even
theorem nth_odd : ∀ (n : Nat) (s : Stream' α), nth (odd s) n = nth s (2 * n + 1) := fun n s => by
@@ -514,7 +511,6 @@ theorem append_append_stream : ∀ (l₁ l₂ : List α) (s : Stream' α),
| [], l₂, s => rfl
| List.cons a l₁, l₂, s => by
rw [List.cons_append, cons_append_stream, cons_append_stream, append_append_stream l₁]
-
#align stream.append_append_stream Stream'.append_append_stream
theorem map_append_stream (f : α → β) :
This was done semi-automatically with some regular expressions in vim in contrast to the fully automatic https://github.com/leanprover-community/mathlib4/pull/1523.
Co-authored-by: Moritz Firsching <firsching@google.com>
@@ -677,8 +677,8 @@ theorem nth_inits : ∀ (n : Nat) (s : Stream' α), nth (inits s) n = take (succ
rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core]
#align stream.nth_inits Stream'.nth_inits
-theorem inits_eq (s : Stream' α) : inits s = [head s]::map (List.cons (head s)) (inits (tail s)) :=
- by
+theorem inits_eq (s : Stream' α) :
+ inits s = [head s]::map (List.cons (head s)) (inits (tail s)) := by
apply Stream'.ext; intro n
cases n
· rfl
by
line breaks (#1523)
During porting, I usually fix the desired format we seem to want for the line breaks around by
with
awk '{do {{if (match($0, "^ by$") && length(p) < 98) {p=p " by";} else {if (NR!=1) {print p}; p=$0}}} while (getline == 1) if (getline==0) print p}' Mathlib/File/Im/Working/On.lean
I noticed there are some more files that slipped through.
This pull request is the result of running this command:
grep -lr "^ by\$" Mathlib | xargs -n 1 awk -i inplace '{do {{if (match($0, "^ by$") && length(p) < 98 && not (match(p, "^[ \t]*--"))) {p=p " by";} else {if (NR!=1) {print p}; p=$0}}} while (getline == 1) if (getline==0) print p}'
Co-authored-by: Moritz Firsching <firsching@google.com>
@@ -120,8 +120,7 @@ theorem mem_cons_of_mem {a : α} {s : Stream' α} (b : α) : a ∈ s → a ∈ b
#align stream.mem_cons_of_mem Stream'.mem_cons_of_mem
theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a = b ∨ a ∈ s :=
- fun ⟨n, h⟩ =>
- by
+ fun ⟨n, h⟩ => by
cases' n with n'
· left
exact h
@@ -382,8 +381,7 @@ theorem unfolds_eq (g : α → β) (f : α → α) (a : α) : unfolds g f a = g
#align stream.unfolds_eq Stream'.unfolds_eq
theorem nth_unfolds_head_tail : ∀ (n : Nat) (s : Stream' α),
- nth (unfolds head tail s) n = nth s n :=
- by
+ nth (unfolds head tail s) n = nth s n := by
intro n; induction' n with n' ih
· intro s
rfl
@@ -661,8 +659,7 @@ theorem inits_tail (s : Stream' α) : inits (tail s) = initsCore [head (tail s)]
theorem cons_nth_inits_core :
∀ (a : α) (n : Nat) (l : List α) (s : Stream' α),
- (a::nth (initsCore l s) n) = nth (initsCore (a::l) s) n :=
- by
+ (a::nth (initsCore l s) n) = nth (initsCore (a::l) s) n := by
intro a n
induction' n with n' ih
· intros
Notes so far
There are various problems with theorems already having been ported. Sometimes there was a change in universe level order, implicit argument order, or explicit arguments order or explicicity of arguments. In these situations I did the following.
--Ignore the error and align the old lemma when the difference between the two was just universe.
--Align the old lemma with the new lemma but incluce a porting note when the difference was the order of implicit arguments
--Make a new lemma with a '
at the end when the difference was to do with explicit arguments.
I also added a bunch of definitions that were not imported, possibly with the wrong names. These definitions are
repeat
, ret
, empty
, init
, last
, ilast
There is a question to be answered about what to do with list.nth_le
, which is discussed on Zulip
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com> Co-authored-by: Johan Commelin <johan@commelin.net> Co-authored-by: Siddhartha Gadgil <siddhartha.gadgil@gmail.com>
@@ -565,12 +565,12 @@ theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
induction n generalizing s <;> simp [*]
#align stream.length_take Stream'.length_take
-theorem nth_take_succ : ∀ (n : Nat) (s : Stream' α),
- List.nth (take (succ n) s) n = some (nth s n)
+theorem get?_take_succ : ∀ (n : Nat) (s : Stream' α),
+ List.get? (take (succ n) s) n = some (nth s n)
| 0, s => rfl
| n + 1, s => by
- rw [take_succ, add_one, List.nth, nth_take_succ n]; rfl
-#align stream.nth_take_succ Stream'.nth_take_succ
+ rw [take_succ, add_one, List.get?, get?_take_succ n]; rfl
+#align stream.nth_take_succ Stream'.get?_take_succ
theorem append_take_drop : ∀ (n : Nat) (s : Stream' α),
appendStream' (take n s) (drop n s) = s := by
@@ -591,7 +591,7 @@ theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take
simp [take] at aux
exact aux
· have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)) := by
- rw [← nth_take_succ, ← nth_take_succ, h (succ (succ n))]
+ rw [← get?_take_succ, ← get?_take_succ, h (succ (succ n))]
injection h₁
#align stream.take_theorem Stream'.take_theorem
All dependencies are ported!