The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.WSeq.Defs

28 declarations. Mathlib docs · Source

def Stream'.WSeq.length E1 #

{α : Type u} → Stream'.WSeq α → Computation ℕ

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

class Stream'.WSeq.IsFinite E1 #

{α : Type u} → Stream'.WSeq α → Prop

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

ctor Stream'.WSeq.IsFinite.mk E0 #

∀ {α : Type u} {s : Stream'.WSeq α}, s.toList.Terminates → s.IsFinite

theorem Stream'.WSeq.IsFinite.out E1 #

∀ {α : Type u} {s : Stream'.WSeq α} [self : s.IsFinite], s.toList.Terminates

instance Stream'.WSeq.toList_terminates E0 #

∀ {α : Type u} (s : Stream'.WSeq α) [h : s.IsFinite], s.toList.Terminates

def Stream'.WSeq.get E1 #

{α : Type u} → (s : Stream'.WSeq α) → [s.IsFinite] → List α

Get the list corresponding to a finite weak sequence.

def Stream'.WSeq.updateNth E1 #

{α : Type u} → Stream'.WSeq α → ℕ → α → Stream'.WSeq α

Replace the nth element of s with a.

def Stream'.WSeq.removeNth E1 #

{α : Type u} → Stream'.WSeq α → ℕ → Stream'.WSeq α

Remove the nth element of s.

def Stream'.WSeq.filterMap E1 #

{α : Type u} → {β : Type v} → (α → Option β) → Stream'.WSeq α → Stream'.WSeq β

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

def Stream'.WSeq.filter E1 #

{α : Type u} → (p : α → Prop) → [DecidablePred p] → Stream'.WSeq α → Stream'.WSeq α

Select the elements of s that satisfy p.

def Stream'.WSeq.find E1 #

{α : Type u} → (p : α → Prop) → [DecidablePred p] → Stream'.WSeq α → Computation (Option α)

Get the first element of s satisfying p.

def Stream'.WSeq.zipWith E1 #

{α : Type u} → {β : Type v} → {γ : Type w} → (α → β → γ) → Stream'.WSeq α → Stream'.WSeq β → Stream'.WSeq γ

Zip a function over two weak sequences

def Stream'.WSeq.zip E1 #

{α : Type u} → {β : Type v} → Stream'.WSeq α → Stream'.WSeq β → Stream'.WSeq (α × β)

Zip two weak sequences into a single sequence of pairs

def Stream'.WSeq.findIndexes E1 #

{α : Type u} → (p : α → Prop) → [DecidablePred p] → Stream'.WSeq α → Stream'.WSeq ℕ

Get the list of indexes of elements of s satisfying p

def Stream'.WSeq.findIndex E1 #

{α : Type u} → (p : α → Prop) → [DecidablePred p] → Stream'.WSeq α → Computation ℕ

Get the index of the first element of s satisfying p

def Stream'.WSeq.indexOf E1 #

{α : Type u} → [DecidableEq α] → α → Stream'.WSeq α → Computation ℕ

Get the index of the first occurrence of a in s

def Stream'.WSeq.indexesOf E1 #

{α : Type u} → [DecidableEq α] → α → Stream'.WSeq α → Stream'.WSeq ℕ

Get the indexes of occurrences of a in s

def Stream'.WSeq.union E1 #

{α : Type u} → Stream'.WSeq α → Stream'.WSeq α → Stream'.WSeq α

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

def Stream'.WSeq.isEmpty E1 #

{α : Type u} → Stream'.WSeq α → Computation Bool

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

def Stream'.WSeq.compute E1 #

{α : Type u} → Stream'.WSeq α → Stream'.WSeq α

Calculate one step of computation

def Stream'.WSeq.take E1 #

{α : Type u} → Stream'.WSeq α → ℕ → Stream'.WSeq α

Get the first n elements of a weak sequence

def Stream'.WSeq.splitAt E1 #

{α : Type u} → Stream'.WSeq α → ℕ → Computation (List α × Stream'.WSeq α)

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

def Stream'.WSeq.any E1 #

{α : Type u} → Stream'.WSeq α → (α → Bool) → Computation Bool

Returns true if any element of s satisfies p

def Stream'.WSeq.all E1 #

{α : Type u} → Stream'.WSeq α → (α → Bool) → Computation Bool

Returns true if every element of s satisfies p

def Stream'.WSeq.scanl E1 #

{α : Type u} → {β : Type v} → (α → β → α) → α → Stream'.WSeq β → 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.)

def Stream'.WSeq.inits E1 #

{α : Type u} → Stream'.WSeq α → Stream'.WSeq (List α)

Get the weak sequence of initial segments of the input sequence

def Stream'.WSeq.collect E1 #

{α : Type u} → Stream'.WSeq α → ℕ → List α

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

theorem Stream'.WSeq.length_eq_map E1 #

∀ {α : Type u} (s : Stream'.WSeq α), s.length = Computation.map List.length s.toList