Skip to content

Commit 54876a5

Browse files
authored
[fixes #1214] Add negated ordering relation symbols systematically to Relation.Binary.* (#2095)
1 parent 37c05ee commit 54876a5

File tree

8 files changed

+79
-62
lines changed

8 files changed

+79
-62
lines changed

CHANGELOG.md

+38-19
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ Non-backwards compatible changes
621621
raw bundles to `Data.X.Base`, this definition can now be made directly. Knock-on
622622
consequences include the need to retain the old constructor name, now introduced
623623
as a pattern synonym, and introduction of (a function equivalent to) the former
624-
field name/projection function `proof` as `≤″-proof` in `Data.Nat.Properties`.
624+
field name/projection function `proof` as `≤″-proof` in `Data.Nat.Properties`.
625625

626626
* Accordingly, the definition has been changed to:
627627
```agda
@@ -842,7 +842,6 @@ Non-backwards compatible changes
842842
IO.Effectful
843843
IO.Instances
844844
```
845-
846845
### (Issue #2096) Introduction of flipped relation symbol for `Relation.Binary.Bundles.Preorder`
847846

848847
* Previously, the relation symbol `_∼_` was (notationally) symmetric, so that its
@@ -856,9 +855,25 @@ Non-backwards compatible changes
856855
Therefore, only _declarations_ of `PartialOrder` records will need their field names
857856
updating.
858857

859-
* NB (issues #1214 #2098) the corresponding situation regarding the `flip`ped
860-
relation symbols `_≥_`, `_>_` (and their negated versions!) has not (yet)
861-
been addressed.
858+
### (Issue #1214) Reorganisation of the introduction of negated relation symbols under `Relation.Binary`
859+
860+
* Previously, negated relation symbols `_≰_` (for `Poset`) and `_≮_` (`TotalOrder`)
861+
were introduced in the corresponding `Relation.Binary.Properties` modules, for re-export.
862+
863+
* Now they are introduced as definitions in the corresponding `Relation.Binary.Bundles`,
864+
together with, for uniformity's sake, an additional negated symbol `_⋦_` for `Preorder`,
865+
with their (obvious) intended semantics:
866+
```agda
867+
infix 4 _⋦_ _≰_ _≮_
868+
Preorder._⋦_ : Rel Carrier _
869+
StrictPartialOrder._≮_ : Rel Carrier _
870+
```
871+
Additionally, `Poset._≰_` is defined by renaming public export of `Preorder._⋦_`
872+
873+
* Backwards compatibility has been maintained, with deprecated definitions in the
874+
corresponding `Relation.Binary.Properties` modules, and the corresponding client
875+
client module `import`s being adjusted accordingly.
876+
862877

863878
### Standardisation of `insertAt`/`updateAt`/`removeAt`
864879

@@ -879,12 +894,12 @@ Non-backwards compatible changes
879894
```
880895
_─_ ↦ removeAt
881896
```
882-
897+
883898
* In `Data.Vec.Base`:
884899
```agda
885900
insert ↦ insertAt
886901
remove ↦ removeAt
887-
902+
888903
updateAt : Fin n → (A → A) → Vec A n → Vec A n
889904
890905
updateAt : Vec A n → Fin n → (A → A) → Vec A n
@@ -895,12 +910,12 @@ Non-backwards compatible changes
895910
remove : Fin (suc n) → Vector A (suc n) → Vector A n
896911
897912
removeAt : Vector A (suc n) → Fin (suc n) → Vector A n
898-
913+
899914
updateAt : Fin n → (A → A) → Vector A n → Vector A n
900915
901916
updateAt : Vector A n → Fin n → (A → A) → Vector A n
902917
```
903-
918+
904919
* The old names (and the names of all proofs about these functions) have been deprecated appropriately.
905920

906921
### Changes to triple reasoning interface
@@ -1659,7 +1674,7 @@ Deprecated names
16591674
take-drop-id ↦ take++drop≡id
16601675
16611676
map-insert ↦ map-insertAt
1662-
1677+
16631678
insert-lookup ↦ insertAt-lookup
16641679
insert-punchIn ↦ insertAt-punchIn
16651680
remove-PunchOut ↦ removeAt-punchOut
@@ -1685,7 +1700,7 @@ Deprecated names
16851700
updateAt-cong-relative ↦ updateAt-cong-local
16861701
16871702
map-updateAt ↦ map-updateAt-local
1688-
1703+
16891704
insert-lookup ↦ insertAt-lookup
16901705
insert-punchIn ↦ insertAt-punchIn
16911706
remove-punchOut ↦ removeAt-punchOut
@@ -1743,11 +1758,6 @@ Deprecated names
17431758
fromForeign ↦ Foreign.Haskell.Coerce.coerce
17441759
```
17451760

1746-
* In `Relation.Binary.Bundles.Preorder`:
1747-
```
1748-
_∼_ ↦ _≲_
1749-
```
1750-
17511761
* In `Relation.Binary.Indexed.Heterogeneous.Bundles.Preorder`:
17521762
```
17531763
_∼_ ↦ _≲_
@@ -1759,6 +1769,15 @@ Deprecated names
17591769
invPreorder ↦ converse-preorder
17601770
```
17611771

1772+
* Moved negated relation symbol from `Relation.Binary.Properties.Poset`:
1773+
```
1774+
_≰_ ↦ Relation.Binary.Bundles.Poset._≰_
1775+
```
1776+
1777+
* Moved negated relation symbol from `Relation.Binary.Properties.TotalOrder`:
1778+
```
1779+
_≮_ ↦ Relation.Binary.Bundles.StrictPartialOrder._≮_
1780+
17621781
* In `Relation.Nullary.Decidable.Core`:
17631782
```
17641783
excluded-middle ↦ ¬¬-excluded-middle
@@ -3301,9 +3320,9 @@ Additions to existing modules
33013320

33023321
* Added new proofs to `Relation.Binary.Consequences`:
33033322
```
3304-
sym⇒¬-sym : Symmetric _∼_ → Symmetric _≁_
3305-
cotrans⇒¬-trans : Cotransitive _∼_ → Transitive _≁_
3306-
irrefl⇒¬-refl : Reflexive _≈_ → Irreflexive _≈_ _∼_ → Reflexive _≁_
3323+
sym⇒¬-sym : Symmetric _∼_ → Symmetric (¬_ ∘₂ _∼_)
3324+
cotrans⇒¬-trans : Cotransitive _∼_ → Transitive (¬_ ∘₂ _∼_)
3325+
irrefl⇒¬-refl : Reflexive _≈_ → Irreflexive _≈_ _∼_ → Reflexive (¬_ ∘₂ _∼_)
33073326
mono₂⇒cong₂ : Symmetric ≈₁ → ≈₁ ⇒ ≤₁ → Antisymmetric ≈₂ ≤₂ → ∀ {f} →
33083327
f Preserves₂ ≤₁ ⟶ ≤₁ ⟶ ≤₂ →
33093328
f Preserves₂ ≈₁ ⟶ ≈₁ ⟶ ≈₂

src/Data/List/Sort/MergeSort.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open import Data.List.Relation.Binary.Permutation.Propositional
2121
import Data.List.Relation.Binary.Permutation.Propositional.Properties as Perm
2222
open import Data.Maybe.Base using (just)
2323
open import Relation.Nullary.Decidable using (does)
24-
open import Data.Nat using (_<_; _>_; z<s; s<s)
24+
open import Data.Nat.Base using (_<_; _>_; z<s; s<s)
2525
open import Data.Nat.Induction
2626
open import Data.Nat.Properties using (m<n⇒m<1+n)
2727
open import Data.Product.Base as Prod using (_,_)
@@ -36,7 +36,7 @@ open DecTotalOrder O renaming (Carrier to A)
3636

3737
open import Data.List.Sort.Base totalOrder
3838
open import Data.List.Relation.Unary.Sorted.TotalOrder totalOrder hiding (head)
39-
open import Relation.Binary.Properties.DecTotalOrder O using (_≰_; ≰⇒≥; ≰-respˡ-≈)
39+
open import Relation.Binary.Properties.DecTotalOrder O using (≰⇒≥; ≰-respˡ-≈)
4040

4141
open PermutationReasoning
4242

src/Relation/Binary/Bundles.agda

+26-22
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,20 @@ record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
9292

9393
open Setoid setoid public
9494

95+
infix 4 _⋦_
96+
_⋦_ : Rel Carrier _
97+
x ⋦ y = ¬ (x ≲ y)
98+
9599
infix 4 _≳_
96100
_≳_ = flip _≲_
97101

98-
infix 4 _∼_ -- for deprecation
102+
-- Deprecated.
103+
infix 4 _∼_
99104
_∼_ = _≲_
105+
{-# WARNING_ON_USAGE _∼_
106+
"Warning: _∼_ was deprecated in v2.0.
107+
Please use _≲_ instead. "
108+
#-}
100109

101110

102111
record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
@@ -114,7 +123,7 @@ record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
114123
preorder = record { isPreorder = isPreorder }
115124

116125
open Preorder preorder public
117-
using (module Eq; _≳_)
126+
using (module Eq; _≳_; _⋦_)
118127

119128

120129
------------------------------------------------------------------------
@@ -139,6 +148,7 @@ record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
139148

140149
open Preorder preorder public
141150
using (module Eq)
151+
renaming (_⋦_ to _≰_)
142152

143153

144154
record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
@@ -159,7 +169,7 @@ record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
159169
}
160170

161171
open Poset poset public
162-
using (preorder)
172+
using (preorder; _≰_)
163173

164174
module Eq where
165175
decSetoid : DecSetoid c ℓ₁
@@ -189,6 +199,10 @@ record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂))
189199

190200
open Setoid setoid public
191201

202+
infix 4 _≮_
203+
_≮_ : Rel Carrier _
204+
x ≮ y = ¬ (x < y)
205+
192206

193207
record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
194208
infix 4 _≈_ _<_
@@ -207,6 +221,9 @@ record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂
207221
{ isStrictPartialOrder = isStrictPartialOrder
208222
}
209223

224+
open StrictPartialOrder strictPartialOrder public
225+
using (_≮_)
226+
210227
module Eq where
211228

212229
decSetoid : DecSetoid c ℓ₁
@@ -238,7 +255,7 @@ record TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
238255
}
239256

240257
open Poset poset public
241-
using (module Eq; preorder)
258+
using (module Eq; preorder; _≰_)
242259

243260
totalPreorder : TotalPreorder c ℓ₁ ℓ₂
244261
totalPreorder = record
@@ -263,14 +280,16 @@ record DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
263280
{ isTotalOrder = isTotalOrder
264281
}
265282

266-
open TotalOrder totalOrder public using (poset; preorder)
283+
open TotalOrder totalOrder public
284+
using (poset; preorder; _≰_)
267285

268286
decPoset : DecPoset c ℓ₁ ℓ₂
269287
decPoset = record
270288
{ isDecPartialOrder = isDecPartialOrder
271289
}
272290

273-
open DecPoset decPoset public using (module Eq)
291+
open DecPoset decPoset public
292+
using (module Eq)
274293

275294

276295
-- Note that these orders are decidable. The current implementation
@@ -295,7 +314,7 @@ record StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) wh
295314
}
296315

297316
open StrictPartialOrder strictPartialOrder public
298-
using (module Eq)
317+
using (module Eq; _≮_)
299318

300319
decSetoid : DecSetoid c ℓ₁
301320
decSetoid = record
@@ -338,18 +357,3 @@ record ApartnessRelation c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) w
338357
isApartnessRelation : IsApartnessRelation _≈_ _#_
339358

340359
open IsApartnessRelation isApartnessRelation public
341-
342-
343-
344-
345-
------------------------------------------------------------------------
346-
-- DEPRECATED
347-
------------------------------------------------------------------------
348-
-- Please use the new names as continuing support for the old names is
349-
-- not guaranteed.
350-
351-
-- Version 2.0
352-
353-
{-# WARNING_ON_USAGE Preorder._∼_
354-
"Warning: Preorder._∼_ was deprecated in v2.0. Please use Preorder._≲_ instead. "
355-
#-}

src/Relation/Binary/Properties/DecTotalOrder.agda

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ open import Relation.Binary.Bundles
1212
using (DecTotalOrder; StrictTotalOrder)
1313

1414
module Relation.Binary.Properties.DecTotalOrder
15-
{d₁ d₂ d₃} (DT : DecTotalOrder d₁ d₂ d₃) where
15+
{d₁ d₂ d₃} (DTO : DecTotalOrder d₁ d₂ d₃) where
1616

17-
open DecTotalOrder DT hiding (trans)
17+
open DecTotalOrder DTO hiding (trans)
1818

1919
import Relation.Binary.Construct.Flip.EqAndOrd as EqAndOrd
2020
import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
@@ -80,19 +80,18 @@ open TotalOrderProperties public
8080
}
8181

8282
open StrictTotalOrder <-strictTotalOrder public
83-
using () renaming (compare to <-compare)
83+
using (_≮_) renaming (compare to <-compare)
8484

8585
------------------------------------------------------------------------
8686
-- _≰_ - the negated order
8787

8888
open TotalOrderProperties public
8989
using
90-
( _≰_
91-
; ≰-respʳ-≈
90+
( ≰-respʳ-≈
9291
; ≰-respˡ-≈
9392
; ≰⇒>
9493
; ≰⇒≥
9594
)
9695

97-
≮⇒≥ : {x y} ¬ (x < y) y ≤ x
96+
≮⇒≥ : {x y} x ≮ y y ≤ x
9897
≮⇒≥ = ToStrict.≮⇒≥ Eq.sym _≟_ reflexive total

src/Relation/Binary/Properties/Poset.agda

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9+
open import Data.Product.Base using (_,_)
910
open import Function.Base using (flip; _∘_)
1011
open import Relation.Binary.Core using (Rel; _Preserves_⟶_)
1112
open import Relation.Binary.Bundles using (Poset; StrictPartialOrder)
@@ -62,11 +63,6 @@ open Poset ≥-poset public
6263
------------------------------------------------------------------------
6364
-- Negated order
6465

65-
infix 4 _≰_
66-
67-
_≰_ : Rel A p₃
68-
x ≰ y = ¬ (x ≤ y)
69-
7066
≰-respˡ-≈ : _≰_ Respectsˡ _≈_
7167
≰-respˡ-≈ x≈y = _∘ ≤-respˡ-≈ (Eq.sym x≈y)
7268

@@ -90,7 +86,7 @@ _<_ = ToStrict._<_
9086
}
9187

9288
open StrictPartialOrder <-strictPartialOrder public
93-
using ( <-resp-≈; <-respʳ-≈; <-respˡ-≈)
89+
using (_≮_; <-resp-≈; <-respʳ-≈; <-respˡ-≈)
9490
renaming
9591
( irrefl to <-irrefl
9692
; asym to <-asym
@@ -103,10 +99,10 @@ open StrictPartialOrder <-strictPartialOrder public
10399
≤∧≉⇒< : {x y} x ≤ y x ≉ y x < y
104100
≤∧≉⇒< = ToStrict.≤∧≉⇒<
105101

106-
<⇒≱ : {x y} x < y ¬ (y ≤ x)
102+
<⇒≱ : {x y} x < y y ≰ x
107103
<⇒≱ = ToStrict.<⇒≱ antisym
108104

109-
≤⇒≯ : {x y} x ≤ y ¬ (y < x)
105+
≤⇒≯ : {x y} x ≤ y y ≮ x
110106
≤⇒≯ = ToStrict.≤⇒≯ antisym
111107

112108
------------------------------------------------------------------------

src/Relation/Binary/Properties/StrictPartialOrder.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Relation.Binary.Construct.StrictToNonStrict
1717
open StrictPartialOrder SPO
1818

1919
------------------------------------------------------------------------
20-
-- The inverse relation is also a strict partial order.
20+
-- The converse relation is also a strict partial order.
2121

2222
>-strictPartialOrder : StrictPartialOrder s₁ s₂ s₃
2323
>-strictPartialOrder = EqAndOrd.strictPartialOrder SPO

src/Relation/Binary/Properties/StrictTotalOrder.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Relation.Binary.Properties.StrictPartialOrder as SPO
1818
open import Relation.Binary.Consequences
1919

2020
------------------------------------------------------------------------
21-
-- _<_ - the strict version is a strict total order
21+
-- _<_ - the strict version is a decidable total order
2222

2323
decTotalOrder : DecTotalOrder _ _ _
2424
decTotalOrder = record

src/Relation/Binary/Properties/TotalOrder.agda

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ open PosetProperties public
5959
}
6060

6161
open TotalOrder ≥-totalOrder public
62-
using () renaming (total to ≥-total)
62+
using () renaming (total to ≥-total; _≰_ to _≱_)
6363

6464
------------------------------------------------------------------------
6565
-- _<_ - the strict version is a strict partial order
@@ -90,8 +90,7 @@ open PosetProperties public
9090

9191
open PosetProperties public
9292
using
93-
( _≰_
94-
; ≰-respʳ-≈
93+
( ≰-respʳ-≈
9594
; ≰-respˡ-≈
9695
)
9796

0 commit comments

Comments
 (0)