Documentation

Mathlib.Data.Seq.WSeq

Partially defined possibly infinite lists #

This file provides a WSeq α type representing partially defined possibly infinite lists (referred here as weak sequences).

def Stream'.WSeq (α : Type u_1) :
Type u_1

Weak sequences.

While the Seq structure allows for lists which may not be finite, a weak sequence also allows the computation of each element to involve an indeterminate amount of computation, including possibly an infinite loop. This is represented as a regular Seq interspersed with none elements to indicate that computation is ongoing.

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.

Equations
Instances For

    Turn a sequence into a weak sequence

    Equations
    Instances For
      def Stream'.WSeq.ofList {α : Type u} (l : List α) :

      Turn a list into a weak sequence

      Equations
      • l = l
      Instances For

        Turn a stream into a weak sequence

        Equations
        • l = l
        Instances For
          instance Stream'.WSeq.coeSeq {α : Type u} :
          Equations
          • Stream'.WSeq.coeSeq = { coe := Stream'.WSeq.ofSeq }
          instance Stream'.WSeq.coeList {α : Type u} :
          Equations
          • Stream'.WSeq.coeList = { coe := Stream'.WSeq.ofList }
          instance Stream'.WSeq.coeStream {α : Type u} :
          Equations
          • Stream'.WSeq.coeStream = { coe := Stream'.WSeq.ofStream }

          The empty weak sequence

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

            Prepend an element to a weak sequence

            Equations
            Instances For

              Compute for one tick, without producing any elements

              Equations
              Instances For

                Destruct a weak sequence, to (eventually possibly) produce either none for nil or some (a, s) if an element is produced.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Stream'.WSeq.recOn {α : Type u} {C : Stream'.WSeq αSort v} (s : Stream'.WSeq α) (h1 : C Stream'.WSeq.nil) (h2 : (x : α) → (s : Stream'.WSeq α) → C (Stream'.WSeq.cons x s)) (h3 : (s : Stream'.WSeq α) → C (Stream'.WSeq.think s)) :
                  C s

                  Recursion principle for weak sequences, compare with List.recOn.

                  Equations
                  Instances For
                    def Stream'.WSeq.Mem {α : Type u} (a : α) (s : Stream'.WSeq α) :

                    membership for weak sequences

                    Equations
                    Instances For
                      Equations
                      • Stream'.WSeq.membership = { mem := Stream'.WSeq.Mem }
                      theorem Stream'.WSeq.not_mem_nil {α : Type u} (a : α) :
                      ¬a Stream'.WSeq.nil

                      Get the head of a weak sequence. This involves a possibly infinite computation.

                      Equations
                      Instances For

                        Encode a computation yielding a weak sequence into additional think constructors in a weak sequence

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          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.

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

                            drop the first n elements from s.

                            Equations
                            Instances For
                              def Stream'.WSeq.get? {α : Type u} (s : Stream'.WSeq α) (n : ) :

                              Get the nth element of s.

                              Equations
                              Instances For

                                Convert s to a list (if it is finite and completes in finite time).

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Get the length of s (if it is finite and completes in finite time).

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

                                    A weak sequence is finite if toList s terminates. Equivalently, it is a finite number of think and cons applied to nil.

                                    Instances

                                      Get the list corresponding to a finite weak sequence.

                                      Equations
                                      Instances For

                                        A weak sequence is productive if it never stalls forever - there are always a finite number of thinks between cons constructors. The sequence itself is allowed to be infinite though.

                                        Instances
                                          def Stream'.WSeq.updateNth {α : Type u} (s : Stream'.WSeq α) (n : ) (a : α) :

                                          Replace the nth element of s with a.

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

                                            Remove the nth element of s.

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

                                              Map the elements of s over f, removing any values that yield none.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                def Stream'.WSeq.filter {α : Type u} (p : αProp) [DecidablePred p] :

                                                Select the elements of s that satisfy p.

                                                Equations
                                                Instances For
                                                  def Stream'.WSeq.find {α : Type u} (p : αProp) [DecidablePred p] (s : Stream'.WSeq α) :

                                                  Get the first element of s satisfying p.

                                                  Equations
                                                  Instances For
                                                    def Stream'.WSeq.zipWith {α : Type u} {β : Type v} {γ : Type w} (f : αβγ) (s1 : Stream'.WSeq α) (s2 : Stream'.WSeq β) :

                                                    Zip a function over two weak sequences

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

                                                      Zip two weak sequences into a single sequence of pairs

                                                      Equations
                                                      Instances For

                                                        Get the list of indexes of elements of s satisfying p

                                                        Equations
                                                        Instances For
                                                          def Stream'.WSeq.findIndex {α : Type u} (p : αProp) [DecidablePred p] (s : Stream'.WSeq α) :

                                                          Get the index of the first element of s satisfying p

                                                          Equations
                                                          Instances For

                                                            Get the index of the first occurrence of a in s

                                                            Equations
                                                            Instances For

                                                              Get the indexes of occurrences of a in s

                                                              Equations
                                                              Instances For
                                                                def Stream'.WSeq.union {α : Type u} (s1 : Stream'.WSeq α) (s2 : Stream'.WSeq α) :

                                                                union s1 s2 is a weak sequence which interleaves s1 and s2 in some order (nondeterministically).

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For

                                                                  Returns true if s is nil and false if s has an element

                                                                  Equations
                                                                  Instances For

                                                                    Calculate one step of computation

                                                                    Equations
                                                                    Instances For
                                                                      def Stream'.WSeq.take {α : Type u} (s : Stream'.WSeq α) (n : ) :

                                                                      Get the first n elements of a weak sequence

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        Split the sequence at position n into a finite initial segment and the weak sequence tail

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

                                                                          Returns true if any element of s satisfies p

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

                                                                            Returns true if every element of s satisfies p

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

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

                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For

                                                                                Get the weak sequence of initial segments of the input sequence

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

                                                                                  Like take, but does not wait for a result. Calculates n steps of computation and returns the sequence computed so far

                                                                                  Equations
                                                                                  Instances For

                                                                                    Append two weak sequences. As with Seq.append, this may not use the second sequence if the first one takes forever to compute

                                                                                    Equations
                                                                                    • Stream'.WSeq.append = Stream'.Seq.append
                                                                                    Instances For
                                                                                      def Stream'.WSeq.map {α : Type u} {β : Type v} (f : αβ) :

                                                                                      Map a function over a weak sequence

                                                                                      Equations
                                                                                      Instances For

                                                                                        Flatten a sequence of weak sequences. (Note that this allows empty sequences, unlike Seq.join.)

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

                                                                                          Monadic bind operator for weak sequences

                                                                                          Equations
                                                                                          Instances For
                                                                                            def Stream'.WSeq.LiftRelO {α : Type u} {β : Type v} (R : αβProp) (C : Stream'.WSeq αStream'.WSeq βProp) :
                                                                                            Option (α × Stream'.WSeq α)Option (β × Stream'.WSeq β)Prop

                                                                                            lift a relation to a relation over weak sequences

                                                                                            Equations
                                                                                            Instances For
                                                                                              theorem Stream'.WSeq.LiftRelO.imp {α : Type u} {β : Type v} {R : αβProp} {S : αβProp} {C : Stream'.WSeq αStream'.WSeq βProp} {D : Stream'.WSeq αStream'.WSeq βProp} (H1 : ∀ (a : α) (b : β), R a bS a b) (H2 : ∀ (s : Stream'.WSeq α) (t : Stream'.WSeq β), C s tD s t) {o : Option (α × Stream'.WSeq α)} {p : Option (β × Stream'.WSeq β)} :
                                                                                              theorem Stream'.WSeq.LiftRelO.imp_right {α : Type u} {β : Type v} (R : αβProp) {C : Stream'.WSeq αStream'.WSeq βProp} {D : Stream'.WSeq αStream'.WSeq βProp} (H : ∀ (s : Stream'.WSeq α) (t : Stream'.WSeq β), C s tD s t) {o : Option (α × Stream'.WSeq α)} {p : Option (β × Stream'.WSeq β)} :
                                                                                              def Stream'.WSeq.BisimO {α : Type u} (R : Stream'.WSeq αStream'.WSeq αProp) :
                                                                                              Option (α × Stream'.WSeq α)Option (α × Stream'.WSeq α)Prop

                                                                                              Definition of bisimilarity for weak sequences

                                                                                              Equations
                                                                                              Instances For
                                                                                                theorem Stream'.WSeq.BisimO.imp {α : Type u} {R : Stream'.WSeq αStream'.WSeq αProp} {S : Stream'.WSeq αStream'.WSeq αProp} (H : ∀ (s t : Stream'.WSeq α), R s tS s t) {o : Option (α × Stream'.WSeq α)} {p : Option (α × Stream'.WSeq α)} :
                                                                                                def Stream'.WSeq.LiftRel {α : Type u} {β : Type v} (R : αβProp) (s : Stream'.WSeq α) (t : Stream'.WSeq β) :

                                                                                                Two weak sequences are LiftRel R related if they are either both empty, or they are both nonempty and the heads are R related and the tails are LiftRel R related. (This is a coinductive definition.)

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For

                                                                                                  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 thinks needed to arrive at the answer.

                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      theorem Stream'.WSeq.LiftRel.refl {α : Type u} (R : ααProp) (H : Reflexive R) :
                                                                                                      theorem Stream'.WSeq.LiftRel.swap_lem {α : Type u} {β : Type v} {R : αβProp} {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq β} (h : Stream'.WSeq.LiftRel R s1 s2) :
                                                                                                      theorem Stream'.WSeq.LiftRel.symm {α : Type u} (R : ααProp) (H : Symmetric R) :
                                                                                                      theorem Stream'.WSeq.LiftRel.trans {α : Type u} (R : ααProp) (H : Transitive R) :
                                                                                                      theorem Stream'.WSeq.Equiv.refl {α : Type u} (s : Stream'.WSeq α) :
                                                                                                      s s
                                                                                                      theorem Stream'.WSeq.Equiv.symm {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} :
                                                                                                      s tt s
                                                                                                      theorem Stream'.WSeq.Equiv.trans {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} {u : Stream'.WSeq α} :
                                                                                                      s tt us u
                                                                                                      theorem Stream'.WSeq.Equiv.equivalence {α : Type u} :
                                                                                                      Equivalence Stream'.WSeq.Equiv
                                                                                                      @[simp]
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.seq_destruct_nil {α : Type u} :
                                                                                                      Stream'.Seq.destruct Stream'.WSeq.nil = none
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.head_nil {α : Type u} :
                                                                                                      Stream'.WSeq.head Stream'.WSeq.nil = Computation.pure none
                                                                                                      @[simp]
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.tail_nil {α : Type u} :
                                                                                                      Stream'.WSeq.tail Stream'.WSeq.nil = Stream'.WSeq.nil
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.tail_cons {α : Type u} (a : α) (s : Stream'.WSeq α) :
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.dropn_nil {α : Type u} (n : ) :
                                                                                                      Stream'.WSeq.drop Stream'.WSeq.nil n = Stream'.WSeq.nil
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.dropn_cons {α : Type u} (a : α) (s : Stream'.WSeq α) (n : ) :
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.join_nil {α : Type u} :
                                                                                                      Stream'.WSeq.join Stream'.WSeq.nil = Stream'.WSeq.nil
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.nil_append {α : Type u} (s : Stream'.WSeq α) :
                                                                                                      Stream'.WSeq.append Stream'.WSeq.nil s = s
                                                                                                      @[simp]
                                                                                                      theorem Stream'.WSeq.append_nil {α : Type u} (s : Stream'.WSeq α) :
                                                                                                      Stream'.WSeq.append s Stream'.WSeq.nil = s

                                                                                                      auxiliary definition of tail over weak sequences

                                                                                                      Equations
                                                                                                      Instances For

                                                                                                        auxiliary definition of drop over weak sequences

                                                                                                        Equations
                                                                                                        Instances For
                                                                                                          theorem Stream'.WSeq.head_some_of_get?_some {α : Type u} {s : Stream'.WSeq α} {a : α} {n : } (h : some a Stream'.WSeq.get? s n) :
                                                                                                          ∃ (a' : α), some a' Stream'.WSeq.head s

                                                                                                          Given a productive weak sequence, we can collapse all the thinks to produce a sequence.

                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            theorem Stream'.WSeq.mem_rec_on {α : Type u} {C : Stream'.WSeq αProp} {a : α} {s : Stream'.WSeq α} (M : a s) (h1 : ∀ (b : α) (s' : Stream'.WSeq α), a = b C s'C (Stream'.WSeq.cons b s')) (h2 : ∀ (s : Stream'.WSeq α), C sC (Stream'.WSeq.think s)) :
                                                                                                            C s
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.mem_think {α : Type u} (s : Stream'.WSeq α) (a : α) :
                                                                                                            theorem Stream'.WSeq.eq_or_mem_iff_mem {α : Type u} {s : Stream'.WSeq α} {a : α} {a' : α} {s' : Stream'.WSeq α} :
                                                                                                            some (a', s') Stream'.WSeq.destruct s(a s a = a' a s')
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.mem_cons_iff {α : Type u} (s : Stream'.WSeq α) (b : α) {a : α} :
                                                                                                            theorem Stream'.WSeq.mem_cons_of_mem {α : Type u} {s : Stream'.WSeq α} (b : α) {a : α} (h : a s) :
                                                                                                            theorem Stream'.WSeq.mem_cons {α : Type u} (s : Stream'.WSeq α) (a : α) :
                                                                                                            theorem Stream'.WSeq.mem_of_mem_tail {α : Type u} {s : Stream'.WSeq α} {a : α} :
                                                                                                            theorem Stream'.WSeq.mem_of_mem_dropn {α : Type u} {s : Stream'.WSeq α} {a : α} {n : } :
                                                                                                            a Stream'.WSeq.drop s na s
                                                                                                            theorem Stream'.WSeq.get?_mem {α : Type u} {s : Stream'.WSeq α} {a : α} {n : } :
                                                                                                            theorem Stream'.WSeq.exists_get?_of_mem {α : Type u} {s : Stream'.WSeq α} {a : α} (h : a s) :
                                                                                                            ∃ (n : ), some a Stream'.WSeq.get? s n
                                                                                                            theorem Stream'.WSeq.exists_dropn_of_mem {α : Type u} {s : Stream'.WSeq α} {a : α} (h : a s) :
                                                                                                            ∃ (n : ), ∃ (s' : Stream'.WSeq α), some (a, s') Stream'.WSeq.destruct (Stream'.WSeq.drop s n)
                                                                                                            theorem Stream'.WSeq.exists_of_liftRel_left {α : Type u} {β : Type v} {R : αβProp} {s : Stream'.WSeq α} {t : Stream'.WSeq β} (H : Stream'.WSeq.LiftRel R s t) {a : α} (h : a s) :
                                                                                                            ∃ (b : β), b t R a b
                                                                                                            theorem Stream'.WSeq.exists_of_liftRel_right {α : Type u} {β : Type v} {R : αβProp} {s : Stream'.WSeq α} {t : Stream'.WSeq β} (H : Stream'.WSeq.LiftRel R s t) {b : β} (h : b t) :
                                                                                                            ∃ (a : α), a s R a b
                                                                                                            theorem Stream'.WSeq.of_mem_append {α : Type u} {s₁ : Stream'.WSeq α} {s₂ : Stream'.WSeq α} {a : α} :
                                                                                                            a Stream'.WSeq.append s₁ s₂a s₁ a s₂
                                                                                                            theorem Stream'.WSeq.mem_append_left {α : Type u} {s₁ : Stream'.WSeq α} {s₂ : Stream'.WSeq α} {a : α} :
                                                                                                            a s₁a Stream'.WSeq.append s₁ s₂
                                                                                                            theorem Stream'.WSeq.exists_of_mem_map {α : Type u} {β : Type v} {f : αβ} {b : β} {s : Stream'.WSeq α} :
                                                                                                            b Stream'.WSeq.map f s∃ (a : α), a s f a = b
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.liftRel_nil {α : Type u} {β : Type v} (R : αβProp) :
                                                                                                            Stream'.WSeq.LiftRel R Stream'.WSeq.nil Stream'.WSeq.nil
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.liftRel_cons {α : Type u} {β : Type v} (R : αβProp) (a : α) (b : β) (s : Stream'.WSeq α) (t : Stream'.WSeq β) :
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.liftRel_think_left {α : Type u} {β : Type v} (R : αβProp) (s : Stream'.WSeq α) (t : Stream'.WSeq β) :
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.liftRel_think_right {α : Type u} {β : Type v} (R : αβProp) (s : Stream'.WSeq α) (t : Stream'.WSeq β) :
                                                                                                            theorem Stream'.WSeq.cons_congr {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} (a : α) (h : s t) :
                                                                                                            theorem Stream'.WSeq.dropn_congr {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} (h : s t) (n : ) :
                                                                                                            theorem Stream'.WSeq.mem_congr {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} (h : s t) (a : α) :
                                                                                                            a s a t
                                                                                                            theorem Stream'.WSeq.Equiv.ext {α : Type u} {s : Stream'.WSeq α} {t : Stream'.WSeq α} (h : ∀ (n : ), Computation.Equiv (Stream'.WSeq.get? s n) (Stream'.WSeq.get? t n)) :
                                                                                                            s t
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.ofList_nil {α : Type u} :
                                                                                                            [] = Stream'.WSeq.nil
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.ofList_cons {α : Type u} (a : α) (l : List α) :
                                                                                                            (a :: l) = Stream'.WSeq.cons a l
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.toList'_nil {α : Type u} (l : List α) :
                                                                                                            Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, Stream'.WSeq.nil) = Computation.pure (List.reverse l)
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.toList'_cons {α : Type u} (l : List α) (s : Stream'.WSeq α) (a : α) :
                                                                                                            Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, Stream'.WSeq.cons a s) = Computation.think (Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (a :: l, s))
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.toList'_think {α : Type u} (l : List α) (s : Stream'.WSeq α) :
                                                                                                            Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, Stream'.WSeq.think s) = Computation.think (Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, s))
                                                                                                            theorem Stream'.WSeq.toList'_map {α : Type u} (l : List α) (s : Stream'.WSeq α) :
                                                                                                            Computation.corec (fun (x : List α × Stream'.WSeq α) => match x with | (l, s) => match Stream'.Seq.destruct s with | none => Sum.inl (List.reverse l) | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, s) = (fun (x : List α) => List.reverse l ++ x) <$> Stream'.WSeq.toList s
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.toList_nil {α : Type u} :
                                                                                                            @[simp]
                                                                                                            @[simp]
                                                                                                            theorem Stream'.WSeq.dropn_ofSeq {α : Type u} (s : Stream'.Seq α) (n : ) :
                                                                                                            Equations
                                                                                                            • =
                                                                                                            def Stream'.WSeq.ret {α : Type u} (a : α) :

                                                                                                            The monadic return a is a singleton list containing a.

                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              @[simp]
                                                                                                              theorem Stream'.WSeq.map_nil {α : Type u} {β : Type v} (f : αβ) :
                                                                                                              Stream'.WSeq.map f Stream'.WSeq.nil = Stream'.WSeq.nil
                                                                                                              @[simp]
                                                                                                              theorem Stream'.WSeq.map_cons {α : Type u} {β : Type v} (f : αβ) (a : α) (s : Stream'.WSeq α) :
                                                                                                              @[simp]
                                                                                                              @[simp]
                                                                                                              theorem Stream'.WSeq.map_id {α : Type u} (s : Stream'.WSeq α) :
                                                                                                              @[simp]
                                                                                                              theorem Stream'.WSeq.map_ret {α : Type u} {β : Type v} (f : αβ) (a : α) :
                                                                                                              @[simp]
                                                                                                              theorem Stream'.WSeq.map_comp {α : Type u} {β : Type v} {γ : Type w} (f : αβ) (g : βγ) (s : Stream'.WSeq α) :
                                                                                                              theorem Stream'.WSeq.mem_map {α : Type u} {β : Type v} (f : αβ) {a : α} {s : Stream'.WSeq α} :
                                                                                                              a sf a Stream'.WSeq.map f s
                                                                                                              theorem Stream'.WSeq.exists_of_mem_join {α : Type u} {a : α} {S : Stream'.WSeq (Stream'.WSeq α)} :
                                                                                                              a Stream'.WSeq.join S∃ (s : Stream'.WSeq α), s S a s
                                                                                                              theorem Stream'.WSeq.exists_of_mem_bind {α : Type u} {β : Type v} {s : Stream'.WSeq α} {f : αStream'.WSeq β} {b : β} (h : b Stream'.WSeq.bind s f) :
                                                                                                              ∃ (a : α), a s b f a
                                                                                                              theorem Stream'.WSeq.liftRel_map {α : Type u} {β : Type v} {γ : Type w} {δ : Type u_1} (R : αβProp) (S : γδProp) {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq β} {f1 : αγ} {f2 : βδ} (h1 : Stream'.WSeq.LiftRel R s1 s2) (h2 : ∀ {a : α} {b : β}, R a bS (f1 a) (f2 b)) :
                                                                                                              theorem Stream'.WSeq.map_congr {α : Type u} {β : Type v} (f : αβ) {s : Stream'.WSeq α} {t : Stream'.WSeq α} (h : s t) :

                                                                                                              auxiliary definition of destruct_append over weak sequences

                                                                                                              Equations
                                                                                                              Instances For

                                                                                                                auxiliary definition of destruct_join over weak sequences

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  theorem Stream'.WSeq.liftRel_append {α : Type u} {β : Type v} (R : αβProp) {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq α} {t1 : Stream'.WSeq β} {t2 : Stream'.WSeq β} (h1 : Stream'.WSeq.LiftRel R s1 t1) (h2 : Stream'.WSeq.LiftRel R s2 t2) :
                                                                                                                  theorem Stream'.WSeq.liftRel_bind {α : Type u} {β : Type v} {γ : Type w} {δ : Type u_1} (R : αβProp) (S : γδProp) {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq β} {f1 : αStream'.WSeq γ} {f2 : βStream'.WSeq δ} (h1 : Stream'.WSeq.LiftRel R s1 s2) (h2 : ∀ {a : α} {b : β}, R a bStream'.WSeq.LiftRel S (f1 a) (f2 b)) :
                                                                                                                  theorem Stream'.WSeq.bind_congr {α : Type u} {β : Type v} {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq α} {f1 : αStream'.WSeq β} {f2 : αStream'.WSeq β} (h1 : s1 s2) (h2 : ∀ (a : α), f1 a f2 a) :
                                                                                                                  @[simp]
                                                                                                                  theorem Stream'.WSeq.join_map_ret {α : Type u} (s : Stream'.WSeq α) :
                                                                                                                  Stream'.WSeq.join (Stream'.WSeq.map Stream'.WSeq.ret s) s
                                                                                                                  @[simp]
                                                                                                                  theorem Stream'.WSeq.bind_ret {α : Type u} {β : Type v} (f : αβ) (s : Stream'.WSeq α) :
                                                                                                                  Stream'.WSeq.bind s (Stream'.WSeq.ret f) Stream'.WSeq.map f s
                                                                                                                  @[simp]
                                                                                                                  theorem Stream'.WSeq.ret_bind {α : Type u} {β : Type v} (a : α) (f : αStream'.WSeq β) :
                                                                                                                  @[simp]
                                                                                                                  theorem Stream'.WSeq.bind_assoc {α : Type u} {β : Type v} {γ : Type w} (s : Stream'.WSeq α) (f : αStream'.WSeq β) (g : βStream'.WSeq γ) :