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 postion 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.
Equations
- Cslib.instFunLikeωSequenceNat = { coe := Cslib.ωSequence.get, coe_injective' := ⋯ }
take n s returns a list of the n first elements of ω-sequence s
Equations
- Cslib.ωSequence.take 0 x✝ = []
- Cslib.ωSequence.take n.succ x✝ = x✝.head :: Cslib.ωSequence.take n x✝.tail
Instances For
Get the list containing the elements of xs from position m to n - 1.
Equations
- xs.extract m n = Cslib.ωSequence.take (n - m) (Cslib.ωSequence.drop m xs)
Instances For
Prepend an element to an ω-sequence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Append an ω-sequence to a list.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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₂).
Equations
- Cslib.ωSequence.zip f s₁ s₂ = { get := fun (n : ℕ) => f (s₁ n) (s₂ n) }