| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Pointwise lifting of relations over Vector |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Data.Nat.Base using (ℕ) |
| 10 |
open import Data.Vec.Functional hiding (map) |
| 11 |
open import Data.Vec.Functional.Relation.Binary.Pointwise |
| 12 |
using (Pointwise) |
| 13 |
import Data.Vec.Functional.Relation.Binary.Pointwise.Properties as PW |
| 14 |
open import Level using (Level) |
| 15 |
open import Relation.Binary.Core using (_⇒_) |
| 16 |
open import Relation.Binary.Bundles using (Setoid) |
| 17 |
open import Relation.Binary.Structures using (IsEquivalence) |
| 18 |
open import Relation.Binary.Definitions |
| 19 |
using (Reflexive; Symmetric; Transitive) |
| 20 |
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_) |
| 21 |
|
| 22 |
module Data.Vec.Functional.Relation.Binary.Equality.Setoid |
| 23 |
{a ℓ} (S : Setoid a ℓ) where |
| 24 |
|
| 25 |
open Setoid S renaming (Carrier to A) |
| 26 |
|
| 27 |
------------------------------------------------------------------------ |
| 28 |
-- Definition |
| 29 |
------------------------------------------------------------------------ |
| 30 |
|
| 31 |
infix 4 _≋_ |
| 32 |
|
| 33 |
_≋_ : ∀ {n} → Vector A n → Vector A n → Set ℓ |
| 34 |
_≋_ = Pointwise _≈_ |
| 35 |
|
| 36 |
------------------------------------------------------------------------ |
| 37 |
-- Relational properties |
| 38 |
------------------------------------------------------------------------ |
| 39 |
|
| 40 |
≋-refl : ∀ {n} → Reflexive (_≋_ {n = n}) |
| 41 |
≋-refl {n} = PW.refl {R = _≈_} refl |
| 42 |
|
| 43 |
≋-reflexive : ∀ {n} → _≡_ ⇒ (_≋_ {n = n}) |
| 44 |
≋-reflexive ≡.refl = ≋-refl |
| 45 |
|
| 46 |
≋-sym : ∀ {n} → Symmetric (_≋_ {n = n}) |
| 47 |
≋-sym = PW.sym {R = _≈_} sym |
| 48 |
|
| 49 |
≋-trans : ∀ {n} → Transitive (_≋_ {n = n}) |
| 50 |
≋-trans = PW.trans {R = _≈_} trans |
| 51 |
|
| 52 |
≋-isEquivalence : ∀ n → IsEquivalence (_≋_ {n = n}) |
| 53 |
≋-isEquivalence = PW.isEquivalence isEquivalence |
| 54 |
|
| 55 |
≋-setoid : ℕ → Setoid _ _ |
| 56 |
≋-setoid = PW.setoid S |
| 57 |
|
| 58 |
------------------------------------------------------------------------ |
| 59 |
-- Properties |
| 60 |
------------------------------------------------------------------------ |
| 61 |
|
| 62 |
open PW public |
| 63 |
using |
| 64 |
( map⁺ |
| 65 |
; head⁺; tail⁺ |
| 66 |
; ++⁺; ++⁻ˡ; ++⁻ʳ; ++⁻ |
| 67 |
; replicate⁺ |
| 68 |
; ⊛⁺ |
| 69 |
; zipWith⁺; zip⁺; zip⁻ |
| 70 |
) |
| 71 |
|
| 72 |
foldr-cong : ∀ {f g} → (∀ {w x y z} → w ≈ x → y ≈ z → f w y ≈ g x z) → |
| 73 |
∀ {d e : A} → d ≈ e → |
| 74 |
∀ {n} {xs ys : Vector A n} → xs ≋ ys → |
| 75 |
foldr f d xs ≈ foldr g e ys |
| 76 |
foldr-cong = PW.foldr-cong |