From 0adbbe8acd1438b0f3b5f9fde77ee6bbd2e704a2 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 11:22:29 +0100 Subject: [PATCH 01/17] introduced alternative definitions; revised one usage of previous one --- src/Data/Nat/Base.agda | 115 +++++++++++++++++++---------------- src/Data/Nat/Properties.agda | 4 +- 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 1e2db666b8..340eb544e0 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -12,8 +12,10 @@ module Data.Nat.Base where open import Algebra.Bundles.Raw using (RawMagma; RawMonoid; RawNearSemiring; RawSemiring) +open import Algebra.Definitions.RawMagma using (_∣ˡ_) open import Data.Bool.Base using (Bool; true; false; T; not) open import Data.Parity.Base using (Parity; 0ℙ; 1ℙ) +open import Data.Product.Base using (_,_; proj₁) open import Level using (0ℓ) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -120,11 +122,59 @@ instance >-nonZero⁻¹ (suc n) = z′ n = n <′ m ------------------------------------------------------------------------ -- Another alternative definition of _≤_ +infix 4 _≤″_ _<″_ _≥″_ _>″_ record _≤″_ (m n : ℕ) : Set where constructor less-than-or-equal @@ -265,7 +316,14 @@ record _≤″_ (m n : ℕ) : Set where {k} : ℕ proof : m + k ≡ n -infix 4 _≤″_ _<″_ _≥″_ _>″_ +{- + +_≤″_ : (m n : ℕ) → Set +_≤″_ = _∣ˡ_ +-rawMagma + +pattern less-than-or-equal {k} proof = k , proof + +-} _<″_ : Rel ℕ 0ℓ m <″ n = suc m ≤″ n @@ -275,7 +333,6 @@ m ≥″ n = n ≤″ m _>″_ : Rel ℕ 0ℓ m >″ n = n <″ m - ------------------------------------------------------------------------ -- Another alternative definition of _≤_ @@ -314,51 +371,7 @@ compare (suc m) (suc n) with compare m n ... | equal m = equal (suc m) ... | greater n k = greater (suc n) k ------------------------------------------------------------------------- --- Raw bundles - -+-rawMagma : RawMagma 0ℓ 0ℓ -+-rawMagma = record - { _≈_ = _≡_ - ; _∙_ = _+_ - } - -+-0-rawMonoid : RawMonoid 0ℓ 0ℓ -+-0-rawMonoid = record - { _≈_ = _≡_ - ; _∙_ = _+_ - ; ε = 0 - } - -*-rawMagma : RawMagma 0ℓ 0ℓ -*-rawMagma = record - { _≈_ = _≡_ - ; _∙_ = _*_ - } - -*-1-rawMonoid : RawMonoid 0ℓ 0ℓ -*-1-rawMonoid = record - { _≈_ = _≡_ - ; _∙_ = _*_ - ; ε = 1 - } - -+-*-rawNearSemiring : RawNearSemiring 0ℓ 0ℓ -+-*-rawNearSemiring = record - { Carrier = _ - ; _≈_ = _≡_ - ; _+_ = _+_ - ; _*_ = _*_ - ; 0# = 0 - } - -+-*-rawSemiring : RawSemiring 0ℓ 0ℓ -+-*-rawSemiring = record - { Carrier = _ - ; _≈_ = _≡_ - ; _+_ = _+_ - ; _*_ = _*_ - ; 0# = 0 - ; 1# = 1 - } - +{- +proof : ∀ {m n} (le : m ≤″ n) → m + (_≤″_.k le) ≡ n +proof le = _≤″_.proof le +-} diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index 3d38c77d07..37c3824e99 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -2098,8 +2098,8 @@ _>″?_ = flip _<″?_ ≤‴⇒≤″ : ∀{m n} → m ≤‴ n → m ≤″ n ≤‴⇒≤″ {m = m} ≤‴-refl = less-than-or-equal {k = 0} (+-identityʳ m) -≤‴⇒≤″ {m = m} (≤‴-step x) = less-than-or-equal (trans (+-suc m _) (_≤″_.proof ind)) where - ind = ≤‴⇒≤″ x +≤‴⇒≤″ {m = m} (≤‴-step x) with less-than-or-equal proof ← ≤‴⇒≤″ x + = less-than-or-equal (trans (+-suc m _) proof) m≤‴m+k : ∀{m n k} → m + k ≡ n → m ≤‴ n m≤‴m+k {m} {k = zero} refl = subst (λ z → m ≤‴ z) (sym (+-identityʳ m)) (≤‴-refl {m}) From b62ef817c3bd41fcbcf018d4036244ee8dd15a74 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 11:56:49 +0100 Subject: [PATCH 02/17] deprecated field name (NB tricky) --- README/Design/Decidability.agda | 2 +- src/Data/Nat/Base.agda | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README/Design/Decidability.agda b/README/Design/Decidability.agda index e615af282e..3f267bed4a 100644 --- a/README/Design/Decidability.agda +++ b/README/Design/Decidability.agda @@ -11,7 +11,7 @@ module README.Design.Decidability where open import Data.Bool open import Data.List open import Data.List.Properties using (∷-injective) -open import Data.Nat +open import Data.Nat hiding (proof) open import Data.Nat.Properties using (suc-injective) open import Data.Product open import Data.Unit diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 340eb544e0..64854b5c99 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -15,7 +15,6 @@ open import Algebra.Bundles.Raw using (RawMagma; RawMonoid; RawNearSemiring; Raw open import Algebra.Definitions.RawMagma using (_∣ˡ_) open import Data.Bool.Base using (Bool; true; false; T; not) open import Data.Parity.Base using (Parity; 0ℙ; 1ℙ) -open import Data.Product.Base using (_,_; proj₁) open import Level using (0ℓ) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -371,7 +370,16 @@ compare (suc m) (suc n) with compare m n ... | equal m = equal (suc m) ... | greater n k = greater (suc n) k -{- +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. + +-- Version 2.0 + proof : ∀ {m n} (le : m ≤″ n) → m + (_≤″_.k le) ≡ n proof le = _≤″_.proof le --} +{-# WARNING_ON_USAGE proof +"Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching instead. Note that the definition of _≤″_ has changed" +#-} From 8993f590b27abf63736db38a5519074aa7761420 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 12:00:28 +0100 Subject: [PATCH 03/17] installed new definition --- src/Data/Nat/Base.agda | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 64854b5c99..15c585ed70 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -15,6 +15,7 @@ open import Algebra.Bundles.Raw using (RawMagma; RawMonoid; RawNearSemiring; Raw open import Algebra.Definitions.RawMagma using (_∣ˡ_) open import Data.Bool.Base using (Bool; true; false; T; not) open import Data.Parity.Base using (Parity; 0ℙ; 1ℙ) +open import Data.Product.Base using (_,_; proj₁) open import Level using (0ℓ) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -309,21 +310,21 @@ m >′ n = n <′ m -- Another alternative definition of _≤_ infix 4 _≤″_ _<″_ _≥″_ _>″_ +{- + record _≤″_ (m n : ℕ) : Set where constructor less-than-or-equal field {k} : ℕ proof : m + k ≡ n -{- +-} _≤″_ : (m n : ℕ) → Set _≤″_ = _∣ˡ_ +-rawMagma pattern less-than-or-equal {k} proof = k , proof --} - _<″_ : Rel ℕ 0ℓ m <″ n = suc m ≤″ n @@ -378,8 +379,8 @@ compare (suc m) (suc n) with compare m n -- Version 2.0 -proof : ∀ {m n} (le : m ≤″ n) → m + (_≤″_.k le) ≡ n -proof le = _≤″_.proof le +proof : ∀ {m n} (le : m ≤″ n) → m + (proj₁ le) ≡ n +proof (less-than-or-equal {k} prf) = prf {-# WARNING_ON_USAGE proof "Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching instead. Note that the definition of _≤″_ has changed" #-} From 7f098087eb95158b6a55d3eac2fc46d8068cd9e9 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 12:12:04 +0100 Subject: [PATCH 04/17] removed old definition; tidied up --- src/Data/Nat/Base.agda | 12 ++---------- src/Data/Nat/Combinatorics.agda | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 15c585ed70..e4945c470f 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -310,16 +310,6 @@ m >′ n = n <′ m -- Another alternative definition of _≤_ infix 4 _≤″_ _<″_ _≥″_ _>″_ -{- - -record _≤″_ (m n : ℕ) : Set where - constructor less-than-or-equal - field - {k} : ℕ - proof : m + k ≡ n - --} - _≤″_ : (m n : ℕ) → Set _≤″_ = _∣ˡ_ +-rawMagma @@ -333,6 +323,7 @@ m ≥″ n = n ≤″ m _>″_ : Rel ℕ 0ℓ m >″ n = n <″ m + ------------------------------------------------------------------------ -- Another alternative definition of _≤_ @@ -371,6 +362,7 @@ compare (suc m) (suc n) with compare m n ... | equal m = equal (suc m) ... | greater n k = greater (suc n) k + ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ diff --git a/src/Data/Nat/Combinatorics.agda b/src/Data/Nat/Combinatorics.agda index 6db600699c..850cd01857 100644 --- a/src/Data/Nat/Combinatorics.agda +++ b/src/Data/Nat/Combinatorics.agda @@ -12,7 +12,7 @@ open import Data.Nat.Base open import Data.Nat.DivMod open import Data.Nat.Divisibility open import Data.Nat.Properties -open import Relation.Binary.Definitions +open import Relation.Binary.Definitions open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; subst) @@ -118,7 +118,7 @@ module _ {n k} (k Date: Sat, 22 Apr 2023 12:38:44 +0100 Subject: [PATCH 05/17] `CHANGELOG` plus portable definition of the `proof` projection --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ src/Data/Nat/Base.agda | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76ca38cd42..de0d9fff33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -427,6 +427,28 @@ Non-backwards compatible changes Prime n = ∀ {d} → 2 ≤ d → d < n → d ∤ n ``` +### Change in the definition of `_≤″_` + +* The definition of `_≤″_` in `Data.Nat.Base` was previously: + ```agda + ``` + which introduced a spurious additional definition, when this is in fact, modulo + field names and implicit/explicit qualifiers, equivalent to the definition of left- + divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. Since the addition of + 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 deprecation of (a function equiavlent to) the former + field name/projection function `proof`. + +* Accordingly, the definition has been + changed to: + ```agda + _≤″_ : (m n : ℕ) → Set + _≤″_ = _∣ˡ_ +-rawMagma + + pattern less-than-or-equal {k} proof = k , proof + ``` + ### Renaming of `Reflection` modules * Under the `Reflection` module, there were various impending name clashes @@ -1109,6 +1131,11 @@ Deprecated names map-with-∈↔ ↦ mapWith∈↔ ``` +* In `Data.Nat.Base`: + ``` + _≤″_.proof ↦ proj₂ + ``` + * In `Data.Nat.Properties`: ``` suc[pred[n]]≡n ↦ suc-pred diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index e4945c470f..1d6cca47ca 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -371,7 +371,7 @@ compare (suc m) (suc n) with compare m n -- Version 2.0 -proof : ∀ {m n} (le : m ≤″ n) → m + (proj₁ le) ≡ n +proof : ∀ {m n} (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n proof (less-than-or-equal {k} prf) = prf {-# WARNING_ON_USAGE proof "Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching instead. Note that the definition of _≤″_ has changed" From 5935db49992de04d76714668b012a0222277af56 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 12:42:02 +0100 Subject: [PATCH 06/17] `CHANGELOG` --- CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de0d9fff33..2545988cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -427,10 +427,15 @@ Non-backwards compatible changes Prime n = ∀ {d} → 2 ≤ d → d < n → d ∤ n ``` -### Change in the definition of `_≤″_` +### Change in the definition of `_≤″_` (issue #1919) * The definition of `_≤″_` in `Data.Nat.Base` was previously: ```agda + record _≤″_ (m n : ℕ) : Set where + constructor less-than-or-equal + field + {k} : ℕ + proof : m + k ≡ n ``` which introduced a spurious additional definition, when this is in fact, modulo field names and implicit/explicit qualifiers, equivalent to the definition of left- @@ -440,8 +445,7 @@ Non-backwards compatible changes as a pattern synonym, and deprecation of (a function equiavlent to) the former field name/projection function `proof`. -* Accordingly, the definition has been - changed to: +* Accordingly, the definition has been changed to: ```agda _≤″_ : (m n : ℕ) → Set _≤″_ = _∣ˡ_ +-rawMagma From 829ddd5fdb5644752b8f4034ab732aa16011cea3 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sat, 22 Apr 2023 12:58:39 +0100 Subject: [PATCH 07/17] more explicit deprecation warning --- src/Data/Nat/Base.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 1d6cca47ca..a9c21d9359 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -374,5 +374,5 @@ compare (suc m) (suc n) with compare m n proof : ∀ {m n} (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n proof (less-than-or-equal {k} prf) = prf {-# WARNING_ON_USAGE proof -"Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching instead. Note that the definition of _≤″_ has changed" +"Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching on less-than-or-equal instead. Note that the definition of _≤″_ has changed" #-} From e9c7170eca2c551f7d2a939dec8b89b3b3151df6 Mon Sep 17 00:00:00 2001 From: James McKinna Date: Sun, 23 Apr 2023 15:38:44 +0100 Subject: [PATCH 08/17] typo in `CHANGELOG` --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2545988cd6..ea4338176e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -442,7 +442,7 @@ Non-backwards compatible changes divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. Since the addition of 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 deprecation of (a function equiavlent to) the former + as a pattern synonym, and deprecation of (a function equivalent to) the former field name/projection function `proof`. * Accordingly, the definition has been changed to: From 824dce6b1219a6c3909863ba9e4ebe1504a98454 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sun, 23 Apr 2023 17:48:05 +0100 Subject: [PATCH 09/17] exchnaged repeated recursive for a nested irrefutbale `with` pattern --- src/Data/List/Properties.agda | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Data/List/Properties.agda b/src/Data/List/Properties.agda index e9ddbe6387..98a7ef92ad 100644 --- a/src/Data/List/Properties.agda +++ b/src/Data/List/Properties.agda @@ -905,16 +905,16 @@ module _ {P : Pred A p} (P? : Decidable P) where partition-defn : partition P? ≗ < filter P? , filter (∁? P?) > partition-defn [] = refl - partition-defn (x ∷ xs) with does (P? x) - ... | true = cong (Prod.map (x ∷_) id) (partition-defn xs) - ... | false = cong (Prod.map id (x ∷_)) (partition-defn xs) + partition-defn (x ∷ xs) with rec ← partition-defn xs with does (P? x) + ... | true = cong (Prod.map (x ∷_) id) rec + ... | false = cong (Prod.map id (x ∷_)) rec length-partition : ∀ xs → (let (ys , zs) = partition P? xs) → length ys ≤ length xs × length zs ≤ length xs length-partition [] = z≤n , z≤n - length-partition (x ∷ xs) with does (P? x) | length-partition xs - ... | true | rec = Prod.map s≤s m≤n⇒m≤1+n rec - ... | false | rec = Prod.map m≤n⇒m≤1+n s≤s rec + length-partition (x ∷ xs) with rec ← length-partition xs with does (P? x) + ... | true = Prod.map s≤s m≤n⇒m≤1+n rec + ... | false = Prod.map m≤n⇒m≤1+n s≤s rec ------------------------------------------------------------------------ -- _ʳ++_ From 61ef3f0723aa0f66f8e434233858b7d59a3b0565 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sun, 23 Apr 2023 18:51:19 +0100 Subject: [PATCH 10/17] Revert "Merge branch 'issue1919' of https://github.com/jamesmckinna/agda-stdlib into issue1919" This reverts commit dbfb5a7747b8ee8c1d8c83bb63b1285735ba4b14, reversing changes made to 824dce6b1219a6c3909863ba9e4ebe1504a98454. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4338176e..2545988cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -442,7 +442,7 @@ Non-backwards compatible changes divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. Since the addition of 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 deprecation of (a function equivalent to) the former + as a pattern synonym, and deprecation of (a function equiavlent to) the former field name/projection function `proof`. * Accordingly, the definition has been changed to: From 693270e8d930c9e04ef8cb2afb6526198981979b Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Sun, 23 Apr 2023 18:52:51 +0100 Subject: [PATCH 11/17] Revert "exchnaged repeated recursive for a nested irrefutbale `with` pattern" This reverts commit 824dce6b1219a6c3909863ba9e4ebe1504a98454. --- src/Data/List/Properties.agda | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Data/List/Properties.agda b/src/Data/List/Properties.agda index 98a7ef92ad..e9ddbe6387 100644 --- a/src/Data/List/Properties.agda +++ b/src/Data/List/Properties.agda @@ -905,16 +905,16 @@ module _ {P : Pred A p} (P? : Decidable P) where partition-defn : partition P? ≗ < filter P? , filter (∁? P?) > partition-defn [] = refl - partition-defn (x ∷ xs) with rec ← partition-defn xs with does (P? x) - ... | true = cong (Prod.map (x ∷_) id) rec - ... | false = cong (Prod.map id (x ∷_)) rec + partition-defn (x ∷ xs) with does (P? x) + ... | true = cong (Prod.map (x ∷_) id) (partition-defn xs) + ... | false = cong (Prod.map id (x ∷_)) (partition-defn xs) length-partition : ∀ xs → (let (ys , zs) = partition P? xs) → length ys ≤ length xs × length zs ≤ length xs length-partition [] = z≤n , z≤n - length-partition (x ∷ xs) with rec ← length-partition xs with does (P? x) - ... | true = Prod.map s≤s m≤n⇒m≤1+n rec - ... | false = Prod.map m≤n⇒m≤1+n s≤s rec + length-partition (x ∷ xs) with does (P? x) | length-partition xs + ... | true | rec = Prod.map s≤s m≤n⇒m≤1+n rec + ... | false | rec = Prod.map m≤n⇒m≤1+n s≤s rec ------------------------------------------------------------------------ -- _ʳ++_ From f120c1ee4ba08fc8ad279bdd40d350c5b87bad0b Mon Sep 17 00:00:00 2001 From: James McKinna Date: Tue, 25 Apr 2023 14:50:55 +0100 Subject: [PATCH 12/17] tweaks --- CHANGELOG.md | 2 +- src/Data/Nat/Base.agda | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2545988cd6..9154cfc17b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1137,7 +1137,7 @@ Deprecated names * In `Data.Nat.Base`: ``` - _≤″_.proof ↦ proj₂ + _≤″_.proof ↦ Data.Product.Base.proj₂ ``` * In `Data.Nat.Properties`: diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index a9c21d9359..5dc16c0183 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -15,7 +15,7 @@ open import Algebra.Bundles.Raw using (RawMagma; RawMonoid; RawNearSemiring; Raw open import Algebra.Definitions.RawMagma using (_∣ˡ_) open import Data.Bool.Base using (Bool; true; false; T; not) open import Data.Parity.Base using (Parity; 0ℙ; 1ℙ) -open import Data.Product.Base using (_,_; proj₁) +open import Data.Product.Base using (_,_) open import Level using (0ℓ) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core From c1edba4fdb281969e126533874512dfb069a6a50 Mon Sep 17 00:00:00 2001 From: jamesmckinna <31931406+jamesmckinna@users.noreply.github.com> Date: Fri, 12 May 2023 16:45:09 +0100 Subject: [PATCH 13/17] Update CHANGELOG.md Co-authored-by: G. Allais --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9154cfc17b..f081cd6494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -442,7 +442,7 @@ Non-backwards compatible changes divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. Since the addition of 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 deprecation of (a function equiavlent to) the former + as a pattern synonym, and deprecation of (a function equivalent to) the former field name/projection function `proof`. * Accordingly, the definition has been changed to: From 519dde45e44b6a351853808d8fabee38f93abd56 Mon Sep 17 00:00:00 2001 From: James McKinna Date: Fri, 4 Aug 2023 14:16:06 +0100 Subject: [PATCH 14/17] removed deprecation wart in favour of new definition in `Data.Nat.Properties` --- CHANGELOG.md | 16 ++++++++-------- src/Data/Nat/Base.agda | 5 ----- src/Data/Nat/Properties.agda | 21 ++++++++++++--------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9154cfc17b..fc9f170d9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -442,15 +442,15 @@ Non-backwards compatible changes divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. Since the addition of 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 deprecation of (a function equiavlent to) the former - field name/projection function `proof`. + as a pattern synonym, and introduction of (a function equivalent to) the former + field name/projection function `proof` as `≤″-proof` in `Data.Nat.Properties`. * Accordingly, the definition has been changed to: ```agda _≤″_ : (m n : ℕ) → Set _≤″_ = _∣ˡ_ +-rawMagma - pattern less-than-or-equal {k} proof = k , proof + pattern less-than-or-equal {k} prf = k , prf ``` ### Renaming of `Reflection` modules @@ -1135,11 +1135,6 @@ Deprecated names map-with-∈↔ ↦ mapWith∈↔ ``` -* In `Data.Nat.Base`: - ``` - _≤″_.proof ↦ Data.Product.Base.proj₂ - ``` - * In `Data.Nat.Properties`: ``` suc[pred[n]]≡n ↦ suc-pred @@ -2170,6 +2165,11 @@ Other minor changes gcd-zero : Zero 1 gcd ``` +* Added new proof in `Data.Nat.Properties`: + ```agda + ≤″-proof : (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n + ``` + * Added new patterns in `Data.Nat.Reflection`: ```agda pattern `ℕ = def (quote ℕ) [] diff --git a/src/Data/Nat/Base.agda b/src/Data/Nat/Base.agda index 5dc16c0183..6b86c51bd5 100644 --- a/src/Data/Nat/Base.agda +++ b/src/Data/Nat/Base.agda @@ -371,8 +371,3 @@ compare (suc m) (suc n) with compare m n -- Version 2.0 -proof : ∀ {m n} (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n -proof (less-than-or-equal {k} prf) = prf -{-# WARNING_ON_USAGE proof -"Warning: _≤″_.proof was deprecated in v2.0. Please use pattern-matching on less-than-or-equal instead. Note that the definition of _≤″_ has changed" -#-} diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index 37c3824e99..e63bf000ea 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -2046,6 +2046,11 @@ m<ᵇ1+m+n m = <⇒<ᵇ (m≤m+n (suc m) _) <″⇒<ᵇ : ∀ {m n} → m <″ n → T (m <ᵇ n) <″⇒<ᵇ {m} (less-than-or-equal refl) = <⇒<ᵇ (m≤m+n (suc m) _) +-- equivalence to the old definition of _≤″_ + +≤″-proof : ∀ {m n} (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n +≤″-proof (less-than-or-equal {k} prf) = prf + -- equivalence to _≤_ ≤″⇒≤ : _≤″_ ⇒ _≤_ @@ -2080,8 +2085,8 @@ _>″?_ = flip _<″?_ ≤″-irrelevant : Irrelevant _≤″_ ≤″-irrelevant {m} (less-than-or-equal eq₁) (less-than-or-equal eq₂) - with +-cancelˡ-≡ m _ _ (trans eq₁ (sym eq₂)) -... | refl = cong less-than-or-equal (≡-irrelevant eq₁ eq₂) + with refl ← +-cancelˡ-≡ m _ _ (trans eq₁ (sym eq₂)) + = cong less-than-or-equal (≡-irrelevant eq₁ eq₂) <″-irrelevant : Irrelevant _<″_ <″-irrelevant = ≤″-irrelevant @@ -2097,17 +2102,15 @@ _>″?_ = flip _<″?_ ------------------------------------------------------------------------ ≤‴⇒≤″ : ∀{m n} → m ≤‴ n → m ≤″ n -≤‴⇒≤″ {m = m} ≤‴-refl = less-than-or-equal {k = 0} (+-identityʳ m) -≤‴⇒≤″ {m = m} (≤‴-step x) with less-than-or-equal proof ← ≤‴⇒≤″ x - = less-than-or-equal (trans (+-suc m _) proof) +≤‴⇒≤″ {m = m} ≤‴-refl = less-than-or-equal {k = 0} (+-identityʳ m) +≤‴⇒≤″ {m = m} (≤‴-step m≤n) = less-than-or-equal (trans (+-suc m _) (≤″-proof (≤‴⇒≤″ m≤n))) m≤‴m+k : ∀{m n k} → m + k ≡ n → m ≤‴ n -m≤‴m+k {m} {k = zero} refl = subst (λ z → m ≤‴ z) (sym (+-identityʳ m)) (≤‴-refl {m}) -m≤‴m+k {m} {k = suc k} proof - = ≤‴-step (m≤‴m+k {k = k} (trans (sym (+-suc m _)) proof)) +m≤‴m+k {m} {k = zero} refl = subst (λ z → m ≤‴ z) (sym (+-identityʳ m)) (≤‴-refl {m}) +m≤‴m+k {m} {k = suc k} prf = ≤‴-step (m≤‴m+k {k = k} (trans (sym (+-suc m _)) prf)) ≤″⇒≤‴ : ∀{m n} → m ≤″ n → m ≤‴ n -≤″⇒≤‴ (less-than-or-equal {k} proof) = m≤‴m+k proof +≤″⇒≤‴ (less-than-or-equal prf) = m≤‴m+k prf 0≤‴n : ∀{n} → 0 ≤‴ n 0≤‴n {n} = m≤‴m+k refl From 1c94a467e49b2d4ea77292fda5568c0312094b99 Mon Sep 17 00:00:00 2001 From: James McKinna Date: Fri, 4 Aug 2023 14:26:58 +0100 Subject: [PATCH 15/17] removed now-spurious `hiding` directive --- README/Design/Decidability.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README/Design/Decidability.agda b/README/Design/Decidability.agda index 3f267bed4a..e615af282e 100644 --- a/README/Design/Decidability.agda +++ b/README/Design/Decidability.agda @@ -11,7 +11,7 @@ module README.Design.Decidability where open import Data.Bool open import Data.List open import Data.List.Properties using (∷-injective) -open import Data.Nat hiding (proof) +open import Data.Nat open import Data.Nat.Properties using (suc-injective) open import Data.Product open import Data.Unit From b44100f01319e27d702750e437539674dc8c8c36 Mon Sep 17 00:00:00 2001 From: James McKinna Date: Fri, 4 Aug 2023 14:41:13 +0100 Subject: [PATCH 16/17] corrected `CHANGELOG` --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9f170d9a..a7f5884cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2070,6 +2070,8 @@ Other minor changes <⇒<′ : m < n → m <′ n <′⇒< : m <′ n → m < n + ≤″-proof : (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n + 1≤n! : 1 ≤ n ! _!≢0 : NonZero (n !) _!*_!≢0 : NonZero (m ! * n !) @@ -2165,11 +2167,6 @@ Other minor changes gcd-zero : Zero 1 gcd ``` -* Added new proof in `Data.Nat.Properties`: - ```agda - ≤″-proof : (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n - ``` - * Added new patterns in `Data.Nat.Reflection`: ```agda pattern `ℕ = def (quote ℕ) [] From 056fec12b2c1335cede076520d884ee0d22b63ab Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Tue, 8 Aug 2023 14:38:25 +0100 Subject: [PATCH 17/17] =?UTF-8?q?make=20equivalence=20proof=20`=E2=89=A4?= =?UTF-8?q?=E2=80=B3=E2=87=92=E2=89=A4=E2=80=B4`=20more=20lazy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Properties.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index d8f1e20da2..6db684587b 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -2060,7 +2060,7 @@ m<ᵇ1+m+n m = <⇒<ᵇ (m≤m+n (suc m) _) -- equivalence to the old definition of _≤″_ ≤″-proof : ∀ {m n} (le : m ≤″ n) → let less-than-or-equal {k} _ = le in m + k ≡ n -≤″-proof (less-than-or-equal {k} prf) = prf +≤″-proof (less-than-or-equal prf) = prf -- equivalence to _≤_ @@ -2121,7 +2121,7 @@ m≤‴m+k {m} {k = zero} refl = subst (λ z → m ≤‴ z) (sym (+-identityʳ m≤‴m+k {m} {k = suc k} prf = ≤‴-step (m≤‴m+k {k = k} (trans (sym (+-suc m _)) prf)) ≤″⇒≤‴ : ∀{m n} → m ≤″ n → m ≤‴ n -≤″⇒≤‴ (less-than-or-equal prf) = m≤‴m+k prf +≤″⇒≤‴ m≤n = m≤‴m+k (≤″-proof m≤n) 0≤‴n : ∀{n} → 0 ≤‴ n 0≤‴n {n} = m≤‴m+k refl