Skip to content

Commit d7d3d69

Browse files
Tidying up in Relation.Binary.Construct.Closure (#1315)
* Use variables * Deprecate non-standard closure names and proofs
1 parent 9a859b9 commit d7d3d69

File tree

9 files changed

+272
-148
lines changed

9 files changed

+272
-148
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Highlights
99
Bug-fixes
1010
---------
1111

12-
* Fixed List.Relation.Unary.All.Properties.map-id, which was abstracted over
12+
* The example module `Maybe` in `Relation.Binary.Construct.Closure.Reflexive` was accidentally exposed publicly. It has been made private.
13+
14+
* Fixed the type of the proof `map-id` in `List.Relation.Unary.All.Properties`, which was incorrectly abstracted over
1315
unused module parameters.
1416

1517
Non-backwards compatible changes
@@ -22,9 +24,21 @@ Non-backwards compatible changes
2224
Deprecated modules
2325
------------------
2426

27+
* The module `TransitiveClosure` in `Induction.WellFounded` has been deprecated. You should instead use the standard definition of transitive closure and the accompanying proof of well-foundness defined in `Relation.Binary.Construct.Closure.Transitive`.
28+
2529
Deprecated names
2630
----------------
2731

32+
* In `Relation.Binary.Construct.Closure.Reflexive`:
33+
```agda
34+
Refl ↦ ReflClosure
35+
```
36+
37+
* In `Relation.Binary.Construct.Closure.Transitive`:
38+
```agda
39+
Plus′ ↦ TransClosure
40+
```
41+
2842
New modules
2943
-----------
3044

@@ -67,6 +81,13 @@ Other minor additions
6781
IsLatticeIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
6882
```
6983

84+
* Added new proofs to `Relation.Binary.Construct.Closure.Transitive`:
85+
```agda
86+
reflexive : Reflexive _∼_ → Reflexive _∼⁺_
87+
symmetric : Symmetric _∼_ → Symmetric _∼⁺_
88+
transitive : Transitive _∼⁺_
89+
wellFounded : WellFounded _∼_ → WellFounded _∼⁺_
90+
7091
* Added new definitions to `Algebra.Definitions`:
7192
```agda
7293
AlmostLeftCancellative e _•_ = ∀ {x} y z → ¬ x ≈ e → (x • y) ≈ (x • z) → y ≈ z

src/Data/Vec/Relation/Binary/Pointwise/Extensional.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private
201201
ix∙⁺jz : IPointwise (Plus _R_) ix jz
202202
ix∙⁺jz = [ iRj ] ∷ xR⁺z ∷ []
203203

204-
¬ix⁺∙jz : ¬ Plus′ (IPointwise _R_) ix jz
204+
¬ix⁺∙jz : ¬ TransClosure (IPointwise _R_) ix jz
205205
¬ix⁺∙jz [ iRj ∷ () ∷ [] ]
206206
¬ix⁺∙jz ((iRj ∷ xRy ∷ []) ∷ [ () ∷ yRz ∷ [] ])
207207
¬ix⁺∙jz ((iRj ∷ xRy ∷ []) ∷ (() ∷ yRz ∷ []) ∷ _)

src/Induction/WellFounded.agda

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ WfRec _<_ P x = ∀ y → y < x → P y
3939
data Acc {A : Set a} (_<_ : Rel A ℓ) (x : A) : Set (a ⊔ ℓ) where
4040
acc : (rs : WfRec _<_ (Acc _<_) x) Acc _<_ x
4141

42-
acc-inverse : {_<_ : Rel A ℓ} {x : A} (q : Acc _<_ x)
43-
(y : A) y < x Acc _<_ y
44-
acc-inverse (acc rs) y y<x = rs y y<x
45-
4642
-- The accessibility predicate encodes what it means to be
4743
-- well-founded; if all elements are accessible, then _<_ is
4844
-- well-founded.
@@ -59,6 +55,10 @@ Please use WellFounded instead."
5955
------------------------------------------------------------------------
6056
-- Basic properties
6157

58+
acc-inverse : {_<_ : Rel A ℓ} {x : A} (q : Acc _<_ x)
59+
(y : A) y < x Acc _<_ y
60+
acc-inverse (acc rs) y y<x = rs y y<x
61+
6262
Acc-resp-≈ : {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} Symmetric _≈_
6363
_<_ Respectsʳ _≈_ (Acc _<_) Respects _≈_
6464
Acc-resp-≈ sym respʳ x≈y (acc rec) =
@@ -146,6 +146,9 @@ module Subrelation {_<₁_ : Rel A ℓ₁} {_<₂_ : Rel A ℓ₂}
146146
\ \Please use wellFounded instead."
147147
#-}
148148

149+
150+
-- DEPRECATED in v1.4.
151+
-- Please use proofs in `Relation.Binary.Construct.On` instead.
149152
module InverseImage {_<_ : Rel B ℓ} (f : A B) where
150153

151154
accessible : {x} Acc _<_ (f x) Acc (_<_ on f) x
@@ -168,6 +171,9 @@ module InverseImage {_<_ : Rel B ℓ} (f : A → B) where
168171
\ \Please use wellFounded from `Relation.Binary.Construct.On` instead."
169172
#-}
170173

174+
175+
-- DEPRECATED in v1.5.
176+
-- Please use `TransClosure` from `Relation.Binary.Construct.Closure.Transitive` instead.
171177
module TransitiveClosure {A : Set a} (_<_ : Rel A ℓ) where
172178

173179
infix 4 _<⁺_
@@ -192,15 +198,17 @@ module TransitiveClosure {A : Set a} (_<_ : Rel A ℓ) where
192198
wellFounded : WellFounded _<_ WellFounded _<⁺_
193199
wellFounded wf = λ x accessible (wf x)
194200

201+
{-# WARNING_ON_USAGE _<⁺_
202+
"Warning: _<⁺_ was deprecated in v1.5.
203+
\ \Please use TransClosure from Relation.Binary.Construct.Closure.Transitive instead."
204+
#-}
195205
downwards-closed = downwardsClosed
196206
{-# WARNING_ON_USAGE downwards-closed
197-
"Warning: downwards-closed was deprecated in v0.15.
198-
\ \Please use downwardsClosed instead."
207+
"Warning: downwards-closed was deprecated in v0.15."
199208
#-}
200209
well-founded = wellFounded
201210
{-# WARNING_ON_USAGE well-founded
202-
"Warning: well-founded was deprecated in v0.15.
203-
\ \Please use wellFounded instead."
211+
"Warning: well-founded was deprecated in v0.15."
204212
#-}
205213

206214

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

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,40 @@
1010
module Relation.Binary.Construct.Closure.Equivalence where
1111

1212
open import Function using (flip; id; _∘_)
13-
open import Level using (_⊔_)
13+
open import Level using (Level; _⊔_)
1414
open import Relation.Binary
1515
open import Relation.Binary.Construct.Closure.ReflexiveTransitive as Star
1616
using (Star; ε; _◅◅_; reverse)
17-
open import Relation.Binary.Construct.Closure.Symmetric as SC using (SymClosure)
17+
open import Relation.Binary.Construct.Closure.Symmetric as SC
18+
using (SymClosure)
19+
20+
private
21+
variable
22+
a ℓ ℓ₁ ℓ₂ : Level
23+
A B : Set a
1824

1925
------------------------------------------------------------------------
2026
-- Definition
2127

22-
EqClosure : {a ℓ} {A : Set a} Rel A ℓ Rel A (a ⊔ ℓ)
28+
EqClosure : {A : Set a} Rel A ℓ Rel A (a ⊔ ℓ)
2329
EqClosure _∼_ = Star (SymClosure _∼_)
2430

2531
------------------------------------------------------------------------
26-
-- Equivalence closures are equivalences.
32+
-- Operations
2733

28-
module _ {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) where
34+
-- A generalised variant of map which allows the index type to change.
35+
gmap : {P : Rel A ℓ₁} {Q : Rel B ℓ₂}
36+
(f : A B) P =[ f ]⇒ Q EqClosure P =[ f ]⇒ EqClosure Q
37+
gmap {Q = Q} f = Star.gmap f ∘ SC.gmap {Q = Q} f
38+
39+
map : {P : Rel A ℓ₁} {Q : Rel A ℓ₂}
40+
P ⇒ Q EqClosure P ⇒ EqClosure Q
41+
map = gmap id
42+
43+
------------------------------------------------------------------------
44+
-- Properties
45+
46+
module _ (_∼_ : Rel A ℓ) where
2947

3048
reflexive : Reflexive (EqClosure _∼_)
3149
reflexive = ε
@@ -43,23 +61,8 @@ module _ {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) where
4361
; trans = transitive
4462
}
4563

46-
setoid : Setoid a (a ⊔ ℓ)
47-
setoid = record
48-
{ _≈_ = EqClosure _∼_
49-
; isEquivalence = isEquivalence
50-
}
51-
52-
------------------------------------------------------------------------
53-
-- Operations
54-
55-
module _ {a ℓ₁ ℓ₂} {A : Set a} where
56-
57-
-- A generalised variant of map which allows the index type to change.
58-
59-
gmap : {b} {B : Set b} {P : Rel A ℓ₁} {Q : Rel B ℓ₂}
60-
(f : A B) P =[ f ]⇒ Q EqClosure P =[ f ]⇒ EqClosure Q
61-
gmap {Q = Q} f = Star.gmap f ∘ SC.gmap {Q = Q} f
62-
63-
map : {P : Rel A ℓ₁} {Q : Rel A ℓ₂}
64-
P ⇒ Q EqClosure P ⇒ EqClosure Q
65-
map = gmap id
64+
setoid : {A : Set a} (_∼_ : Rel A ℓ) Setoid a (a ⊔ ℓ)
65+
setoid _∼_ = record
66+
{ _≈_ = EqClosure _∼_
67+
; isEquivalence = isEquivalence _∼_
68+
}

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

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,65 @@ open import Relation.Binary
1515
open import Relation.Binary.Construct.Constant using (Const)
1616
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl)
1717

18+
private
19+
variable
20+
a ℓ ℓ₁ ℓ₂ : Level
21+
A B : Set a
22+
1823
------------------------------------------------------------------------
19-
-- Reflexive closure
24+
-- Definition
2025

21-
data Refl {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) : Rel A (a ⊔ ℓ) where
22-
[_] : {x y} (x∼y : x ∼ y) Refl _∼_ x y
23-
refl : Reflexive (Refl _∼_)
26+
data ReflClosure {A : Set a} (_∼_ : Rel A ℓ) : Rel A (a ⊔ ℓ) where
27+
refl : Reflexive (ReflClosure _∼_)
28+
[_] : {x y} (x∼y : x ∼ y) ReflClosure _∼_ x y
2429

25-
[]-injective : {a ℓ} {A : Set a} {_∼_ : Rel A ℓ} {x y p q}
26-
(Refl _∼_ x y ∋ [ p ]) ≡ [ q ] p ≡ q
27-
[]-injective refl = refl
30+
------------------------------------------------------------------------
31+
-- Operations
2832

29-
-- Map.
33+
map : {R : Rel A ℓ₁} {S : Rel B ℓ₂} {f : A B}
34+
R =[ f ]⇒ S ReflClosure R =[ f ]⇒ ReflClosure S
35+
map R⇒S [ xRy ] = [ R⇒S xRy ]
36+
map R⇒S refl = refl
3037

31-
map : {a a′ ℓ ℓ′} {A : Set a} {A′ : Set a′}
32-
{_R_ : Rel A ℓ} {_R′_ : Rel A′ ℓ′} {f : A A′}
33-
_R_ =[ f ]⇒ _R′_ Refl _R_ =[ f ]⇒ Refl _R′_
34-
map R⇒R′ [ xRy ] = [ R⇒R′ xRy ]
35-
map R⇒R′ refl = refl
38+
------------------------------------------------------------------------
39+
-- Properties
3640

3741
-- The reflexive closure has no effect on reflexive relations.
38-
39-
drop-refl : {a ℓ} {A : Set a} {_R_ : Rel A ℓ}
40-
Reflexive _R_ Refl _R_ ⇒ _R_
41-
drop-refl rfl [ x∼y ] = x∼y
42+
drop-refl : {R : Rel A ℓ} Reflexive R ReflClosure R ⇒ R
43+
drop-refl rfl [ xRy ] = xRy
4244
drop-refl rfl refl = rfl
4345

46+
[]-injective : {R : Rel A ℓ} {x y p q}
47+
(ReflClosure R x y ∋ [ p ]) ≡ [ q ] p ≡ q
48+
[]-injective refl = refl
49+
4450
------------------------------------------------------------------------
45-
-- Example: Maybe
51+
-- Example usage
4652

47-
module Maybe where
53+
private
54+
module Maybe where
55+
Maybe : Set a Set a
56+
Maybe A = ReflClosure (Const A) tt tt
57+
58+
nothing : Maybe A
59+
nothing = refl
60+
61+
just : A Maybe A
62+
just = [_]
63+
64+
65+
66+
------------------------------------------------------------------------
67+
-- Deprecations
68+
------------------------------------------------------------------------
69+
-- Please use the new names as continuing support for the old names is
70+
-- not guaranteed.
4871

49-
Maybe : {ℓ} Set Set
50-
Maybe A = Refl (Const A) tt tt
72+
-- v1.5
5173

52-
nothing : {a} {A : Set a} Maybe A
53-
nothing = refl
74+
Refl = ReflClosure
75+
{-# WARNING_ON_USAGE Refl
76+
"Warning: Refl was deprecated in v1.5.
77+
Please use ReflClosure instead."
78+
#-}
5479

55-
just : {a} {A : Set a} A Maybe A
56-
just = [_]

0 commit comments

Comments
 (0)