# Documentation

Mathlib.Data.Stream.Defs

# Definition of Stream' and functions on streams #

A stream Stream' α is an infinite sequence of elements of α. One can also think about it as an infinite list. In this file we define Stream' and some functions that take and/or return streams. Note that we already have Stream to represent a similar object, hence the awkward naming.

def Stream' (α : Type u) :

A stream Stream' α is an infinite sequence of elements of α.

Instances For
def Stream'.cons {α : Type u_1} (a : α) (s : ) :

Prepend an element to a stream.

Instances For
Instances For
def Stream'.nth {α : Type u_1} (s : ) (n : ) :
α

n-th element of a stream.

Instances For
@[inline, reducible]
abbrev Stream'.head {α : Type u_1} (s : ) :
α

Head of a stream: Stream'.head s = Stream'.nth s 0.

Instances For
def Stream'.tail {α : Type u_1} (s : ) :

Tail of a stream: Stream'.tail (h :: t) = t.

Instances For
def Stream'.drop {α : Type u_1} (n : ) (s : ) :

Drop first n elements of a stream.

Instances For
def Stream'.All {α : Type u_1} (p : αProp) (s : ) :

Proposition saying that all elements of a stream satisfy a predicate.

Instances For
def Stream'.Any {α : Type u_1} (p : αProp) (s : ) :

Proposition saying that at least one element of a stream satisfies a predicate.

Instances For
instance Stream'.instMembershipStream' {α : Type u_1} :

a ∈ s means that a = Stream'.nth n s for some n.

def Stream'.map {α : Type u_1} {β : Type u_2} (f : αβ) (s : ) :

Apply a function f to all elements of a stream s.

Instances For
def Stream'.zip {α : Type u_1} {β : Type u_2} {δ : Type u_3} (f : αβδ) (s₁ : ) (s₂ : ) :

Zip two streams using a binary operation: Stream'.nth n (Stream'.zip f s₁ s₂) = f (Stream'.nth s₁) (Stream'.nth s₂).

Instances For
def Stream'.enum {α : Type u_1} (s : ) :

Enumerate a stream by tagging each element with its index.

Instances For
def Stream'.const {α : Type u_1} (a : α) :

The constant stream: Stream'.nth n (Stream'.const a) = a.

Instances For
def Stream'.iterate {α : Type u_1} (f : αα) (a : α) :

Iterates of a function as a stream.

Equations
Instances For
def Stream'.corec {α : Type u_1} {β : Type u_2} (f : αβ) (g : αα) :
α
Instances For
def Stream'.corecOn {α : Type u_1} {β : Type u_2} (a : α) (f : αβ) (g : αα) :
Instances For
def Stream'.corec' {α : Type u_1} {β : Type u_2} (f : αβ × α) :
α
Instances For
def Stream'.corecState {σ : Type u_1} {α : Type u_1} (cmd : StateM σ α) (s : σ) :

Use a state monad to generate a stream through corecursion

Instances For
@[inline, reducible]
abbrev Stream'.unfolds {α : Type u_1} {β : Type u_2} (g : αβ) (f : αα) (a : α) :
Instances For
def Stream'.interleave {α : Type u_1} (s₁ : ) (s₂ : ) :

Interleave two streams.

Instances For
Instances For
def Stream'.even {α : Type u_1} (s : ) :

Elements of a stream with even indices.

Instances For
def Stream'.odd {α : Type u_1} (s : ) :

Elements of a stream with odd indices.

Instances For
def Stream'.appendStream' {α : Type u_1} :
List α

Append a stream to a list.

Equations
Instances For
Instances For
def Stream'.take {α : Type u_1} :
List α

take n s returns a list of the n first elements of stream s

Equations
Instances For
def Stream'.cycleF {α : Type u_1} :
α × List α × α × List αα

An auxiliary definition for Stream'.cycle corecursive def

Instances For
def Stream'.cycleG {α : Type u_1} :
α × List α × α × List αα × List α × α × List α

An auxiliary definition for Stream'.cycle corecursive def

Instances For
def Stream'.cycle {α : Type u_1} (l : List α) :
l []

Interpret a nonempty list as a cyclic stream.

Instances For
def Stream'.tails {α : Type u_1} (s : ) :

Tails of a stream, starting with Stream'.tail s.

Instances For
def Stream'.initsCore {α : Type u_1} (l : List α) (s : ) :

An auxiliary definition for Stream'.inits.

Instances For
def Stream'.inits {α : Type u_1} (s : ) :

Nonempty initial segments of a stream.

Instances For
def Stream'.pure {α : Type u_1} (a : α) :

A constant stream, same as Stream'.const.

Instances For
def Stream'.apply {α : Type u_1} {β : Type u_2} (f : Stream' (αβ)) (s : ) :

Given a stream of functions and a stream of values, apply n-th function to n-th value.

Instances For
Instances For

The stream of natural numbers: Stream'.nth n Stream'.nats = n.

Instances For