Skip to content

[fixes #1214] Add negated ordering relation symbols systematically to Relation.Binary.* #2095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
72fb46f
choosing precedence = 4
jamesmckinna Sep 15, 2023
ba82a9d
knock-on changes
jamesmckinna Sep 15, 2023
568ffc3
knock-on changes
jamesmckinna Sep 15, 2023
3e022d6
refactored `Poset` to rename field from `Preorder`
jamesmckinna Sep 15, 2023
cfb537a
further propagation of the negated relations
jamesmckinna Sep 15, 2023
e7d0179
now the relations are definitionally equal
jamesmckinna Sep 15, 2023
b38f78e
fix-whitespace
jamesmckinna Sep 15, 2023
d16f453
one more knock-on import change
jamesmckinna Sep 15, 2023
80b71b7
`TotalOrder` now exports `_≱_`
jamesmckinna Sep 15, 2023
8c8fdf6
`Properties.Poset` now uses (renamed) `_≰_`
jamesmckinna Sep 15, 2023
593ee3d
much more extensive documentation
jamesmckinna Sep 16, 2023
5f1cbe9
replaced negated relation by its definitional equivalent
jamesmckinna Sep 16, 2023
91ac637
`inverse` should be `converse`
jamesmckinna Sep 16, 2023
1d8dd80
revised deprecations
jamesmckinna Sep 16, 2023
ae4be25
removed redundant `private` block
jamesmckinna Sep 16, 2023
6ba0381
revised deprecation strategy, again
jamesmckinna Sep 16, 2023
5575ab4
revised forward pointer to issues #2096 #2098
jamesmckinna Sep 16, 2023
b730e8d
cosmetic symbol change, plus updated `CHANGELOG` to describe it
jamesmckinna Sep 16, 2023
3fb6e33
Merge branch 'master' into issue1214
jamesmckinna Oct 2, 2023
4b52284
revised `CHANGELOG` after merge of #2114
jamesmckinna Oct 4, 2023
a8a8162
Merge branch 'master' into issue1214
jamesmckinna Oct 4, 2023
ec79e09
further revised `CHANGELOG` after merge of #2114
jamesmckinna Oct 4, 2023
d4f2c79
further revised `CHANGELOG` after merge of #2099; erroneous prior com…
jamesmckinna Oct 4, 2023
3a354cf
further revised `CHANGELOG` after merge of #2099
jamesmckinna Oct 4, 2023
6fd62b0
further revised `CHANGELOG`: fixing notational errors
jamesmckinna Oct 4, 2023
d098a68
Merge branch 'master' into issue1214
jamesmckinna Oct 7, 2023
82f00dc
removed one extraneous `CHANGELOG` note
jamesmckinna Oct 7, 2023
8eb7271
removed one more extraneous `CHANGELOG` note
jamesmckinna Oct 7, 2023
1aaae22
removed one more extraneous `CHANGELOG` note
jamesmckinna Oct 7, 2023
cf720b3
removed one more extraneous `CHANGELOG` note: forward pointer to #2098
jamesmckinna Oct 7, 2023
c520340
removed one more extraneous `CHANGELOG` note: forward pointer to #2098
jamesmckinna Oct 7, 2023
dfc76ed
removed one more extraneous `CHANGELOG` note: NB
jamesmckinna Oct 7, 2023
c9e7010
removed one more extraneous `CHANGELOG` note: NB; plus relocated text
jamesmckinna Oct 7, 2023
976a1d6
removed one more extraneous `CHANGELOG` note: deprecation
jamesmckinna Oct 7, 2023
47bd7a8
Remove deprecations in Property files
MatthewDaggitt Oct 10, 2023
834ed4e
Fix DecTotalOrder
MatthewDaggitt Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ Non-backwards compatible changes
* The module `Function.Definitions` no longer has two equalities as module arguments, as
they did not interact as intended with the re-exports from `Function.Definitions.(Core1/Core2)`.
The latter have been removed and their definitions folded into `Function.Definitions`.
* In `Function.Definitions` the types of `Surjective`, `Injective` and `Surjective`

* In `Function.Definitions` the types of `Surjective`, `Injective` and `Surjective`
have been changed from:
```
Surjective f = ∀ y → ∃ λ x → f x ≈₂ y
Expand All @@ -370,16 +370,16 @@ Non-backwards compatible changes
```
This is for several reasons: i) the new definitions compose much more easily, ii) Agda
can better infer the equalities used.

To ease backwards compatibility:
- the old definitions have been moved to the new names `StrictlySurjective`,
`StrictlyInverseˡ` and `StrictlyInverseʳ`.
- The records in `Function.Structures` and `Function.Bundles` export proofs
of these under the names `strictlySurjective`, `strictlyInverseˡ` and
`strictlyInverseʳ`,
- the old definitions have been moved to the new names `StrictlySurjective`,
`StrictlyInverseˡ` and `StrictlyInverseʳ`.
- The records in `Function.Structures` and `Function.Bundles` export proofs
of these under the names `strictlySurjective`, `strictlyInverseˡ` and
`strictlyInverseʳ`,
- Conversion functions have been added in both directions to
`Function.Consequences(.Propositional)`.
`Function.Consequences(.Propositional)`.

#### Proofs of non-zeroness/positivity/negativity as instance arguments

* Many numeric operations in the library require their arguments to be non-zero,
Expand Down Expand Up @@ -762,6 +762,41 @@ Non-backwards compatible changes
IO.Effectful
IO.Instances
```
### (Issue #1214) Reorganisation of the introduction of negated relation symbols under `Relation.Binary`

* Previously, negated relation symbols `_≰_` (for `Poset`) and `_≮_` (`TotalOrder`)
were introduced in the corresponding `Relation.Binary.Properties` modules, for re-export.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not mentioning _≮_ here?

Copy link
Contributor Author

@jamesmckinna jamesmckinna Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean \<~n? Because it was never used in the library before #2099 introduced it as the symbol for Preorder. But I can do so if you think it adds additional force?

This is one of those cases where I didn't account for behaviour that was only introduced in v2.0 (indeed, only a few days after I wrote this CHANGELOG entry... and now, o ly another few days after the not-mentioned symbol even got merged into the library!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check: I was confused by your original question, because I do mention _≮_ here... so I (perhaps mistakenly) presumed you had meant to type an their symbol. Could you restate the question please, so that I can better see the drift of it? Sorry to be obtuse!


* Now they are introduced as definitions in the corresponding `Relation.Binary.Bundles`,
together with, for uniformity's sake, an additional negated symbol `_≁_` for `Preorder`.
NB `_≮_` is now introduced *earlier* in the hierarchy, at `StrictPartialOrder`, which
incurs some rather complicated deprecation gymnastics...

* Accordingly, in fact we now have `_⋦_` (in `TotalPreorder`) and `_≰_` (in `Poset`)
as renamed `public` re-exports from `_≁_` in `Preorder`.

* As knock-on changes, public re-exports of `Preorder`, `Poset`, `StrictPartialOrder`
in derived bundles also now need to re-export the various new symbols accordingly.

* Backwards compatibility has been maintained, with deprecated definitions in the
corresponding `Relation.Binary.Properties` modules, and the corresponding client
client module `import`s being adjusted accordingly.

* Elsewhere under `Relation.Binary.Properties` etc. the use of *explicitly* negated
relation symbols have now been replaced by their definitionally equal counterparts
using the new symbols accordingly.

* NB modules such as `Relation.Binary.Construct.NonStrictToStrict` which operate
only on the the underlying `Structures` such as `IsPartialOrder` etc., are unable
to make use of the new symbols.

* NB (issues #2096 #2098) the corresponding situation regarding the `flip`ped
relation symbols `_≥_`, `_>_` (and their negated versions!) has not (yet) been
addressed; to develop a parallel architecture to that above, there would need
to be a suitable symbol for the flipped relation `_∼_` (and its negation!) in
`Relation.Bundles.Preorder`, currently handled purely semantically via `flip ∼` in
`Relation.Binary.Properties.Preorder`, `Relation.Binary.Construct.Flip.{Ord|EqAndOrd}`
etc. Ditto. the strict ordering relation `_<_` defined in `Relation.Binary.Properties.Poset`...

### Other

Expand Down Expand Up @@ -928,6 +963,7 @@ Non-backwards compatible changes
lookup : All P xs → (∀ {x} → x ∈ₚ xs → P x)
lookupₛ : P Respects _≈_ → All P xs → (∀ {x} → x ∈ xs → P x)
```

* `excluded-middle` in `Relation.Nullary.Decidable.Core` has been renamed to
`¬¬-excluded-middle`.

Expand Down Expand Up @@ -1498,6 +1534,16 @@ Deprecated names
invPreorder ↦ converse-preorder
```

* Moved negated relation symbol from `Relation.Binary.Properties.Poset`:
```
_≰_ ↦ Relation.Binary.Bundles.Poset._≰_
```

* Moved negated relation symbol from `Relation.Binary.Properties.TotalOrder`:
```
_≮_ ↦ Relation.Binary.Bundles.StrictPartialOrder._≮_
```

### Renamed Data.Erased to Data.Irrelevant

* This fixes the fact we had picked the wrong name originally. The erased modality
Expand Down Expand Up @@ -2253,7 +2299,7 @@ Other minor changes

length-isMagmaHomomorphism : (A : Set a) → IsMagmaHomomorphism (++-rawMagma A) +-rawMagma length
length-isMonoidHomomorphism : (A : Set a) → IsMonoidHomomorphism (++-[]-rawMonoid A) +-0-rawMonoid length

take-map : take n (map f xs) ≡ map f (take n xs)
drop-map : drop n (map f xs) ≡ map f (drop n xs)
head-map : head (map f xs) ≡ Maybe.map f (head xs)
Expand Down Expand Up @@ -2804,6 +2850,20 @@ Other minor changes
prependVLams : List String → Term → Term
```

* Added new definitions to `Relation.Binary.Bundles`:

The following negated relation symbols have now been added, with their
(obvious) intended semantics:
```agda
infix 4 _≁_ _≰_ _≮_
Preorder._≁_ : Rel Carrier _
StrictPartialOrder._≮_ : Rel Carrier _
```
Additionally, `Poset._≰_` is defined by renaming public export of `Preorder._≁_`

The corresponding former definitions in `Relation.Binary.Properties.*`
have been deprecated.

* Added new operations in `Relation.Binary.Construct.Closure.Equivalence`:
```
fold : IsEquivalence _∼_ → _⟶_ ⇒ _∼_ → EqClosure _⟶_ ⇒ _∼_
Expand Down
4 changes: 2 additions & 2 deletions src/Data/List/Sort/MergeSort.agda
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open import Data.List.Relation.Binary.Permutation.Propositional
import Data.List.Relation.Binary.Permutation.Propositional.Properties as Perm
open import Data.Maybe.Base using (just)
open import Relation.Nullary.Decidable using (does)
open import Data.Nat using (_<_; _>_; z<s; s<s)
open import Data.Nat.Base using (_<_; _>_; z<s; s<s)
open import Data.Nat.Induction
open import Data.Nat.Properties using (m<n⇒m<1+n)
open import Data.Product.Base as Prod using (_,_)
Expand All @@ -36,7 +36,7 @@ open DecTotalOrder O renaming (Carrier to A)

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

open PermutationReasoning

Expand Down
21 changes: 15 additions & 6 deletions src/Relation/Binary/Bundles.agda
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where

open Setoid setoid public

infix 4 _≁_
_≁_ : Rel Carrier _
x ≁ y = ¬ (x ∼ y)

record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≲_
Expand All @@ -107,7 +110,7 @@ record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
preorder = record { isPreorder = isPreorder }

open Preorder preorder public
using (module Eq)
using (module Eq) renaming (_≁_ to _⋦_)


------------------------------------------------------------------------
Expand All @@ -131,7 +134,7 @@ record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
}

open Preorder preorder public
using (module Eq)
using (module Eq) renaming (_≁_ to _≰_)


record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
Expand All @@ -152,7 +155,7 @@ record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
}

open Poset poset public
using (preorder)
using (preorder; _≰_)

module Eq where
decSetoid : DecSetoid c ℓ₁
Expand Down Expand Up @@ -182,6 +185,10 @@ record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂))

open Setoid setoid public

infix 4 _≮_
_≮_ : Rel Carrier _
x ≮ y = ¬ (x < y)


record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
Expand All @@ -200,6 +207,8 @@ record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂
{ isStrictPartialOrder = isStrictPartialOrder
}

open StrictPartialOrder strictPartialOrder using (_≮_)

module Eq where

decSetoid : DecSetoid c ℓ₁
Expand Down Expand Up @@ -231,7 +240,7 @@ record TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
}

open Poset poset public
using (module Eq; preorder)
using (module Eq; preorder; _≰_)

totalPreorder : TotalPreorder c ℓ₁ ℓ₂
totalPreorder = record
Expand All @@ -256,7 +265,7 @@ record DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
{ isTotalOrder = isTotalOrder
}

open TotalOrder totalOrder public using (poset; preorder)
open TotalOrder totalOrder public using (poset; preorder; _≰_)

decPoset : DecPoset c ℓ₁ ℓ₂
decPoset = record
Expand Down Expand Up @@ -288,7 +297,7 @@ record StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) wh
}

open StrictPartialOrder strictPartialOrder public
using (module Eq)
using (module Eq; _≮_)

decSetoid : DecSetoid c ℓ₁
decSetoid = record
Expand Down
20 changes: 14 additions & 6 deletions src/Relation/Binary/Properties/DecTotalOrder.agda
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ open import Relation.Binary.Bundles
using (DecTotalOrder; StrictTotalOrder)

module Relation.Binary.Properties.DecTotalOrder
{d₁ d₂ d₃} (DT : DecTotalOrder d₁ d₂ d₃) where
{d₁ d₂ d₃} (DTO : DecTotalOrder d₁ d₂ d₃) where

open DecTotalOrder DT hiding (trans)
-- issue #1214: locally to this module, we hide the relation _≰_, so
-- that we can deprecate its export here, yet re-export it elsewhere
open DecTotalOrder DTO hiding (trans; _≰_)

import Relation.Binary.Construct.Flip.EqAndOrd as EqAndOrd
import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
Expand Down Expand Up @@ -80,19 +82,25 @@ open TotalOrderProperties public
}

open StrictTotalOrder <-strictTotalOrder public
using () renaming (compare to <-compare)
using (_≮_) renaming (compare to <-compare)

------------------------------------------------------------------------
-- _≰_ - the negated order

open TotalOrderProperties public
using
( _≰_
; ≰-respʳ-≈
( ≰-respʳ-≈
; ≰-respˡ-≈
; ≰⇒>
; ≰⇒≥
)

≮⇒≥ : ∀ {x y} → ¬ (x < y) → y ≤ x
≮⇒≥ : ∀ {x y} → x ≮ y → y ≤ x
≮⇒≥ = ToStrict.≮⇒≥ Eq.sym _≟_ reflexive total

-- issue #1214: see above
infix 4 _≰_
_≰_ = DecTotalOrder._≰_ DTO
{-# WARNING_ON_USAGE _≰_
"Warning: export of _≰_ from this module was deprecated in v2.0, in favour of a direct public export from Relation.Binary.Bundles.Poset instead"
#-}
35 changes: 24 additions & 11 deletions src/Relation/Binary/Properties/Poset.agda
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

open import Data.Product.Base using (_,_)
open import Function.Base using (flip; _∘_)
open import Relation.Binary.Core using (Rel; _Preserves_⟶_)
open import Relation.Binary.Bundles using (Poset; StrictPartialOrder)
Expand All @@ -20,7 +21,7 @@ open import Relation.Nullary.Negation using (contradiction)
module Relation.Binary.Properties.Poset
{p₁ p₂ p₃} (P : Poset p₁ p₂ p₃) where

open Poset P renaming (Carrier to A)
open Poset P renaming (Carrier to A; _≰_ to _≰A_) -- issue #1214 see below

import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
import Relation.Binary.Properties.Preorder preorder as PreorderProperties
Expand Down Expand Up @@ -62,15 +63,10 @@ open Poset ≥-poset public
------------------------------------------------------------------------
-- Negated order

infix 4 _≰_

_≰_ : Rel A p₃
x ≰ y = ¬ (x ≤ y)

≰-respˡ-≈ : _≰_ Respectsˡ _≈_
≰-respˡ-≈ : _≰A_ Respectsˡ _≈_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting a very weird rendering of the symbol here: _≰A_, in particular the symbol has an A after it? Weirdly it doesn't appear in Bundles though. Any ideas what is causing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The A is there to avoid a renaming conflict; it's a locally introduced symbol at the top of the module, renaming apart from an existing symbol. See my comment in the CHANGELOG about "deprecation gymnastics"... or maybe there's a better way to proceed that you know?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh weird. Let me have a closer look at the renaming going on. Obviously didn't appreciate what was going on properly in the first review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, something else weird is going on re: renaming/deprecation, on #2099: which I'll re-open temporarily to document.

≰-respˡ-≈ x≈y = _∘ ≤-respˡ-≈ (Eq.sym x≈y)

≰-respʳ-≈ : _≰_ Respectsʳ _≈_
≰-respʳ-≈ : _≰A_ Respectsʳ _≈_
≰-respʳ-≈ x≈y = _∘ ≤-respʳ-≈ (Eq.sym x≈y)

------------------------------------------------------------------------
Expand All @@ -90,7 +86,7 @@ _<_ = ToStrict._<_
}

open StrictPartialOrder <-strictPartialOrder public
using ( <-resp-≈; <-respʳ-≈; <-respˡ-≈)
using (_≮_; <-resp-≈; <-respʳ-≈; <-respˡ-≈)
renaming
( irrefl to <-irrefl
; asym to <-asym
Expand All @@ -103,10 +99,10 @@ open StrictPartialOrder <-strictPartialOrder public
≤∧≉⇒< : ∀ {x y} → x ≤ y → x ≉ y → x < y
≤∧≉⇒< = ToStrict.≤∧≉⇒<

<⇒≱ : ∀ {x y} → x < y → ¬ (y ≤ x)
<⇒≱ : ∀ {x y} → x < y → y ≰A x
<⇒≱ = ToStrict.<⇒≱ antisym

≤⇒≯ : ∀ {x y} → x ≤ y → ¬ (y < x)
≤⇒≯ : ∀ {x y} → x ≤ y → y ≮ x
≤⇒≯ = ToStrict.≤⇒≯ antisym

------------------------------------------------------------------------
Expand All @@ -133,3 +129,20 @@ mono⇒cong = Consequences.mono⇒cong _≈_ _≈_ Eq.sym reflexive antisym

antimono⇒cong : ∀ {f} → f Preserves _≤_ ⟶ _≥_ → f Preserves _≈_ ⟶ _≈_
antimono⇒cong = Consequences.antimono⇒cong _≈_ _≈_ Eq.sym reflexive antisym


------------------------------------------------------------------------
-- DEPRECATED
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.

-- Version 2.0

-- issue #1214: locally to this module, we rename the relation _≰_,
-- so that we can deprecate it here, yet re-export it elsewhere
infix 4 _≰_
_≰_ = _≰A_
{-# WARNING_ON_USAGE _≤_
"Warning: export of _≰_ from this module was deprecated in v2.0, in favour of a direct public export from Relation.Binary.Bundles.Poset instead"
#-}
2 changes: 1 addition & 1 deletion src/Relation/Binary/Properties/StrictPartialOrder.agda
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Relation.Binary.Construct.StrictToNonStrict
open StrictPartialOrder SPO

------------------------------------------------------------------------
-- The inverse relation is also a strict partial order.
-- The converse relation is also a strict partial order.

>-strictPartialOrder : StrictPartialOrder s₁ s₂ s₃
>-strictPartialOrder = EqAndOrd.strictPartialOrder SPO
Expand Down
Loading