@@ -15,18 +15,20 @@ open import Data.Fin.Permutation using (id; flip; _⟨$⟩ʳ_; inverseʳ; _∘
1515open import Data.Vec.Functional
1616open import Data.Vec.Functional.Relation.Binary.Permutation
1717open import Relation.Binary.PropositionalEquality
18- using (refl; trans; _≡_; cong; module ≡-Reasoning )
19- open import Relation.Binary.Indexed.Heterogeneous.Definitions
20-
21- open ≡-Reasoning
18+ using (_≡_; refl; trans; cong; module ≡-Reasoning )
19+ open import Relation.Binary.Indexed.Heterogeneous
2220
2321private
2422 variable
25- ℓ : Level
26- A : Set ℓ
23+ a : Level
24+ A : Set a
2725 n : ℕ
2826 xs ys : Vector A n
2927
28+
29+ ------------------------------------------------------------------------
30+ -- Basics
31+
3032↭-refl : Reflexive (Vector A) _↭_
3133↭-refl = id , λ _ → refl
3234
@@ -36,10 +38,32 @@ private
3638↭-sym : Symmetric (Vector A) _↭_
3739proj₁ (↭-sym (xs↭ys , _)) = flip xs↭ys
3840proj₂ (↭-sym {x = xs} {ys} (xs↭ys , xs↭ys≡)) i = begin
39- ys (flip xs↭ys ⟨$⟩ʳ i) ≡˘ ⟨ xs↭ys≡ _ ⟩
41+ ys (flip xs↭ys ⟨$⟩ʳ i) ≡ ⟨ xs↭ys≡ _ ⟨
4042 xs (xs↭ys ⟨$⟩ʳ (flip xs↭ys ⟨$⟩ʳ i)) ≡⟨ cong xs (inverseʳ xs↭ys) ⟩
41- xs i ∎
43+ xs i ∎
44+ where open ≡-Reasoning
4245
4346↭-trans : Transitive (Vector A) _↭_
4447proj₁ (↭-trans (xs↭ys , _) (ys↭zs , _)) = ys↭zs ∘ₚ xs↭ys
4548proj₂ (↭-trans (_ , xs↭ys) (_ , ys↭zs)) _ = trans (xs↭ys _) (ys↭zs _)
49+
50+ ------------------------------------------------------------------------
51+ -- Structure
52+
53+ isIndexedEquivalence : IsIndexedEquivalence (Vector A) _↭_
54+ isIndexedEquivalence {A = A} = record
55+ { refl = ↭-refl
56+ ; sym = ↭-sym
57+ ; trans = λ {n₁ n₂ n₃} {xs : Vector A n₁} {ys : Vector A n₂} {zs : Vector A n₃}
58+ xs↭ys ys↭zs → ↭-trans {i = n₁} {i = xs} xs↭ys ys↭zs
59+ }
60+
61+ ------------------------------------------------------------------------
62+ -- Bundle
63+
64+ indexedSetoid : {A : Set a} → IndexedSetoid ℕ a _
65+ indexedSetoid {A = A} = record
66+ { Carrier = Vector A
67+ ; _≈_ = _↭_
68+ ; isEquivalence = isIndexedEquivalence
69+ }
0 commit comments