Skip to content

Commit eb5f308

Browse files
MatthewDaggittjamesmckinna
authored andcommitted
Added remaining flipped and negated relations to binary relation bundles (agda#2162)
1 parent c5a3693 commit eb5f308

File tree

9 files changed

+144
-63
lines changed

9 files changed

+144
-63
lines changed

CHANGELOG.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,24 @@ Non-backwards compatible changes
852852
IO.Instances
853853
```
854854

855-
### (Issue #2096) Introduction of flipped relation symbol for `Relation.Binary.Bundles.Preorder`
856-
857-
* Previously, the relation symbol `_∼_` was (notationally) symmetric, so that its
858-
converse relation could only be discussed *semantically* in terms of `flip _∼_`
859-
in `Relation.Binary.Properties.Preorder`, `Relation.Binary.Construct.Flip.{Ord|EqAndOrd}`
860-
861-
* Now, the symbol `_∼_` has been renamed to a new symbol `_≲_`, with `_≳_`
862-
introduced as a definition in `Relation.Binary.Bundles.Preorder` whose properties
863-
in `Relation.Binary.Properties.Preorder` now refer to it. Partial backwards compatible
864-
has been achieved by redeclaring a deprecated version of the old name in the record.
865-
Therefore, only _declarations_ of `PartialOrder` records will need their field names
866-
updating.
855+
### (Issue #2096) Introduction of flipped and negated relation symbols to bundles in `Relation.Binary.Bundles`
856+
857+
* Previously, bundles such as `Preorder`, `Poset`, `TotalOrder` etc. did not have the flipped
858+
and negated versions of the operators exposed. In some cases they could obtained by opening the
859+
relevant `Relation.Binary.Properties.X` file but usually they had to be redefined every time.
860+
861+
* To fix this, these bundles now all export all 4 versions of the operator: normal, converse, negated,
862+
converse-negated. Accordingly they are no longer exported from the corresponding `Properties` file.
863+
864+
* To make this work for `Preorder`, it was necessary to change the name of the relation symbol.
865+
Previously, the symbol was `_∼_` which is (notationally) symmetric, so that its
866+
converse relation could only be discussed *semantically* in terms of `flip _∼_`.
867+
868+
* Now, the `Preorder` record field `_∼_` has been renamed to `_≲_`, with `_≳_`
869+
introduced as a definition in `Relation.Binary.Bundles.Preorder`.
870+
Partial backwards compatible has been achieved by redeclaring a deprecated version
871+
of the old symbol in the record. Therefore, only _declarations_ of `PartialOrder` records will
872+
need their field names updating.
867873

868874
### (Issue #1214) Reorganisation of the introduction of negated relation symbols under `Relation.Binary`
869875

README/Design/Hierarchies.agda

+37
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,43 @@ record Semigroup : Set (suc (a ⊔ ℓ)) where
249249
-- differently, as a function with an unknown domain an codomain is
250250
-- of little use.
251251

252+
-------------------------
253+
-- Bundle re-exporting --
254+
-------------------------
255+
256+
-- In general ensuring that bundles re-export everything in their
257+
-- sub-bundles can get a little tricky.
258+
259+
-- Imagine we have the following general scenario where bundle A is a
260+
-- direct refinement of bundle C (i.e. the record `IsA` has a `IsC` field)
261+
-- but is also morally a refinement of bundles B and D.
262+
263+
-- Structures Bundles
264+
-- ========== =======
265+
-- IsA A
266+
-- / || \ / || \
267+
-- IsB IsC IsD B C D
268+
269+
-- The procedure for re-exports in the bundles is as follows:
270+
271+
-- 1. `open IsA isA public using (IsC, M)` where `M` is everything
272+
-- exported by `IsA` that is not exported by `IsC`.
273+
274+
-- 2. Construct `c : C` via the `isC` obtained in step 1.
275+
276+
-- 3. `open C c public hiding (N)` where `N` is the list of fields
277+
-- shared by both `A` and `C`.
278+
279+
-- 4. Construct `b : B` via the `isB` obtained in step 1.
280+
281+
-- 5. `open B b public using (O)` where `O` is everything exported
282+
-- by `B` but not exported by `IsA`.
283+
284+
-- 6. Construct `d : D` via the `isC` obtained in step 1.
285+
286+
-- 7. `open D d public using (P)` where `P` is everything exported
287+
-- by `D` but not exported by `IsA`
288+
252289
------------------------------------------------------------------------
253290
-- Other hierarchy modules
254291
------------------------------------------------------------------------

src/Algebra/Lattice/Properties/Semilattice.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import Relation.Binary.Construct.NaturalOrder.Left _≈_ _∧_
2727
poset : Poset c ℓ ℓ
2828
poset = LeftNaturalOrder.poset isSemilattice
2929

30-
open Poset poset using (_≤_; isPartialOrder)
31-
open PosetProperties poset using (_≥_; ≥-isPartialOrder)
30+
open Poset poset using (_≤_; _≥_; isPartialOrder)
31+
open PosetProperties poset using (≥-isPartialOrder)
3232

3333
------------------------------------------------------------------------
3434
-- Every algebraic semilattice can be turned into an order-theoretic one.

src/Data/Product/Relation/Binary/Lex/Strict.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ module _ {_≈₁_ : Rel A ℓ₁} {_<₁_ : Rel A ℓ₂}
240240
(isEquivalence pre₁) (isEquivalence pre₂)
241241
; reflexive = ×-reflexive _≈₁_ _<₁_ _<₂_ (reflexive pre₂)
242242
; trans = ×-transitive {_<₂_ = _<₂_}
243-
(isEquivalence pre₁) (-resp-≈ pre₁)
243+
(isEquivalence pre₁) (-resp-≈ pre₁)
244244
(trans pre₁) (trans pre₂)
245245
}
246246
where open IsPreorder

src/Relation/Binary/Bundles.agda

+61-27
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where
4343
isEquivalence : IsEquivalence _≈_
4444

4545
open IsEquivalence isEquivalence public
46+
using (refl; reflexive; isPartialEquivalence)
4647

4748
partialSetoid : PartialSetoid c ℓ
4849
partialSetoid = record
4950
{ isPartialEquivalence = isPartialEquivalence
5051
}
5152

52-
open PartialSetoid partialSetoid public using (_≉_)
53+
open PartialSetoid partialSetoid public
54+
hiding (Carrier; _≈_; isPartialEquivalence)
5355

5456

5557
record DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where
@@ -60,14 +62,15 @@ record DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where
6062
isDecEquivalence : IsDecEquivalence _≈_
6163

6264
open IsDecEquivalence isDecEquivalence public
65+
using (_≟_; isEquivalence)
6366

6467
setoid : Setoid c ℓ
6568
setoid = record
6669
{ isEquivalence = isEquivalence
6770
}
6871

69-
open Setoid setoid public using (partialSetoid; _≉_)
70-
72+
open Setoid setoid public
73+
hiding (Carrier; _≈_; isEquivalence)
7174

7275
------------------------------------------------------------------------
7376
-- Preorders
@@ -99,6 +102,9 @@ record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
99102
infix 4 _≳_
100103
_≳_ = flip _≲_
101104

105+
infix 4 _⋧_
106+
_⋧_ = flip _⋦_
107+
102108
-- Deprecated.
103109
infix 4 _∼_
104110
_∼_ = _≲_
@@ -117,14 +123,15 @@ record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
117123
isTotalPreorder : IsTotalPreorder _≈_ _≲_
118124

119125
open IsTotalPreorder isTotalPreorder public
120-
hiding (module Eq)
126+
using (total; isPreorder)
121127

122128
preorder : Preorder c ℓ₁ ℓ₂
123-
preorder = record { isPreorder = isPreorder }
129+
preorder = record
130+
{ isPreorder = isPreorder
131+
}
124132

125133
open Preorder preorder public
126-
using (module Eq; _≳_; _⋦_)
127-
134+
hiding (Carrier; _≈_; _≲_; isPreorder)
128135

129136
------------------------------------------------------------------------
130137
-- Partial orders
@@ -139,16 +146,21 @@ record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
139146
isPartialOrder : IsPartialOrder _≈_ _≤_
140147

141148
open IsPartialOrder isPartialOrder public
142-
hiding (module Eq)
149+
using (antisym; isPreorder)
143150

144151
preorder : Preorder c ℓ₁ ℓ₂
145152
preorder = record
146153
{ isPreorder = isPreorder
147154
}
148155

149156
open Preorder preorder public
150-
using (module Eq)
151-
renaming (_⋦_ to _≰_)
157+
hiding (Carrier; _≈_; _≲_; isPreorder)
158+
renaming
159+
( _⋦_ to _≰_; _≳_ to _≥_; _⋧_ to _≱_
160+
; ≲-respˡ-≈ to ≤-respˡ-≈
161+
; ≲-respʳ-≈ to ≤-respʳ-≈
162+
; ≲-resp-≈ to ≤-resp-≈
163+
)
152164

153165

154166
record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
@@ -159,17 +171,18 @@ record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
159171
_≤_ : Rel Carrier ℓ₂
160172
isDecPartialOrder : IsDecPartialOrder _≈_ _≤_
161173

162-
private
163-
module DPO = IsDecPartialOrder isDecPartialOrder
164-
open DPO public hiding (module Eq)
174+
private module DPO = IsDecPartialOrder isDecPartialOrder
175+
176+
open DPO public
177+
using (_≟_; _≤?_; isPartialOrder)
165178

166179
poset : Poset c ℓ₁ ℓ₂
167180
poset = record
168181
{ isPartialOrder = isPartialOrder
169182
}
170183

171184
open Poset poset public
172-
using (preorder; _≰_)
185+
hiding (Carrier; _≈_; _≤_; isPartialOrder; module Eq)
173186

174187
module Eq where
175188
decSetoid : DecSetoid c ℓ₁
@@ -203,6 +216,12 @@ record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂))
203216
_≮_ : Rel Carrier _
204217
x ≮ y = ¬ (x < y)
205218

219+
infix 4 _>_
220+
_>_ = flip _<_
221+
222+
infix 4 _≯_
223+
_≯_ = flip _≮_
224+
206225

207226
record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
208227
infix 4 _≈_ _<_
@@ -212,17 +231,18 @@ record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂
212231
_<_ : Rel Carrier ℓ₂
213232
isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_
214233

215-
private
216-
module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder
217-
open DSPO public hiding (module Eq)
234+
private module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder
235+
236+
open DSPO public
237+
using (_<?_; _≟_; isStrictPartialOrder)
218238

219239
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
220240
strictPartialOrder = record
221241
{ isStrictPartialOrder = isStrictPartialOrder
222242
}
223243

224244
open StrictPartialOrder strictPartialOrder public
225-
using (_≮_)
245+
hiding (Carrier; _≈_; _<_; isStrictPartialOrder; module Eq)
226246

227247
module Eq where
228248

@@ -247,15 +267,15 @@ record TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
247267
isTotalOrder : IsTotalOrder _≈_ _≤_
248268

249269
open IsTotalOrder isTotalOrder public
250-
hiding (module Eq)
270+
using (total; isPartialOrder; isTotalPreorder)
251271

252272
poset : Poset c ℓ₁ ℓ₂
253273
poset = record
254274
{ isPartialOrder = isPartialOrder
255275
}
256276

257277
open Poset poset public
258-
using (module Eq; preorder; _≰_)
278+
hiding (Carrier; _≈_; _≤_; isPartialOrder)
259279

260280
totalPreorder : TotalPreorder c ℓ₁ ℓ₂
261281
totalPreorder = record
@@ -271,17 +291,18 @@ record DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
271291
_≤_ : Rel Carrier ℓ₂
272292
isDecTotalOrder : IsDecTotalOrder _≈_ _≤_
273293

274-
private
275-
module DTO = IsDecTotalOrder isDecTotalOrder
276-
open DTO public hiding (module Eq)
294+
private module DTO = IsDecTotalOrder isDecTotalOrder
295+
296+
open DTO public
297+
using (_≟_; _≤?_; isTotalOrder; isDecPartialOrder)
277298

278299
totalOrder : TotalOrder c ℓ₁ ℓ₂
279300
totalOrder = record
280301
{ isTotalOrder = isTotalOrder
281302
}
282303

283304
open TotalOrder totalOrder public
284-
using (poset; preorder; _≰_)
305+
hiding (Carrier; _≈_; _≤_; isTotalOrder; module Eq)
285306

286307
decPoset : DecPoset c ℓ₁ ℓ₂
287308
decPoset = record
@@ -306,25 +327,37 @@ record StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) wh
306327
isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_
307328

308329
open IsStrictTotalOrder isStrictTotalOrder public
309-
hiding (module Eq)
330+
using
331+
( _≟_; _<?_; compare; isStrictPartialOrder
332+
; isDecStrictPartialOrder; isDecEquivalence
333+
)
310334

311335
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
312336
strictPartialOrder = record
313337
{ isStrictPartialOrder = isStrictPartialOrder
314338
}
315339

316340
open StrictPartialOrder strictPartialOrder public
317-
using (module Eq; _≮_)
341+
hiding (Carrier; _≈_; _<_; isStrictPartialOrder; module Eq)
342+
343+
decStrictPartialOrder : DecStrictPartialOrder c ℓ₁ ℓ₂
344+
decStrictPartialOrder = record
345+
{ isDecStrictPartialOrder = isDecStrictPartialOrder
346+
}
347+
348+
open DecStrictPartialOrder decStrictPartialOrder public
349+
using (module Eq)
318350

319351
decSetoid : DecSetoid c ℓ₁
320352
decSetoid = record
321-
{ isDecEquivalence = isDecEquivalence
353+
{ isDecEquivalence = Eq.isDecEquivalence
322354
}
323355
{-# WARNING_ON_USAGE decSetoid
324356
"Warning: decSetoid was deprecated in v1.3.
325357
Please use Eq.decSetoid instead."
326358
#-}
327359

360+
328361
record DenseLinearOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
329362
infix 4 _≈_ _<_
330363
field
@@ -342,6 +375,7 @@ record DenseLinearOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) wh
342375
}
343376

344377
open StrictTotalOrder strictTotalOrder public
378+
hiding (Carrier; _≈_; _<_; isStrictTotalOrder)
345379

346380

347381
------------------------------------------------------------------------

src/Relation/Binary/Properties/DecTotalOrder.agda

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ open import Relation.Nullary.Negation using (¬_)
2626

2727
open TotalOrderProperties public
2828
using
29-
( _≥_
30-
; ≥-refl
29+
( ≥-refl
3130
; ≥-reflexive
3231
; ≥-trans
3332
; ≥-antisym

src/Relation/Binary/Properties/Poset.agda

-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ open Eq using (_≉_)
3030
------------------------------------------------------------------------
3131
-- The _≥_ relation is also a poset.
3232

33-
infix 4 _≥_
34-
35-
_≥_ : Rel A p₃
36-
x ≥ y = y ≤ x
37-
3833
open PreorderProperties public
3934
using () renaming
4035
( converse-isPreorder to ≥-isPreorder

src/Relation/Binary/Properties/TotalOrder.agda

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ decTotalOrder ≟ = record
3939

4040
open PosetProperties public
4141
using
42-
( _≥_
43-
; ≥-refl
42+
( ≥-refl
4443
; ≥-reflexive
4544
; ≥-trans
4645
; ≥-antisym
@@ -59,7 +58,7 @@ open PosetProperties public
5958
}
6059

6160
open TotalOrder ≥-totalOrder public
62-
using () renaming (total to ≥-total; _≰_ to _≱_)
61+
using () renaming (total to ≥-total)
6362

6463
------------------------------------------------------------------------
6564
-- _<_ - the strict version is a strict partial order

0 commit comments

Comments
 (0)