Skip to content
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

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

Merged
merged 36 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
57 changes: 38 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ Non-backwards compatible changes
raw bundles to `Data.X.Base`, this definition can now be made directly. Knock-on
consequences include the need to retain the old constructor name, now introduced
as a pattern synonym, and introduction of (a function equivalent to) the former
field name/projection function `proof` as `≤″-proof` in `Data.Nat.Properties`.
field name/projection function `proof` as `≤″-proof` in `Data.Nat.Properties`.

* Accordingly, the definition has been changed to:
```agda
Expand Down Expand Up @@ -842,7 +842,6 @@ Non-backwards compatible changes
IO.Effectful
IO.Instances
```

### (Issue #2096) Introduction of flipped relation symbol for `Relation.Binary.Bundles.Preorder`

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

* NB (issues #1214 #2098) the corresponding situation regarding the `flip`ped
relation symbols `_≥_`, `_>_` (and their negated versions!) has not (yet)
been addressed.
### (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`,
with their (obvious) intended semantics:
```agda
infix 4 _⋦_ _≰_ _≮_
Preorder._⋦_ : Rel Carrier _
StrictPartialOrder._≮_ : Rel Carrier _
```
Additionally, `Poset._≰_` is defined by renaming public export of `Preorder._⋦_`

* 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.


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

Expand All @@ -879,12 +894,12 @@ Non-backwards compatible changes
```
_─_ ↦ removeAt
```

* In `Data.Vec.Base`:
```agda
insert ↦ insertAt
remove ↦ removeAt

updateAt : Fin n → (A → A) → Vec A n → Vec A n
updateAt : Vec A n → Fin n → (A → A) → Vec A n
Expand All @@ -895,12 +910,12 @@ Non-backwards compatible changes
remove : Fin (suc n) → Vector A (suc n) → Vector A n
removeAt : Vector A (suc n) → Fin (suc n) → Vector A n

updateAt : Fin n → (A → A) → Vector A n → Vector A n
updateAt : Vector A n → Fin n → (A → A) → Vector A n
```

* The old names (and the names of all proofs about these functions) have been deprecated appropriately.

### Changes to triple reasoning interface
Expand Down Expand Up @@ -1658,7 +1673,7 @@ Deprecated names
take-drop-id ↦ take++drop≡id

map-insert ↦ map-insertAt

insert-lookup ↦ insertAt-lookup
insert-punchIn ↦ insertAt-punchIn
remove-PunchOut ↦ removeAt-punchOut
Expand All @@ -1684,7 +1699,7 @@ Deprecated names
updateAt-cong-relative ↦ updateAt-cong-local

map-updateAt ↦ map-updateAt-local

insert-lookup ↦ insertAt-lookup
insert-punchIn ↦ insertAt-punchIn
remove-punchOut ↦ removeAt-punchOut
Expand Down Expand Up @@ -1742,11 +1757,6 @@ Deprecated names
fromForeign ↦ Foreign.Haskell.Coerce.coerce
```

* In `Relation.Binary.Bundles.Preorder`:
```
_∼_ ↦ _≲_
```

* In `Relation.Binary.Indexed.Heterogeneous.Bundles.Preorder`:
```
_∼_ ↦ _≲_
Expand All @@ -1758,6 +1768,15 @@ 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._≮_

* In `Relation.Nullary.Decidable.Core`:
```
excluded-middle ↦ ¬¬-excluded-middle
Expand Down Expand Up @@ -3300,9 +3319,9 @@ Additions to existing modules

* Added new proofs to `Relation.Binary.Consequences`:
```
sym⇒¬-sym : Symmetric _∼_ → Symmetric _≁_
cotrans⇒¬-trans : Cotransitive _∼_ → Transitive _≁_
irrefl⇒¬-refl : Reflexive _≈_ → Irreflexive _≈_ _∼_ → Reflexive _≁_
sym⇒¬-sym : Symmetric _∼_ → Symmetric (¬_ ∘₂ _∼_)
cotrans⇒¬-trans : Cotransitive _∼_ → Transitive (¬_ ∘₂ _∼_)
irrefl⇒¬-refl : Reflexive _≈_ → Irreflexive _≈_ _∼_ → Reflexive (¬_ ∘₂ _∼_)
mono₂⇒cong₂ : Symmetric ≈₁ → ≈₁ ⇒ ≤₁ → Antisymmetric ≈₂ ≤₂ → ∀ {f} →
f Preserves₂ ≤₁ ⟶ ≤₁ ⟶ ≤₂ →
f Preserves₂ ≈₁ ⟶ ≈₁ ⟶ ≈₂
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
48 changes: 26 additions & 22 deletions src/Relation/Binary/Bundles.agda
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,20 @@ record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where

open Setoid setoid public

infix 4 _⋦_
_⋦_ : Rel Carrier _
x ⋦ y = ¬ (x ≲ y)

infix 4 _≳_
_≳_ = flip _≲_

infix 4 _∼_ -- for deprecation
-- Deprecated.
infix 4 _∼_
_∼_ = _≲_
{-# WARNING_ON_USAGE _∼_
"Warning: _∼_ was deprecated in v2.0.
Please use _≲_ instead. "
#-}


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

open Preorder preorder public
using (module Eq; _≳_)
using (module Eq; _≳_; _⋦_)


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

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


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

open Poset poset public
using (preorder)
using (preorder; _≰_)
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved

module Eq where
decSetoid : DecSetoid c ℓ₁
Expand Down Expand Up @@ -189,6 +199,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 @@ -207,6 +221,9 @@ record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂
{ isStrictPartialOrder = isStrictPartialOrder
}

open StrictPartialOrder strictPartialOrder public
using (_≮_)

module Eq where

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

open Poset poset public
using (module Eq; preorder)
using (module Eq; preorder; _≰_)
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved

totalPreorder : TotalPreorder c ℓ₁ ℓ₂
totalPreorder = record
Expand All @@ -263,14 +280,16 @@ 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
{ isDecPartialOrder = isDecPartialOrder
}

open DecPoset decPoset public using (module Eq)
open DecPoset decPoset public
using (module Eq)


-- Note that these orders are decidable. The current implementation
Expand All @@ -295,7 +314,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 Expand Up @@ -338,18 +357,3 @@ record ApartnessRelation c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) w
isApartnessRelation : IsApartnessRelation _≈_ _#_

open IsApartnessRelation isApartnessRelation public




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

-- Version 2.0

{-# WARNING_ON_USAGE Preorder._∼_
"Warning: Preorder._∼_ was deprecated in v2.0. Please use Preorder._≲_ instead. "
#-}
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 5 additions & 6 deletions src/Relation/Binary/Properties/DecTotalOrder.agda
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ 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)
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 +80,18 @@ 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
12 changes: 4 additions & 8 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 Down Expand Up @@ -62,11 +63,6 @@ open Poset ≥-poset public
------------------------------------------------------------------------
-- Negated order

infix 4 _≰_

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

≰-respˡ-≈ : _≰_ 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 ≰ x
<⇒≱ = ToStrict.<⇒≱ antisym

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

------------------------------------------------------------------------
Expand Down
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
2 changes: 1 addition & 1 deletion src/Relation/Binary/Properties/StrictTotalOrder.agda
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Relation.Binary.Properties.StrictPartialOrder as SPO
open import Relation.Binary.Consequences

------------------------------------------------------------------------
-- _<_ - the strict version is a strict total order
-- _<_ - the strict version is a decidable total order

decTotalOrder : DecTotalOrder _ _ _
decTotalOrder = record
Expand Down
5 changes: 2 additions & 3 deletions src/Relation/Binary/Properties/TotalOrder.agda
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ open PosetProperties public
}

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

------------------------------------------------------------------------
-- _<_ - the strict version is a strict partial order
Expand Down Expand Up @@ -90,8 +90,7 @@ open PosetProperties public

open PosetProperties public
using
( _≰_
; ≰-respʳ-≈
( ≰-respʳ-≈
; ≰-respˡ-≈
)

Expand Down
Loading