Debian Codegraph @

src/Relation/Binary/Construct/Closure/Reflexive.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Reflexive closures
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Relation.Binary.Construct.Closure.Reflexive where
10
11 open import Data.Unit.Base
12 open import Level
13 open import Function.Base using (_∋_)
14 open import Relation.Binary.Core using (Rel; _=[_]⇒_; _⇒_)
15 open import Relation.Binary.Definitions using (Reflexive)
16 open import Relation.Binary.Construct.Constant.Core using (Const)
17 open import Relation.Binary.PropositionalEquality.Core using (_≡_ ; refl)
18
19 private
20 variable
21 a ℓ ℓ₁ ℓ₂ : Level
22 A B : Set a
23
24 ------------------------------------------------------------------------
25 -- Definition
26
27 data ReflClosure {A : Set a} (_∼_ : Rel A ℓ) : Rel A (a ⊔ ℓ) where
28 refl : Reflexive (ReflClosure _∼_)
29 [_] : ∀ {x y} (x∼y : x ∼ y) → ReflClosure _∼_ x y
30
31 ------------------------------------------------------------------------
32 -- Operations
33
34 map : ∀ {R : Rel A ℓ₁} {S : Rel B ℓ₂} {f : A → B} →
35 R =[ f ]⇒ S → ReflClosure R =[ f ]⇒ ReflClosure S
36 map R⇒S [ xRy ] = [ R⇒S xRy ]
37 map R⇒S refl = refl
38
39 ------------------------------------------------------------------------
40 -- Properties
41
42 -- The reflexive closure has no effect on reflexive relations.
43 drop-refl : {R : Rel A ℓ} → Reflexive R → ReflClosure R ⇒ R
44 drop-refl rfl [ xRy ] = xRy
45 drop-refl rfl refl = rfl
46
47 reflexive : {R : Rel A ℓ} → _≡_ ⇒ ReflClosure R
48 reflexive refl = refl
49
50 []-injective : {R : Rel A ℓ} → ∀ {x y p q} →
51 (ReflClosure R x y ∋ [ p ]) ≡ [ q ] → p ≡ q
52 []-injective refl = refl
53
54 ------------------------------------------------------------------------
55 -- Example usage
56
57 private
58 module Maybe where
59 Maybe : Set a → Set a
60 Maybe A = ReflClosure (Const A) tt tt
61
62 nothing : Maybe A
63 nothing = refl
64
65 just : A → Maybe A
66 just = [_]
67
68
69
70 ------------------------------------------------------------------------
71 -- Deprecations
72 ------------------------------------------------------------------------
73 -- Please use the new names as continuing support for the old names is
74 -- not guaranteed.
75
76 -- v1.5
77
78 Refl = ReflClosure
79 {-# WARNING_ON_USAGE Refl
80 "Warning: Refl was deprecated in v1.5.
81 Please use ReflClosure instead."
82 #-}