data.seq.wseqMathlib.Data.Seq.WSeq

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
@@ -678,7 +678,7 @@ theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap
 theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
   fun s1 s2 (h : swap (LiftRel R) s2 s1) => by
   rwa [lift_rel.swap,
-    show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h 
+    show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h
 #align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm
 -/
 
@@ -1021,9 +1021,9 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
   (head_terminates_iff _).2 <|
     by
     rcases(head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩
-    simp [tail] at h 
+    simp [tail] at h
     rcases exists_of_mem_bind h with ⟨s', h1, h2⟩
-    unfold Functor.map at h1 
+    unfold Functor.map at h1
     exact
       let ⟨t, h3, h4⟩ := Computation.exists_of_mem_map h1
       Computation.terminates_of_mem h3
@@ -1033,10 +1033,10 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
 #print Stream'.WSeq.destruct_some_of_destruct_tail_some /-
 theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) :
     ∃ a', some a' ∈ destruct s := by
-  unfold tail Functor.map at h ; simp at h 
+  unfold tail Functor.map at h; simp at h
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
   rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
-  cases' t' with t' <;> rw [← ht2] at td  <;> simp at td 
+  cases' t' with t' <;> rw [← ht2] at td <;> simp at td
   · have := mem_unique td (ret_mem _); contradiction
   · exact ⟨_, ht'⟩
 #align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some
@@ -1045,7 +1045,7 @@ theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ de
 #print Stream'.WSeq.head_some_of_head_tail_some /-
 theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) :
     ∃ a', some a' ∈ head s := by
-  unfold head at h 
+  unfold head at h
   rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
   cases' o with o <;> injection e with h'; clear e h'
   cases' destruct_some_of_destruct_tail_some md with a am
@@ -1083,7 +1083,7 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
     by
     cases e : Computation.get (nth s (n + 1)); · assumption
     have := mem_of_get_eq _ e
-    simp [nth] at this h ; cases' head_some_of_head_tail_some this with a' h'
+    simp [nth] at this h; cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
     contradiction⟩
 #align stream.wseq.to_seq Stream'.WSeq.toSeq
@@ -1146,7 +1146,7 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
             apply s.rec_on _ (fun x s => _) fun s => _ <;>
           intro m <;>
         have := congr_arg Computation.destruct m <;>
-      simp at this  <;>
+      simp at this <;>
     cases' this with i1 i2
   · rw [i1, i2]
     cases' s' with f al
@@ -1209,7 +1209,7 @@ theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s :=
     cases' o with o <;> injection h2 with h'
     cases' o with a' s'
     exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm)
-  · have := @IH (tail s); rw [nth_tail] at this 
+  · have := @IH (tail s); rw [nth_tail] at this
     exact mem_of_mem_tail (this h)
 #align stream.wseq.nth_mem Stream'.WSeq.get?_mem
 -/
@@ -1235,8 +1235,8 @@ theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) :
     rcases(head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩
     have := Computation.mem_unique (Computation.mem_map _ om) h
     cases' o with o <;> injection this with i
-    cases' o with a' s'; dsimp at i 
-    rw [i] at om ; exact ⟨_, om⟩⟩
+    cases' o with a' s'; dsimp at i
+    rw [i] at om; exact ⟨_, om⟩⟩
 #align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem
 -/
 
@@ -1267,7 +1267,7 @@ theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t
 
 #print Stream'.WSeq.exists_of_liftRel_right /-
 theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) :
-    ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H  <;> exact exists_of_lift_rel_left H h
+    ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H <;> exact exists_of_lift_rel_left H h
 #align stream.wseq.exists_of_lift_rel_right Stream'.WSeq.exists_of_liftRel_right
 -/
 
@@ -1709,22 +1709,22 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
     from fun S h => (this _ h nil S (by simp) (by simp [h])).resolve_left (not_mem_nil _)
   intro ss h; apply mem_rec_on h (fun b ss o => _) fun ss IH => _ <;> intro s S
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej  <;> have := congr_arg seq.destruct ej <;>
-          simp at this  <;> try cases this <;> try contradiction
+                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
+        try cases this <;> try contradiction
     substs b' ss
     simp at m ⊢
     cases' o with e IH; · simp [e]
     cases' m with e m; · simp [e]
     exact Or.imp_left Or.inr (IH _ _ rfl m)
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej  <;> have := congr_arg seq.destruct ej <;>
-          simp at this  <;> try try have := this.1; contradiction <;> subst ss
+                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
+        try try have := this.1; contradiction <;> subst ss
     · apply Or.inr; simp at m ⊢
       cases' IH s S rfl m with as ex
       · exact ⟨s, Or.inl rfl, as⟩
       · rcases ex with ⟨s', sS, as⟩
         exact ⟨s', Or.inr sS, as⟩
-    · apply Or.inr; simp at m 
+    · apply Or.inr; simp at m
       rcases(IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
     · simp at m IH ⊢; apply IH _ _ rfl m
@@ -1877,7 +1877,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
   by
   cases' exists_results_of_mem ma with n h; clear ma; revert a S T
   apply Nat.strong_induction_on n _
-  intro n IH a S T ST ra; simp [destruct_join] at ra ;
+  intro n IH a S T ST ra; simp [destruct_join] at ra;
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
     let ⟨p, mT, rop⟩ := Computation.exists_of_liftRel_left (lift_rel_destruct ST) rs1.Mem
@@ -1886,7 +1886,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
       simp only [destruct_join] <;>
         exact ⟨none, mem_bind mT (ret_mem _), by rw [eq_of_ret_mem rs2.mem] <;> trivial⟩
     | some (s, S'), some (t, T'), ⟨st, ST'⟩, rs1, rs2, mT => by
-      simp [destruct_append] at rs2  <;>
+      simp [destruct_append] at rs2 <;>
         exact
           let ⟨k1, rs3, ek⟩ := of_results_think rs2
           let ⟨o', m1, n1, rs4, rs5, ek1⟩ := of_results_bind rs3
@@ -1904,7 +1904,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
                 apply think_mem; apply mem_bind mt; exact mb
           | some (a, s'), some (b, t'), ⟨ab, st'⟩, rs4, rs5, mt =>
             by
-            simp at rs5 
+            simp at rs5
             refine' ⟨some (b, append t' (join T')), _, _⟩
             · simp [destruct_join]; apply mem_bind mT; simp [destruct_append]
               apply think_mem; apply mem_bind mt; apply ret_mem
Diff
@@ -1183,7 +1183,7 @@ theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s :=
 #print Stream'.WSeq.mem_of_mem_tail /-
 theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s :=
   by
-  intro h; have := h; cases' h with n e; revert s; simp [Stream'.nth]
+  intro h; have := h; cases' h with n e; revert s; simp [Stream'.get]
   induction' n with n IH <;> intro s <;> apply s.rec_on _ (fun x s => _) fun s => _ <;>
         repeat' simp <;>
       intro m e <;>
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2017 Microsoft Corporation. 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.Seq.Seq
+import Data.List.Basic
+import Data.Seq.Seq
 
 #align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
 
Diff
@@ -692,10 +692,10 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
   have h2 := lift_rel_destruct h2
   refine'
     Computation.liftRel_def.2
-      ⟨(Computation.terminates_of_LiftRel h1).trans (Computation.terminates_of_LiftRel h2),
+      ⟨(Computation.terminates_of_liftRel h1).trans (Computation.terminates_of_liftRel h2),
         fun a c ha hc => _⟩
   rcases h1.left ha with ⟨b, hb, t1⟩
-  have t2 := Computation.rel_of_LiftRel h2 hb hc
+  have t2 := Computation.rel_of_liftRel h2 hb hc
   cases' a with a <;> cases' c with c
   · trivial
   · cases b; · cases t2; · cases t1
@@ -1880,7 +1880,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
   intro n IH a S T ST ra; simp [destruct_join] at ra ;
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
-    let ⟨p, mT, rop⟩ := Computation.exists_of_LiftRel_left (lift_rel_destruct ST) rs1.Mem
+    let ⟨p, mT, rop⟩ := Computation.exists_of_liftRel_left (lift_rel_destruct ST) rs1.Mem
     match o, p, rop, rs1, rs2, mT with
     | none, none, _, rs1, rs2, mT => by
       simp only [destruct_join] <;>
@@ -1890,7 +1890,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
         exact
           let ⟨k1, rs3, ek⟩ := of_results_think rs2
           let ⟨o', m1, n1, rs4, rs5, ek1⟩ := of_results_bind rs3
-          let ⟨p', mt, rop'⟩ := Computation.exists_of_LiftRel_left (lift_rel_destruct st) rs4.Mem
+          let ⟨p', mt, rop'⟩ := Computation.exists_of_liftRel_left (lift_rel_destruct st) rs4.Mem
           match o', p', rop', rs4, rs5, mt with
           | none, none, _, rs4, rs5', mt =>
             by
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2017 Microsoft Corporation. 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.wseq
-! 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.Seq.Seq
 
+#align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
 namespace Stream'
 
 open Function
Diff
@@ -481,15 +481,15 @@ def scanl (f : α → β → α) (a : α) (s : WSeq β) : WSeq α :=
 /-- Get the weak sequence of initial segments of the input sequence -/
 def inits (s : WSeq α) : WSeq (List α) :=
   cons [] <|
-    @Seq.corec (Option (List α)) (Dlist α × WSeq α)
+    @Seq.corec (Option (List α)) (Std.DList α × WSeq α)
       (fun ⟨l, s⟩ =>
         match Seq.destruct s with
         | none => none
         | some (none, s') => some (none, l, s')
         | some (some a, s') =>
-          let l' := l.concat a
+          let l' := l.push a
           some (some l'.toList, l', s'))
-      (Dlist.empty, s)
+      (Std.DList.empty, s)
 #align stream.wseq.inits Stream'.WSeq.inits
 -/
 
Diff
@@ -624,7 +624,6 @@ theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β
 #align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff
 -/
 
--- mathport name: equiv
 infixl:50 " ~ " => Equiv
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -752,7 +751,6 @@ theorem Equiv.equivalence : Equivalence (@Equiv α) :=
 
 open Computation
 
--- mathport name: exprreturn
 local notation "return" => Computation.pure
 
 #print Stream'.WSeq.destruct_nil /-
@@ -1736,12 +1734,14 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 -/
 
+#print Stream'.WSeq.exists_of_mem_bind /-
 theorem exists_of_mem_bind {s : WSeq α} {f : α → WSeq β} {b} (h : b ∈ bind s f) :
     ∃ a ∈ s, b ∈ f a :=
   let ⟨t, tm, bt⟩ := exists_of_mem_join h
   let ⟨a, as, e⟩ := exists_of_mem_map tm
   ⟨a, as, by rwa [e]⟩
 #align stream.wseq.exists_of_mem_bind Stream'.WSeq.exists_of_mem_bind
+-/
 
 #print Stream'.WSeq.destruct_map /-
 theorem destruct_map (f : α → β) (s : WSeq α) :
@@ -1759,6 +1759,7 @@ theorem destruct_map (f : α → β) (s : WSeq α) :
 #align stream.wseq.destruct_map Stream'.WSeq.destruct_map
 -/
 
+#print Stream'.WSeq.liftRel_map /-
 theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
     {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2) (h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) :
     LiftRel S (map f1 s1) (map f2 s2) :=
@@ -1774,6 +1775,7 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
       · cases' a with a s <;> cases' b with b t; cases' h with r h
         exact ⟨h2 r, s, rfl, t, rfl, h⟩⟩
 #align stream.wseq.lift_rel_map Stream'.WSeq.liftRel_map
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1947,11 +1949,13 @@ theorem join_congr {S T : WSeq (WSeq α)} (h : LiftRel Equiv S T) : join S ~ joi
 #align stream.wseq.join_congr Stream'.WSeq.join_congr
 -/
 
+#print Stream'.WSeq.liftRel_bind /-
 theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
     {f1 : α → WSeq γ} {f2 : β → WSeq δ} (h1 : LiftRel R s1 s2)
     (h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
   liftRel_join _ (liftRel_map _ _ h1 @h2)
 #align stream.wseq.lift_rel_bind Stream'.WSeq.liftRel_bind
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
Diff
@@ -657,7 +657,8 @@ theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (Lif
 #print Stream'.WSeq.LiftRelO.swap /-
 theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) :=
   by
-  funext x y <;> cases' x with x <;> [skip;cases x] <;> · cases' y with y <;> [skip;cases y] <;> rfl
+  funext x y <;> cases' x with x <;> [skip; cases x] <;>
+    · cases' y with y <;> [skip; cases y] <;> rfl
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
 -/
 
@@ -681,7 +682,7 @@ theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap
 theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
   fun s1 s2 (h : swap (LiftRel R) s2 s1) => by
   rwa [lift_rel.swap,
-    show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h
+    show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h 
 #align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm
 -/
 
@@ -1025,9 +1026,9 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
   (head_terminates_iff _).2 <|
     by
     rcases(head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩
-    simp [tail] at h
+    simp [tail] at h 
     rcases exists_of_mem_bind h with ⟨s', h1, h2⟩
-    unfold Functor.map at h1
+    unfold Functor.map at h1 
     exact
       let ⟨t, h3, h4⟩ := Computation.exists_of_mem_map h1
       Computation.terminates_of_mem h3
@@ -1037,10 +1038,10 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
 #print Stream'.WSeq.destruct_some_of_destruct_tail_some /-
 theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) :
     ∃ a', some a' ∈ destruct s := by
-  unfold tail Functor.map at h; simp at h
+  unfold tail Functor.map at h ; simp at h 
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
   rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
-  cases' t' with t' <;> rw [← ht2] at td <;> simp at td
+  cases' t' with t' <;> rw [← ht2] at td  <;> simp at td 
   · have := mem_unique td (ret_mem _); contradiction
   · exact ⟨_, ht'⟩
 #align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some
@@ -1049,7 +1050,7 @@ theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ de
 #print Stream'.WSeq.head_some_of_head_tail_some /-
 theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) :
     ∃ a', some a' ∈ head s := by
-  unfold head at h
+  unfold head at h 
   rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
   cases' o with o <;> injection e with h'; clear e h'
   cases' destruct_some_of_destruct_tail_some md with a am
@@ -1061,7 +1062,7 @@ theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail
 theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) :
     ∃ a', some a' ∈ head s := by
   revert a; induction' n with n IH <;> intros
-  exacts[⟨_, h⟩,
+  exacts [⟨_, h⟩,
     let ⟨a', h'⟩ := head_some_of_head_tail_some h
     IH h']
 #align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some
@@ -1087,7 +1088,7 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
     by
     cases e : Computation.get (nth s (n + 1)); · assumption
     have := mem_of_get_eq _ e
-    simp [nth] at this h; cases' head_some_of_head_tail_some this with a' h'
+    simp [nth] at this h ; cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
     contradiction⟩
 #align stream.wseq.to_seq Stream'.WSeq.toSeq
@@ -1096,8 +1097,8 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
 #print Stream'.WSeq.get?_terminates_le /-
 theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
     Terminates (get? s n) → Terminates (get? s m) := by
-  induction' h with m' h IH <;>
-    [exact id;exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
+  induction' h with m' h IH <;> [exact id;
+    exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
 #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le
 -/
 
@@ -1135,7 +1136,7 @@ theorem mem_think (s : WSeq α) (a) : a ∈ think s ↔ a ∈ s :=
   change (some (some a) ∈ some none::f) ↔ some (some a) ∈ f
   constructor <;> intro h
   · apply (Stream'.eq_or_mem_of_mem_cons h).resolve_left
-    intro ; injections
+    intro; injections
   · apply Stream'.mem_cons_of_mem _ h
 #align stream.wseq.mem_think Stream'.WSeq.mem_think
 -/
@@ -1150,7 +1151,7 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
             apply s.rec_on _ (fun x s => _) fun s => _ <;>
           intro m <;>
         have := congr_arg Computation.destruct m <;>
-      simp at this <;>
+      simp at this  <;>
     cases' this with i1 i2
   · rw [i1, i2]
     cases' s' with f al
@@ -1213,7 +1214,7 @@ theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s :=
     cases' o with o <;> injection h2 with h'
     cases' o with a' s'
     exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm)
-  · have := @IH (tail s); rw [nth_tail] at this
+  · have := @IH (tail s); rw [nth_tail] at this 
     exact mem_of_mem_tail (this h)
 #align stream.wseq.nth_mem Stream'.WSeq.get?_mem
 -/
@@ -1239,8 +1240,8 @@ theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) :
     rcases(head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩
     have := Computation.mem_unique (Computation.mem_map _ om) h
     cases' o with o <;> injection this with i
-    cases' o with a' s'; dsimp at i
-    rw [i] at om; exact ⟨_, om⟩⟩
+    cases' o with a' s'; dsimp at i 
+    rw [i] at om ; exact ⟨_, om⟩⟩
 #align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem
 -/
 
@@ -1271,7 +1272,7 @@ theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t
 
 #print Stream'.WSeq.exists_of_liftRel_right /-
 theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) :
-    ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H <;> exact exists_of_lift_rel_left H h
+    ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H  <;> exact exists_of_lift_rel_left H h
 #align stream.wseq.exists_of_lift_rel_right Stream'.WSeq.exists_of_liftRel_right
 -/
 
@@ -1491,7 +1492,7 @@ theorem length_eq_map (s : WSeq α) : length s = Computation.map List.length (to
   refine'
     Computation.eq_of_bisim
       (fun c1 c2 =>
-        ∃ (l : List α)(s : wseq α),
+        ∃ (l : List α) (s : wseq α),
           c1 = Computation.corec length._match_2 (l.length, s) ∧
             c2 = Computation.map List.length (Computation.corec to_list._match_2 (l, s)))
       _ ⟨[], s, rfl, rfl⟩
@@ -1552,7 +1553,7 @@ theorem toList'_map (l : List α) (s : WSeq α) :
   refine'
     Computation.eq_of_bisim
       (fun c1 c2 =>
-        ∃ (l' : List α)(s : wseq α),
+        ∃ (l' : List α) (s : wseq α),
           c1 = Computation.corec to_list._match_2 (l' ++ l, s) ∧
             c2 = Computation.map ((· ++ ·) l.reverse) (Computation.corec to_list._match_2 (l', s)))
       _ ⟨[], s, rfl, rfl⟩
@@ -1713,25 +1714,25 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
     from fun S h => (this _ h nil S (by simp) (by simp [h])).resolve_left (not_mem_nil _)
   intro ss h; apply mem_rec_on h (fun b ss o => _) fun ss IH => _ <;> intro s S
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
-        try cases this <;> try contradiction
+                intro ej m <;> simp at ej  <;> have := congr_arg seq.destruct ej <;>
+          simp at this  <;> try cases this <;> try contradiction
     substs b' ss
-    simp at m⊢
+    simp at m ⊢
     cases' o with e IH; · simp [e]
     cases' m with e m; · simp [e]
     exact Or.imp_left Or.inr (IH _ _ rfl m)
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
-        try try have := this.1; contradiction <;> subst ss
-    · apply Or.inr; simp at m⊢
+                intro ej m <;> simp at ej  <;> have := congr_arg seq.destruct ej <;>
+          simp at this  <;> try try have := this.1; contradiction <;> subst ss
+    · apply Or.inr; simp at m ⊢
       cases' IH s S rfl m with as ex
       · exact ⟨s, Or.inl rfl, as⟩
       · rcases ex with ⟨s', sS, as⟩
         exact ⟨s', Or.inr sS, as⟩
-    · apply Or.inr; simp at m
+    · apply Or.inr; simp at m 
       rcases(IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
-    · simp at m IH⊢; apply IH _ _ rfl m
+    · simp at m IH ⊢; apply IH _ _ rfl m
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 -/
 
@@ -1877,7 +1878,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
   by
   cases' exists_results_of_mem ma with n h; clear ma; revert a S T
   apply Nat.strong_induction_on n _
-  intro n IH a S T ST ra; simp [destruct_join] at ra;
+  intro n IH a S T ST ra; simp [destruct_join] at ra ;
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
     let ⟨p, mT, rop⟩ := Computation.exists_of_LiftRel_left (lift_rel_destruct ST) rs1.Mem
@@ -1886,7 +1887,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
       simp only [destruct_join] <;>
         exact ⟨none, mem_bind mT (ret_mem _), by rw [eq_of_ret_mem rs2.mem] <;> trivial⟩
     | some (s, S'), some (t, T'), ⟨st, ST'⟩, rs1, rs2, mT => by
-      simp [destruct_append] at rs2 <;>
+      simp [destruct_append] at rs2  <;>
         exact
           let ⟨k1, rs3, ek⟩ := of_results_think rs2
           let ⟨o', m1, n1, rs4, rs5, ek1⟩ := of_results_bind rs3
@@ -1904,7 +1905,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
                 apply think_mem; apply mem_bind mt; exact mb
           | some (a, s'), some (b, t'), ⟨ab, st'⟩, rs4, rs5, mt =>
             by
-            simp at rs5
+            simp at rs5 
             refine' ⟨some (b, append t' (join T')), _, _⟩
             · simp [destruct_join]; apply mem_bind mT; simp [destruct_append]
               apply think_mem; apply mem_bind mt; apply ret_mem
@@ -1929,7 +1930,7 @@ theorem liftRel_join (R : α → β → Prop) {S : WSeq (WSeq α)} {T : WSeq (WS
       | some (a, s), some (b, t), ⟨h1, h2⟩ => by simp <;> exact ⟨h1, s, t, S, rfl, T, rfl, h2, ST⟩
       | none, none, _ => by
         dsimp [destruct_append.aux, Computation.LiftRel]; constructor
-        · intro ; apply lift_rel_join.lem _ ST fun _ _ => id
+        · intro; apply lift_rel_join.lem _ ST fun _ _ => id
         · intro b mb
           rw [← lift_rel_o.swap]; apply lift_rel_join.lem (swap R)
           · rw [← lift_rel.swap R, ← lift_rel.swap]; apply ST
@@ -2005,7 +2006,7 @@ theorem join_append (S T : WSeq (WSeq α)) : join (append S T) ~ append (join S)
   apply
     lift_rel_rec
       (fun c1 c2 =>
-        ∃ (s : wseq α)(S T : _),
+        ∃ (s : wseq α) (S T : _),
           c1 = destruct (append s (join (append S T))) ∧
             c2 = destruct (append s (append (join S) (join T))))
       _ _ _
Diff
@@ -1735,12 +1735,6 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 -/
 
-/- warning: stream.wseq.exists_of_mem_bind -> Stream'.WSeq.exists_of_mem_bind is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {s : Stream'.WSeq.{u1} α} {f : α -> (Stream'.WSeq.{u2} β)} {b : β}, (Membership.Mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (Stream'.WSeq.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) (fun (H : Membership.Mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) => Membership.Mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (f a))))
-but is expected to have type
-  forall {α : Type.{u1}} {β : Type.{u2}} {s : Stream'.WSeq.{u1} α} {f : α -> (Stream'.WSeq.{u2} β)} {b : β}, (Membership.mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (Stream'.WSeq.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) (Membership.mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (f a))))
-Case conversion may be inaccurate. Consider using '#align stream.wseq.exists_of_mem_bind Stream'.WSeq.exists_of_mem_bindₓ'. -/
 theorem exists_of_mem_bind {s : WSeq α} {f : α → WSeq β} {b} (h : b ∈ bind s f) :
     ∃ a ∈ s, b ∈ f a :=
   let ⟨t, tm, bt⟩ := exists_of_mem_join h
@@ -1764,12 +1758,6 @@ theorem destruct_map (f : α → β) (s : WSeq α) :
 #align stream.wseq.destruct_map Stream'.WSeq.destruct_map
 -/
 
-/- warning: stream.wseq.lift_rel_map -> Stream'.WSeq.liftRel_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u1} α} {s2 : Stream'.WSeq.{u2} β} {f1 : α -> γ} {f2 : β -> δ}, (Stream'.WSeq.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (Stream'.WSeq.map.{u1, u3} α γ f1 s1) (Stream'.WSeq.map.{u2, u4} β δ f2 s2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u2} α} {s2 : Stream'.WSeq.{u3} β} {f1 : α -> γ} {f2 : β -> δ}, (Stream'.WSeq.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (Stream'.WSeq.map.{u2, u4} α γ f1 s1) (Stream'.WSeq.map.{u3, u1} β δ f2 s2))
-Case conversion may be inaccurate. Consider using '#align stream.wseq.lift_rel_map Stream'.WSeq.liftRel_mapₓ'. -/
 theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
     {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2) (h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) :
     LiftRel S (map f1 s1) (map f2 s2) :=
@@ -1958,12 +1946,6 @@ theorem join_congr {S T : WSeq (WSeq α)} (h : LiftRel Equiv S T) : join S ~ joi
 #align stream.wseq.join_congr Stream'.WSeq.join_congr
 -/
 
-/- warning: stream.wseq.lift_rel_bind -> Stream'.WSeq.liftRel_bind is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u1} α} {s2 : Stream'.WSeq.{u2} β} {f1 : α -> (Stream'.WSeq.{u3} γ)} {f2 : β -> (Stream'.WSeq.{u4} δ)}, (Stream'.WSeq.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (Stream'.WSeq.bind.{u1, u3} α γ s1 f1) (Stream'.WSeq.bind.{u2, u4} β δ s2 f2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u2} α} {s2 : Stream'.WSeq.{u3} β} {f1 : α -> (Stream'.WSeq.{u4} γ)} {f2 : β -> (Stream'.WSeq.{u1} δ)}, (Stream'.WSeq.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (Stream'.WSeq.bind.{u2, u4} α γ s1 f1) (Stream'.WSeq.bind.{u3, u1} β δ s2 f2))
-Case conversion may be inaccurate. Consider using '#align stream.wseq.lift_rel_bind Stream'.WSeq.liftRel_bindₓ'. -/
 theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
     {f1 : α → WSeq γ} {f2 : β → WSeq δ} (h1 : LiftRel R s1 s2)
     (h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
Diff
@@ -616,16 +616,11 @@ theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β
       LiftRel R s t ∨ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t),
       Or.inr h, fun s t h =>
       by
-      have h : Computation.LiftRel (lift_rel_o R (lift_rel R)) (destruct s) (destruct t) :=
-        by
-        cases' h with h h
-        exact lift_rel_destruct h
-        assumption
+      have h : Computation.LiftRel (lift_rel_o R (lift_rel R)) (destruct s) (destruct t) := by
+        cases' h with h h; exact lift_rel_destruct h; assumption
       apply Computation.LiftRel.imp _ _ _ h
-      intro a b
-      apply lift_rel_o.imp_right
-      intro s t
-      apply Or.inl⟩⟩
+      intro a b; apply lift_rel_o.imp_right
+      intro s t; apply Or.inl⟩⟩
 #align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff
 -/
 
@@ -706,21 +701,11 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
   have t2 := Computation.rel_of_LiftRel h2 hb hc
   cases' a with a <;> cases' c with c
   · trivial
-  · cases b
-    · cases t2
-    · cases t1
-  · cases a
-    cases' b with b
-    · cases t1
-    · cases b
-      cases t2
-  · cases' a with a s
-    cases' b with b
-    · cases t1
-    cases' b with b t
-    cases' c with c u
-    cases' t1 with ab st
-    cases' t2 with bc tu
+  · cases b; · cases t2; · cases t1
+  · cases a; cases' b with b; · cases t1; · cases b; cases t2
+  · cases' a with a s; cases' b with b; · cases t1
+    cases' b with b t; cases' c with c u
+    cases' t1 with ab st; cases' t2 with bc tu
     exact ⟨H ab bc, t, st, tu⟩
 #align stream.wseq.lift_rel.trans Stream'.WSeq.LiftRel.trans
 -/
@@ -836,8 +821,7 @@ theorem flatten_pure (s : WSeq α) : flatten (return s) = s :=
   refine' seq.eq_of_bisim (fun s1 s2 => flatten (return s2) = s1) _ rfl
   intro s' s h; rw [← h]; simp [flatten]
   cases seq.destruct s; · simp
-  · cases' val with o s'
-    simp
+  · cases' val with o s'; simp
 #align stream.wseq.flatten_ret Stream'.WSeq.flatten_pure
 -/
 
@@ -946,21 +930,15 @@ theorem join_nil : join nil = (nil : WSeq α) :=
 
 #print Stream'.WSeq.join_think /-
 @[simp]
-theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) :=
-  by
-  simp [think, join]
-  unfold Functor.map
-  simp [join, seq1.ret]
+theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) := by simp [think, join];
+  unfold Functor.map; simp [join, seq1.ret]
 #align stream.wseq.join_think Stream'.WSeq.join_think
 -/
 
 #print Stream'.WSeq.join_cons /-
 @[simp]
-theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) :=
-  by
-  simp [think, join]
-  unfold Functor.map
-  simp [join, cons, append]
+theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) := by
+  simp [think, join]; unfold Functor.map; simp [join, cons, append]
 #align stream.wseq.join_cons Stream'.WSeq.join_cons
 -/
 
@@ -1063,8 +1041,7 @@ theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ de
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
   rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
   cases' t' with t' <;> rw [← ht2] at td <;> simp at td
-  · have := mem_unique td (ret_mem _)
-    contradiction
+  · have := mem_unique td (ret_mem _); contradiction
   · exact ⟨_, ht'⟩
 #align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some
 -/
@@ -1144,14 +1121,8 @@ theorem mem_rec_on {C : WSeq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a
   by
   apply seq.mem_rec_on M
   intro o s' h; cases' o with b
-  · apply h2
-    cases h
-    · contradiction
-    · assumption
-  · apply h1
-    apply Or.imp_left _ h
-    intro h
-    injection h
+  · apply h2; cases h; · contradiction; · assumption
+  · apply h1; apply Or.imp_left _ h; intro h; injection h
 #align stream.wseq.mem_rec_on Stream'.WSeq.mem_rec_on
 -/
 
@@ -1164,8 +1135,7 @@ theorem mem_think (s : WSeq α) (a) : a ∈ think s ↔ a ∈ s :=
   change (some (some a) ∈ some none::f) ↔ some (some a) ∈ f
   constructor <;> intro h
   · apply (Stream'.eq_or_mem_of_mem_cons h).resolve_left
-    intro
-    injections
+    intro ; injections
   · apply Stream'.mem_cons_of_mem _ h
 #align stream.wseq.mem_think Stream'.WSeq.mem_think
 -/
@@ -1184,17 +1154,14 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
     cases' this with i1 i2
   · rw [i1, i2]
     cases' s' with f al
-    unfold cons Membership.Mem wseq.mem seq.mem seq.cons
-    simp
+    unfold cons Membership.Mem wseq.mem seq.mem seq.cons; simp
     have h_a_eq_a' : a = a' ↔ some (some a) = some (some a') := by simp
     rw [h_a_eq_a']
     refine' ⟨Stream'.eq_or_mem_of_mem_cons, fun o => _⟩
     · cases' o with e m
-      · rw [e]
-        apply Stream'.mem_cons
+      · rw [e]; apply Stream'.mem_cons
       · exact Stream'.mem_cons_of_mem _ m
-  · simp
-    exact IH this
+  · simp; exact IH this
 #align stream.wseq.eq_or_mem_iff_mem Stream'.WSeq.eq_or_mem_iff_mem
 -/
 
@@ -1227,10 +1194,7 @@ theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s :=
     injections
   · exact Or.inr m
   · exact Or.inr m
-  · apply IH m
-    rw [e]
-    cases tail s
-    rfl
+  · apply IH m; rw [e]; cases tail s; rfl
 #align stream.wseq.mem_of_mem_tail Stream'.WSeq.mem_of_mem_tail
 -/
 
@@ -1249,8 +1213,7 @@ theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s :=
     cases' o with o <;> injection h2 with h'
     cases' o with a' s'
     exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm)
-  · have := @IH (tail s)
-    rw [nth_tail] at this
+  · have := @IH (tail s); rw [nth_tail] at this
     exact mem_of_mem_tail (this h)
 #align stream.wseq.nth_mem Stream'.WSeq.get?_mem
 -/
@@ -1259,21 +1222,12 @@ theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s :=
 theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ get? s n :=
   by
   apply mem_rec_on h
-  · intro a' s' h
-    cases' h with h h
-    · exists 0
-      simp [nth]
-      rw [h]
-      apply ret_mem
-    · cases' h with n h
-      exists n + 1
-      simp [nth]
-      exact h
-  · intro s' h
-    cases' h with n h
-    exists n
-    simp [nth]
-    apply think_mem h
+  · intro a' s' h; cases' h with h h
+    · exists 0; simp [nth]; rw [h]; apply ret_mem
+    · cases' h with n h; exists n + 1
+      simp [nth]; exact h
+  · intro s' h; cases' h with n h
+    exists n; simp [nth]; apply think_mem h
 #align stream.wseq.exists_nth_of_mem Stream'.WSeq.exists_get?_of_mem
 -/
 
@@ -1413,13 +1367,9 @@ theorem head_congr : ∀ {s t : WSeq α}, s ~ t → head s ~ head t :=
   rcases l dsm with ⟨dt, dtm, dst⟩
   cases' ds with a <;> cases' dt with b
   · apply Computation.mem_map _ dtm
-  · cases b
-    cases dst
-  · cases a
-    cases dst
-  · cases' a with a s'
-    cases' b with b t'
-    rw [dst.left]
+  · cases b; cases dst
+  · cases a; cases dst
+  · cases' a with a s'; cases' b with b t'; rw [dst.left]
     exact @Computation.mem_map _ _ (@Functor.map _ _ (α × wseq α) _ Prod.fst) _ (destruct t) dtm
 #align stream.wseq.head_congr Stream'.WSeq.head_congr
 -/
@@ -1429,9 +1379,7 @@ theorem head_congr : ∀ {s t : WSeq α}, s ~ t → head s ~ head t :=
 theorem flatten_equiv {c : Computation (WSeq α)} {s} (h : s ∈ c) : flatten c ~ s :=
   by
   apply Computation.memRecOn h; · simp
-  · intro s'
-    apply Equiv.trans
-    simp [think_equiv]
+  · intro s'; apply Equiv.trans; simp [think_equiv]
 #align stream.wseq.flatten_equiv Stream'.WSeq.flatten_equiv
 -/
 
@@ -1469,11 +1417,8 @@ theorem tail_congr {s t : WSeq α} (h : s ~ t) : tail s ~ tail t :=
   cases' a with a <;> cases' b with b
   · trivial
   · cases h
-  · cases a
-    cases h
-  · cases' a with a s'
-    cases' b with b t'
-    exact h.right
+  · cases a; cases h
+  · cases' a with a s'; cases' b with b t'; exact h.right
 #align stream.wseq.tail_congr Stream'.WSeq.tail_congr
 -/
 
@@ -1527,8 +1472,7 @@ theorem Equiv.ext {s t : WSeq α} (h : ∀ n, get? s n ~ get? t n) : s ~ t :=
       · trivial
       · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb))
       · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb))
-      · cases' a with a s'
-        cases' b with b t'
+      · cases' a with a s'; cases' b with b t'
         injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) with
           ab
         refine' ⟨ab, fun n => _⟩
@@ -1536,8 +1480,7 @@ theorem Equiv.ext {s t : WSeq α} (h : ∀ n, get? s n ~ get? t n) : s ~ t :=
           (nth_congr (flatten_equiv (Computation.mem_map _ ma)) n).symm.trans
             ((_ : nth (tail s) n ~ nth (tail t) n).trans
               (nth_congr (flatten_equiv (Computation.mem_map _ mb)) n))
-        rw [nth_tail, nth_tail]
-        apply h⟩
+        rw [nth_tail, nth_tail]; apply h⟩
 #align stream.wseq.equiv.ext Stream'.WSeq.Equiv.ext
 -/
 
@@ -1774,26 +1717,21 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
         try cases this <;> try contradiction
     substs b' ss
     simp at m⊢
-    cases' o with e IH
-    · simp [e]
-    cases' m with e m
-    · simp [e]
+    cases' o with e IH; · simp [e]
+    cases' m with e m; · simp [e]
     exact Or.imp_left Or.inr (IH _ _ rfl m)
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
                 intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
         try try have := this.1; contradiction <;> subst ss
-    · apply Or.inr
-      simp at m⊢
+    · apply Or.inr; simp at m⊢
       cases' IH s S rfl m with as ex
       · exact ⟨s, Or.inl rfl, as⟩
       · rcases ex with ⟨s', sS, as⟩
         exact ⟨s', Or.inr sS, as⟩
-    · apply Or.inr
-      simp at m
+    · apply Or.inr; simp at m
       rcases(IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
-    · simp at m IH⊢
-      apply IH _ _ rfl m
+    · simp at m IH⊢; apply IH _ _ rfl m
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 -/
 
@@ -1819,9 +1757,7 @@ theorem destruct_map (f : α → β) (s : WSeq α) :
       ∃ s,
         c1 = destruct (map f s) ∧
           c2 = Computation.map (Option.map (Prod.map f (map f))) (destruct s)
-  · intro c1 c2 h
-    cases' h with s h
-    rw [h.left, h.right]
+  · intro c1 c2 h; cases' h with s h; rw [h.left, h.right]
     apply s.rec_on _ (fun a s => _) fun s => _ <;> simp
     exact ⟨s, rfl, rfl⟩
   · exact ⟨s, rfl, rfl⟩
@@ -1846,8 +1782,7 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
       cases' o with a <;> cases' p with b <;> simp
       · cases b <;> cases h
       · cases a <;> cases h
-      · cases' a with a s <;> cases' b with b t
-        cases' h with r h
+      · cases' a with a s <;> cases' b with b t; cases' h with r h
         exact ⟨h2 r, s, rfl, t, rfl, h⟩⟩
 #align stream.wseq.lift_rel_map Stream'.WSeq.liftRel_map
 
@@ -1931,18 +1866,13 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : WSeq α} {t1 t2 : WSeq
       apply Computation.liftRel_bind _ _ (lift_rel_destruct h)
       intro o p h
       cases' o with a <;> cases' p with b
-      · simp
-        apply Computation.LiftRel.imp _ _ _ (lift_rel_destruct h2)
-        intro a b
-        apply lift_rel_o.imp_right
-        intro s t
-        apply Or.inl
+      · simp; apply Computation.LiftRel.imp _ _ _ (lift_rel_destruct h2)
+        intro a b; apply lift_rel_o.imp_right
+        intro s t; apply Or.inl
       · cases b <;> cases h
       · cases a <;> cases h
-      · cases' a with a s <;> cases' b with b t
-        cases' h with r h
-        simp
-        exact ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
+      · cases' a with a s <;> cases' b with b t; cases' h with r h
+        simp; exact ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
 #align stream.wseq.lift_rel_append Stream'.WSeq.liftRel_append
 -/
 
@@ -1982,22 +1912,14 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
               apply Nat.lt_succ_of_le (Nat.le_add_right _ _)
             let ⟨ob, mb, rob⟩ := IH _ this ST' rs5'
             refine' ⟨ob, _, rob⟩ <;>
-              · simp [destruct_join]
-                apply mem_bind mT
-                simp [destruct_append]
-                apply think_mem
-                apply mem_bind mt
-                exact mb
+              · simp [destruct_join]; apply mem_bind mT; simp [destruct_append]
+                apply think_mem; apply mem_bind mt; exact mb
           | some (a, s'), some (b, t'), ⟨ab, st'⟩, rs4, rs5, mt =>
             by
             simp at rs5
             refine' ⟨some (b, append t' (join T')), _, _⟩
-            · simp [destruct_join]
-              apply mem_bind mT
-              simp [destruct_append]
-              apply think_mem
-              apply mem_bind mt
-              apply ret_mem
+            · simp [destruct_join]; apply mem_bind mT; simp [destruct_append]
+              apply think_mem; apply mem_bind mt; apply ret_mem
             rw [eq_of_ret_mem rs5.mem]
             exact ⟨ab, HU _ _ ⟨s', t', S', T', rfl, rfl, st', ST'⟩⟩
 #align stream.wseq.lift_rel_join.lem Stream'.WSeq.liftRel_join.lem
@@ -2019,13 +1941,10 @@ theorem liftRel_join (R : α → β → Prop) {S : WSeq (WSeq α)} {T : WSeq (WS
       | some (a, s), some (b, t), ⟨h1, h2⟩ => by simp <;> exact ⟨h1, s, t, S, rfl, T, rfl, h2, ST⟩
       | none, none, _ => by
         dsimp [destruct_append.aux, Computation.LiftRel]; constructor
-        · intro
-          apply lift_rel_join.lem _ ST fun _ _ => id
+        · intro ; apply lift_rel_join.lem _ ST fun _ _ => id
         · intro b mb
-          rw [← lift_rel_o.swap]
-          apply lift_rel_join.lem (swap R)
-          · rw [← lift_rel.swap R, ← lift_rel.swap]
-            apply ST
+          rw [← lift_rel_o.swap]; apply lift_rel_join.lem (swap R)
+          · rw [← lift_rel.swap R, ← lift_rel.swap]; apply ST
           · rw [← lift_rel.swap R, ← lift_rel.swap (lift_rel R)]
             exact fun s1 s2 ⟨s, t, S, T, h1, h2, st, ST⟩ => ⟨t, s, T, S, h2, h1, st, ST⟩
           · exact mb⟩
Diff
@@ -662,8 +662,7 @@ theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (Lif
 #print Stream'.WSeq.LiftRelO.swap /-
 theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) :=
   by
-  funext x y <;> cases' x with x <;> [skip, cases x] <;>
-    · cases' y with y <;> [skip, cases y] <;> rfl
+  funext x y <;> cases' x with x <;> [skip;cases x] <;> · cases' y with y <;> [skip;cases y] <;> rfl
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
 -/
 
@@ -1120,8 +1119,8 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
 #print Stream'.WSeq.get?_terminates_le /-
 theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
     Terminates (get? s n) → Terminates (get? s m) := by
-  induction' h with m' h IH <;> [exact id,
-    exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
+  induction' h with m' h IH <;>
+    [exact id;exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
 #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le
 -/
 
Diff
@@ -17,6 +17,7 @@ open Function
 
 universe u v w
 
+#print Stream'.WSeq /-
 /-
 coinductive wseq (α : Type u) : Type u
 | nil : wseq α
@@ -34,182 +35,238 @@ coinductive wseq (α : Type u) : Type u
   This model is appropriate for Haskell style lazy lists, and is closed
   under most interesting computation patterns on infinite lists,
   but conversely it is difficult to extract elements from it. -/
-def Wseq (α) :=
+def WSeq (α) :=
   Seq (Option α)
-#align stream.wseq Stream'.Wseq
+#align stream.wseq Stream'.WSeq
+-/
 
 namespace Wseq
 
 variable {α : Type u} {β : Type v} {γ : Type w}
 
+#print Stream'.WSeq.ofSeq /-
 /-- Turn a sequence into a weak sequence -/
-def ofSeq : Seq α → Wseq α :=
+def ofSeq : Seq α → WSeq α :=
   (· <$> ·) some
-#align stream.wseq.of_seq Stream'.Wseq.ofSeq
+#align stream.wseq.of_seq Stream'.WSeq.ofSeq
+-/
 
+#print Stream'.WSeq.ofList /-
 /-- Turn a list into a weak sequence -/
-def ofList (l : List α) : Wseq α :=
+def ofList (l : List α) : WSeq α :=
   ofSeq l
-#align stream.wseq.of_list Stream'.Wseq.ofList
+#align stream.wseq.of_list Stream'.WSeq.ofList
+-/
 
+#print Stream'.WSeq.ofStream /-
 /-- Turn a stream into a weak sequence -/
-def ofStream (l : Stream' α) : Wseq α :=
+def ofStream (l : Stream' α) : WSeq α :=
   ofSeq l
-#align stream.wseq.of_stream Stream'.Wseq.ofStream
+#align stream.wseq.of_stream Stream'.WSeq.ofStream
+-/
 
-instance coeSeq : Coe (Seq α) (Wseq α) :=
+#print Stream'.WSeq.coeSeq /-
+instance coeSeq : Coe (Seq α) (WSeq α) :=
   ⟨ofSeq⟩
-#align stream.wseq.coe_seq Stream'.Wseq.coeSeq
+#align stream.wseq.coe_seq Stream'.WSeq.coeSeq
+-/
 
-instance coeList : Coe (List α) (Wseq α) :=
+#print Stream'.WSeq.coeList /-
+instance coeList : Coe (List α) (WSeq α) :=
   ⟨ofList⟩
-#align stream.wseq.coe_list Stream'.Wseq.coeList
+#align stream.wseq.coe_list Stream'.WSeq.coeList
+-/
 
-instance coeStream : Coe (Stream' α) (Wseq α) :=
+#print Stream'.WSeq.coeStream /-
+instance coeStream : Coe (Stream' α) (WSeq α) :=
   ⟨ofStream⟩
-#align stream.wseq.coe_stream Stream'.Wseq.coeStream
+#align stream.wseq.coe_stream Stream'.WSeq.coeStream
+-/
 
+#print Stream'.WSeq.nil /-
 /-- The empty weak sequence -/
-def nil : Wseq α :=
+def nil : WSeq α :=
   Seq.nil
-#align stream.wseq.nil Stream'.Wseq.nil
+#align stream.wseq.nil Stream'.WSeq.nil
+-/
 
-instance : Inhabited (Wseq α) :=
+instance : Inhabited (WSeq α) :=
   ⟨nil⟩
 
+#print Stream'.WSeq.cons /-
 /-- Prepend an element to a weak sequence -/
-def cons (a : α) : Wseq α → Wseq α :=
+def cons (a : α) : WSeq α → WSeq α :=
   Seq.cons (some a)
-#align stream.wseq.cons Stream'.Wseq.cons
+#align stream.wseq.cons Stream'.WSeq.cons
+-/
 
+#print Stream'.WSeq.think /-
 /-- Compute for one tick, without producing any elements -/
-def think : Wseq α → Wseq α :=
+def think : WSeq α → WSeq α :=
   Seq.cons none
-#align stream.wseq.think Stream'.Wseq.think
+#align stream.wseq.think Stream'.WSeq.think
+-/
 
+#print Stream'.WSeq.destruct /-
 /-- Destruct a weak sequence, to (eventually possibly) produce either
   `none` for `nil` or `some (a, s)` if an element is produced. -/
-def destruct : Wseq α → Computation (Option (α × Wseq α)) :=
+def destruct : WSeq α → Computation (Option (α × WSeq α)) :=
   Computation.corec fun s =>
     match Seq.destruct s with
     | none => Sum.inl none
     | some (none, s') => Sum.inr s'
     | some (some a, s') => Sum.inl (some (a, s'))
-#align stream.wseq.destruct Stream'.Wseq.destruct
+#align stream.wseq.destruct Stream'.WSeq.destruct
+-/
 
+#print Stream'.WSeq.recOn /-
 /-- Recursion principle for weak sequences, compare with `list.rec_on`. -/
-def recOn {C : Wseq α → Sort v} (s : Wseq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s))
+def recOn {C : WSeq α → Sort v} (s : WSeq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s))
     (h3 : ∀ s, C (think s)) : C s :=
   Seq.recOn s h1 fun o => Option.recOn o h3 h2
-#align stream.wseq.rec_on Stream'.Wseq.recOn
+#align stream.wseq.rec_on Stream'.WSeq.recOn
+-/
 
+#print Stream'.WSeq.Mem /-
 /-- membership for weak sequences-/
-protected def Mem (a : α) (s : Wseq α) :=
+protected def Mem (a : α) (s : WSeq α) :=
   Seq.Mem (some a) s
-#align stream.wseq.mem Stream'.Wseq.Mem
+#align stream.wseq.mem Stream'.WSeq.Mem
+-/
 
-instance : Membership α (Wseq α) :=
-  ⟨Wseq.Mem⟩
+instance : Membership α (WSeq α) :=
+  ⟨WSeq.Mem⟩
 
+#print Stream'.WSeq.not_mem_nil /-
 theorem not_mem_nil (a : α) : a ∉ @nil α :=
   Seq.not_mem_nil a
-#align stream.wseq.not_mem_nil Stream'.Wseq.not_mem_nil
+#align stream.wseq.not_mem_nil Stream'.WSeq.not_mem_nil
+-/
 
+#print Stream'.WSeq.head /-
 /-- Get the head of a weak sequence. This involves a possibly
   infinite computation. -/
-def head (s : Wseq α) : Computation (Option α) :=
+def head (s : WSeq α) : Computation (Option α) :=
   Computation.map ((· <$> ·) Prod.fst) (destruct s)
-#align stream.wseq.head Stream'.Wseq.head
+#align stream.wseq.head Stream'.WSeq.head
+-/
 
+#print Stream'.WSeq.flatten /-
 /-- Encode a computation yielding a weak sequence into additional
   `think` constructors in a weak sequence -/
-def flatten : Computation (Wseq α) → Wseq α :=
+def flatten : Computation (WSeq α) → WSeq α :=
   Seq.corec fun c =>
     match Computation.destruct c with
     | Sum.inl s => Seq.omap return (Seq.destruct s)
     | Sum.inr c' => some (none, c')
-#align stream.wseq.flatten Stream'.Wseq.flatten
+#align stream.wseq.flatten Stream'.WSeq.flatten
+-/
 
+#print Stream'.WSeq.tail /-
 /-- Get the tail of a weak sequence. This doesn't need a `computation`
   wrapper, unlike `head`, because `flatten` allows us to hide this
   in the construction of the weak sequence itself. -/
-def tail (s : Wseq α) : Wseq α :=
+def tail (s : WSeq α) : WSeq α :=
   flatten <| (fun o => Option.recOn o nil Prod.snd) <$> destruct s
-#align stream.wseq.tail Stream'.Wseq.tail
+#align stream.wseq.tail Stream'.WSeq.tail
+-/
 
+#print Stream'.WSeq.drop /-
 /-- drop the first `n` elements from `s`. -/
-def drop (s : Wseq α) : ℕ → Wseq α
+def drop (s : WSeq α) : ℕ → WSeq α
   | 0 => s
   | n + 1 => tail (drop n)
-#align stream.wseq.drop Stream'.Wseq.drop
+#align stream.wseq.drop Stream'.WSeq.drop
+-/
 
 attribute [simp] drop
 
+#print Stream'.WSeq.get? /-
 /-- Get the nth element of `s`. -/
-def nth (s : Wseq α) (n : ℕ) : Computation (Option α) :=
+def get? (s : WSeq α) (n : ℕ) : Computation (Option α) :=
   head (drop s n)
-#align stream.wseq.nth Stream'.Wseq.nth
+#align stream.wseq.nth Stream'.WSeq.get?
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.toList /-
 /-- Convert `s` to a list (if it is finite and completes in finite time). -/
-def toList (s : Wseq α) : Computation (List α) :=
-  @Computation.corec (List α) (List α × Wseq α)
+def toList (s : WSeq α) : Computation (List α) :=
+  @Computation.corec (List α) (List α × WSeq α)
     (fun ⟨l, s⟩ =>
       match Seq.destruct s with
       | none => Sum.inl l.reverse
       | some (none, s') => Sum.inr (l, s')
       | some (some a, s') => Sum.inr (a::l, s'))
     ([], s)
-#align stream.wseq.to_list Stream'.Wseq.toList
+#align stream.wseq.to_list Stream'.WSeq.toList
+-/
 
+#print Stream'.WSeq.length /-
 /-- Get the length of `s` (if it is finite and completes in finite time). -/
-def length (s : Wseq α) : Computation ℕ :=
-  @Computation.corec ℕ (ℕ × Wseq α)
+def length (s : WSeq α) : Computation ℕ :=
+  @Computation.corec ℕ (ℕ × WSeq α)
     (fun ⟨n, s⟩ =>
       match Seq.destruct s with
       | none => Sum.inl n
       | some (none, s') => Sum.inr (n, s')
       | some (some a, s') => Sum.inr (n + 1, s'))
     (0, s)
-#align stream.wseq.length Stream'.Wseq.length
+#align stream.wseq.length Stream'.WSeq.length
+-/
 
+#print Stream'.WSeq.IsFinite /-
 /-- A weak sequence is finite if `to_list s` terminates. Equivalently,
   it is a finite number of `think` and `cons` applied to `nil`. -/
-class IsFinite (s : Wseq α) : Prop where
+class IsFinite (s : WSeq α) : Prop where
   out : (toList s).Terminates
-#align stream.wseq.is_finite Stream'.Wseq.IsFinite
+#align stream.wseq.is_finite Stream'.WSeq.IsFinite
+-/
 
-instance toList_terminates (s : Wseq α) [h : IsFinite s] : (toList s).Terminates :=
+#print Stream'.WSeq.toList_terminates /-
+instance toList_terminates (s : WSeq α) [h : IsFinite s] : (toList s).Terminates :=
   h.out
-#align stream.wseq.to_list_terminates Stream'.Wseq.toList_terminates
+#align stream.wseq.to_list_terminates Stream'.WSeq.toList_terminates
+-/
 
+#print Stream'.WSeq.get /-
 /-- Get the list corresponding to a finite weak sequence. -/
-def get (s : Wseq α) [IsFinite s] : List α :=
+def get (s : WSeq α) [IsFinite s] : List α :=
   (toList s).get
-#align stream.wseq.get Stream'.Wseq.get
+#align stream.wseq.get Stream'.WSeq.get
+-/
 
+#print Stream'.WSeq.Productive /-
 /-- A weak sequence is *productive* if it never stalls forever - there are
  always a finite number of `think`s between `cons` constructors.
  The sequence itself is allowed to be infinite though. -/
-class Productive (s : Wseq α) : Prop where
-  nth_terminates : ∀ n, (nth s n).Terminates
-#align stream.wseq.productive Stream'.Wseq.Productive
+class Productive (s : WSeq α) : Prop where
+  get?_terminates : ∀ n, (get? s n).Terminates
+#align stream.wseq.productive Stream'.WSeq.Productive
+-/
 
-theorem productive_iff (s : Wseq α) : Productive s ↔ ∀ n, (nth s n).Terminates :=
+#print Stream'.WSeq.productive_iff /-
+theorem productive_iff (s : WSeq α) : Productive s ↔ ∀ n, (get? s n).Terminates :=
   ⟨fun h => h.1, fun h => ⟨h⟩⟩
-#align stream.wseq.productive_iff Stream'.Wseq.productive_iff
+#align stream.wseq.productive_iff Stream'.WSeq.productive_iff
+-/
 
-instance nth_terminates (s : Wseq α) [h : Productive s] : ∀ n, (nth s n).Terminates :=
-  h.nth_terminates
-#align stream.wseq.nth_terminates Stream'.Wseq.nth_terminates
+#print Stream'.WSeq.get?_terminates /-
+instance get?_terminates (s : WSeq α) [h : Productive s] : ∀ n, (get? s n).Terminates :=
+  h.get?_terminates
+#align stream.wseq.nth_terminates Stream'.WSeq.get?_terminates
+-/
 
-instance head_terminates (s : Wseq α) [Productive s] : (head s).Terminates :=
-  s.nth_terminates 0
-#align stream.wseq.head_terminates Stream'.Wseq.head_terminates
+#print Stream'.WSeq.head_terminates /-
+instance head_terminates (s : WSeq α) [Productive s] : (head s).Terminates :=
+  s.get?_terminates 0
+#align stream.wseq.head_terminates Stream'.WSeq.head_terminates
+-/
 
+#print Stream'.WSeq.updateNth /-
 /-- Replace the `n`th element of `s` with `a`. -/
-def updateNth (s : Wseq α) (n : ℕ) (a : α) : Wseq α :=
-  @Seq.corec (Option α) (ℕ × Wseq α)
+def updateNth (s : WSeq α) (n : ℕ) (a : α) : WSeq α :=
+  @Seq.corec (Option α) (ℕ × WSeq α)
     (fun ⟨n, s⟩ =>
       match Seq.destruct s, n with
       | none, n => none
@@ -218,11 +275,13 @@ def updateNth (s : Wseq α) (n : ℕ) (a : α) : Wseq α :=
       | some (some a', s'), 1 => some (some a, 0, s')
       | some (some a', s'), n + 2 => some (some a', n + 1, s'))
     (n + 1, s)
-#align stream.wseq.update_nth Stream'.Wseq.updateNth
+#align stream.wseq.update_nth Stream'.WSeq.updateNth
+-/
 
+#print Stream'.WSeq.removeNth /-
 /-- Remove the `n`th element of `s`. -/
-def removeNth (s : Wseq α) (n : ℕ) : Wseq α :=
-  @Seq.corec (Option α) (ℕ × Wseq α)
+def removeNth (s : WSeq α) (n : ℕ) : WSeq α :=
+  @Seq.corec (Option α) (ℕ × WSeq α)
     (fun ⟨n, s⟩ =>
       match Seq.destruct s, n with
       | none, n => none
@@ -231,31 +290,39 @@ def removeNth (s : Wseq α) (n : ℕ) : Wseq α :=
       | some (some a', s'), 1 => some (none, 0, s')
       | some (some a', s'), n + 2 => some (some a', n + 1, s'))
     (n + 1, s)
-#align stream.wseq.remove_nth Stream'.Wseq.removeNth
+#align stream.wseq.remove_nth Stream'.WSeq.removeNth
+-/
 
+#print Stream'.WSeq.filterMap /-
 /-- Map the elements of `s` over `f`, removing any values that yield `none`. -/
-def filterMap (f : α → Option β) : Wseq α → Wseq β :=
+def filterMap (f : α → Option β) : WSeq α → WSeq β :=
   Seq.corec fun s =>
     match Seq.destruct s with
     | none => none
     | some (none, s') => some (none, s')
     | some (some a, s') => some (f a, s')
-#align stream.wseq.filter_map Stream'.Wseq.filterMap
+#align stream.wseq.filter_map Stream'.WSeq.filterMap
+-/
 
+#print Stream'.WSeq.filter /-
 /-- Select the elements of `s` that satisfy `p`. -/
-def filter (p : α → Prop) [DecidablePred p] : Wseq α → Wseq α :=
+def filter (p : α → Prop) [DecidablePred p] : WSeq α → WSeq α :=
   filterMap fun a => if p a then some a else none
-#align stream.wseq.filter Stream'.Wseq.filter
+#align stream.wseq.filter Stream'.WSeq.filter
+-/
 
+#print Stream'.WSeq.find /-
 -- example of infinite list manipulations
 /-- Get the first element of `s` satisfying `p`. -/
-def find (p : α → Prop) [DecidablePred p] (s : Wseq α) : Computation (Option α) :=
+def find (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation (Option α) :=
   head <| filter p s
-#align stream.wseq.find Stream'.Wseq.find
+#align stream.wseq.find Stream'.WSeq.find
+-/
 
+#print Stream'.WSeq.zipWith /-
 /-- Zip a function over two weak sequences -/
-def zipWith (f : α → β → γ) (s1 : Wseq α) (s2 : Wseq β) : Wseq γ :=
-  @Seq.corec (Option γ) (Wseq α × Wseq β)
+def zipWith (f : α → β → γ) (s1 : WSeq α) (s2 : WSeq β) : WSeq γ :=
+  @Seq.corec (Option γ) (WSeq α × WSeq β)
     (fun ⟨s1, s2⟩ =>
       match Seq.destruct s1, Seq.destruct s2 with
       | some (none, s1'), some (none, s2') => some (none, s1', s2')
@@ -264,37 +331,49 @@ def zipWith (f : α → β → γ) (s1 : Wseq α) (s2 : Wseq β) : Wseq γ :=
       | some (some a1, s1'), some (some a2, s2') => some (some (f a1 a2), s1', s2')
       | _, _ => none)
     (s1, s2)
-#align stream.wseq.zip_with Stream'.Wseq.zipWith
+#align stream.wseq.zip_with Stream'.WSeq.zipWith
+-/
 
+#print Stream'.WSeq.zip /-
 /-- Zip two weak sequences into a single sequence of pairs -/
-def zip : Wseq α → Wseq β → Wseq (α × β) :=
+def zip : WSeq α → WSeq β → WSeq (α × β) :=
   zipWith Prod.mk
-#align stream.wseq.zip Stream'.Wseq.zip
+#align stream.wseq.zip Stream'.WSeq.zip
+-/
 
+#print Stream'.WSeq.findIndexes /-
 /-- Get the list of indexes of elements of `s` satisfying `p` -/
-def findIndexes (p : α → Prop) [DecidablePred p] (s : Wseq α) : Wseq ℕ :=
-  (zip s (Stream'.nats : Wseq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none
-#align stream.wseq.find_indexes Stream'.Wseq.findIndexes
+def findIndexes (p : α → Prop) [DecidablePred p] (s : WSeq α) : WSeq ℕ :=
+  (zip s (Stream'.nats : WSeq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none
+#align stream.wseq.find_indexes Stream'.WSeq.findIndexes
+-/
 
+#print Stream'.WSeq.findIndex /-
 /-- Get the index of the first element of `s` satisfying `p` -/
-def findIndex (p : α → Prop) [DecidablePred p] (s : Wseq α) : Computation ℕ :=
+def findIndex (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation ℕ :=
   (fun o => Option.getD o 0) <$> head (findIndexes p s)
-#align stream.wseq.find_index Stream'.Wseq.findIndex
+#align stream.wseq.find_index Stream'.WSeq.findIndex
+-/
 
+#print Stream'.WSeq.indexOf /-
 /-- Get the index of the first occurrence of `a` in `s` -/
-def indexOf [DecidableEq α] (a : α) : Wseq α → Computation ℕ :=
+def indexOf [DecidableEq α] (a : α) : WSeq α → Computation ℕ :=
   findIndex (Eq a)
-#align stream.wseq.index_of Stream'.Wseq.indexOf
+#align stream.wseq.index_of Stream'.WSeq.indexOf
+-/
 
+#print Stream'.WSeq.indexesOf /-
 /-- Get the indexes of occurrences of `a` in `s` -/
-def indexesOf [DecidableEq α] (a : α) : Wseq α → Wseq ℕ :=
+def indexesOf [DecidableEq α] (a : α) : WSeq α → WSeq ℕ :=
   findIndexes (Eq a)
-#align stream.wseq.indexes_of Stream'.Wseq.indexesOf
+#align stream.wseq.indexes_of Stream'.WSeq.indexesOf
+-/
 
+#print Stream'.WSeq.union /-
 /-- `union s1 s2` is a weak sequence which interleaves `s1` and `s2` in
   some order (nondeterministically). -/
-def union (s1 s2 : Wseq α) : Wseq α :=
-  @Seq.corec (Option α) (Wseq α × Wseq α)
+def union (s1 s2 : WSeq α) : WSeq α :=
+  @Seq.corec (Option α) (WSeq α × WSeq α)
     (fun ⟨s1, s2⟩ =>
       match Seq.destruct s1, Seq.destruct s2 with
       | none, none => none
@@ -305,23 +384,29 @@ def union (s1 s2 : Wseq α) : Wseq α :=
       | some (none, s1'), some (some a2, s2') => some (some a2, s1', s2')
       | some (some a1, s1'), some (some a2, s2') => some (some a1, cons a2 s1', s2'))
     (s1, s2)
-#align stream.wseq.union Stream'.Wseq.union
+#align stream.wseq.union Stream'.WSeq.union
+-/
 
+#print Stream'.WSeq.isEmpty /-
 /-- Returns `tt` if `s` is `nil` and `ff` if `s` has an element -/
-def isEmpty (s : Wseq α) : Computation Bool :=
+def isEmpty (s : WSeq α) : Computation Bool :=
   Computation.map Option.isNone <| head s
-#align stream.wseq.is_empty Stream'.Wseq.isEmpty
+#align stream.wseq.is_empty Stream'.WSeq.isEmpty
+-/
 
+#print Stream'.WSeq.compute /-
 /-- Calculate one step of computation -/
-def compute (s : Wseq α) : Wseq α :=
+def compute (s : WSeq α) : WSeq α :=
   match Seq.destruct s with
   | some (none, s') => s'
   | _ => s
-#align stream.wseq.compute Stream'.Wseq.compute
+#align stream.wseq.compute Stream'.WSeq.compute
+-/
 
+#print Stream'.WSeq.take /-
 /-- Get the first `n` elements of a weak sequence -/
-def take (s : Wseq α) (n : ℕ) : Wseq α :=
-  @Seq.corec (Option α) (ℕ × Wseq α)
+def take (s : WSeq α) (n : ℕ) : WSeq α :=
+  @Seq.corec (Option α) (ℕ × WSeq α)
     (fun ⟨n, s⟩ =>
       match n, Seq.destruct s with
       | 0, _ => none
@@ -329,13 +414,15 @@ def take (s : Wseq α) (n : ℕ) : Wseq α :=
       | m + 1, some (none, s') => some (none, m + 1, s')
       | m + 1, some (some a, s') => some (some a, m, s'))
     (n, s)
-#align stream.wseq.take Stream'.Wseq.take
+#align stream.wseq.take Stream'.WSeq.take
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.splitAt /-
 /-- Split the sequence at position `n` into a finite initial segment
   and the weak sequence tail -/
-def splitAt (s : Wseq α) (n : ℕ) : Computation (List α × Wseq α) :=
-  @Computation.corec (List α × Wseq α) (ℕ × List α × Wseq α)
+def splitAt (s : WSeq α) (n : ℕ) : Computation (List α × WSeq α) :=
+  @Computation.corec (List α × WSeq α) (ℕ × List α × WSeq α)
     (fun ⟨n, l, s⟩ =>
       match n, Seq.destruct s with
       | 0, _ => Sum.inl (l.reverse, s)
@@ -343,36 +430,42 @@ def splitAt (s : Wseq α) (n : ℕ) : Computation (List α × Wseq α) :=
       | m + 1, some (none, s') => Sum.inr (n, l, s')
       | m + 1, some (some a, s') => Sum.inr (m, a::l, s'))
     (n, [], s)
-#align stream.wseq.split_at Stream'.Wseq.splitAt
+#align stream.wseq.split_at Stream'.WSeq.splitAt
+-/
 
+#print Stream'.WSeq.any /-
 /-- Returns `tt` if any element of `s` satisfies `p` -/
-def any (s : Wseq α) (p : α → Bool) : Computation Bool :=
+def any (s : WSeq α) (p : α → Bool) : Computation Bool :=
   Computation.corec
-    (fun s : Wseq α =>
+    (fun s : WSeq α =>
       match Seq.destruct s with
       | none => Sum.inl false
       | some (none, s') => Sum.inr s'
       | some (some a, s') => if p a then Sum.inl true else Sum.inr s')
     s
-#align stream.wseq.any Stream'.Wseq.any
+#align stream.wseq.any Stream'.WSeq.any
+-/
 
+#print Stream'.WSeq.all /-
 /-- Returns `tt` if every element of `s` satisfies `p` -/
-def all (s : Wseq α) (p : α → Bool) : Computation Bool :=
+def all (s : WSeq α) (p : α → Bool) : Computation Bool :=
   Computation.corec
-    (fun s : Wseq α =>
+    (fun s : WSeq α =>
       match Seq.destruct s with
       | none => Sum.inl true
       | some (none, s') => Sum.inr s'
       | some (some a, s') => if p a then Sum.inr s' else Sum.inl false)
     s
-#align stream.wseq.all Stream'.Wseq.all
+#align stream.wseq.all Stream'.WSeq.all
+-/
 
+#print Stream'.WSeq.scanl /-
 /-- Apply a function to the elements of the sequence to produce a sequence
   of partial results. (There is no `scanr` because this would require
   working from the end of the sequence, which may not exist.) -/
-def scanl (f : α → β → α) (a : α) (s : Wseq β) : Wseq α :=
+def scanl (f : α → β → α) (a : α) (s : WSeq β) : WSeq α :=
   cons a <|
-    @Seq.corec (Option α) (α × Wseq β)
+    @Seq.corec (Option α) (α × WSeq β)
       (fun ⟨a, s⟩ =>
         match Seq.destruct s with
         | none => none
@@ -381,12 +474,14 @@ def scanl (f : α → β → α) (a : α) (s : Wseq β) : Wseq α :=
           let a' := f a b
           some (some a', a', s'))
       (a, s)
-#align stream.wseq.scanl Stream'.Wseq.scanl
+#align stream.wseq.scanl Stream'.WSeq.scanl
+-/
 
+#print Stream'.WSeq.inits /-
 /-- Get the weak sequence of initial segments of the input sequence -/
-def inits (s : Wseq α) : Wseq (List α) :=
+def inits (s : WSeq α) : WSeq (List α) :=
   cons [] <|
-    @Seq.corec (Option (List α)) (Dlist α × Wseq α)
+    @Seq.corec (Option (List α)) (Dlist α × WSeq α)
       (fun ⟨l, s⟩ =>
         match Seq.destruct s with
         | none => none
@@ -395,98 +490,126 @@ def inits (s : Wseq α) : Wseq (List α) :=
           let l' := l.concat a
           some (some l'.toList, l', s'))
       (Dlist.empty, s)
-#align stream.wseq.inits Stream'.Wseq.inits
+#align stream.wseq.inits Stream'.WSeq.inits
+-/
 
+#print Stream'.WSeq.collect /-
 /-- Like take, but does not wait for a result. Calculates `n` steps of
   computation and returns the sequence computed so far -/
-def collect (s : Wseq α) (n : ℕ) : List α :=
+def collect (s : WSeq α) (n : ℕ) : List α :=
   (Seq.take n s).filterMap id
-#align stream.wseq.collect Stream'.Wseq.collect
+#align stream.wseq.collect Stream'.WSeq.collect
+-/
 
+#print Stream'.WSeq.append /-
 /-- Append two weak sequences. As with `seq.append`, this may not use
   the second sequence if the first one takes forever to compute -/
-def append : Wseq α → Wseq α → Wseq α :=
+def append : WSeq α → WSeq α → WSeq α :=
   Seq.append
-#align stream.wseq.append Stream'.Wseq.append
+#align stream.wseq.append Stream'.WSeq.append
+-/
 
+#print Stream'.WSeq.map /-
 /-- Map a function over a weak sequence -/
-def map (f : α → β) : Wseq α → Wseq β :=
+def map (f : α → β) : WSeq α → WSeq β :=
   Seq.map (Option.map f)
-#align stream.wseq.map Stream'.Wseq.map
+#align stream.wseq.map Stream'.WSeq.map
+-/
 
+#print Stream'.WSeq.join /-
 /-- Flatten a sequence of weak sequences. (Note that this allows
   empty sequences, unlike `seq.join`.) -/
-def join (S : Wseq (Wseq α)) : Wseq α :=
+def join (S : WSeq (WSeq α)) : WSeq α :=
   Seq.join
-    ((fun o : Option (Wseq α) =>
+    ((fun o : Option (WSeq α) =>
         match o with
         | none => Seq1.ret none
         | some s => (none, s)) <$>
       S)
-#align stream.wseq.join Stream'.Wseq.join
+#align stream.wseq.join Stream'.WSeq.join
+-/
 
+#print Stream'.WSeq.bind /-
 /-- Monadic bind operator for weak sequences -/
-def bind (s : Wseq α) (f : α → Wseq β) : Wseq β :=
+def bind (s : WSeq α) (f : α → WSeq β) : WSeq β :=
   join (map f s)
-#align stream.wseq.bind Stream'.Wseq.bind
+#align stream.wseq.bind Stream'.WSeq.bind
+-/
 
+#print Stream'.WSeq.LiftRelO /-
 /-- lift a relation to a relation over weak sequences -/
 @[simp]
-def LiftRelO (R : α → β → Prop) (C : Wseq α → Wseq β → Prop) :
-    Option (α × Wseq α) → Option (β × Wseq β) → Prop
+def LiftRelO (R : α → β → Prop) (C : WSeq α → WSeq β → Prop) :
+    Option (α × WSeq α) → Option (β × WSeq β) → Prop
   | none, none => True
   | some (a, s), some (b, t) => R a b ∧ C s t
   | _, _ => False
-#align stream.wseq.lift_rel_o Stream'.Wseq.LiftRelO
+#align stream.wseq.lift_rel_o Stream'.WSeq.LiftRelO
+-/
 
-theorem LiftRelO.imp {R S : α → β → Prop} {C D : Wseq α → Wseq β → Prop} (H1 : ∀ a b, R a b → S a b)
+#print Stream'.WSeq.LiftRelO.imp /-
+theorem LiftRelO.imp {R S : α → β → Prop} {C D : WSeq α → WSeq β → Prop} (H1 : ∀ a b, R a b → S a b)
     (H2 : ∀ s t, C s t → D s t) : ∀ {o p}, LiftRelO R C o p → LiftRelO S D o p
   | none, none, h => trivial
   | some (a, s), some (b, t), h => And.imp (H1 _ _) (H2 _ _) h
   | none, some _, h => False.elim h
   | some (_, _), none, h => False.elim h
-#align stream.wseq.lift_rel_o.imp Stream'.Wseq.LiftRelO.imp
+#align stream.wseq.lift_rel_o.imp Stream'.WSeq.LiftRelO.imp
+-/
 
-theorem LiftRelO.imp_right (R : α → β → Prop) {C D : Wseq α → Wseq β → Prop}
+#print Stream'.WSeq.LiftRelO.imp_right /-
+theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β → Prop}
     (H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p :=
   LiftRelO.imp (fun _ _ => id) H
-#align stream.wseq.lift_rel_o.imp_right Stream'.Wseq.LiftRelO.imp_right
+#align stream.wseq.lift_rel_o.imp_right Stream'.WSeq.LiftRelO.imp_right
+-/
 
+#print Stream'.WSeq.BisimO /-
 /-- Definitino of bisimilarity for weak sequences-/
 @[simp]
-def BisimO (R : Wseq α → Wseq α → Prop) : Option (α × Wseq α) → Option (α × Wseq α) → Prop :=
+def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop :=
   LiftRelO (· = ·) R
-#align stream.wseq.bisim_o Stream'.Wseq.BisimO
+#align stream.wseq.bisim_o Stream'.WSeq.BisimO
+-/
 
-theorem BisimO.imp {R S : Wseq α → Wseq α → Prop} (H : ∀ s t, R s t → S s t) {o p} :
+#print Stream'.WSeq.BisimO.imp /-
+theorem BisimO.imp {R S : WSeq α → WSeq α → Prop} (H : ∀ s t, R s t → S s t) {o p} :
     BisimO R o p → BisimO S o p :=
   LiftRelO.imp_right _ H
-#align stream.wseq.bisim_o.imp Stream'.Wseq.BisimO.imp
+#align stream.wseq.bisim_o.imp Stream'.WSeq.BisimO.imp
+-/
 
+#print Stream'.WSeq.LiftRel /-
 /-- Two weak sequences are `lift_rel R` related if they are either both empty,
   or they are both nonempty and the heads are `R` related and the tails are
   `lift_rel R` related. (This is a coinductive definition.) -/
-def LiftRel (R : α → β → Prop) (s : Wseq α) (t : Wseq β) : Prop :=
-  ∃ C : Wseq α → Wseq β → Prop,
+def LiftRel (R : α → β → Prop) (s : WSeq α) (t : WSeq β) : Prop :=
+  ∃ C : WSeq α → WSeq β → Prop,
     C s t ∧ ∀ {s t}, C s t → Computation.LiftRel (LiftRelO R C) (destruct s) (destruct t)
-#align stream.wseq.lift_rel Stream'.Wseq.LiftRel
+#align stream.wseq.lift_rel Stream'.WSeq.LiftRel
+-/
 
+#print Stream'.WSeq.Equiv /-
 /-- If two sequences are equivalent, then they have the same values and
   the same computational behavior (i.e. if one loops forever then so does
   the other), although they may differ in the number of `think`s needed to
   arrive at the answer. -/
-def Equiv : Wseq α → Wseq α → Prop :=
+def Equiv : WSeq α → WSeq α → Prop :=
   LiftRel (· = ·)
-#align stream.wseq.equiv Stream'.Wseq.Equiv
+#align stream.wseq.equiv Stream'.WSeq.Equiv
+-/
 
-theorem liftRel_destruct {R : α → β → Prop} {s : Wseq α} {t : Wseq β} :
+#print Stream'.WSeq.liftRel_destruct /-
+theorem liftRel_destruct {R : α → β → Prop} {s : WSeq α} {t : WSeq β} :
     LiftRel R s t → Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t)
   | ⟨R, h1, h2⟩ => by
     refine' Computation.LiftRel.imp _ _ _ (h2 h1) <;> apply lift_rel_o.imp_right <;>
       exact fun s' t' h' => ⟨R, h', @h2⟩
-#align stream.wseq.lift_rel_destruct Stream'.Wseq.liftRel_destruct
+#align stream.wseq.lift_rel_destruct Stream'.WSeq.liftRel_destruct
+-/
 
-theorem liftRel_destruct_iff {R : α → β → Prop} {s : Wseq α} {t : Wseq β} :
+#print Stream'.WSeq.liftRel_destruct_iff /-
+theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β} :
     LiftRel R s t ↔ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) :=
   ⟨liftRel_destruct, fun h =>
     ⟨fun s t =>
@@ -503,56 +626,72 @@ theorem liftRel_destruct_iff {R : α → β → Prop} {s : Wseq α} {t : Wseq β
       apply lift_rel_o.imp_right
       intro s t
       apply Or.inl⟩⟩
-#align stream.wseq.lift_rel_destruct_iff Stream'.Wseq.liftRel_destruct_iff
+#align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff
+-/
 
 -- mathport name: equiv
 infixl:50 " ~ " => Equiv
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:228:8: unsupported: ambiguous notation -/
-theorem destruct_congr {s t : Wseq α} :
+#print Stream'.WSeq.destruct_congr /-
+theorem destruct_congr {s t : WSeq α} :
     s ~ t → Computation.LiftRel (BisimO (· ~ ·)) (destruct s) (destruct t) :=
   liftRel_destruct
-#align stream.wseq.destruct_congr Stream'.Wseq.destruct_congr
+#align stream.wseq.destruct_congr Stream'.WSeq.destruct_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:228:8: unsupported: ambiguous notation -/
-theorem destruct_congr_iff {s t : Wseq α} :
+#print Stream'.WSeq.destruct_congr_iff /-
+theorem destruct_congr_iff {s t : WSeq α} :
     s ~ t ↔ Computation.LiftRel (BisimO (· ~ ·)) (destruct s) (destruct t) :=
   liftRel_destruct_iff
-#align stream.wseq.destruct_congr_iff Stream'.Wseq.destruct_congr_iff
+#align stream.wseq.destruct_congr_iff Stream'.WSeq.destruct_congr_iff
+-/
 
+#print Stream'.WSeq.LiftRel.refl /-
 theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s =>
   by
   refine' ⟨(· = ·), rfl, fun s t (h : s = t) => _⟩
   rw [← h]; apply Computation.LiftRel.refl
   intro a; cases' a with a; simp; cases a <;> simp; apply H
-#align stream.wseq.lift_rel.refl Stream'.Wseq.LiftRel.refl
+#align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl
+-/
 
+#print Stream'.WSeq.LiftRelO.swap /-
 theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) :=
   by
   funext x y <;> cases' x with x <;> [skip, cases x] <;>
     · cases' y with y <;> [skip, cases y] <;> rfl
-#align stream.wseq.lift_rel_o.swap Stream'.Wseq.LiftRelO.swap
+#align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
+-/
 
+#print Stream'.WSeq.LiftRel.swap_lem /-
 theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) :
     LiftRel (swap R) s2 s1 :=
   by
   refine' ⟨swap (lift_rel R), h, fun s t (h : lift_rel R t s) => _⟩
   rw [← lift_rel_o.swap, Computation.LiftRel.swap]
   apply lift_rel_destruct h
-#align stream.wseq.lift_rel.swap_lem Stream'.Wseq.LiftRel.swap_lem
+#align stream.wseq.lift_rel.swap_lem Stream'.WSeq.LiftRel.swap_lem
+-/
 
+#print Stream'.WSeq.LiftRel.swap /-
 theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) :=
   funext fun x => funext fun y => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩
-#align stream.wseq.lift_rel.swap Stream'.Wseq.LiftRel.swap
+#align stream.wseq.lift_rel.swap Stream'.WSeq.LiftRel.swap
+-/
 
+#print Stream'.WSeq.LiftRel.symm /-
 theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
   fun s1 s2 (h : swap (LiftRel R) s2 s1) => by
   rwa [lift_rel.swap,
     show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h
-#align stream.wseq.lift_rel.symm Stream'.Wseq.LiftRel.symm
+#align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm
+-/
 
+#print Stream'.WSeq.LiftRel.trans /-
 theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) :=
   fun s t u h1 h2 =>
   by
@@ -584,101 +723,135 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
     cases' t1 with ab st
     cases' t2 with bc tu
     exact ⟨H ab bc, t, st, tu⟩
-#align stream.wseq.lift_rel.trans Stream'.Wseq.LiftRel.trans
+#align stream.wseq.lift_rel.trans Stream'.WSeq.LiftRel.trans
+-/
 
+#print Stream'.WSeq.LiftRel.equiv /-
 theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R)
   | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, LiftRel.symm R symm, LiftRel.trans R trans⟩
-#align stream.wseq.lift_rel.equiv Stream'.Wseq.LiftRel.equiv
+#align stream.wseq.lift_rel.equiv Stream'.WSeq.LiftRel.equiv
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.Equiv.refl /-
 @[refl]
-theorem Equiv.refl : ∀ s : Wseq α, s ~ s :=
+theorem Equiv.refl : ∀ s : WSeq α, s ~ s :=
   LiftRel.refl (· = ·) Eq.refl
-#align stream.wseq.equiv.refl Stream'.Wseq.Equiv.refl
+#align stream.wseq.equiv.refl Stream'.WSeq.Equiv.refl
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.Equiv.symm /-
 @[symm]
-theorem Equiv.symm : ∀ {s t : Wseq α}, s ~ t → t ~ s :=
+theorem Equiv.symm : ∀ {s t : WSeq α}, s ~ t → t ~ s :=
   LiftRel.symm (· = ·) (@Eq.symm _)
-#align stream.wseq.equiv.symm Stream'.Wseq.Equiv.symm
+#align stream.wseq.equiv.symm Stream'.WSeq.Equiv.symm
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.Equiv.trans /-
 @[trans]
-theorem Equiv.trans : ∀ {s t u : Wseq α}, s ~ t → t ~ u → s ~ u :=
+theorem Equiv.trans : ∀ {s t u : WSeq α}, s ~ t → t ~ u → s ~ u :=
   LiftRel.trans (· = ·) (@Eq.trans _)
-#align stream.wseq.equiv.trans Stream'.Wseq.Equiv.trans
+#align stream.wseq.equiv.trans Stream'.WSeq.Equiv.trans
+-/
 
+#print Stream'.WSeq.Equiv.equivalence /-
 theorem Equiv.equivalence : Equivalence (@Equiv α) :=
   ⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩
-#align stream.wseq.equiv.equivalence Stream'.Wseq.Equiv.equivalence
+#align stream.wseq.equiv.equivalence Stream'.WSeq.Equiv.equivalence
+-/
 
 open Computation
 
 -- mathport name: exprreturn
 local notation "return" => Computation.pure
 
+#print Stream'.WSeq.destruct_nil /-
 @[simp]
-theorem destruct_nil : destruct (nil : Wseq α) = return none :=
+theorem destruct_nil : destruct (nil : WSeq α) = return none :=
   Computation.destruct_eq_pure rfl
-#align stream.wseq.destruct_nil Stream'.Wseq.destruct_nil
+#align stream.wseq.destruct_nil Stream'.WSeq.destruct_nil
+-/
 
+#print Stream'.WSeq.destruct_cons /-
 @[simp]
 theorem destruct_cons (a : α) (s) : destruct (cons a s) = return (some (a, s)) :=
   Computation.destruct_eq_pure <| by simp [destruct, cons, Computation.rmap]
-#align stream.wseq.destruct_cons Stream'.Wseq.destruct_cons
+#align stream.wseq.destruct_cons Stream'.WSeq.destruct_cons
+-/
 
+#print Stream'.WSeq.destruct_think /-
 @[simp]
-theorem destruct_think (s : Wseq α) : destruct (think s) = (destruct s).think :=
+theorem destruct_think (s : WSeq α) : destruct (think s) = (destruct s).think :=
   Computation.destruct_eq_think <| by simp [destruct, think, Computation.rmap]
-#align stream.wseq.destruct_think Stream'.Wseq.destruct_think
+#align stream.wseq.destruct_think Stream'.WSeq.destruct_think
+-/
 
+#print Stream'.WSeq.seq_destruct_nil /-
 @[simp]
-theorem seq_destruct_nil : Seq.destruct (nil : Wseq α) = none :=
+theorem seq_destruct_nil : Seq.destruct (nil : WSeq α) = none :=
   Seq.destruct_nil
-#align stream.wseq.seq_destruct_nil Stream'.Wseq.seq_destruct_nil
+#align stream.wseq.seq_destruct_nil Stream'.WSeq.seq_destruct_nil
+-/
 
+#print Stream'.WSeq.seq_destruct_cons /-
 @[simp]
 theorem seq_destruct_cons (a : α) (s) : Seq.destruct (cons a s) = some (some a, s) :=
   Seq.destruct_cons _ _
-#align stream.wseq.seq_destruct_cons Stream'.Wseq.seq_destruct_cons
+#align stream.wseq.seq_destruct_cons Stream'.WSeq.seq_destruct_cons
+-/
 
+#print Stream'.WSeq.seq_destruct_think /-
 @[simp]
-theorem seq_destruct_think (s : Wseq α) : Seq.destruct (think s) = some (none, s) :=
+theorem seq_destruct_think (s : WSeq α) : Seq.destruct (think s) = some (none, s) :=
   Seq.destruct_cons _ _
-#align stream.wseq.seq_destruct_think Stream'.Wseq.seq_destruct_think
+#align stream.wseq.seq_destruct_think Stream'.WSeq.seq_destruct_think
+-/
 
+#print Stream'.WSeq.head_nil /-
 @[simp]
-theorem head_nil : head (nil : Wseq α) = return none := by simp [head] <;> rfl
-#align stream.wseq.head_nil Stream'.Wseq.head_nil
+theorem head_nil : head (nil : WSeq α) = return none := by simp [head] <;> rfl
+#align stream.wseq.head_nil Stream'.WSeq.head_nil
+-/
 
+#print Stream'.WSeq.head_cons /-
 @[simp]
 theorem head_cons (a : α) (s) : head (cons a s) = return (some a) := by simp [head] <;> rfl
-#align stream.wseq.head_cons Stream'.Wseq.head_cons
+#align stream.wseq.head_cons Stream'.WSeq.head_cons
+-/
 
+#print Stream'.WSeq.head_think /-
 @[simp]
-theorem head_think (s : Wseq α) : head (think s) = (head s).think := by simp [head] <;> rfl
-#align stream.wseq.head_think Stream'.Wseq.head_think
+theorem head_think (s : WSeq α) : head (think s) = (head s).think := by simp [head] <;> rfl
+#align stream.wseq.head_think Stream'.WSeq.head_think
+-/
 
+#print Stream'.WSeq.flatten_pure /-
 @[simp]
-theorem flatten_ret (s : Wseq α) : flatten (return s) = s :=
+theorem flatten_pure (s : WSeq α) : flatten (return s) = s :=
   by
   refine' seq.eq_of_bisim (fun s1 s2 => flatten (return s2) = s1) _ rfl
   intro s' s h; rw [← h]; simp [flatten]
   cases seq.destruct s; · simp
   · cases' val with o s'
     simp
-#align stream.wseq.flatten_ret Stream'.Wseq.flatten_ret
+#align stream.wseq.flatten_ret Stream'.WSeq.flatten_pure
+-/
 
+#print Stream'.WSeq.flatten_think /-
 @[simp]
-theorem flatten_think (c : Computation (Wseq α)) : flatten c.think = think (flatten c) :=
+theorem flatten_think (c : Computation (WSeq α)) : flatten c.think = think (flatten c) :=
   Seq.destruct_eq_cons <| by simp [flatten, think]
-#align stream.wseq.flatten_think Stream'.Wseq.flatten_think
+#align stream.wseq.flatten_think Stream'.WSeq.flatten_think
+-/
 
+#print Stream'.WSeq.destruct_flatten /-
 @[simp]
-theorem destruct_flatten (c : Computation (Wseq α)) : destruct (flatten c) = c >>= destruct :=
+theorem destruct_flatten (c : Computation (WSeq α)) : destruct (flatten c) = c >>= destruct :=
   by
   refine'
     Computation.eq_of_bisim
@@ -693,134 +866,184 @@ theorem destruct_flatten (c : Computation (Wseq α)) : destruct (flatten c) = c
       apply c.rec_on (fun a => _) fun c' => _ <;> repeat' simp
       · cases (destruct a).destruct <;> simp
       · exact Or.inr ⟨c', rfl, rfl⟩
-#align stream.wseq.destruct_flatten Stream'.Wseq.destruct_flatten
+#align stream.wseq.destruct_flatten Stream'.WSeq.destruct_flatten
+-/
 
-theorem head_terminates_iff (s : Wseq α) : Terminates (head s) ↔ Terminates (destruct s) :=
+#print Stream'.WSeq.head_terminates_iff /-
+theorem head_terminates_iff (s : WSeq α) : Terminates (head s) ↔ Terminates (destruct s) :=
   terminates_map_iff _ (destruct s)
-#align stream.wseq.head_terminates_iff Stream'.Wseq.head_terminates_iff
+#align stream.wseq.head_terminates_iff Stream'.WSeq.head_terminates_iff
+-/
 
+#print Stream'.WSeq.tail_nil /-
 @[simp]
-theorem tail_nil : tail (nil : Wseq α) = nil := by simp [tail]
-#align stream.wseq.tail_nil Stream'.Wseq.tail_nil
+theorem tail_nil : tail (nil : WSeq α) = nil := by simp [tail]
+#align stream.wseq.tail_nil Stream'.WSeq.tail_nil
+-/
 
+#print Stream'.WSeq.tail_cons /-
 @[simp]
 theorem tail_cons (a : α) (s) : tail (cons a s) = s := by simp [tail]
-#align stream.wseq.tail_cons Stream'.Wseq.tail_cons
+#align stream.wseq.tail_cons Stream'.WSeq.tail_cons
+-/
 
+#print Stream'.WSeq.tail_think /-
 @[simp]
-theorem tail_think (s : Wseq α) : tail (think s) = (tail s).think := by simp [tail]
-#align stream.wseq.tail_think Stream'.Wseq.tail_think
+theorem tail_think (s : WSeq α) : tail (think s) = (tail s).think := by simp [tail]
+#align stream.wseq.tail_think Stream'.WSeq.tail_think
+-/
 
+#print Stream'.WSeq.dropn_nil /-
 @[simp]
-theorem dropn_nil (n) : drop (nil : Wseq α) n = nil := by induction n <;> simp [*, drop]
-#align stream.wseq.dropn_nil Stream'.Wseq.dropn_nil
+theorem dropn_nil (n) : drop (nil : WSeq α) n = nil := by induction n <;> simp [*, drop]
+#align stream.wseq.dropn_nil Stream'.WSeq.dropn_nil
+-/
 
+#print Stream'.WSeq.dropn_cons /-
 @[simp]
 theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by
   induction n <;> simp [*, drop]
-#align stream.wseq.dropn_cons Stream'.Wseq.dropn_cons
+#align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons
+-/
 
+#print Stream'.WSeq.dropn_think /-
 @[simp]
-theorem dropn_think (s : Wseq α) (n) : drop (think s) n = (drop s n).think := by
+theorem dropn_think (s : WSeq α) (n) : drop (think s) n = (drop s n).think := by
   induction n <;> simp [*, drop]
-#align stream.wseq.dropn_think Stream'.Wseq.dropn_think
+#align stream.wseq.dropn_think Stream'.WSeq.dropn_think
+-/
 
-theorem dropn_add (s : Wseq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
+#print Stream'.WSeq.dropn_add /-
+theorem dropn_add (s : WSeq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
   | 0 => rfl
   | n + 1 => congr_arg tail (dropn_add n)
-#align stream.wseq.dropn_add Stream'.Wseq.dropn_add
+#align stream.wseq.dropn_add Stream'.WSeq.dropn_add
+-/
 
-theorem dropn_tail (s : Wseq α) (n) : drop (tail s) n = drop s (n + 1) := by
+#print Stream'.WSeq.dropn_tail /-
+theorem dropn_tail (s : WSeq α) (n) : drop (tail s) n = drop s (n + 1) := by
   rw [add_comm] <;> symm <;> apply dropn_add
-#align stream.wseq.dropn_tail Stream'.Wseq.dropn_tail
+#align stream.wseq.dropn_tail Stream'.WSeq.dropn_tail
+-/
 
-theorem nth_add (s : Wseq α) (m n) : nth s (m + n) = nth (drop s m) n :=
+#print Stream'.WSeq.get?_add /-
+theorem get?_add (s : WSeq α) (m n) : get? s (m + n) = get? (drop s m) n :=
   congr_arg head (dropn_add _ _ _)
-#align stream.wseq.nth_add Stream'.Wseq.nth_add
+#align stream.wseq.nth_add Stream'.WSeq.get?_add
+-/
 
-theorem nth_tail (s : Wseq α) (n) : nth (tail s) n = nth s (n + 1) :=
+#print Stream'.WSeq.get?_tail /-
+theorem get?_tail (s : WSeq α) (n) : get? (tail s) n = get? s (n + 1) :=
   congr_arg head (dropn_tail _ _)
-#align stream.wseq.nth_tail Stream'.Wseq.nth_tail
+#align stream.wseq.nth_tail Stream'.WSeq.get?_tail
+-/
 
+#print Stream'.WSeq.join_nil /-
 @[simp]
-theorem join_nil : join nil = (nil : Wseq α) :=
+theorem join_nil : join nil = (nil : WSeq α) :=
   Seq.join_nil
-#align stream.wseq.join_nil Stream'.Wseq.join_nil
+#align stream.wseq.join_nil Stream'.WSeq.join_nil
+-/
 
+#print Stream'.WSeq.join_think /-
 @[simp]
-theorem join_think (S : Wseq (Wseq α)) : join (think S) = think (join S) :=
+theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) :=
   by
   simp [think, join]
   unfold Functor.map
   simp [join, seq1.ret]
-#align stream.wseq.join_think Stream'.Wseq.join_think
+#align stream.wseq.join_think Stream'.WSeq.join_think
+-/
 
+#print Stream'.WSeq.join_cons /-
 @[simp]
-theorem join_cons (s : Wseq α) (S) : join (cons s S) = think (append s (join S)) :=
+theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) :=
   by
   simp [think, join]
   unfold Functor.map
   simp [join, cons, append]
-#align stream.wseq.join_cons Stream'.Wseq.join_cons
+#align stream.wseq.join_cons Stream'.WSeq.join_cons
+-/
 
+#print Stream'.WSeq.nil_append /-
 @[simp]
-theorem nil_append (s : Wseq α) : append nil s = s :=
+theorem nil_append (s : WSeq α) : append nil s = s :=
   Seq.nil_append _
-#align stream.wseq.nil_append Stream'.Wseq.nil_append
+#align stream.wseq.nil_append Stream'.WSeq.nil_append
+-/
 
+#print Stream'.WSeq.cons_append /-
 @[simp]
 theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :=
   Seq.cons_append _ _ _
-#align stream.wseq.cons_append Stream'.Wseq.cons_append
+#align stream.wseq.cons_append Stream'.WSeq.cons_append
+-/
 
+#print Stream'.WSeq.think_append /-
 @[simp]
-theorem think_append (s t : Wseq α) : append (think s) t = think (append s t) :=
+theorem think_append (s t : WSeq α) : append (think s) t = think (append s t) :=
   Seq.cons_append _ _ _
-#align stream.wseq.think_append Stream'.Wseq.think_append
+#align stream.wseq.think_append Stream'.WSeq.think_append
+-/
 
+#print Stream'.WSeq.append_nil /-
 @[simp]
-theorem append_nil (s : Wseq α) : append s nil = s :=
+theorem append_nil (s : WSeq α) : append s nil = s :=
   Seq.append_nil _
-#align stream.wseq.append_nil Stream'.Wseq.append_nil
+#align stream.wseq.append_nil Stream'.WSeq.append_nil
+-/
 
+#print Stream'.WSeq.append_assoc /-
 @[simp]
-theorem append_assoc (s t u : Wseq α) : append (append s t) u = append s (append t u) :=
+theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (append t u) :=
   Seq.append_assoc _ _ _
-#align stream.wseq.append_assoc Stream'.Wseq.append_assoc
+#align stream.wseq.append_assoc Stream'.WSeq.append_assoc
+-/
 
+#print Stream'.WSeq.tail.aux /-
 /-- auxilary defintion of tail over weak sequences-/
 @[simp]
-def tail.aux : Option (α × Wseq α) → Computation (Option (α × Wseq α))
+def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | none => return none
   | some (a, s) => destruct s
-#align stream.wseq.tail.aux Stream'.Wseq.tail.aux
+#align stream.wseq.tail.aux Stream'.WSeq.tail.aux
+-/
 
-theorem destruct_tail (s : Wseq α) : destruct (tail s) = destruct s >>= tail.aux :=
+#print Stream'.WSeq.destruct_tail /-
+theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.aux :=
   by
   simp [tail]; rw [← bind_pure_comp_eq_map, LawfulMonad.bind_assoc]
   apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp
-#align stream.wseq.destruct_tail Stream'.Wseq.destruct_tail
+#align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail
+-/
 
+#print Stream'.WSeq.drop.aux /-
 /-- auxilary defintion of drop over weak sequences-/
 @[simp]
-def drop.aux : ℕ → Option (α × Wseq α) → Computation (Option (α × Wseq α))
+def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | 0 => return
   | n + 1 => fun a => tail.aux a >>= drop.aux n
-#align stream.wseq.drop.aux Stream'.Wseq.drop.aux
+#align stream.wseq.drop.aux Stream'.WSeq.drop.aux
+-/
 
+#print Stream'.WSeq.drop.aux_none /-
 theorem drop.aux_none : ∀ n, @drop.aux α n none = return none
   | 0 => rfl
   | n + 1 =>
     show Computation.bind (return none) (drop.aux n) = return none by rw [ret_bind, drop.aux_none]
-#align stream.wseq.drop.aux_none Stream'.Wseq.drop.aux_none
+#align stream.wseq.drop.aux_none Stream'.WSeq.drop.aux_none
+-/
 
-theorem destruct_dropn : ∀ (s : Wseq α) (n), destruct (drop s n) = destruct s >>= drop.aux n
+#print Stream'.WSeq.destruct_dropn /-
+theorem destruct_dropn : ∀ (s : WSeq α) (n), destruct (drop s n) = destruct s >>= drop.aux n
   | s, 0 => (bind_pure' _).symm
   | s, n + 1 => by
     rw [← dropn_tail, destruct_dropn _ n, destruct_tail, LawfulMonad.bind_assoc] <;> rfl
-#align stream.wseq.destruct_dropn Stream'.Wseq.destruct_dropn
+#align stream.wseq.destruct_dropn Stream'.WSeq.destruct_dropn
+-/
 
-theorem head_terminates_of_head_tail_terminates (s : Wseq α) [T : Terminates (head (tail s))] :
+#print Stream'.WSeq.head_terminates_of_head_tail_terminates /-
+theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (head (tail s))] :
     Terminates (head s) :=
   (head_terminates_iff _).2 <|
     by
@@ -831,9 +1054,11 @@ theorem head_terminates_of_head_tail_terminates (s : Wseq α) [T : Terminates (h
     exact
       let ⟨t, h3, h4⟩ := Computation.exists_of_mem_map h1
       Computation.terminates_of_mem h3
-#align stream.wseq.head_terminates_of_head_tail_terminates Stream'.Wseq.head_terminates_of_head_tail_terminates
+#align stream.wseq.head_terminates_of_head_tail_terminates Stream'.WSeq.head_terminates_of_head_tail_terminates
+-/
 
-theorem destruct_some_of_destruct_tail_some {s : Wseq α} {a} (h : some a ∈ destruct (tail s)) :
+#print Stream'.WSeq.destruct_some_of_destruct_tail_some /-
+theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) :
     ∃ a', some a' ∈ destruct s := by
   unfold tail Functor.map at h; simp at h
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
@@ -842,62 +1067,80 @@ theorem destruct_some_of_destruct_tail_some {s : Wseq α} {a} (h : some a ∈ de
   · have := mem_unique td (ret_mem _)
     contradiction
   · exact ⟨_, ht'⟩
-#align stream.wseq.destruct_some_of_destruct_tail_some Stream'.Wseq.destruct_some_of_destruct_tail_some
+#align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some
+-/
 
-theorem head_some_of_head_tail_some {s : Wseq α} {a} (h : some a ∈ head (tail s)) :
+#print Stream'.WSeq.head_some_of_head_tail_some /-
+theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) :
     ∃ a', some a' ∈ head s := by
   unfold head at h
   rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
   cases' o with o <;> injection e with h'; clear e h'
   cases' destruct_some_of_destruct_tail_some md with a am
   exact ⟨_, Computation.mem_map ((· <$> ·) (@Prod.fst α (wseq α))) am⟩
-#align stream.wseq.head_some_of_head_tail_some Stream'.Wseq.head_some_of_head_tail_some
+#align stream.wseq.head_some_of_head_tail_some Stream'.WSeq.head_some_of_head_tail_some
+-/
 
-theorem head_some_of_nth_some {s : Wseq α} {a n} (h : some a ∈ nth s n) : ∃ a', some a' ∈ head s :=
-  by
+#print Stream'.WSeq.head_some_of_get?_some /-
+theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) :
+    ∃ a', some a' ∈ head s := by
   revert a; induction' n with n IH <;> intros
   exacts[⟨_, h⟩,
     let ⟨a', h'⟩ := head_some_of_head_tail_some h
     IH h']
-#align stream.wseq.head_some_of_nth_some Stream'.Wseq.head_some_of_nth_some
+#align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some
+-/
 
-instance productive_tail (s : Wseq α) [Productive s] : Productive (tail s) :=
+#print Stream'.WSeq.productive_tail /-
+instance productive_tail (s : WSeq α) [Productive s] : Productive (tail s) :=
   ⟨fun n => by rw [nth_tail] <;> infer_instance⟩
-#align stream.wseq.productive_tail Stream'.Wseq.productive_tail
+#align stream.wseq.productive_tail Stream'.WSeq.productive_tail
+-/
 
-instance productive_dropn (s : Wseq α) [Productive s] (n) : Productive (drop s n) :=
+#print Stream'.WSeq.productive_dropn /-
+instance productive_dropn (s : WSeq α) [Productive s] (n) : Productive (drop s n) :=
   ⟨fun m => by rw [← nth_add] <;> infer_instance⟩
-#align stream.wseq.productive_dropn Stream'.Wseq.productive_dropn
+#align stream.wseq.productive_dropn Stream'.WSeq.productive_dropn
+-/
 
+#print Stream'.WSeq.toSeq /-
 /-- Given a productive weak sequence, we can collapse all the `think`s to
   produce a sequence. -/
-def toSeq (s : Wseq α) [Productive s] : Seq α :=
-  ⟨fun n => (nth s n).get, fun n h =>
+def toSeq (s : WSeq α) [Productive s] : Seq α :=
+  ⟨fun n => (get? s n).get, fun n h =>
     by
     cases e : Computation.get (nth s (n + 1)); · assumption
     have := mem_of_get_eq _ e
     simp [nth] at this h; cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
     contradiction⟩
-#align stream.wseq.to_seq Stream'.Wseq.toSeq
+#align stream.wseq.to_seq Stream'.WSeq.toSeq
+-/
 
-theorem nth_terminates_le {s : Wseq α} {m n} (h : m ≤ n) :
-    Terminates (nth s n) → Terminates (nth s m) := by
+#print Stream'.WSeq.get?_terminates_le /-
+theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
+    Terminates (get? s n) → Terminates (get? s m) := by
   induction' h with m' h IH <;> [exact id,
     exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
-#align stream.wseq.nth_terminates_le Stream'.Wseq.nth_terminates_le
+#align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le
+-/
 
-theorem head_terminates_of_nth_terminates {s : Wseq α} {n} :
-    Terminates (nth s n) → Terminates (head s) :=
-  nth_terminates_le (Nat.zero_le n)
-#align stream.wseq.head_terminates_of_nth_terminates Stream'.Wseq.head_terminates_of_nth_terminates
+#print Stream'.WSeq.head_terminates_of_get?_terminates /-
+theorem head_terminates_of_get?_terminates {s : WSeq α} {n} :
+    Terminates (get? s n) → Terminates (head s) :=
+  get?_terminates_le (Nat.zero_le n)
+#align stream.wseq.head_terminates_of_nth_terminates Stream'.WSeq.head_terminates_of_get?_terminates
+-/
 
-theorem destruct_terminates_of_nth_terminates {s : Wseq α} {n} (T : Terminates (nth s n)) :
+#print Stream'.WSeq.destruct_terminates_of_get?_terminates /-
+theorem destruct_terminates_of_get?_terminates {s : WSeq α} {n} (T : Terminates (get? s n)) :
     Terminates (destruct s) :=
-  (head_terminates_iff _).1 <| head_terminates_of_nth_terminates T
-#align stream.wseq.destruct_terminates_of_nth_terminates Stream'.Wseq.destruct_terminates_of_nth_terminates
+  (head_terminates_iff _).1 <| head_terminates_of_get?_terminates T
+#align stream.wseq.destruct_terminates_of_nth_terminates Stream'.WSeq.destruct_terminates_of_get?_terminates
+-/
 
-theorem mem_rec_on {C : Wseq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s'))
+#print Stream'.WSeq.mem_rec_on /-
+theorem mem_rec_on {C : WSeq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s'))
     (h2 : ∀ s, C s → C (think s)) : C s :=
   by
   apply seq.mem_rec_on M
@@ -910,11 +1153,13 @@ theorem mem_rec_on {C : Wseq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a
     apply Or.imp_left _ h
     intro h
     injection h
-#align stream.wseq.mem_rec_on Stream'.Wseq.mem_rec_on
+#align stream.wseq.mem_rec_on Stream'.WSeq.mem_rec_on
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.mem_think /-
 @[simp]
-theorem mem_think (s : Wseq α) (a) : a ∈ think s ↔ a ∈ s :=
+theorem mem_think (s : WSeq α) (a) : a ∈ think s ↔ a ∈ s :=
   by
   cases' s with f al
   change (some (some a) ∈ some none::f) ↔ some (some a) ∈ f
@@ -923,9 +1168,11 @@ theorem mem_think (s : Wseq α) (a) : a ∈ think s ↔ a ∈ s :=
     intro
     injections
   · apply Stream'.mem_cons_of_mem _ h
-#align stream.wseq.mem_think Stream'.Wseq.mem_think
+#align stream.wseq.mem_think Stream'.WSeq.mem_think
+-/
 
-theorem eq_or_mem_iff_mem {s : Wseq α} {a a' s'} :
+#print Stream'.WSeq.eq_or_mem_iff_mem /-
+theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
     some (a', s') ∈ destruct s → (a ∈ s ↔ a = a' ∨ a ∈ s') :=
   by
   generalize e : destruct s = c; intro h
@@ -949,22 +1196,30 @@ theorem eq_or_mem_iff_mem {s : Wseq α} {a a' s'} :
       · exact Stream'.mem_cons_of_mem _ m
   · simp
     exact IH this
-#align stream.wseq.eq_or_mem_iff_mem Stream'.Wseq.eq_or_mem_iff_mem
+#align stream.wseq.eq_or_mem_iff_mem Stream'.WSeq.eq_or_mem_iff_mem
+-/
 
+#print Stream'.WSeq.mem_cons_iff /-
 @[simp]
-theorem mem_cons_iff (s : Wseq α) (b) {a} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
+theorem mem_cons_iff (s : WSeq α) (b) {a} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
   eq_or_mem_iff_mem <| by simp [ret_mem]
-#align stream.wseq.mem_cons_iff Stream'.Wseq.mem_cons_iff
+#align stream.wseq.mem_cons_iff Stream'.WSeq.mem_cons_iff
+-/
 
-theorem mem_cons_of_mem {s : Wseq α} (b) {a} (h : a ∈ s) : a ∈ cons b s :=
+#print Stream'.WSeq.mem_cons_of_mem /-
+theorem mem_cons_of_mem {s : WSeq α} (b) {a} (h : a ∈ s) : a ∈ cons b s :=
   (mem_cons_iff _ _).2 (Or.inr h)
-#align stream.wseq.mem_cons_of_mem Stream'.Wseq.mem_cons_of_mem
+#align stream.wseq.mem_cons_of_mem Stream'.WSeq.mem_cons_of_mem
+-/
 
-theorem mem_cons (s : Wseq α) (a) : a ∈ cons a s :=
+#print Stream'.WSeq.mem_cons /-
+theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s :=
   (mem_cons_iff _ _).2 (Or.inl rfl)
-#align stream.wseq.mem_cons Stream'.Wseq.mem_cons
+#align stream.wseq.mem_cons Stream'.WSeq.mem_cons
+-/
 
-theorem mem_of_mem_tail {s : Wseq α} {a} : a ∈ tail s → a ∈ s :=
+#print Stream'.WSeq.mem_of_mem_tail /-
+theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s :=
   by
   intro h; have := h; cases' h with n e; revert s; simp [Stream'.nth]
   induction' n with n IH <;> intro s <;> apply s.rec_on _ (fun x s => _) fun s => _ <;>
@@ -977,14 +1232,18 @@ theorem mem_of_mem_tail {s : Wseq α} {a} : a ∈ tail s → a ∈ s :=
     rw [e]
     cases tail s
     rfl
-#align stream.wseq.mem_of_mem_tail Stream'.Wseq.mem_of_mem_tail
+#align stream.wseq.mem_of_mem_tail Stream'.WSeq.mem_of_mem_tail
+-/
 
-theorem mem_of_mem_dropn {s : Wseq α} {a} : ∀ {n}, a ∈ drop s n → a ∈ s
+#print Stream'.WSeq.mem_of_mem_dropn /-
+theorem mem_of_mem_dropn {s : WSeq α} {a} : ∀ {n}, a ∈ drop s n → a ∈ s
   | 0, h => h
   | n + 1, h => @mem_of_mem_dropn n (mem_of_mem_tail h)
-#align stream.wseq.mem_of_mem_dropn Stream'.Wseq.mem_of_mem_dropn
+#align stream.wseq.mem_of_mem_dropn Stream'.WSeq.mem_of_mem_dropn
+-/
 
-theorem nth_mem {s : Wseq α} {a n} : some a ∈ nth s n → a ∈ s :=
+#print Stream'.WSeq.get?_mem /-
+theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s :=
   by
   revert s; induction' n with n IH <;> intro s h
   · rcases Computation.exists_of_mem_map h with ⟨o, h1, h2⟩
@@ -994,9 +1253,11 @@ theorem nth_mem {s : Wseq α} {a n} : some a ∈ nth s n → a ∈ s :=
   · have := @IH (tail s)
     rw [nth_tail] at this
     exact mem_of_mem_tail (this h)
-#align stream.wseq.nth_mem Stream'.Wseq.nth_mem
+#align stream.wseq.nth_mem Stream'.WSeq.get?_mem
+-/
 
-theorem exists_nth_of_mem {s : Wseq α} {a} (h : a ∈ s) : ∃ n, some a ∈ nth s n :=
+#print Stream'.WSeq.exists_get?_of_mem /-
+theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ get? s n :=
   by
   apply mem_rec_on h
   · intro a' s' h
@@ -1014,19 +1275,23 @@ theorem exists_nth_of_mem {s : Wseq α} {a} (h : a ∈ s) : ∃ n, some a ∈ nt
     exists n
     simp [nth]
     apply think_mem h
-#align stream.wseq.exists_nth_of_mem Stream'.Wseq.exists_nth_of_mem
+#align stream.wseq.exists_nth_of_mem Stream'.WSeq.exists_get?_of_mem
+-/
 
-theorem exists_dropn_of_mem {s : Wseq α} {a} (h : a ∈ s) :
+#print Stream'.WSeq.exists_dropn_of_mem /-
+theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) :
     ∃ n s', some (a, s') ∈ destruct (drop s n) :=
-  let ⟨n, h⟩ := exists_nth_of_mem h
+  let ⟨n, h⟩ := exists_get?_of_mem h
   ⟨n, by
     rcases(head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩
     have := Computation.mem_unique (Computation.mem_map _ om) h
     cases' o with o <;> injection this with i
     cases' o with a' s'; dsimp at i
     rw [i] at om; exact ⟨_, om⟩⟩
-#align stream.wseq.exists_dropn_of_mem Stream'.Wseq.exists_dropn_of_mem
+#align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem
+-/
 
+#print Stream'.WSeq.liftRel_dropn_destruct /-
 theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t) :
     ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n))
   | 0 => liftRel_destruct H
@@ -1038,81 +1303,109 @@ theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t
       match a, b, o with
       | none, none, _ => by simp
       | some (a, s), some (b, t), ⟨h1, h2⟩ => by simp [tail.aux] <;> apply lift_rel_destruct h2
-#align stream.wseq.lift_rel_dropn_destruct Stream'.Wseq.liftRel_dropn_destruct
+#align stream.wseq.lift_rel_dropn_destruct Stream'.WSeq.liftRel_dropn_destruct
+-/
 
+#print Stream'.WSeq.exists_of_liftRel_left /-
 theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t) {a} (h : a ∈ s) :
     ∃ b, b ∈ t ∧ R a b :=
-  let ⟨n, h⟩ := exists_nth_of_mem h
+  let ⟨n, h⟩ := exists_get?_of_mem h
   let ⟨some (_, s'), sd, rfl⟩ := Computation.exists_of_mem_map h
   let ⟨some (b, t'), td, ⟨ab, _⟩⟩ := (liftRel_dropn_destruct H n).left sd
-  ⟨b, nth_mem (Computation.mem_map ((· <$> ·) Prod.fst.{v, v}) td), ab⟩
-#align stream.wseq.exists_of_lift_rel_left Stream'.Wseq.exists_of_liftRel_left
+  ⟨b, get?_mem (Computation.mem_map ((· <$> ·) Prod.fst.{v, v}) td), ab⟩
+#align stream.wseq.exists_of_lift_rel_left Stream'.WSeq.exists_of_liftRel_left
+-/
 
+#print Stream'.WSeq.exists_of_liftRel_right /-
 theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) :
     ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H <;> exact exists_of_lift_rel_left H h
-#align stream.wseq.exists_of_lift_rel_right Stream'.Wseq.exists_of_liftRel_right
+#align stream.wseq.exists_of_lift_rel_right Stream'.WSeq.exists_of_liftRel_right
+-/
 
-theorem head_terminates_of_mem {s : Wseq α} {a} (h : a ∈ s) : Terminates (head s) :=
-  let ⟨n, h⟩ := exists_nth_of_mem h
-  head_terminates_of_nth_terminates ⟨⟨_, h⟩⟩
-#align stream.wseq.head_terminates_of_mem Stream'.Wseq.head_terminates_of_mem
+#print Stream'.WSeq.head_terminates_of_mem /-
+theorem head_terminates_of_mem {s : WSeq α} {a} (h : a ∈ s) : Terminates (head s) :=
+  let ⟨n, h⟩ := exists_get?_of_mem h
+  head_terminates_of_get?_terminates ⟨⟨_, h⟩⟩
+#align stream.wseq.head_terminates_of_mem Stream'.WSeq.head_terminates_of_mem
+-/
 
-theorem of_mem_append {s₁ s₂ : Wseq α} {a : α} : a ∈ append s₁ s₂ → a ∈ s₁ ∨ a ∈ s₂ :=
+#print Stream'.WSeq.of_mem_append /-
+theorem of_mem_append {s₁ s₂ : WSeq α} {a : α} : a ∈ append s₁ s₂ → a ∈ s₁ ∨ a ∈ s₂ :=
   Seq.of_mem_append
-#align stream.wseq.of_mem_append Stream'.Wseq.of_mem_append
+#align stream.wseq.of_mem_append Stream'.WSeq.of_mem_append
+-/
 
-theorem mem_append_left {s₁ s₂ : Wseq α} {a : α} : a ∈ s₁ → a ∈ append s₁ s₂ :=
+#print Stream'.WSeq.mem_append_left /-
+theorem mem_append_left {s₁ s₂ : WSeq α} {a : α} : a ∈ s₁ → a ∈ append s₁ s₂ :=
   Seq.mem_append_left
-#align stream.wseq.mem_append_left Stream'.Wseq.mem_append_left
+#align stream.wseq.mem_append_left Stream'.WSeq.mem_append_left
+-/
 
-theorem exists_of_mem_map {f} {b : β} : ∀ {s : Wseq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
+#print Stream'.WSeq.exists_of_mem_map /-
+theorem exists_of_mem_map {f} {b : β} : ∀ {s : WSeq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
   | ⟨g, al⟩, h => by
     let ⟨o, om, oe⟩ := Seq.exists_of_mem_map h
     cases' o with a <;> injection oe with h' <;> exact ⟨a, om, h'⟩
-#align stream.wseq.exists_of_mem_map Stream'.Wseq.exists_of_mem_map
+#align stream.wseq.exists_of_mem_map Stream'.WSeq.exists_of_mem_map
+-/
 
+#print Stream'.WSeq.liftRel_nil /-
 @[simp]
 theorem liftRel_nil (R : α → β → Prop) : LiftRel R nil nil := by rw [lift_rel_destruct_iff] <;> simp
-#align stream.wseq.lift_rel_nil Stream'.Wseq.liftRel_nil
+#align stream.wseq.lift_rel_nil Stream'.WSeq.liftRel_nil
+-/
 
+#print Stream'.WSeq.liftRel_cons /-
 @[simp]
 theorem liftRel_cons (R : α → β → Prop) (a b s t) :
     LiftRel R (cons a s) (cons b t) ↔ R a b ∧ LiftRel R s t := by
   rw [lift_rel_destruct_iff] <;> simp
-#align stream.wseq.lift_rel_cons Stream'.Wseq.liftRel_cons
+#align stream.wseq.lift_rel_cons Stream'.WSeq.liftRel_cons
+-/
 
+#print Stream'.WSeq.liftRel_think_left /-
 @[simp]
 theorem liftRel_think_left (R : α → β → Prop) (s t) : LiftRel R (think s) t ↔ LiftRel R s t := by
   rw [lift_rel_destruct_iff, lift_rel_destruct_iff] <;> simp
-#align stream.wseq.lift_rel_think_left Stream'.Wseq.liftRel_think_left
+#align stream.wseq.lift_rel_think_left Stream'.WSeq.liftRel_think_left
+-/
 
+#print Stream'.WSeq.liftRel_think_right /-
 @[simp]
 theorem liftRel_think_right (R : α → β → Prop) (s t) : LiftRel R s (think t) ↔ LiftRel R s t := by
   rw [lift_rel_destruct_iff, lift_rel_destruct_iff] <;> simp
-#align stream.wseq.lift_rel_think_right Stream'.Wseq.liftRel_think_right
+#align stream.wseq.lift_rel_think_right Stream'.WSeq.liftRel_think_right
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem cons_congr {s t : Wseq α} (a : α) (h : s ~ t) : cons a s ~ cons a t := by
+#print Stream'.WSeq.cons_congr /-
+theorem cons_congr {s t : WSeq α} (a : α) (h : s ~ t) : cons a s ~ cons a t := by
   unfold Equiv <;> simp <;> exact h
-#align stream.wseq.cons_congr Stream'.Wseq.cons_congr
+#align stream.wseq.cons_congr Stream'.WSeq.cons_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem think_equiv (s : Wseq α) : think s ~ s := by unfold Equiv <;> simp <;> apply Equiv.refl
-#align stream.wseq.think_equiv Stream'.Wseq.think_equiv
+#print Stream'.WSeq.think_equiv /-
+theorem think_equiv (s : WSeq α) : think s ~ s := by unfold Equiv <;> simp <;> apply Equiv.refl
+#align stream.wseq.think_equiv Stream'.WSeq.think_equiv
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem think_congr {s t : Wseq α} (h : s ~ t) : think s ~ think t := by
+#print Stream'.WSeq.think_congr /-
+theorem think_congr {s t : WSeq α} (h : s ~ t) : think s ~ think t := by
   unfold Equiv <;> simp <;> exact h
-#align stream.wseq.think_congr Stream'.Wseq.think_congr
+#align stream.wseq.think_congr Stream'.WSeq.think_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem head_congr : ∀ {s t : Wseq α}, s ~ t → head s ~ head t :=
+#print Stream'.WSeq.head_congr /-
+theorem head_congr : ∀ {s t : WSeq α}, s ~ t → head s ~ head t :=
   by
-  suffices ∀ {s t : Wseq α}, s ~ t → ∀ {o}, o ∈ head s → o ∈ head t from fun s t h o =>
+  suffices ∀ {s t : WSeq α}, s ~ t → ∀ {o}, o ∈ head s → o ∈ head t from fun s t h o =>
     ⟨this h, this h.symm⟩
   intro s t h o ho
   rcases@Computation.exists_of_mem_map _ _ _ _ (destruct s) ho with ⟨ds, dsm, dse⟩
@@ -1129,18 +1422,22 @@ theorem head_congr : ∀ {s t : Wseq α}, s ~ t → head s ~ head t :=
     cases' b with b t'
     rw [dst.left]
     exact @Computation.mem_map _ _ (@Functor.map _ _ (α × wseq α) _ Prod.fst) _ (destruct t) dtm
-#align stream.wseq.head_congr Stream'.Wseq.head_congr
+#align stream.wseq.head_congr Stream'.WSeq.head_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem flatten_equiv {c : Computation (Wseq α)} {s} (h : s ∈ c) : flatten c ~ s :=
+#print Stream'.WSeq.flatten_equiv /-
+theorem flatten_equiv {c : Computation (WSeq α)} {s} (h : s ∈ c) : flatten c ~ s :=
   by
   apply Computation.memRecOn h; · simp
   · intro s'
     apply Equiv.trans
     simp [think_equiv]
-#align stream.wseq.flatten_equiv Stream'.Wseq.flatten_equiv
+#align stream.wseq.flatten_equiv Stream'.WSeq.flatten_equiv
+-/
 
-theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (Wseq α)} {c2 : Computation (Wseq β)}
+#print Stream'.WSeq.liftRel_flatten /-
+theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (WSeq α)} {c2 : Computation (WSeq β)}
     (h : c1.LiftRel (LiftRel R) c2) : LiftRel R (flatten c1) (flatten c2) :=
   let S s t := ∃ c1 c2, s = flatten c1 ∧ t = flatten c2 ∧ Computation.LiftRel (LiftRel R) c1 c2
   ⟨S, ⟨c1, c2, rfl, rfl, h⟩, fun s t h =>
@@ -1150,17 +1447,21 @@ theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (Wseq α)} {c
       intro a b ab; apply Computation.LiftRel.imp _ _ _ (lift_rel_destruct ab)
       intro a b; apply lift_rel_o.imp_right
       intro s t h; refine' ⟨return s, return t, _, _, _⟩ <;> simp [h]⟩
-#align stream.wseq.lift_rel_flatten Stream'.Wseq.liftRel_flatten
+#align stream.wseq.lift_rel_flatten Stream'.WSeq.liftRel_flatten
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem flatten_congr {c1 c2 : Computation (Wseq α)} :
+#print Stream'.WSeq.flatten_congr /-
+theorem flatten_congr {c1 c2 : Computation (WSeq α)} :
     Computation.LiftRel Equiv c1 c2 → flatten c1 ~ flatten c2 :=
   liftRel_flatten
-#align stream.wseq.flatten_congr Stream'.Wseq.flatten_congr
+#align stream.wseq.flatten_congr Stream'.WSeq.flatten_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem tail_congr {s t : Wseq α} (h : s ~ t) : tail s ~ tail t :=
+#print Stream'.WSeq.tail_congr /-
+theorem tail_congr {s t : WSeq α} (h : s ~ t) : tail s ~ tail t :=
   by
   apply flatten_congr
   unfold Functor.map; rw [← bind_ret, ← bind_ret]
@@ -1174,40 +1475,50 @@ theorem tail_congr {s t : Wseq α} (h : s ~ t) : tail s ~ tail t :=
   · cases' a with a s'
     cases' b with b t'
     exact h.right
-#align stream.wseq.tail_congr Stream'.Wseq.tail_congr
+#align stream.wseq.tail_congr Stream'.WSeq.tail_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem dropn_congr {s t : Wseq α} (h : s ~ t) (n) : drop s n ~ drop t n := by
+#print Stream'.WSeq.dropn_congr /-
+theorem dropn_congr {s t : WSeq α} (h : s ~ t) (n) : drop s n ~ drop t n := by
   induction n <;> simp [*, tail_congr]
-#align stream.wseq.dropn_congr Stream'.Wseq.dropn_congr
+#align stream.wseq.dropn_congr Stream'.WSeq.dropn_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem nth_congr {s t : Wseq α} (h : s ~ t) (n) : nth s n ~ nth t n :=
+#print Stream'.WSeq.get?_congr /-
+theorem get?_congr {s t : WSeq α} (h : s ~ t) (n) : get? s n ~ get? t n :=
   head_congr (dropn_congr h _)
-#align stream.wseq.nth_congr Stream'.Wseq.nth_congr
+#align stream.wseq.nth_congr Stream'.WSeq.get?_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem mem_congr {s t : Wseq α} (h : s ~ t) (a) : a ∈ s ↔ a ∈ t :=
-  suffices ∀ {s t : Wseq α}, s ~ t → a ∈ s → a ∈ t from ⟨this h, this h.symm⟩
+#print Stream'.WSeq.mem_congr /-
+theorem mem_congr {s t : WSeq α} (h : s ~ t) (a) : a ∈ s ↔ a ∈ t :=
+  suffices ∀ {s t : WSeq α}, s ~ t → a ∈ s → a ∈ t from ⟨this h, this h.symm⟩
   fun s t h as =>
-  let ⟨n, hn⟩ := exists_nth_of_mem as
-  nth_mem ((nth_congr h _ _).1 hn)
-#align stream.wseq.mem_congr Stream'.Wseq.mem_congr
+  let ⟨n, hn⟩ := exists_get?_of_mem as
+  get?_mem ((get?_congr h _ _).1 hn)
+#align stream.wseq.mem_congr Stream'.WSeq.mem_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem productive_congr {s t : Wseq α} (h : s ~ t) : Productive s ↔ Productive t := by
+#print Stream'.WSeq.productive_congr /-
+theorem productive_congr {s t : WSeq α} (h : s ~ t) : Productive s ↔ Productive t := by
   simp only [productive_iff] <;> exact forall_congr' fun n => terminates_congr <| nth_congr h _
-#align stream.wseq.productive_congr Stream'.Wseq.productive_congr
+#align stream.wseq.productive_congr Stream'.WSeq.productive_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem Equiv.ext {s t : Wseq α} (h : ∀ n, nth s n ~ nth t n) : s ~ t :=
-  ⟨fun s t => ∀ n, nth s n ~ nth t n, h, fun s t h =>
+#print Stream'.WSeq.Equiv.ext /-
+theorem Equiv.ext {s t : WSeq α} (h : ∀ n, get? s n ~ get? t n) : s ~ t :=
+  ⟨fun s t => ∀ n, get? s n ~ get? t n, h, fun s t h =>
     by
     refine' lift_rel_def.2 ⟨_, _⟩
     · rw [← head_terminates_iff, ← head_terminates_iff]
@@ -1228,10 +1539,12 @@ theorem Equiv.ext {s t : Wseq α} (h : ∀ n, nth s n ~ nth t n) : s ~ t :=
               (nth_congr (flatten_equiv (Computation.mem_map _ mb)) n))
         rw [nth_tail, nth_tail]
         apply h⟩
-#align stream.wseq.equiv.ext Stream'.Wseq.Equiv.ext
+#align stream.wseq.equiv.ext Stream'.WSeq.Equiv.ext
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem length_eq_map (s : Wseq α) : length s = Computation.map List.length (toList s) :=
+#print Stream'.WSeq.length_eq_map /-
+theorem length_eq_map (s : WSeq α) : length s = Computation.map List.length (toList s) :=
   by
   refine'
     Computation.eq_of_bisim
@@ -1244,43 +1557,55 @@ theorem length_eq_map (s : Wseq α) : length s = Computation.map List.length (to
   apply s.rec_on _ (fun a s => _) fun s => _ <;> repeat' simp [to_list, nil, cons, think, length]
   · refine' ⟨a::l, s, _, _⟩ <;> simp
   · refine' ⟨l, s, _, _⟩ <;> simp
-#align stream.wseq.length_eq_map Stream'.Wseq.length_eq_map
+#align stream.wseq.length_eq_map Stream'.WSeq.length_eq_map
+-/
 
+#print Stream'.WSeq.ofList_nil /-
 @[simp]
-theorem ofList_nil : ofList [] = (nil : Wseq α) :=
+theorem ofList_nil : ofList [] = (nil : WSeq α) :=
   rfl
-#align stream.wseq.of_list_nil Stream'.Wseq.ofList_nil
+#align stream.wseq.of_list_nil Stream'.WSeq.ofList_nil
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.ofList_cons /-
 @[simp]
 theorem ofList_cons (a : α) (l) : ofList (a::l) = cons a (ofList l) :=
   show Seq.map some (Seq.ofList (a::l)) = Seq.cons (some a) (Seq.map some (Seq.ofList l)) by simp
-#align stream.wseq.of_list_cons Stream'.Wseq.ofList_cons
+#align stream.wseq.of_list_cons Stream'.WSeq.ofList_cons
+-/
 
+#print Stream'.WSeq.toList'_nil /-
 @[simp]
-theorem to_list'_nil (l : List α) : Computation.corec ToList._match2 (l, nil) = return l.reverse :=
+theorem toList'_nil (l : List α) : Computation.corec toList._match2 (l, nil) = return l.reverse :=
   destruct_eq_pure rfl
-#align stream.wseq.to_list'_nil Stream'.Wseq.to_list'_nil
+#align stream.wseq.to_list'_nil Stream'.WSeq.toList'_nil
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.toList'_cons /-
 @[simp]
-theorem to_list'_cons (l : List α) (s : Wseq α) (a : α) :
-    Computation.corec ToList._match2 (l, cons a s) =
-      (Computation.corec ToList._match2 (a::l, s)).think :=
+theorem toList'_cons (l : List α) (s : WSeq α) (a : α) :
+    Computation.corec toList._match2 (l, cons a s) =
+      (Computation.corec toList._match2 (a::l, s)).think :=
   destruct_eq_think <| by simp [to_list, cons]
-#align stream.wseq.to_list'_cons Stream'.Wseq.to_list'_cons
+#align stream.wseq.to_list'_cons Stream'.WSeq.toList'_cons
+-/
 
+#print Stream'.WSeq.toList'_think /-
 @[simp]
-theorem to_list'_think (l : List α) (s : Wseq α) :
-    Computation.corec ToList._match2 (l, think s) =
-      (Computation.corec ToList._match2 (l, s)).think :=
+theorem toList'_think (l : List α) (s : WSeq α) :
+    Computation.corec toList._match2 (l, think s) =
+      (Computation.corec toList._match2 (l, s)).think :=
   destruct_eq_think <| by simp [to_list, think]
-#align stream.wseq.to_list'_think Stream'.Wseq.to_list'_think
+#align stream.wseq.to_list'_think Stream'.WSeq.toList'_think
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem to_list'_map (l : List α) (s : Wseq α) :
-    Computation.corec ToList._match2 (l, s) = (· ++ ·) l.reverse <$> toList s :=
+#print Stream'.WSeq.toList'_map /-
+theorem toList'_map (l : List α) (s : WSeq α) :
+    Computation.corec toList._match2 (l, s) = (· ++ ·) l.reverse <$> toList s :=
   by
   refine'
     Computation.eq_of_bisim
@@ -1293,22 +1618,30 @@ theorem to_list'_map (l : List α) (s : Wseq α) :
   apply s.rec_on _ (fun a s => _) fun s => _ <;> repeat' simp [to_list, nil, cons, think, length]
   · refine' ⟨a::l', s, _, _⟩ <;> simp
   · refine' ⟨l', s, _, _⟩ <;> simp
-#align stream.wseq.to_list'_map Stream'.Wseq.to_list'_map
+#align stream.wseq.to_list'_map Stream'.WSeq.toList'_map
+-/
 
+#print Stream'.WSeq.toList_cons /-
 @[simp]
 theorem toList_cons (a : α) (s) : toList (cons a s) = (List.cons a <$> toList s).think :=
   destruct_eq_think <| by unfold to_list <;> simp <;> rw [to_list'_map] <;> simp <;> rfl
-#align stream.wseq.to_list_cons Stream'.Wseq.toList_cons
+#align stream.wseq.to_list_cons Stream'.WSeq.toList_cons
+-/
 
+#print Stream'.WSeq.toList_nil /-
 @[simp]
-theorem toList_nil : toList (nil : Wseq α) = return [] :=
+theorem toList_nil : toList (nil : WSeq α) = return [] :=
   destruct_eq_pure rfl
-#align stream.wseq.to_list_nil Stream'.Wseq.toList_nil
+#align stream.wseq.to_list_nil Stream'.WSeq.toList_nil
+-/
 
+#print Stream'.WSeq.toList_ofList /-
 theorem toList_ofList (l : List α) : l ∈ toList (ofList l) := by
   induction' l with a l IH <;> simp [ret_mem] <;> exact think_mem (Computation.mem_map _ IH)
-#align stream.wseq.to_list_of_list Stream'.Wseq.toList_ofList
+#align stream.wseq.to_list_of_list Stream'.WSeq.toList_ofList
+-/
 
+#print Stream'.WSeq.destruct_ofSeq /-
 @[simp]
 theorem destruct_ofSeq (s : Seq α) :
     destruct (ofSeq s) = return (s.headI.map fun a => (a, ofSeq s.tail)) :=
@@ -1318,90 +1651,122 @@ theorem destruct_ofSeq (s : Seq α) :
     cases' seq.nth s 0 with a; · rfl
     unfold Functor.map
     simp [destruct]
-#align stream.wseq.destruct_of_seq Stream'.Wseq.destruct_ofSeq
+#align stream.wseq.destruct_of_seq Stream'.WSeq.destruct_ofSeq
+-/
 
+#print Stream'.WSeq.head_ofSeq /-
 @[simp]
 theorem head_ofSeq (s : Seq α) : head (ofSeq s) = return s.headI := by
   simp [head] <;> cases seq.head s <;> rfl
-#align stream.wseq.head_of_seq Stream'.Wseq.head_ofSeq
+#align stream.wseq.head_of_seq Stream'.WSeq.head_ofSeq
+-/
 
+#print Stream'.WSeq.tail_ofSeq /-
 @[simp]
 theorem tail_ofSeq (s : Seq α) : tail (ofSeq s) = ofSeq s.tail :=
   by
   simp [tail]; apply s.rec_on _ fun x s => _ <;> simp [of_seq]; · rfl
   rw [seq.head_cons, seq.tail_cons]; rfl
-#align stream.wseq.tail_of_seq Stream'.Wseq.tail_ofSeq
+#align stream.wseq.tail_of_seq Stream'.WSeq.tail_ofSeq
+-/
 
+#print Stream'.WSeq.dropn_ofSeq /-
 @[simp]
 theorem dropn_ofSeq (s : Seq α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n)
   | 0 => rfl
   | n + 1 => by dsimp [drop] <;> rw [dropn_of_seq, tail_of_seq]
-#align stream.wseq.dropn_of_seq Stream'.Wseq.dropn_ofSeq
+#align stream.wseq.dropn_of_seq Stream'.WSeq.dropn_ofSeq
+-/
 
-theorem nth_ofSeq (s : Seq α) (n) : nth (ofSeq s) n = return (Seq.get? s n) := by
+#print Stream'.WSeq.get?_ofSeq /-
+theorem get?_ofSeq (s : Seq α) (n) : get? (ofSeq s) n = return (Seq.get? s n) := by
   dsimp [nth] <;> rw [dropn_of_seq, head_of_seq, seq.head_dropn]
-#align stream.wseq.nth_of_seq Stream'.Wseq.nth_ofSeq
+#align stream.wseq.nth_of_seq Stream'.WSeq.get?_ofSeq
+-/
 
+#print Stream'.WSeq.productive_ofSeq /-
 instance productive_ofSeq (s : Seq α) : Productive (ofSeq s) :=
   ⟨fun n => by rw [nth_of_seq] <;> infer_instance⟩
-#align stream.wseq.productive_of_seq Stream'.Wseq.productive_ofSeq
+#align stream.wseq.productive_of_seq Stream'.WSeq.productive_ofSeq
+-/
 
+#print Stream'.WSeq.toSeq_ofSeq /-
 theorem toSeq_ofSeq (s : Seq α) : toSeq (ofSeq s) = s :=
   by
   apply Subtype.eq; funext n
   dsimp [to_seq]; apply get_eq_of_mem
   rw [nth_of_seq]; apply ret_mem
-#align stream.wseq.to_seq_of_seq Stream'.Wseq.toSeq_ofSeq
+#align stream.wseq.to_seq_of_seq Stream'.WSeq.toSeq_ofSeq
+-/
 
+#print Stream'.WSeq.ret /-
 /-- The monadic `return a` is a singleton list containing `a`. -/
-def ret (a : α) : Wseq α :=
+def ret (a : α) : WSeq α :=
   ofList [a]
-#align stream.wseq.ret Stream'.Wseq.ret
+#align stream.wseq.ret Stream'.WSeq.ret
+-/
 
+#print Stream'.WSeq.map_nil /-
 @[simp]
 theorem map_nil (f : α → β) : map f nil = nil :=
   rfl
-#align stream.wseq.map_nil Stream'.Wseq.map_nil
+#align stream.wseq.map_nil Stream'.WSeq.map_nil
+-/
 
+#print Stream'.WSeq.map_cons /-
 @[simp]
 theorem map_cons (f : α → β) (a s) : map f (cons a s) = cons (f a) (map f s) :=
   Seq.map_cons _ _ _
-#align stream.wseq.map_cons Stream'.Wseq.map_cons
+#align stream.wseq.map_cons Stream'.WSeq.map_cons
+-/
 
+#print Stream'.WSeq.map_think /-
 @[simp]
 theorem map_think (f : α → β) (s) : map f (think s) = think (map f s) :=
   Seq.map_cons _ _ _
-#align stream.wseq.map_think Stream'.Wseq.map_think
+#align stream.wseq.map_think Stream'.WSeq.map_think
+-/
 
+#print Stream'.WSeq.map_id /-
 @[simp]
-theorem map_id (s : Wseq α) : map id s = s := by simp [map]
-#align stream.wseq.map_id Stream'.Wseq.map_id
+theorem map_id (s : WSeq α) : map id s = s := by simp [map]
+#align stream.wseq.map_id Stream'.WSeq.map_id
+-/
 
+#print Stream'.WSeq.map_ret /-
 @[simp]
 theorem map_ret (f : α → β) (a) : map f (ret a) = ret (f a) := by simp [ret]
-#align stream.wseq.map_ret Stream'.Wseq.map_ret
+#align stream.wseq.map_ret Stream'.WSeq.map_ret
+-/
 
+#print Stream'.WSeq.map_append /-
 @[simp]
 theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s) (map f t) :=
   Seq.map_append _ _ _
-#align stream.wseq.map_append Stream'.Wseq.map_append
+#align stream.wseq.map_append Stream'.WSeq.map_append
+-/
 
-theorem map_comp (f : α → β) (g : β → γ) (s : Wseq α) : map (g ∘ f) s = map g (map f s) :=
+#print Stream'.WSeq.map_comp /-
+theorem map_comp (f : α → β) (g : β → γ) (s : WSeq α) : map (g ∘ f) s = map g (map f s) :=
   by
   dsimp [map]; rw [← seq.map_comp]
   apply congr_fun; apply congr_arg
   ext ⟨⟩ <;> rfl
-#align stream.wseq.map_comp Stream'.Wseq.map_comp
+#align stream.wseq.map_comp Stream'.WSeq.map_comp
+-/
 
-theorem mem_map (f : α → β) {a : α} {s : Wseq α} : a ∈ s → f a ∈ map f s :=
+#print Stream'.WSeq.mem_map /-
+theorem mem_map (f : α → β) {a : α} {s : WSeq α} : a ∈ s → f a ∈ map f s :=
   Seq.mem_map (Option.map f)
-#align stream.wseq.mem_map Stream'.Wseq.mem_map
+#align stream.wseq.mem_map Stream'.WSeq.mem_map
+-/
 
+#print Stream'.WSeq.exists_of_mem_join /-
 -- The converse is not true without additional assumptions
-theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S → ∃ s, s ∈ S ∧ a ∈ s :=
+theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S → ∃ s, s ∈ S ∧ a ∈ s :=
   by
   suffices
-    ∀ ss : Wseq α,
+    ∀ ss : WSeq α,
       a ∈ ss → ∀ s S, append s (join S) = ss → a ∈ append s (join S) → a ∈ s ∨ ∃ s, s ∈ S ∧ a ∈ s
     from fun S h => (this _ h nil S (by simp) (by simp [h])).resolve_left (not_mem_nil _)
   intro ss h; apply mem_rec_on h (fun b ss o => _) fun ss IH => _ <;> intro s S
@@ -1430,16 +1795,24 @@ theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S →
       exact ⟨s, by simp [sS], as⟩
     · simp at m IH⊢
       apply IH _ _ rfl m
-#align stream.wseq.exists_of_mem_join Stream'.Wseq.exists_of_mem_join
+#align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
+-/
 
-theorem exists_of_mem_bind {s : Wseq α} {f : α → Wseq β} {b} (h : b ∈ bind s f) :
+/- warning: stream.wseq.exists_of_mem_bind -> Stream'.WSeq.exists_of_mem_bind is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {s : Stream'.WSeq.{u1} α} {f : α -> (Stream'.WSeq.{u2} β)} {b : β}, (Membership.Mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (Stream'.WSeq.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) (fun (H : Membership.Mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) => Membership.Mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (f a))))
+but is expected to have type
+  forall {α : Type.{u1}} {β : Type.{u2}} {s : Stream'.WSeq.{u1} α} {f : α -> (Stream'.WSeq.{u2} β)} {b : β}, (Membership.mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (Stream'.WSeq.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Stream'.WSeq.{u1} α) (Stream'.WSeq.membership.{u1} α) a s) (Membership.mem.{u2, u2} β (Stream'.WSeq.{u2} β) (Stream'.WSeq.membership.{u2} β) b (f a))))
+Case conversion may be inaccurate. Consider using '#align stream.wseq.exists_of_mem_bind Stream'.WSeq.exists_of_mem_bindₓ'. -/
+theorem exists_of_mem_bind {s : WSeq α} {f : α → WSeq β} {b} (h : b ∈ bind s f) :
     ∃ a ∈ s, b ∈ f a :=
   let ⟨t, tm, bt⟩ := exists_of_mem_join h
   let ⟨a, as, e⟩ := exists_of_mem_map tm
   ⟨a, as, by rwa [e]⟩
-#align stream.wseq.exists_of_mem_bind Stream'.Wseq.exists_of_mem_bind
+#align stream.wseq.exists_of_mem_bind Stream'.WSeq.exists_of_mem_bind
 
-theorem destruct_map (f : α → β) (s : Wseq α) :
+#print Stream'.WSeq.destruct_map /-
+theorem destruct_map (f : α → β) (s : WSeq α) :
     destruct (map f s) = Computation.map (Option.map (Prod.map f (map f))) (destruct s) :=
   by
   apply
@@ -1453,9 +1826,16 @@ theorem destruct_map (f : α → β) (s : Wseq α) :
     apply s.rec_on _ (fun a s => _) fun s => _ <;> simp
     exact ⟨s, rfl, rfl⟩
   · exact ⟨s, rfl, rfl⟩
-#align stream.wseq.destruct_map Stream'.Wseq.destruct_map
+#align stream.wseq.destruct_map Stream'.WSeq.destruct_map
+-/
 
-theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Wseq α} {s2 : Wseq β}
+/- warning: stream.wseq.lift_rel_map -> Stream'.WSeq.liftRel_map is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u1} α} {s2 : Stream'.WSeq.{u2} β} {f1 : α -> γ} {f2 : β -> δ}, (Stream'.WSeq.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (Stream'.WSeq.map.{u1, u3} α γ f1 s1) (Stream'.WSeq.map.{u2, u4} β δ f2 s2))
+but is expected to have type
+  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u2} α} {s2 : Stream'.WSeq.{u3} β} {f1 : α -> γ} {f2 : β -> δ}, (Stream'.WSeq.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (Stream'.WSeq.map.{u2, u4} α γ f1 s1) (Stream'.WSeq.map.{u3, u1} β δ f2 s2))
+Case conversion may be inaccurate. Consider using '#align stream.wseq.lift_rel_map Stream'.WSeq.liftRel_mapₓ'. -/
+theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
     {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2) (h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) :
     LiftRel S (map f1 s1) (map f2 s2) :=
   ⟨fun s1 s2 => ∃ s t, s1 = map f1 s ∧ s2 = map f2 t ∧ LiftRel R s t, ⟨s1, s2, rfl, rfl, h1⟩,
@@ -1470,23 +1850,28 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
       · cases' a with a s <;> cases' b with b t
         cases' h with r h
         exact ⟨h2 r, s, rfl, t, rfl, h⟩⟩
-#align stream.wseq.lift_rel_map Stream'.Wseq.liftRel_map
+#align stream.wseq.lift_rel_map Stream'.WSeq.liftRel_map
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem map_congr (f : α → β) {s t : Wseq α} (h : s ~ t) : map f s ~ map f t :=
+#print Stream'.WSeq.map_congr /-
+theorem map_congr (f : α → β) {s t : WSeq α} (h : s ~ t) : map f s ~ map f t :=
   liftRel_map _ _ h fun _ _ => congr_arg _
-#align stream.wseq.map_congr Stream'.Wseq.map_congr
+#align stream.wseq.map_congr Stream'.WSeq.map_congr
+-/
 
+#print Stream'.WSeq.destruct_append.aux /-
 /-- auxilary defintion of `destruct_append` over weak sequences-/
 @[simp]
-def DestructAppend.aux (t : Wseq α) : Option (α × Wseq α) → Computation (Option (α × Wseq α))
+def destruct_append.aux (t : WSeq α) : Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | none => destruct t
   | some (a, s) => return (some (a, append s t))
-#align stream.wseq.destruct_append.aux Stream'.Wseq.DestructAppend.aux
+#align stream.wseq.destruct_append.aux Stream'.WSeq.destruct_append.aux
+-/
 
-theorem destruct_append (s t : Wseq α) :
-    destruct (append s t) = (destruct s).bind (DestructAppend.aux t) :=
+#print Stream'.WSeq.destruct_append /-
+theorem destruct_append (s t : WSeq α) :
+    destruct (append s t) = (destruct s).bind (destruct_append.aux t) :=
   by
   apply
     Computation.eq_of_bisim
@@ -1498,17 +1883,21 @@ theorem destruct_append (s t : Wseq α) :
   · apply t.rec_on _ (fun b t => _) fun t => _ <;> simp
     · refine' ⟨nil, t, _, _⟩ <;> simp
   · exact ⟨s, t, rfl, rfl⟩
-#align stream.wseq.destruct_append Stream'.Wseq.destruct_append
+#align stream.wseq.destruct_append Stream'.WSeq.destruct_append
+-/
 
+#print Stream'.WSeq.destruct_join.aux /-
 /-- auxilary defintion of `destruct_join` over weak sequences-/
 @[simp]
-def DestructJoin.aux : Option (Wseq α × Wseq (Wseq α)) → Computation (Option (α × Wseq α))
+def destruct_join.aux : Option (WSeq α × WSeq (WSeq α)) → Computation (Option (α × WSeq α))
   | none => return none
   | some (s, S) => (destruct (append s (join S))).think
-#align stream.wseq.destruct_join.aux Stream'.Wseq.DestructJoin.aux
+#align stream.wseq.destruct_join.aux Stream'.WSeq.destruct_join.aux
+-/
 
-theorem destruct_join (S : Wseq (Wseq α)) :
-    destruct (join S) = (destruct S).bind DestructJoin.aux :=
+#print Stream'.WSeq.destruct_join /-
+theorem destruct_join (S : WSeq (WSeq α)) :
+    destruct (join S) = (destruct S).bind destruct_join.aux :=
   by
   apply
     Computation.eq_of_bisim
@@ -1523,9 +1912,11 @@ theorem destruct_join (S : Wseq (Wseq α)) :
       by
       apply S.rec_on _ (fun s S => _) fun S => _ <;> simp
       · refine' Or.inr ⟨S, rfl, rfl⟩
-#align stream.wseq.destruct_join Stream'.Wseq.destruct_join
+#align stream.wseq.destruct_join Stream'.WSeq.destruct_join
+-/
 
-theorem liftRel_append (R : α → β → Prop) {s1 s2 : Wseq α} {t1 t2 : Wseq β} (h1 : LiftRel R s1 t1)
+#print Stream'.WSeq.liftRel_append /-
+theorem liftRel_append (R : α → β → Prop) {s1 s2 : WSeq α} {t1 t2 : WSeq β} (h1 : LiftRel R s1 t1)
     (h2 : LiftRel R s2 t2) : LiftRel R (append s1 s2) (append t1 t2) :=
   ⟨fun s t => LiftRel R s t ∨ ∃ s1 t1, s = append s1 s2 ∧ t = append t1 t2 ∧ LiftRel R s1 t1,
     Or.inr ⟨s1, t1, rfl, rfl, h1⟩, fun s t h =>
@@ -1553,9 +1944,11 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : Wseq α} {t1 t2 : Wseq
         cases' h with r h
         simp
         exact ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
-#align stream.wseq.lift_rel_append Stream'.Wseq.liftRel_append
+#align stream.wseq.lift_rel_append Stream'.WSeq.liftRel_append
+-/
 
-theorem LiftRelJoin.lem (R : α → β → Prop) {S T} {U : Wseq α → Wseq β → Prop}
+#print Stream'.WSeq.liftRel_join.lem /-
+theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β → Prop}
     (ST : LiftRel (LiftRel R) S T)
     (HU :
       ∀ s1 s2,
@@ -1608,9 +2001,11 @@ theorem LiftRelJoin.lem (R : α → β → Prop) {S T} {U : Wseq α → Wseq β
               apply ret_mem
             rw [eq_of_ret_mem rs5.mem]
             exact ⟨ab, HU _ _ ⟨s', t', S', T', rfl, rfl, st', ST'⟩⟩
-#align stream.wseq.lift_rel_join.lem Stream'.Wseq.LiftRelJoin.lem
+#align stream.wseq.lift_rel_join.lem Stream'.WSeq.liftRel_join.lem
+-/
 
-theorem liftRel_join (R : α → β → Prop) {S : Wseq (Wseq α)} {T : Wseq (Wseq β)}
+#print Stream'.WSeq.liftRel_join /-
+theorem liftRel_join (R : α → β → Prop) {S : WSeq (WSeq α)} {T : WSeq (WSeq β)}
     (h : LiftRel (LiftRel R) S T) : LiftRel R (join S) (join T) :=
   ⟨fun s1 s2 =>
     ∃ s t S T,
@@ -1635,35 +2030,49 @@ theorem liftRel_join (R : α → β → Prop) {S : Wseq (Wseq α)} {T : Wseq (Ws
           · rw [← lift_rel.swap R, ← lift_rel.swap (lift_rel R)]
             exact fun s1 s2 ⟨s, t, S, T, h1, h2, st, ST⟩ => ⟨t, s, T, S, h2, h1, st, ST⟩
           · exact mb⟩
-#align stream.wseq.lift_rel_join Stream'.Wseq.liftRel_join
+#align stream.wseq.lift_rel_join Stream'.WSeq.liftRel_join
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem join_congr {S T : Wseq (Wseq α)} (h : LiftRel Equiv S T) : join S ~ join T :=
+#print Stream'.WSeq.join_congr /-
+theorem join_congr {S T : WSeq (WSeq α)} (h : LiftRel Equiv S T) : join S ~ join T :=
   liftRel_join _ h
-#align stream.wseq.join_congr Stream'.Wseq.join_congr
+#align stream.wseq.join_congr Stream'.WSeq.join_congr
+-/
 
-theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Wseq α} {s2 : Wseq β}
-    {f1 : α → Wseq γ} {f2 : β → Wseq δ} (h1 : LiftRel R s1 s2)
+/- warning: stream.wseq.lift_rel_bind -> Stream'.WSeq.liftRel_bind is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u1} α} {s2 : Stream'.WSeq.{u2} β} {f1 : α -> (Stream'.WSeq.{u3} γ)} {f2 : β -> (Stream'.WSeq.{u4} δ)}, (Stream'.WSeq.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u3, u4} γ δ S (Stream'.WSeq.bind.{u1, u3} α γ s1 f1) (Stream'.WSeq.bind.{u2, u4} β δ s2 f2))
+but is expected to have type
+  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Stream'.WSeq.{u2} α} {s2 : Stream'.WSeq.{u3} β} {f1 : α -> (Stream'.WSeq.{u4} γ)} {f2 : β -> (Stream'.WSeq.{u1} δ)}, (Stream'.WSeq.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (f1 a) (f2 b))) -> (Stream'.WSeq.LiftRel.{u4, u1} γ δ S (Stream'.WSeq.bind.{u2, u4} α γ s1 f1) (Stream'.WSeq.bind.{u3, u1} β δ s2 f2))
+Case conversion may be inaccurate. Consider using '#align stream.wseq.lift_rel_bind Stream'.WSeq.liftRel_bindₓ'. -/
+theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : WSeq α} {s2 : WSeq β}
+    {f1 : α → WSeq γ} {f2 : β → WSeq δ} (h1 : LiftRel R s1 s2)
     (h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
   liftRel_join _ (liftRel_map _ _ h1 @h2)
-#align stream.wseq.lift_rel_bind Stream'.Wseq.liftRel_bind
+#align stream.wseq.lift_rel_bind Stream'.WSeq.liftRel_bind
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem bind_congr {s1 s2 : Wseq α} {f1 f2 : α → Wseq β} (h1 : s1 ~ s2) (h2 : ∀ a, f1 a ~ f2 a) :
+#print Stream'.WSeq.bind_congr /-
+theorem bind_congr {s1 s2 : WSeq α} {f1 f2 : α → WSeq β} (h1 : s1 ~ s2) (h2 : ∀ a, f1 a ~ f2 a) :
     bind s1 f1 ~ bind s2 f2 :=
   liftRel_bind _ _ h1 fun a b h => by rw [h] <;> apply h2
-#align stream.wseq.bind_congr Stream'.Wseq.bind_congr
+#align stream.wseq.bind_congr Stream'.WSeq.bind_congr
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.join_ret /-
 @[simp]
-theorem join_ret (s : Wseq α) : join (ret s) ~ s := by simp [ret] <;> apply think_equiv
-#align stream.wseq.join_ret Stream'.Wseq.join_ret
+theorem join_ret (s : WSeq α) : join (ret s) ~ s := by simp [ret] <;> apply think_equiv
+#align stream.wseq.join_ret Stream'.WSeq.join_ret
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.join_map_ret /-
 @[simp]
-theorem join_map_ret (s : Wseq α) : join (map ret s) ~ s :=
+theorem join_map_ret (s : WSeq α) : join (map ret s) ~ s :=
   by
   refine' ⟨fun s1 s2 => join (map ret s2) = s1, rfl, _⟩
   intro s' s h; rw [← h]
@@ -1680,11 +2089,13 @@ theorem join_map_ret (s : Wseq α) : join (map ret s) ~ s :=
           fun s => ⟨s, rfl, rfl⟩
         apply s.rec_on _ (fun a s => _) fun s => _ <;> simp [ret, ret_mem, this, Option.exists]
   · exact ⟨s, rfl, rfl⟩
-#align stream.wseq.join_map_ret Stream'.Wseq.join_map_ret
+#align stream.wseq.join_map_ret Stream'.WSeq.join_map_ret
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.join_append /-
 @[simp]
-theorem join_append (S T : Wseq (Wseq α)) : join (append S T) ~ append (join S) (join T) :=
+theorem join_append (S T : WSeq (WSeq α)) : join (append S T) ~ append (join S) (join T) :=
   by
   refine'
     ⟨fun s1 s2 =>
@@ -1714,21 +2125,27 @@ theorem join_append (S T : Wseq (Wseq α)) : join (append S T) ~ append (join S)
         · refine' ⟨nil, S, T, _, _⟩ <;> simp
       · exact ⟨s, S, T, rfl, rfl⟩
       · exact ⟨s, S, T, rfl, rfl⟩
-#align stream.wseq.join_append Stream'.Wseq.join_append
+#align stream.wseq.join_append Stream'.WSeq.join_append
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.bind_ret /-
 @[simp]
 theorem bind_ret (f : α → β) (s) : bind s (ret ∘ f) ~ map f s :=
   by
   dsimp [bind]; change fun x => ret (f x) with ret ∘ f
   rw [map_comp]; apply join_map_ret
-#align stream.wseq.bind_ret Stream'.Wseq.bind_ret
+#align stream.wseq.bind_ret Stream'.WSeq.bind_ret
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.ret_bind /-
 @[simp]
-theorem ret_bind (a : α) (f : α → Wseq β) : bind (ret a) f ~ f a := by simp [bind]
-#align stream.wseq.ret_bind Stream'.Wseq.ret_bind
+theorem ret_bind (a : α) (f : α → WSeq β) : bind (ret a) f ~ f a := by simp [bind]
+#align stream.wseq.ret_bind Stream'.WSeq.ret_bind
+-/
 
+#print Stream'.WSeq.map_join /-
 @[simp]
 theorem map_join (f : α → β) (S) : map f (join S) = join (map (map f) S) :=
   by
@@ -1747,11 +2164,13 @@ theorem map_join (f : α → β) (S) : map f (join S) = join (map (map f) S) :=
         · exact ⟨_, _, rfl, rfl⟩
         · exact ⟨_, _, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
-#align stream.wseq.map_join Stream'.Wseq.map_join
+#align stream.wseq.map_join Stream'.WSeq.map_join
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.join_join /-
 @[simp]
-theorem join_join (SS : Wseq (Wseq (Wseq α))) : join (join SS) ~ join (map join SS) :=
+theorem join_join (SS : WSeq (WSeq (WSeq α))) : join (join SS) ~ join (map join SS) :=
   by
   refine'
     ⟨fun s1 s2 =>
@@ -1783,18 +2202,21 @@ theorem join_join (SS : Wseq (Wseq (Wseq α))) : join (join SS) ~ join (map join
         · refine' ⟨nil, S, SS, _, _⟩ <;> simp
       · exact ⟨s, S, SS, rfl, rfl⟩
       · exact ⟨s, S, SS, rfl, rfl⟩
-#align stream.wseq.join_join Stream'.Wseq.join_join
+#align stream.wseq.join_join Stream'.WSeq.join_join
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Stream'.WSeq.bind_assoc /-
 @[simp]
-theorem bind_assoc (s : Wseq α) (f : α → Wseq β) (g : β → Wseq γ) :
+theorem bind_assoc (s : WSeq α) (f : α → WSeq β) (g : β → WSeq γ) :
     bind (bind s f) g ~ bind s fun x : α => bind (f x) g :=
   by
   simp [bind]; rw [← map_comp f (map g), map_comp (map g ∘ f) join]
   apply join_join
-#align stream.wseq.bind_assoc Stream'.Wseq.bind_assoc
+#align stream.wseq.bind_assoc Stream'.WSeq.bind_assoc
+-/
 
-instance : Monad Wseq where
+instance : Monad WSeq where
   map := @map
   pure := @ret
   bind := @bind
Diff
@@ -1338,7 +1338,7 @@ theorem dropn_ofSeq (s : Seq α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n)
   | n + 1 => by dsimp [drop] <;> rw [dropn_of_seq, tail_of_seq]
 #align stream.wseq.dropn_of_seq Stream'.Wseq.dropn_ofSeq
 
-theorem nth_ofSeq (s : Seq α) (n) : nth (ofSeq s) n = return (Seq.nth s n) := by
+theorem nth_ofSeq (s : Seq α) (n) : nth (ofSeq s) n = return (Seq.get? s n) := by
   dsimp [nth] <;> rw [dropn_of_seq, head_of_seq, seq.head_dropn]
 #align stream.wseq.nth_of_seq Stream'.Wseq.nth_ofSeq
 
Diff
@@ -4,13 +4,15 @@ 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.wseq
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! 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.Seq.Seq
 
+namespace Stream'
+
 open Function
 
 universe u v w
@@ -33,267 +35,268 @@ coinductive wseq (α : Type u) : Type u
   under most interesting computation patterns on infinite lists,
   but conversely it is difficult to extract elements from it. -/
 def Wseq (α) :=
-  SeqCat (Option α)
-#align wseq Wseq
+  Seq (Option α)
+#align stream.wseq Stream'.Wseq
 
 namespace Wseq
 
 variable {α : Type u} {β : Type v} {γ : Type w}
 
 /-- Turn a sequence into a weak sequence -/
-def ofSeq : SeqCat α → Wseq α :=
+def ofSeq : Seq α → Wseq α :=
   (· <$> ·) some
-#align wseq.of_seq Wseq.ofSeq
+#align stream.wseq.of_seq Stream'.Wseq.ofSeq
 
 /-- Turn a list into a weak sequence -/
 def ofList (l : List α) : Wseq α :=
   ofSeq l
-#align wseq.of_list Wseq.ofList
+#align stream.wseq.of_list Stream'.Wseq.ofList
 
 /-- Turn a stream into a weak sequence -/
 def ofStream (l : Stream' α) : Wseq α :=
   ofSeq l
-#align wseq.of_stream Wseq.ofStream
+#align stream.wseq.of_stream Stream'.Wseq.ofStream
 
-instance coeSeq : Coe (SeqCat α) (Wseq α) :=
+instance coeSeq : Coe (Seq α) (Wseq α) :=
   ⟨ofSeq⟩
-#align wseq.coe_seq Wseq.coeSeq
+#align stream.wseq.coe_seq Stream'.Wseq.coeSeq
 
 instance coeList : Coe (List α) (Wseq α) :=
   ⟨ofList⟩
-#align wseq.coe_list Wseq.coeList
+#align stream.wseq.coe_list Stream'.Wseq.coeList
 
 instance coeStream : Coe (Stream' α) (Wseq α) :=
   ⟨ofStream⟩
-#align wseq.coe_stream Wseq.coeStream
+#align stream.wseq.coe_stream Stream'.Wseq.coeStream
 
 /-- The empty weak sequence -/
 def nil : Wseq α :=
-  SeqCat.nil
-#align wseq.nil Wseq.nil
+  Seq.nil
+#align stream.wseq.nil Stream'.Wseq.nil
 
 instance : Inhabited (Wseq α) :=
   ⟨nil⟩
 
 /-- Prepend an element to a weak sequence -/
 def cons (a : α) : Wseq α → Wseq α :=
-  SeqCat.cons (some a)
-#align wseq.cons Wseq.cons
+  Seq.cons (some a)
+#align stream.wseq.cons Stream'.Wseq.cons
 
 /-- Compute for one tick, without producing any elements -/
 def think : Wseq α → Wseq α :=
-  SeqCat.cons none
-#align wseq.think Wseq.think
+  Seq.cons none
+#align stream.wseq.think Stream'.Wseq.think
 
 /-- Destruct a weak sequence, to (eventually possibly) produce either
   `none` for `nil` or `some (a, s)` if an element is produced. -/
 def destruct : Wseq α → Computation (Option (α × Wseq α)) :=
   Computation.corec fun s =>
-    match SeqCat.destruct s with
+    match Seq.destruct s with
     | none => Sum.inl none
     | some (none, s') => Sum.inr s'
     | some (some a, s') => Sum.inl (some (a, s'))
-#align wseq.destruct Wseq.destruct
+#align stream.wseq.destruct Stream'.Wseq.destruct
 
 /-- Recursion principle for weak sequences, compare with `list.rec_on`. -/
 def recOn {C : Wseq α → Sort v} (s : Wseq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s))
     (h3 : ∀ s, C (think s)) : C s :=
-  SeqCat.recOn s h1 fun o => Option.recOn o h3 h2
-#align wseq.rec_on Wseq.recOn
+  Seq.recOn s h1 fun o => Option.recOn o h3 h2
+#align stream.wseq.rec_on Stream'.Wseq.recOn
 
+/-- membership for weak sequences-/
 protected def Mem (a : α) (s : Wseq α) :=
-  SeqCat.Mem (some a) s
-#align wseq.mem Wseq.Mem
+  Seq.Mem (some a) s
+#align stream.wseq.mem Stream'.Wseq.Mem
 
 instance : Membership α (Wseq α) :=
   ⟨Wseq.Mem⟩
 
 theorem not_mem_nil (a : α) : a ∉ @nil α :=
-  SeqCat.not_mem_nil a
-#align wseq.not_mem_nil Wseq.not_mem_nil
+  Seq.not_mem_nil a
+#align stream.wseq.not_mem_nil Stream'.Wseq.not_mem_nil
 
 /-- Get the head of a weak sequence. This involves a possibly
   infinite computation. -/
 def head (s : Wseq α) : Computation (Option α) :=
   Computation.map ((· <$> ·) Prod.fst) (destruct s)
-#align wseq.head Wseq.head
+#align stream.wseq.head Stream'.Wseq.head
 
 /-- Encode a computation yielding a weak sequence into additional
   `think` constructors in a weak sequence -/
 def flatten : Computation (Wseq α) → Wseq α :=
-  SeqCat.corec fun c =>
+  Seq.corec fun c =>
     match Computation.destruct c with
-    | Sum.inl s => SeqCat.omap return (SeqCat.destruct s)
+    | Sum.inl s => Seq.omap return (Seq.destruct s)
     | Sum.inr c' => some (none, c')
-#align wseq.flatten Wseq.flatten
+#align stream.wseq.flatten Stream'.Wseq.flatten
 
 /-- Get the tail of a weak sequence. This doesn't need a `computation`
   wrapper, unlike `head`, because `flatten` allows us to hide this
   in the construction of the weak sequence itself. -/
 def tail (s : Wseq α) : Wseq α :=
   flatten <| (fun o => Option.recOn o nil Prod.snd) <$> destruct s
-#align wseq.tail Wseq.tail
+#align stream.wseq.tail Stream'.Wseq.tail
 
 /-- drop the first `n` elements from `s`. -/
 def drop (s : Wseq α) : ℕ → Wseq α
   | 0 => s
   | n + 1 => tail (drop n)
-#align wseq.drop Wseq.drop
+#align stream.wseq.drop Stream'.Wseq.drop
 
 attribute [simp] drop
 
 /-- Get the nth element of `s`. -/
 def nth (s : Wseq α) (n : ℕ) : Computation (Option α) :=
   head (drop s n)
-#align wseq.nth Wseq.nth
+#align stream.wseq.nth Stream'.Wseq.nth
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- Convert `s` to a list (if it is finite and completes in finite time). -/
 def toList (s : Wseq α) : Computation (List α) :=
   @Computation.corec (List α) (List α × Wseq α)
     (fun ⟨l, s⟩ =>
-      match SeqCat.destruct s with
+      match Seq.destruct s with
       | none => Sum.inl l.reverse
       | some (none, s') => Sum.inr (l, s')
       | some (some a, s') => Sum.inr (a::l, s'))
     ([], s)
-#align wseq.to_list Wseq.toList
+#align stream.wseq.to_list Stream'.Wseq.toList
 
 /-- Get the length of `s` (if it is finite and completes in finite time). -/
 def length (s : Wseq α) : Computation ℕ :=
   @Computation.corec ℕ (ℕ × Wseq α)
     (fun ⟨n, s⟩ =>
-      match SeqCat.destruct s with
+      match Seq.destruct s with
       | none => Sum.inl n
       | some (none, s') => Sum.inr (n, s')
       | some (some a, s') => Sum.inr (n + 1, s'))
     (0, s)
-#align wseq.length Wseq.length
+#align stream.wseq.length Stream'.Wseq.length
 
 /-- A weak sequence is finite if `to_list s` terminates. Equivalently,
   it is a finite number of `think` and `cons` applied to `nil`. -/
 class IsFinite (s : Wseq α) : Prop where
   out : (toList s).Terminates
-#align wseq.is_finite Wseq.IsFinite
+#align stream.wseq.is_finite Stream'.Wseq.IsFinite
 
 instance toList_terminates (s : Wseq α) [h : IsFinite s] : (toList s).Terminates :=
   h.out
-#align wseq.to_list_terminates Wseq.toList_terminates
+#align stream.wseq.to_list_terminates Stream'.Wseq.toList_terminates
 
 /-- Get the list corresponding to a finite weak sequence. -/
 def get (s : Wseq α) [IsFinite s] : List α :=
   (toList s).get
-#align wseq.get Wseq.get
+#align stream.wseq.get Stream'.Wseq.get
 
 /-- A weak sequence is *productive* if it never stalls forever - there are
  always a finite number of `think`s between `cons` constructors.
  The sequence itself is allowed to be infinite though. -/
 class Productive (s : Wseq α) : Prop where
   nth_terminates : ∀ n, (nth s n).Terminates
-#align wseq.productive Wseq.Productive
+#align stream.wseq.productive Stream'.Wseq.Productive
 
 theorem productive_iff (s : Wseq α) : Productive s ↔ ∀ n, (nth s n).Terminates :=
   ⟨fun h => h.1, fun h => ⟨h⟩⟩
-#align wseq.productive_iff Wseq.productive_iff
+#align stream.wseq.productive_iff Stream'.Wseq.productive_iff
 
 instance nth_terminates (s : Wseq α) [h : Productive s] : ∀ n, (nth s n).Terminates :=
   h.nth_terminates
-#align wseq.nth_terminates Wseq.nth_terminates
+#align stream.wseq.nth_terminates Stream'.Wseq.nth_terminates
 
 instance head_terminates (s : Wseq α) [Productive s] : (head s).Terminates :=
   s.nth_terminates 0
-#align wseq.head_terminates Wseq.head_terminates
+#align stream.wseq.head_terminates Stream'.Wseq.head_terminates
 
 /-- Replace the `n`th element of `s` with `a`. -/
 def updateNth (s : Wseq α) (n : ℕ) (a : α) : Wseq α :=
-  @SeqCat.corec (Option α) (ℕ × Wseq α)
+  @Seq.corec (Option α) (ℕ × Wseq α)
     (fun ⟨n, s⟩ =>
-      match SeqCat.destruct s, n with
+      match Seq.destruct s, n with
       | none, n => none
       | some (none, s'), n => some (none, n, s')
       | some (some a', s'), 0 => some (some a', 0, s')
       | some (some a', s'), 1 => some (some a, 0, s')
       | some (some a', s'), n + 2 => some (some a', n + 1, s'))
     (n + 1, s)
-#align wseq.update_nth Wseq.updateNth
+#align stream.wseq.update_nth Stream'.Wseq.updateNth
 
 /-- Remove the `n`th element of `s`. -/
 def removeNth (s : Wseq α) (n : ℕ) : Wseq α :=
-  @SeqCat.corec (Option α) (ℕ × Wseq α)
+  @Seq.corec (Option α) (ℕ × Wseq α)
     (fun ⟨n, s⟩ =>
-      match SeqCat.destruct s, n with
+      match Seq.destruct s, n with
       | none, n => none
       | some (none, s'), n => some (none, n, s')
       | some (some a', s'), 0 => some (some a', 0, s')
       | some (some a', s'), 1 => some (none, 0, s')
       | some (some a', s'), n + 2 => some (some a', n + 1, s'))
     (n + 1, s)
-#align wseq.remove_nth Wseq.removeNth
+#align stream.wseq.remove_nth Stream'.Wseq.removeNth
 
 /-- Map the elements of `s` over `f`, removing any values that yield `none`. -/
 def filterMap (f : α → Option β) : Wseq α → Wseq β :=
-  SeqCat.corec fun s =>
-    match SeqCat.destruct s with
+  Seq.corec fun s =>
+    match Seq.destruct s with
     | none => none
     | some (none, s') => some (none, s')
     | some (some a, s') => some (f a, s')
-#align wseq.filter_map Wseq.filterMap
+#align stream.wseq.filter_map Stream'.Wseq.filterMap
 
 /-- Select the elements of `s` that satisfy `p`. -/
 def filter (p : α → Prop) [DecidablePred p] : Wseq α → Wseq α :=
   filterMap fun a => if p a then some a else none
-#align wseq.filter Wseq.filter
+#align stream.wseq.filter Stream'.Wseq.filter
 
 -- example of infinite list manipulations
 /-- Get the first element of `s` satisfying `p`. -/
 def find (p : α → Prop) [DecidablePred p] (s : Wseq α) : Computation (Option α) :=
   head <| filter p s
-#align wseq.find Wseq.find
+#align stream.wseq.find Stream'.Wseq.find
 
 /-- Zip a function over two weak sequences -/
 def zipWith (f : α → β → γ) (s1 : Wseq α) (s2 : Wseq β) : Wseq γ :=
-  @SeqCat.corec (Option γ) (Wseq α × Wseq β)
+  @Seq.corec (Option γ) (Wseq α × Wseq β)
     (fun ⟨s1, s2⟩ =>
-      match SeqCat.destruct s1, SeqCat.destruct s2 with
+      match Seq.destruct s1, Seq.destruct s2 with
       | some (none, s1'), some (none, s2') => some (none, s1', s2')
       | some (some a1, s1'), some (none, s2') => some (none, s1, s2')
       | some (none, s1'), some (some a2, s2') => some (none, s1', s2)
       | some (some a1, s1'), some (some a2, s2') => some (some (f a1 a2), s1', s2')
       | _, _ => none)
     (s1, s2)
-#align wseq.zip_with Wseq.zipWith
+#align stream.wseq.zip_with Stream'.Wseq.zipWith
 
 /-- Zip two weak sequences into a single sequence of pairs -/
 def zip : Wseq α → Wseq β → Wseq (α × β) :=
   zipWith Prod.mk
-#align wseq.zip Wseq.zip
+#align stream.wseq.zip Stream'.Wseq.zip
 
 /-- Get the list of indexes of elements of `s` satisfying `p` -/
 def findIndexes (p : α → Prop) [DecidablePred p] (s : Wseq α) : Wseq ℕ :=
   (zip s (Stream'.nats : Wseq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none
-#align wseq.find_indexes Wseq.findIndexes
+#align stream.wseq.find_indexes Stream'.Wseq.findIndexes
 
 /-- Get the index of the first element of `s` satisfying `p` -/
 def findIndex (p : α → Prop) [DecidablePred p] (s : Wseq α) : Computation ℕ :=
   (fun o => Option.getD o 0) <$> head (findIndexes p s)
-#align wseq.find_index Wseq.findIndex
+#align stream.wseq.find_index Stream'.Wseq.findIndex
 
 /-- Get the index of the first occurrence of `a` in `s` -/
 def indexOf [DecidableEq α] (a : α) : Wseq α → Computation ℕ :=
   findIndex (Eq a)
-#align wseq.index_of Wseq.indexOf
+#align stream.wseq.index_of Stream'.Wseq.indexOf
 
 /-- Get the indexes of occurrences of `a` in `s` -/
 def indexesOf [DecidableEq α] (a : α) : Wseq α → Wseq ℕ :=
   findIndexes (Eq a)
-#align wseq.indexes_of Wseq.indexesOf
+#align stream.wseq.indexes_of Stream'.Wseq.indexesOf
 
 /-- `union s1 s2` is a weak sequence which interleaves `s1` and `s2` in
   some order (nondeterministically). -/
 def union (s1 s2 : Wseq α) : Wseq α :=
-  @SeqCat.corec (Option α) (Wseq α × Wseq α)
+  @Seq.corec (Option α) (Wseq α × Wseq α)
     (fun ⟨s1, s2⟩ =>
-      match SeqCat.destruct s1, SeqCat.destruct s2 with
+      match Seq.destruct s1, Seq.destruct s2 with
       | none, none => none
       | some (a1, s1'), none => some (a1, s1', nil)
       | none, some (a2, s2') => some (a2, nil, s2')
@@ -302,31 +305,31 @@ def union (s1 s2 : Wseq α) : Wseq α :=
       | some (none, s1'), some (some a2, s2') => some (some a2, s1', s2')
       | some (some a1, s1'), some (some a2, s2') => some (some a1, cons a2 s1', s2'))
     (s1, s2)
-#align wseq.union Wseq.union
+#align stream.wseq.union Stream'.Wseq.union
 
 /-- Returns `tt` if `s` is `nil` and `ff` if `s` has an element -/
 def isEmpty (s : Wseq α) : Computation Bool :=
   Computation.map Option.isNone <| head s
-#align wseq.is_empty Wseq.isEmpty
+#align stream.wseq.is_empty Stream'.Wseq.isEmpty
 
 /-- Calculate one step of computation -/
 def compute (s : Wseq α) : Wseq α :=
-  match SeqCat.destruct s with
+  match Seq.destruct s with
   | some (none, s') => s'
   | _ => s
-#align wseq.compute Wseq.compute
+#align stream.wseq.compute Stream'.Wseq.compute
 
 /-- Get the first `n` elements of a weak sequence -/
 def take (s : Wseq α) (n : ℕ) : Wseq α :=
-  @SeqCat.corec (Option α) (ℕ × Wseq α)
+  @Seq.corec (Option α) (ℕ × Wseq α)
     (fun ⟨n, s⟩ =>
-      match n, SeqCat.destruct s with
+      match n, Seq.destruct s with
       | 0, _ => none
       | m + 1, none => none
       | m + 1, some (none, s') => some (none, m + 1, s')
       | m + 1, some (some a, s') => some (some a, m, s'))
     (n, s)
-#align wseq.take Wseq.take
+#align stream.wseq.take Stream'.Wseq.take
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /-- Split the sequence at position `n` into a finite initial segment
@@ -334,106 +337,107 @@ def take (s : Wseq α) (n : ℕ) : Wseq α :=
 def splitAt (s : Wseq α) (n : ℕ) : Computation (List α × Wseq α) :=
   @Computation.corec (List α × Wseq α) (ℕ × List α × Wseq α)
     (fun ⟨n, l, s⟩ =>
-      match n, SeqCat.destruct s with
+      match n, Seq.destruct s with
       | 0, _ => Sum.inl (l.reverse, s)
       | m + 1, none => Sum.inl (l.reverse, s)
       | m + 1, some (none, s') => Sum.inr (n, l, s')
       | m + 1, some (some a, s') => Sum.inr (m, a::l, s'))
     (n, [], s)
-#align wseq.split_at Wseq.splitAt
+#align stream.wseq.split_at Stream'.Wseq.splitAt
 
 /-- Returns `tt` if any element of `s` satisfies `p` -/
 def any (s : Wseq α) (p : α → Bool) : Computation Bool :=
   Computation.corec
     (fun s : Wseq α =>
-      match SeqCat.destruct s with
+      match Seq.destruct s with
       | none => Sum.inl false
       | some (none, s') => Sum.inr s'
       | some (some a, s') => if p a then Sum.inl true else Sum.inr s')
     s
-#align wseq.any Wseq.any
+#align stream.wseq.any Stream'.Wseq.any
 
 /-- Returns `tt` if every element of `s` satisfies `p` -/
 def all (s : Wseq α) (p : α → Bool) : Computation Bool :=
   Computation.corec
     (fun s : Wseq α =>
-      match SeqCat.destruct s with
+      match Seq.destruct s with
       | none => Sum.inl true
       | some (none, s') => Sum.inr s'
       | some (some a, s') => if p a then Sum.inr s' else Sum.inl false)
     s
-#align wseq.all Wseq.all
+#align stream.wseq.all Stream'.Wseq.all
 
 /-- Apply a function to the elements of the sequence to produce a sequence
   of partial results. (There is no `scanr` because this would require
   working from the end of the sequence, which may not exist.) -/
 def scanl (f : α → β → α) (a : α) (s : Wseq β) : Wseq α :=
   cons a <|
-    @SeqCat.corec (Option α) (α × Wseq β)
+    @Seq.corec (Option α) (α × Wseq β)
       (fun ⟨a, s⟩ =>
-        match SeqCat.destruct s with
+        match Seq.destruct s with
         | none => none
         | some (none, s') => some (none, a, s')
         | some (some b, s') =>
           let a' := f a b
           some (some a', a', s'))
       (a, s)
-#align wseq.scanl Wseq.scanl
+#align stream.wseq.scanl Stream'.Wseq.scanl
 
 /-- Get the weak sequence of initial segments of the input sequence -/
 def inits (s : Wseq α) : Wseq (List α) :=
   cons [] <|
-    @SeqCat.corec (Option (List α)) (Dlist α × Wseq α)
+    @Seq.corec (Option (List α)) (Dlist α × Wseq α)
       (fun ⟨l, s⟩ =>
-        match SeqCat.destruct s with
+        match Seq.destruct s with
         | none => none
         | some (none, s') => some (none, l, s')
         | some (some a, s') =>
           let l' := l.concat a
           some (some l'.toList, l', s'))
       (Dlist.empty, s)
-#align wseq.inits Wseq.inits
+#align stream.wseq.inits Stream'.Wseq.inits
 
 /-- Like take, but does not wait for a result. Calculates `n` steps of
   computation and returns the sequence computed so far -/
 def collect (s : Wseq α) (n : ℕ) : List α :=
-  (SeqCat.take n s).filterMap id
-#align wseq.collect Wseq.collect
+  (Seq.take n s).filterMap id
+#align stream.wseq.collect Stream'.Wseq.collect
 
 /-- Append two weak sequences. As with `seq.append`, this may not use
   the second sequence if the first one takes forever to compute -/
 def append : Wseq α → Wseq α → Wseq α :=
-  SeqCat.append
-#align wseq.append Wseq.append
+  Seq.append
+#align stream.wseq.append Stream'.Wseq.append
 
 /-- Map a function over a weak sequence -/
 def map (f : α → β) : Wseq α → Wseq β :=
-  SeqCat.map (Option.map f)
-#align wseq.map Wseq.map
+  Seq.map (Option.map f)
+#align stream.wseq.map Stream'.Wseq.map
 
 /-- Flatten a sequence of weak sequences. (Note that this allows
   empty sequences, unlike `seq.join`.) -/
 def join (S : Wseq (Wseq α)) : Wseq α :=
-  SeqCat.join
+  Seq.join
     ((fun o : Option (Wseq α) =>
         match o with
         | none => Seq1.ret none
         | some s => (none, s)) <$>
       S)
-#align wseq.join Wseq.join
+#align stream.wseq.join Stream'.Wseq.join
 
 /-- Monadic bind operator for weak sequences -/
 def bind (s : Wseq α) (f : α → Wseq β) : Wseq β :=
   join (map f s)
-#align wseq.bind Wseq.bind
+#align stream.wseq.bind Stream'.Wseq.bind
 
+/-- lift a relation to a relation over weak sequences -/
 @[simp]
 def LiftRelO (R : α → β → Prop) (C : Wseq α → Wseq β → Prop) :
     Option (α × Wseq α) → Option (β × Wseq β) → Prop
   | none, none => True
   | some (a, s), some (b, t) => R a b ∧ C s t
   | _, _ => False
-#align wseq.lift_rel_o Wseq.LiftRelO
+#align stream.wseq.lift_rel_o Stream'.Wseq.LiftRelO
 
 theorem LiftRelO.imp {R S : α → β → Prop} {C D : Wseq α → Wseq β → Prop} (H1 : ∀ a b, R a b → S a b)
     (H2 : ∀ s t, C s t → D s t) : ∀ {o p}, LiftRelO R C o p → LiftRelO S D o p
@@ -441,22 +445,23 @@ theorem LiftRelO.imp {R S : α → β → Prop} {C D : Wseq α → Wseq β → P
   | some (a, s), some (b, t), h => And.imp (H1 _ _) (H2 _ _) h
   | none, some _, h => False.elim h
   | some (_, _), none, h => False.elim h
-#align wseq.lift_rel_o.imp Wseq.LiftRelO.imp
+#align stream.wseq.lift_rel_o.imp Stream'.Wseq.LiftRelO.imp
 
 theorem LiftRelO.imp_right (R : α → β → Prop) {C D : Wseq α → Wseq β → Prop}
     (H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p :=
   LiftRelO.imp (fun _ _ => id) H
-#align wseq.lift_rel_o.imp_right Wseq.LiftRelO.imp_right
+#align stream.wseq.lift_rel_o.imp_right Stream'.Wseq.LiftRelO.imp_right
 
+/-- Definitino of bisimilarity for weak sequences-/
 @[simp]
 def BisimO (R : Wseq α → Wseq α → Prop) : Option (α × Wseq α) → Option (α × Wseq α) → Prop :=
   LiftRelO (· = ·) R
-#align wseq.bisim_o Wseq.BisimO
+#align stream.wseq.bisim_o Stream'.Wseq.BisimO
 
 theorem BisimO.imp {R S : Wseq α → Wseq α → Prop} (H : ∀ s t, R s t → S s t) {o p} :
     BisimO R o p → BisimO S o p :=
   LiftRelO.imp_right _ H
-#align wseq.bisim_o.imp Wseq.BisimO.imp
+#align stream.wseq.bisim_o.imp Stream'.Wseq.BisimO.imp
 
 /-- Two weak sequences are `lift_rel R` related if they are either both empty,
   or they are both nonempty and the heads are `R` related and the tails are
@@ -464,7 +469,7 @@ theorem BisimO.imp {R S : Wseq α → Wseq α → Prop} (H : ∀ s t, R s t →
 def LiftRel (R : α → β → Prop) (s : Wseq α) (t : Wseq β) : Prop :=
   ∃ C : Wseq α → Wseq β → Prop,
     C s t ∧ ∀ {s t}, C s t → Computation.LiftRel (LiftRelO R C) (destruct s) (destruct t)
-#align wseq.lift_rel Wseq.LiftRel
+#align stream.wseq.lift_rel Stream'.Wseq.LiftRel
 
 /-- If two sequences are equivalent, then they have the same values and
   the same computational behavior (i.e. if one loops forever then so does
@@ -472,14 +477,14 @@ def LiftRel (R : α → β → Prop) (s : Wseq α) (t : Wseq β) : Prop :=
   arrive at the answer. -/
 def Equiv : Wseq α → Wseq α → Prop :=
   LiftRel (· = ·)
-#align wseq.equiv Wseq.Equiv
+#align stream.wseq.equiv Stream'.Wseq.Equiv
 
 theorem liftRel_destruct {R : α → β → Prop} {s : Wseq α} {t : Wseq β} :
     LiftRel R s t → Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t)
   | ⟨R, h1, h2⟩ => by
     refine' Computation.LiftRel.imp _ _ _ (h2 h1) <;> apply lift_rel_o.imp_right <;>
       exact fun s' t' h' => ⟨R, h', @h2⟩
-#align wseq.lift_rel_destruct Wseq.liftRel_destruct
+#align stream.wseq.lift_rel_destruct Stream'.Wseq.liftRel_destruct
 
 theorem liftRel_destruct_iff {R : α → β → Prop} {s : Wseq α} {t : Wseq β} :
     LiftRel R s t ↔ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) :=
@@ -498,7 +503,7 @@ theorem liftRel_destruct_iff {R : α → β → Prop} {s : Wseq α} {t : Wseq β
       apply lift_rel_o.imp_right
       intro s t
       apply Or.inl⟩⟩
-#align wseq.lift_rel_destruct_iff Wseq.liftRel_destruct_iff
+#align stream.wseq.lift_rel_destruct_iff Stream'.Wseq.liftRel_destruct_iff
 
 -- mathport name: equiv
 infixl:50 " ~ " => Equiv
@@ -508,27 +513,27 @@ infixl:50 " ~ " => Equiv
 theorem destruct_congr {s t : Wseq α} :
     s ~ t → Computation.LiftRel (BisimO (· ~ ·)) (destruct s) (destruct t) :=
   liftRel_destruct
-#align wseq.destruct_congr Wseq.destruct_congr
+#align stream.wseq.destruct_congr Stream'.Wseq.destruct_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:228:8: unsupported: ambiguous notation -/
 theorem destruct_congr_iff {s t : Wseq α} :
     s ~ t ↔ Computation.LiftRel (BisimO (· ~ ·)) (destruct s) (destruct t) :=
   liftRel_destruct_iff
-#align wseq.destruct_congr_iff Wseq.destruct_congr_iff
+#align stream.wseq.destruct_congr_iff Stream'.Wseq.destruct_congr_iff
 
 theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s =>
   by
   refine' ⟨(· = ·), rfl, fun s t (h : s = t) => _⟩
   rw [← h]; apply Computation.LiftRel.refl
   intro a; cases' a with a; simp; cases a <;> simp; apply H
-#align wseq.lift_rel.refl Wseq.LiftRel.refl
+#align stream.wseq.lift_rel.refl Stream'.Wseq.LiftRel.refl
 
 theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) :=
   by
   funext x y <;> cases' x with x <;> [skip, cases x] <;>
     · cases' y with y <;> [skip, cases y] <;> rfl
-#align wseq.lift_rel_o.swap Wseq.LiftRelO.swap
+#align stream.wseq.lift_rel_o.swap Stream'.Wseq.LiftRelO.swap
 
 theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) :
     LiftRel (swap R) s2 s1 :=
@@ -536,17 +541,17 @@ theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2)
   refine' ⟨swap (lift_rel R), h, fun s t (h : lift_rel R t s) => _⟩
   rw [← lift_rel_o.swap, Computation.LiftRel.swap]
   apply lift_rel_destruct h
-#align wseq.lift_rel.swap_lem Wseq.LiftRel.swap_lem
+#align stream.wseq.lift_rel.swap_lem Stream'.Wseq.LiftRel.swap_lem
 
 theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) :=
   funext fun x => funext fun y => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩
-#align wseq.lift_rel.swap Wseq.LiftRel.swap
+#align stream.wseq.lift_rel.swap Stream'.Wseq.LiftRel.swap
 
 theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
   fun s1 s2 (h : swap (LiftRel R) s2 s1) => by
   rwa [lift_rel.swap,
     show swap R = R from funext fun a => funext fun b => propext <| by constructor <;> apply H] at h
-#align wseq.lift_rel.symm Wseq.LiftRel.symm
+#align stream.wseq.lift_rel.symm Stream'.Wseq.LiftRel.symm
 
 theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) :=
   fun s t u h1 h2 =>
@@ -579,24 +584,24 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
     cases' t1 with ab st
     cases' t2 with bc tu
     exact ⟨H ab bc, t, st, tu⟩
-#align wseq.lift_rel.trans Wseq.LiftRel.trans
+#align stream.wseq.lift_rel.trans Stream'.Wseq.LiftRel.trans
 
 theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R)
   | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, LiftRel.symm R symm, LiftRel.trans R trans⟩
-#align wseq.lift_rel.equiv Wseq.LiftRel.equiv
+#align stream.wseq.lift_rel.equiv Stream'.Wseq.LiftRel.equiv
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[refl]
 theorem Equiv.refl : ∀ s : Wseq α, s ~ s :=
   LiftRel.refl (· = ·) Eq.refl
-#align wseq.equiv.refl Wseq.Equiv.refl
+#align stream.wseq.equiv.refl Stream'.Wseq.Equiv.refl
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[symm]
 theorem Equiv.symm : ∀ {s t : Wseq α}, s ~ t → t ~ s :=
   LiftRel.symm (· = ·) (@Eq.symm _)
-#align wseq.equiv.symm Wseq.Equiv.symm
+#align stream.wseq.equiv.symm Stream'.Wseq.Equiv.symm
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -604,11 +609,11 @@ theorem Equiv.symm : ∀ {s t : Wseq α}, s ~ t → t ~ s :=
 @[trans]
 theorem Equiv.trans : ∀ {s t u : Wseq α}, s ~ t → t ~ u → s ~ u :=
   LiftRel.trans (· = ·) (@Eq.trans _)
-#align wseq.equiv.trans Wseq.Equiv.trans
+#align stream.wseq.equiv.trans Stream'.Wseq.Equiv.trans
 
 theorem Equiv.equivalence : Equivalence (@Equiv α) :=
   ⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩
-#align wseq.equiv.equivalence Wseq.Equiv.equivalence
+#align stream.wseq.equiv.equivalence Stream'.Wseq.Equiv.equivalence
 
 open Computation
 
@@ -618,59 +623,59 @@ local notation "return" => Computation.pure
 @[simp]
 theorem destruct_nil : destruct (nil : Wseq α) = return none :=
   Computation.destruct_eq_pure rfl
-#align wseq.destruct_nil Wseq.destruct_nil
+#align stream.wseq.destruct_nil Stream'.Wseq.destruct_nil
 
 @[simp]
 theorem destruct_cons (a : α) (s) : destruct (cons a s) = return (some (a, s)) :=
   Computation.destruct_eq_pure <| by simp [destruct, cons, Computation.rmap]
-#align wseq.destruct_cons Wseq.destruct_cons
+#align stream.wseq.destruct_cons Stream'.Wseq.destruct_cons
 
 @[simp]
 theorem destruct_think (s : Wseq α) : destruct (think s) = (destruct s).think :=
   Computation.destruct_eq_think <| by simp [destruct, think, Computation.rmap]
-#align wseq.destruct_think Wseq.destruct_think
+#align stream.wseq.destruct_think Stream'.Wseq.destruct_think
 
 @[simp]
-theorem seq_destruct_nil : SeqCat.destruct (nil : Wseq α) = none :=
-  SeqCat.destruct_nil
-#align wseq.seq_destruct_nil Wseq.seq_destruct_nil
+theorem seq_destruct_nil : Seq.destruct (nil : Wseq α) = none :=
+  Seq.destruct_nil
+#align stream.wseq.seq_destruct_nil Stream'.Wseq.seq_destruct_nil
 
 @[simp]
-theorem seqCat_destruct_cons (a : α) (s) : SeqCat.destruct (cons a s) = some (some a, s) :=
-  SeqCat.destruct_cons _ _
-#align wseq.seq_destruct_cons Wseq.seqCat_destruct_cons
+theorem seq_destruct_cons (a : α) (s) : Seq.destruct (cons a s) = some (some a, s) :=
+  Seq.destruct_cons _ _
+#align stream.wseq.seq_destruct_cons Stream'.Wseq.seq_destruct_cons
 
 @[simp]
-theorem seqCat_destruct_think (s : Wseq α) : SeqCat.destruct (think s) = some (none, s) :=
-  SeqCat.destruct_cons _ _
-#align wseq.seq_destruct_think Wseq.seqCat_destruct_think
+theorem seq_destruct_think (s : Wseq α) : Seq.destruct (think s) = some (none, s) :=
+  Seq.destruct_cons _ _
+#align stream.wseq.seq_destruct_think Stream'.Wseq.seq_destruct_think
 
 @[simp]
 theorem head_nil : head (nil : Wseq α) = return none := by simp [head] <;> rfl
-#align wseq.head_nil Wseq.head_nil
+#align stream.wseq.head_nil Stream'.Wseq.head_nil
 
 @[simp]
 theorem head_cons (a : α) (s) : head (cons a s) = return (some a) := by simp [head] <;> rfl
-#align wseq.head_cons Wseq.head_cons
+#align stream.wseq.head_cons Stream'.Wseq.head_cons
 
 @[simp]
 theorem head_think (s : Wseq α) : head (think s) = (head s).think := by simp [head] <;> rfl
-#align wseq.head_think Wseq.head_think
+#align stream.wseq.head_think Stream'.Wseq.head_think
 
 @[simp]
 theorem flatten_ret (s : Wseq α) : flatten (return s) = s :=
   by
-  refine' SeqCat.eq_of_bisim (fun s1 s2 => flatten (return s2) = s1) _ rfl
+  refine' seq.eq_of_bisim (fun s1 s2 => flatten (return s2) = s1) _ rfl
   intro s' s h; rw [← h]; simp [flatten]
-  cases SeqCat.destruct s; · simp
+  cases seq.destruct s; · simp
   · cases' val with o s'
     simp
-#align wseq.flatten_ret Wseq.flatten_ret
+#align stream.wseq.flatten_ret Stream'.Wseq.flatten_ret
 
 @[simp]
 theorem flatten_think (c : Computation (Wseq α)) : flatten c.think = think (flatten c) :=
-  SeqCat.destruct_eq_cons <| by simp [flatten, think]
-#align wseq.flatten_think Wseq.flatten_think
+  Seq.destruct_eq_cons <| by simp [flatten, think]
+#align stream.wseq.flatten_think Stream'.Wseq.flatten_think
 
 @[simp]
 theorem destruct_flatten (c : Computation (Wseq α)) : destruct (flatten c) = c >>= destruct :=
@@ -688,67 +693,67 @@ theorem destruct_flatten (c : Computation (Wseq α)) : destruct (flatten c) = c
       apply c.rec_on (fun a => _) fun c' => _ <;> repeat' simp
       · cases (destruct a).destruct <;> simp
       · exact Or.inr ⟨c', rfl, rfl⟩
-#align wseq.destruct_flatten Wseq.destruct_flatten
+#align stream.wseq.destruct_flatten Stream'.Wseq.destruct_flatten
 
 theorem head_terminates_iff (s : Wseq α) : Terminates (head s) ↔ Terminates (destruct s) :=
   terminates_map_iff _ (destruct s)
-#align wseq.head_terminates_iff Wseq.head_terminates_iff
+#align stream.wseq.head_terminates_iff Stream'.Wseq.head_terminates_iff
 
 @[simp]
 theorem tail_nil : tail (nil : Wseq α) = nil := by simp [tail]
-#align wseq.tail_nil Wseq.tail_nil
+#align stream.wseq.tail_nil Stream'.Wseq.tail_nil
 
 @[simp]
 theorem tail_cons (a : α) (s) : tail (cons a s) = s := by simp [tail]
-#align wseq.tail_cons Wseq.tail_cons
+#align stream.wseq.tail_cons Stream'.Wseq.tail_cons
 
 @[simp]
 theorem tail_think (s : Wseq α) : tail (think s) = (tail s).think := by simp [tail]
-#align wseq.tail_think Wseq.tail_think
+#align stream.wseq.tail_think Stream'.Wseq.tail_think
 
 @[simp]
 theorem dropn_nil (n) : drop (nil : Wseq α) n = nil := by induction n <;> simp [*, drop]
-#align wseq.dropn_nil Wseq.dropn_nil
+#align stream.wseq.dropn_nil Stream'.Wseq.dropn_nil
 
 @[simp]
 theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by
   induction n <;> simp [*, drop]
-#align wseq.dropn_cons Wseq.dropn_cons
+#align stream.wseq.dropn_cons Stream'.Wseq.dropn_cons
 
 @[simp]
 theorem dropn_think (s : Wseq α) (n) : drop (think s) n = (drop s n).think := by
   induction n <;> simp [*, drop]
-#align wseq.dropn_think Wseq.dropn_think
+#align stream.wseq.dropn_think Stream'.Wseq.dropn_think
 
 theorem dropn_add (s : Wseq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
   | 0 => rfl
   | n + 1 => congr_arg tail (dropn_add n)
-#align wseq.dropn_add Wseq.dropn_add
+#align stream.wseq.dropn_add Stream'.Wseq.dropn_add
 
 theorem dropn_tail (s : Wseq α) (n) : drop (tail s) n = drop s (n + 1) := by
   rw [add_comm] <;> symm <;> apply dropn_add
-#align wseq.dropn_tail Wseq.dropn_tail
+#align stream.wseq.dropn_tail Stream'.Wseq.dropn_tail
 
 theorem nth_add (s : Wseq α) (m n) : nth s (m + n) = nth (drop s m) n :=
   congr_arg head (dropn_add _ _ _)
-#align wseq.nth_add Wseq.nth_add
+#align stream.wseq.nth_add Stream'.Wseq.nth_add
 
 theorem nth_tail (s : Wseq α) (n) : nth (tail s) n = nth s (n + 1) :=
   congr_arg head (dropn_tail _ _)
-#align wseq.nth_tail Wseq.nth_tail
+#align stream.wseq.nth_tail Stream'.Wseq.nth_tail
 
 @[simp]
 theorem join_nil : join nil = (nil : Wseq α) :=
-  SeqCat.join_nil
-#align wseq.join_nil Wseq.join_nil
+  Seq.join_nil
+#align stream.wseq.join_nil Stream'.Wseq.join_nil
 
 @[simp]
 theorem join_think (S : Wseq (Wseq α)) : join (think S) = think (join S) :=
   by
   simp [think, join]
   unfold Functor.map
-  simp [join, Seq1.ret]
-#align wseq.join_think Wseq.join_think
+  simp [join, seq1.ret]
+#align stream.wseq.join_think Stream'.Wseq.join_think
 
 @[simp]
 theorem join_cons (s : Wseq α) (S) : join (cons s S) = think (append s (join S)) :=
@@ -756,62 +761,64 @@ theorem join_cons (s : Wseq α) (S) : join (cons s S) = think (append s (join S)
   simp [think, join]
   unfold Functor.map
   simp [join, cons, append]
-#align wseq.join_cons Wseq.join_cons
+#align stream.wseq.join_cons Stream'.Wseq.join_cons
 
 @[simp]
 theorem nil_append (s : Wseq α) : append nil s = s :=
-  SeqCat.nil_append _
-#align wseq.nil_append Wseq.nil_append
+  Seq.nil_append _
+#align stream.wseq.nil_append Stream'.Wseq.nil_append
 
 @[simp]
 theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :=
-  SeqCat.cons_append _ _ _
-#align wseq.cons_append Wseq.cons_append
+  Seq.cons_append _ _ _
+#align stream.wseq.cons_append Stream'.Wseq.cons_append
 
 @[simp]
 theorem think_append (s t : Wseq α) : append (think s) t = think (append s t) :=
-  SeqCat.cons_append _ _ _
-#align wseq.think_append Wseq.think_append
+  Seq.cons_append _ _ _
+#align stream.wseq.think_append Stream'.Wseq.think_append
 
 @[simp]
 theorem append_nil (s : Wseq α) : append s nil = s :=
-  SeqCat.append_nil _
-#align wseq.append_nil Wseq.append_nil
+  Seq.append_nil _
+#align stream.wseq.append_nil Stream'.Wseq.append_nil
 
 @[simp]
 theorem append_assoc (s t u : Wseq α) : append (append s t) u = append s (append t u) :=
-  SeqCat.append_assoc _ _ _
-#align wseq.append_assoc Wseq.append_assoc
+  Seq.append_assoc _ _ _
+#align stream.wseq.append_assoc Stream'.Wseq.append_assoc
 
+/-- auxilary defintion of tail over weak sequences-/
 @[simp]
 def tail.aux : Option (α × Wseq α) → Computation (Option (α × Wseq α))
   | none => return none
   | some (a, s) => destruct s
-#align wseq.tail.aux Wseq.tail.aux
+#align stream.wseq.tail.aux Stream'.Wseq.tail.aux
 
 theorem destruct_tail (s : Wseq α) : destruct (tail s) = destruct s >>= tail.aux :=
   by
   simp [tail]; rw [← bind_pure_comp_eq_map, LawfulMonad.bind_assoc]
   apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp
-#align wseq.destruct_tail Wseq.destruct_tail
+#align stream.wseq.destruct_tail Stream'.Wseq.destruct_tail
 
+/-- auxilary defintion of drop over weak sequences-/
 @[simp]
 def drop.aux : ℕ → Option (α × Wseq α) → Computation (Option (α × Wseq α))
   | 0 => return
   | n + 1 => fun a => tail.aux a >>= drop.aux n
-#align wseq.drop.aux Wseq.drop.aux
+#align stream.wseq.drop.aux Stream'.Wseq.drop.aux
 
 theorem drop.aux_none : ∀ n, @drop.aux α n none = return none
   | 0 => rfl
   | n + 1 =>
     show Computation.bind (return none) (drop.aux n) = return none by rw [ret_bind, drop.aux_none]
-#align wseq.drop.aux_none Wseq.drop.aux_none
+#align stream.wseq.drop.aux_none Stream'.Wseq.drop.aux_none
 
 theorem destruct_dropn : ∀ (s : Wseq α) (n), destruct (drop s n) = destruct s >>= drop.aux n
   | s, 0 => (bind_pure' _).symm
   | s, n + 1 => by
     rw [← dropn_tail, destruct_dropn _ n, destruct_tail, LawfulMonad.bind_assoc] <;> rfl
-#align wseq.destruct_dropn Wseq.destruct_dropn
+#align stream.wseq.destruct_dropn Stream'.Wseq.destruct_dropn
 
 theorem head_terminates_of_head_tail_terminates (s : Wseq α) [T : Terminates (head (tail s))] :
     Terminates (head s) :=
@@ -822,29 +829,29 @@ theorem head_terminates_of_head_tail_terminates (s : Wseq α) [T : Terminates (h
     rcases exists_of_mem_bind h with ⟨s', h1, h2⟩
     unfold Functor.map at h1
     exact
-      let ⟨t, h3, h4⟩ := exists_of_mem_map h1
-      terminates_of_mem h3
-#align wseq.head_terminates_of_head_tail_terminates Wseq.head_terminates_of_head_tail_terminates
+      let ⟨t, h3, h4⟩ := Computation.exists_of_mem_map h1
+      Computation.terminates_of_mem h3
+#align stream.wseq.head_terminates_of_head_tail_terminates Stream'.Wseq.head_terminates_of_head_tail_terminates
 
 theorem destruct_some_of_destruct_tail_some {s : Wseq α} {a} (h : some a ∈ destruct (tail s)) :
     ∃ a', some a' ∈ destruct s := by
   unfold tail Functor.map at h; simp at h
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
-  rcases exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
+  rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
   cases' t' with t' <;> rw [← ht2] at td <;> simp at td
   · have := mem_unique td (ret_mem _)
     contradiction
   · exact ⟨_, ht'⟩
-#align wseq.destruct_some_of_destruct_tail_some Wseq.destruct_some_of_destruct_tail_some
+#align stream.wseq.destruct_some_of_destruct_tail_some Stream'.Wseq.destruct_some_of_destruct_tail_some
 
 theorem head_some_of_head_tail_some {s : Wseq α} {a} (h : some a ∈ head (tail s)) :
     ∃ a', some a' ∈ head s := by
   unfold head at h
-  rcases exists_of_mem_map h with ⟨o, md, e⟩; clear h
+  rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
   cases' o with o <;> injection e with h'; clear e h'
   cases' destruct_some_of_destruct_tail_some md with a am
-  exact ⟨_, mem_map ((· <$> ·) (@Prod.fst α (Wseq α))) am⟩
-#align wseq.head_some_of_head_tail_some Wseq.head_some_of_head_tail_some
+  exact ⟨_, Computation.mem_map ((· <$> ·) (@Prod.fst α (wseq α))) am⟩
+#align stream.wseq.head_some_of_head_tail_some Stream'.Wseq.head_some_of_head_tail_some
 
 theorem head_some_of_nth_some {s : Wseq α} {a n} (h : some a ∈ nth s n) : ∃ a', some a' ∈ head s :=
   by
@@ -852,19 +859,19 @@ theorem head_some_of_nth_some {s : Wseq α} {a n} (h : some a ∈ nth s n) : ∃
   exacts[⟨_, h⟩,
     let ⟨a', h'⟩ := head_some_of_head_tail_some h
     IH h']
-#align wseq.head_some_of_nth_some Wseq.head_some_of_nth_some
+#align stream.wseq.head_some_of_nth_some Stream'.Wseq.head_some_of_nth_some
 
 instance productive_tail (s : Wseq α) [Productive s] : Productive (tail s) :=
   ⟨fun n => by rw [nth_tail] <;> infer_instance⟩
-#align wseq.productive_tail Wseq.productive_tail
+#align stream.wseq.productive_tail Stream'.Wseq.productive_tail
 
 instance productive_dropn (s : Wseq α) [Productive s] (n) : Productive (drop s n) :=
   ⟨fun m => by rw [← nth_add] <;> infer_instance⟩
-#align wseq.productive_dropn Wseq.productive_dropn
+#align stream.wseq.productive_dropn Stream'.Wseq.productive_dropn
 
 /-- Given a productive weak sequence, we can collapse all the `think`s to
   produce a sequence. -/
-def toSeq (s : Wseq α) [Productive s] : SeqCat α :=
+def toSeq (s : Wseq α) [Productive s] : Seq α :=
   ⟨fun n => (nth s n).get, fun n h =>
     by
     cases e : Computation.get (nth s (n + 1)); · assumption
@@ -872,28 +879,28 @@ def toSeq (s : Wseq α) [Productive s] : SeqCat α :=
     simp [nth] at this h; cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
     contradiction⟩
-#align wseq.to_seq Wseq.toSeq
+#align stream.wseq.to_seq Stream'.Wseq.toSeq
 
 theorem nth_terminates_le {s : Wseq α} {m n} (h : m ≤ n) :
     Terminates (nth s n) → Terminates (nth s m) := by
   induction' h with m' h IH <;> [exact id,
     exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
-#align wseq.nth_terminates_le Wseq.nth_terminates_le
+#align stream.wseq.nth_terminates_le Stream'.Wseq.nth_terminates_le
 
 theorem head_terminates_of_nth_terminates {s : Wseq α} {n} :
     Terminates (nth s n) → Terminates (head s) :=
   nth_terminates_le (Nat.zero_le n)
-#align wseq.head_terminates_of_nth_terminates Wseq.head_terminates_of_nth_terminates
+#align stream.wseq.head_terminates_of_nth_terminates Stream'.Wseq.head_terminates_of_nth_terminates
 
 theorem destruct_terminates_of_nth_terminates {s : Wseq α} {n} (T : Terminates (nth s n)) :
     Terminates (destruct s) :=
   (head_terminates_iff _).1 <| head_terminates_of_nth_terminates T
-#align wseq.destruct_terminates_of_nth_terminates Wseq.destruct_terminates_of_nth_terminates
+#align stream.wseq.destruct_terminates_of_nth_terminates Stream'.Wseq.destruct_terminates_of_nth_terminates
 
 theorem mem_rec_on {C : Wseq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s'))
     (h2 : ∀ s, C s → C (think s)) : C s :=
   by
-  apply SeqCat.mem_rec_on M
+  apply seq.mem_rec_on M
   intro o s' h; cases' o with b
   · apply h2
     cases h
@@ -903,7 +910,7 @@ theorem mem_rec_on {C : Wseq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a
     apply Or.imp_left _ h
     intro h
     injection h
-#align wseq.mem_rec_on Wseq.mem_rec_on
+#align stream.wseq.mem_rec_on Stream'.Wseq.mem_rec_on
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -916,7 +923,7 @@ theorem mem_think (s : Wseq α) (a) : a ∈ think s ↔ a ∈ s :=
     intro
     injections
   · apply Stream'.mem_cons_of_mem _ h
-#align wseq.mem_think Wseq.mem_think
+#align stream.wseq.mem_think Stream'.Wseq.mem_think
 
 theorem eq_or_mem_iff_mem {s : Wseq α} {a a' s'} :
     some (a', s') ∈ destruct s → (a ∈ s ↔ a = a' ∨ a ∈ s') :=
@@ -931,7 +938,7 @@ theorem eq_or_mem_iff_mem {s : Wseq α} {a a' s'} :
     cases' this with i1 i2
   · rw [i1, i2]
     cases' s' with f al
-    unfold cons Membership.Mem Wseq.Mem SeqCat.Mem SeqCat.cons
+    unfold cons Membership.Mem wseq.mem seq.mem seq.cons
     simp
     have h_a_eq_a' : a = a' ↔ some (some a) = some (some a') := by simp
     rw [h_a_eq_a']
@@ -942,20 +949,20 @@ theorem eq_or_mem_iff_mem {s : Wseq α} {a a' s'} :
       · exact Stream'.mem_cons_of_mem _ m
   · simp
     exact IH this
-#align wseq.eq_or_mem_iff_mem Wseq.eq_or_mem_iff_mem
+#align stream.wseq.eq_or_mem_iff_mem Stream'.Wseq.eq_or_mem_iff_mem
 
 @[simp]
 theorem mem_cons_iff (s : Wseq α) (b) {a} : a ∈ cons b s ↔ a = b ∨ a ∈ s :=
   eq_or_mem_iff_mem <| by simp [ret_mem]
-#align wseq.mem_cons_iff Wseq.mem_cons_iff
+#align stream.wseq.mem_cons_iff Stream'.Wseq.mem_cons_iff
 
 theorem mem_cons_of_mem {s : Wseq α} (b) {a} (h : a ∈ s) : a ∈ cons b s :=
   (mem_cons_iff _ _).2 (Or.inr h)
-#align wseq.mem_cons_of_mem Wseq.mem_cons_of_mem
+#align stream.wseq.mem_cons_of_mem Stream'.Wseq.mem_cons_of_mem
 
 theorem mem_cons (s : Wseq α) (a) : a ∈ cons a s :=
   (mem_cons_iff _ _).2 (Or.inl rfl)
-#align wseq.mem_cons Wseq.mem_cons
+#align stream.wseq.mem_cons Stream'.Wseq.mem_cons
 
 theorem mem_of_mem_tail {s : Wseq α} {a} : a ∈ tail s → a ∈ s :=
   by
@@ -970,24 +977,24 @@ theorem mem_of_mem_tail {s : Wseq α} {a} : a ∈ tail s → a ∈ s :=
     rw [e]
     cases tail s
     rfl
-#align wseq.mem_of_mem_tail Wseq.mem_of_mem_tail
+#align stream.wseq.mem_of_mem_tail Stream'.Wseq.mem_of_mem_tail
 
 theorem mem_of_mem_dropn {s : Wseq α} {a} : ∀ {n}, a ∈ drop s n → a ∈ s
   | 0, h => h
   | n + 1, h => @mem_of_mem_dropn n (mem_of_mem_tail h)
-#align wseq.mem_of_mem_dropn Wseq.mem_of_mem_dropn
+#align stream.wseq.mem_of_mem_dropn Stream'.Wseq.mem_of_mem_dropn
 
 theorem nth_mem {s : Wseq α} {a n} : some a ∈ nth s n → a ∈ s :=
   by
   revert s; induction' n with n IH <;> intro s h
-  · rcases exists_of_mem_map h with ⟨o, h1, h2⟩
+  · rcases Computation.exists_of_mem_map h with ⟨o, h1, h2⟩
     cases' o with o <;> injection h2 with h'
     cases' o with a' s'
     exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm)
   · have := @IH (tail s)
     rw [nth_tail] at this
     exact mem_of_mem_tail (this h)
-#align wseq.nth_mem Wseq.nth_mem
+#align stream.wseq.nth_mem Stream'.Wseq.nth_mem
 
 theorem exists_nth_of_mem {s : Wseq α} {a} (h : a ∈ s) : ∃ n, some a ∈ nth s n :=
   by
@@ -1007,18 +1014,18 @@ theorem exists_nth_of_mem {s : Wseq α} {a} (h : a ∈ s) : ∃ n, some a ∈ nt
     exists n
     simp [nth]
     apply think_mem h
-#align wseq.exists_nth_of_mem Wseq.exists_nth_of_mem
+#align stream.wseq.exists_nth_of_mem Stream'.Wseq.exists_nth_of_mem
 
 theorem exists_dropn_of_mem {s : Wseq α} {a} (h : a ∈ s) :
     ∃ n s', some (a, s') ∈ destruct (drop s n) :=
   let ⟨n, h⟩ := exists_nth_of_mem h
   ⟨n, by
     rcases(head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩
-    have := mem_unique (mem_map _ om) h
+    have := Computation.mem_unique (Computation.mem_map _ om) h
     cases' o with o <;> injection this with i
     cases' o with a' s'; dsimp at i
     rw [i] at om; exact ⟨_, om⟩⟩
-#align wseq.exists_dropn_of_mem Wseq.exists_dropn_of_mem
+#align stream.wseq.exists_dropn_of_mem Stream'.Wseq.exists_dropn_of_mem
 
 theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t) :
     ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n))
@@ -1031,74 +1038,74 @@ theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t
       match a, b, o with
       | none, none, _ => by simp
       | some (a, s), some (b, t), ⟨h1, h2⟩ => by simp [tail.aux] <;> apply lift_rel_destruct h2
-#align wseq.lift_rel_dropn_destruct Wseq.liftRel_dropn_destruct
+#align stream.wseq.lift_rel_dropn_destruct Stream'.Wseq.liftRel_dropn_destruct
 
 theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t) {a} (h : a ∈ s) :
     ∃ b, b ∈ t ∧ R a b :=
   let ⟨n, h⟩ := exists_nth_of_mem h
-  let ⟨some (_, s'), sd, rfl⟩ := exists_of_mem_map h
+  let ⟨some (_, s'), sd, rfl⟩ := Computation.exists_of_mem_map h
   let ⟨some (b, t'), td, ⟨ab, _⟩⟩ := (liftRel_dropn_destruct H n).left sd
-  ⟨b, nth_mem (mem_map ((· <$> ·) Prod.fst.{v, v}) td), ab⟩
-#align wseq.exists_of_lift_rel_left Wseq.exists_of_liftRel_left
+  ⟨b, nth_mem (Computation.mem_map ((· <$> ·) Prod.fst.{v, v}) td), ab⟩
+#align stream.wseq.exists_of_lift_rel_left Stream'.Wseq.exists_of_liftRel_left
 
 theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) :
     ∃ a, a ∈ s ∧ R a b := by rw [← lift_rel.swap] at H <;> exact exists_of_lift_rel_left H h
-#align wseq.exists_of_lift_rel_right Wseq.exists_of_liftRel_right
+#align stream.wseq.exists_of_lift_rel_right Stream'.Wseq.exists_of_liftRel_right
 
 theorem head_terminates_of_mem {s : Wseq α} {a} (h : a ∈ s) : Terminates (head s) :=
   let ⟨n, h⟩ := exists_nth_of_mem h
   head_terminates_of_nth_terminates ⟨⟨_, h⟩⟩
-#align wseq.head_terminates_of_mem Wseq.head_terminates_of_mem
+#align stream.wseq.head_terminates_of_mem Stream'.Wseq.head_terminates_of_mem
 
 theorem of_mem_append {s₁ s₂ : Wseq α} {a : α} : a ∈ append s₁ s₂ → a ∈ s₁ ∨ a ∈ s₂ :=
-  SeqCat.of_mem_append
-#align wseq.of_mem_append Wseq.of_mem_append
+  Seq.of_mem_append
+#align stream.wseq.of_mem_append Stream'.Wseq.of_mem_append
 
 theorem mem_append_left {s₁ s₂ : Wseq α} {a : α} : a ∈ s₁ → a ∈ append s₁ s₂ :=
-  SeqCat.mem_append_left
-#align wseq.mem_append_left Wseq.mem_append_left
+  Seq.mem_append_left
+#align stream.wseq.mem_append_left Stream'.Wseq.mem_append_left
 
 theorem exists_of_mem_map {f} {b : β} : ∀ {s : Wseq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
   | ⟨g, al⟩, h => by
-    let ⟨o, om, oe⟩ := SeqCat.exists_of_mem_map h
+    let ⟨o, om, oe⟩ := Seq.exists_of_mem_map h
     cases' o with a <;> injection oe with h' <;> exact ⟨a, om, h'⟩
-#align wseq.exists_of_mem_map Wseq.exists_of_mem_map
+#align stream.wseq.exists_of_mem_map Stream'.Wseq.exists_of_mem_map
 
 @[simp]
 theorem liftRel_nil (R : α → β → Prop) : LiftRel R nil nil := by rw [lift_rel_destruct_iff] <;> simp
-#align wseq.lift_rel_nil Wseq.liftRel_nil
+#align stream.wseq.lift_rel_nil Stream'.Wseq.liftRel_nil
 
 @[simp]
 theorem liftRel_cons (R : α → β → Prop) (a b s t) :
     LiftRel R (cons a s) (cons b t) ↔ R a b ∧ LiftRel R s t := by
   rw [lift_rel_destruct_iff] <;> simp
-#align wseq.lift_rel_cons Wseq.liftRel_cons
+#align stream.wseq.lift_rel_cons Stream'.Wseq.liftRel_cons
 
 @[simp]
 theorem liftRel_think_left (R : α → β → Prop) (s t) : LiftRel R (think s) t ↔ LiftRel R s t := by
   rw [lift_rel_destruct_iff, lift_rel_destruct_iff] <;> simp
-#align wseq.lift_rel_think_left Wseq.liftRel_think_left
+#align stream.wseq.lift_rel_think_left Stream'.Wseq.liftRel_think_left
 
 @[simp]
 theorem liftRel_think_right (R : α → β → Prop) (s t) : LiftRel R s (think t) ↔ LiftRel R s t := by
   rw [lift_rel_destruct_iff, lift_rel_destruct_iff] <;> simp
-#align wseq.lift_rel_think_right Wseq.liftRel_think_right
+#align stream.wseq.lift_rel_think_right Stream'.Wseq.liftRel_think_right
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem cons_congr {s t : Wseq α} (a : α) (h : s ~ t) : cons a s ~ cons a t := by
   unfold Equiv <;> simp <;> exact h
-#align wseq.cons_congr Wseq.cons_congr
+#align stream.wseq.cons_congr Stream'.Wseq.cons_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem think_equiv (s : Wseq α) : think s ~ s := by unfold Equiv <;> simp <;> apply Equiv.refl
-#align wseq.think_equiv Wseq.think_equiv
+#align stream.wseq.think_equiv Stream'.Wseq.think_equiv
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem think_congr {s t : Wseq α} (a : α) (h : s ~ t) : think s ~ think t := by
+theorem think_congr {s t : Wseq α} (h : s ~ t) : think s ~ think t := by
   unfold Equiv <;> simp <;> exact h
-#align wseq.think_congr Wseq.think_congr
+#align stream.wseq.think_congr Stream'.Wseq.think_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1113,7 +1120,7 @@ theorem head_congr : ∀ {s t : Wseq α}, s ~ t → head s ~ head t :=
   cases' destruct_congr h with l r
   rcases l dsm with ⟨dt, dtm, dst⟩
   cases' ds with a <;> cases' dt with b
-  · apply mem_map _ dtm
+  · apply Computation.mem_map _ dtm
   · cases b
     cases dst
   · cases a
@@ -1121,8 +1128,8 @@ theorem head_congr : ∀ {s t : Wseq α}, s ~ t → head s ~ head t :=
   · cases' a with a s'
     cases' b with b t'
     rw [dst.left]
-    exact @mem_map _ _ (@Functor.map _ _ (α × Wseq α) _ Prod.fst) _ (destruct t) dtm
-#align wseq.head_congr Wseq.head_congr
+    exact @Computation.mem_map _ _ (@Functor.map _ _ (α × wseq α) _ Prod.fst) _ (destruct t) dtm
+#align stream.wseq.head_congr Stream'.Wseq.head_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem flatten_equiv {c : Computation (Wseq α)} {s} (h : s ∈ c) : flatten c ~ s :=
@@ -1131,7 +1138,7 @@ theorem flatten_equiv {c : Computation (Wseq α)} {s} (h : s ∈ c) : flatten c
   · intro s'
     apply Equiv.trans
     simp [think_equiv]
-#align wseq.flatten_equiv Wseq.flatten_equiv
+#align stream.wseq.flatten_equiv Stream'.Wseq.flatten_equiv
 
 theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (Wseq α)} {c2 : Computation (Wseq β)}
     (h : c1.LiftRel (LiftRel R) c2) : LiftRel R (flatten c1) (flatten c2) :=
@@ -1143,13 +1150,13 @@ theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (Wseq α)} {c
       intro a b ab; apply Computation.LiftRel.imp _ _ _ (lift_rel_destruct ab)
       intro a b; apply lift_rel_o.imp_right
       intro s t h; refine' ⟨return s, return t, _, _, _⟩ <;> simp [h]⟩
-#align wseq.lift_rel_flatten Wseq.liftRel_flatten
+#align stream.wseq.lift_rel_flatten Stream'.Wseq.liftRel_flatten
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem flatten_congr {c1 c2 : Computation (Wseq α)} :
     Computation.LiftRel Equiv c1 c2 → flatten c1 ~ flatten c2 :=
   liftRel_flatten
-#align wseq.flatten_congr Wseq.flatten_congr
+#align stream.wseq.flatten_congr Stream'.Wseq.flatten_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1167,19 +1174,19 @@ theorem tail_congr {s t : Wseq α} (h : s ~ t) : tail s ~ tail t :=
   · cases' a with a s'
     cases' b with b t'
     exact h.right
-#align wseq.tail_congr Wseq.tail_congr
+#align stream.wseq.tail_congr Stream'.Wseq.tail_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem dropn_congr {s t : Wseq α} (h : s ~ t) (n) : drop s n ~ drop t n := by
   induction n <;> simp [*, tail_congr]
-#align wseq.dropn_congr Wseq.dropn_congr
+#align stream.wseq.dropn_congr Stream'.Wseq.dropn_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem nth_congr {s t : Wseq α} (h : s ~ t) (n) : nth s n ~ nth t n :=
   head_congr (dropn_congr h _)
-#align wseq.nth_congr Wseq.nth_congr
+#align stream.wseq.nth_congr Stream'.Wseq.nth_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1188,12 +1195,12 @@ theorem mem_congr {s t : Wseq α} (h : s ~ t) (a) : a ∈ s ↔ a ∈ t :=
   fun s t h as =>
   let ⟨n, hn⟩ := exists_nth_of_mem as
   nth_mem ((nth_congr h _ _).1 hn)
-#align wseq.mem_congr Wseq.mem_congr
+#align stream.wseq.mem_congr Stream'.Wseq.mem_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem productive_congr {s t : Wseq α} (h : s ~ t) : Productive s ↔ Productive t := by
   simp only [productive_iff] <;> exact forall_congr' fun n => terminates_congr <| nth_congr h _
-#align wseq.productive_congr Wseq.productive_congr
+#align stream.wseq.productive_congr Stream'.Wseq.productive_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1208,188 +1215,187 @@ theorem Equiv.ext {s t : Wseq α} (h : ∀ n, nth s n ~ nth t n) : s ~ t :=
     · intro a b ma mb
       cases' a with a <;> cases' b with b
       · trivial
-      · injection mem_unique (mem_map _ ma) ((h 0 _).2 (mem_map _ mb))
-      · injection mem_unique (mem_map _ ma) ((h 0 _).2 (mem_map _ mb))
+      · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb))
+      · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb))
       · cases' a with a s'
         cases' b with b t'
-        injection mem_unique (mem_map _ ma) ((h 0 _).2 (mem_map _ mb)) with ab
+        injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) with
+          ab
         refine' ⟨ab, fun n => _⟩
         refine'
-          (nth_congr (flatten_equiv (mem_map _ ma)) n).symm.trans
+          (nth_congr (flatten_equiv (Computation.mem_map _ ma)) n).symm.trans
             ((_ : nth (tail s) n ~ nth (tail t) n).trans
-              (nth_congr (flatten_equiv (mem_map _ mb)) n))
+              (nth_congr (flatten_equiv (Computation.mem_map _ mb)) n))
         rw [nth_tail, nth_tail]
         apply h⟩
-#align wseq.equiv.ext Wseq.Equiv.ext
+#align stream.wseq.equiv.ext Stream'.Wseq.Equiv.ext
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem length_eq_map (s : Wseq α) : length s = Computation.map List.length (toList s) :=
   by
   refine'
-    eq_of_bisim
+    Computation.eq_of_bisim
       (fun c1 c2 =>
-        ∃ (l : List α)(s : Wseq α),
-          c1 = corec length._match_2 (l.length, s) ∧
-            c2 = Computation.map List.length (corec to_list._match_2 (l, s)))
+        ∃ (l : List α)(s : wseq α),
+          c1 = Computation.corec length._match_2 (l.length, s) ∧
+            c2 = Computation.map List.length (Computation.corec to_list._match_2 (l, s)))
       _ ⟨[], s, rfl, rfl⟩
   intro s1 s2 h; rcases h with ⟨l, s, h⟩; rw [h.left, h.right]
   apply s.rec_on _ (fun a s => _) fun s => _ <;> repeat' simp [to_list, nil, cons, think, length]
   · refine' ⟨a::l, s, _, _⟩ <;> simp
   · refine' ⟨l, s, _, _⟩ <;> simp
-#align wseq.length_eq_map Wseq.length_eq_map
+#align stream.wseq.length_eq_map Stream'.Wseq.length_eq_map
 
 @[simp]
 theorem ofList_nil : ofList [] = (nil : Wseq α) :=
   rfl
-#align wseq.of_list_nil Wseq.ofList_nil
+#align stream.wseq.of_list_nil Stream'.Wseq.ofList_nil
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem ofList_cons (a : α) (l) : ofList (a::l) = cons a (ofList l) :=
-  show
-    SeqCat.map some (SeqCat.ofList (a::l)) =
-      SeqCat.cons (some a) (SeqCat.map some (SeqCat.ofList l))
-    by simp
-#align wseq.of_list_cons Wseq.ofList_cons
+  show Seq.map some (Seq.ofList (a::l)) = Seq.cons (some a) (Seq.map some (Seq.ofList l)) by simp
+#align stream.wseq.of_list_cons Stream'.Wseq.ofList_cons
 
 @[simp]
-theorem to_list'_nil (l : List α) : corec ToList._match2 (l, nil) = return l.reverse :=
+theorem to_list'_nil (l : List α) : Computation.corec ToList._match2 (l, nil) = return l.reverse :=
   destruct_eq_pure rfl
-#align wseq.to_list'_nil Wseq.to_list'_nil
+#align stream.wseq.to_list'_nil Stream'.Wseq.to_list'_nil
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem to_list'_cons (l : List α) (s : Wseq α) (a : α) :
-    corec ToList._match2 (l, cons a s) = (corec ToList._match2 (a::l, s)).think :=
+    Computation.corec ToList._match2 (l, cons a s) =
+      (Computation.corec ToList._match2 (a::l, s)).think :=
   destruct_eq_think <| by simp [to_list, cons]
-#align wseq.to_list'_cons Wseq.to_list'_cons
+#align stream.wseq.to_list'_cons Stream'.Wseq.to_list'_cons
 
 @[simp]
 theorem to_list'_think (l : List α) (s : Wseq α) :
-    corec ToList._match2 (l, think s) = (corec ToList._match2 (l, s)).think :=
+    Computation.corec ToList._match2 (l, think s) =
+      (Computation.corec ToList._match2 (l, s)).think :=
   destruct_eq_think <| by simp [to_list, think]
-#align wseq.to_list'_think Wseq.to_list'_think
+#align stream.wseq.to_list'_think Stream'.Wseq.to_list'_think
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem to_list'_map (l : List α) (s : Wseq α) :
-    corec ToList._match2 (l, s) = (· ++ ·) l.reverse <$> toList s :=
+    Computation.corec ToList._match2 (l, s) = (· ++ ·) l.reverse <$> toList s :=
   by
   refine'
-    eq_of_bisim
+    Computation.eq_of_bisim
       (fun c1 c2 =>
-        ∃ (l' : List α)(s : Wseq α),
-          c1 = corec to_list._match_2 (l' ++ l, s) ∧
-            c2 = Computation.map ((· ++ ·) l.reverse) (corec to_list._match_2 (l', s)))
+        ∃ (l' : List α)(s : wseq α),
+          c1 = Computation.corec to_list._match_2 (l' ++ l, s) ∧
+            c2 = Computation.map ((· ++ ·) l.reverse) (Computation.corec to_list._match_2 (l', s)))
       _ ⟨[], s, rfl, rfl⟩
   intro s1 s2 h; rcases h with ⟨l', s, h⟩; rw [h.left, h.right]
   apply s.rec_on _ (fun a s => _) fun s => _ <;> repeat' simp [to_list, nil, cons, think, length]
   · refine' ⟨a::l', s, _, _⟩ <;> simp
   · refine' ⟨l', s, _, _⟩ <;> simp
-#align wseq.to_list'_map Wseq.to_list'_map
+#align stream.wseq.to_list'_map Stream'.Wseq.to_list'_map
 
 @[simp]
 theorem toList_cons (a : α) (s) : toList (cons a s) = (List.cons a <$> toList s).think :=
   destruct_eq_think <| by unfold to_list <;> simp <;> rw [to_list'_map] <;> simp <;> rfl
-#align wseq.to_list_cons Wseq.toList_cons
+#align stream.wseq.to_list_cons Stream'.Wseq.toList_cons
 
 @[simp]
 theorem toList_nil : toList (nil : Wseq α) = return [] :=
   destruct_eq_pure rfl
-#align wseq.to_list_nil Wseq.toList_nil
+#align stream.wseq.to_list_nil Stream'.Wseq.toList_nil
 
 theorem toList_ofList (l : List α) : l ∈ toList (ofList l) := by
-  induction' l with a l IH <;> simp [ret_mem] <;> exact think_mem (mem_map _ IH)
-#align wseq.to_list_of_list Wseq.toList_ofList
+  induction' l with a l IH <;> simp [ret_mem] <;> exact think_mem (Computation.mem_map _ IH)
+#align stream.wseq.to_list_of_list Stream'.Wseq.toList_ofList
 
 @[simp]
-theorem destruct_ofSeq (s : SeqCat α) :
+theorem destruct_ofSeq (s : Seq α) :
     destruct (ofSeq s) = return (s.headI.map fun a => (a, ofSeq s.tail)) :=
-  destruct_eq_pure <|
-    by
-    simp [of_seq, head, destruct, SeqCat.destruct, SeqCat.head]
-    rw [show SeqCat.nth (some <$> s) 0 = some <$> SeqCat.nth s 0 by apply SeqCat.map_nth]
-    cases' SeqCat.nth s 0 with a; · rfl
+  destruct_eq_pure <| by
+    simp [of_seq, head, destruct, seq.destruct, seq.head]
+    rw [show seq.nth (some <$> s) 0 = some <$> seq.nth s 0 by apply seq.map_nth]
+    cases' seq.nth s 0 with a; · rfl
     unfold Functor.map
     simp [destruct]
-#align wseq.destruct_of_seq Wseq.destruct_ofSeq
+#align stream.wseq.destruct_of_seq Stream'.Wseq.destruct_ofSeq
 
 @[simp]
-theorem head_ofSeq (s : SeqCat α) : head (ofSeq s) = return s.headI := by
-  simp [head] <;> cases SeqCat.head s <;> rfl
-#align wseq.head_of_seq Wseq.head_ofSeq
+theorem head_ofSeq (s : Seq α) : head (ofSeq s) = return s.headI := by
+  simp [head] <;> cases seq.head s <;> rfl
+#align stream.wseq.head_of_seq Stream'.Wseq.head_ofSeq
 
 @[simp]
-theorem tail_ofSeq (s : SeqCat α) : tail (ofSeq s) = ofSeq s.tail :=
+theorem tail_ofSeq (s : Seq α) : tail (ofSeq s) = ofSeq s.tail :=
   by
   simp [tail]; apply s.rec_on _ fun x s => _ <;> simp [of_seq]; · rfl
-  rw [SeqCat.head_cons, SeqCat.tail_cons]; rfl
-#align wseq.tail_of_seq Wseq.tail_ofSeq
+  rw [seq.head_cons, seq.tail_cons]; rfl
+#align stream.wseq.tail_of_seq Stream'.Wseq.tail_ofSeq
 
 @[simp]
-theorem dropn_ofSeq (s : SeqCat α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n)
+theorem dropn_ofSeq (s : Seq α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n)
   | 0 => rfl
   | n + 1 => by dsimp [drop] <;> rw [dropn_of_seq, tail_of_seq]
-#align wseq.dropn_of_seq Wseq.dropn_ofSeq
+#align stream.wseq.dropn_of_seq Stream'.Wseq.dropn_ofSeq
 
-theorem nth_ofSeq (s : SeqCat α) (n) : nth (ofSeq s) n = return (SeqCat.nth s n) := by
-  dsimp [nth] <;> rw [dropn_of_seq, head_of_seq, SeqCat.head_dropn]
-#align wseq.nth_of_seq Wseq.nth_ofSeq
+theorem nth_ofSeq (s : Seq α) (n) : nth (ofSeq s) n = return (Seq.nth s n) := by
+  dsimp [nth] <;> rw [dropn_of_seq, head_of_seq, seq.head_dropn]
+#align stream.wseq.nth_of_seq Stream'.Wseq.nth_ofSeq
 
-instance productive_ofSeq (s : SeqCat α) : Productive (ofSeq s) :=
+instance productive_ofSeq (s : Seq α) : Productive (ofSeq s) :=
   ⟨fun n => by rw [nth_of_seq] <;> infer_instance⟩
-#align wseq.productive_of_seq Wseq.productive_ofSeq
+#align stream.wseq.productive_of_seq Stream'.Wseq.productive_ofSeq
 
-theorem toSeq_ofSeq (s : SeqCat α) : toSeq (ofSeq s) = s :=
+theorem toSeq_ofSeq (s : Seq α) : toSeq (ofSeq s) = s :=
   by
   apply Subtype.eq; funext n
   dsimp [to_seq]; apply get_eq_of_mem
   rw [nth_of_seq]; apply ret_mem
-#align wseq.to_seq_of_seq Wseq.toSeq_ofSeq
+#align stream.wseq.to_seq_of_seq Stream'.Wseq.toSeq_ofSeq
 
 /-- The monadic `return a` is a singleton list containing `a`. -/
 def ret (a : α) : Wseq α :=
   ofList [a]
-#align wseq.ret Wseq.ret
+#align stream.wseq.ret Stream'.Wseq.ret
 
 @[simp]
 theorem map_nil (f : α → β) : map f nil = nil :=
   rfl
-#align wseq.map_nil Wseq.map_nil
+#align stream.wseq.map_nil Stream'.Wseq.map_nil
 
 @[simp]
 theorem map_cons (f : α → β) (a s) : map f (cons a s) = cons (f a) (map f s) :=
-  SeqCat.map_cons _ _ _
-#align wseq.map_cons Wseq.map_cons
+  Seq.map_cons _ _ _
+#align stream.wseq.map_cons Stream'.Wseq.map_cons
 
 @[simp]
 theorem map_think (f : α → β) (s) : map f (think s) = think (map f s) :=
-  SeqCat.map_cons _ _ _
-#align wseq.map_think Wseq.map_think
+  Seq.map_cons _ _ _
+#align stream.wseq.map_think Stream'.Wseq.map_think
 
 @[simp]
 theorem map_id (s : Wseq α) : map id s = s := by simp [map]
-#align wseq.map_id Wseq.map_id
+#align stream.wseq.map_id Stream'.Wseq.map_id
 
 @[simp]
 theorem map_ret (f : α → β) (a) : map f (ret a) = ret (f a) := by simp [ret]
-#align wseq.map_ret Wseq.map_ret
+#align stream.wseq.map_ret Stream'.Wseq.map_ret
 
 @[simp]
 theorem map_append (f : α → β) (s t) : map f (append s t) = append (map f s) (map f t) :=
-  SeqCat.map_append _ _ _
-#align wseq.map_append Wseq.map_append
+  Seq.map_append _ _ _
+#align stream.wseq.map_append Stream'.Wseq.map_append
 
 theorem map_comp (f : α → β) (g : β → γ) (s : Wseq α) : map (g ∘ f) s = map g (map f s) :=
   by
-  dsimp [map]; rw [← SeqCat.map_comp]
+  dsimp [map]; rw [← seq.map_comp]
   apply congr_fun; apply congr_arg
   ext ⟨⟩ <;> rfl
-#align wseq.map_comp Wseq.map_comp
+#align stream.wseq.map_comp Stream'.Wseq.map_comp
 
 theorem mem_map (f : α → β) {a : α} {s : Wseq α} : a ∈ s → f a ∈ map f s :=
-  SeqCat.mem_map (Option.map f)
-#align wseq.mem_map Wseq.mem_map
+  Seq.mem_map (Option.map f)
+#align stream.wseq.mem_map Stream'.Wseq.mem_map
 
 -- The converse is not true without additional assumptions
 theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S → ∃ s, s ∈ S ∧ a ∈ s :=
@@ -1400,8 +1406,8 @@ theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S →
     from fun S h => (this _ h nil S (by simp) (by simp [h])).resolve_left (not_mem_nil _)
   intro ss h; apply mem_rec_on h (fun b ss o => _) fun ss IH => _ <;> intro s S
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej <;> have := congr_arg SeqCat.destruct ej <;>
-          simp at this <;> try cases this <;> try contradiction
+                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
+        try cases this <;> try contradiction
     substs b' ss
     simp at m⊢
     cases' o with e IH
@@ -1410,8 +1416,8 @@ theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S →
     · simp [e]
     exact Or.imp_left Or.inr (IH _ _ rfl m)
   · refine' s.rec_on (S.rec_on _ (fun s S => _) fun S => _) (fun b' s => _) fun s => _ <;>
-                intro ej m <;> simp at ej <;> have := congr_arg SeqCat.destruct ej <;>
-          simp at this <;> try try have := this.1; contradiction <;> subst ss
+                intro ej m <;> simp at ej <;> have := congr_arg seq.destruct ej <;> simp at this <;>
+        try try have := this.1; contradiction <;> subst ss
     · apply Or.inr
       simp at m⊢
       cases' IH s S rfl m with as ex
@@ -1424,20 +1430,20 @@ theorem exists_of_mem_join {a : α} : ∀ {S : Wseq (Wseq α)}, a ∈ join S →
       exact ⟨s, by simp [sS], as⟩
     · simp at m IH⊢
       apply IH _ _ rfl m
-#align wseq.exists_of_mem_join Wseq.exists_of_mem_join
+#align stream.wseq.exists_of_mem_join Stream'.Wseq.exists_of_mem_join
 
 theorem exists_of_mem_bind {s : Wseq α} {f : α → Wseq β} {b} (h : b ∈ bind s f) :
     ∃ a ∈ s, b ∈ f a :=
   let ⟨t, tm, bt⟩ := exists_of_mem_join h
   let ⟨a, as, e⟩ := exists_of_mem_map tm
   ⟨a, as, by rwa [e]⟩
-#align wseq.exists_of_mem_bind Wseq.exists_of_mem_bind
+#align stream.wseq.exists_of_mem_bind Stream'.Wseq.exists_of_mem_bind
 
 theorem destruct_map (f : α → β) (s : Wseq α) :
     destruct (map f s) = Computation.map (Option.map (Prod.map f (map f))) (destruct s) :=
   by
   apply
-    eq_of_bisim fun c1 c2 =>
+    Computation.eq_of_bisim fun c1 c2 =>
       ∃ s,
         c1 = destruct (map f s) ∧
           c2 = Computation.map (Option.map (Prod.map f (map f))) (destruct s)
@@ -1447,7 +1453,7 @@ theorem destruct_map (f : α → β) (s : Wseq α) :
     apply s.rec_on _ (fun a s => _) fun s => _ <;> simp
     exact ⟨s, rfl, rfl⟩
   · exact ⟨s, rfl, rfl⟩
-#align wseq.destruct_map Wseq.destruct_map
+#align stream.wseq.destruct_map Stream'.Wseq.destruct_map
 
 theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Wseq α} {s2 : Wseq β}
     {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2) (h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) :
@@ -1464,25 +1470,26 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
       · cases' a with a s <;> cases' b with b t
         cases' h with r h
         exact ⟨h2 r, s, rfl, t, rfl, h⟩⟩
-#align wseq.lift_rel_map Wseq.liftRel_map
+#align stream.wseq.lift_rel_map Stream'.Wseq.liftRel_map
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem map_congr (f : α → β) {s t : Wseq α} (h : s ~ t) : map f s ~ map f t :=
   liftRel_map _ _ h fun _ _ => congr_arg _
-#align wseq.map_congr Wseq.map_congr
+#align stream.wseq.map_congr Stream'.Wseq.map_congr
 
+/-- auxilary defintion of `destruct_append` over weak sequences-/
 @[simp]
 def DestructAppend.aux (t : Wseq α) : Option (α × Wseq α) → Computation (Option (α × Wseq α))
   | none => destruct t
   | some (a, s) => return (some (a, append s t))
-#align wseq.destruct_append.aux Wseq.DestructAppend.aux
+#align stream.wseq.destruct_append.aux Stream'.Wseq.DestructAppend.aux
 
 theorem destruct_append (s t : Wseq α) :
     destruct (append s t) = (destruct s).bind (DestructAppend.aux t) :=
   by
   apply
-    eq_of_bisim
+    Computation.eq_of_bisim
       (fun c1 c2 =>
         ∃ s t, c1 = destruct (append s t) ∧ c2 = (destruct s).bind (destruct_append.aux t))
       _ ⟨s, t, rfl, rfl⟩
@@ -1491,19 +1498,20 @@ theorem destruct_append (s t : Wseq α) :
   · apply t.rec_on _ (fun b t => _) fun t => _ <;> simp
     · refine' ⟨nil, t, _, _⟩ <;> simp
   · exact ⟨s, t, rfl, rfl⟩
-#align wseq.destruct_append Wseq.destruct_append
+#align stream.wseq.destruct_append Stream'.Wseq.destruct_append
 
+/-- auxilary defintion of `destruct_join` over weak sequences-/
 @[simp]
 def DestructJoin.aux : Option (Wseq α × Wseq (Wseq α)) → Computation (Option (α × Wseq α))
   | none => return none
   | some (s, S) => (destruct (append s (join S))).think
-#align wseq.destruct_join.aux Wseq.DestructJoin.aux
+#align stream.wseq.destruct_join.aux Stream'.Wseq.DestructJoin.aux
 
 theorem destruct_join (S : Wseq (Wseq α)) :
     destruct (join S) = (destruct S).bind DestructJoin.aux :=
   by
   apply
-    eq_of_bisim
+    Computation.eq_of_bisim
       (fun c1 c2 =>
         c1 = c2 ∨ ∃ S, c1 = destruct (join S) ∧ c2 = (destruct S).bind destruct_join.aux)
       _ (Or.inr ⟨S, rfl, rfl⟩)
@@ -1515,7 +1523,7 @@ theorem destruct_join (S : Wseq (Wseq α)) :
       by
       apply S.rec_on _ (fun s S => _) fun S => _ <;> simp
       · refine' Or.inr ⟨S, rfl, rfl⟩
-#align wseq.destruct_join Wseq.destruct_join
+#align stream.wseq.destruct_join Stream'.Wseq.destruct_join
 
 theorem liftRel_append (R : α → β → Prop) {s1 s2 : Wseq α} {t1 t2 : Wseq β} (h1 : LiftRel R s1 t1)
     (h2 : LiftRel R s2 t2) : LiftRel R (append s1 s2) (append t1 t2) :=
@@ -1545,7 +1553,7 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : Wseq α} {t1 t2 : Wseq
         cases' h with r h
         simp
         exact ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
-#align wseq.lift_rel_append Wseq.liftRel_append
+#align stream.wseq.lift_rel_append Stream'.Wseq.liftRel_append
 
 theorem LiftRelJoin.lem (R : α → β → Prop) {S T} {U : Wseq α → Wseq β → Prop}
     (ST : LiftRel (LiftRel R) S T)
@@ -1600,7 +1608,7 @@ theorem LiftRelJoin.lem (R : α → β → Prop) {S T} {U : Wseq α → Wseq β
               apply ret_mem
             rw [eq_of_ret_mem rs5.mem]
             exact ⟨ab, HU _ _ ⟨s', t', S', T', rfl, rfl, st', ST'⟩⟩
-#align wseq.lift_rel_join.lem Wseq.LiftRelJoin.lem
+#align stream.wseq.lift_rel_join.lem Stream'.Wseq.LiftRelJoin.lem
 
 theorem liftRel_join (R : α → β → Prop) {S : Wseq (Wseq α)} {T : Wseq (Wseq β)}
     (h : LiftRel (LiftRel R) S T) : LiftRel R (join S) (join T) :=
@@ -1627,18 +1635,18 @@ theorem liftRel_join (R : α → β → Prop) {S : Wseq (Wseq α)} {T : Wseq (Ws
           · rw [← lift_rel.swap R, ← lift_rel.swap (lift_rel R)]
             exact fun s1 s2 ⟨s, t, S, T, h1, h2, st, ST⟩ => ⟨t, s, T, S, h2, h1, st, ST⟩
           · exact mb⟩
-#align wseq.lift_rel_join Wseq.liftRel_join
+#align stream.wseq.lift_rel_join Stream'.Wseq.liftRel_join
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem join_congr {S T : Wseq (Wseq α)} (h : LiftRel Equiv S T) : join S ~ join T :=
   liftRel_join _ h
-#align wseq.join_congr Wseq.join_congr
+#align stream.wseq.join_congr Stream'.Wseq.join_congr
 
 theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Wseq α} {s2 : Wseq β}
     {f1 : α → Wseq γ} {f2 : β → Wseq δ} (h1 : LiftRel R s1 s2)
     (h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
   liftRel_join _ (liftRel_map _ _ h1 @h2)
-#align wseq.lift_rel_bind Wseq.liftRel_bind
+#align stream.wseq.lift_rel_bind Stream'.Wseq.liftRel_bind
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -1646,12 +1654,12 @@ theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1
 theorem bind_congr {s1 s2 : Wseq α} {f1 f2 : α → Wseq β} (h1 : s1 ~ s2) (h2 : ∀ a, f1 a ~ f2 a) :
     bind s1 f1 ~ bind s2 f2 :=
   liftRel_bind _ _ h1 fun a b h => by rw [h] <;> apply h2
-#align wseq.bind_congr Wseq.bind_congr
+#align stream.wseq.bind_congr Stream'.Wseq.bind_congr
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem join_ret (s : Wseq α) : join (ret s) ~ s := by simp [ret] <;> apply think_equiv
-#align wseq.join_ret Wseq.join_ret
+#align stream.wseq.join_ret Stream'.Wseq.join_ret
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -1667,12 +1675,12 @@ theorem join_map_ret (s : Wseq α) : join (map ret s) ~ s :=
         clear h _match
         have :
           ∀ s,
-            ∃ s' : Wseq α,
+            ∃ s' : wseq α,
               (map ret s).join.destruct = (map ret s').join.destruct ∧ destruct s = s'.destruct :=
           fun s => ⟨s, rfl, rfl⟩
         apply s.rec_on _ (fun a s => _) fun s => _ <;> simp [ret, ret_mem, this, Option.exists]
   · exact ⟨s, rfl, rfl⟩
-#align wseq.join_map_ret Wseq.join_map_ret
+#align stream.wseq.join_map_ret Stream'.Wseq.join_map_ret
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -1686,7 +1694,7 @@ theorem join_append (S T : Wseq (Wseq α)) : join (append S T) ~ append (join S)
   apply
     lift_rel_rec
       (fun c1 c2 =>
-        ∃ (s : Wseq α)(S T : _),
+        ∃ (s : wseq α)(S T : _),
           c1 = destruct (append s (join (append S T))) ∧
             c2 = destruct (append s (append (join S) (join T))))
       _ _ _
@@ -1697,16 +1705,16 @@ theorem join_append (S T : Wseq (Wseq α)) : join (append S T) ~ append (join S)
     match c1, c2, h with
     | _, _, ⟨s, S, T, rfl, rfl⟩ => by
       clear _match h h
-      apply Wseq.recOn s _ (fun a s => _) fun s => _ <;> simp
-      · apply Wseq.recOn S _ (fun s S => _) fun S => _ <;> simp
-        · apply Wseq.recOn T _ (fun s T => _) fun T => _ <;> simp
+      apply wseq.rec_on s _ (fun a s => _) fun s => _ <;> simp
+      · apply wseq.rec_on S _ (fun s S => _) fun S => _ <;> simp
+        · apply wseq.rec_on T _ (fun s T => _) fun T => _ <;> simp
           · refine' ⟨s, nil, T, _, _⟩ <;> simp
           · refine' ⟨nil, nil, T, _, _⟩ <;> simp
         · exact ⟨s, S, T, rfl, rfl⟩
         · refine' ⟨nil, S, T, _, _⟩ <;> simp
       · exact ⟨s, S, T, rfl, rfl⟩
       · exact ⟨s, S, T, rfl, rfl⟩
-#align wseq.join_append Wseq.join_append
+#align stream.wseq.join_append Stream'.Wseq.join_append
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -1714,32 +1722,32 @@ theorem bind_ret (f : α → β) (s) : bind s (ret ∘ f) ~ map f s :=
   by
   dsimp [bind]; change fun x => ret (f x) with ret ∘ f
   rw [map_comp]; apply join_map_ret
-#align wseq.bind_ret Wseq.bind_ret
+#align stream.wseq.bind_ret Stream'.Wseq.bind_ret
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
 theorem ret_bind (a : α) (f : α → Wseq β) : bind (ret a) f ~ f a := by simp [bind]
-#align wseq.ret_bind Wseq.ret_bind
+#align stream.wseq.ret_bind Stream'.Wseq.ret_bind
 
 @[simp]
 theorem map_join (f : α → β) (S) : map f (join S) = join (map (map f) S) :=
   by
   apply
-    SeqCat.eq_of_bisim fun s1 s2 =>
+    seq.eq_of_bisim fun s1 s2 =>
       ∃ s S, s1 = append s (map f (join S)) ∧ s2 = append s (join (map (map f) S))
   · intro s1 s2 h
     exact
       match s1, s2, h with
       | _, _, ⟨s, S, rfl, rfl⟩ =>
         by
-        apply Wseq.recOn s _ (fun a s => _) fun s => _ <;> simp
-        · apply Wseq.recOn S _ (fun s S => _) fun S => _ <;> simp
+        apply wseq.rec_on s _ (fun a s => _) fun s => _ <;> simp
+        · apply wseq.rec_on S _ (fun s S => _) fun S => _ <;> simp
           · exact ⟨map f s, S, rfl, rfl⟩
           · refine' ⟨nil, S, _, _⟩ <;> simp
         · exact ⟨_, _, rfl, rfl⟩
         · exact ⟨_, _, rfl, rfl⟩
   · refine' ⟨nil, S, _, _⟩ <;> simp
-#align wseq.map_join Wseq.map_join
+#align stream.wseq.map_join Stream'.Wseq.map_join
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -1766,16 +1774,16 @@ theorem join_join (SS : Wseq (Wseq (Wseq α))) : join (join SS) ~ join (map join
     match c1, c2, h with
     | _, _, ⟨s, S, SS, rfl, rfl⟩ => by
       clear _match h h
-      apply Wseq.recOn s _ (fun a s => _) fun s => _ <;> simp
-      · apply Wseq.recOn S _ (fun s S => _) fun S => _ <;> simp
-        · apply Wseq.recOn SS _ (fun S SS => _) fun SS => _ <;> simp
+      apply wseq.rec_on s _ (fun a s => _) fun s => _ <;> simp
+      · apply wseq.rec_on S _ (fun s S => _) fun S => _ <;> simp
+        · apply wseq.rec_on SS _ (fun S SS => _) fun SS => _ <;> simp
           · refine' ⟨nil, S, SS, _, _⟩ <;> simp
           · refine' ⟨nil, nil, SS, _, _⟩ <;> simp
         · exact ⟨s, S, SS, rfl, rfl⟩
         · refine' ⟨nil, S, SS, _, _⟩ <;> simp
       · exact ⟨s, S, SS, rfl, rfl⟩
       · exact ⟨s, S, SS, rfl, rfl⟩
-#align wseq.join_join Wseq.join_join
+#align stream.wseq.join_join Stream'.Wseq.join_join
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 @[simp]
@@ -1784,7 +1792,7 @@ theorem bind_assoc (s : Wseq α) (f : α → Wseq β) (g : β → Wseq γ) :
   by
   simp [bind]; rw [← map_comp f (map g), map_comp (map g ∘ f) join]
   apply join_join
-#align wseq.bind_assoc Wseq.bind_assoc
+#align stream.wseq.bind_assoc Stream'.Wseq.bind_assoc
 
 instance : Monad Wseq where
   map := @map
@@ -1807,3 +1815,5 @@ instance : is_lawful_monad wseq :=
 -/
 end Wseq
 
+end Stream'
+

Changes in mathlib4

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

A PR accompanying #12339.

Zulip discussion

Diff
@@ -509,8 +509,8 @@ theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β
       Or.inr h, fun {s t} h => by
       have h : Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := by
         cases' h with h h
-        exact liftRel_destruct h
-        assumption
+        · exact liftRel_destruct h
+        · assumption
       apply Computation.LiftRel.imp _ _ _ h
       intro a b
       apply LiftRelO.imp_right
@@ -1041,7 +1041,7 @@ theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t
   | n + 1 => by
     simp only [LiftRelO, drop, Nat.add_eq, Nat.add_zero, destruct_tail, tail.aux]
     apply liftRel_bind
-    apply liftRel_dropn_destruct H n
+    · apply liftRel_dropn_destruct H n
     exact fun {a b} o =>
       match a, b, o with
       | none, none, _ => by
chore: tidy various files (#12042)
Diff
@@ -1158,7 +1158,6 @@ theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (WSeq α)} {c
   ⟨S, ⟨c1, c2, rfl, rfl, h⟩, fun {s t} h =>
     match s, t, h with
     | _, _, ⟨c1, c2, rfl, rfl, h⟩ => by
-      -- Porting note: `exists_and_left` should be excluded.
       simp only [destruct_flatten]; apply liftRel_bind _ _ h
       intro a b ab; apply Computation.LiftRel.imp _ _ _ (liftRel_destruct ab)
       intro a b; apply LiftRelO.imp_right
@@ -1176,7 +1175,6 @@ theorem tail_congr {s t : WSeq α} (h : s ~ʷ t) : tail s ~ʷ tail t := by
   apply flatten_congr
   dsimp only [(· <$> ·)]; rw [← Computation.bind_pure, ← Computation.bind_pure]
   apply liftRel_bind _ _ (destruct_congr h)
-  -- Porting note: These 2 theorems should be excluded.
   intro a b h; simp only [comp_apply, liftRel_pure]
   cases' a with a <;> cases' b with b
   · trivial
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
@@ -737,7 +737,7 @@ theorem dropn_add (s : WSeq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
 #align stream.wseq.dropn_add Stream'.WSeq.dropn_add
 
 theorem dropn_tail (s : WSeq α) (n) : drop (tail s) n = drop s (n + 1) := by
-  rw [add_comm]
+  rw [Nat.add_comm]
   symm
   apply dropn_add
 #align stream.wseq.dropn_tail Stream'.WSeq.dropn_tail
@@ -1039,7 +1039,7 @@ theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t
     ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n))
   | 0 => liftRel_destruct H
   | n + 1 => by
-    simp only [LiftRelO, drop, Nat.add_eq, add_zero, destruct_tail, tail.aux]
+    simp only [LiftRelO, drop, Nat.add_eq, Nat.add_zero, destruct_tail, tail.aux]
     apply liftRel_bind
     apply liftRel_dropn_destruct H n
     exact fun {a b} o =>
@@ -1379,7 +1379,7 @@ theorem tail_ofSeq (s : Seq α) : tail (ofSeq s) = ofSeq s.tail := by
 theorem dropn_ofSeq (s : Seq α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n)
   | 0 => rfl
   | n + 1 => by
-    simp only [drop, Nat.add_eq, add_zero, Seq.drop]
+    simp only [drop, Nat.add_eq, Nat.add_zero, Seq.drop]
     rw [dropn_ofSeq s n, tail_ofSeq]
 #align stream.wseq.dropn_of_seq Stream'.WSeq.dropn_ofSeq
 
chore: split insertNth lemmas from List.Basic (#11542)

Removes the insertNth section of this long file to its own new file. This section seems to be completely independent of the rest of the file, so this is a fairly easy split to make.

Diff
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
 import Mathlib.Logic.Relation
-import Mathlib.Data.List.Basic
 import Mathlib.Data.Option.Basic
 import Mathlib.Data.Seq.Seq
 
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
@@ -3,7 +3,9 @@ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
+import Mathlib.Logic.Relation
 import Mathlib.Data.List.Basic
+import Mathlib.Data.Option.Basic
 import Mathlib.Data.Seq.Seq
 
 #align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
chore: remove tactics (#11365)

More tactics that are not used, found using the linter at #11308.

The PR consists of tactic removals, whitespace changes and replacing a porting note by an explanation.

Diff
@@ -1449,7 +1449,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
   · induction' s using WSeq.recOn with b' s s <;>
       [induction' S using WSeq.recOn with s S S; skip; skip] <;>
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;>
-      simp at this; try cases this; try contradiction
+      simp at this; cases this
     substs b' ss
     simp? at m ⊢ says simp only [cons_append, mem_cons_iff] at m ⊢
     cases' o with e IH
@@ -1460,7 +1460,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
   · induction' s using WSeq.recOn with b' s s <;>
       [induction' S using WSeq.recOn with s S S; skip; skip] <;>
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;> simp at this <;>
-      try { try { have := this.1 }; contradiction } <;> subst ss
+      subst ss
     · apply Or.inr
       -- Porting note: `exists_eq_or_imp` should be excluded.
       simp [-exists_eq_or_imp] at m ⊢
chore: remove useless tactics (#11333)

The removal of some pointless tactics flagged by #11308.

Diff
@@ -545,8 +545,7 @@ theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (Lif
 theorem LiftRelO.swap (R : α → β → Prop) (C) :
     swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by
   funext x y
-  cases' x with x <;> [skip; cases x] <;>
-    (cases' y with y <;> [skip; cases y] <;> rfl)
+  rcases x with ⟨⟩ | ⟨hx, jx⟩ <;> rcases y with ⟨⟩ | ⟨hy, jy⟩ <;> rfl
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
 
 theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) :
chore: more squeeze_simps arising from linter (#11259)

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

Diff
@@ -666,7 +666,9 @@ theorem head_think (s : WSeq α) : head (think s) = (head s).think := by simp [h
 @[simp]
 theorem flatten_pure (s : WSeq α) : flatten (Computation.pure s) = s := by
   refine' Seq.eq_of_bisim (fun s1 s2 => flatten (Computation.pure s2) = s1) _ rfl
-  intro s' s h; rw [← h]; simp [flatten]
+  intro s' s h
+  rw [← h]
+  simp only [Seq.BisimO, flatten, Seq.omap, pure_def, Seq.corec_eq, destruct_pure]
   cases Seq.destruct s with
   | none => simp
   | some val =>
@@ -966,7 +968,7 @@ theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s :=
 #align stream.wseq.mem_cons Stream'.WSeq.mem_cons
 
 theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s := by
-  intro h; have := h; cases' h with n e; revert s; simp [Stream'.get]
+  intro h; have := h; cases' h with n e; revert s; simp only [Stream'.get]
   induction' n with n IH <;> intro s <;> induction' s using WSeq.recOn with x s s <;>
     simp <;> intro m e <;>
     injections
@@ -1045,7 +1047,7 @@ theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t
       | none, none, _ => by
         -- Porting note: These 2 theorems should be excluded.
         simp [-liftRel_pure_left, -liftRel_pure_right]
-      | some (a, s), some (b, t), ⟨_, h2⟩ => by simp [tail.aux]; apply liftRel_destruct h2
+      | some (a, s), some (b, t), ⟨_, h2⟩ => by simpa [tail.aux] using liftRel_destruct h2
 #align stream.wseq.lift_rel_dropn_destruct Stream'.WSeq.liftRel_dropn_destruct
 
 theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t) {a} (h : a ∈ s) :
@@ -1111,14 +1113,14 @@ theorem liftRel_think_right (R : α → β → Prop) (s t) : LiftRel R s (think
 #align stream.wseq.lift_rel_think_right Stream'.WSeq.liftRel_think_right
 
 theorem cons_congr {s t : WSeq α} (a : α) (h : s ~ʷ t) : cons a s ~ʷ cons a t := by
-  unfold Equiv; simp; exact h
+  unfold Equiv; simpa using h
 #align stream.wseq.cons_congr Stream'.WSeq.cons_congr
 
-theorem think_equiv (s : WSeq α) : think s ~ʷ s := by unfold Equiv; simp; apply Equiv.refl
+theorem think_equiv (s : WSeq α) : think s ~ʷ s := by unfold Equiv; simpa using Equiv.refl _
 #align stream.wseq.think_equiv Stream'.WSeq.think_equiv
 
 theorem think_congr {s t : WSeq α} (h : s ~ʷ t) : think s ~ʷ think t := by
-  unfold Equiv; simp; exact h
+  unfold Equiv; simpa using h
 #align stream.wseq.think_congr Stream'.WSeq.think_congr
 
 theorem head_congr : ∀ {s t : WSeq α}, s ~ʷ t → head s ~ head t := by
@@ -1157,7 +1159,7 @@ theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (WSeq α)} {c
     match s, t, h with
     | _, _, ⟨c1, c2, rfl, rfl, h⟩ => by
       -- Porting note: `exists_and_left` should be excluded.
-      simp [-exists_and_left]; apply liftRel_bind _ _ h
+      simp only [destruct_flatten]; apply liftRel_bind _ _ h
       intro a b ab; apply Computation.LiftRel.imp _ _ _ (liftRel_destruct ab)
       intro a b; apply LiftRelO.imp_right
       intro s t h; refine' ⟨Computation.pure s, Computation.pure t, _, _, _⟩ <;>
@@ -1175,7 +1177,7 @@ theorem tail_congr {s t : WSeq α} (h : s ~ʷ t) : tail s ~ʷ tail t := by
   dsimp only [(· <$> ·)]; rw [← Computation.bind_pure, ← Computation.bind_pure]
   apply liftRel_bind _ _ (destruct_congr h)
   -- Porting note: These 2 theorems should be excluded.
-  intro a b h; simp [-liftRel_pure_left, -liftRel_pure_right]
+  intro a b h; simp only [comp_apply, liftRel_pure]
   cases' a with a <;> cases' b with b
   · trivial
   · cases h
@@ -1329,7 +1331,12 @@ theorem toList'_map (l : List α) (s : WSeq α) :
 
 @[simp]
 theorem toList_cons (a : α) (s) : toList (cons a s) = (List.cons a <$> toList s).think :=
-  destruct_eq_think <| by unfold toList; simp; rw [toList'_map]; simp; rfl
+  destruct_eq_think <| by
+    unfold toList
+    simp only [toList'_cons, Computation.destruct_think, Sum.inr.injEq]
+    rw [toList'_map]
+    simp only [List.reverse_cons, List.reverse_nil, List.nil_append, List.singleton_append]
+    rfl
 #align stream.wseq.to_list_cons Stream'.WSeq.toList_cons
 
 @[simp]
@@ -1356,12 +1363,15 @@ theorem destruct_ofSeq (s : Seq α) :
 
 @[simp]
 theorem head_ofSeq (s : Seq α) : head (ofSeq s) = Computation.pure s.head := by
-  simp [head]; cases Seq.head s <;> rfl
+  simp only [head, Option.map_eq_map, destruct_ofSeq, Computation.map_pure, Option.map_map]
+  cases Seq.head s <;> rfl
 #align stream.wseq.head_of_seq Stream'.WSeq.head_ofSeq
 
 @[simp]
 theorem tail_ofSeq (s : Seq α) : tail (ofSeq s) = ofSeq s.tail := by
-  simp [tail]; induction' s using Seq.recOn with x s <;> simp [ofSeq]
+  simp only [tail, destruct_ofSeq, map_pure', flatten_pure]
+  induction' s using Seq.recOn with x s <;> simp only [ofSeq, Seq.tail_nil, Seq.head_nil,
+    Option.map_none', Seq.tail_cons, Seq.head_cons, Option.map_some']
   · rfl
 #align stream.wseq.tail_of_seq Stream'.WSeq.tail_ofSeq
 
@@ -1463,7 +1473,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
       simp? at m says simp only [join_think, nil_append, mem_think] at m
       rcases (IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
-    · simp at m IH ⊢
+    · simp only [think_append, mem_think] at m IH ⊢
       apply IH _ _ rfl m
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 
@@ -1496,7 +1506,8 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
     fun {s1 s2} h =>
     match s1, s2, h with
     | _, _, ⟨s, t, rfl, rfl, h⟩ => by
-      simp [destruct_map]; apply Computation.liftRel_map _ _ (liftRel_destruct h)
+      simp only [exists_and_left, destruct_map]
+      apply Computation.liftRel_map _ _ (liftRel_destruct h)
       intro o p h
       cases' o with a <;> cases' p with b <;> simp
       · cases b; cases h
@@ -1568,7 +1579,7 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : WSeq α} {t1 t2 : WSeq
       apply Computation.liftRel_bind _ _ (liftRel_destruct h)
       intro o p h
       cases' o with a <;> cases' p with b
-      · simp
+      · simp only [destruct_append.aux]
         apply Computation.LiftRel.imp _ _ _ (liftRel_destruct h2)
         intro a b
         apply LiftRelO.imp_right
@@ -1579,8 +1590,7 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : WSeq α} {t1 t2 : WSeq
       · cases' a with a s; cases' b with b t
         cases' h with r h
         -- Porting note: These 2 theorems should be excluded.
-        simp [-liftRel_pure_left, -liftRel_pure_right]
-        exact ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
+        simpa [-liftRel_pure_left, -liftRel_pure_right] using ⟨r, Or.inr ⟨s, rfl, t, rfl, h⟩⟩⟩
 #align stream.wseq.lift_rel_append Stream'.WSeq.liftRel_append
 
 theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β → Prop}
@@ -1594,7 +1604,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
     {a} (ma : a ∈ destruct (join S)) : ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b := by
   cases' exists_results_of_mem ma with n h; clear ma; revert S T ST a
   induction' n using Nat.strongInductionOn with n IH
-  intro S T ST a ra; simp [destruct_join] at ra
+  intro S T ST a ra; simp only [destruct_join] at ra
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
     let ⟨p, mT, rop⟩ := Computation.exists_of_liftRel_left (liftRel_destruct ST) rs1.mem
@@ -1616,7 +1626,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
             apply Nat.lt_succ_of_le (Nat.le_add_right _ _)
           let ⟨ob, mb, rob⟩ := IH _ this ST' rs5'
           refine' ⟨ob, _, rob⟩
-          · simp (config := { unfoldPartialApp := true }) [destruct_join]
+          · simp (config := { unfoldPartialApp := true }) only [destruct_join, destruct_join.aux]
             apply mem_bind mT
             simp only [destruct_append, destruct_append.aux]
             apply think_mem
@@ -1625,7 +1635,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
         | some (a, s'), some (b, t'), ⟨ab, st'⟩, _, rs5, mt => by
           simp?  at rs5  says simp only [destruct_append.aux] at rs5
           refine' ⟨some (b, append t' (join T')), _, _⟩
-          · simp (config := { unfoldPartialApp := true }) [destruct_join]
+          · simp (config := { unfoldPartialApp := true }) only [destruct_join, destruct_join.aux]
             apply mem_bind mT
             simp only [destruct_append, destruct_append.aux]
             apply think_mem
@@ -1647,8 +1657,7 @@ theorem liftRel_join (R : α → β → Prop) {S : WSeq (WSeq α)} {T : WSeq (WS
       match o, p, h with
       | some (a, s), some (b, t), ⟨h1, h2⟩ => by
         -- Porting note: These 2 theorems should be excluded.
-        simp [-liftRel_pure_left, -liftRel_pure_right]
-        exact ⟨h1, s, t, S, rfl, T, rfl, h2, ST⟩
+        simpa [-liftRel_pure_left, -liftRel_pure_right] using ⟨h1, s, t, S, rfl, T, rfl, h2, ST⟩
       | none, none, _ => by
         -- Porting note: `LiftRelO` should be excluded.
         dsimp [destruct_append.aux, Computation.LiftRel, -LiftRelO]; constructor
@@ -1680,7 +1689,7 @@ theorem bind_congr {s1 s2 : WSeq α} {f1 f2 : α → WSeq β} (h1 : s1 ~ʷ s2) (
 #align stream.wseq.bind_congr Stream'.WSeq.bind_congr
 
 @[simp]
-theorem join_ret (s : WSeq α) : join (ret s) ~ʷ s := by simp [ret]; apply think_equiv
+theorem join_ret (s : WSeq α) : join (ret s) ~ʷ s := by simpa [ret] using think_equiv _
 #align stream.wseq.join_ret Stream'.WSeq.join_ret
 
 @[simp]
chore: classify was simp porting notes (#10746)

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

Diff
@@ -720,7 +720,7 @@ theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by
   induction n with
   | zero => simp [drop]
   | succ n n_ih =>
-    -- Porting note: Was `simp [*, drop]`.
+    -- porting note (#10745): was `simp [*, drop]`.
     simp [drop, ← n_ih]
 #align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons
 
@@ -1009,7 +1009,7 @@ theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ g
       apply ret_mem
     · cases' h with n h
       exists n + 1
-      -- Porting note: Was `simp [get?]`.
+      -- porting note (#10745): was `simp [get?]`.
       simpa [get?]
   · intro s' h
     cases' h with n h
chore: Remove nonterminal simp at (#7795)

Removes nonterminal uses of simp at. Replaces most of these with instances of simp? ... says.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -829,7 +829,7 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
     Terminates (head s) :=
   (head_terminates_iff _).2 <| by
     rcases (head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩
-    simp [tail] at h
+    simp? [tail] at h says simp only [tail, destruct_flatten] at h
     rcases exists_of_mem_bind h with ⟨s', h1, _⟩
     unfold Functor.map at h1
     exact
@@ -882,7 +882,7 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
     cases e : Computation.get (get? s (n + 1))
     · assumption
     have := Computation.mem_of_get_eq _ e
-    simp [get?] at this h
+    simp? [get?] at this h says simp only [get?] at this h
     cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@Computation.mem_of_get_eq _ _ _ _ h)
     contradiction⟩
@@ -1442,7 +1442,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;>
       simp at this; try cases this; try contradiction
     substs b' ss
-    simp at m ⊢
+    simp? at m ⊢ says simp only [cons_append, mem_cons_iff] at m ⊢
     cases' o with e IH
     · simp [e]
     cases' m with e m
@@ -1460,7 +1460,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
       · rcases ex with ⟨s', sS, as⟩
         exact ⟨s', Or.inr sS, as⟩
     · apply Or.inr
-      simp at m
+      simp? at m says simp only [join_think, nil_append, mem_think] at m
       rcases (IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
     · simp at m IH ⊢
@@ -1603,7 +1603,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
       simp only [destruct_join]
       exact ⟨none, mem_bind mT (ret_mem _), by rw [eq_of_pure_mem rs2.mem]; trivial⟩
     | some (s, S'), some (t, T'), ⟨st, ST'⟩, _, rs2, mT => by
-      simp [destruct_append] at rs2
+      simp? [destruct_append]  at rs2  says simp only [destruct_join.aux, destruct_append] at rs2
       exact
         let ⟨k1, rs3, ek⟩ := of_results_think rs2
         let ⟨o', m1, n1, rs4, rs5, ek1⟩ := of_results_bind rs3
@@ -1623,7 +1623,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
             apply mem_bind mt
             exact mb
         | some (a, s'), some (b, t'), ⟨ab, st'⟩, _, rs5, mt => by
-          simp at rs5
+          simp?  at rs5  says simp only [destruct_append.aux] at rs5
           refine' ⟨some (b, append t' (join T')), _, _⟩
           · simp (config := { unfoldPartialApp := true }) [destruct_join]
             apply mem_bind mT
chore: Replace (· op ·) a by (a op ·) (#8843)

I used the regex \(\(· (.) ·\) (.)\), replacing with ($2 $1 ·).

Diff
@@ -1305,7 +1305,7 @@ theorem toList'_map (l : List α) (s : WSeq α) :
       match Seq.destruct s with
       | none => Sum.inl l.reverse
       | some (none, s') => Sum.inr (l, s')
-      | some (some a, s') => Sum.inr (a::l, s')) (l, s) = (· ++ ·) l.reverse <$> toList s := by
+      | some (some a, s') => Sum.inr (a :: l, s')) (l, s) = (l.reverse ++ ·) <$> toList s := by
   refine'
     Computation.eq_of_bisim
       (fun c1 c2 =>
@@ -1315,7 +1315,7 @@ theorem toList'_map (l : List α) (s : WSeq α) :
             | none => Sum.inl l.reverse
             | some (none, s') => Sum.inr (l, s')
             | some (some a, s') => Sum.inr (a::l, s')) (l' ++ l, s) ∧
-            c2 = Computation.map ((· ++ ·) l.reverse) (Computation.corec (fun ⟨l, s⟩ =>
+            c2 = Computation.map (l.reverse ++ ·) (Computation.corec (fun ⟨l, s⟩ =>
               match Seq.destruct s with
               | none => Sum.inl l.reverse
               | some (none, s') => Sum.inr (l, s')
chore: space after (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -721,7 +721,7 @@ theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by
   | zero => simp [drop]
   | succ n n_ih =>
     -- Porting note: Was `simp [*, drop]`.
-    simp [drop, ←n_ih]
+    simp [drop, ← n_ih]
 #align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons
 
 @[simp]
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -1616,7 +1616,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
             apply Nat.lt_succ_of_le (Nat.le_add_right _ _)
           let ⟨ob, mb, rob⟩ := IH _ this ST' rs5'
           refine' ⟨ob, _, rob⟩
-          · simp [destruct_join]
+          · simp (config := { unfoldPartialApp := true }) [destruct_join]
             apply mem_bind mT
             simp only [destruct_append, destruct_append.aux]
             apply think_mem
@@ -1625,7 +1625,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
         | some (a, s'), some (b, t'), ⟨ab, st'⟩, _, rs5, mt => by
           simp at rs5
           refine' ⟨some (b, append t' (join T')), _, _⟩
-          · simp [destruct_join]
+          · simp (config := { unfoldPartialApp := true }) [destruct_join]
             apply mem_bind mT
             simp only [destruct_append, destruct_append.aux]
             apply think_mem
@@ -1697,7 +1697,8 @@ theorem join_map_ret (s : WSeq α) : join (map ret s) ~ʷ s := by
             (map (fun a => cons a nil) s).join.destruct =
               (map (fun a => cons a nil) s').join.destruct ∧ destruct s = s'.destruct :=
           fun s => ⟨s, rfl, rfl⟩
-        induction' s using WSeq.recOn with a s s <;> simp [ret, ret_mem, this, Option.exists]
+        induction' s using WSeq.recOn with a s s <;>
+          simp (config := { unfoldPartialApp := true }) [ret, ret_mem, this, Option.exists]
   · exact ⟨s, rfl, rfl⟩
 #align stream.wseq.join_map_ret Stream'.WSeq.join_map_ret
 
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
@@ -881,10 +881,10 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
    fun {n} h => by
     cases e : Computation.get (get? s (n + 1))
     · assumption
-    have := mem_of_get_eq _ e
+    have := Computation.mem_of_get_eq _ e
     simp [get?] at this h
     cases' head_some_of_head_tail_some this with a' h'
-    have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
+    have := mem_unique h' (@Computation.mem_of_get_eq _ _ _ _ h)
     contradiction⟩
 #align stream.wseq.to_seq Stream'.WSeq.toSeq
 
@@ -966,7 +966,7 @@ theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s :=
 #align stream.wseq.mem_cons Stream'.WSeq.mem_cons
 
 theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s := by
-  intro h; have := h; cases' h with n e; revert s; simp [Stream'.nth]
+  intro h; have := h; cases' h with n e; revert s; simp [Stream'.get]
   induction' n with n IH <;> intro s <;> induction' s using WSeq.recOn with x s s <;>
     simp <;> intro m e <;>
     injections
chore: remove nonterminal simp (#7580)

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

Diff
@@ -755,14 +755,14 @@ theorem join_nil : join nil = (nil : WSeq α) :=
 
 @[simp]
 theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) := by
-  simp [think, join]
+  simp only [join, think]
   dsimp only [(· <$> ·)]
   simp [join, Seq1.ret]
 #align stream.wseq.join_think Stream'.WSeq.join_think
 
 @[simp]
 theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) := by
-  simp [think, join]
+  simp only [join, think]
   dsimp only [(· <$> ·)]
   simp [join, cons, append]
 #align stream.wseq.join_cons Stream'.WSeq.join_cons
@@ -800,7 +800,7 @@ def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α))
 #align stream.wseq.tail.aux Stream'.WSeq.tail.aux
 
 theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.aux := by
-  simp [tail]; rw [← bind_pure_comp, LawfulMonad.bind_assoc]
+  simp only [tail, destruct_flatten, tail.aux]; rw [← bind_pure_comp, LawfulMonad.bind_assoc]
   apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp
 #align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail
 
@@ -1014,7 +1014,7 @@ theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ g
   · intro s' h
     cases' h with n h
     exists n
-    simp [get?]
+    simp only [get?, dropn_think, head_think]
     apply think_mem h
 #align stream.wseq.exists_nth_of_mem Stream'.WSeq.exists_get?_of_mem
 
@@ -1564,7 +1564,7 @@ theorem liftRel_append (R : α → β → Prop) {s1 s2 : WSeq α} {t1 t2 : WSeq
       intro a b; apply LiftRelO.imp_right
       intro s t; apply Or.inl
     | _, _, Or.inr ⟨s1, t1, rfl, rfl, h⟩ => by
-      simp [destruct_append]
+      simp only [LiftRelO, exists_and_left, destruct_append, destruct_append.aux]
       apply Computation.liftRel_bind _ _ (liftRel_destruct h)
       intro o p h
       cases' o with a <;> cases' p with b
@@ -1618,7 +1618,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
           refine' ⟨ob, _, rob⟩
           · simp [destruct_join]
             apply mem_bind mT
-            simp [destruct_append]
+            simp only [destruct_append, destruct_append.aux]
             apply think_mem
             apply mem_bind mt
             exact mb
@@ -1627,7 +1627,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
           refine' ⟨some (b, append t' (join T')), _, _⟩
           · simp [destruct_join]
             apply mem_bind mT
-            simp [destruct_append]
+            simp only [destruct_append, destruct_append.aux]
             apply think_mem
             apply mem_bind mt
             apply ret_mem
@@ -1795,7 +1795,7 @@ theorem join_join (SS : WSeq (WSeq (WSeq α))) : join (join SS) ~ʷ join (map jo
 @[simp]
 theorem bind_assoc (s : WSeq α) (f : α → WSeq β) (g : β → WSeq γ) :
     bind (bind s f) g ~ʷ bind s fun x : α => bind (f x) g := by
-  simp [bind]; erw [← map_comp f (map g), map_comp (map g ∘ f) join]
+  simp only [bind, map_join]; erw [← map_comp f (map g), map_comp (map g ∘ f) join]
   apply join_join
 #align stream.wseq.bind_assoc Stream'.WSeq.bind_assoc
 
chore: tidy various files (#7041)
Diff
@@ -572,10 +572,10 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
   have h2 := liftRel_destruct h2
   refine'
     Computation.liftRel_def.2
-      ⟨(Computation.terminates_of_LiftRel h1).trans (Computation.terminates_of_LiftRel h2),
+      ⟨(Computation.terminates_of_liftRel h1).trans (Computation.terminates_of_liftRel h2),
         fun {a c} ha hc => _⟩
   rcases h1.left ha with ⟨b, hb, t1⟩
-  have t2 := Computation.rel_of_LiftRel h2 hb hc
+  have t2 := Computation.rel_of_liftRel h2 hb hc
   cases' a with a <;> cases' c with c
   · trivial
   · cases b
@@ -1597,7 +1597,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
   intro S T ST a ra; simp [destruct_join] at ra
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
-    let ⟨p, mT, rop⟩ := Computation.exists_of_LiftRel_left (liftRel_destruct ST) rs1.mem
+    let ⟨p, mT, rop⟩ := Computation.exists_of_liftRel_left (liftRel_destruct ST) rs1.mem
     match o, p, rop, rs1, rs2, mT with
     | none, none, _, _, rs2, mT => by
       simp only [destruct_join]
@@ -1607,7 +1607,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
       exact
         let ⟨k1, rs3, ek⟩ := of_results_think rs2
         let ⟨o', m1, n1, rs4, rs5, ek1⟩ := of_results_bind rs3
-        let ⟨p', mt, rop'⟩ := Computation.exists_of_LiftRel_left (liftRel_destruct st) rs4.mem
+        let ⟨p', mt, rop'⟩ := Computation.exists_of_liftRel_left (liftRel_destruct st) rs4.mem
         match o', p', rop', rs4, rs5, mt with
         | none, none, _, _, rs5', mt => by
           have : n1 < n := by
@@ -1687,7 +1687,7 @@ theorem join_ret (s : WSeq α) : join (ret s) ~ʷ s := by simp [ret]; apply thin
 theorem join_map_ret (s : WSeq α) : join (map ret s) ~ʷ s := by
   refine' ⟨fun s1 s2 => join (map ret s2) = s1, rfl, _⟩
   intro s' s h; rw [← h]
-  apply lift_rel_rec fun c1 c2 => ∃ s, c1 = destruct (join (map ret s)) ∧ c2 = destruct s
+  apply liftRel_rec fun c1 c2 => ∃ s, c1 = destruct (join (map ret s)) ∧ c2 = destruct s
   · exact fun {c1 c2} h =>
       match c1, c2, h with
       | _, _, ⟨s, rfl, rfl⟩ => by
@@ -1709,7 +1709,7 @@ theorem join_append (S T : WSeq (WSeq α)) : join (append S T) ~ʷ append (join
       ⟨nil, S, T, by simp, by simp⟩, _⟩
   intro s1 s2 h
   apply
-    lift_rel_rec
+    liftRel_rec
       (fun c1 c2 =>
         ∃ (s : WSeq α) (S T : _),
           c1 = destruct (append s (join (append S T))) ∧
@@ -1768,7 +1768,7 @@ theorem join_join (SS : WSeq (WSeq (WSeq α))) : join (join SS) ~ʷ join (map jo
       ⟨nil, nil, SS, by simp, by simp⟩, _⟩
   intro s1 s2 h
   apply
-    lift_rel_rec
+    liftRel_rec
       (fun c1 c2 =>
         ∃ s S SS,
           c1 = destruct (append s (join (append S (join SS)))) ∧
chore: tidy various files (#7009)
Diff
@@ -839,10 +839,10 @@ theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (h
 
 theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) :
     ∃ a', some a' ∈ destruct s := by
-  unfold tail Functor.map at h; simp at h
+  unfold tail Functor.map at h; simp only [destruct_flatten] at h
   rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
   rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
-  cases' t' with t' <;> rw [← ht2] at td <;> simp at td
+  cases' t' with t' <;> rw [← ht2] at td <;> simp only [destruct_nil] at td
   · have := mem_unique td (ret_mem _)
     contradiction
   · exact ⟨_, ht'⟩
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,15 +2,12 @@
 Copyright (c) 2017 Microsoft Corporation. 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.wseq
-! 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.Seq.Seq
 
+#align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
 /-!
 # Partially defined possibly infinite lists
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

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

Diff
@@ -1720,7 +1720,7 @@ theorem join_append (S T : WSeq (WSeq α)) : join (append S T) ~ʷ append (join
       _ _ _
       (let ⟨s, S, T, h1, h2⟩ := h
       ⟨s, S, T, congr_arg destruct h1, congr_arg destruct h2⟩)
-  rintro c1 c2  ⟨s, S, T, rfl, rfl⟩
+  rintro c1 c2 ⟨s, S, T, rfl, rfl⟩
   induction' s using WSeq.recOn with a s s <;> simp
   · induction' S using WSeq.recOn with s S S <;> simp
     · induction' T using WSeq.recOn with s T T <;> simp
chore: remove a few superfluous semicolons (#5880)

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

Diff
@@ -893,8 +893,8 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
 
 theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
     Terminates (get? s n) → Terminates (get? s m) := by
-  induction' h with m' _ IH <;> [exact id;
-    exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
+  induction' h with m' _ IH
+  exacts [id, fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
 #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le
 
 theorem head_terminates_of_get?_terminates {s : WSeq α} {n} :
@@ -1442,8 +1442,8 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
   intro ss h; apply mem_rec_on h <;> [intro b ss o; intro ss IH] <;> intro s S
   · induction' s using WSeq.recOn with b' s s <;>
       [induction' S using WSeq.recOn with s S S; skip; skip] <;>
-      intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;> simp at this;
-      try cases this; try contradiction
+      intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;>
+      simp at this; try cases this; try contradiction
     substs b' ss
     simp at m ⊢
     cases' o with e IH
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
@@ -1445,7 +1445,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;> simp at this;
       try cases this; try contradiction
     substs b' ss
-    simp at m⊢
+    simp at m ⊢
     cases' o with e IH
     · simp [e]
     cases' m with e m
@@ -1466,7 +1466,7 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
       simp at m
       rcases (IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
-    · simp at m IH⊢
+    · simp at m IH ⊢
       apply IH _ _ rfl m
 #align stream.wseq.exists_of_mem_join Stream'.WSeq.exists_of_mem_join
 
chore: formatting issues (#4947)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -1817,10 +1817,10 @@ instance monad : Monad WSeq where
   this type of construction.
 
 instance lawfulMonad : LawfulMonad WSeq :=
-{ id_map := @map_id,
-  bind_pure_comp := @bind_ret,
-  pure_bind := @ret_bind,
-  bind_assoc := @bind_assoc }
+  { id_map := @map_id,
+    bind_pure_comp := @bind_ret,
+    pure_bind := @ret_bind,
+    bind_assoc := @bind_assoc }
 -/
 end WSeq
 
chore: fix typos (#4518)

I ran codespell Mathlib and got tired halfway through the suggestions.

Diff
@@ -795,7 +795,7 @@ theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (appen
   Seq.append_assoc _ _ _
 #align stream.wseq.append_assoc Stream'.WSeq.append_assoc
 
-/-- auxilary defintion of tail over weak sequences-/
+/-- auxiliary definition of tail over weak sequences-/
 @[simp]
 def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | none => Computation.pure none
@@ -807,7 +807,7 @@ theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.au
   apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp
 #align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail
 
-/-- auxilary defintion of drop over weak sequences-/
+/-- auxiliary definition of drop over weak sequences-/
 @[simp]
 def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | 0 => Computation.pure
@@ -1513,7 +1513,7 @@ theorem map_congr (f : α → β) {s t : WSeq α} (h : s ~ʷ t) : map f s ~ʷ ma
   liftRel_map _ _ h fun {_ _} => congr_arg _
 #align stream.wseq.map_congr Stream'.WSeq.map_congr
 
-/-- auxilary defintion of `destruct_append` over weak sequences-/
+/-- auxiliary definition of `destruct_append` over weak sequences-/
 @[simp]
 def destruct_append.aux (t : WSeq α) : Option (α × WSeq α) → Computation (Option (α × WSeq α))
   | none => destruct t
@@ -1534,7 +1534,7 @@ theorem destruct_append (s t : WSeq α) :
   · exact ⟨s, t, rfl, rfl⟩
 #align stream.wseq.destruct_append Stream'.WSeq.destruct_append
 
-/-- auxilary defintion of `destruct_join` over weak sequences-/
+/-- auxiliary definition of `destruct_join` over weak sequences-/
 @[simp]
 def destruct_join.aux : Option (WSeq α × WSeq (WSeq α)) → Computation (Option (α × WSeq α))
   | none => Computation.pure none
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
@@ -548,8 +548,8 @@ theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (Lif
 theorem LiftRelO.swap (R : α → β → Prop) (C) :
     swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by
   funext x y
-  cases' x with x <;> [skip, cases x] <;>
-    · cases' y with y <;> [skip, cases y] <;> rfl
+  cases' x with x <;> [skip; cases x] <;>
+    (cases' y with y <;> [skip; cases y] <;> rfl)
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
 
 theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) :
@@ -855,7 +855,7 @@ theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail
     ∃ a', some a' ∈ head s := by
   unfold head at h
   rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
-  cases' o with o <;> [injection e, injection e with h']; clear h'
+  cases' o with o <;> [injection e; injection e with h']; clear h'
   cases' destruct_some_of_destruct_tail_some md with a am
   exact ⟨_, Computation.mem_map (@Prod.fst α (WSeq α) <$> ·) am⟩
 #align stream.wseq.head_some_of_head_tail_some Stream'.WSeq.head_some_of_head_tail_some
@@ -893,7 +893,7 @@ def toSeq (s : WSeq α) [Productive s] : Seq α :=
 
 theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
     Terminates (get? s n) → Terminates (get? s m) := by
-  induction' h with m' _ IH <;> [exact id,
+  induction' h with m' _ IH <;> [exact id;
     exact fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
 #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le
 
@@ -936,7 +936,7 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
     some (a', s') ∈ destruct s → (a ∈ s ↔ a = a' ∨ a ∈ s') := by
   generalize e : destruct s = c; intro h
   revert s
-  apply Computation.memRecOn h <;> [skip, intro c IH] <;> intro s <;>
+  apply Computation.memRecOn h <;> [skip; intro c IH] <;> intro s <;>
     induction' s using WSeq.recOn with x s s <;>
     intro m <;>
     have := congr_arg Computation.destruct m <;>
@@ -1439,9 +1439,9 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
     ∀ ss : WSeq α,
       a ∈ ss → ∀ s S, append s (join S) = ss → a ∈ append s (join S) → a ∈ s ∨ ∃ s, s ∈ S ∧ a ∈ s
     from fun S h => (this _ h nil S (by simp) (by simp [h])).resolve_left (not_mem_nil _)
-  intro ss h; apply mem_rec_on h <;> [intro b ss o, intro ss IH] <;> intro s S
+  intro ss h; apply mem_rec_on h <;> [intro b ss o; intro ss IH] <;> intro s S
   · induction' s using WSeq.recOn with b' s s <;>
-      [induction' S using WSeq.recOn with s S S, skip, skip] <;>
+      [induction' S using WSeq.recOn with s S S; skip; skip] <;>
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;> simp at this;
       try cases this; try contradiction
     substs b' ss
@@ -1452,19 +1452,19 @@ theorem exists_of_mem_join {a : α} : ∀ {S : WSeq (WSeq α)}, a ∈ join S →
     · simp [e]
     exact Or.imp_left Or.inr (IH _ _ rfl m)
   · induction' s using WSeq.recOn with b' s s <;>
-      [induction' S using WSeq.recOn with s S S, skip, skip] <;>
+      [induction' S using WSeq.recOn with s S S; skip; skip] <;>
       intro ej m <;> simp at ej <;> have := congr_arg Seq.destruct ej <;> simp at this <;>
       try { try { have := this.1 }; contradiction } <;> subst ss
     · apply Or.inr
       -- Porting note: `exists_eq_or_imp` should be excluded.
-      simp [-exists_eq_or_imp] at m⊢
+      simp [-exists_eq_or_imp] at m ⊢
       cases' IH s S rfl m with as ex
       · exact ⟨s, Or.inl rfl, as⟩
       · rcases ex with ⟨s', sS, as⟩
         exact ⟨s', Or.inr sS, as⟩
     · apply Or.inr
       simp at m
-      rcases(IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
+      rcases (IH nil S (by simp) (by simp [m])).resolve_left (not_mem_nil _) with ⟨s, sS, as⟩
       exact ⟨s, by simp [sS], as⟩
     · simp at m IH⊢
       apply IH _ _ rfl m
chore: tidy various files (#3848)
Diff
@@ -468,7 +468,7 @@ theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β 
   LiftRelO.imp (fun _ _ => id) H
 #align stream.wseq.lift_rel_o.imp_right Stream'.WSeq.LiftRelO.imp_right
 
-/-- Definitino of bisimilarity for weak sequences-/
+/-- Definition of bisimilarity for weak sequences-/
 @[simp]
 def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop :=
   LiftRelO (· = ·) R
@@ -535,13 +535,20 @@ theorem destruct_congr_iff {s t : WSeq α} :
 
 theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s => by
   refine' ⟨(· = ·), rfl, fun {s t} (h : s = t) => _⟩
-  rw [← h]; apply Computation.LiftRel.refl
-  intro a; cases' a with a; simp; cases a; simp; apply H
+  rw [← h]
+  apply Computation.LiftRel.refl
+  intro a
+  cases' a with a
+  · simp
+  · cases a
+    simp only [LiftRelO, and_true]
+    apply H
 #align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl
 
 theorem LiftRelO.swap (R : α → β → Prop) (C) :
     swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by
-  funext x y; cases' x with x <;> [skip, cases x] <;>
+  funext x y
+  cases' x with x <;> [skip, cases x] <;>
     · cases' y with y <;> [skip, cases y] <;> rfl
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
 
@@ -557,10 +564,7 @@ theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap
 #align stream.wseq.lift_rel.swap Stream'.WSeq.LiftRel.swap
 
 theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
-  fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by
-  rwa [LiftRel.swap,
-    show Function.swap R = R from funext fun a =>
-      funext fun b => propext <| by constructor <;> apply H] at h
+  fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by rwa [LiftRel.swap, H.swap_eq] at h
 #align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm
 
 theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) :=
@@ -858,10 +862,11 @@ theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail
 
 theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) :
     ∃ a', some a' ∈ head s := by
-  revert a; induction' n with n IH <;> intro a h
-  exacts [⟨_, h⟩,
-    let ⟨a', h'⟩ := head_some_of_head_tail_some h
-    IH h']
+  induction n generalizing a with
+  | zero => exact ⟨_, h⟩
+  | succ n IH =>
+      let ⟨a', h'⟩ := head_some_of_head_tail_some h
+      exact IH h'
 #align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some
 
 instance productive_tail (s : WSeq α) [Productive s] : Productive (tail s) :=
@@ -875,10 +880,13 @@ instance productive_dropn (s : WSeq α) [Productive s] (n) : Productive (drop s
 /-- Given a productive weak sequence, we can collapse all the `think`s to
   produce a sequence. -/
 def toSeq (s : WSeq α) [Productive s] : Seq α :=
-  ⟨fun n => (get? s n).get, fun {n} h => by
-    cases e : Computation.get (get? s (n + 1)); · assumption
+  ⟨fun n => (get? s n).get,
+   fun {n} h => by
+    cases e : Computation.get (get? s (n + 1))
+    · assumption
     have := mem_of_get_eq _ e
-    simp [get?] at this h; cases' head_some_of_head_tail_some this with a' h'
+    simp [get?] at this h
+    cases' head_some_of_head_tail_some this with a' h'
     have := mem_unique h' (@mem_of_get_eq _ _ _ _ h)
     contradiction⟩
 #align stream.wseq.to_seq Stream'.WSeq.toSeq
@@ -932,12 +940,11 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
     induction' s using WSeq.recOn with x s s <;>
     intro m <;>
     have := congr_arg Computation.destruct m <;>
-    simp at this <;>
-    [cases' this with i1 i2, skip]
-  · rw [i1, i2]
+    simp at this
+  · cases' this with i1 i2
+    rw [i1, i2]
     cases' s' with f al
     dsimp only [cons, (· ∈ ·), WSeq.Mem, Seq.Mem, Seq.cons]
-    simp
     have h_a_eq_a' : a = a' ↔ some (some a) = some (some a') := by simp
     rw [h_a_eq_a']
     refine' ⟨Stream'.eq_or_mem_of_mem_cons, fun o => _⟩
@@ -945,8 +952,7 @@ theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} :
       · rw [e]
         apply Stream'.mem_cons
       · exact Stream'.mem_cons_of_mem _ m
-  · simp
-    exact IH this
+  · simp [IH this]
 #align stream.wseq.eq_or_mem_iff_mem Stream'.WSeq.eq_or_mem_iff_mem
 
 @[simp]
@@ -986,7 +992,9 @@ theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s := by
     --               `Computation.exists_of_mem_map`.
     dsimp only [get?, head] at h
     rcases Computation.exists_of_mem_map h with ⟨o, h1, h2⟩
-    cases' o with o <;> [injection h2, injection h2 with h']
+    cases' o with o
+    · injection h2
+    injection h2 with h'
     cases' o with a' s'
     exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm)
   · have := @IH (tail s)
@@ -1019,16 +1027,20 @@ theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) :
   ⟨n, by
     rcases (head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩
     have := Computation.mem_unique (Computation.mem_map _ om) h
-    cases' o with o <;> [injection this, injection this with i]
-    cases' o with a' s'; dsimp at i
-    rw [i] at om; exact ⟨_, om⟩⟩
+    cases' o with o
+    · injection this
+    injection this with i
+    cases' o with a' s'
+    dsimp at i
+    rw [i] at om
+    exact ⟨_, om⟩⟩
 #align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem
 
 theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t) :
     ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n))
   | 0 => liftRel_destruct H
   | n + 1 => by
-    simp [destruct_tail, drop]
+    simp only [LiftRelO, drop, Nat.add_eq, add_zero, destruct_tail, tail.aux]
     apply liftRel_bind
     apply liftRel_dropn_destruct H n
     exact fun {a b} o =>
@@ -1070,7 +1082,9 @@ theorem mem_append_left {s₁ s₂ : WSeq α} {a : α} : a ∈ s₁ → a ∈ ap
 theorem exists_of_mem_map {f} {b : β} : ∀ {s : WSeq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b
   | ⟨g, al⟩, h => by
     let ⟨o, om, oe⟩ := Seq.exists_of_mem_map h
-    cases' o with a <;> [injection oe, injection oe with h']
+    cases' o with a
+    · injection oe
+    injection oe with h'
     exact ⟨a, om, h'⟩
 #align stream.wseq.exists_of_mem_map Stream'.WSeq.exists_of_mem_map
 
@@ -1133,8 +1147,7 @@ theorem head_congr : ∀ {s t : WSeq α}, s ~ʷ t → head s ~ head t := by
 
 theorem flatten_equiv {c : Computation (WSeq α)} {s} (h : s ∈ c) : flatten c ~ʷ s := by
   apply Computation.memRecOn h
-  · simp
-    rfl
+  · simp [Equiv.refl]
   · intro s'
     apply Equiv.trans
     simp [think_equiv]
@@ -1335,9 +1348,11 @@ theorem toList_ofList (l : List α) : l ∈ toList (ofList l) := by
 theorem destruct_ofSeq (s : Seq α) :
     destruct (ofSeq s) = Computation.pure (s.head.map fun a => (a, ofSeq s.tail)) :=
   destruct_eq_pure <| by
-    simp [ofSeq, head, destruct, Seq.destruct, Seq.head]
+    simp only [destruct, Seq.destruct, Option.map_eq_map, ofSeq, Computation.corec_eq, rmap,
+      Seq.head]
     rw [show Seq.get? (some <$> s) 0 = some <$> Seq.get? s 0 by apply Seq.map_get?]
-    cases' Seq.get? s 0 with a; · rfl
+    cases' Seq.get? s 0 with a
+    · rfl
     dsimp only [(· <$> ·)]
     simp [destruct]
 #align stream.wseq.destruct_of_seq Stream'.WSeq.destruct_ofSeq
@@ -1533,7 +1548,7 @@ theorem destruct_join (S : WSeq (WSeq α)) :
       (fun c1 c2 =>
         c1 = c2 ∨ ∃ S, c1 = destruct (join S) ∧ c2 = (destruct S).bind destruct_join.aux)
       _ (Or.inr ⟨S, rfl, rfl⟩)
-  intro c1 c2 h;
+  intro c1 c2 h
   exact
     match c1, c2, h with
     | c, _, Or.inl <| rfl => by cases c.destruct <;> simp
@@ -1582,7 +1597,7 @@ theorem liftRel_join.lem (R : α → β → Prop) {S T} {U : WSeq α → WSeq β
     {a} (ma : a ∈ destruct (join S)) : ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b := by
   cases' exists_results_of_mem ma with n h; clear ma; revert S T ST a
   induction' n using Nat.strongInductionOn with n IH
-  intro S T ST a ra; simp [destruct_join] at ra;
+  intro S T ST a ra; simp [destruct_join] at ra
   exact
     let ⟨o, m, k, rs1, rs2, en⟩ := of_results_bind ra
     let ⟨p, mT, rop⟩ := Computation.exists_of_LiftRel_left (liftRel_destruct ST) rs1.mem
@@ -1705,20 +1720,16 @@ theorem join_append (S T : WSeq (WSeq α)) : join (append S T) ~ʷ append (join
       _ _ _
       (let ⟨s, S, T, h1, h2⟩ := h
       ⟨s, S, T, congr_arg destruct h1, congr_arg destruct h2⟩)
-  intro c1 c2 h
-  exact
-    match c1, c2, h with
-    | _, _, ⟨s, S, T, rfl, rfl⟩ => by
-      clear h
-      induction' s using WSeq.recOn with a s s <;> simp
-      · induction' S using WSeq.recOn with s S S <;> simp
-        · induction' T using WSeq.recOn with s T T <;> simp
-          · refine' ⟨s, nil, T, _, _⟩ <;> simp
-          · refine' ⟨nil, nil, T, _, _⟩ <;> simp
-        · exact ⟨s, S, T, rfl, rfl⟩
-        · refine' ⟨nil, S, T, _, _⟩ <;> simp
-      · exact ⟨s, S, T, rfl, rfl⟩
-      · exact ⟨s, S, T, rfl, rfl⟩
+  rintro c1 c2  ⟨s, S, T, rfl, rfl⟩
+  induction' s using WSeq.recOn with a s s <;> simp
+  · induction' S using WSeq.recOn with s S S <;> simp
+    · induction' T using WSeq.recOn with s T T <;> simp
+      · refine' ⟨s, nil, T, _, _⟩ <;> simp
+      · refine' ⟨nil, nil, T, _, _⟩ <;> simp
+    · exact ⟨s, S, T, rfl, rfl⟩
+    · refine' ⟨nil, S, T, _, _⟩ <;> simp
+  · exact ⟨s, S, T, rfl, rfl⟩
+  · exact ⟨s, S, T, rfl, rfl⟩
 #align stream.wseq.join_append Stream'.WSeq.join_append
 
 @[simp]
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
@@ -539,8 +539,8 @@ theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (Lif
   intro a; cases' a with a; simp; cases a; simp; apply H
 #align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl
 
-theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) :=
-  by
+theorem LiftRelO.swap (R : α → β → Prop) (C) :
+    swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by
   funext x y; cases' x with x <;> [skip, cases x] <;>
     · cases' y with y <;> [skip, cases y] <;> rfl
 #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
feat: port Data.Seq.WSeq (#3405)

This PR also make Option.recOn computable.

Co-authored-by: Pol_tta <52843868+Komyyy@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Dependencies 2 + 76

77 files ported (97.5%)
40854 lines ported (99.4%)
Show graph

The unported dependencies are