streamEq
import stream (stream, hd, tl, mapS, iterate)
def tlN : (a : 𝕌) → ℕ → El (stream a) → El (stream a) ≔
λa. λn. ℕ-elim (m. El (stream a) → El (stream a)) (λs. s) (m ih. λs. ih (tl _ s)) n
def nth : (a : 𝕌) → ℕ → El (stream a) → El a ≔
λa. λn. λs. hd _ (tlN _ n s)
def obsEq : (a : 𝕌) → El (stream a) → El (stream a) → Ω ≔
λa. λs. λt. ∥(n : ℕ) → Prf (nth _ n s ≡ nth _ n t ∈ El a)∥
def obsEqRefl : (a : 𝕌) (s : El (stream a)) → Prf (obsEq _ s s) ≔
λa. λs. ⋆ (λn. ⋆)
def nthMap : (a : 𝕌) (b : 𝕌) (f : El a → El b) (n : ℕ) (s : El (stream a)) →
nth _ n (mapS _ _ f s) ≡ f (nth _ n s) ∈ El b ≔
λa. λb. λf. λn.
ℕ-elim (m. (s : El (stream a)) → nth _ m (mapS _ _ f s) ≡ f (nth _ m s) ∈ El b)
(λs. ⋆)
(m ih. λs. ih (tl _ s))
n
def mapIdObsEq : (a : 𝕌) (s : El (stream a)) → Prf (obsEq _ (mapS _ _ (λx. x) s) s) ≔
λa. λs. ⋆ (λn. nthMap _ _ (λx. x) n s)
def mapFuseObsEq : (a : 𝕌) (b : 𝕌) (c : 𝕌) (f : El a → El b) (g : El b → El c)
(s : El (stream a)) →
Prf (obsEq _ (mapS _ _ g (mapS _ _ f s)) (mapS _ _ (λx. g (f x)) s)) ≔
λa. λb. λc. λf. λg. λs.
⋆ (λn. (ℕ-elim (m. (t : El (stream a)) →
nth _ m (mapS _ _ g (mapS _ _ f t)) ≡ nth _ m (mapS _ _ (λx. g (f x)) t) ∈ El c)
(λt. ⋆)
(m ih. λt. ih (tl _ t))
n) s)
def iterShiftObsEq : (a : 𝕌) (f : El a → El a) (x : El a) →
Prf (obsEq _ (tl _ (iterate _ f x)) (iterate _ f (f x))) ≔
λa. λf. λx. ⋆ (λn. ⋆)