Skip to content

Commit 3b796db

Browse files
committed
Add some algebraic properties of pointwise relations on streams
1 parent f40c085 commit 3b796db

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/Codata/Guarded/Stream/Relation/Binary/Pointwise.agda

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open import Codata.Guarded.Stream as Stream using (Stream; head; tail)
1212
open import Data.Nat.Base using (ℕ; zero; suc)
1313
open import Function.Base using (_∘_; _on_)
1414
open import Level using (Level; _⊔_)
15-
open import Relation.Binary.Core using (REL; _⇒_)
15+
open import Relation.Binary.Core using (REL; Rel; _⇒_)
1616
open import Relation.Binary.Bundles using (Setoid)
1717
open import Relation.Binary.Definitions
1818
using (Reflexive; Sym; Trans; Antisym; Symmetric; Transitive)
@@ -104,6 +104,43 @@ drop⁺ : ∀ n → Pointwise R ⇒ (Pointwise R on Stream.drop n)
104104
drop⁺ zero as≈bs = as≈bs
105105
drop⁺ (suc n) as≈bs = drop⁺ n (as≈bs .tail)
106106

107+
------------------------------------------------------------------------
108+
-- Algebraic properties
109+
110+
module _ {A : Set a} {_≈_ : Rel A ℓ} where
111+
112+
open import Algebra.Definitions
113+
114+
private
115+
variable
116+
_∙_ : A A A
117+
_⁻¹ : A A
118+
ε : A
119+
120+
assoc : Associative _≈_ _∙_ Associative (Pointwise _≈_) (Stream.zipWith _∙_)
121+
head (assoc assoc₁ xs ys zs) = assoc₁ (head xs) (head ys) (head zs)
122+
tail (assoc assoc₁ xs ys zs) = assoc assoc₁ (tail xs) (tail ys) (tail zs)
123+
124+
comm : Commutative _≈_ _∙_ Commutative (Pointwise _≈_) (Stream.zipWith _∙_)
125+
head (comm comm₁ xs ys) = comm₁ (head xs) (head ys)
126+
tail (comm comm₁ xs ys) = comm comm₁ (tail xs) (tail ys)
127+
128+
identityˡ : LeftIdentity _≈_ ε _∙_ LeftIdentity (Pointwise _≈_) (Stream.repeat ε) (Stream.zipWith _∙_)
129+
head (identityˡ identityˡ₁ xs) = identityˡ₁ (head xs)
130+
tail (identityˡ identityˡ₁ xs) = identityˡ identityˡ₁ (tail xs)
131+
132+
identityʳ : RightIdentity _≈_ ε _∙_ RightIdentity (Pointwise _≈_) (Stream.repeat ε) (Stream.zipWith _∙_)
133+
head (identityʳ identityʳ₁ xs) = identityʳ₁ (head xs)
134+
tail (identityʳ identityʳ₁ xs) = identityʳ identityʳ₁ (tail xs)
135+
136+
inverseˡ : LeftInverse _≈_ ε _⁻¹ _∙_ LeftInverse (Pointwise _≈_) (Stream.repeat ε) (Stream.map _⁻¹) (Stream.zipWith _∙_)
137+
head (inverseˡ inverseˡ₁ xs) = inverseˡ₁ (head xs)
138+
tail (inverseˡ inverseˡ₁ xs) = inverseˡ inverseˡ₁ (tail xs)
139+
140+
inverseʳ : RightInverse _≈_ ε _⁻¹ _∙_ RightInverse (Pointwise _≈_) (Stream.repeat ε) (Stream.map _⁻¹) (Stream.zipWith _∙_)
141+
head (inverseʳ inverseʳ₁ xs) = inverseʳ₁ (head xs)
142+
tail (inverseʳ inverseʳ₁ xs) = inverseʳ inverseʳ₁ (tail xs)
143+
107144
------------------------------------------------------------------------
108145
-- Pointwise Equality as a Bisimilarity
109146

0 commit comments

Comments
 (0)