Documentation

Mathlib.Data.Seq.Seq

Possibly infinite lists #

This file provides a Seq α type representing possibly infinite lists (referred here as sequences). It is encoded as an infinite stream of options such that if f n = none, then f m = none for all m ≥ n.

def Stream'.IsSeq {α : Type u} (s : Stream' (Option α)) :

A stream s : Option α is a sequence if s.get n = none implies s.get (n + 1) = none.

Equations
  • s.IsSeq = ∀ {n : }, s n = nones (n + 1) = none
Instances For
    def Stream'.Seq (α : Type u) :

    Seq α is the type of possibly infinite lists (referred here as sequences). It is encoded as an infinite stream of options such that if f n = none, then f m = none for all m ≥ n.

    Equations
    Instances For
      def Stream'.Seq1 (α : Type u_1) :
      Type u_1

      Seq1 α is the type of nonempty sequences.

      Equations
      Instances For

        The empty sequence

        Equations
        Instances For
          Equations
          • Stream'.Seq.instInhabited = { default := Stream'.Seq.nil }
          def Stream'.Seq.cons {α : Type u} (a : α) (s : Stream'.Seq α) :

          Prepend an element to a sequence

          Equations
          Instances For
            @[simp]
            theorem Stream'.Seq.val_cons {α : Type u} (s : Stream'.Seq α) (x : α) :
            def Stream'.Seq.get? {α : Type u} :
            Stream'.Seq αOption α

            Get the nth element of a sequence (if it exists)

            Equations
            • Stream'.Seq.get? = Subtype.val
            Instances For
              @[simp]
              theorem Stream'.Seq.get?_mk {α : Type u} (f : Stream' (Option α)) (hf : f.IsSeq) :
              Stream'.Seq.get? f, hf = f
              @[simp]
              theorem Stream'.Seq.get?_nil {α : Type u} (n : ) :
              Stream'.Seq.nil.get? n = none
              @[simp]
              theorem Stream'.Seq.get?_cons_zero {α : Type u} (a : α) (s : Stream'.Seq α) :
              (Stream'.Seq.cons a s).get? 0 = some a
              @[simp]
              theorem Stream'.Seq.get?_cons_succ {α : Type u} (a : α) (s : Stream'.Seq α) (n : ) :
              (Stream'.Seq.cons a s).get? (n + 1) = s.get? n
              theorem Stream'.Seq.ext {α : Type u} {s t : Stream'.Seq α} (h : ∀ (n : ), s.get? n = t.get? n) :
              s = t
              def Stream'.Seq.TerminatedAt {α : Type u} (s : Stream'.Seq α) (n : ) :

              A sequence has terminated at position n if the value at position n equals none.

              Equations
              • s.TerminatedAt n = (s.get? n = none)
              Instances For
                instance Stream'.Seq.terminatedAtDecidable {α : Type u} (s : Stream'.Seq α) (n : ) :
                Decidable (s.TerminatedAt n)

                It is decidable whether a sequence terminates at a given position.

                Equations

                A sequence terminates if there is some position n at which it has terminated.

                Equations
                • s.Terminates = ∃ (n : ), s.TerminatedAt n
                Instances For
                  theorem Stream'.Seq.not_terminates_iff {α : Type u} {s : Stream'.Seq α} :
                  ¬s.Terminates ∀ (n : ), (s.get? n).isSome = true
                  def Stream'.Seq.omap {α : Type u} {β : Type v} {γ : Type w} (f : βγ) :
                  Option (α × β)Option (α × γ)

                  Functorial action of the functor Option (α × _)

                  Equations
                  Instances For
                    def Stream'.Seq.head {α : Type u} (s : Stream'.Seq α) :

                    Get the first element of a sequence

                    Equations
                    • s.head = s.get? 0
                    Instances For
                      def Stream'.Seq.tail {α : Type u} (s : Stream'.Seq α) :

                      Get the tail of a sequence (or nil if the sequence is nil)

                      Equations
                      • s.tail = (↑s).tail,
                      Instances For
                        def Stream'.Seq.Mem {α : Type u} (s : Stream'.Seq α) (a : α) :

                        member definition for Seq

                        Equations
                        Instances For
                          Equations
                          • Stream'.Seq.instMembership = { mem := Stream'.Seq.Mem }
                          theorem Stream'.Seq.le_stable {α : Type u} (s : Stream'.Seq α) {m n : } (h : m n) :
                          s.get? m = nones.get? n = none
                          theorem Stream'.Seq.terminated_stable {α : Type u} (s : Stream'.Seq α) {m n : } :
                          m ns.TerminatedAt ms.TerminatedAt n

                          If a sequence terminated at position n, it also terminated at m ≥ n.

                          theorem Stream'.Seq.ge_stable {α : Type u} (s : Stream'.Seq α) {aₙ : α} {n m : } (m_le_n : m n) (s_nth_eq_some : s.get? n = some aₙ) :
                          ∃ (aₘ : α), s.get? m = some aₘ

                          If s.get? n = some aₙ for some value aₙ, then there is also some value aₘ such that s.get? = some aₘ for m ≤ n.

                          theorem Stream'.Seq.not_mem_nil {α : Type u} (a : α) :
                          ¬a Stream'.Seq.nil
                          theorem Stream'.Seq.mem_cons {α : Type u} (a : α) (s : Stream'.Seq α) :
                          theorem Stream'.Seq.mem_cons_of_mem {α : Type u} (y : α) {a : α} {s : Stream'.Seq α} :
                          a sa Stream'.Seq.cons y s
                          theorem Stream'.Seq.eq_or_mem_of_mem_cons {α : Type u} {a b : α} {s : Stream'.Seq α} :
                          a Stream'.Seq.cons b sa = b a s
                          @[simp]
                          theorem Stream'.Seq.mem_cons_iff {α : Type u} {a b : α} {s : Stream'.Seq α} :

                          Destructor for a sequence, resulting in either none (for nil) or some (a, s) (for cons a s).

                          Equations
                          • s.destruct = (fun (a' : α) => (a', s.tail)) <$> s.get? 0
                          Instances For
                            theorem Stream'.Seq.destruct_eq_nil {α : Type u} {s : Stream'.Seq α} :
                            s.destruct = nones = Stream'.Seq.nil
                            theorem Stream'.Seq.destruct_eq_cons {α : Type u} {s : Stream'.Seq α} {a : α} {s' : Stream'.Seq α} :
                            s.destruct = some (a, s')s = Stream'.Seq.cons a s'
                            @[simp]
                            theorem Stream'.Seq.destruct_nil {α : Type u} :
                            Stream'.Seq.nil.destruct = none
                            @[simp]
                            theorem Stream'.Seq.destruct_cons {α : Type u} (a : α) (s : Stream'.Seq α) :
                            (Stream'.Seq.cons a s).destruct = some (a, s)
                            theorem Stream'.Seq.head_eq_destruct {α : Type u} (s : Stream'.Seq α) :
                            s.head = Prod.fst <$> s.destruct
                            @[simp]
                            theorem Stream'.Seq.head_nil {α : Type u} :
                            Stream'.Seq.nil.head = none
                            @[simp]
                            theorem Stream'.Seq.head_cons {α : Type u} (a : α) (s : Stream'.Seq α) :
                            (Stream'.Seq.cons a s).head = some a
                            @[simp]
                            theorem Stream'.Seq.tail_nil {α : Type u} :
                            Stream'.Seq.nil.tail = Stream'.Seq.nil
                            @[simp]
                            theorem Stream'.Seq.tail_cons {α : Type u} (a : α) (s : Stream'.Seq α) :
                            (Stream'.Seq.cons a s).tail = s
                            @[simp]
                            theorem Stream'.Seq.get?_tail {α : Type u} (s : Stream'.Seq α) (n : ) :
                            s.tail.get? n = s.get? (n + 1)
                            def Stream'.Seq.recOn {α : Type u} {C : Stream'.Seq αSort v} (s : Stream'.Seq α) (h1 : C Stream'.Seq.nil) (h2 : (x : α) → (s : Stream'.Seq α) → C (Stream'.Seq.cons x s)) :
                            C s

                            Recursion principle for sequences, compare with List.recOn.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem Stream'.Seq.mem_rec_on {α : Type u} {C : Stream'.Seq αProp} {a : α} {s : Stream'.Seq α} (M : a s) (h1 : ∀ (b : α) (s' : Stream'.Seq α), a = b C s'C (Stream'.Seq.cons b s')) :
                              C s
                              def Stream'.Seq.Corec.f {α : Type u} {β : Type v} (f : βOption (α × β)) :
                              Option βOption α × Option β

                              Corecursor over pairs of Option values

                              Equations
                              Instances For
                                def Stream'.Seq.corec {α : Type u} {β : Type v} (f : βOption (α × β)) (b : β) :

                                Corecursor for Seq α as a coinductive type. Iterates f to produce new elements of the sequence until none is obtained.

                                Equations
                                Instances For
                                  @[simp]
                                  theorem Stream'.Seq.corec_eq {α : Type u} {β : Type v} (f : βOption (α × β)) (b : β) :
                                  def Stream'.Seq.BisimO {α : Type u} (R : Stream'.Seq αStream'.Seq αProp) :

                                  Bisimilarity relation over Option of Seq1 α

                                  Equations
                                  Instances For

                                    a relation is bisimilar if it meets the BisimO test

                                    Equations
                                    Instances For
                                      theorem Stream'.Seq.eq_of_bisim {α : Type u} (R : Stream'.Seq αStream'.Seq αProp) (bisim : Stream'.Seq.IsBisimulation R) {s₁ s₂ : Stream'.Seq α} (r : R s₁ s₂) :
                                      s₁ = s₂
                                      theorem Stream'.Seq.coinduction {α : Type u} {s₁ s₂ : Stream'.Seq α} :
                                      s₁.head = s₂.head(∀ (β : Type u) (fr : Stream'.Seq αβ), fr s₁ = fr s₂fr s₁.tail = fr s₂.tail)s₁ = s₂
                                      theorem Stream'.Seq.coinduction2 {α : Type u} {β : Type v} (s : Stream'.Seq α) (f g : Stream'.Seq αStream'.Seq β) (H : ∀ (s : Stream'.Seq α), Stream'.Seq.BisimO (fun (s1 s2 : Stream'.Seq β) => ∃ (s : Stream'.Seq α), s1 = f s s2 = g s) (f s).destruct (g s).destruct) :
                                      f s = g s
                                      def Stream'.Seq.ofList {α : Type u} (l : List α) :

                                      Embed a list as a sequence

                                      Equations
                                      • l = l.get?,
                                      Instances For
                                        instance Stream'.Seq.coeList {α : Type u} :
                                        Coe (List α) (Stream'.Seq α)
                                        Equations
                                        • Stream'.Seq.coeList = { coe := Stream'.Seq.ofList }
                                        @[simp]
                                        theorem Stream'.Seq.ofList_nil {α : Type u} :
                                        [] = Stream'.Seq.nil
                                        @[simp]
                                        theorem Stream'.Seq.ofList_get {α : Type u} (l : List α) (n : ) :
                                        (↑l).get? n = l.get? n
                                        @[simp]
                                        theorem Stream'.Seq.ofList_cons {α : Type u} (a : α) (l : List α) :
                                        (a :: l) = Stream'.Seq.cons a l
                                        theorem Stream'.Seq.ofList_injective {α : Type u} :
                                        Function.Injective Stream'.Seq.ofList
                                        def Stream'.Seq.ofStream {α : Type u} (s : Stream' α) :

                                        Embed an infinite stream as a sequence

                                        Equations
                                        Instances For
                                          instance Stream'.Seq.coeStream {α : Type u} :
                                          Equations
                                          • Stream'.Seq.coeStream = { coe := Stream'.Seq.ofStream }

                                          Embed a MLList α as a sequence. Note that even though this is non-meta, it will produce infinite sequences if used with cyclic MLLists created by meta constructions.

                                          Equations
                                          Instances For
                                            @[deprecated Stream'.Seq.ofMLList]

                                            Alias of Stream'.Seq.ofMLList.


                                            Embed a MLList α as a sequence. Note that even though this is non-meta, it will produce infinite sequences if used with cyclic MLLists created by meta constructions.

                                            Equations
                                            Instances For
                                              instance Stream'.Seq.coeMLList {α : Type u} :
                                              Equations
                                              • Stream'.Seq.coeMLList = { coe := Stream'.Seq.ofMLList }
                                              @[deprecated Stream'.Seq.coeMLList]

                                              Alias of Stream'.Seq.coeMLList.

                                              Equations
                                              Instances For
                                                unsafe def Stream'.Seq.toMLList {α : Type u} :

                                                Translate a sequence into a MLList.

                                                Equations
                                                • x✝.toMLList = match x✝.destruct with | none => MLList.nil | some (a, s') => MLList.cons a s'.toMLList
                                                Instances For
                                                  @[deprecated Stream'.Seq.toMLList]
                                                  unsafe def Stream'.Seq.toLazyList {α : Type u} :

                                                  Alias of Stream'.Seq.toMLList.


                                                  Translate a sequence into a MLList.

                                                  Equations
                                                  Instances For
                                                    unsafe def Stream'.Seq.forceToList {α : Type u} (s : Stream'.Seq α) :
                                                    List α

                                                    Translate a sequence to a list. This function will run forever if run on an infinite sequence.

                                                    Equations
                                                    • s.forceToList = s.toMLList.force
                                                    Instances For

                                                      The sequence of natural numbers some 0, some 1, ...

                                                      Equations
                                                      Instances For
                                                        @[simp]
                                                        def Stream'.Seq.append {α : Type u} (s₁ s₂ : Stream'.Seq α) :

                                                        Append two sequences. If s₁ is infinite, then s₁ ++ s₂ = s₁, otherwise it puts s₂ at the location of the nil in s₁.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          def Stream'.Seq.map {α : Type u} {β : Type v} (f : αβ) :

                                                          Map a function over a sequence.

                                                          Equations
                                                          Instances For

                                                            Flatten a sequence of sequences. (It is required that the sequences be nonempty to ensure productivity; in the case of an infinite sequence of nil, the first element is never generated.)

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              def Stream'.Seq.drop {α : Type u} (s : Stream'.Seq α) :

                                                              Remove the first n elements from the sequence.

                                                              Equations
                                                              • s.drop 0 = s
                                                              • s.drop n.succ = (s.drop n).tail
                                                              Instances For
                                                                def Stream'.Seq.take {α : Type u} :
                                                                Stream'.Seq αList α

                                                                Take the first n elements of the sequence (producing a list)

                                                                Equations
                                                                Instances For
                                                                  def Stream'.Seq.splitAt {α : Type u} :
                                                                  Stream'.Seq αList α × Stream'.Seq α

                                                                  Split a sequence at n, producing a finite initial segment and an infinite tail.

                                                                  Equations
                                                                  Instances For
                                                                    def Stream'.Seq.zipWith {α : Type u} {β : Type v} {γ : Type w} (f : αβγ) (s₁ : Stream'.Seq α) (s₂ : Stream'.Seq β) :

                                                                    Combine two sequences with a function

                                                                    Equations
                                                                    Instances For
                                                                      @[simp]
                                                                      theorem Stream'.Seq.get?_zipWith {α : Type u} {β : Type v} {γ : Type w} (f : αβγ) (s : Stream'.Seq α) (s' : Stream'.Seq β) (n : ) :
                                                                      (Stream'.Seq.zipWith f s s').get? n = Option.map₂ f (s.get? n) (s'.get? n)
                                                                      def Stream'.Seq.zip {α : Type u} {β : Type v} :
                                                                      Stream'.Seq αStream'.Seq βStream'.Seq (α × β)

                                                                      Pair two sequences into a sequence of pairs

                                                                      Equations
                                                                      Instances For
                                                                        theorem Stream'.Seq.get?_zip {α : Type u} {β : Type v} (s : Stream'.Seq α) (t : Stream'.Seq β) (n : ) :
                                                                        (s.zip t).get? n = Option.map₂ Prod.mk (s.get? n) (t.get? n)
                                                                        def Stream'.Seq.unzip {α : Type u} {β : Type v} (s : Stream'.Seq (α × β)) :

                                                                        Separate a sequence of pairs into two sequences

                                                                        Equations
                                                                        Instances For
                                                                          def Stream'.Seq.enum {α : Type u} (s : Stream'.Seq α) :

                                                                          Enumerate a sequence by tagging each element with its index.

                                                                          Equations
                                                                          Instances For
                                                                            @[simp]
                                                                            theorem Stream'.Seq.get?_enum {α : Type u} (s : Stream'.Seq α) (n : ) :
                                                                            s.enum.get? n = Option.map (Prod.mk n) (s.get? n)
                                                                            @[simp]
                                                                            theorem Stream'.Seq.enum_nil {α : Type u} :
                                                                            Stream'.Seq.nil.enum = Stream'.Seq.nil
                                                                            def Stream'.Seq.length {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) :

                                                                            The length of a terminating sequence.

                                                                            Equations
                                                                            Instances For
                                                                              def Stream'.Seq.toList {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) :
                                                                              List α

                                                                              Convert a sequence which is known to terminate into a list

                                                                              Equations
                                                                              Instances For
                                                                                def Stream'.Seq.toStream {α : Type u} (s : Stream'.Seq α) (h : ¬s.Terminates) :

                                                                                Convert a sequence which is known not to terminate into a stream

                                                                                Equations
                                                                                • s.toStream h n = (s.get? n).get
                                                                                Instances For
                                                                                  def Stream'.Seq.toListOrStream {α : Type u} (s : Stream'.Seq α) [Decidable s.Terminates] :

                                                                                  Convert a sequence into either a list or a stream depending on whether it is finite or infinite. (Without decidability of the infiniteness predicate, this is not constructively possible.)

                                                                                  Equations
                                                                                  • s.toListOrStream = if h : s.Terminates then Sum.inl (s.toList h) else Sum.inr (s.toStream h)
                                                                                  Instances For
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.nil_append {α : Type u} (s : Stream'.Seq α) :
                                                                                    Stream'.Seq.nil.append s = s
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.getElem?_take {α : Type u} (n k : ) (s : Stream'.Seq α) :
                                                                                    (Stream'.Seq.take k s)[n]? = if n < k then s.get? n else none
                                                                                    theorem Stream'.Seq.terminatedAt_ofList {α : Type u} (l : List α) :
                                                                                    (↑l).TerminatedAt l.length
                                                                                    theorem Stream'.Seq.terminates_ofList {α : Type u} (l : List α) :
                                                                                    (↑l).Terminates
                                                                                    theorem Stream'.Seq.terminatedAt_nil {α : Type u} :
                                                                                    Stream'.Seq.nil.TerminatedAt 0
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.terminates_nil {α : Type u} :
                                                                                    Stream'.Seq.nil.Terminates
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.length_nil {α : Type u} :
                                                                                    Stream'.Seq.nil.length = 0
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.get?_zero_eq_none {α : Type u} {s : Stream'.Seq α} :
                                                                                    s.get? 0 = none s = Stream'.Seq.nil
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.length_eq_zero {α : Type u} {s : Stream'.Seq α} {h : s.Terminates} :
                                                                                    s.length h = 0 s = Stream'.Seq.nil
                                                                                    theorem Stream'.Seq.terminatedAt_zero_iff {α : Type u} {s : Stream'.Seq α} :
                                                                                    s.TerminatedAt 0 s = Stream'.Seq.nil
                                                                                    theorem Stream'.Seq.length_le_iff' {α : Type u} {s : Stream'.Seq α} {n : } :
                                                                                    (∃ (h : s.Terminates), s.length h n) s.TerminatedAt n

                                                                                    The statement of length_le_iff' does not assume that the sequence terminates. For a simpler statement of the theorem where the sequence is known to terminate see length_le_iff

                                                                                    theorem Stream'.Seq.length_le_iff {α : Type u} {s : Stream'.Seq α} {n : } {h : s.Terminates} :
                                                                                    s.length h n s.TerminatedAt n

                                                                                    The statement of length_le_iff assumes that the sequence terminates. For a statement of the where the sequence is not known to terminate see length_le_iff'

                                                                                    theorem Stream'.Seq.lt_length_iff' {α : Type u} {s : Stream'.Seq α} {n : } :
                                                                                    (∀ (h : s.Terminates), n < s.length h) ∃ (a : α), a s.get? n

                                                                                    The statement of lt_length_iff' does not assume that the sequence terminates. For a simpler statement of the theorem where the sequence is known to terminate see lt_length_iff

                                                                                    theorem Stream'.Seq.lt_length_iff {α : Type u} {s : Stream'.Seq α} {n : } {h : s.Terminates} :
                                                                                    n < s.length h ∃ (a : α), a s.get? n

                                                                                    The statement of length_le_iff assumes that the sequence terminates. For a statement of the where the sequence is not known to terminate see length_le_iff'

                                                                                    theorem Stream'.Seq.length_take_of_le_length {α : Type u} {s : Stream'.Seq α} {n : } (hle : ∀ (h : s.Terminates), n s.length h) :
                                                                                    (Stream'.Seq.take n s).length = n
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.length_toList {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) :
                                                                                    (s.toList h).length = s.length h
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.getElem?_toList {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) (n : ) :
                                                                                    (s.toList h)[n]? = s.get? n
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.ofList_toList {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) :
                                                                                    (s.toList h) = s
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.toList_ofList {α : Type u} (l : List α) :
                                                                                    (↑l).toList = l
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.toList_nil {α : Type u} :
                                                                                    Stream'.Seq.nil.toList = []
                                                                                    theorem Stream'.Seq.getLast?_toList {α : Type u} (s : Stream'.Seq α) (h : s.Terminates) :
                                                                                    (s.toList h).getLast? = s.get? (s.length h - 1)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.cons_append {α : Type u} (a : α) (s t : Stream'.Seq α) :
                                                                                    (Stream'.Seq.cons a s).append t = Stream'.Seq.cons a (s.append t)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.append_nil {α : Type u} (s : Stream'.Seq α) :
                                                                                    s.append Stream'.Seq.nil = s
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.append_assoc {α : Type u} (s t u : Stream'.Seq α) :
                                                                                    (s.append t).append u = s.append (t.append u)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_nil {α : Type u} {β : Type v} (f : αβ) :
                                                                                    Stream'.Seq.map f Stream'.Seq.nil = Stream'.Seq.nil
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_cons {α : Type u} {β : Type v} (f : αβ) (a : α) (s : Stream'.Seq α) :
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_id {α : Type u} (s : Stream'.Seq α) :
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_tail {α : Type u} {β : Type v} (f : αβ) (s : Stream'.Seq α) :
                                                                                    Stream'.Seq.map f s.tail = (Stream'.Seq.map f s).tail
                                                                                    theorem Stream'.Seq.map_comp {α : Type u} {β : Type v} {γ : Type w} (f : αβ) (g : βγ) (s : Stream'.Seq α) :
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_append {α : Type u} {β : Type v} (f : αβ) (s t : Stream'.Seq α) :
                                                                                    Stream'.Seq.map f (s.append t) = (Stream'.Seq.map f s).append (Stream'.Seq.map f t)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.map_get? {α : Type u} {β : Type v} (f : αβ) (s : Stream'.Seq α) (n : ) :
                                                                                    (Stream'.Seq.map f s).get? n = Option.map f (s.get? n)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.terminatedAt_map_iff {α : Type u} {β : Type v} {f : αβ} {s : Stream'.Seq α} {n : } :
                                                                                    (Stream'.Seq.map f s).TerminatedAt n s.TerminatedAt n
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.terminates_map_iff {α : Type u} {β : Type v} {f : αβ} {s : Stream'.Seq α} :
                                                                                    (Stream'.Seq.map f s).Terminates s.Terminates
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.length_map {α : Type u} {β : Type v} {s : Stream'.Seq α} {f : αβ} (h : (Stream'.Seq.map f s).Terminates) :
                                                                                    (Stream'.Seq.map f s).length h = s.length
                                                                                    Equations
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.join_nil {α : Type u} :
                                                                                    Stream'.Seq.nil.join = Stream'.Seq.nil
                                                                                    theorem Stream'.Seq.join_cons_nil {α : Type u} (a : α) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                    (Stream'.Seq.cons (a, Stream'.Seq.nil) S).join = Stream'.Seq.cons a S.join
                                                                                    theorem Stream'.Seq.join_cons_cons {α : Type u} (a b : α) (s : Stream'.Seq α) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.join_cons {α : Type u} (a : α) (s : Stream'.Seq α) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                    (Stream'.Seq.cons (a, s) S).join = Stream'.Seq.cons a (s.append S.join)
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.join_append {α : Type u} (S T : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                    (S.append T).join = S.join.append T.join
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.ofStream_cons {α : Type u} (a : α) (s : Stream' α) :
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.ofList_append {α : Type u} (l l' : List α) :
                                                                                    (l ++ l') = (↑l).append l'
                                                                                    @[simp]
                                                                                    theorem Stream'.Seq.ofStream_append {α : Type u} (l : List α) (s : Stream' α) :
                                                                                    (l ++ₛ s) = (↑l).append s
                                                                                    def Stream'.Seq.toList' {α : Type u_1} (s : Stream'.Seq α) :

                                                                                    Convert a sequence into a list, embedded in a computation to allow for the possibility of infinite sequences (in which case the computation never returns anything).

                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      theorem Stream'.Seq.dropn_add {α : Type u} (s : Stream'.Seq α) (m n : ) :
                                                                                      s.drop (m + n) = (s.drop m).drop n
                                                                                      theorem Stream'.Seq.dropn_tail {α : Type u} (s : Stream'.Seq α) (n : ) :
                                                                                      s.tail.drop n = s.drop (n + 1)
                                                                                      @[simp]
                                                                                      theorem Stream'.Seq.head_dropn {α : Type u} (s : Stream'.Seq α) (n : ) :
                                                                                      (s.drop n).head = s.get? n
                                                                                      theorem Stream'.Seq.mem_map {α : Type u} {β : Type v} (f : αβ) {a : α} {s : Stream'.Seq α} :
                                                                                      a sf a Stream'.Seq.map f s
                                                                                      theorem Stream'.Seq.exists_of_mem_map {α : Type u} {β : Type v} {f : αβ} {b : β} {s : Stream'.Seq α} :
                                                                                      b Stream'.Seq.map f s∃ (a : α), a s f a = b
                                                                                      theorem Stream'.Seq.of_mem_append {α : Type u} {s₁ s₂ : Stream'.Seq α} {a : α} (h : a s₁.append s₂) :
                                                                                      a s₁ a s₂
                                                                                      theorem Stream'.Seq.mem_append_left {α : Type u} {s₁ s₂ : Stream'.Seq α} {a : α} (h : a s₁) :
                                                                                      a s₁.append s₂
                                                                                      @[simp]
                                                                                      theorem Stream'.Seq.enum_cons {α : Type u} (s : Stream'.Seq α) (x : α) :

                                                                                      Convert a Seq1 to a sequence.

                                                                                      Equations
                                                                                      Instances For
                                                                                        instance Stream'.Seq1.coeSeq {α : Type u} :
                                                                                        Equations
                                                                                        • Stream'.Seq1.coeSeq = { coe := Stream'.Seq1.toSeq }
                                                                                        def Stream'.Seq1.map {α : Type u} {β : Type v} (f : αβ) :

                                                                                        Map a function on a Seq1

                                                                                        Equations
                                                                                        Instances For
                                                                                          theorem Stream'.Seq1.map_pair {α : Type u} {β : Type v} {f : αβ} {a : α} {s : Stream'.Seq α} :
                                                                                          Stream'.Seq1.map f (a, s) = (f a, Stream'.Seq.map f s)

                                                                                          Flatten a nonempty sequence of nonempty sequences

                                                                                          Equations
                                                                                          Instances For
                                                                                            @[simp]
                                                                                            theorem Stream'.Seq1.join_nil {α : Type u} (a : α) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                            Stream'.Seq1.join ((a, Stream'.Seq.nil), S) = (a, S.join)
                                                                                            @[simp]
                                                                                            theorem Stream'.Seq1.join_cons {α : Type u} (a b : α) (s : Stream'.Seq α) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                            Stream'.Seq1.join ((a, Stream'.Seq.cons b s), S) = (a, (Stream'.Seq.cons (b, s) S).join)
                                                                                            def Stream'.Seq1.ret {α : Type u} (a : α) :

                                                                                            The return operator for the Seq1 monad, which produces a singleton sequence.

                                                                                            Equations
                                                                                            Instances For
                                                                                              Equations
                                                                                              def Stream'.Seq1.bind {α : Type u} {β : Type v} (s : Stream'.Seq1 α) (f : αStream'.Seq1 β) :

                                                                                              The bind operator for the Seq1 monad, which maps f on each element of s and appends the results together. (Not all of s may be evaluated, because the first few elements of s may already produce an infinite result.)

                                                                                              Equations
                                                                                              Instances For
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.join_map_ret {α : Type u} (s : Stream'.Seq α) :
                                                                                                (Stream'.Seq.map Stream'.Seq1.ret s).join = s
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.bind_ret {α : Type u} {β : Type v} (f : αβ) (s : Stream'.Seq1 α) :
                                                                                                s.bind (Stream'.Seq1.ret f) = Stream'.Seq1.map f s
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.ret_bind {α : Type u} {β : Type v} (a : α) (f : αStream'.Seq1 β) :
                                                                                                (Stream'.Seq1.ret a).bind f = f a
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.map_join' {α : Type u} {β : Type v} (f : αβ) (S : Stream'.Seq (Stream'.Seq1 α)) :
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.map_join {α : Type u} {β : Type v} (f : αβ) (S : Stream'.Seq1 (Stream'.Seq1 α)) :
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.join_join {α : Type u} (SS : Stream'.Seq (Stream'.Seq1 (Stream'.Seq1 α))) :
                                                                                                SS.join.join = (Stream'.Seq.map Stream'.Seq1.join SS).join
                                                                                                @[simp]
                                                                                                theorem Stream'.Seq1.bind_assoc {α : Type u} {β : Type v} {γ : Type w} (s : Stream'.Seq1 α) (f : αStream'.Seq1 β) (g : βStream'.Seq1 γ) :
                                                                                                (s.bind f).bind g = s.bind fun (x : α) => (f x).bind g