data.seq.seqMathlib.Data.Seq.Seq

This file has been ported!

Changes since the initial port

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.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -5,7 +5,7 @@ Authors: Mario Carneiro
 -/
 import Data.List.Basic
 import Data.LazyList
-import Data.Nat.Defs
+import Algebra.Group.Nat
 import Data.Stream.Init
 import Data.Seq.Computation
 
Diff
@@ -5,7 +5,7 @@ Authors: Mario Carneiro
 -/
 import Data.List.Basic
 import Data.LazyList
-import Data.Nat.Basic
+import Data.Nat.Defs
 import Data.Stream.Init
 import Data.Seq.Computation
 
Diff
@@ -282,7 +282,7 @@ theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s =
   · cases' s with f al
     injections _ h1 h2
     rw [← h2]; apply Subtype.eq; dsimp [tail, cons]
-    rw [h1] at f0 ; rw [← f0]
+    rw [h1] at f0; rw [← f0]
     exact (Stream'.eta f).symm
 #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons
 -/
@@ -359,7 +359,7 @@ def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (co
 theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s :=
   by
-  cases' M with k e; unfold Stream'.get at e 
+  cases' M with k e; unfold Stream'.get at e
   induction' k with k IH generalizing s
   · have TH : s = cons a (tail s) := by
       apply destruct_eq_cons
@@ -368,7 +368,7 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
   revert e; apply s.rec_on _ fun b s' => _ <;> intro e
   · injection e
   · have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s' <;> rfl
-    rw [h_eq] at e 
+    rw [h_eq] at e
     apply h1 _ _ (Or.inr (IH e))
 #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on
 -/
@@ -396,7 +396,7 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α :=
   induction' n with n IH <;> intro o
   · change (corec.F f o).1 = none → (corec.F f (corec.F f o).2).1 = none
     cases' o with b <;> intro h; · rfl
-    dsimp [corec.F] at h ; dsimp [corec.F]
+    dsimp [corec.F] at h; dsimp [corec.F]
     cases' f b with s; · rfl
     · cases' s with a b'; contradiction
   · rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
@@ -462,11 +462,11 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
       have := bisim r; revert r this
       apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
       · constructor; rfl; assumption
-      · rw [destruct_nil, destruct_cons] at this 
+      · rw [destruct_nil, destruct_cons] at this
         exact False.elim this
-      · rw [destruct_nil, destruct_cons] at this 
+      · rw [destruct_nil, destruct_cons] at this
         exact False.elim this
-      · rw [destruct_cons, destruct_cons] at this 
+      · rw [destruct_cons, destruct_cons] at this
         rw [head_cons, head_cons, tail_cons, tail_cons]
         cases' this with h1 h2
         constructor; rw [h1]; exact h2
Diff
@@ -359,7 +359,7 @@ def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (co
 theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s :=
   by
-  cases' M with k e; unfold Stream'.nth at e 
+  cases' M with k e; unfold Stream'.get at e 
   induction' k with k IH generalizing s
   · have TH : s = cons a (tail s) := by
       apply destruct_eq_cons
@@ -522,11 +522,11 @@ theorem ofList_nil : ofList [] = (nil : Seq α) :=
 #align stream.seq.of_list_nil Stream'.Seq.ofList_nil
 -/
 
-#print Stream'.Seq.ofList_nth /-
+#print Stream'.Seq.ofList_get /-
 @[simp]
-theorem ofList_nth (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
+theorem ofList_get (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
   rfl
-#align stream.seq.of_list_nth Stream'.Seq.ofList_nth
+#align stream.seq.of_list_nth Stream'.Seq.ofList_get
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -620,7 +620,7 @@ def map (f : α → β) : Seq α → Seq β
   | ⟨s, al⟩ =>
     ⟨s.map (Option.map f), fun n =>
       by
-      dsimp [Stream'.map, Stream'.nth]
+      dsimp [Stream'.map, Stream'.get]
       induction' e : s n with <;> intro
       · rw [al e]; assumption; · contradiction⟩
 #align stream.seq.map Stream'.Seq.map
Diff
@@ -3,11 +3,11 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
-import Mathbin.Data.List.Basic
-import Mathbin.Data.LazyList
-import Mathbin.Data.Nat.Basic
-import Mathbin.Data.Stream.Init
-import Mathbin.Data.Seq.Computation
+import Data.List.Basic
+import Data.LazyList
+import Data.Nat.Basic
+import Data.Stream.Init
+import Data.Seq.Computation
 
 #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
 
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.seq.seq
-! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.List.Basic
 import Mathbin.Data.LazyList
@@ -14,6 +9,8 @@ import Mathbin.Data.Nat.Basic
 import Mathbin.Data.Stream.Init
 import Mathbin.Data.Seq.Computation
 
+#align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
 namespace Stream'
 
 universe u v w
Diff
@@ -1256,7 +1256,7 @@ instance : Monad Seq1 where
 
 instance : LawfulMonad Seq1 where
   id_map := @map_id
-  bind_pure_comp_eq_map := @bind_ret
+  bind_pure_comp := @bind_ret
   pure_bind := @ret_bind
   bind_assoc := @bind_assoc
 
Diff
@@ -307,9 +307,11 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
 #align stream.seq.destruct_cons Stream'.Seq.destruct_cons
 -/
 
+#print Stream'.Seq.head_eq_destruct /-
 theorem head_eq_destruct (s : Seq α) : head s = Prod.fst <$> destruct s := by
   unfold destruct head <;> cases nth s 0 <;> rfl
 #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
+-/
 
 #print Stream'.Seq.head_nil /-
 @[simp]
@@ -426,7 +428,6 @@ section Bisim
 
 variable (R : Seq α → Seq α → Prop)
 
--- mathport name: R
 local infixl:50 " ~ " => R
 
 #print Stream'.Seq.BisimO /-
Diff
@@ -203,7 +203,7 @@ instance : Membership α (Seq α) :=
 
 #print Stream'.Seq.le_stable /-
 theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by
-  cases' s with f al; induction' h with n h IH; exacts[id, fun h2 => al (IH h2)]
+  cases' s with f al; induction' h with n h IH; exacts [id, fun h2 => al (IH h2)]
 #align stream.seq.le_stable Stream'.Seq.le_stable
 -/
 
@@ -252,7 +252,7 @@ theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s →
 #print Stream'.Seq.mem_cons_iff /-
 @[simp]
 theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
-  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons;exact mem_cons_of_mem _ m]⟩
+  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons; exact mem_cons_of_mem _ m]⟩
 #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff
 -/
 
@@ -271,7 +271,7 @@ theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil :=
   induction' f0 : nth s 0 with <;> intro h
   · apply Subtype.eq
     funext n
-    induction' n with n IH; exacts[f0, s.2 IH]
+    induction' n with n IH; exacts [f0, s.2 IH]
   · contradiction
 #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
 -/
@@ -285,7 +285,7 @@ theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s =
   · cases' s with f al
     injections _ h1 h2
     rw [← h2]; apply Subtype.eq; dsimp [tail, cons]
-    rw [h1] at f0; rw [← f0]
+    rw [h1] at f0 ; rw [← f0]
     exact (Stream'.eta f).symm
 #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons
 -/
@@ -360,7 +360,7 @@ def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (co
 theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s :=
   by
-  cases' M with k e; unfold Stream'.nth at e
+  cases' M with k e; unfold Stream'.nth at e 
   induction' k with k IH generalizing s
   · have TH : s = cons a (tail s) := by
       apply destruct_eq_cons
@@ -369,7 +369,7 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
   revert e; apply s.rec_on _ fun b s' => _ <;> intro e
   · injection e
   · have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s' <;> rfl
-    rw [h_eq] at e
+    rw [h_eq] at e 
     apply h1 _ _ (Or.inr (IH e))
 #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on
 -/
@@ -397,7 +397,7 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α :=
   induction' n with n IH <;> intro o
   · change (corec.F f o).1 = none → (corec.F f (corec.F f o).2).1 = none
     cases' o with b <;> intro h; · rfl
-    dsimp [corec.F] at h; dsimp [corec.F]
+    dsimp [corec.F] at h ; dsimp [corec.F]
     cases' f b with s; · rfl
     · cases' s with a b'; contradiction
   · rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
@@ -464,11 +464,11 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
       have := bisim r; revert r this
       apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
       · constructor; rfl; assumption
-      · rw [destruct_nil, destruct_cons] at this
+      · rw [destruct_nil, destruct_cons] at this 
         exact False.elim this
-      · rw [destruct_nil, destruct_cons] at this
+      · rw [destruct_nil, destruct_cons] at this 
         exact False.elim this
-      · rw [destruct_cons, destruct_cons] at this
+      · rw [destruct_cons, destruct_cons] at this 
         rw [head_cons, head_cons, tail_cons, tail_cons]
         cases' this with h1 h2
         constructor; rw [h1]; exact h2
@@ -506,7 +506,7 @@ theorem coinduction2 (s) (f g : Seq α → Seq β)
 /-- Embed a list as a sequence -/
 def ofList (l : List α) : Seq α :=
   ⟨List.get? l, fun n h => by
-    rw [List.get?_eq_none] at h⊢
+    rw [List.get?_eq_none] at h ⊢
     exact h.trans (Nat.le_succ n)⟩
 #align stream.seq.of_list Stream'.Seq.ofList
 -/
Diff
@@ -307,12 +307,6 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
 #align stream.seq.destruct_cons Stream'.Seq.destruct_cons
 -/
 
-/- warning: stream.seq.head_eq_destruct -> Stream'.Seq.head_eq_destruct is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} (s : Stream'.Seq.{u1} α), Eq.{succ u1} (Option.{u1} α) (Stream'.Seq.head.{u1} α s) (Functor.map.{u1, u1} Option.{u1} (Traversable.toFunctor.{u1} Option.{u1} Option.traversable.{u1}) (Prod.{u1, u1} α (Stream'.Seq.{u1} α)) α (Prod.fst.{u1, u1} α (Stream'.Seq.{u1} α)) (Stream'.Seq.destruct.{u1} α s))
-but is expected to have type
-  forall {α : Type.{u1}} (s : Stream'.Seq.{u1} α), Eq.{succ u1} (Option.{u1} α) (Stream'.Seq.head.{u1} α s) (Functor.map.{u1, u1} Option.{u1} instFunctorOption.{u1} (Prod.{u1, u1} α (Stream'.Seq.{u1} α)) α (Prod.fst.{u1, u1} α (Stream'.Seq.{u1} α)) (Stream'.Seq.destruct.{u1} α s))
-Case conversion may be inaccurate. Consider using '#align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destructₓ'. -/
 theorem head_eq_destruct (s : Seq α) : head s = Prod.fst <$> destruct s := by
   unfold destruct head <;> cases nth s 0 <;> rfl
 #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
Diff
@@ -187,9 +187,7 @@ def head (s : Seq α) : Option α :=
 #print Stream'.Seq.tail /-
 /-- Get the tail of a sequence (or `nil` if the sequence is `nil`) -/
 def tail (s : Seq α) : Seq α :=
-  ⟨s.1.tail, fun n => by
-    cases' s with f al
-    exact al⟩
+  ⟨s.1.tail, fun n => by cases' s with f al; exact al⟩
 #align stream.seq.tail Stream'.Seq.tail
 -/
 
@@ -204,11 +202,8 @@ instance : Membership α (Seq α) :=
   ⟨Seq.Mem⟩
 
 #print Stream'.Seq.le_stable /-
-theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none :=
-  by
-  cases' s with f al
-  induction' h with n h IH
-  exacts[id, fun h2 => al (IH h2)]
+theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by
+  cases' s with f al; induction' h with n h IH; exacts[id, fun h2 => al (IH h2)]
 #align stream.seq.le_stable Stream'.Seq.le_stable
 -/
 
@@ -276,8 +271,7 @@ theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil :=
   induction' f0 : nth s 0 with <;> intro h
   · apply Subtype.eq
     funext n
-    induction' n with n IH
-    exacts[f0, s.2 IH]
+    induction' n with n IH; exacts[f0, s.2 IH]
   · contradiction
 #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
 -/
@@ -290,11 +284,8 @@ theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s =
   · contradiction
   · cases' s with f al
     injections _ h1 h2
-    rw [← h2]
-    apply Subtype.eq
-    dsimp [tail, cons]
-    rw [h1] at f0
-    rw [← f0]
+    rw [← h2]; apply Subtype.eq; dsimp [tail, cons]
+    rw [h1] at f0; rw [← f0]
     exact (Stream'.eta f).symm
 #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons
 -/
@@ -366,11 +357,8 @@ theorem get?_tail (s : Seq α) (n) : get? (tail s) n = get? s (n + 1) :=
 def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s :=
   by
   induction' H : destruct s with v v
-  · rw [destruct_eq_nil H]
-    apply h1
-  · cases' v with a s'
-    rw [destruct_eq_cons H]
-    apply h2
+  · rw [destruct_eq_nil H]; apply h1
+  · cases' v with a s'; rw [destruct_eq_cons H]; apply h2
 #align stream.seq.rec_on Stream'.Seq.recOn
 -/
 
@@ -382,11 +370,8 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
   induction' k with k IH generalizing s
   · have TH : s = cons a (tail s) := by
       apply destruct_eq_cons
-      unfold destruct nth Functor.map
-      rw [← e]
-      rfl
-    rw [TH]
-    apply h1 _ _ (Or.inl rfl)
+      unfold destruct nth Functor.map; rw [← e]; rfl
+    rw [TH]; apply h1 _ _ (Or.inl rfl)
   revert e; apply s.rec_on _ fun b s' => _ <;> intro e
   · injection e
   · have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s' <;> rfl
@@ -417,14 +402,10 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α :=
   revert h; generalize some b = o; revert o
   induction' n with n IH <;> intro o
   · change (corec.F f o).1 = none → (corec.F f (corec.F f o).2).1 = none
-    cases' o with b <;> intro h
-    · rfl
-    dsimp [corec.F] at h
-    dsimp [corec.F]
-    cases' f b with s
-    · rfl
-    · cases' s with a b'
-      contradiction
+    cases' o with b <;> intro h; · rfl
+    dsimp [corec.F] at h; dsimp [corec.F]
+    cases' f b with s; · rfl
+    · cases' s with a b'; contradiction
   · rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
     exact IH (corec.F f o).2
 #align stream.seq.corec Stream'.Seq.corec
@@ -488,9 +469,7 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
         And.imp id (fun r => ⟨tail s, tail s', by cases s <;> rfl, by cases s' <;> rfl, r⟩) this
       have := bisim r; revert r this
       apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
-      · constructor
-        rfl
-        assumption
+      · constructor; rfl; assumption
       · rw [destruct_nil, destruct_cons] at this
         exact False.elim this
       · rw [destruct_nil, destruct_cons] at this
@@ -498,9 +477,7 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
       · rw [destruct_cons, destruct_cons] at this
         rw [head_cons, head_cons, tail_cons, tail_cons]
         cases' this with h1 h2
-        constructor
-        rw [h1]
-        exact h2
+        constructor; rw [h1]; exact h2
   exact ⟨s₁, s₂, rfl, rfl, r⟩
 #align stream.seq.eq_of_bisim Stream'.Seq.eq_of_bisim
 -/
@@ -653,8 +630,7 @@ def map (f : α → β) : Seq α → Seq β
       by
       dsimp [Stream'.map, Stream'.nth]
       induction' e : s n with <;> intro
-      · rw [al e]
-        assumption; · contradiction⟩
+      · rw [al e]; assumption; · contradiction⟩
 #align stream.seq.map Stream'.Seq.map
 -/
 
@@ -807,8 +783,7 @@ theorem nil_append (s : Seq α) : append nil s = s :=
   dsimp [append]; apply rec_on s _ _
   · trivial
   · intro x s
-    rw [destruct_cons]
-    dsimp
+    rw [destruct_cons]; dsimp
     exact ⟨rfl, s, rfl, rfl⟩
 #align stream.seq.nil_append Stream'.Seq.nil_append
 -/
@@ -831,8 +806,7 @@ theorem append_nil (s : Seq α) : append s nil = s :=
   apply rec_on s _ _
   · trivial
   · intro x s
-    rw [cons_append, destruct_cons, destruct_cons]
-    dsimp
+    rw [cons_append, destruct_cons, destruct_cons]; dsimp
     exact ⟨rfl, s, rfl, rfl⟩
 #align stream.seq.append_nil Stream'.Seq.append_nil
 -/
@@ -842,19 +816,16 @@ theorem append_nil (s : Seq α) : append s nil = s :=
 theorem append_assoc (s t u : Seq α) : append (append s t) u = append s (append t u) :=
   by
   apply eq_of_bisim fun s1 s2 => ∃ s t u, s1 = append (append s t) u ∧ s2 = append s (append t u)
-  · intro s1 s2 h
+  · intro s1 s2 h;
     exact
       match s1, s2, h with
       | _, _, ⟨s, t, u, rfl, rfl⟩ => by
         apply rec_on s <;> simp
         · apply rec_on t <;> simp
           · apply rec_on u <;> simp
-            · intro x u
-              refine' ⟨nil, nil, u, _, _⟩ <;> simp
-          · intro x t
-            refine' ⟨nil, t, u, _, _⟩ <;> simp
-        · intro x s
-          exact ⟨s, t, u, rfl, rfl⟩
+            · intro x u; refine' ⟨nil, nil, u, _, _⟩ <;> simp
+          · intro x t; refine' ⟨nil, t, u, _, _⟩ <;> simp
+        · intro x s; exact ⟨s, t, u, rfl, rfl⟩
   · exact ⟨s, t, u, rfl, rfl⟩
 #align stream.seq.append_assoc Stream'.Seq.append_assoc
 -/
@@ -912,10 +883,8 @@ theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s)
     | _, _, ⟨s, t, rfl, rfl⟩ => by
       apply rec_on s <;> simp
       · apply rec_on t <;> simp
-        · intro x t
-          refine' ⟨nil, t, _, _⟩ <;> simp
-      · intro x s
-        refine' ⟨s, t, rfl, rfl⟩
+        · intro x t; refine' ⟨nil, t, _, _⟩ <;> simp
+      · intro x s; refine' ⟨s, t, rfl, rfl⟩
 #align stream.seq.map_append Stream'.Seq.map_append
 -/
 
@@ -967,15 +936,11 @@ theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join
     match s1, s2, h with
     | _, _, Or.inl <| Eq.refl s => by
       apply rec_on s; · trivial
-      · intro x s
-        rw [destruct_cons]
-        exact ⟨rfl, Or.inl rfl⟩
+      · intro x s; rw [destruct_cons]; exact ⟨rfl, Or.inl rfl⟩
     | _, _, Or.inr ⟨a, s, S, rfl, rfl⟩ => by
       apply rec_on s
       · simp
-      · intro x s
-        simp
-        refine' Or.inr ⟨x, s, S, rfl, rfl⟩
+      · intro x s; simp; refine' Or.inr ⟨x, s, S, rfl, rfl⟩
 #align stream.seq.join_cons Stream'.Seq.join_cons
 -/
 
@@ -986,22 +951,18 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
   apply
     eq_of_bisim fun s1 s2 =>
       ∃ s S T, s1 = append s (join (append S T)) ∧ s2 = append s (append (join S) (join T))
-  · intro s1 s2 h
+  · intro s1 s2 h;
     exact
       match s1, s2, h with
       | _, _, ⟨s, S, T, rfl, rfl⟩ => by
         apply rec_on s <;> simp
         · apply rec_on S <;> simp
-          · apply rec_on T
-            · simp
-            · intro s T
-              cases' s with a s <;> simp
+          · apply rec_on T; · simp
+            · intro s T; cases' s with a s <;> simp
               refine' ⟨s, nil, T, _, _⟩ <;> simp
-          · intro s S
-            cases' s with a s <;> simp
+          · intro s S; cases' s with a s <;> simp
             exact ⟨s, S, T, rfl, rfl⟩
-        · intro x s
-          exact ⟨s, S, T, rfl, rfl⟩
+        · intro x s; exact ⟨s, S, T, rfl, rfl⟩
   · refine' ⟨nil, S, T, _, _⟩ <;> simp
 #align stream.seq.join_append Stream'.Seq.join_append
 -/
@@ -1088,11 +1049,9 @@ theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂)
   apply mem_rec_on h _
   intro b s' o s₁
   apply s₁.rec_on _ fun c t₁ => _ <;> intro m e <;> have := congr_arg destruct e
-  · apply Or.inr
-    simpa using m
+  · apply Or.inr; simpa using m
   · cases' show a = c ∨ a ∈ append t₁ s₂ by simpa using m with e' m
-    · rw [e']
-      exact Or.inl (mem_cons _ _)
+    · rw [e']; exact Or.inl (mem_cons _ _)
     · cases' show c = b ∧ append t₁ s₂ = s' by simpa with i1 i2
       cases' o with e' IH
       · simp [i1, e']
@@ -1232,17 +1191,15 @@ theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.m
     seq.eq_of_bisim fun s1 s2 =>
       ∃ s S,
         s1 = seq.append s (seq.map f (seq.join S)) ∧ s2 = append s (seq.join (seq.map (map f) S))
-  · intro s1 s2 h
+  · intro s1 s2 h;
     exact
       match s1, s2, h with
       | _, _, ⟨s, S, rfl, rfl⟩ => by
         apply rec_on s <;> simp
         · apply rec_on S <;> simp
-          · intro x S
-            cases' x with a s <;> simp [map]
+          · intro x S; cases' x with a s <;> simp [map]
             exact ⟨_, _, rfl, rfl⟩
-        · intro x s
-          refine' ⟨s, S, rfl, rfl⟩
+        · intro x s; refine' ⟨s, S, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
 #align stream.seq1.map_join' Stream'.Seq1.map_join'
 -/
@@ -1263,20 +1220,18 @@ theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
     seq.eq_of_bisim fun s1 s2 =>
       ∃ s SS,
         s1 = seq.append s (seq.join (seq.join SS)) ∧ s2 = seq.append s (seq.join (seq.map join SS))
-  · intro s1 s2 h
+  · intro s1 s2 h;
     exact
       match s1, s2, h with
       | _, _, ⟨s, SS, rfl, rfl⟩ => by
         apply rec_on s <;> simp
         · apply rec_on SS <;> simp
-          · intro S SS
-            cases' S with s S <;> cases' s with x s <;> simp [map]
+          · intro S SS; cases' S with s S <;> cases' s with x s <;> simp [map]
             apply rec_on s <;> simp
             · exact ⟨_, _, rfl, rfl⟩
             · intro x s
               refine' ⟨seq.cons x (append s (seq.join S)), SS, _, _⟩ <;> simp
-        · intro x s
-          exact ⟨s, SS, rfl, rfl⟩
+        · intro x s; exact ⟨s, SS, rfl, rfl⟩
   · refine' ⟨nil, SS, _, _⟩ <;> simp
 #align stream.seq1.join_join Stream'.Seq1.join_join
 -/
@@ -1294,8 +1249,7 @@ theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
   generalize seq.map (map g ∘ f) s = SS
   rcases map g (f a) with ⟨⟨a, s⟩, S⟩
   apply rec_on s <;> intros <;> apply rec_on S <;> intros <;> simp
-  · cases' x with x t
-    apply rec_on t <;> intros <;> simp
+  · cases' x with x t; apply rec_on t <;> intros <;> simp
   · cases' x_1 with y t <;> simp
 #align stream.seq1.bind_assoc Stream'.Seq1.bind_assoc
 -/
Diff
@@ -257,7 +257,7 @@ theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s →
 #print Stream'.Seq.mem_cons_iff /-
 @[simp]
 theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
-  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons, exact mem_cons_of_mem _ m]⟩
+  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons;exact mem_cons_of_mem _ m]⟩
 #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff
 -/
 
Diff
@@ -94,11 +94,11 @@ theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f :=
 #align stream.seq.nth_mk Stream'.Seq.get?_mk
 -/
 
-#print Stream'.Seq.nth_nil /-
+#print Stream'.Seq.get?_nil /-
 @[simp]
-theorem nth_nil (n : ℕ) : (@nil α).get? n = none :=
+theorem get?_nil (n : ℕ) : (@nil α).get? n = none :=
   rfl
-#align stream.seq.nth_nil Stream'.Seq.nth_nil
+#align stream.seq.nth_nil Stream'.Seq.get?_nil
 -/
 
 #print Stream'.Seq.get?_cons_zero /-
@@ -610,14 +610,12 @@ unsafe def toLazyList : Seq α → LazyList α
 #align stream.seq.to_lazy_list Stream'.Seq.toLazyList
 -/
 
-/- warning: stream.seq.force_to_list clashes with stream.seq.to_lazy_list -> Stream'.Seq.toLazyList
-Case conversion may be inaccurate. Consider using '#align stream.seq.force_to_list Stream'.Seq.toLazyListₓ'. -/
-#print Stream'.Seq.toLazyList /-
+#print Stream'.Seq.forceToList /-
 /-- Translate a sequence to a list. This function will run forever if
   run on an infinite sequence. -/
-unsafe def toLazyList (s : Seq α) : List α :=
+unsafe def forceToList (s : Seq α) : List α :=
   (toLazyList s).toList
-#align stream.seq.force_to_list Stream'.Seq.toLazyList
+#align stream.seq.force_to_list Stream'.Seq.forceToList
 -/
 
 #print Stream'.Seq.nats /-
@@ -627,11 +625,11 @@ def nats : Seq ℕ :=
 #align stream.seq.nats Stream'.Seq.nats
 -/
 
-#print Stream'.Seq.nats_nth /-
+#print Stream'.Seq.nats_get? /-
 @[simp]
-theorem nats_nth (n : ℕ) : nats.get? n = some n :=
+theorem nats_get? (n : ℕ) : nats.get? n = some n :=
   rfl
-#align stream.seq.nats_nth Stream'.Seq.nats_nth
+#align stream.seq.nats_nth Stream'.Seq.nats_get?
 -/
 
 #print Stream'.Seq.append /-
Diff
@@ -18,6 +18,7 @@ namespace Stream'
 
 universe u v w
 
+#print Stream'.IsSeq /-
 /-
 coinductive seq (α : Type u) : Type u
 | nil : seq α
@@ -28,32 +29,40 @@ coinductive seq (α : Type u) : Type u
 def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
   ∀ {n : ℕ}, s n = none → s (n + 1) = none
 #align stream.is_seq Stream'.IsSeq
+-/
 
+#print Stream'.Seq /-
 /-- `seq α` is the type of possibly infinite lists (referred here as sequences).
   It is encoded as an infinite stream of options such that if `f n = none`, then
   `f m = none` for all `m ≥ n`. -/
 def Seq (α : Type u) : Type u :=
   { f : Stream' (Option α) // f.IsSeq }
 #align stream.seq Stream'.Seq
+-/
 
+#print Stream'.Seq1 /-
 /-- `seq1 α` is the type of nonempty sequences. -/
 def Seq1 (α) :=
   α × Seq α
 #align stream.seq1 Stream'.Seq1
+-/
 
 namespace Seq
 
 variable {α : Type u} {β : Type v} {γ : Type w}
 
+#print Stream'.Seq.nil /-
 /-- The empty sequence -/
 def nil : Seq α :=
   ⟨Stream'.const none, fun n h => rfl⟩
 #align stream.seq.nil Stream'.Seq.nil
+-/
 
 instance : Inhabited (Seq α) :=
   ⟨nil⟩
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.Seq.cons /-
 /-- Prepend an element to a sequence -/
 def cons (a : α) (s : Seq α) : Seq α :=
   ⟨some a::s.1, by
@@ -61,114 +70,156 @@ def cons (a : α) (s : Seq α) : Seq α :=
     · contradiction
     · exact s.2 h⟩
 #align stream.seq.cons Stream'.Seq.cons
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.Seq.val_cons /-
 @[simp]
 theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val :=
   rfl
 #align stream.seq.val_cons Stream'.Seq.val_cons
+-/
 
+#print Stream'.Seq.get? /-
 /-- Get the nth element of a sequence (if it exists) -/
-def nth : Seq α → ℕ → Option α :=
+def get? : Seq α → ℕ → Option α :=
   Subtype.val
-#align stream.seq.nth Stream'.Seq.nth
+#align stream.seq.nth Stream'.Seq.get?
+-/
 
+#print Stream'.Seq.get?_mk /-
 @[simp]
-theorem nth_mk (f hf) : @nth α ⟨f, hf⟩ = f :=
+theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f :=
   rfl
-#align stream.seq.nth_mk Stream'.Seq.nth_mk
+#align stream.seq.nth_mk Stream'.Seq.get?_mk
+-/
 
+#print Stream'.Seq.nth_nil /-
 @[simp]
 theorem nth_nil (n : ℕ) : (@nil α).get? n = none :=
   rfl
 #align stream.seq.nth_nil Stream'.Seq.nth_nil
+-/
 
+#print Stream'.Seq.get?_cons_zero /-
 @[simp]
-theorem nth_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
+theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
   rfl
-#align stream.seq.nth_cons_zero Stream'.Seq.nth_cons_zero
+#align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero
+-/
 
+#print Stream'.Seq.get?_cons_succ /-
 @[simp]
-theorem nth_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
+theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
   rfl
-#align stream.seq.nth_cons_succ Stream'.Seq.nth_cons_succ
+#align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ
+-/
 
+#print Stream'.Seq.ext /-
 @[ext]
 protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t :=
   Subtype.eq <| funext h
 #align stream.seq.ext Stream'.Seq.ext
+-/
 
+#print Stream'.Seq.cons_injective2 /-
 theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h =>
   ⟨by rw [← Option.some_inj, ← nth_cons_zero, h, nth_cons_zero],
     Seq.ext fun n => by simp_rw [← nth_cons_succ x s n, h, nth_cons_succ]⟩
 #align stream.seq.cons_injective2 Stream'.Seq.cons_injective2
+-/
 
+#print Stream'.Seq.cons_left_injective /-
 theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s :=
   cons_injective2.left _
 #align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective
+-/
 
+#print Stream'.Seq.cons_right_injective /-
 theorem cons_right_injective (x : α) : Function.Injective (cons x) :=
   cons_injective2.right _
 #align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective
+-/
 
+#print Stream'.Seq.TerminatedAt /-
 /-- A sequence has terminated at position `n` if the value at position `n` equals `none`. -/
 def TerminatedAt (s : Seq α) (n : ℕ) : Prop :=
   s.get? n = none
 #align stream.seq.terminated_at Stream'.Seq.TerminatedAt
+-/
 
+#print Stream'.Seq.terminatedAtDecidable /-
 /-- It is decidable whether a sequence terminates at a given position. -/
 instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
   decidable_of_iff' (s.get? n).isNone <| by unfold terminated_at <;> cases s.nth n <;> simp
 #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable
+-/
 
+#print Stream'.Seq.Terminates /-
 /-- A sequence terminates if there is some position `n` at which it has terminated. -/
 def Terminates (s : Seq α) : Prop :=
   ∃ n : ℕ, s.TerminatedAt n
 #align stream.seq.terminates Stream'.Seq.Terminates
+-/
 
+#print Stream'.Seq.not_terminates_iff /-
 theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by
   simp [terminates, terminated_at, ← Ne.def, Option.ne_none_iff_isSome]
 #align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff
+-/
 
+#print Stream'.Seq.omap /-
 /-- Functorial action of the functor `option (α × _)` -/
 @[simp]
 def omap (f : β → γ) : Option (α × β) → Option (α × γ)
   | none => none
   | some (a, b) => some (a, f b)
 #align stream.seq.omap Stream'.Seq.omap
+-/
 
+#print Stream'.Seq.head /-
 /-- Get the first element of a sequence -/
 def head (s : Seq α) : Option α :=
-  nth s 0
+  get? s 0
 #align stream.seq.head Stream'.Seq.head
+-/
 
+#print Stream'.Seq.tail /-
 /-- Get the tail of a sequence (or `nil` if the sequence is `nil`) -/
 def tail (s : Seq α) : Seq α :=
   ⟨s.1.tail, fun n => by
     cases' s with f al
     exact al⟩
 #align stream.seq.tail Stream'.Seq.tail
+-/
 
+#print Stream'.Seq.Mem /-
 /-- member definition for `seq`-/
 protected def Mem (a : α) (s : Seq α) :=
   some a ∈ s.1
 #align stream.seq.mem Stream'.Seq.Mem
+-/
 
 instance : Membership α (Seq α) :=
   ⟨Seq.Mem⟩
 
+#print Stream'.Seq.le_stable /-
 theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none :=
   by
   cases' s with f al
   induction' h with n h IH
   exacts[id, fun h2 => al (IH h2)]
 #align stream.seq.le_stable Stream'.Seq.le_stable
+-/
 
+#print Stream'.Seq.terminated_stable /-
 /-- If a sequence terminated at position `n`, it also terminated at `m ≥ n `. -/
 theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n :=
   le_stable
 #align stream.seq.terminated_stable Stream'.Seq.terminated_stable
+-/
 
+#print Stream'.Seq.ge_stable /-
 /-- If `s.nth n = some aₙ` for some value `aₙ`, then there is also some value `aₘ` such
 that `s.nth = some aₘ` for `m ≤ n`.
 -/
@@ -178,33 +229,47 @@ theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n)
   have : s.get? m ≠ none := mt (s.le_stable m_le_n) this
   Option.ne_none_iff_exists'.mp this
 #align stream.seq.ge_stable Stream'.Seq.ge_stable
+-/
 
+#print Stream'.Seq.not_mem_nil /-
 theorem not_mem_nil (a : α) : a ∉ @nil α := fun ⟨n, (h : some a = none)⟩ => by injection h
 #align stream.seq.not_mem_nil Stream'.Seq.not_mem_nil
+-/
 
+#print Stream'.Seq.mem_cons /-
 theorem mem_cons (a : α) : ∀ s : Seq α, a ∈ cons a s
   | ⟨f, al⟩ => Stream'.mem_cons (some a) _
 #align stream.seq.mem_cons Stream'.Seq.mem_cons
+-/
 
+#print Stream'.Seq.mem_cons_of_mem /-
 theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : Seq α}, a ∈ s → a ∈ cons y s
   | ⟨f, al⟩ => Stream'.mem_cons_of_mem (some y)
 #align stream.seq.mem_cons_of_mem Stream'.Seq.mem_cons_of_mem
+-/
 
+#print Stream'.Seq.eq_or_mem_of_mem_cons /-
 theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s → a = b ∨ a ∈ s
   | ⟨f, al⟩, h => (Stream'.eq_or_mem_of_mem_cons h).imp_left fun h => by injection h
 #align stream.seq.eq_or_mem_of_mem_cons Stream'.Seq.eq_or_mem_of_mem_cons
+-/
 
+#print Stream'.Seq.mem_cons_iff /-
 @[simp]
 theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
   ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons, exact mem_cons_of_mem _ m]⟩
 #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff
+-/
 
+#print Stream'.Seq.destruct /-
 /-- Destructor for a sequence, resulting in either `none` (for `nil`) or
   `some (a, s)` (for `cons a s`). -/
 def destruct (s : Seq α) : Option (Seq1 α) :=
-  (fun a' => (a', s.tail)) <$> nth s 0
+  (fun a' => (a', s.tail)) <$> get? s 0
 #align stream.seq.destruct Stream'.Seq.destruct
+-/
 
+#print Stream'.Seq.destruct_eq_nil /-
 theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil :=
   by
   dsimp [destruct]
@@ -215,7 +280,9 @@ theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil :=
     exacts[f0, s.2 IH]
   · contradiction
 #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
+-/
 
+#print Stream'.Seq.destruct_eq_cons /-
 theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s = cons a s' :=
   by
   dsimp [destruct]
@@ -230,12 +297,16 @@ theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s =
     rw [← f0]
     exact (Stream'.eta f).symm
 #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons
+-/
 
+#print Stream'.Seq.destruct_nil /-
 @[simp]
 theorem destruct_nil : destruct (nil : Seq α) = none :=
   rfl
 #align stream.seq.destruct_nil Stream'.Seq.destruct_nil
+-/
 
+#print Stream'.Seq.destruct_cons /-
 @[simp]
 theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
   | ⟨f, al⟩ => by
@@ -243,36 +314,54 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
     apply congr_arg fun s => some (a, s)
     apply Subtype.eq; dsimp [tail]; rw [Stream'.tail_cons]
 #align stream.seq.destruct_cons Stream'.Seq.destruct_cons
+-/
 
+/- warning: stream.seq.head_eq_destruct -> Stream'.Seq.head_eq_destruct is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} (s : Stream'.Seq.{u1} α), Eq.{succ u1} (Option.{u1} α) (Stream'.Seq.head.{u1} α s) (Functor.map.{u1, u1} Option.{u1} (Traversable.toFunctor.{u1} Option.{u1} Option.traversable.{u1}) (Prod.{u1, u1} α (Stream'.Seq.{u1} α)) α (Prod.fst.{u1, u1} α (Stream'.Seq.{u1} α)) (Stream'.Seq.destruct.{u1} α s))
+but is expected to have type
+  forall {α : Type.{u1}} (s : Stream'.Seq.{u1} α), Eq.{succ u1} (Option.{u1} α) (Stream'.Seq.head.{u1} α s) (Functor.map.{u1, u1} Option.{u1} instFunctorOption.{u1} (Prod.{u1, u1} α (Stream'.Seq.{u1} α)) α (Prod.fst.{u1, u1} α (Stream'.Seq.{u1} α)) (Stream'.Seq.destruct.{u1} α s))
+Case conversion may be inaccurate. Consider using '#align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destructₓ'. -/
 theorem head_eq_destruct (s : Seq α) : head s = Prod.fst <$> destruct s := by
   unfold destruct head <;> cases nth s 0 <;> rfl
 #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
 
+#print Stream'.Seq.head_nil /-
 @[simp]
 theorem head_nil : head (nil : Seq α) = none :=
   rfl
 #align stream.seq.head_nil Stream'.Seq.head_nil
+-/
 
+#print Stream'.Seq.head_cons /-
 @[simp]
 theorem head_cons (a : α) (s) : head (cons a s) = some a := by
   rw [head_eq_destruct, destruct_cons] <;> rfl
 #align stream.seq.head_cons Stream'.Seq.head_cons
+-/
 
+#print Stream'.Seq.tail_nil /-
 @[simp]
 theorem tail_nil : tail (nil : Seq α) = nil :=
   rfl
 #align stream.seq.tail_nil Stream'.Seq.tail_nil
+-/
 
+#print Stream'.Seq.tail_cons /-
 @[simp]
 theorem tail_cons (a : α) (s) : tail (cons a s) = s := by
   cases' s with f al <;> apply Subtype.eq <;> dsimp [tail, cons] <;> rw [Stream'.tail_cons]
 #align stream.seq.tail_cons Stream'.Seq.tail_cons
+-/
 
+#print Stream'.Seq.get?_tail /-
 @[simp]
-theorem nth_tail (s : Seq α) (n) : nth (tail s) n = nth s (n + 1) :=
+theorem get?_tail (s : Seq α) (n) : get? (tail s) n = get? s (n + 1) :=
   rfl
-#align stream.seq.nth_tail Stream'.Seq.nth_tail
+#align stream.seq.nth_tail Stream'.Seq.get?_tail
+-/
 
+#print Stream'.Seq.recOn /-
 /-- Recursion principle for sequences, compare with `list.rec_on`. -/
 def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s :=
   by
@@ -283,7 +372,9 @@ def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (co
     rw [destruct_eq_cons H]
     apply h2
 #align stream.seq.rec_on Stream'.Seq.recOn
+-/
 
+#print Stream'.Seq.mem_rec_on /-
 theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s :=
   by
@@ -302,7 +393,9 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     rw [h_eq] at e
     apply h1 _ _ (Or.inr (IH e))
 #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on
+-/
 
+#print Stream'.Seq.Corec.f /-
 /-- Corecursor over pairs of `option` values-/
 def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option β
   | none => (none, none)
@@ -311,7 +404,9 @@ def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option 
     | none => (none, none)
     | some (a, b') => (some a, some b')
 #align stream.seq.corec.F Stream'.Seq.Corec.f
+-/
 
+#print Stream'.Seq.corec /-
 /-- Corecursor for `seq α` as a coinductive type. Iterates `f` to produce new elements
   of the sequence until `none` is obtained. -/
 def corec (f : β → Option (α × β)) (b : β) : Seq α :=
@@ -333,7 +428,9 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α :=
   · rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
     exact IH (corec.F f o).2
 #align stream.seq.corec Stream'.Seq.corec
+-/
 
+#print Stream'.Seq.corec_eq /-
 @[simp]
 theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b) = omap (corec f) (f b) :=
   by
@@ -348,6 +445,7 @@ theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b)
   rw [Stream'.corec'_eq, Stream'.tail_cons]
   dsimp [corec.F]; rw [h]; rfl
 #align stream.seq.corec_eq Stream'.Seq.corec_eq
+-/
 
 section Bisim
 
@@ -356,20 +454,25 @@ variable (R : Seq α → Seq α → Prop)
 -- mathport name: R
 local infixl:50 " ~ " => R
 
+#print Stream'.Seq.BisimO /-
 /-- Bisimilarity relation over `option` of `seq1 α`-/
 def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop
   | none, none => True
   | some (a, s), some (a', s') => a = a' ∧ R s s'
   | _, _ => False
 #align stream.seq.bisim_o Stream'.Seq.BisimO
+-/
 
 attribute [simp] bisim_o
 
+#print Stream'.Seq.IsBisimulation /-
 /-- a relation is bisimiar if it meets the `bisim_o` test-/
 def IsBisimulation :=
   ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂)
 #align stream.seq.is_bisimulation Stream'.Seq.IsBisimulation
+-/
 
+#print Stream'.Seq.eq_of_bisim /-
 -- If two streams are bisimilar, then they are equal
 theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ :=
   by
@@ -400,9 +503,11 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
         exact h2
   exact ⟨s₁, s₂, rfl, rfl, r⟩
 #align stream.seq.eq_of_bisim Stream'.Seq.eq_of_bisim
+-/
 
 end Bisim
 
+#print Stream'.Seq.coinduction /-
 theorem coinduction :
     ∀ {s₁ s₂ : Seq α},
       head s₁ = head s₂ →
@@ -410,7 +515,9 @@ theorem coinduction :
   | ⟨f₁, a₁⟩, ⟨f₂, a₂⟩, hh, ht =>
     Subtype.eq (Stream'.coinduction hh fun β fr => ht β fun s => fr s.1)
 #align stream.seq.coinduction Stream'.Seq.coinduction
+-/
 
+#print Stream'.Seq.coinduction2 /-
 theorem coinduction2 (s) (f g : Seq α → Seq β)
     (H :
       ∀ s,
@@ -422,43 +529,59 @@ theorem coinduction2 (s) (f g : Seq α → Seq β)
   intro s1 s2 h; rcases h with ⟨s, h1, h2⟩
   rw [h1, h2]; apply H
 #align stream.seq.coinduction2 Stream'.Seq.coinduction2
+-/
 
+#print Stream'.Seq.ofList /-
 /-- Embed a list as a sequence -/
 def ofList (l : List α) : Seq α :=
   ⟨List.get? l, fun n h => by
     rw [List.get?_eq_none] at h⊢
     exact h.trans (Nat.le_succ n)⟩
 #align stream.seq.of_list Stream'.Seq.ofList
+-/
 
+#print Stream'.Seq.coeList /-
 instance coeList : Coe (List α) (Seq α) :=
   ⟨ofList⟩
 #align stream.seq.coe_list Stream'.Seq.coeList
+-/
 
+#print Stream'.Seq.ofList_nil /-
 @[simp]
 theorem ofList_nil : ofList [] = (nil : Seq α) :=
   rfl
 #align stream.seq.of_list_nil Stream'.Seq.ofList_nil
+-/
 
+#print Stream'.Seq.ofList_nth /-
 @[simp]
 theorem ofList_nth (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
   rfl
 #align stream.seq.of_list_nth Stream'.Seq.ofList_nth
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.Seq.ofList_cons /-
 @[simp]
 theorem ofList_cons (a : α) (l : List α) : ofList (a::l) = cons a (ofList l) := by
   ext1 (_ | n) <;> rfl
 #align stream.seq.of_list_cons Stream'.Seq.ofList_cons
+-/
 
+#print Stream'.Seq.ofStream /-
 /-- Embed an infinite stream as a sequence -/
 def ofStream (s : Stream' α) : Seq α :=
   ⟨s.map some, fun n h => by contradiction⟩
 #align stream.seq.of_stream Stream'.Seq.ofStream
+-/
 
+#print Stream'.Seq.coeStream /-
 instance coeStream : Coe (Stream' α) (Seq α) :=
   ⟨ofStream⟩
 #align stream.seq.coe_stream Stream'.Seq.coeStream
+-/
 
+#print Stream'.Seq.ofLazyList /-
 /-- Embed a `lazy_list α` as a sequence. Note that even though this
   is non-meta, it will produce infinite sequences if used with
   cyclic `lazy_list`s created by meta constructions. -/
@@ -468,36 +591,50 @@ def ofLazyList : LazyList α → Seq α :=
     | LazyList.nil => none
     | LazyList.cons a l' => some (a, l' ())
 #align stream.seq.of_lazy_list Stream'.Seq.ofLazyList
+-/
 
+#print Stream'.Seq.coeLazyList /-
 instance coeLazyList : Coe (LazyList α) (Seq α) :=
   ⟨ofLazyList⟩
 #align stream.seq.coe_lazy_list Stream'.Seq.coeLazyList
+-/
 
+#print Stream'.Seq.toLazyList /-
 /-- Translate a sequence into a `lazy_list`. Since `lazy_list` and `list`
   are isomorphic as non-meta types, this function is necessarily meta. -/
-unsafe def to_lazy_list : Seq α → LazyList α
+unsafe def toLazyList : Seq α → LazyList α
   | s =>
     match destruct s with
     | none => LazyList.nil
     | some (a, s') => LazyList.cons a (to_lazy_list s')
-#align stream.seq.to_lazy_list stream.seq.to_lazy_list
+#align stream.seq.to_lazy_list Stream'.Seq.toLazyList
+-/
 
+/- warning: stream.seq.force_to_list clashes with stream.seq.to_lazy_list -> Stream'.Seq.toLazyList
+Case conversion may be inaccurate. Consider using '#align stream.seq.force_to_list Stream'.Seq.toLazyListₓ'. -/
+#print Stream'.Seq.toLazyList /-
 /-- Translate a sequence to a list. This function will run forever if
   run on an infinite sequence. -/
-unsafe def force_to_list (s : Seq α) : List α :=
-  (to_lazy_list s).toList
-#align stream.seq.force_to_list stream.seq.force_to_list
+unsafe def toLazyList (s : Seq α) : List α :=
+  (toLazyList s).toList
+#align stream.seq.force_to_list Stream'.Seq.toLazyList
+-/
 
+#print Stream'.Seq.nats /-
 /-- The sequence of natural numbers some 0, some 1, ... -/
 def nats : Seq ℕ :=
   Stream'.nats
 #align stream.seq.nats Stream'.Seq.nats
+-/
 
+#print Stream'.Seq.nats_nth /-
 @[simp]
 theorem nats_nth (n : ℕ) : nats.get? n = some n :=
   rfl
 #align stream.seq.nats_nth Stream'.Seq.nats_nth
+-/
 
+#print Stream'.Seq.append /-
 /-- Append two sequences. If `s₁` is infinite, then `s₁ ++ s₂ = s₁`,
   otherwise it puts `s₂` at the location of the `nil` in `s₁`. -/
 def append (s₁ s₂ : Seq α) : Seq α :=
@@ -508,7 +645,9 @@ def append (s₁ s₂ : Seq α) : Seq α :=
       | some (a, s₁') => some (a, s₁', s₂))
     (s₁, s₂)
 #align stream.seq.append Stream'.Seq.append
+-/
 
+#print Stream'.Seq.map /-
 /-- Map a function over a sequence. -/
 def map (f : α → β) : Seq α → Seq β
   | ⟨s, al⟩ =>
@@ -519,7 +658,9 @@ def map (f : α → β) : Seq α → Seq β
       · rw [al e]
         assumption; · contradiction⟩
 #align stream.seq.map Stream'.Seq.map
+-/
 
+#print Stream'.Seq.join /-
 /-- Flatten a sequence of sequences. (It is required that the
   sequences be nonempty to ensure productivity; in the case
   of an infinite sequence of `nil`, the first element is never
@@ -535,15 +676,19 @@ def join : Seq (Seq1 α) → Seq α :=
           | none => S'
           | some s' => cons s' S')
 #align stream.seq.join Stream'.Seq.join
+-/
 
+#print Stream'.Seq.drop /-
 /-- Remove the first `n` elements from the sequence. -/
 def drop (s : Seq α) : ℕ → Seq α
   | 0 => s
   | n + 1 => tail (drop n)
 #align stream.seq.drop Stream'.Seq.drop
+-/
 
 attribute [simp] drop
 
+#print Stream'.Seq.take /-
 /-- Take the first `n` elements of the sequence (producing a list) -/
 def take : ℕ → Seq α → List α
   | 0, s => []
@@ -552,7 +697,9 @@ def take : ℕ → Seq α → List α
     | none => []
     | some (x, r) => List.cons x (take n r)
 #align stream.seq.take Stream'.Seq.take
+-/
 
+#print Stream'.Seq.splitAt /-
 /-- Split a sequence at `n`, producing a finite initial segment
   and an infinite tail. -/
 def splitAt : ℕ → Seq α → List α × Seq α
@@ -564,72 +711,96 @@ def splitAt : ℕ → Seq α → List α × Seq α
       let (l, r) := split_at n s'
       (List.cons x l, r)
 #align stream.seq.split_at Stream'.Seq.splitAt
+-/
 
 section ZipWith
 
+#print Stream'.Seq.zipWith /-
 /-- Combine two sequences with a function -/
 def zipWith (f : α → β → γ) (s₁ : Seq α) (s₂ : Seq β) : Seq γ :=
   ⟨fun n => Option.map₂ f (s₁.get? n) (s₂.get? n), fun n hn =>
     Option.map₂_eq_none_iff.2 <| (Option.map₂_eq_none_iff.1 hn).imp s₁.2 s₂.2⟩
 #align stream.seq.zip_with Stream'.Seq.zipWith
+-/
 
 variable {s : Seq α} {s' : Seq β} {n : ℕ}
 
+#print Stream'.Seq.get?_zipWith /-
 @[simp]
-theorem nth_zipWith (f : α → β → γ) (s s' n) :
+theorem get?_zipWith (f : α → β → γ) (s s' n) :
     (zipWith f s s').get? n = Option.map₂ f (s.get? n) (s'.get? n) :=
   rfl
-#align stream.seq.nth_zip_with Stream'.Seq.nth_zipWith
+#align stream.seq.nth_zip_with Stream'.Seq.get?_zipWith
+-/
 
 end ZipWith
 
+#print Stream'.Seq.zip /-
 /-- Pair two sequences into a sequence of pairs -/
 def zip : Seq α → Seq β → Seq (α × β) :=
   zipWith Prod.mk
 #align stream.seq.zip Stream'.Seq.zip
+-/
 
-theorem nth_zip (s : Seq α) (t : Seq β) (n : ℕ) :
-    nth (zip s t) n = Option.map₂ Prod.mk (nth s n) (nth t n) :=
-  nth_zipWith _ _ _ _
-#align stream.seq.nth_zip Stream'.Seq.nth_zip
+#print Stream'.Seq.get?_zip /-
+theorem get?_zip (s : Seq α) (t : Seq β) (n : ℕ) :
+    get? (zip s t) n = Option.map₂ Prod.mk (get? s n) (get? t n) :=
+  get?_zipWith _ _ _ _
+#align stream.seq.nth_zip Stream'.Seq.get?_zip
+-/
 
+#print Stream'.Seq.unzip /-
 /-- Separate a sequence of pairs into two sequences -/
 def unzip (s : Seq (α × β)) : Seq α × Seq β :=
   (map Prod.fst s, map Prod.snd s)
 #align stream.seq.unzip Stream'.Seq.unzip
+-/
 
+#print Stream'.Seq.enum /-
 /-- Enumerate a sequence by tagging each element with its index. -/
 def enum (s : Seq α) : Seq (ℕ × α) :=
   Seq.zip nats s
 #align stream.seq.enum Stream'.Seq.enum
+-/
 
+#print Stream'.Seq.get?_enum /-
 @[simp]
-theorem nth_enum (s : Seq α) (n : ℕ) : nth (enum s) n = Option.map (Prod.mk n) (nth s n) :=
-  nth_zip _ _ _
-#align stream.seq.nth_enum Stream'.Seq.nth_enum
+theorem get?_enum (s : Seq α) (n : ℕ) : get? (enum s) n = Option.map (Prod.mk n) (get? s n) :=
+  get?_zip _ _ _
+#align stream.seq.nth_enum Stream'.Seq.get?_enum
+-/
 
+#print Stream'.Seq.enum_nil /-
 @[simp]
 theorem enum_nil : enum (nil : Seq α) = nil :=
   rfl
 #align stream.seq.enum_nil Stream'.Seq.enum_nil
+-/
 
+#print Stream'.Seq.toList /-
 /-- Convert a sequence which is known to terminate into a list -/
 def toList (s : Seq α) (h : s.Terminates) : List α :=
   take (Nat.find h) s
 #align stream.seq.to_list Stream'.Seq.toList
+-/
 
+#print Stream'.Seq.toStream /-
 /-- Convert a sequence which is known not to terminate into a stream -/
 def toStream (s : Seq α) (h : ¬s.Terminates) : Stream' α := fun n =>
   Option.get <| not_terminates_iff.1 h n
 #align stream.seq.to_stream Stream'.Seq.toStream
+-/
 
+#print Stream'.Seq.toListOrStream /-
 /-- Convert a sequence into either a list or a stream depending on whether
   it is finite or infinite. (Without decidability of the infiniteness predicate,
   this is not constructively possible.) -/
 def toListOrStream (s : Seq α) [Decidable s.Terminates] : Sum (List α) (Stream' α) :=
   if h : s.Terminates then Sum.inl (toList s h) else Sum.inr (toStream s h)
 #align stream.seq.to_list_or_stream Stream'.Seq.toListOrStream
+-/
 
+#print Stream'.Seq.nil_append /-
 @[simp]
 theorem nil_append (s : Seq α) : append nil s = s :=
   by
@@ -642,7 +813,9 @@ theorem nil_append (s : Seq α) : append nil s = s :=
     dsimp
     exact ⟨rfl, s, rfl, rfl⟩
 #align stream.seq.nil_append Stream'.Seq.nil_append
+-/
 
+#print Stream'.Seq.cons_append /-
 @[simp]
 theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :=
   destruct_eq_cons <| by
@@ -650,7 +823,9 @@ theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :
     dsimp [append]; rw [destruct_cons]
     dsimp [append]; rfl
 #align stream.seq.cons_append Stream'.Seq.cons_append
+-/
 
+#print Stream'.Seq.append_nil /-
 @[simp]
 theorem append_nil (s : Seq α) : append s nil = s :=
   by
@@ -662,7 +837,9 @@ theorem append_nil (s : Seq α) : append s nil = s :=
     dsimp
     exact ⟨rfl, s, rfl, rfl⟩
 #align stream.seq.append_nil Stream'.Seq.append_nil
+-/
 
+#print Stream'.Seq.append_assoc /-
 @[simp]
 theorem append_assoc (s t u : Seq α) : append (append s t) u = append s (append t u) :=
   by
@@ -682,29 +859,39 @@ theorem append_assoc (s t u : Seq α) : append (append s t) u = append s (append
           exact ⟨s, t, u, rfl, rfl⟩
   · exact ⟨s, t, u, rfl, rfl⟩
 #align stream.seq.append_assoc Stream'.Seq.append_assoc
+-/
 
+#print Stream'.Seq.map_nil /-
 @[simp]
 theorem map_nil (f : α → β) : map f nil = nil :=
   rfl
 #align stream.seq.map_nil Stream'.Seq.map_nil
+-/
 
+#print Stream'.Seq.map_cons /-
 @[simp]
 theorem map_cons (f : α → β) (a) : ∀ s, map f (cons a s) = cons (f a) (map f s)
   | ⟨s, al⟩ => by apply Subtype.eq <;> dsimp [cons, map] <;> rw [Stream'.map_cons] <;> rfl
 #align stream.seq.map_cons Stream'.Seq.map_cons
+-/
 
+#print Stream'.Seq.map_id /-
 @[simp]
 theorem map_id : ∀ s : Seq α, map id s = s
   | ⟨s, al⟩ => by
     apply Subtype.eq <;> dsimp [map]
     rw [Option.map_id, Stream'.map_id] <;> rfl
 #align stream.seq.map_id Stream'.Seq.map_id
+-/
 
+#print Stream'.Seq.map_tail /-
 @[simp]
 theorem map_tail (f : α → β) : ∀ s, map f (tail s) = tail (map f s)
   | ⟨s, al⟩ => by apply Subtype.eq <;> dsimp [tail, map] <;> rw [Stream'.map_tail] <;> rfl
 #align stream.seq.map_tail Stream'.Seq.map_tail
+-/
 
+#print Stream'.Seq.map_comp /-
 theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Seq α, map (g ∘ f) s = map g (map f s)
   | ⟨s, al⟩ => by
     apply Subtype.eq <;> dsimp [map]
@@ -712,7 +899,9 @@ theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Seq α, map (g ∘ f)
     apply congr_arg fun f : _ → Option γ => Stream'.map f s
     ext ⟨⟩ <;> rfl
 #align stream.seq.map_comp Stream'.Seq.map_comp
+-/
 
+#print Stream'.Seq.map_append /-
 @[simp]
 theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s) (map f t) :=
   by
@@ -730,11 +919,14 @@ theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s)
       · intro x s
         refine' ⟨s, t, rfl, rfl⟩
 #align stream.seq.map_append Stream'.Seq.map_append
+-/
 
+#print Stream'.Seq.map_get? /-
 @[simp]
-theorem map_nth (f : α → β) : ∀ s n, nth (map f s) n = (nth s n).map f
+theorem map_get? (f : α → β) : ∀ s n, get? (map f s) n = (get? s n).map f
   | ⟨s, al⟩, n => rfl
-#align stream.seq.map_nth Stream'.Seq.map_nth
+#align stream.seq.map_nth Stream'.Seq.map_get?
+-/
 
 instance : Functor Seq where map := @map
 
@@ -742,22 +934,29 @@ instance : LawfulFunctor Seq where
   id_map := @map_id
   comp_map := @map_comp
 
+#print Stream'.Seq.join_nil /-
 @[simp]
 theorem join_nil : join nil = (nil : Seq α) :=
   destruct_eq_nil rfl
 #align stream.seq.join_nil Stream'.Seq.join_nil
+-/
 
+#print Stream'.Seq.join_cons_nil /-
 @[simp]
 theorem join_cons_nil (a : α) (S) : join (cons (a, nil) S) = cons a (join S) :=
   destruct_eq_cons <| by simp [join]
 #align stream.seq.join_cons_nil Stream'.Seq.join_cons_nil
+-/
 
+#print Stream'.Seq.join_cons_cons /-
 @[simp]
 theorem join_cons_cons (a b : α) (s S) :
     join (cons (a, cons b s) S) = cons a (join (cons (b, s) S)) :=
   destruct_eq_cons <| by simp [join]
 #align stream.seq.join_cons_cons Stream'.Seq.join_cons_cons
+-/
 
+#print Stream'.Seq.join_cons /-
 @[simp]
 theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join S)) :=
   by
@@ -780,7 +979,9 @@ theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join
         simp
         refine' Or.inr ⟨x, s, S, rfl, rfl⟩
 #align stream.seq.join_cons Stream'.Seq.join_cons
+-/
 
+#print Stream'.Seq.join_append /-
 @[simp]
 theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S) (join T) :=
   by
@@ -805,25 +1006,33 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
           exact ⟨s, S, T, rfl, rfl⟩
   · refine' ⟨nil, S, T, _, _⟩ <;> simp
 #align stream.seq.join_append Stream'.Seq.join_append
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.Seq.ofStream_cons /-
 @[simp]
 theorem ofStream_cons (a : α) (s) : ofStream (a::s) = cons a (ofStream s) := by
   apply Subtype.eq <;> simp [of_stream, cons] <;> rw [Stream'.map_cons]
 #align stream.seq.of_stream_cons Stream'.Seq.ofStream_cons
+-/
 
+#print Stream'.Seq.ofList_append /-
 @[simp]
 theorem ofList_append (l l' : List α) : ofList (l ++ l') = append (ofList l) (ofList l') := by
   induction l <;> simp [*]
 #align stream.seq.of_list_append Stream'.Seq.ofList_append
+-/
 
+#print Stream'.Seq.ofStream_append /-
 @[simp]
 theorem ofStream_append (l : List α) (s : Stream' α) :
     ofStream (l ++ₛ s) = append (ofList l) (ofStream s) := by
   induction l <;> simp [*, Stream'.nil_append_stream, Stream'.cons_append_stream]
 #align stream.seq.of_stream_append Stream'.Seq.ofStream_append
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.Seq.toList' /-
 /-- Convert a sequence into a list, embedded in a computation to allow for
   the possibility of infinite sequences (in which case the computation
   never returns anything). -/
@@ -835,33 +1044,45 @@ def toList' {α} (s : Seq α) : Computation (List α) :=
       | some (a, s') => Sum.inr (a::l, s'))
     ([], s)
 #align stream.seq.to_list' Stream'.Seq.toList'
+-/
 
+#print Stream'.Seq.dropn_add /-
 theorem dropn_add (s : Seq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
   | 0 => rfl
   | n + 1 => congr_arg tail (dropn_add n)
 #align stream.seq.dropn_add Stream'.Seq.dropn_add
+-/
 
+#print Stream'.Seq.dropn_tail /-
 theorem dropn_tail (s : Seq α) (n) : drop (tail s) n = drop s (n + 1) := by
   rw [add_comm] <;> symm <;> apply dropn_add
 #align stream.seq.dropn_tail Stream'.Seq.dropn_tail
+-/
 
+#print Stream'.Seq.head_dropn /-
 @[simp]
-theorem head_dropn (s : Seq α) (n) : head (drop s n) = nth s n :=
+theorem head_dropn (s : Seq α) (n) : head (drop s n) = get? s n :=
   by
   induction' n with n IH generalizing s; · rfl
   rw [Nat.succ_eq_add_one, ← nth_tail, ← dropn_tail]; apply IH
 #align stream.seq.head_dropn Stream'.Seq.head_dropn
+-/
 
+#print Stream'.Seq.mem_map /-
 theorem mem_map (f : α → β) {a : α} : ∀ {s : Seq α}, a ∈ s → f a ∈ map f s
   | ⟨g, al⟩ => Stream'.mem_map (Option.map f)
 #align stream.seq.mem_map Stream'.Seq.mem_map
+-/
 
+#print Stream'.Seq.exists_of_mem_map /-
 theorem exists_of_mem_map {f} {b : β} : ∀ {s : Seq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
   | ⟨g, al⟩, h => by
     let ⟨o, om, oe⟩ := Stream'.exists_of_mem_map h
     cases' o with a <;> injection oe with h' <;> exact ⟨a, om, h'⟩
 #align stream.seq.exists_of_mem_map Stream'.Seq.exists_of_mem_map
+-/
 
+#print Stream'.Seq.of_mem_append /-
 theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂) : a ∈ s₁ ∨ a ∈ s₂ :=
   by
   have := h; revert this
@@ -879,11 +1100,15 @@ theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂)
       · simp [i1, e']
       · exact Or.imp_left (mem_cons_of_mem _) (IH m i2)
 #align stream.seq.of_mem_append Stream'.Seq.of_mem_append
+-/
 
+#print Stream'.Seq.mem_append_left /-
 theorem mem_append_left {s₁ s₂ : Seq α} {a : α} (h : a ∈ s₁) : a ∈ append s₁ s₂ := by
   apply mem_rec_on h <;> intros <;> simp [*]
 #align stream.seq.mem_append_left Stream'.Seq.mem_append_left
+-/
 
+#print Stream'.Seq.enum_cons /-
 @[simp]
 theorem enum_cons (s : Seq α) (x : α) :
     enum (cons x s) = cons (0, x) (map (Prod.map Nat.succ id) (enum s)) :=
@@ -893,6 +1118,7 @@ theorem enum_cons (s : Seq α) (x : α) :
   · simp only [nth_enum, nth_cons_succ, map_nth, Option.map_map]
     congr
 #align stream.seq.enum_cons Stream'.Seq.enum_cons
+-/
 
 end Seq
 
@@ -902,24 +1128,33 @@ variable {α : Type u} {β : Type v} {γ : Type w}
 
 open Stream'.Seq
 
+#print Stream'.Seq1.toSeq /-
 /-- Convert a `seq1` to a sequence. -/
 def toSeq : Seq1 α → Seq α
   | (a, s) => Seq.cons a s
 #align stream.seq1.to_seq Stream'.Seq1.toSeq
+-/
 
+#print Stream'.Seq1.coeSeq /-
 instance coeSeq : Coe (Seq1 α) (Seq α) :=
   ⟨toSeq⟩
 #align stream.seq1.coe_seq Stream'.Seq1.coeSeq
+-/
 
+#print Stream'.Seq1.map /-
 /-- Map a function on a `seq1` -/
 def map (f : α → β) : Seq1 α → Seq1 β
   | (a, s) => (f a, Seq.map f s)
 #align stream.seq1.map Stream'.Seq1.map
+-/
 
+#print Stream'.Seq1.map_id /-
 theorem map_id : ∀ s : Seq1 α, map id s = s
   | ⟨a, s⟩ => by simp [map]
 #align stream.seq1.map_id Stream'.Seq1.map_id
+-/
 
+#print Stream'.Seq1.join /-
 /-- Flatten a nonempty sequence of nonempty sequences -/
 def join : Seq1 (Seq1 α) → Seq1 α
   | ((a, s), S) =>
@@ -927,27 +1162,35 @@ def join : Seq1 (Seq1 α) → Seq1 α
     | none => (a, Seq.join S)
     | some s' => (a, Seq.join (Seq.cons s' S))
 #align stream.seq1.join Stream'.Seq1.join
+-/
 
+#print Stream'.Seq1.join_nil /-
 @[simp]
 theorem join_nil (a : α) (S) : join ((a, nil), S) = (a, Seq.join S) :=
   rfl
 #align stream.seq1.join_nil Stream'.Seq1.join_nil
+-/
 
+#print Stream'.Seq1.join_cons /-
 @[simp]
 theorem join_cons (a b : α) (s S) :
     join ((a, Seq.cons b s), S) = (a, Seq.join (Seq.cons (b, s) S)) := by
   dsimp [join] <;> rw [destruct_cons] <;> rfl
 #align stream.seq1.join_cons Stream'.Seq1.join_cons
+-/
 
+#print Stream'.Seq1.ret /-
 /-- The `return` operator for the `seq1` monad,
   which produces a singleton sequence. -/
 def ret (a : α) : Seq1 α :=
   (a, nil)
 #align stream.seq1.ret Stream'.Seq1.ret
+-/
 
 instance [Inhabited α] : Inhabited (Seq1 α) :=
   ⟨ret default⟩
 
+#print Stream'.Seq1.bind /-
 /-- The `bind` operator for the `seq1` monad,
   which maps `f` on each element of `s` and appends the results together.
   (Not all of `s` may be evaluated, because the first few elements of `s`
@@ -955,19 +1198,25 @@ instance [Inhabited α] : Inhabited (Seq1 α) :=
 def bind (s : Seq1 α) (f : α → Seq1 β) : Seq1 β :=
   join (map f s)
 #align stream.seq1.bind Stream'.Seq1.bind
+-/
 
+#print Stream'.Seq1.join_map_ret /-
 @[simp]
 theorem join_map_ret (s : Seq α) : Seq.join (Seq.map ret s) = s := by
   apply coinduction2 s <;> intro s <;> apply rec_on s <;> simp [ret]
 #align stream.seq1.join_map_ret Stream'.Seq1.join_map_ret
+-/
 
+#print Stream'.Seq1.bind_ret /-
 @[simp]
 theorem bind_ret (f : α → β) : ∀ s, bind s (ret ∘ f) = map f s
   | ⟨a, s⟩ => by
     dsimp [bind, map]; change fun x => ret (f x) with ret ∘ f
     rw [map_comp]; simp [Function.comp, ret]
 #align stream.seq1.bind_ret Stream'.Seq1.bind_ret
+-/
 
+#print Stream'.Seq1.ret_bind /-
 @[simp]
 theorem ret_bind (a : α) (f : α → Seq1 β) : bind (ret a) f = f a :=
   by
@@ -975,7 +1224,9 @@ theorem ret_bind (a : α) (f : α → Seq1 β) : bind (ret a) f = f a :=
   cases' f a with a s
   apply rec_on s <;> intros <;> simp
 #align stream.seq1.ret_bind Stream'.Seq1.ret_bind
+-/
 
+#print Stream'.Seq1.map_join' /-
 @[simp]
 theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.map (map f) S) :=
   by
@@ -996,12 +1247,16 @@ theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.m
           refine' ⟨s, S, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
 #align stream.seq1.map_join' Stream'.Seq1.map_join'
+-/
 
+#print Stream'.Seq1.map_join /-
 @[simp]
 theorem map_join (f : α → β) : ∀ S, map f (join S) = join (map (map f) S)
   | ((a, s), S) => by apply rec_on s <;> intros <;> simp [map]
 #align stream.seq1.map_join Stream'.Seq1.map_join
+-/
 
+#print Stream'.Seq1.join_join /-
 @[simp]
 theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
     Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) :=
@@ -1026,7 +1281,9 @@ theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
           exact ⟨s, SS, rfl, rfl⟩
   · refine' ⟨nil, SS, _, _⟩ <;> simp
 #align stream.seq1.join_join Stream'.Seq1.join_join
+-/
 
+#print Stream'.Seq1.bind_assoc /-
 @[simp]
 theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
     bind (bind s f) g = bind s fun x : α => bind (f x) g :=
@@ -1043,6 +1300,7 @@ theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
     apply rec_on t <;> intros <;> simp
   · cases' x_1 with y t <;> simp
 #align stream.seq1.bind_assoc Stream'.Seq1.bind_assoc
+-/
 
 instance : Monad Seq1 where
   map := @map
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module data.seq.seq
-! leanprover-community/mathlib commit 995b47e555f1b6297c7cf16855f1023e355219fb
+! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,8 @@ import Mathbin.Data.Nat.Basic
 import Mathbin.Data.Stream.Init
 import Mathbin.Data.Seq.Computation
 
+namespace Stream'
+
 universe u v w
 
 /-
@@ -23,187 +25,187 @@ coinductive seq (α : Type u) : Type u
 -/
 /-- A stream `s : option α` is a sequence if `s.nth n = none` implies `s.nth (n + 1) = none`.
 -/
-def Stream'.IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
+def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
   ∀ {n : ℕ}, s n = none → s (n + 1) = none
 #align stream.is_seq Stream'.IsSeq
 
 /-- `seq α` is the type of possibly infinite lists (referred here as sequences).
   It is encoded as an infinite stream of options such that if `f n = none`, then
   `f m = none` for all `m ≥ n`. -/
-def SeqCat (α : Type u) : Type u :=
+def Seq (α : Type u) : Type u :=
   { f : Stream' (Option α) // f.IsSeq }
-#align seq SeqCat
+#align stream.seq Stream'.Seq
 
 /-- `seq1 α` is the type of nonempty sequences. -/
 def Seq1 (α) :=
-  α × SeqCat α
-#align seq1 Seq1
+  α × Seq α
+#align stream.seq1 Stream'.Seq1
 
-namespace SeqCat
+namespace Seq
 
 variable {α : Type u} {β : Type v} {γ : Type w}
 
 /-- The empty sequence -/
-def nil : SeqCat α :=
+def nil : Seq α :=
   ⟨Stream'.const none, fun n h => rfl⟩
-#align seq.nil SeqCat.nil
+#align stream.seq.nil Stream'.Seq.nil
 
-instance : Inhabited (SeqCat α) :=
+instance : Inhabited (Seq α) :=
   ⟨nil⟩
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- Prepend an element to a sequence -/
-def cons (a : α) (s : SeqCat α) : SeqCat α :=
+def cons (a : α) (s : Seq α) : Seq α :=
   ⟨some a::s.1, by
     rintro (n | _) h
     · contradiction
     · exact s.2 h⟩
-#align seq.cons SeqCat.cons
+#align stream.seq.cons Stream'.Seq.cons
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
-theorem val_cons (s : SeqCat α) (x : α) : (cons x s).val = some x::s.val :=
+theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val :=
   rfl
-#align seq.val_cons SeqCat.val_cons
+#align stream.seq.val_cons Stream'.Seq.val_cons
 
 /-- Get the nth element of a sequence (if it exists) -/
-def nth : SeqCat α → ℕ → Option α :=
+def nth : Seq α → ℕ → Option α :=
   Subtype.val
-#align seq.nth SeqCat.nth
+#align stream.seq.nth Stream'.Seq.nth
 
 @[simp]
 theorem nth_mk (f hf) : @nth α ⟨f, hf⟩ = f :=
   rfl
-#align seq.nth_mk SeqCat.nth_mk
+#align stream.seq.nth_mk Stream'.Seq.nth_mk
 
 @[simp]
 theorem nth_nil (n : ℕ) : (@nil α).get? n = none :=
   rfl
-#align seq.nth_nil SeqCat.nth_nil
+#align stream.seq.nth_nil Stream'.Seq.nth_nil
 
 @[simp]
-theorem nth_cons_zero (a : α) (s : SeqCat α) : (cons a s).get? 0 = some a :=
+theorem nth_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
   rfl
-#align seq.nth_cons_zero SeqCat.nth_cons_zero
+#align stream.seq.nth_cons_zero Stream'.Seq.nth_cons_zero
 
 @[simp]
-theorem nth_cons_succ (a : α) (s : SeqCat α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
+theorem nth_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
   rfl
-#align seq.nth_cons_succ SeqCat.nth_cons_succ
+#align stream.seq.nth_cons_succ Stream'.Seq.nth_cons_succ
 
 @[ext]
-protected theorem ext {s t : SeqCat α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t :=
+protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t :=
   Subtype.eq <| funext h
-#align seq.ext SeqCat.ext
+#align stream.seq.ext Stream'.Seq.ext
 
-theorem cons_injective2 : Function.Injective2 (cons : α → SeqCat α → SeqCat α) := fun x y s t h =>
+theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h =>
   ⟨by rw [← Option.some_inj, ← nth_cons_zero, h, nth_cons_zero],
-    SeqCat.ext fun n => by simp_rw [← nth_cons_succ x s n, h, nth_cons_succ]⟩
-#align seq.cons_injective2 SeqCat.cons_injective2
+    Seq.ext fun n => by simp_rw [← nth_cons_succ x s n, h, nth_cons_succ]⟩
+#align stream.seq.cons_injective2 Stream'.Seq.cons_injective2
 
-theorem cons_left_injective (s : SeqCat α) : Function.Injective fun x => cons x s :=
+theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s :=
   cons_injective2.left _
-#align seq.cons_left_injective SeqCat.cons_left_injective
+#align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective
 
 theorem cons_right_injective (x : α) : Function.Injective (cons x) :=
   cons_injective2.right _
-#align seq.cons_right_injective SeqCat.cons_right_injective
+#align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective
 
 /-- A sequence has terminated at position `n` if the value at position `n` equals `none`. -/
-def TerminatedAt (s : SeqCat α) (n : ℕ) : Prop :=
+def TerminatedAt (s : Seq α) (n : ℕ) : Prop :=
   s.get? n = none
-#align seq.terminated_at SeqCat.TerminatedAt
+#align stream.seq.terminated_at Stream'.Seq.TerminatedAt
 
 /-- It is decidable whether a sequence terminates at a given position. -/
-instance terminatedAtDecidable (s : SeqCat α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
+instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
   decidable_of_iff' (s.get? n).isNone <| by unfold terminated_at <;> cases s.nth n <;> simp
-#align seq.terminated_at_decidable SeqCat.terminatedAtDecidable
+#align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable
 
 /-- A sequence terminates if there is some position `n` at which it has terminated. -/
-def Terminates (s : SeqCat α) : Prop :=
+def Terminates (s : Seq α) : Prop :=
   ∃ n : ℕ, s.TerminatedAt n
-#align seq.terminates SeqCat.Terminates
+#align stream.seq.terminates Stream'.Seq.Terminates
 
-theorem not_terminates_iff {s : SeqCat α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by
+theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by
   simp [terminates, terminated_at, ← Ne.def, Option.ne_none_iff_isSome]
-#align seq.not_terminates_iff SeqCat.not_terminates_iff
+#align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff
 
 /-- Functorial action of the functor `option (α × _)` -/
 @[simp]
 def omap (f : β → γ) : Option (α × β) → Option (α × γ)
   | none => none
   | some (a, b) => some (a, f b)
-#align seq.omap SeqCat.omap
+#align stream.seq.omap Stream'.Seq.omap
 
 /-- Get the first element of a sequence -/
-def head (s : SeqCat α) : Option α :=
+def head (s : Seq α) : Option α :=
   nth s 0
-#align seq.head SeqCat.head
+#align stream.seq.head Stream'.Seq.head
 
 /-- Get the tail of a sequence (or `nil` if the sequence is `nil`) -/
-def tail (s : SeqCat α) : SeqCat α :=
+def tail (s : Seq α) : Seq α :=
   ⟨s.1.tail, fun n => by
     cases' s with f al
     exact al⟩
-#align seq.tail SeqCat.tail
+#align stream.seq.tail Stream'.Seq.tail
 
-protected def Mem (a : α) (s : SeqCat α) :=
+/-- member definition for `seq`-/
+protected def Mem (a : α) (s : Seq α) :=
   some a ∈ s.1
-#align seq.mem SeqCat.Mem
+#align stream.seq.mem Stream'.Seq.Mem
 
-instance : Membership α (SeqCat α) :=
-  ⟨SeqCat.Mem⟩
+instance : Membership α (Seq α) :=
+  ⟨Seq.Mem⟩
 
-theorem le_stable (s : SeqCat α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none :=
+theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none :=
   by
   cases' s with f al
   induction' h with n h IH
   exacts[id, fun h2 => al (IH h2)]
-#align seq.le_stable SeqCat.le_stable
+#align stream.seq.le_stable Stream'.Seq.le_stable
 
 /-- If a sequence terminated at position `n`, it also terminated at `m ≥ n `. -/
-theorem terminated_stable :
-    ∀ (s : SeqCat α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n :=
+theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n :=
   le_stable
-#align seq.terminated_stable SeqCat.terminated_stable
+#align stream.seq.terminated_stable Stream'.Seq.terminated_stable
 
 /-- If `s.nth n = some aₙ` for some value `aₙ`, then there is also some value `aₘ` such
 that `s.nth = some aₘ` for `m ≤ n`.
 -/
-theorem ge_stable (s : SeqCat α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n)
+theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n)
     (s_nth_eq_some : s.get? n = some aₙ) : ∃ aₘ : α, s.get? m = some aₘ :=
   have : s.get? n ≠ none := by simp [s_nth_eq_some]
   have : s.get? m ≠ none := mt (s.le_stable m_le_n) this
   Option.ne_none_iff_exists'.mp this
-#align seq.ge_stable SeqCat.ge_stable
+#align stream.seq.ge_stable Stream'.Seq.ge_stable
 
 theorem not_mem_nil (a : α) : a ∉ @nil α := fun ⟨n, (h : some a = none)⟩ => by injection h
-#align seq.not_mem_nil SeqCat.not_mem_nil
+#align stream.seq.not_mem_nil Stream'.Seq.not_mem_nil
 
-theorem mem_cons (a : α) : ∀ s : SeqCat α, a ∈ cons a s
+theorem mem_cons (a : α) : ∀ s : Seq α, a ∈ cons a s
   | ⟨f, al⟩ => Stream'.mem_cons (some a) _
-#align seq.mem_cons SeqCat.mem_cons
+#align stream.seq.mem_cons Stream'.Seq.mem_cons
 
-theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : SeqCat α}, a ∈ s → a ∈ cons y s
+theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : Seq α}, a ∈ s → a ∈ cons y s
   | ⟨f, al⟩ => Stream'.mem_cons_of_mem (some y)
-#align seq.mem_cons_of_mem SeqCat.mem_cons_of_mem
+#align stream.seq.mem_cons_of_mem Stream'.Seq.mem_cons_of_mem
 
-theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : SeqCat α}, a ∈ cons b s → a = b ∨ a ∈ s
+theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s → a = b ∨ a ∈ s
   | ⟨f, al⟩, h => (Stream'.eq_or_mem_of_mem_cons h).imp_left fun h => by injection h
-#align seq.eq_or_mem_of_mem_cons SeqCat.eq_or_mem_of_mem_cons
+#align stream.seq.eq_or_mem_of_mem_cons Stream'.Seq.eq_or_mem_of_mem_cons
 
 @[simp]
-theorem mem_cons_iff {a b : α} {s : SeqCat α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
+theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
   ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons, exact mem_cons_of_mem _ m]⟩
-#align seq.mem_cons_iff SeqCat.mem_cons_iff
+#align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff
 
 /-- Destructor for a sequence, resulting in either `none` (for `nil`) or
   `some (a, s)` (for `cons a s`). -/
-def destruct (s : SeqCat α) : Option (Seq1 α) :=
+def destruct (s : Seq α) : Option (Seq1 α) :=
   (fun a' => (a', s.tail)) <$> nth s 0
-#align seq.destruct SeqCat.destruct
+#align stream.seq.destruct Stream'.Seq.destruct
 
-theorem destruct_eq_nil {s : SeqCat α} : destruct s = none → s = nil :=
+theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil :=
   by
   dsimp [destruct]
   induction' f0 : nth s 0 with <;> intro h
@@ -212,9 +214,9 @@ theorem destruct_eq_nil {s : SeqCat α} : destruct s = none → s = nil :=
     induction' n with n IH
     exacts[f0, s.2 IH]
   · contradiction
-#align seq.destruct_eq_nil SeqCat.destruct_eq_nil
+#align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
 
-theorem destruct_eq_cons {s : SeqCat α} {a s'} : destruct s = some (a, s') → s = cons a s' :=
+theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s = cons a s' :=
   by
   dsimp [destruct]
   induction' f0 : nth s 0 with a' <;> intro h
@@ -227,12 +229,12 @@ theorem destruct_eq_cons {s : SeqCat α} {a s'} : destruct s = some (a, s') →
     rw [h1] at f0
     rw [← f0]
     exact (Stream'.eta f).symm
-#align seq.destruct_eq_cons SeqCat.destruct_eq_cons
+#align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons
 
 @[simp]
-theorem destruct_nil : destruct (nil : SeqCat α) = none :=
+theorem destruct_nil : destruct (nil : Seq α) = none :=
   rfl
-#align seq.destruct_nil SeqCat.destruct_nil
+#align stream.seq.destruct_nil Stream'.Seq.destruct_nil
 
 @[simp]
 theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
@@ -240,39 +242,39 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
     unfold cons destruct Functor.map
     apply congr_arg fun s => some (a, s)
     apply Subtype.eq; dsimp [tail]; rw [Stream'.tail_cons]
-#align seq.destruct_cons SeqCat.destruct_cons
+#align stream.seq.destruct_cons Stream'.Seq.destruct_cons
 
-theorem head_eq_destruct (s : SeqCat α) : head s = Prod.fst <$> destruct s := by
+theorem head_eq_destruct (s : Seq α) : head s = Prod.fst <$> destruct s := by
   unfold destruct head <;> cases nth s 0 <;> rfl
-#align seq.head_eq_destruct SeqCat.head_eq_destruct
+#align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
 
 @[simp]
-theorem head_nil : head (nil : SeqCat α) = none :=
+theorem head_nil : head (nil : Seq α) = none :=
   rfl
-#align seq.head_nil SeqCat.head_nil
+#align stream.seq.head_nil Stream'.Seq.head_nil
 
 @[simp]
 theorem head_cons (a : α) (s) : head (cons a s) = some a := by
   rw [head_eq_destruct, destruct_cons] <;> rfl
-#align seq.head_cons SeqCat.head_cons
+#align stream.seq.head_cons Stream'.Seq.head_cons
 
 @[simp]
-theorem tail_nil : tail (nil : SeqCat α) = nil :=
+theorem tail_nil : tail (nil : Seq α) = nil :=
   rfl
-#align seq.tail_nil SeqCat.tail_nil
+#align stream.seq.tail_nil Stream'.Seq.tail_nil
 
 @[simp]
 theorem tail_cons (a : α) (s) : tail (cons a s) = s := by
   cases' s with f al <;> apply Subtype.eq <;> dsimp [tail, cons] <;> rw [Stream'.tail_cons]
-#align seq.tail_cons SeqCat.tail_cons
+#align stream.seq.tail_cons Stream'.Seq.tail_cons
 
 @[simp]
-theorem nth_tail (s : SeqCat α) (n) : nth (tail s) n = nth s (n + 1) :=
+theorem nth_tail (s : Seq α) (n) : nth (tail s) n = nth s (n + 1) :=
   rfl
-#align seq.nth_tail SeqCat.nth_tail
+#align stream.seq.nth_tail Stream'.Seq.nth_tail
 
 /-- Recursion principle for sequences, compare with `list.rec_on`. -/
-def recOn {C : SeqCat α → Sort v} (s : SeqCat α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s :=
+def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s :=
   by
   induction' H : destruct s with v v
   · rw [destruct_eq_nil H]
@@ -280,9 +282,9 @@ def recOn {C : SeqCat α → Sort v} (s : SeqCat α) (h1 : C nil) (h2 : ∀ x s,
   · cases' v with a s'
     rw [destruct_eq_cons H]
     apply h2
-#align seq.rec_on SeqCat.recOn
+#align stream.seq.rec_on Stream'.Seq.recOn
 
-theorem mem_rec_on {C : SeqCat α → Prop} {a s} (M : a ∈ s)
+theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s :=
   by
   cases' M with k e; unfold Stream'.nth at e
@@ -299,19 +301,20 @@ theorem mem_rec_on {C : SeqCat α → Prop} {a s} (M : a ∈ s)
   · have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s' <;> rfl
     rw [h_eq] at e
     apply h1 _ _ (Or.inr (IH e))
-#align seq.mem_rec_on SeqCat.mem_rec_on
+#align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on
 
+/-- Corecursor over pairs of `option` values-/
 def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option β
   | none => (none, none)
   | some b =>
     match f b with
     | none => (none, none)
     | some (a, b') => (some a, some b')
-#align seq.corec.F SeqCat.Corec.f
+#align stream.seq.corec.F Stream'.Seq.Corec.f
 
 /-- Corecursor for `seq α` as a coinductive type. Iterates `f` to produce new elements
   of the sequence until `none` is obtained. -/
-def corec (f : β → Option (α × β)) (b : β) : SeqCat α :=
+def corec (f : β → Option (α × β)) (b : β) : Seq α :=
   by
   refine' ⟨Stream'.corec' (corec.F f) (some b), fun n h => _⟩
   rw [Stream'.corec'_eq]
@@ -329,7 +332,7 @@ def corec (f : β → Option (α × β)) (b : β) : SeqCat α :=
       contradiction
   · rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
     exact IH (corec.F f o).2
-#align seq.corec SeqCat.corec
+#align stream.seq.corec Stream'.Seq.corec
 
 @[simp]
 theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b) = omap (corec f) (f b) :=
@@ -344,32 +347,34 @@ theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b)
   dsimp [corec, tail]
   rw [Stream'.corec'_eq, Stream'.tail_cons]
   dsimp [corec.F]; rw [h]; rfl
-#align seq.corec_eq SeqCat.corec_eq
+#align stream.seq.corec_eq Stream'.Seq.corec_eq
 
 section Bisim
 
-variable (R : SeqCat α → SeqCat α → Prop)
+variable (R : Seq α → Seq α → Prop)
 
 -- mathport name: R
 local infixl:50 " ~ " => R
 
+/-- Bisimilarity relation over `option` of `seq1 α`-/
 def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop
   | none, none => True
   | some (a, s), some (a', s') => a = a' ∧ R s s'
   | _, _ => False
-#align seq.bisim_o SeqCat.BisimO
+#align stream.seq.bisim_o Stream'.Seq.BisimO
 
 attribute [simp] bisim_o
 
+/-- a relation is bisimiar if it meets the `bisim_o` test-/
 def IsBisimulation :=
   ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂)
-#align seq.is_bisimulation SeqCat.IsBisimulation
+#align stream.seq.is_bisimulation Stream'.Seq.IsBisimulation
 
 -- If two streams are bisimilar, then they are equal
 theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ :=
   by
   apply Subtype.eq
-  apply Stream'.eq_of_bisim fun x y => ∃ s s' : SeqCat α, s.1 = x ∧ s'.1 = y ∧ R s s'
+  apply Stream'.eq_of_bisim fun x y => ∃ s s' : seq α, s.1 = x ∧ s'.1 = y ∧ R s s'
   dsimp [Stream'.IsBisimulation]
   intro t₁ t₂ e
   exact
@@ -394,118 +399,118 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
         rw [h1]
         exact h2
   exact ⟨s₁, s₂, rfl, rfl, r⟩
-#align seq.eq_of_bisim SeqCat.eq_of_bisim
+#align stream.seq.eq_of_bisim Stream'.Seq.eq_of_bisim
 
 end Bisim
 
 theorem coinduction :
-    ∀ {s₁ s₂ : SeqCat α},
+    ∀ {s₁ s₂ : Seq α},
       head s₁ = head s₂ →
-        (∀ (β : Type u) (fr : SeqCat α → β), fr s₁ = fr s₂ → fr (tail s₁) = fr (tail s₂)) → s₁ = s₂
+        (∀ (β : Type u) (fr : Seq α → β), fr s₁ = fr s₂ → fr (tail s₁) = fr (tail s₂)) → s₁ = s₂
   | ⟨f₁, a₁⟩, ⟨f₂, a₂⟩, hh, ht =>
     Subtype.eq (Stream'.coinduction hh fun β fr => ht β fun s => fr s.1)
-#align seq.coinduction SeqCat.coinduction
+#align stream.seq.coinduction Stream'.Seq.coinduction
 
-theorem coinduction2 (s) (f g : SeqCat α → SeqCat β)
+theorem coinduction2 (s) (f g : Seq α → Seq β)
     (H :
       ∀ s,
-        BisimO (fun s1 s2 : SeqCat β => ∃ s : SeqCat α, s1 = f s ∧ s2 = g s) (destruct (f s))
+        BisimO (fun s1 s2 : Seq β => ∃ s : Seq α, s1 = f s ∧ s2 = g s) (destruct (f s))
           (destruct (g s))) :
     f s = g s :=
   by
   refine' eq_of_bisim (fun s1 s2 => ∃ s, s1 = f s ∧ s2 = g s) _ ⟨s, rfl, rfl⟩
   intro s1 s2 h; rcases h with ⟨s, h1, h2⟩
   rw [h1, h2]; apply H
-#align seq.coinduction2 SeqCat.coinduction2
+#align stream.seq.coinduction2 Stream'.Seq.coinduction2
 
 /-- Embed a list as a sequence -/
-def ofList (l : List α) : SeqCat α :=
+def ofList (l : List α) : Seq α :=
   ⟨List.get? l, fun n h => by
     rw [List.get?_eq_none] at h⊢
     exact h.trans (Nat.le_succ n)⟩
-#align seq.of_list SeqCat.ofList
+#align stream.seq.of_list Stream'.Seq.ofList
 
-instance coeList : Coe (List α) (SeqCat α) :=
+instance coeList : Coe (List α) (Seq α) :=
   ⟨ofList⟩
-#align seq.coe_list SeqCat.coeList
+#align stream.seq.coe_list Stream'.Seq.coeList
 
 @[simp]
-theorem ofList_nil : ofList [] = (nil : SeqCat α) :=
+theorem ofList_nil : ofList [] = (nil : Seq α) :=
   rfl
-#align seq.of_list_nil SeqCat.ofList_nil
+#align stream.seq.of_list_nil Stream'.Seq.ofList_nil
 
 @[simp]
 theorem ofList_nth (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
   rfl
-#align seq.of_list_nth SeqCat.ofList_nth
+#align stream.seq.of_list_nth Stream'.Seq.ofList_nth
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem ofList_cons (a : α) (l : List α) : ofList (a::l) = cons a (ofList l) := by
   ext1 (_ | n) <;> rfl
-#align seq.of_list_cons SeqCat.ofList_cons
+#align stream.seq.of_list_cons Stream'.Seq.ofList_cons
 
 /-- Embed an infinite stream as a sequence -/
-def ofStream (s : Stream' α) : SeqCat α :=
+def ofStream (s : Stream' α) : Seq α :=
   ⟨s.map some, fun n h => by contradiction⟩
-#align seq.of_stream SeqCat.ofStream
+#align stream.seq.of_stream Stream'.Seq.ofStream
 
-instance coeStream : Coe (Stream' α) (SeqCat α) :=
+instance coeStream : Coe (Stream' α) (Seq α) :=
   ⟨ofStream⟩
-#align seq.coe_stream SeqCat.coeStream
+#align stream.seq.coe_stream Stream'.Seq.coeStream
 
 /-- Embed a `lazy_list α` as a sequence. Note that even though this
   is non-meta, it will produce infinite sequences if used with
   cyclic `lazy_list`s created by meta constructions. -/
-def ofLazyList : LazyList α → SeqCat α :=
+def ofLazyList : LazyList α → Seq α :=
   corec fun l =>
     match l with
     | LazyList.nil => none
     | LazyList.cons a l' => some (a, l' ())
-#align seq.of_lazy_list SeqCat.ofLazyList
+#align stream.seq.of_lazy_list Stream'.Seq.ofLazyList
 
-instance coeLazyList : Coe (LazyList α) (SeqCat α) :=
+instance coeLazyList : Coe (LazyList α) (Seq α) :=
   ⟨ofLazyList⟩
-#align seq.coe_lazy_list SeqCat.coeLazyList
+#align stream.seq.coe_lazy_list Stream'.Seq.coeLazyList
 
 /-- Translate a sequence into a `lazy_list`. Since `lazy_list` and `list`
   are isomorphic as non-meta types, this function is necessarily meta. -/
-unsafe def to_lazy_list : SeqCat α → LazyList α
+unsafe def to_lazy_list : Seq α → LazyList α
   | s =>
     match destruct s with
     | none => LazyList.nil
     | some (a, s') => LazyList.cons a (to_lazy_list s')
-#align seq.to_lazy_list seq.to_lazy_list
+#align stream.seq.to_lazy_list stream.seq.to_lazy_list
 
 /-- Translate a sequence to a list. This function will run forever if
   run on an infinite sequence. -/
-unsafe def force_to_list (s : SeqCat α) : List α :=
+unsafe def force_to_list (s : Seq α) : List α :=
   (to_lazy_list s).toList
-#align seq.force_to_list seq.force_to_list
+#align stream.seq.force_to_list stream.seq.force_to_list
 
 /-- The sequence of natural numbers some 0, some 1, ... -/
-def nats : SeqCat ℕ :=
+def nats : Seq ℕ :=
   Stream'.nats
-#align seq.nats SeqCat.nats
+#align stream.seq.nats Stream'.Seq.nats
 
 @[simp]
 theorem nats_nth (n : ℕ) : nats.get? n = some n :=
   rfl
-#align seq.nats_nth SeqCat.nats_nth
+#align stream.seq.nats_nth Stream'.Seq.nats_nth
 
 /-- Append two sequences. If `s₁` is infinite, then `s₁ ++ s₂ = s₁`,
   otherwise it puts `s₂` at the location of the `nil` in `s₁`. -/
-def append (s₁ s₂ : SeqCat α) : SeqCat α :=
-  @corec α (SeqCat α × SeqCat α)
+def append (s₁ s₂ : Seq α) : Seq α :=
+  @corec α (Seq α × Seq α)
     (fun ⟨s₁, s₂⟩ =>
       match destruct s₁ with
       | none => omap (fun s₂ => (nil, s₂)) (destruct s₂)
       | some (a, s₁') => some (a, s₁', s₂))
     (s₁, s₂)
-#align seq.append SeqCat.append
+#align stream.seq.append Stream'.Seq.append
 
 /-- Map a function over a sequence. -/
-def map (f : α → β) : SeqCat α → SeqCat β
+def map (f : α → β) : Seq α → Seq β
   | ⟨s, al⟩ =>
     ⟨s.map (Option.map f), fun n =>
       by
@@ -513,13 +518,13 @@ def map (f : α → β) : SeqCat α → SeqCat β
       induction' e : s n with <;> intro
       · rw [al e]
         assumption; · contradiction⟩
-#align seq.map SeqCat.map
+#align stream.seq.map Stream'.Seq.map
 
 /-- Flatten a sequence of sequences. (It is required that the
   sequences be nonempty to ensure productivity; in the case
   of an infinite sequence of `nil`, the first element is never
   generated.) -/
-def join : SeqCat (Seq1 α) → SeqCat α :=
+def join : Seq (Seq1 α) → Seq α :=
   corec fun S =>
     match destruct S with
     | none => none
@@ -529,28 +534,28 @@ def join : SeqCat (Seq1 α) → SeqCat α :=
           match destruct s with
           | none => S'
           | some s' => cons s' S')
-#align seq.join SeqCat.join
+#align stream.seq.join Stream'.Seq.join
 
 /-- Remove the first `n` elements from the sequence. -/
-def drop (s : SeqCat α) : ℕ → SeqCat α
+def drop (s : Seq α) : ℕ → Seq α
   | 0 => s
   | n + 1 => tail (drop n)
-#align seq.drop SeqCat.drop
+#align stream.seq.drop Stream'.Seq.drop
 
 attribute [simp] drop
 
 /-- Take the first `n` elements of the sequence (producing a list) -/
-def take : ℕ → SeqCat α → List α
+def take : ℕ → Seq α → List α
   | 0, s => []
   | n + 1, s =>
     match destruct s with
     | none => []
     | some (x, r) => List.cons x (take n r)
-#align seq.take SeqCat.take
+#align stream.seq.take Stream'.Seq.take
 
 /-- Split a sequence at `n`, producing a finite initial segment
   and an infinite tail. -/
-def splitAt : ℕ → SeqCat α → List α × SeqCat α
+def splitAt : ℕ → Seq α → List α × Seq α
   | 0, s => ([], s)
   | n + 1, s =>
     match destruct s with
@@ -558,75 +563,75 @@ def splitAt : ℕ → SeqCat α → List α × SeqCat α
     | some (x, s') =>
       let (l, r) := split_at n s'
       (List.cons x l, r)
-#align seq.split_at SeqCat.splitAt
+#align stream.seq.split_at Stream'.Seq.splitAt
 
 section ZipWith
 
 /-- Combine two sequences with a function -/
-def zipWith (f : α → β → γ) (s₁ : SeqCat α) (s₂ : SeqCat β) : SeqCat γ :=
+def zipWith (f : α → β → γ) (s₁ : Seq α) (s₂ : Seq β) : Seq γ :=
   ⟨fun n => Option.map₂ f (s₁.get? n) (s₂.get? n), fun n hn =>
     Option.map₂_eq_none_iff.2 <| (Option.map₂_eq_none_iff.1 hn).imp s₁.2 s₂.2⟩
-#align seq.zip_with SeqCat.zipWith
+#align stream.seq.zip_with Stream'.Seq.zipWith
 
-variable {s : SeqCat α} {s' : SeqCat β} {n : ℕ}
+variable {s : Seq α} {s' : Seq β} {n : ℕ}
 
 @[simp]
 theorem nth_zipWith (f : α → β → γ) (s s' n) :
     (zipWith f s s').get? n = Option.map₂ f (s.get? n) (s'.get? n) :=
   rfl
-#align seq.nth_zip_with SeqCat.nth_zipWith
+#align stream.seq.nth_zip_with Stream'.Seq.nth_zipWith
 
 end ZipWith
 
 /-- Pair two sequences into a sequence of pairs -/
-def zip : SeqCat α → SeqCat β → SeqCat (α × β) :=
+def zip : Seq α → Seq β → Seq (α × β) :=
   zipWith Prod.mk
-#align seq.zip SeqCat.zip
+#align stream.seq.zip Stream'.Seq.zip
 
-theorem nth_zip (s : SeqCat α) (t : SeqCat β) (n : ℕ) :
+theorem nth_zip (s : Seq α) (t : Seq β) (n : ℕ) :
     nth (zip s t) n = Option.map₂ Prod.mk (nth s n) (nth t n) :=
   nth_zipWith _ _ _ _
-#align seq.nth_zip SeqCat.nth_zip
+#align stream.seq.nth_zip Stream'.Seq.nth_zip
 
 /-- Separate a sequence of pairs into two sequences -/
-def unzip (s : SeqCat (α × β)) : SeqCat α × SeqCat β :=
+def unzip (s : Seq (α × β)) : Seq α × Seq β :=
   (map Prod.fst s, map Prod.snd s)
-#align seq.unzip SeqCat.unzip
+#align stream.seq.unzip Stream'.Seq.unzip
 
 /-- Enumerate a sequence by tagging each element with its index. -/
-def enum (s : SeqCat α) : SeqCat (ℕ × α) :=
-  SeqCat.zip nats s
-#align seq.enum SeqCat.enum
+def enum (s : Seq α) : Seq (ℕ × α) :=
+  Seq.zip nats s
+#align stream.seq.enum Stream'.Seq.enum
 
 @[simp]
-theorem nth_enum (s : SeqCat α) (n : ℕ) : nth (enum s) n = Option.map (Prod.mk n) (nth s n) :=
+theorem nth_enum (s : Seq α) (n : ℕ) : nth (enum s) n = Option.map (Prod.mk n) (nth s n) :=
   nth_zip _ _ _
-#align seq.nth_enum SeqCat.nth_enum
+#align stream.seq.nth_enum Stream'.Seq.nth_enum
 
 @[simp]
-theorem enum_nil : enum (nil : SeqCat α) = nil :=
+theorem enum_nil : enum (nil : Seq α) = nil :=
   rfl
-#align seq.enum_nil SeqCat.enum_nil
+#align stream.seq.enum_nil Stream'.Seq.enum_nil
 
 /-- Convert a sequence which is known to terminate into a list -/
-def toList (s : SeqCat α) (h : s.Terminates) : List α :=
+def toList (s : Seq α) (h : s.Terminates) : List α :=
   take (Nat.find h) s
-#align seq.to_list SeqCat.toList
+#align stream.seq.to_list Stream'.Seq.toList
 
 /-- Convert a sequence which is known not to terminate into a stream -/
-def toStream (s : SeqCat α) (h : ¬s.Terminates) : Stream' α := fun n =>
+def toStream (s : Seq α) (h : ¬s.Terminates) : Stream' α := fun n =>
   Option.get <| not_terminates_iff.1 h n
-#align seq.to_stream SeqCat.toStream
+#align stream.seq.to_stream Stream'.Seq.toStream
 
 /-- Convert a sequence into either a list or a stream depending on whether
   it is finite or infinite. (Without decidability of the infiniteness predicate,
   this is not constructively possible.) -/
-def toListOrStream (s : SeqCat α) [Decidable s.Terminates] : Sum (List α) (Stream' α) :=
+def toListOrStream (s : Seq α) [Decidable s.Terminates] : Sum (List α) (Stream' α) :=
   if h : s.Terminates then Sum.inl (toList s h) else Sum.inr (toStream s h)
-#align seq.to_list_or_stream SeqCat.toListOrStream
+#align stream.seq.to_list_or_stream Stream'.Seq.toListOrStream
 
 @[simp]
-theorem nil_append (s : SeqCat α) : append nil s = s :=
+theorem nil_append (s : Seq α) : append nil s = s :=
   by
   apply coinduction2; intro s
   dsimp [append]; rw [corec_eq]
@@ -636,7 +641,7 @@ theorem nil_append (s : SeqCat α) : append nil s = s :=
     rw [destruct_cons]
     dsimp
     exact ⟨rfl, s, rfl, rfl⟩
-#align seq.nil_append SeqCat.nil_append
+#align stream.seq.nil_append Stream'.Seq.nil_append
 
 @[simp]
 theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :=
@@ -644,10 +649,10 @@ theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :
     dsimp [append]; rw [corec_eq]
     dsimp [append]; rw [destruct_cons]
     dsimp [append]; rfl
-#align seq.cons_append SeqCat.cons_append
+#align stream.seq.cons_append Stream'.Seq.cons_append
 
 @[simp]
-theorem append_nil (s : SeqCat α) : append s nil = s :=
+theorem append_nil (s : Seq α) : append s nil = s :=
   by
   apply coinduction2 s; intro s
   apply rec_on s _ _
@@ -656,10 +661,10 @@ theorem append_nil (s : SeqCat α) : append s nil = s :=
     rw [cons_append, destruct_cons, destruct_cons]
     dsimp
     exact ⟨rfl, s, rfl, rfl⟩
-#align seq.append_nil SeqCat.append_nil
+#align stream.seq.append_nil Stream'.Seq.append_nil
 
 @[simp]
-theorem append_assoc (s t u : SeqCat α) : append (append s t) u = append s (append t u) :=
+theorem append_assoc (s t u : Seq α) : append (append s t) u = append s (append t u) :=
   by
   apply eq_of_bisim fun s1 s2 => ∃ s t u, s1 = append (append s t) u ∧ s2 = append s (append t u)
   · intro s1 s2 h
@@ -676,37 +681,37 @@ theorem append_assoc (s t u : SeqCat α) : append (append s t) u = append s (app
         · intro x s
           exact ⟨s, t, u, rfl, rfl⟩
   · exact ⟨s, t, u, rfl, rfl⟩
-#align seq.append_assoc SeqCat.append_assoc
+#align stream.seq.append_assoc Stream'.Seq.append_assoc
 
 @[simp]
 theorem map_nil (f : α → β) : map f nil = nil :=
   rfl
-#align seq.map_nil SeqCat.map_nil
+#align stream.seq.map_nil Stream'.Seq.map_nil
 
 @[simp]
 theorem map_cons (f : α → β) (a) : ∀ s, map f (cons a s) = cons (f a) (map f s)
   | ⟨s, al⟩ => by apply Subtype.eq <;> dsimp [cons, map] <;> rw [Stream'.map_cons] <;> rfl
-#align seq.map_cons SeqCat.map_cons
+#align stream.seq.map_cons Stream'.Seq.map_cons
 
 @[simp]
-theorem map_id : ∀ s : SeqCat α, map id s = s
+theorem map_id : ∀ s : Seq α, map id s = s
   | ⟨s, al⟩ => by
     apply Subtype.eq <;> dsimp [map]
     rw [Option.map_id, Stream'.map_id] <;> rfl
-#align seq.map_id SeqCat.map_id
+#align stream.seq.map_id Stream'.Seq.map_id
 
 @[simp]
 theorem map_tail (f : α → β) : ∀ s, map f (tail s) = tail (map f s)
   | ⟨s, al⟩ => by apply Subtype.eq <;> dsimp [tail, map] <;> rw [Stream'.map_tail] <;> rfl
-#align seq.map_tail SeqCat.map_tail
+#align stream.seq.map_tail Stream'.Seq.map_tail
 
-theorem map_comp (f : α → β) (g : β → γ) : ∀ s : SeqCat α, map (g ∘ f) s = map g (map f s)
+theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Seq α, map (g ∘ f) s = map g (map f s)
   | ⟨s, al⟩ => by
     apply Subtype.eq <;> dsimp [map]
     rw [Stream'.map_map]
     apply congr_arg fun f : _ → Option γ => Stream'.map f s
     ext ⟨⟩ <;> rfl
-#align seq.map_comp SeqCat.map_comp
+#align stream.seq.map_comp Stream'.Seq.map_comp
 
 @[simp]
 theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s) (map f t) :=
@@ -724,34 +729,34 @@ theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s)
           refine' ⟨nil, t, _, _⟩ <;> simp
       · intro x s
         refine' ⟨s, t, rfl, rfl⟩
-#align seq.map_append SeqCat.map_append
+#align stream.seq.map_append Stream'.Seq.map_append
 
 @[simp]
 theorem map_nth (f : α → β) : ∀ s n, nth (map f s) n = (nth s n).map f
   | ⟨s, al⟩, n => rfl
-#align seq.map_nth SeqCat.map_nth
+#align stream.seq.map_nth Stream'.Seq.map_nth
 
-instance : Functor SeqCat where map := @map
+instance : Functor Seq where map := @map
 
-instance : LawfulFunctor SeqCat where
+instance : LawfulFunctor Seq where
   id_map := @map_id
   comp_map := @map_comp
 
 @[simp]
-theorem join_nil : join nil = (nil : SeqCat α) :=
+theorem join_nil : join nil = (nil : Seq α) :=
   destruct_eq_nil rfl
-#align seq.join_nil SeqCat.join_nil
+#align stream.seq.join_nil Stream'.Seq.join_nil
 
 @[simp]
 theorem join_cons_nil (a : α) (S) : join (cons (a, nil) S) = cons a (join S) :=
   destruct_eq_cons <| by simp [join]
-#align seq.join_cons_nil SeqCat.join_cons_nil
+#align stream.seq.join_cons_nil Stream'.Seq.join_cons_nil
 
 @[simp]
 theorem join_cons_cons (a b : α) (s S) :
     join (cons (a, cons b s) S) = cons a (join (cons (b, s) S)) :=
   destruct_eq_cons <| by simp [join]
-#align seq.join_cons_cons SeqCat.join_cons_cons
+#align stream.seq.join_cons_cons Stream'.Seq.join_cons_cons
 
 @[simp]
 theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join S)) :=
@@ -774,10 +779,10 @@ theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join
       · intro x s
         simp
         refine' Or.inr ⟨x, s, S, rfl, rfl⟩
-#align seq.join_cons SeqCat.join_cons
+#align stream.seq.join_cons Stream'.Seq.join_cons
 
 @[simp]
-theorem join_append (S T : SeqCat (Seq1 α)) : join (append S T) = append (join S) (join T) :=
+theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S) (join T) :=
   by
   apply
     eq_of_bisim fun s1 s2 =>
@@ -799,65 +804,65 @@ theorem join_append (S T : SeqCat (Seq1 α)) : join (append S T) = append (join
         · intro x s
           exact ⟨s, S, T, rfl, rfl⟩
   · refine' ⟨nil, S, T, _, _⟩ <;> simp
-#align seq.join_append SeqCat.join_append
+#align stream.seq.join_append Stream'.Seq.join_append
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem ofStream_cons (a : α) (s) : ofStream (a::s) = cons a (ofStream s) := by
   apply Subtype.eq <;> simp [of_stream, cons] <;> rw [Stream'.map_cons]
-#align seq.of_stream_cons SeqCat.ofStream_cons
+#align stream.seq.of_stream_cons Stream'.Seq.ofStream_cons
 
 @[simp]
 theorem ofList_append (l l' : List α) : ofList (l ++ l') = append (ofList l) (ofList l') := by
   induction l <;> simp [*]
-#align seq.of_list_append SeqCat.ofList_append
+#align stream.seq.of_list_append Stream'.Seq.ofList_append
 
 @[simp]
 theorem ofStream_append (l : List α) (s : Stream' α) :
     ofStream (l ++ₛ s) = append (ofList l) (ofStream s) := by
   induction l <;> simp [*, Stream'.nil_append_stream, Stream'.cons_append_stream]
-#align seq.of_stream_append SeqCat.ofStream_append
+#align stream.seq.of_stream_append Stream'.Seq.ofStream_append
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- Convert a sequence into a list, embedded in a computation to allow for
   the possibility of infinite sequences (in which case the computation
   never returns anything). -/
-def toList' {α} (s : SeqCat α) : Computation (List α) :=
-  @Computation.corec (List α) (List α × SeqCat α)
+def toList' {α} (s : Seq α) : Computation (List α) :=
+  @Computation.corec (List α) (List α × Seq α)
     (fun ⟨l, s⟩ =>
       match destruct s with
       | none => Sum.inl l.reverse
       | some (a, s') => Sum.inr (a::l, s'))
     ([], s)
-#align seq.to_list' SeqCat.toList'
+#align stream.seq.to_list' Stream'.Seq.toList'
 
-theorem dropn_add (s : SeqCat α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
+theorem dropn_add (s : Seq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
   | 0 => rfl
   | n + 1 => congr_arg tail (dropn_add n)
-#align seq.dropn_add SeqCat.dropn_add
+#align stream.seq.dropn_add Stream'.Seq.dropn_add
 
-theorem dropn_tail (s : SeqCat α) (n) : drop (tail s) n = drop s (n + 1) := by
+theorem dropn_tail (s : Seq α) (n) : drop (tail s) n = drop s (n + 1) := by
   rw [add_comm] <;> symm <;> apply dropn_add
-#align seq.dropn_tail SeqCat.dropn_tail
+#align stream.seq.dropn_tail Stream'.Seq.dropn_tail
 
 @[simp]
-theorem head_dropn (s : SeqCat α) (n) : head (drop s n) = nth s n :=
+theorem head_dropn (s : Seq α) (n) : head (drop s n) = nth s n :=
   by
   induction' n with n IH generalizing s; · rfl
   rw [Nat.succ_eq_add_one, ← nth_tail, ← dropn_tail]; apply IH
-#align seq.head_dropn SeqCat.head_dropn
+#align stream.seq.head_dropn Stream'.Seq.head_dropn
 
-theorem mem_map (f : α → β) {a : α} : ∀ {s : SeqCat α}, a ∈ s → f a ∈ map f s
+theorem mem_map (f : α → β) {a : α} : ∀ {s : Seq α}, a ∈ s → f a ∈ map f s
   | ⟨g, al⟩ => Stream'.mem_map (Option.map f)
-#align seq.mem_map SeqCat.mem_map
+#align stream.seq.mem_map Stream'.Seq.mem_map
 
-theorem exists_of_mem_map {f} {b : β} : ∀ {s : SeqCat α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
+theorem exists_of_mem_map {f} {b : β} : ∀ {s : Seq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
   | ⟨g, al⟩, h => by
     let ⟨o, om, oe⟩ := Stream'.exists_of_mem_map h
     cases' o with a <;> injection oe with h' <;> exact ⟨a, om, h'⟩
-#align seq.exists_of_mem_map SeqCat.exists_of_mem_map
+#align stream.seq.exists_of_mem_map Stream'.Seq.exists_of_mem_map
 
-theorem of_mem_append {s₁ s₂ : SeqCat α} {a : α} (h : a ∈ append s₁ s₂) : a ∈ s₁ ∨ a ∈ s₂ :=
+theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂) : a ∈ s₁ ∨ a ∈ s₂ :=
   by
   have := h; revert this
   generalize e : append s₁ s₂ = ss; intro h; revert s₁
@@ -873,71 +878,72 @@ theorem of_mem_append {s₁ s₂ : SeqCat α} {a : α} (h : a ∈ append s₁ s
       cases' o with e' IH
       · simp [i1, e']
       · exact Or.imp_left (mem_cons_of_mem _) (IH m i2)
-#align seq.of_mem_append SeqCat.of_mem_append
+#align stream.seq.of_mem_append Stream'.Seq.of_mem_append
 
-theorem mem_append_left {s₁ s₂ : SeqCat α} {a : α} (h : a ∈ s₁) : a ∈ append s₁ s₂ := by
+theorem mem_append_left {s₁ s₂ : Seq α} {a : α} (h : a ∈ s₁) : a ∈ append s₁ s₂ := by
   apply mem_rec_on h <;> intros <;> simp [*]
-#align seq.mem_append_left SeqCat.mem_append_left
+#align stream.seq.mem_append_left Stream'.Seq.mem_append_left
 
 @[simp]
-theorem enum_cons (s : SeqCat α) (x : α) :
+theorem enum_cons (s : Seq α) (x : α) :
     enum (cons x s) = cons (0, x) (map (Prod.map Nat.succ id) (enum s)) :=
   by
   ext ⟨n⟩ : 1
   · simp
   · simp only [nth_enum, nth_cons_succ, map_nth, Option.map_map]
     congr
-#align seq.enum_cons SeqCat.enum_cons
+#align stream.seq.enum_cons Stream'.Seq.enum_cons
 
-end SeqCat
+end Seq
 
 namespace Seq1
 
 variable {α : Type u} {β : Type v} {γ : Type w}
 
-open SeqCat
+open Stream'.Seq
 
 /-- Convert a `seq1` to a sequence. -/
-def toSeq : Seq1 α → SeqCat α
-  | (a, s) => cons a s
-#align seq1.to_seq Seq1.toSeq
+def toSeq : Seq1 α → Seq α
+  | (a, s) => Seq.cons a s
+#align stream.seq1.to_seq Stream'.Seq1.toSeq
 
-instance coeSeq : Coe (Seq1 α) (SeqCat α) :=
+instance coeSeq : Coe (Seq1 α) (Seq α) :=
   ⟨toSeq⟩
-#align seq1.coe_seq Seq1.coeSeq
+#align stream.seq1.coe_seq Stream'.Seq1.coeSeq
 
 /-- Map a function on a `seq1` -/
 def map (f : α → β) : Seq1 α → Seq1 β
-  | (a, s) => (f a, SeqCat.map f s)
-#align seq1.map Seq1.map
+  | (a, s) => (f a, Seq.map f s)
+#align stream.seq1.map Stream'.Seq1.map
 
 theorem map_id : ∀ s : Seq1 α, map id s = s
   | ⟨a, s⟩ => by simp [map]
-#align seq1.map_id Seq1.map_id
+#align stream.seq1.map_id Stream'.Seq1.map_id
 
 /-- Flatten a nonempty sequence of nonempty sequences -/
 def join : Seq1 (Seq1 α) → Seq1 α
   | ((a, s), S) =>
     match destruct s with
-    | none => (a, SeqCat.join S)
-    | some s' => (a, SeqCat.join (cons s' S))
-#align seq1.join Seq1.join
+    | none => (a, Seq.join S)
+    | some s' => (a, Seq.join (Seq.cons s' S))
+#align stream.seq1.join Stream'.Seq1.join
 
 @[simp]
-theorem join_nil (a : α) (S) : join ((a, nil), S) = (a, SeqCat.join S) :=
+theorem join_nil (a : α) (S) : join ((a, nil), S) = (a, Seq.join S) :=
   rfl
-#align seq1.join_nil Seq1.join_nil
+#align stream.seq1.join_nil Stream'.Seq1.join_nil
 
 @[simp]
-theorem join_cons (a b : α) (s S) : join ((a, cons b s), S) = (a, SeqCat.join (cons (b, s) S)) := by
+theorem join_cons (a b : α) (s S) :
+    join ((a, Seq.cons b s), S) = (a, Seq.join (Seq.cons (b, s) S)) := by
   dsimp [join] <;> rw [destruct_cons] <;> rfl
-#align seq1.join_cons Seq1.join_cons
+#align stream.seq1.join_cons Stream'.Seq1.join_cons
 
 /-- The `return` operator for the `seq1` monad,
   which produces a singleton sequence. -/
 def ret (a : α) : Seq1 α :=
   (a, nil)
-#align seq1.ret Seq1.ret
+#align stream.seq1.ret Stream'.Seq1.ret
 
 instance [Inhabited α] : Inhabited (Seq1 α) :=
   ⟨ret default⟩
@@ -948,19 +954,19 @@ instance [Inhabited α] : Inhabited (Seq1 α) :=
   may already produce an infinite result.) -/
 def bind (s : Seq1 α) (f : α → Seq1 β) : Seq1 β :=
   join (map f s)
-#align seq1.bind Seq1.bind
+#align stream.seq1.bind Stream'.Seq1.bind
 
 @[simp]
-theorem join_map_ret (s : SeqCat α) : SeqCat.join (SeqCat.map ret s) = s := by
+theorem join_map_ret (s : Seq α) : Seq.join (Seq.map ret s) = s := by
   apply coinduction2 s <;> intro s <;> apply rec_on s <;> simp [ret]
-#align seq1.join_map_ret Seq1.join_map_ret
+#align stream.seq1.join_map_ret Stream'.Seq1.join_map_ret
 
 @[simp]
 theorem bind_ret (f : α → β) : ∀ s, bind s (ret ∘ f) = map f s
   | ⟨a, s⟩ => by
     dsimp [bind, map]; change fun x => ret (f x) with ret ∘ f
     rw [map_comp]; simp [Function.comp, ret]
-#align seq1.bind_ret Seq1.bind_ret
+#align stream.seq1.bind_ret Stream'.Seq1.bind_ret
 
 @[simp]
 theorem ret_bind (a : α) (f : α → Seq1 β) : bind (ret a) f = f a :=
@@ -968,17 +974,15 @@ theorem ret_bind (a : α) (f : α → Seq1 β) : bind (ret a) f = f a :=
   simp [ret, bind, map]
   cases' f a with a s
   apply rec_on s <;> intros <;> simp
-#align seq1.ret_bind Seq1.ret_bind
+#align stream.seq1.ret_bind Stream'.Seq1.ret_bind
 
 @[simp]
-theorem map_join' (f : α → β) (S) :
-    SeqCat.map f (SeqCat.join S) = SeqCat.join (SeqCat.map (map f) S) :=
+theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.map (map f) S) :=
   by
   apply
-    eq_of_bisim fun s1 s2 =>
+    seq.eq_of_bisim fun s1 s2 =>
       ∃ s S,
-        s1 = append s (SeqCat.map f (SeqCat.join S)) ∧
-          s2 = append s (SeqCat.join (SeqCat.map (map f) S))
+        s1 = seq.append s (seq.map f (seq.join S)) ∧ s2 = append s (seq.join (seq.map (map f) S))
   · intro s1 s2 h
     exact
       match s1, s2, h with
@@ -991,22 +995,21 @@ theorem map_join' (f : α → β) (S) :
         · intro x s
           refine' ⟨s, S, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
-#align seq1.map_join' Seq1.map_join'
+#align stream.seq1.map_join' Stream'.Seq1.map_join'
 
 @[simp]
 theorem map_join (f : α → β) : ∀ S, map f (join S) = join (map (map f) S)
   | ((a, s), S) => by apply rec_on s <;> intros <;> simp [map]
-#align seq1.map_join Seq1.map_join
+#align stream.seq1.map_join Stream'.Seq1.map_join
 
 @[simp]
-theorem join_join (SS : SeqCat (Seq1 (Seq1 α))) :
-    SeqCat.join (SeqCat.join SS) = SeqCat.join (SeqCat.map join SS) :=
+theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
+    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) :=
   by
   apply
-    eq_of_bisim fun s1 s2 =>
+    seq.eq_of_bisim fun s1 s2 =>
       ∃ s SS,
-        s1 = SeqCat.append s (SeqCat.join (SeqCat.join SS)) ∧
-          s2 = SeqCat.append s (SeqCat.join (SeqCat.map join SS))
+        s1 = seq.append s (seq.join (seq.join SS)) ∧ s2 = seq.append s (seq.join (seq.map join SS))
   · intro s1 s2 h
     exact
       match s1, s2, h with
@@ -1018,11 +1021,11 @@ theorem join_join (SS : SeqCat (Seq1 (Seq1 α))) :
             apply rec_on s <;> simp
             · exact ⟨_, _, rfl, rfl⟩
             · intro x s
-              refine' ⟨cons x (append s (SeqCat.join S)), SS, _, _⟩ <;> simp
+              refine' ⟨seq.cons x (append s (seq.join S)), SS, _, _⟩ <;> simp
         · intro x s
           exact ⟨s, SS, rfl, rfl⟩
   · refine' ⟨nil, SS, _, _⟩ <;> simp
-#align seq1.join_join Seq1.join_join
+#align stream.seq1.join_join Stream'.Seq1.join_join
 
 @[simp]
 theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
@@ -1033,13 +1036,13 @@ theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
   rw [← map_comp]
   change fun x => join (map g (f x)) with join ∘ map g ∘ f
   rw [map_comp _ join]
-  generalize SeqCat.map (map g ∘ f) s = SS
+  generalize seq.map (map g ∘ f) s = SS
   rcases map g (f a) with ⟨⟨a, s⟩, S⟩
   apply rec_on s <;> intros <;> apply rec_on S <;> intros <;> simp
   · cases' x with x t
     apply rec_on t <;> intros <;> simp
   · cases' x_1 with y t <;> simp
-#align seq1.bind_assoc Seq1.bind_assoc
+#align stream.seq1.bind_assoc Stream'.Seq1.bind_assoc
 
 instance : Monad Seq1 where
   map := @map
@@ -1054,3 +1057,5 @@ instance : LawfulMonad Seq1 where
 
 end Seq1
 
+end Stream'
+

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -377,9 +377,9 @@ def IsBisimulation :=
 theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ := by
   apply Subtype.eq
   apply Stream'.eq_of_bisim fun x y => ∃ s s' : Seq α, s.1 = x ∧ s'.1 = y ∧ R s s'
-  dsimp [Stream'.IsBisimulation]
-  intro t₁ t₂ e
-  exact
+  · dsimp [Stream'.IsBisimulation]
+    intro t₁ t₂ e
+    exact
     match t₁, t₂, e with
     | _, _, ⟨s, s', rfl, rfl, r⟩ => by
       suffices head s = head s' ∧ R (tail s) (tail s') from
@@ -401,9 +401,9 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
         rw [head_cons, head_cons, tail_cons, tail_cons]
         cases' this with h1 h2
         constructor
-        rw [h1]
-        exact h2
-  exact ⟨s₁, s₂, rfl, rfl, r⟩
+        · rw [h1]
+        · exact h2
+  · exact ⟨s₁, s₂, rfl, rfl, r⟩
 #align stream.seq.eq_of_bisim Stream'.Seq.eq_of_bisim
 
 end Bisim
chore(Data/List): Use Std lemmas (#11711)

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.

Diff
@@ -837,7 +837,7 @@ theorem dropn_add (s : Seq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
 #align stream.seq.dropn_add Stream'.Seq.dropn_add
 
 theorem dropn_tail (s : Seq α) (n) : drop (tail s) n = drop s (n + 1) := by
-  rw [add_comm]; symm; apply dropn_add
+  rw [Nat.add_comm]; symm; apply dropn_add
 #align stream.seq.dropn_tail Stream'.Seq.dropn_tail
 
 @[simp]
chore(Mathlib/Data/List/Basic): minimize imports (#11497)

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>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
 import Std.Data.LazyList
+import Mathlib.Data.Option.NAry
 import Mathlib.Data.Seq.Computation
 
 #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
chore: classify new theorem / theorem porting notes (#11432)

Classifies by adding issue number #10756 to porting notes claiming anything equivalent to:

  • "added theorem"
  • "added theorems"
  • "new theorem"
  • "new theorems"
  • "added lemma"
  • "new lemma"
  • "new lemmas"
Diff
@@ -913,7 +913,7 @@ def map (f : α → β) : Seq1 α → Seq1 β
   | (a, s) => (f a, Seq.map f s)
 #align stream.seq1.map Stream'.Seq1.map
 
--- Porting note: New theorem.
+-- Porting note (#10756): new theorem.
 theorem map_pair {f : α → β} {a s} : map f (a, s) = (f a, Seq.map f s) := rfl
 
 theorem map_id : ∀ s : Seq1 α, map id s = s
chore: more squeeze_simps arising from linter (#11259)

The squeezing continues! All found by the linter at #11246.

Diff
@@ -775,8 +775,7 @@ theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join
       apply recOn s
       · simp [join_cons_cons, join_cons_nil]
       · intro x s
-        simp [join_cons_cons, join_cons_nil]
-        exact Or.inr ⟨x, s, S, rfl, rfl⟩
+        simpa [join_cons_cons, join_cons_nil] using Or.inr ⟨x, s, S, rfl, rfl⟩
 #align stream.seq.join_cons Stream'.Seq.join_cons
 
 @[simp]
@@ -793,11 +792,11 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
           · apply recOn T
             · simp
             · intro s T
-              cases' s with a s; simp
+              cases' s with a s; simp only [join_cons, destruct_cons, true_and]
               refine' ⟨s, nil, T, _, _⟩ <;> simp
           · intro s S
-            cases' s with a s; simp
-            exact ⟨s, S, T, rfl, rfl⟩
+            cases' s with a s
+            simpa using ⟨s, S, T, rfl, rfl⟩
         · intro _ s
           exact ⟨s, S, T, rfl, rfl⟩
   · refine' ⟨nil, S, T, _, _⟩ <;> simp
@@ -805,7 +804,7 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
 
 @[simp]
 theorem ofStream_cons (a : α) (s) : ofStream (a::s) = cons a (ofStream s) := by
-  apply Subtype.eq; simp [ofStream, cons]; rw [Stream'.map_cons]
+  apply Subtype.eq; simp only [ofStream, cons]; rw [Stream'.map_cons]
 #align stream.seq.of_stream_cons Stream'.Seq.ofStream_cons
 
 @[simp]
@@ -991,8 +990,8 @@ theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.m
         apply recOn s <;> simp
         · apply recOn S <;> simp
           · intro x S
-            cases' x with a s; simp [map]
-            exact ⟨_, _, rfl, rfl⟩
+            cases' x with a s
+            simpa [map] using ⟨_, _, rfl, rfl⟩
         · intro _ s
           exact ⟨s, S, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
@@ -1017,7 +1016,8 @@ theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
         apply recOn s <;> simp
         · apply recOn SS <;> simp
           · intro S SS
-            cases' S with s S; cases' s with x s; simp [map]
+            cases' S with s S; cases' s with x s
+            simp only [Seq.join_cons, join_append, destruct_cons]
             apply recOn s <;> simp
             · exact ⟨_, _, rfl, rfl⟩
             · intro x s
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -241,7 +241,7 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
     apply Subtype.eq; dsimp [tail]
 #align stream.seq.destruct_cons Stream'.Seq.destruct_cons
 
--- porting note: needed universe annotation to avoid universe issues
+-- Porting note: needed universe annotation to avoid universe issues
 theorem head_eq_destruct (s : Seq α) : head.{u} s = Prod.fst.{u} <$> destruct.{u} s := by
   unfold destruct head; cases get? s 0 <;> rfl
 #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
@@ -295,7 +295,7 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
       rfl
     rw [TH]
     apply h1 _ _ (Or.inl rfl)
-  -- porting note: had to reshuffle `intro`
+  -- Porting note: had to reshuffle `intro`
   revert e; apply s.recOn _ fun b s' => _
   · intro e; injection e
   · intro b s' e
@@ -339,7 +339,7 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α := by
 theorem corec_eq (f : β → Option (α × β)) (b : β) :
     destruct (corec f b) = omap (corec f) (f b) := by
   dsimp [corec, destruct, get]
-  -- porting note: next two lines were `change`...`with`...
+  -- Porting note: next two lines were `change`...`with`...
   have h: Stream'.corec' (Corec.f f) (some b) 0 = (Corec.f f (some b)).1 := rfl
   rw [h]
   dsimp [Corec.f]
@@ -746,12 +746,12 @@ theorem join_nil : join nil = (nil : Seq α) :=
   destruct_eq_nil rfl
 #align stream.seq.join_nil Stream'.Seq.join_nil
 
---@[simp] -- porting note: simp can prove: `join_cons` is more general
+--@[simp] -- Porting note: simp can prove: `join_cons` is more general
 theorem join_cons_nil (a : α) (S) : join (cons (a, nil) S) = cons a (join S) :=
   destruct_eq_cons <| by simp [join]
 #align stream.seq.join_cons_nil Stream'.Seq.join_cons_nil
 
---@[simp] -- porting note: simp can prove: `join_cons` is more general
+--@[simp] -- Porting note: simp can prove: `join_cons` is more general
 theorem join_cons_cons (a b : α) (s S) :
     join (cons (a, cons b s) S) = cons a (join (cons (b, s) S)) :=
   destruct_eq_cons <| by simp [join]
chore: remove terminal, terminal refines (#10762)

I replaced a few "terminal" refine/refine's with exact.

The strategy was very simple-minded: essentially any refine whose following line had smaller indentation got replaced by exact and then I cleaned up the mess.

This PR certainly leaves some further terminal refines, but maybe the current change is beneficial.

Diff
@@ -726,7 +726,7 @@ theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s)
         · intro _ t
           refine' ⟨nil, t, _, _⟩ <;> simp
       · intro _ s
-        refine' ⟨s, t, rfl, rfl⟩
+        exact ⟨s, t, rfl, rfl⟩
 #align stream.seq.map_append Stream'.Seq.map_append
 
 @[simp]
@@ -776,7 +776,7 @@ theorem join_cons (a : α) (s S) : join (cons (a, s) S) = cons a (append s (join
       · simp [join_cons_cons, join_cons_nil]
       · intro x s
         simp [join_cons_cons, join_cons_nil]
-        refine' Or.inr ⟨x, s, S, rfl, rfl⟩
+        exact Or.inr ⟨x, s, S, rfl, rfl⟩
 #align stream.seq.join_cons Stream'.Seq.join_cons
 
 @[simp]
@@ -994,7 +994,7 @@ theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.m
             cases' x with a s; simp [map]
             exact ⟨_, _, rfl, rfl⟩
         · intro _ s
-          refine' ⟨s, S, rfl, rfl⟩
+          exact ⟨s, S, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
 #align stream.seq1.map_join' Stream'.Seq1.map_join'
 
chore: classify was simp porting notes (#10746)

Classifies by adding issue number (#10745) to porting notes claiming was simp.

Diff
@@ -1031,7 +1031,7 @@ theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
 theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
     bind (bind s f) g = bind s fun x : α => bind (f x) g := by
   cases' s with a s
-  -- Porting note: Was `simp [bind, map]`.
+  -- porting note (#10745): was `simp [bind, map]`.
   simp only [bind, map_pair, map_join]
   rw [← map_comp]
   simp only [show (fun x => join (map g (f x))) = join ∘ (map g ∘ f) from rfl]
chore: bump Std (#10568)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -3,7 +3,7 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
-import Mathlib.Data.LazyList
+import Std.Data.LazyList
 import Mathlib.Data.Seq.Computation
 
 #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
refactor: Split off basic Nat file (#9551)

Data.Nat.Basic is currently made of two things:

  • Basic lemmas that continue the theory in Std (and could belong there, really)
  • Basic algebraic order instances

I need the first ones earlier in the algebraic order hierarchy, hence the split.

Part of #9411. Similar to #9443

Diff
@@ -3,10 +3,7 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
-import Mathlib.Data.List.Basic
 import Mathlib.Data.LazyList
-import Mathlib.Data.Nat.Basic
-import Mathlib.Data.Stream.Init
 import Mathlib.Data.Seq.Computation
 
 #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
style: rename 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.

Diff
@@ -28,7 +28,7 @@ coinductive seq (α : Type u) : Type u
 | nil : seq α
 | cons : α → seq α → seq α
 -/
-/-- A stream `s : Option α` is a sequence if `s.nth n = none` implies `s.nth (n + 1) = none`.
+/-- A stream `s : Option α` is a sequence if `s.get n = none` implies `s.get (n + 1) = none`.
 -/
 def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
   ∀ {n : ℕ}, s n = none → s (n + 1) = none
@@ -289,7 +289,7 @@ def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (co
 
 theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
     (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s := by
-  cases' M with k e; unfold Stream'.nth at e
+  cases' M with k e; unfold Stream'.get at e
   induction' k with k IH generalizing s
   · have TH : s = cons a (tail s) := by
       apply destruct_eq_cons
@@ -341,7 +341,7 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α := by
 @[simp]
 theorem corec_eq (f : β → Option (α × β)) (b : β) :
     destruct (corec f b) = omap (corec f) (f b) := by
-  dsimp [corec, destruct, nth]
+  dsimp [corec, destruct, get]
   -- porting note: next two lines were `change`...`with`...
   have h: Stream'.corec' (Corec.f f) (some b) 0 = (Corec.f f (some b)).1 := rfl
   rw [h]
@@ -447,9 +447,9 @@ theorem ofList_nil : ofList [] = (nil : Seq α) :=
 #align stream.seq.of_list_nil Stream'.Seq.ofList_nil
 
 @[simp]
-theorem ofList_nth (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
+theorem ofList_get (l : List α) (n : ℕ) : (ofList l).get? n = l.get? n :=
   rfl
-#align stream.seq.of_list_nth Stream'.Seq.ofList_nth
+#align stream.seq.of_list_nth Stream'.Seq.ofList_get
 
 @[simp]
 theorem ofList_cons (a : α) (l : List α) : ofList (a::l) = cons a (ofList l) := by
@@ -520,7 +520,7 @@ def append (s₁ s₂ : Seq α) : Seq α :=
 def map (f : α → β) : Seq α → Seq β
   | ⟨s, al⟩ =>
     ⟨s.map (Option.map f), fun {n} => by
-      dsimp [Stream'.map, Stream'.nth]
+      dsimp [Stream'.map, Stream'.get]
       induction' e : s n with e <;> intro
       · rw [al e]
         assumption
chore: remove nonterminal simp (#7580)

Removes nonterminal simps on lines looking like simp [...]

Diff
@@ -976,7 +976,7 @@ theorem bind_ret (f : α → β) : ∀ s, bind s (ret ∘ f) = map f s
 
 @[simp]
 theorem ret_bind (a : α) (f : α → Seq1 β) : bind (ret a) f = f a := by
-  simp [ret, bind, map]
+  simp only [bind, map, ret._eq_1, map_nil]
   cases' f a with a s
   apply recOn s <;> intros <;> simp
 #align stream.seq1.ret_bind Stream'.Seq1.ret_bind
chore: remove trailing space in backticks (#7617)

This will improve spaces in the mathlib4 docs.

Diff
@@ -166,7 +166,7 @@ theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get?
   exacts [id, fun h2 => al (IH h2)]
 #align stream.seq.le_stable Stream'.Seq.le_stable
 
-/-- If a sequence terminated at position `n`, it also terminated at `m ≥ n `. -/
+/-- If a sequence terminated at position `n`, it also terminated at `m ≥ n`. -/
 theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n :=
   le_stable
 #align stream.seq.terminated_stable Stream'.Seq.terminated_stable
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -342,7 +342,6 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α := by
 theorem corec_eq (f : β → Option (α × β)) (b : β) :
     destruct (corec f b) = omap (corec f) (f b) := by
   dsimp [corec, destruct, nth]
-  dsimp
   -- porting note: next two lines were `change`...`with`...
   have h: Stream'.corec' (Corec.f f) (some b) 0 = (Corec.f f (some b)).1 := rfl
   rw [h]
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.seq.seq
-! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.List.Basic
 import Mathlib.Data.LazyList
@@ -14,6 +9,8 @@ import Mathlib.Data.Nat.Basic
 import Mathlib.Data.Stream.Init
 import Mathlib.Data.Seq.Computation
 
+#align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
 /-!
 # Possibly infinite lists
 
chore: remove a few superfluous semicolons (#5880)

Alongside any necessary spacing/flow changes to accommodate their removal.

Diff
@@ -724,7 +724,7 @@ theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s)
   apply
     eq_of_bisim (fun s1 s2 => ∃ s t, s1 = map f (append s t) ∧ s2 = append (map f s) (map f t)) _
       ⟨s, t, rfl, rfl⟩
-  intro s1 s2 h;
+  intro s1 s2 h
   exact
     match s1, s2, h with
     | _, _, ⟨s, t, rfl, rfl⟩ => by
chore: remove occurrences of semicolon after space (#5713)

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.

Diff
@@ -124,7 +124,7 @@ def TerminatedAt (s : Seq α) (n : ℕ) : Prop :=
 
 /-- It is decidable whether a sequence terminates at a given position. -/
 instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
-  decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt ; cases s.get? n <;> simp
+  decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp
 #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable
 
 /-- A sequence terminates if there is some position `n` at which it has terminated. -/
@@ -249,7 +249,7 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
 
 -- porting note: needed universe annotation to avoid universe issues
 theorem head_eq_destruct (s : Seq α) : head.{u} s = Prod.fst.{u} <$> destruct.{u} s := by
-  unfold destruct head ; cases get? s 0 <;> rfl
+  unfold destruct head; cases get? s 0 <;> rfl
 #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct
 
 @[simp]
@@ -305,7 +305,7 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s)
   revert e; apply s.recOn _ fun b s' => _
   · intro e; injection e
   · intro b s' e
-    have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s' ; rfl
+    have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s'; rfl
     rw [h_eq] at e
     apply h1 _ _ (Or.inr (IH e))
 #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on
@@ -389,7 +389,7 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
     match t₁, t₂, e with
     | _, _, ⟨s, s', rfl, rfl, r⟩ => by
       suffices head s = head s' ∧ R (tail s) (tail s') from
-        And.imp id (fun r => ⟨tail s, tail s', by cases s ; rfl, by cases s' ; rfl, r⟩) this
+        And.imp id (fun r => ⟨tail s, tail s', by cases s; rfl, by cases s'; rfl, r⟩) this
       have := bisim r; revert r this
       apply recOn s _ _ <;> apply recOn s' _ _
       · intro r _
@@ -697,24 +697,24 @@ theorem map_nil (f : α → β) : map f nil = nil :=
 
 @[simp]
 theorem map_cons (f : α → β) (a) : ∀ s, map f (cons a s) = cons (f a) (map f s)
-  | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [cons, map] ; rw [Stream'.map_cons] ; rfl
+  | ⟨s, al⟩ => by apply Subtype.eq; dsimp [cons, map]; rw [Stream'.map_cons]; rfl
 #align stream.seq.map_cons Stream'.Seq.map_cons
 
 @[simp]
 theorem map_id : ∀ s : Seq α, map id s = s
   | ⟨s, al⟩ => by
-    apply Subtype.eq ; dsimp [map]
+    apply Subtype.eq; dsimp [map]
     rw [Option.map_id, Stream'.map_id]
 #align stream.seq.map_id Stream'.Seq.map_id
 
 @[simp]
 theorem map_tail (f : α → β) : ∀ s, map f (tail s) = tail (map f s)
-  | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [tail, map]
+  | ⟨s, al⟩ => by apply Subtype.eq; dsimp [tail, map]
 #align stream.seq.map_tail Stream'.Seq.map_tail
 
 theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Seq α, map (g ∘ f) s = map g (map f s)
   | ⟨s, al⟩ => by
-    apply Subtype.eq ; dsimp [map]
+    apply Subtype.eq; dsimp [map]
     apply congr_arg fun f : _ → Option γ => Stream'.map f s
     ext ⟨⟩ <;> rfl
 #align stream.seq.map_comp Stream'.Seq.map_comp
@@ -800,10 +800,10 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
           · apply recOn T
             · simp
             · intro s T
-              cases' s with a s ; simp
+              cases' s with a s; simp
               refine' ⟨s, nil, T, _, _⟩ <;> simp
           · intro s S
-            cases' s with a s ; simp
+            cases' s with a s; simp
             exact ⟨s, S, T, rfl, rfl⟩
         · intro _ s
           exact ⟨s, S, T, rfl, rfl⟩
@@ -812,7 +812,7 @@ theorem join_append (S T : Seq (Seq1 α)) : join (append S T) = append (join S)
 
 @[simp]
 theorem ofStream_cons (a : α) (s) : ofStream (a::s) = cons a (ofStream s) := by
-  apply Subtype.eq ; simp [ofStream, cons] ; rw [Stream'.map_cons]
+  apply Subtype.eq; simp [ofStream, cons]; rw [Stream'.map_cons]
 #align stream.seq.of_stream_cons Stream'.Seq.ofStream_cons
 
 @[simp]
@@ -844,7 +844,7 @@ theorem dropn_add (s : Seq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
 #align stream.seq.dropn_add Stream'.Seq.dropn_add
 
 theorem dropn_tail (s : Seq α) (n) : drop (tail s) n = drop s (n + 1) := by
-  rw [add_comm] ; symm ; apply dropn_add
+  rw [add_comm]; symm; apply dropn_add
 #align stream.seq.dropn_tail Stream'.Seq.dropn_tail
 
 @[simp]
@@ -863,7 +863,7 @@ theorem exists_of_mem_map {f} {b : β} : ∀ {s : Seq α}, b ∈ map f s → ∃
     let ⟨o, om, oe⟩ := @Stream'.exists_of_mem_map _ _ (Option.map f) (some b) g h
     cases' o with a
     · injection oe
-    · injection oe with h' ; exact ⟨a, om, h'⟩
+    · injection oe with h'; exact ⟨a, om, h'⟩
 #align stream.seq.exists_of_mem_map Stream'.Seq.exists_of_mem_map
 
 theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂) : a ∈ s₁ ∨ a ∈ s₂ := by
@@ -887,7 +887,7 @@ theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂)
 #align stream.seq.of_mem_append Stream'.Seq.of_mem_append
 
 theorem mem_append_left {s₁ s₂ : Seq α} {a : α} (h : a ∈ s₁) : a ∈ append s₁ s₂ := by
-  apply mem_rec_on h ; intros ; simp [*]
+  apply mem_rec_on h; intros; simp [*]
 #align stream.seq.mem_append_left Stream'.Seq.mem_append_left
 
 @[simp]
@@ -944,7 +944,7 @@ theorem join_nil (a : α) (S) : join ((a, nil), S) = (a, Seq.join S) :=
 @[simp]
 theorem join_cons (a b : α) (s S) :
     join ((a, Seq.cons b s), S) = (a, Seq.join (Seq.cons (b, s) S)) := by
-  dsimp [join] ; rw [destruct_cons]
+  dsimp [join]; rw [destruct_cons]
 #align stream.seq1.join_cons Stream'.Seq1.join_cons
 
 /-- The `return` operator for the `Seq1` monad,
@@ -966,7 +966,7 @@ def bind (s : Seq1 α) (f : α → Seq1 β) : Seq1 β :=
 
 @[simp]
 theorem join_map_ret (s : Seq α) : Seq.join (Seq.map ret s) = s := by
-  apply coinduction2 s ; intro s ; apply recOn s <;> simp [ret]
+  apply coinduction2 s; intro s; apply recOn s <;> simp [ret]
 #align stream.seq1.join_map_ret Stream'.Seq1.join_map_ret
 
 @[simp]
@@ -998,7 +998,7 @@ theorem map_join' (f : α → β) (S) : Seq.map f (Seq.join S) = Seq.join (Seq.m
         apply recOn s <;> simp
         · apply recOn S <;> simp
           · intro x S
-            cases' x with a s ; simp [map]
+            cases' x with a s; simp [map]
             exact ⟨_, _, rfl, rfl⟩
         · intro _ s
           refine' ⟨s, S, rfl, rfl⟩
@@ -1024,7 +1024,7 @@ theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
         apply recOn s <;> simp
         · apply recOn SS <;> simp
           · intro S SS
-            cases' S with s S ; cases' s with x s ; simp [map]
+            cases' S with s S; cases' s with x s; simp [map]
             apply recOn s <;> simp
             · exact ⟨_, _, rfl, rfl⟩
             · intro x s
chore: fix focusing dots (#5708)

This PR is the result of running

find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;

which firstly replaces . focusing dots with · and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.

Diff
@@ -394,8 +394,8 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
       apply recOn s _ _ <;> apply recOn s' _ _
       · intro r _
         constructor
-        . rfl
-        . assumption
+        · rfl
+        · assumption
       · intro x s _ this
         rw [destruct_nil, destruct_cons] at this
         exact False.elim this
@@ -528,7 +528,7 @@ def map (f : α → β) : Seq α → Seq β
       induction' e : s n with e <;> intro
       · rw [al e]
         assumption
-      . contradiction⟩
+      · contradiction⟩
 #align stream.seq.map Stream'.Seq.map
 
 /-- Flatten a sequence of sequences. (It is required that the
@@ -862,8 +862,8 @@ theorem exists_of_mem_map {f} {b : β} : ∀ {s : Seq α}, b ∈ map f s → ∃
   | ⟨g, al⟩ =>
     let ⟨o, om, oe⟩ := @Stream'.exists_of_mem_map _ _ (Option.map f) (some b) g h
     cases' o with a
-    . injection oe
-    . injection oe with h' ; exact ⟨a, om, h'⟩
+    · injection oe
+    · injection oe with h' ; exact ⟨a, om, h'⟩
 #align stream.seq.exists_of_mem_map Stream'.Seq.exists_of_mem_map
 
 theorem of_mem_append {s₁ s₂ : Seq α} {a : α} (h : a ∈ append s₁ s₂) : a ∈ s₁ ∨ a ∈ s₂ := by
chore: clean up spacing around at and goals (#5387)

Changes are of the form

  • some_tactic at h⊢ -> some_tactic at h ⊢
  • some_tactic at h -> some_tactic at h
Diff
@@ -437,7 +437,7 @@ theorem coinduction2 (s) (f g : Seq α → Seq β)
 @[coe]
 def ofList (l : List α) : Seq α :=
   ⟨List.get? l, fun {n} h => by
-    rw [List.get?_eq_none] at h⊢
+    rw [List.get?_eq_none] at h ⊢
     exact h.trans (Nat.le_succ n)⟩
 #align stream.seq.of_list Stream'.Seq.ofList
 
chore: fix many typos (#4967)

These are all doc fixes

Diff
@@ -374,7 +374,7 @@ def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop
 
 attribute [simp] BisimO
 
-/-- a relation is bisimiar if it meets the `BisimO` test-/
+/-- a relation is bisimilar if it meets the `BisimO` test-/
 def IsBisimulation :=
   ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂)
 #align stream.seq.is_bisimulation Stream'.Seq.IsBisimulation
chore: add space after exacts (#4945)

Too often tempted to change these during other PRs, so doing a mass edit here.

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -166,7 +166,7 @@ instance : Membership α (Seq α) :=
 theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by
   cases' s with f al
   induction' h with n _ IH
-  exacts[id, fun h2 => al (IH h2)]
+  exacts [id, fun h2 => al (IH h2)]
 #align stream.seq.le_stable Stream'.Seq.le_stable
 
 /-- If a sequence terminated at position `n`, it also terminated at `m ≥ n `. -/
@@ -216,7 +216,7 @@ theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil := by
   · apply Subtype.eq
     funext n
     induction' n with n IH
-    exacts[f0, s.2 IH]
+    exacts [f0, s.2 IH]
   · contradiction
 #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
 
chore: update std 05-22 (#4248)

The main breaking change is that tac <;> [t1, t2] is now written tac <;> [t1; t2], to avoid clashing with tactics like cases and use that take comma-separated lists.

Diff
@@ -201,7 +201,7 @@ theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s →
 
 @[simp]
 theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
-  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons, exact mem_cons_of_mem _ m]⟩
+  ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons; exact mem_cons_of_mem _ m]⟩
 #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff
 
 /-- Destructor for a sequence, resulting in either `none` (for `nil`) or
feat: more simp lemmas about streams (#3929)

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).

Diff
@@ -244,7 +244,7 @@ theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s)
   | ⟨f, al⟩ => by
     unfold cons destruct Functor.map
     apply congr_arg fun s => some (a, s)
-    apply Subtype.eq; dsimp [tail]; rw [Stream'.tail_cons]
+    apply Subtype.eq; dsimp [tail]
 #align stream.seq.destruct_cons Stream'.Seq.destruct_cons
 
 -- porting note: needed universe annotation to avoid universe issues
@@ -272,7 +272,6 @@ theorem tail_cons (a : α) (s) : tail (cons a s) = s := by
   cases' s with f al
   apply Subtype.eq
   dsimp [tail, cons]
-  rw [Stream'.tail_cons]
 #align stream.seq.tail_cons Stream'.Seq.tail_cons
 
 @[simp]
@@ -710,13 +709,12 @@ theorem map_id : ∀ s : Seq α, map id s = s
 
 @[simp]
 theorem map_tail (f : α → β) : ∀ s, map f (tail s) = tail (map f s)
-  | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [tail, map] ; rw [Stream'.map_tail]
+  | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [tail, map]
 #align stream.seq.map_tail Stream'.Seq.map_tail
 
 theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Seq α, map (g ∘ f) s = map g (map f s)
   | ⟨s, al⟩ => by
     apply Subtype.eq ; dsimp [map]
-    rw [Stream'.map_map]
     apply congr_arg fun f : _ → Option γ => Stream'.map f s
     ext ⟨⟩ <;> rfl
 #align stream.seq.map_comp Stream'.Seq.map_comp
chore: bye-bye, solo bys! (#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 bys".

Diff
@@ -343,8 +343,8 @@ def corec (f : β → Option (α × β)) (b : β) : Seq α := by
 #align stream.seq.corec Stream'.Seq.corec
 
 @[simp]
-theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b) = omap (corec f) (f b) :=
-  by
+theorem corec_eq (f : β → Option (α × β)) (b : β) :
+    destruct (corec f b) = omap (corec f) (f b) := by
   dsimp [corec, destruct, nth]
   dsimp
   -- porting note: next two lines were `change`...`with`...
doc: Fix typo in Data.Seq.Seq (#3439)
Diff
@@ -17,7 +17,7 @@ import Mathlib.Data.Seq.Computation
 /-!
 # Possibly infinite lists
 
-This file provides a `Seq α` type repesenting possibly infinite lists (referred here as sequences).
+This file provides a `Seq α` type representing possibly infinite lists (referred here as sequences).
   It is encoded as an infinite stream of options such that if `f n = none`, then
   `f m = none` for all `m ≥ n`.
 -/
chore: tidy various files (#3408)
Diff
@@ -85,9 +85,9 @@ theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f :=
 #align stream.seq.nth_mk Stream'.Seq.get?_mk
 
 @[simp]
-theorem nth_nil (n : ℕ) : (@nil α).get? n = none :=
+theorem get?_nil (n : ℕ) : (@nil α).get? n = none :=
   rfl
-#align stream.seq.nth_nil Stream'.Seq.nth_nil
+#align stream.seq.nth_nil Stream'.Seq.get?_nil
 
 @[simp]
 theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
@@ -259,7 +259,7 @@ theorem head_nil : head (nil : Seq α) = none :=
 
 @[simp]
 theorem head_cons (a : α) (s) : head (cons a s) = some a := by
-  rw [head_eq_destruct, destruct_cons] ; rfl
+  rw [head_eq_destruct, destruct_cons, Option.map_eq_map, Option.map_some']
 #align stream.seq.head_cons Stream'.Seq.head_cons
 
 @[simp]
@@ -269,7 +269,10 @@ theorem tail_nil : tail (nil : Seq α) = nil :=
 
 @[simp]
 theorem tail_cons (a : α) (s) : tail (cons a s) = s := by
-  cases' s with f al ; apply Subtype.eq ; dsimp [tail, cons] ; rw [Stream'.tail_cons]
+  cases' s with f al
+  apply Subtype.eq
+  dsimp [tail, cons]
+  rw [Stream'.tail_cons]
 #align stream.seq.tail_cons Stream'.Seq.tail_cons
 
 @[simp]
@@ -361,7 +364,6 @@ section Bisim
 
 variable (R : Seq α → Seq α → Prop)
 
--- mathport name: R
 local infixl:50 " ~ " => R
 
 /-- Bisimilarity relation over `Option` of `Seq1 α`-/
@@ -494,9 +496,9 @@ unsafe def toLazyList : Seq α → LazyList α
 
 /-- Translate a sequence to a list. This function will run forever if
   run on an infinite sequence. -/
-unsafe def force_to_list (s : Seq α) : List α :=
+unsafe def forceToList (s : Seq α) : List α :=
   (toLazyList s).toList
-#align stream.seq.force_to_list Stream'.Seq.toLazyList
+#align stream.seq.force_to_list Stream'.Seq.forceToList
 
 /-- The sequence of natural numbers some 0, some 1, ... -/
 def nats : Seq ℕ :=
@@ -504,9 +506,9 @@ def nats : Seq ℕ :=
 #align stream.seq.nats Stream'.Seq.nats
 
 @[simp]
-theorem nats_nth (n : ℕ) : nats.get? n = some n :=
+theorem nats_get? (n : ℕ) : nats.get? n = some n :=
   rfl
-#align stream.seq.nats_nth Stream'.Seq.nats_nth
+#align stream.seq.nats_nth Stream'.Seq.nats_get?
 
 /-- Append two sequences. If `s₁` is infinite, then `s₁ ++ s₂ = s₁`,
   otherwise it puts `s₂` at the location of the `nil` in `s₁`. -/
@@ -1039,7 +1041,7 @@ theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
     bind (bind s f) g = bind s fun x : α => bind (f x) g := by
   cases' s with a s
   -- Porting note: Was `simp [bind, map]`.
-  simp [bind, map_pair]
+  simp only [bind, map_pair, map_join]
   rw [← map_comp]
   simp only [show (fun x => join (map g (f x))) = join ∘ (map g ∘ f) from rfl]
   rw [map_comp _ join]
Feat: Port/Data.Seq.Seq (#3187)

Port of Data.Seq.Seq following Mathlib3 refactor to avoid Seq overload.

Down to two issues:

  • bind_ret goes like Mathlib3 right up to the last line but doesn't close (I've tried the full Mathlib3 simp invocation to no avail.
  • bind_assoc has issues with single match lines gumming up the works, which should dsimp away but don't

Co-authored-by: Komyyy <pol_tta@outlook.jp>

Dependencies 2 + 75

76 files ported (97.4%)
39483 lines ported (99.4%)
Show graph

The unported dependencies are