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