Debian Codegraph @

src/Function/Relation/Binary/Setoid/Equality.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Function Equality setoid
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Level using (Level; _⊔_)
10 open import Relation.Binary.Bundles using (Setoid)
11
12 module Function.Relation.Binary.Setoid.Equality {a₁ a₂ b₁ b₂ : Level}
13 (From : Setoid a₁ a₂) (To : Setoid b₁ b₂) where
14
15 open import Function.Bundles using (Func; _⟨$⟩_)
16 open import Relation.Binary.Definitions
17 using (Reflexive; Symmetric; Transitive)
18 open import Relation.Binary.Structures
19 using (IsEquivalence)
20
21 private
22 module To = Setoid To
23 module From = Setoid From
24
25 infix 4 _≈_
26 _≈_ : (f g : Func From To) → Set (a₁ ⊔ b₂)
27 f ≈ g = ∀ x → f ⟨$⟩ x To.≈ g ⟨$⟩ x
28
29 refl : Reflexive _≈_
30 refl _ = To.refl
31
32 sym : Symmetric _≈_
33 sym f≈g x = To.sym (f≈g x)
34
35 trans : Transitive _≈_
36 trans f≈g g≈h x = To.trans (f≈g x) (g≈h x)
37
38 isEquivalence : IsEquivalence _≈_
39 isEquivalence = record -- need to η-expand else Agda gets confused
40 { refl = λ {f} → refl {f}
41 ; sym = λ {f} {g} → sym {f} {g}
42 ; trans = λ {f} {g} {h} → trans {f} {g} {h}
43 }
44
45 setoid : Setoid _ _
46 setoid = record { isEquivalence = isEquivalence }
47
48 -- most of the time, this infix version is nicer to use
49 infixr 9 _⇨_
50 _⇨_ : Setoid _ _
51 _⇨_ = setoid