Documentation

Cslib.Foundations.Data.OmegaSequence.Defs

Definition of ωSequence and functions on infinite sequences #

An ωSequence α is an infinite sequence of elements of α. It is basically a wrapper around the type ℕ → α which supports the dot-notation and the analogues of many familiar API functions of List α. In particular, the element at position n : ℕ of s : ωSequence α is obtained using the function application notation s n.

In this file we define ωSequence and its API functions. Most code below is adapted from Mathlib.Data.Stream.Defs.

structure Cslib.ωSequence (α : Type u) :

An ωSequence α is an infinite sequence of elements of α.

  • get : ℕ → α

    The function that defines this infinite sequence.

Instances For
    @[instance_reducible]
    @[instance_reducible]
    instance Cslib.instCoeForallNatωSequence {α : Type u} :
    Coe (ℕ → α) (ωSequence α)
    @[reducible, inline]
    abbrev Cslib.ωSequence.head {α : Type u} (s : ωSequence α) :
    α

    Head of an ω-sequence: ωSequence.head s = ωSequence s 0.

    Tail of an ω-sequence: ωSequence.tail (h :: t) = t.

    def Cslib.ωSequence.drop {α : Type u} (n : ℕ) (s : ωSequence α) :

    Drop first n elements of an ω-sequence.

    def Cslib.ωSequence.take {α : Type u} :
    ℕ → ωSequence α → List α

    take n s returns a list of the n first elements of ω-sequence s

    def Cslib.ωSequence.extract {α : Type u} (xs : ωSequence α) (m n : ℕ) :
    List α

    Get the list containing the elements of xs from position m to n - 1.

    def Cslib.ωSequence.cons {α : Type u} (a : α) (s : ωSequence α) :

    Prepend an element to an ω-sequence.

    Prepend an element to an ω-sequence.

    Append an ω-sequence to a list.

    def Cslib.ωSequence.const {α : Type u} (a : α) :

    The constant ω-sequence: ωSequence n (ωSequence.const a) = a.

    def Cslib.ωSequence.map {α : Type u} {β : Type v} (f : α → β) (s : ωSequence α) :

    Apply a function f to all elements of an ω-sequence s.

    def Cslib.ωSequence.zip {α : Type u} {β : Type v} {δ : Type w} (f : α → β → δ) (s₁ : ωSequence α) (s₂ : ωSequence β) :

    Zip two ω-sequences using a binary operation: ωSequence n (ωSequence.zip f s₁ s₂) = f (ωSequence s₁) (ωSequence s₂).

    def Cslib.ωSequence.iterate {α : Type u} (f : α → α) (a : α) :

    Iterates of a function as an ω-sequence.