The areas / V33. Data structures and computation
Mathlib.Data.Seq.Defs
109 declarations. Mathlib docs · Source
Possibly infinite lists
This file provides Stream'.Seq α, a type representing possibly infinite lists (referred here as
sequences). It is encoded as an infinite stream of options such that if f n = none, then
f m = none for all m ≥ n.
Main definitions
Seq α: The type of possibly infinite lists (sequences) encoded as streams of options. It is encoded asStream' (Option α)such that iff n = none, thenf m = nonefor allm ≥ n. It has two "constructors":nilandcons, and a destructordestruct.Seq1 α: The type of nonempty sequencesSeq.get?: Extract the nth element of a sequence (if it exists).Seq.corec: Corecursion principle forSeq αas a coinductive type.Seq.Terminates: Predicate for when a sequence is finite.
One can convert between sequences and other types: List, Stream', MLList using corresponding
functions defined in this file.
There are also a number of operations and predicates on sequences mirroring those on lists:
Seq.map, Seq.zip, Seq.zipWith, Seq.unzip, Seq.fold, Seq.update, Seq.drop,
Seq.splitAt, Seq.append, Seq.join, Seq.enum, Seq.Pairwise,
as well as a cases principle Seq.recOn which allows one to reason about
sequences by cases (nil and cons).
Main statements
eq_of_bisim: Bisimulation principle for sequences.
Constructors
Destructors
Recursion and corecursion principles
Bisimulation
Termination
Membership
Converting from/to other types
Operations on sequences
theorem Stream'.Seq.omap.match_1.congr_eq_2 E1 #
∀ {α : Type u_2} {β : Type u_1} (motive : Option (α × β) → Sort u_3) (x : Option (α × β)) (h_1 : Unit → motive none)
(h_2 : (a : α) → (b : β) → motive (some (a, b))) (a : α) (b : β),
x = some (a, b) →
(match x with
| none => h_1 ()
| some (a, b) => h_2 a b) ≍
h_2 a b
theorem Stream'.Seq.BisimO.match_1.congr_eq_1 E1 #
∀ {α : Type u_1} (motive : Option (Stream'.Seq1 α) → Option (Stream'.Seq1 α) → Sort u_2)
(x x_1 : Option (Stream'.Seq1 α)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.Seq α) → (a' : α) → (s' : Stream'.Seq α) → motive (some (a, s)) (some (a', s')))
(h_3 : (x x_2 : Option (Stream'.Seq1 α)) → motive x x_2),
x = none →
x_1 = none →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (a', s') => h_2 a s a' s'
| x, x_2 => h_3 x x_2) ≍
h_1 ()
theorem Stream'.Seq.BisimO.match_1.congr_eq_3 E1 #
∀ {α : Type u_1} (motive : Option (Stream'.Seq1 α) → Option (Stream'.Seq1 α) → Sort u_2)
(x x_1 : Option (Stream'.Seq1 α)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.Seq α) → (a' : α) → (s' : Stream'.Seq α) → motive (some (a, s)) (some (a', s')))
(h_3 : (x x_2 : Option (Stream'.Seq1 α)) → motive x x_2) (x_2 x_3 : Option (Stream'.Seq1 α)),
x = x_2 →
x_1 = x_3 →
(x_2 = none → x_3 = none → False) →
(∀ (a : α) (s : Stream'.Seq α) (a' : α) (s' : Stream'.Seq α), x_2 = some (a, s) → x_3 = some (a', s') → False) →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (a', s') => h_2 a s a' s'
| x, x_6 => h_3 x x_6) ≍
h_3 x_2 x_3
theorem Stream'.Seq.BisimO.match_1.congr_eq_2 E1 #
∀ {α : Type u_1} (motive : Option (Stream'.Seq1 α) → Option (Stream'.Seq1 α) → Sort u_2)
(x x_1 : Option (Stream'.Seq1 α)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.Seq α) → (a' : α) → (s' : Stream'.Seq α) → motive (some (a, s)) (some (a', s')))
(h_3 : (x x_2 : Option (Stream'.Seq1 α)) → motive x x_2) (a : α) (s : Stream'.Seq α) (a' : α) (s' : Stream'.Seq α),
x = some (a, s) →
x_1 = some (a', s') →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (a', s') => h_2 a s a' s'
| x, x_2 => h_3 x x_2) ≍
h_2 a s a' s'
theorem Stream'.Seq.omap.match_1.congr_eq_1 E1 #
∀ {α : Type u_2} {β : Type u_1} (motive : Option (α × β) → Sort u_3) (x : Option (α × β)) (h_1 : Unit → motive none)
(h_2 : (a : α) → (b : β) → motive (some (a, b))),
x = none →
(match x with
| none => h_1 ()
| some (a, b) => h_2 a b) ≍
h_1 ()
def Stream'.IsSeq E1 #
{α : Type u} → Stream' (Option α) → Prop
A stream s : Option α is a sequence if s.get n = none implies s.get (n + 1) = none.
def Stream'.Seq E3 #
Type u → Type u
Seq α is the type of possibly infinite lists (referred here as sequences).
It is encoded as an infinite stream of options such that if f n = none, then
f m = none for all m ≥ n.
def Stream'.Seq1 E1 #
Type u_1 → Type u_1
Seq1 α is the type of nonempty sequences.
def Stream'.Seq.get? E3 #
{α : Type u} → Stream'.Seq α → ℕ → Option α
Get the nth element of a sequence (if it exists)
theorem Stream'.Seq.val_eq_get E0 #
∀ {α : Type u} (s : Stream'.Seq α) (n : ℕ), ↑s n = s.get? n
theorem Stream'.Seq.get?_mk E0 #
∀ {α : Type u} (f : Stream' (Option α)) (hf : f.IsSeq), Stream'.Seq.get? ⟨f, hf⟩ = f
theorem Stream'.Seq.le_stable E1 #
∀ {α : Type u} (s : Stream'.Seq α) {m n : ℕ}, m ≤ n → s.get? m = none → s.get? n = none
theorem Stream'.Seq.ge_stable E1 #
∀ {α : Type u} (s : Stream'.Seq α) {aₙ : α} {n m : ℕ}, m ≤ n → s.get? n = some aₙ → ∃ aₘ, s.get? m = some aₘ
If s.get? n = some aₙ for some value aₙ, then there is also some value aₘ such
that s.get? = some aₘ for m ≤ n.
theorem Stream'.Seq.ext E1 #
∀ {α : Type u} {s t : Stream'.Seq α}, (∀ (n : ℕ), s.get? n = t.get? n) → s = t
theorem Stream'.Seq.ext_iff E0 #
∀ {α : Type u} {s t : Stream'.Seq α}, s = t ↔ ∀ (n : ℕ), s.get? n = t.get? n
def Stream'.Seq.nil E1 #
{α : Type u} → Stream'.Seq α
The empty sequence
instance Stream'.Seq.instInhabited E0 #
{α : Type u} → Inhabited (Stream'.Seq α)
def Stream'.Seq.cons E1 #
{α : Type u} → α → Stream'.Seq α → Stream'.Seq α
Prepend an element to a sequence
theorem Stream'.Seq.val_cons E0 #
∀ {α : Type u} (s : Stream'.Seq α) (x : α), ↑(Stream'.Seq.cons x s) = Stream'.cons (some x) ↑s
theorem Stream'.Seq.get?_nil E0 #
∀ {α : Type u} (n : ℕ), Stream'.Seq.nil.get? n = none
theorem Stream'.Seq.get?_zero_eq_none E0 #
∀ {α : Type u} {s : Stream'.Seq α}, s.get? 0 = none ↔ s = Stream'.Seq.nil
theorem Stream'.Seq.get?_cons_zero E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α), (Stream'.Seq.cons a s).get? 0 = some a
theorem Stream'.Seq.get?_cons_succ E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α) (n : ℕ), (Stream'.Seq.cons a s).get? (n + 1) = s.get? n
theorem Stream'.Seq.cons_ne_nil E0 #
∀ {α : Type u} {x : α} {s : Stream'.Seq α}, Stream'.Seq.cons x s ≠ Stream'.Seq.nil
theorem Stream'.Seq.nil_ne_cons E0 #
∀ {α : Type u} {x : α} {s : Stream'.Seq α}, Stream'.Seq.nil ≠ Stream'.Seq.cons x s
theorem Stream'.Seq.cons_injective2 E1 #
∀ {α : Type u}, Function.Injective2 Stream'.Seq.cons
theorem Stream'.Seq.cons_left_injective E1 #
∀ {α : Type u} (s : Stream'.Seq α), Function.Injective fun x ↦ Stream'.Seq.cons x s
theorem Stream'.Seq.cons_right_injective E1 #
∀ {α : Type u} (x : α), Function.Injective (Stream'.Seq.cons x)
theorem Stream'.Seq.cons_eq_cons E0 #
∀ {α : Type u} {x x' : α} {s s' : Stream'.Seq α}, Stream'.Seq.cons x s = Stream'.Seq.cons x' s' ↔ x = x' ∧ s = s'
def Stream'.Seq.head E1 #
{α : Type u} → Stream'.Seq α → Option α
Get the first element of a sequence
def Stream'.Seq.tail E1 #
{α : Type u} → Stream'.Seq α → Stream'.Seq α
Get the tail of a sequence (or nil if the sequence is nil)
def Stream'.Seq.destruct E3 #
{α : Type u} → Stream'.Seq α → Option (Stream'.Seq1 α)
Destructor for a sequence, resulting in either none (for nil) or
some (a, s) (for cons a s).
theorem Stream'.Seq.head_eq_destruct E1 #
∀ {α : Type u} (s : Stream'.Seq α), s.head = Prod.fst <$> s.destruct
theorem Stream'.Seq.get?_tail E0 #
∀ {α : Type u} (s : Stream'.Seq α) (n : ℕ), s.tail.get? n = s.get? (n + 1)
theorem Stream'.Seq.destruct_nil E0 #
∀ {α : Type u}, Stream'.Seq.nil.destruct = none
theorem Stream'.Seq.destruct_cons E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α), (Stream'.Seq.cons a s).destruct = some (a, s)
theorem Stream'.Seq.destruct_eq_none E1 #
∀ {α : Type u} {s : Stream'.Seq α}, s.destruct = none → s = Stream'.Seq.nil
theorem Stream'.Seq.destruct_eq_cons E1 #
∀ {α : Type u} {s : Stream'.Seq α} {a : α} {s' : Stream'.Seq α}, s.destruct = some (a, s') → s = Stream'.Seq.cons a s'
theorem Stream'.Seq.head_nil E0 #
∀ {α : Type u}, Stream'.Seq.nil.head = none
theorem Stream'.Seq.head_cons E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α), (Stream'.Seq.cons a s).head = some a
theorem Stream'.Seq.tail_nil E0 #
∀ {α : Type u}, Stream'.Seq.nil.tail = Stream'.Seq.nil
theorem Stream'.Seq.tail_cons E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α), (Stream'.Seq.cons a s).tail = s
theorem Stream'.Seq.head_eq_some E1 #
∀ {α : Type u} {s : Stream'.Seq α} {x : α}, s.head = some x → s = Stream'.Seq.cons x s.tail
theorem Stream'.Seq.head_eq_none E1 #
∀ {α : Type u} {s : Stream'.Seq α}, s.head = none → s = Stream'.Seq.nil
theorem Stream'.Seq.head_eq_none_iff E0 #
∀ {α : Type u} {s : Stream'.Seq α}, s.head = none ↔ s = Stream'.Seq.nil
def Stream'.Seq.recOn E3 #
{α : Type u} →
{motive : Stream'.Seq α → Sort v} →
(s : Stream'.Seq α) →
motive Stream'.Seq.nil → ((x : α) → (s : Stream'.Seq α) → motive (Stream'.Seq.cons x s)) → motive s
Recursion principle for sequences, compare with List.recOn.
def Stream'.Seq.omap E1 #
{α : Type u} → {β : Type v} → {γ : Type w} → (β → γ) → Option (α × β) → Option (α × γ)
Functorial action of the functor Option (α × _)
def Stream'.Seq.Corec.f E1 #
{α : Type u} → {β : Type v} → (β → Option (α × β)) → Option β → Option α × Option β
Corecursor over pairs of Option values
def Stream'.Seq.corec E1 #
{α : Type u} → {β : Type v} → (β → Option (α × β)) → β → Stream'.Seq α
Corecursor for Seq α as a coinductive type. Iterates f to produce new elements
of the sequence until none is obtained.
theorem Stream'.Seq.corec_eq E0 #
∀ {α : Type u} {β : Type v} (f : β → Option (α × β)) (b : β),
(Stream'.Seq.corec f b).destruct = Stream'.Seq.omap (Stream'.Seq.corec f) (f b)
theorem Stream'.Seq.corec_nil E1 #
∀ {α : Type u} {β : Type v} (f : β → Option (α × β)) (b : β), f b = none → Stream'.Seq.corec f b = Stream'.Seq.nil
theorem Stream'.Seq.corec_cons E1 #
∀ {α : Type u} {β : Type v} {f : β → Option (α × β)} {b : β} {x : α} {s : β},
f b = some (x, s) → Stream'.Seq.corec f b = Stream'.Seq.cons x (Stream'.Seq.corec f s)
def Stream'.Seq.BisimO E1 #
{α : Type u} → (Stream'.Seq α → Stream'.Seq α → Prop) → Option (Stream'.Seq1 α) → Option (Stream'.Seq1 α) → Prop
Bisimilarity relation over Option of Seq1 α
def Stream'.Seq.IsBisimulation E1 #
{α : Type u} → (Stream'.Seq α → Stream'.Seq α → Prop) → Prop
a relation is bisimilar if it meets the BisimO test
theorem Stream'.Seq.coinduction E1 #
∀ {α : Type u} {s₁ s₂ : Stream'.Seq α},
s₁.head = s₂.head → (∀ (β : Type u) (fr : Stream'.Seq α → β), fr s₁ = fr s₂ → fr s₁.tail = fr s₂.tail) → s₁ = s₂
theorem Stream'.Seq.coinduction2 E1 #
∀ {α : Type u} {β : Type v} (s : Stream'.Seq α) (f g : Stream'.Seq α → Stream'.Seq β),
(∀ (s : Stream'.Seq α), Stream'.Seq.BisimO (fun s1 s2 ↦ ∃ s, s1 = f s ∧ s2 = g s) (f s).destruct (g s).destruct) →
f s = g s
def Stream'.Seq.TerminatedAt E1 #
{α : Type u} → Stream'.Seq α → ℕ → Prop
A sequence has terminated at position n if the value at position n equals none.
instance Stream'.Seq.terminatedAtDecidable E0 #
{α : Type u} → (s : Stream'.Seq α) → (n : ℕ) → Decidable (s.TerminatedAt n)
It is decidable whether a sequence terminates at a given position.
def Stream'.Seq.Terminates E3 #
{α : Type u} → Stream'.Seq α → Prop
A sequence terminates if there is some position n at which it has terminated.
def Stream'.Seq.length E1 #
{α : Type u} → (s : Stream'.Seq α) → s.Terminates → ℕ
The length of a terminating sequence.
def Stream'.Seq.length' E1 #
{α : Type u} → Stream'.Seq α → ℕ∞
The ENat-valued length of a sequence. For non-terminating sequences, it is ⊤.
theorem Stream'.Seq.terminated_stable E1 #
∀ {α : Type u} (s : Stream'.Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n
If a sequence terminated at position n, it also terminated at m ≥ n.
theorem Stream'.Seq.not_terminates_iff E0 #
∀ {α : Type u} {s : Stream'.Seq α}, ¬s.Terminates ↔ ∀ (n : ℕ), (s.get? n).isSome = true
theorem Stream'.Seq.terminatedAt_nil E1 #
∀ {α : Type u} {n : ℕ}, Stream'.Seq.nil.TerminatedAt n
theorem Stream'.Seq.cons_not_terminatedAt_zero E0 #
∀ {α : Type u} {x : α} {s : Stream'.Seq α}, ¬(Stream'.Seq.cons x s).TerminatedAt 0
theorem Stream'.Seq.cons_terminatedAt_succ_iff E0 #
∀ {α : Type u} {x : α} {s : Stream'.Seq α} {n : ℕ}, (Stream'.Seq.cons x s).TerminatedAt (n + 1) ↔ s.TerminatedAt n
theorem Stream'.Seq.terminates_nil E0 #
∀ {α : Type u}, Stream'.Seq.nil.Terminates
theorem Stream'.Seq.terminates_cons_iff E0 #
∀ {α : Type u} {x : α} {s : Stream'.Seq α}, (Stream'.Seq.cons x s).Terminates ↔ s.Terminates
theorem Stream'.Seq.terminatedAt_zero_iff E0 #
∀ {α : Type u} {s : Stream'.Seq α}, s.TerminatedAt 0 ↔ s = Stream'.Seq.nil
def Stream'.Seq.Mem E1 #
{α : Type u} → Stream'.Seq α → α → Prop
member definition for Seq
instance Stream'.Seq.instMembership E0 #
{α : Type u} → Membership α (Stream'.Seq α)
theorem Stream'.Seq.get?_mem E1 #
∀ {α : Type u} {s : Stream'.Seq α} {n : ℕ} {x : α}, s.get? n = some x → x ∈ s
theorem Stream'.Seq.mem_iff_exists_get? E0 #
∀ {α : Type u} {s : Stream'.Seq α} {x : α}, x ∈ s ↔ ∃ i, some x = s.get? i
theorem Stream'.Seq.notMem_nil E0 #
∀ {α : Type u} (a : α), a ∉ Stream'.Seq.nil
theorem Stream'.Seq.mem_cons E0 #
∀ {α : Type u} (a : α) (s : Stream'.Seq α), a ∈ Stream'.Seq.cons a s
theorem Stream'.Seq.mem_cons_of_mem E0 #
∀ {α : Type u} (y : α) {a : α} {s : Stream'.Seq α}, a ∈ s → a ∈ Stream'.Seq.cons y s
theorem Stream'.Seq.mem_cons_iff E0 #
∀ {α : Type u} {a b : α} {s : Stream'.Seq α}, a ∈ Stream'.Seq.cons b s ↔ a = b ∨ a ∈ s
theorem Stream'.Seq.mem_rec_on E0 #
∀ {α : Type u} {C : Stream'.Seq α → Prop} {a : α} {s : Stream'.Seq α},
a ∈ s → (∀ (b : α) (s' : Stream'.Seq α), a = b ∨ C s' → C (Stream'.Seq.cons b s')) → C s
def Stream'.Seq.ofList E1 #
{α : Type u} → List α → Stream'.Seq α
Embed a list as a sequence
instance Stream'.Seq.coeList E0 #
{α : Type u} → Coe (List α) (Stream'.Seq α)
theorem Stream'.Seq.ofList_nil E0 #
∀ {α : Type u}, ↑[] = Stream'.Seq.nil
theorem Stream'.Seq.ofList_get? E0 #
∀ {α : Type u} (l : List α) (n : ℕ), (↑l).get? n = l[n]?
theorem Stream'.Seq.ofList_cons E0 #
∀ {α : Type u} (a : α) (l : List α), ↑(a :: l) = Stream'.Seq.cons a ↑l
theorem Stream'.Seq.ofList_injective E1 #
∀ {α : Type u}, Function.Injective Stream'.Seq.ofList
def Stream'.Seq.ofStream E1 #
{α : Type u} → Stream' α → Stream'.Seq α
Embed an infinite stream as a sequence
instance Stream'.Seq.coeStream E0 #
{α : Type u} → Coe (Stream' α) (Stream'.Seq α)
def Stream'.Seq.ofMLList E1 #
{α : Type u} → MLList Id α → Stream'.Seq α
Embed a MLList α as a sequence. Note that even though this
is non-meta, it will produce infinite sequences if used with
cyclic MLLists created by meta constructions.
instance Stream'.Seq.coeMLList E0 #
{α : Type u} → Coe (MLList Id α) (Stream'.Seq α)
def Stream'.Seq.toMLList E1 #
{α : Type u} → Stream'.Seq α → MLList Id α
Translate a sequence into a MLList.
def Stream'.Seq.forceToList E1 #
{α : Type u} → Stream'.Seq α → List α
Translate a sequence to a list. This function will run forever if run on an infinite sequence.
def Stream'.Seq.take E1 #
{α : Type u} → ℕ → Stream'.Seq α → List α
Take the first n elements of the sequence (producing a list)
def Stream'.Seq.toList E1 #
{α : Type u} → (s : Stream'.Seq α) → s.Terminates → List α
Convert a sequence which is known to terminate into a list
def Stream'.Seq.toStream E1 #
{α : Type u} → (s : Stream'.Seq α) → ¬s.Terminates → Stream' α
Convert a sequence which is known not to terminate into a stream
def Stream'.Seq.toListOrStream E1 #
{α : Type u} → (s : Stream'.Seq α) → [Decidable s.Terminates] → List α ⊕ Stream' α
Convert a sequence into either a list or a stream depending on whether it is finite or infinite. (Without decidability of the infiniteness predicate, this is not constructively possible.)
def Stream'.Seq.toList' E1 #
{α : Type u_1} → Stream'.Seq α → Computation (List α)
Convert a sequence into a list, embedded in a computation to allow for the possibility of infinite sequences (in which case the computation never returns anything).
def Stream'.Seq.append E3 #
{α : Type u} → Stream'.Seq α → Stream'.Seq α → Stream'.Seq α
Append two sequences. If s₁ is infinite, then s₁ ++ s₂ = s₁,
otherwise it puts s₂ at the location of the nil in s₁.
def Stream'.Seq.map E3 #
{α : Type u} → {β : Type v} → (α → β) → Stream'.Seq α → Stream'.Seq β
Map a function over a sequence.
def Stream'.Seq.join E3 #
{α : Type u} → Stream'.Seq (Stream'.Seq1 α) → Stream'.Seq α
Flatten a sequence of sequences. (It is required that the
sequences be nonempty to ensure productivity; in the case
of an infinite sequence of nil, the first element is never
generated.)
def Stream'.Seq.drop E3 #
{α : Type u} → Stream'.Seq α → ℕ → Stream'.Seq α
Remove the first n elements from the sequence.
def Stream'.Seq.splitAt E3 #
{α : Type u} → ℕ → Stream'.Seq α → List α × Stream'.Seq α
Split a sequence at n, producing a finite initial segment
and an infinite tail.
def Stream'.Seq.zipWith E3 #
{α : Type u} → {β : Type v} → {γ : Type w} → (α → β → γ) → Stream'.Seq α → Stream'.Seq β → Stream'.Seq γ
Combine two sequences with a function
def Stream'.Seq.zip E3 #
{α : Type u} → {β : Type v} → Stream'.Seq α → Stream'.Seq β → Stream'.Seq (α × β)
Pair two sequences into a sequence of pairs
def Stream'.Seq.unzip E3 #
{α : Type u} → {β : Type v} → Stream'.Seq (α × β) → Stream'.Seq α × Stream'.Seq β
Separate a sequence of pairs into two sequences
def Stream'.Seq.nats E1 #
Stream'.Seq ℕ
The sequence of natural numbers some 0, some 1, ...
def Stream'.Seq.enum E3 #
{α : Type u} → Stream'.Seq α → Stream'.Seq (ℕ × α)
Enumerate a sequence by tagging each element with its index.
def Stream'.Seq.fold E3 #
{α : Type u} → {β : Type v} → Stream'.Seq α → β → (β → α → β) → Stream'.Seq β
Folds a sequence using f, producing a sequence of intermediate values, i.e.
[init, f init s.head, f (f init s.head) s.tail.head, ...].
def Stream'.Seq.update E3 #
{α : Type u} → Stream'.Seq α → ℕ → (α → α) → Stream'.Seq α
Applies f to the nth element of the sequence, if it exists, replacing that element
with the result.
def Stream'.Seq.set E1 #
{α : Type u} → Stream'.Seq α → ℕ → α → Stream'.Seq α
Sets the value of sequence s at index n to a. If the nth element does not exist
(s terminates earlier), the sequence is left unchanged.
def Stream'.Seq.Pairwise E3 #
{α : Type u} → (α → α → Prop) → Stream'.Seq α → Prop
Pairwise R s means that all the elements with earlier indices are
R-related to all the elements with later indices.
Pairwise R [1, 2, 3] ↔ R 1 2 ∧ R 1 3 ∧ R 2 3
For example if R = (· ≠ ·) then it asserts s has no duplicates,
and if R = (· < ·) then it asserts that s is (strictly) sorted.