Skip to content

Commit c3dd0d4

Browse files
authored
[fix] Issue #1726: deprecates _≺_ in Data.Fin.Base plus its properties (#1868)
1 parent 1c2f96e commit c3dd0d4

File tree

4 files changed

+108
-35
lines changed

4 files changed

+108
-35
lines changed

CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,24 @@ Deprecated names
888888
raise ↦ _↑ʳ_
889889
```
890890

891+
Issue #1726: the relation `_≺_` and its single constructor `_≻toℕ_`
892+
have been deprecated in favour of their extensional equivalent `_<_`
893+
but omitting the inversion principle which pattern matching on `_≻toℕ_`
894+
would achieve; this instead is proxied by the property `Data.Fin.Properties.toℕ<`.
895+
896+
* In `Data.Fin.Induction`:
897+
```
898+
≺-Rec
899+
≺-wellFounded
900+
≺-recBuilder
901+
≺-rec
902+
```
903+
904+
As with Issue #1726 above: the deprecation of relation `_≺_` means that these definitions
905+
associated with wf-recursion are deprecated in favour of their `_<_` counterparts.
906+
But it's not quite sensible to say that these definiton should be *renamed* to *anything*,
907+
least of all those counterparts... the type confusion would be intolerable.
908+
891909
* In `Data.Fin.Properties`:
892910
```
893911
toℕ-raise ↦ toℕ-↑ʳ
@@ -898,6 +916,9 @@ Deprecated names
898916
eq? ↦ inj⇒≟
899917
```
900918

919+
Likewise under issue #1726: the properties `≺⇒<′` and `<′⇒≺` have been deprecated
920+
in favour of their proxy counterparts `<⇒<′` and `<′⇒<`.
921+
901922
* In `Data.Fin.Permutation.Components`:
902923
```
903924
reverse ↦ Data.Fin.Base.opposite

src/Data/Fin/Base.agda

+12-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ _>_ : IRel Fin 0ℓ
290290
i > j = toℕ i ℕ.> toℕ j
291291

292292

293-
data _≺_ : Set where
294-
_≻toℕ_ : n (i : Fin n) toℕ i ≺ n
295-
296293
------------------------------------------------------------------------
297294
-- An ordering view.
298295

@@ -335,3 +332,15 @@ NB argument order has been flipped:
335332
the left-hand argument is the Fin m
336333
the right-hand is the Nat index increment."
337334
#-}
335+
336+
data _≺_ : Set where
337+
_≻toℕ_ : n (i : Fin n) toℕ i ≺ n
338+
339+
{-# WARNING_ON_USAGE _≺_
340+
"Warning: _≺_ was deprecated in v2.0.
341+
Please use equivalent relation _<_ instead."
342+
#-}
343+
{-# WARNING_ON_USAGE _≻toℕ_
344+
"Warning: _≻toℕ_ was deprecated in v2.0.
345+
Please use toℕ<n from Data.Fin.Properties instead."
346+
#-}

src/Data/Fin/Induction.agda

+43-19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
------------------------------------------------------------------------
66

77
{-# OPTIONS --without-K --safe #-}
8+
{-# OPTIONS --warn=noUserWarning #-} -- for deprecated _≺_ (issue #1726)
89

910
open import Data.Fin.Base
1011
open import Data.Fin.Properties
@@ -20,7 +21,8 @@ open import Function.Base using (flip; _$_)
2021
open import Induction
2122
open import Induction.WellFounded as WF
2223
open import Level using (Level)
23-
open import Relation.Binary using (Rel; Decidable; IsPartialOrder; IsStrictPartialOrder; StrictPartialOrder)
24+
open import Relation.Binary
25+
using (Rel; Decidable; IsPartialOrder; IsStrictPartialOrder; StrictPartialOrder)
2426
import Relation.Binary.Construct.Converse as Converse
2527
import Relation.Binary.Construct.Flip as Flip
2628
import Relation.Binary.Construct.NonStrictToStrict as ToStrict
@@ -94,24 +96,6 @@ private
9496
... | no n≢i = subst P (inject₁-lower₁ i n≢i) (Pᵢ₊₁⇒Pᵢ _ Pᵢ₊₁)
9597
where Pᵢ₊₁ = induct (rec _ (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i)))))
9698

97-
------------------------------------------------------------------------
98-
-- Induction over _≺_
99-
100-
≺-Rec : RecStruct ℕ ℓ ℓ
101-
≺-Rec = WfRec _≺_
102-
103-
≺-wellFounded : WellFounded _≺_
104-
≺-wellFounded = Subrelation.wellFounded ≺⇒<′ ℕ.<′-wellFounded
105-
106-
module _ {ℓ} where
107-
open WF.All ≺-wellFounded ℓ public
108-
renaming
109-
( wfRecBuilder to ≺-recBuilder
110-
; wfRec to ≺-rec
111-
)
112-
hiding (wfRec-builder)
113-
114-
11599
------------------------------------------------------------------------
116100
-- Well-foundedness of other (strict) partial orders on Fin
117101

@@ -159,3 +143,43 @@ module _ {_≈_ : Rel (Fin n) ℓ} where
159143
WellFounded (flip (ToStrict._<_ _≈_ _⊑_))
160144
po-noetherian isPO =
161145
spo-noetherian (ToStrict.<-isStrictPartialOrder _≈_ _ isPO)
146+
147+
------------------------------------------------------------------------
148+
-- DEPRECATED NAMES
149+
------------------------------------------------------------------------
150+
-- Please use the new names as continuing support for the old names is
151+
-- not guaranteed.
152+
153+
-- Version 2.0
154+
155+
≺-Rec : RecStruct ℕ ℓ ℓ
156+
≺-Rec = WfRec _≺_
157+
158+
≺-wellFounded : WellFounded _≺_
159+
≺-wellFounded = Subrelation.wellFounded ≺⇒<′ ℕ.<′-wellFounded
160+
161+
module _ {ℓ} where
162+
open WF.All ≺-wellFounded ℓ public
163+
renaming
164+
( wfRecBuilder to ≺-recBuilder
165+
; wfRec to ≺-rec
166+
)
167+
hiding (wfRec-builder)
168+
169+
{-# WARNING_ON_USAGE ≺-Rec
170+
"Warning: ≺-Rec was deprecated in v2.0.
171+
Please use <-Rec instead."
172+
#-}
173+
{-# WARNING_ON_USAGE ≺-wellFounded
174+
"Warning: ≺-wellFounded was deprecated in v2.0.
175+
Please use <-wellFounded instead."
176+
#-}
177+
{-# WARNING_ON_USAGE ≺-recBuilder
178+
"Warning: ≺-recBuilder was deprecated in v2.0.
179+
Please use <-recBuilder instead."
180+
#-}
181+
{-# WARNING_ON_USAGE ≺-rec
182+
"Warning: ≺-rec was deprecated in v2.0.
183+
Please use <-rec instead."
184+
#-}
185+

src/Data/Fin/Properties.agda

+32-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
------------------------------------------------------------------------
77

88
{-# OPTIONS --without-K --safe #-}
9+
{-# OPTIONS --warn=noUserWarning #-} -- for deprecated _≺_ (issue #1726)
910

1011
module Data.Fin.Properties where
1112

@@ -166,7 +167,7 @@ toℕ≤n : ∀ (i : Fin n) → toℕ i ℕ.≤ n
166167
toℕ≤n {suc n} i = ℕₚ.m≤n⇒m≤1+n (toℕ≤pred[n] i)
167168

168169
toℕ<n : (i : Fin n) toℕ i ℕ.< n
169-
toℕ<n {suc n} i = ss (toℕ≤pred[n] i)
170+
toℕ<n {suc n} i = s<s (toℕ≤pred[n] i)
170171

171172
-- A simpler implementation of toℕ≤pred[n],
172173
-- however, with a different reduction behavior.
@@ -758,18 +759,6 @@ lift-injective f inj (suc k) {zero} {zero} eq = refl
758759
lift-injective f inj (suc k) {suc _} {suc _} eq =
759760
cong suc (lift-injective f inj k (suc-injective eq))
760761

761-
------------------------------------------------------------------------
762-
-- _≺_
763-
------------------------------------------------------------------------
764-
765-
≺⇒<′ : _≺_ ⇒ ℕ._<′_
766-
≺⇒<′ (n ≻toℕ i) = ℕₚ.≤⇒≤′ (toℕ<n i)
767-
768-
<′⇒≺ : ℕ._<′_ ⇒ _≺_
769-
<′⇒≺ {n} ℕ.≤′-refl = subst (_≺ suc n) (toℕ-fromℕ n) (suc n ≻toℕ fromℕ n)
770-
<′⇒≺ (ℕ.≤′-step m≤′n) with <′⇒≺ m≤′n
771-
... | n ≻toℕ i = subst (_≺ suc n) (toℕ-inject₁ i) (suc n ≻toℕ _)
772-
773762
------------------------------------------------------------------------
774763
-- pred
775764
------------------------------------------------------------------------
@@ -1133,3 +1122,33 @@ eq? = inj⇒≟
11331122
"Warning: eq? was deprecated in v2.0.
11341123
Please use inj⇒≟ instead."
11351124
#-}
1125+
1126+
private
1127+
1128+
z≺s : {n} zero ≺ suc n
1129+
z≺s = _ ≻toℕ zero
1130+
1131+
s≺s : {m n} m ≺ n suc m ≺ suc n
1132+
s≺s (n ≻toℕ i) = (suc n) ≻toℕ (suc i)
1133+
1134+
<⇒≺ : ℕ._<_ ⇒ _≺_
1135+
<⇒≺ {zero} z<s = z≺s
1136+
<⇒≺ {suc m} (s<s lt) = s≺s (<⇒≺ lt)
1137+
1138+
≺⇒< : _≺_ ⇒ ℕ._<_
1139+
≺⇒< (n ≻toℕ i) = toℕ<n i
1140+
1141+
≺⇒<′ : _≺_ ⇒ ℕ._<′_
1142+
≺⇒<′ lt = ℕₚ.<⇒<′ (≺⇒< lt)
1143+
{-# WARNING_ON_USAGE ≺⇒<′
1144+
"Warning: ≺⇒<′ was deprecated in v2.0.
1145+
Please use <⇒<′ instead."
1146+
#-}
1147+
1148+
<′⇒≺ : ℕ._<′_ ⇒ _≺_
1149+
<′⇒≺ lt = <⇒≺ (ℕₚ.<′⇒< lt)
1150+
{-# WARNING_ON_USAGE <′⇒≺
1151+
"Warning: <′⇒≺ was deprecated in v2.0.
1152+
Please use <′⇒< instead."
1153+
#-}
1154+

0 commit comments

Comments
 (0)