From e6c61163f2d703f302728aacb5d5639782aba322 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 25 Oct 2023 10:34:50 +0100 Subject: [PATCH 01/85] =?UTF-8?q?added=20new=20definitions=20to=20`=5F?= =?UTF-8?q?=E2=88=A3=5F`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility/Core.agda | 49 ++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 2f8cdbe241..11f3e48ce1 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -12,13 +12,13 @@ module Data.Nat.Divisibility.Core where -open import Data.Nat.Base using (ℕ; _*_) +open import Data.Nat.Base using (ℕ; _*_; NonZero; ≢-nonZero; ≢-nonZero⁻¹; _<_) open import Data.Nat.Properties open import Level using (0ℓ) -open import Relation.Nullary.Negation using (¬_) +open import Relation.Nullary.Negation using (¬_; contraposition) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality - using (_≡_; refl; sym; cong₂; module ≡-Reasoning) + using (_≡_; refl; cong; cong₂; subst; module ≡-Reasoning) ------------------------------------------------------------------------ -- Definition @@ -35,7 +35,37 @@ record _∣_ (m n : ℕ) : Set where constructor divides field quotient : ℕ equality : n ≡ quotient * m -open _∣_ using (quotient) public + + quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 + quotient≡0⇒n≡0 q≡0 = subst (λ q → n ≡ q * m) q≡0 equality + + instance + quotient≢0 : .{{NonZero n}} → NonZero quotient + quotient≢0 = ≢-nonZero (contraposition quotient≡0⇒n≡0 (≢-nonZero⁻¹ n)) + + n≡m*quotient : n ≡ m * quotient + n≡m*quotient = begin + n ≡⟨ equality ⟩ + quotient * m ≡⟨ *-comm quotient m ⟩ + m * quotient ∎ where open ≡-Reasoning + + module _ (11 : (m1 m λ q≤1 → n≮n n (begin-strict + n ≡⟨ equality ⟩ + quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ + 1 * m ≡⟨ *-identityˡ m ⟩ + m <⟨ m1; quotient<) public + ------------------------------------------------------------------------ -- Basic properties From 29c3cb78b9f1efb7005058cd0662108f3e722645 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 25 Oct 2023 10:37:00 +0100 Subject: [PATCH 02/85] `CHANGELOG` --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9f403d64..e73944dc8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2753,9 +2753,16 @@ Additions to existing modules <-asym : Asymmetric _<_ ``` -* Added a new pattern synonym to `Data.Nat.Divisibility.Core`: +* Added new definitions, a new NonZero instance, and a new pattern synonym to `Data.Nat.Divisibility.Core`: ```agda pattern divides-refl q = divides q refl + + instance quotient≢0 : .{{NonZero n}} → NonZero quotient + + quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 + n≡m*quotient : n ≡ m * quotient + quotient>1 : (1 Date: Wed, 25 Oct 2023 11:41:02 +0100 Subject: [PATCH 03/85] =?UTF-8?q?don't=20declare=20`quotient=E2=89=A20`=20?= =?UTF-8?q?as=20an=20`instance`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 ++--- src/Data/Nat/Divisibility/Core.agda | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e73944dc8a..aa22a30a24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2753,13 +2753,12 @@ Additions to existing modules <-asym : Asymmetric _<_ ``` -* Added new definitions, a new NonZero instance, and a new pattern synonym to `Data.Nat.Divisibility.Core`: +* Added new definitions and a new pattern synonym to `Data.Nat.Divisibility.Core`: ```agda pattern divides-refl q = divides q refl - instance quotient≢0 : .{{NonZero n}} → NonZero quotient - quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 + quotient≢0 : .{{NonZero n}} → NonZero quotient n≡m*quotient : n ≡ m * quotient quotient>1 : (1 Date: Wed, 25 Oct 2023 13:00:00 +0100 Subject: [PATCH 04/85] replace use of `subst` with one of `trans` --- src/Data/Nat/Divisibility/Core.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index e6eea7e988..a4ee7b7dfd 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -18,7 +18,7 @@ open import Level using (0ℓ) open import Relation.Nullary.Negation using (¬_; contraposition) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality - using (_≡_; refl; cong; cong₂; subst; module ≡-Reasoning) + using (_≡_; refl; trans; cong; cong₂; subst; module ≡-Reasoning) ------------------------------------------------------------------------ -- Definition @@ -37,7 +37,7 @@ record _∣_ (m n : ℕ) : Set where equality : n ≡ quotient * m quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 - quotient≡0⇒n≡0 q≡0 = subst (λ q → n ≡ q * m) q≡0 equality + quotient≡0⇒n≡0 q≡0 = trans equality (cong (_* m) q≡0) quotient≢0 : .{{NonZero n}} → NonZero quotient quotient≢0 = ≢-nonZero (contraposition quotient≡0⇒n≡0 (≢-nonZero⁻¹ n)) From 4edc8f8bbf4310da24324b3200b28fc3270bf742 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 25 Oct 2023 13:08:12 +0100 Subject: [PATCH 05/85] what's sauce for the goose... --- src/Data/Nat/Divisibility/Core.agda | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index a4ee7b7dfd..0abc461fe4 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -18,7 +18,7 @@ open import Level using (0ℓ) open import Relation.Nullary.Negation using (¬_; contraposition) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality - using (_≡_; refl; trans; cong; cong₂; subst; module ≡-Reasoning) + using (_≡_; refl; trans; cong; cong₂; module ≡-Reasoning) ------------------------------------------------------------------------ -- Definition @@ -43,10 +43,7 @@ record _∣_ (m n : ℕ) : Set where quotient≢0 = ≢-nonZero (contraposition quotient≡0⇒n≡0 (≢-nonZero⁻¹ n)) n≡m*quotient : n ≡ m * quotient - n≡m*quotient = begin - n ≡⟨ equality ⟩ - quotient * m ≡⟨ *-comm quotient m ⟩ - m * quotient ∎ where open ≡-Reasoning + n≡m*quotient = trans equality (*-comm quotient m) module _ (1 Date: Wed, 25 Oct 2023 13:38:06 +0100 Subject: [PATCH 06/85] switch to a `rewrite`-based solution... --- src/Data/Nat/Divisibility/Core.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 0abc461fe4..97a6c32c1a 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -37,13 +37,13 @@ record _∣_ (m n : ℕ) : Set where equality : n ≡ quotient * m quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 - quotient≡0⇒n≡0 q≡0 = trans equality (cong (_* m) q≡0) + quotient≡0⇒n≡0 q≡0 rewrite equality | q≡0 = refl quotient≢0 : .{{NonZero n}} → NonZero quotient quotient≢0 = ≢-nonZero (contraposition quotient≡0⇒n≡0 (≢-nonZero⁻¹ n)) n≡m*quotient : n ≡ m * quotient - n≡m*quotient = trans equality (*-comm quotient m) + n≡m*quotient rewrite *-comm m quotient = equality module _ (1 Date: Wed, 25 Oct 2023 19:47:56 +0100 Subject: [PATCH 07/85] tightened `import`s --- src/Data/Nat/Divisibility/Core.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 97a6c32c1a..92d1955e53 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -18,7 +18,7 @@ open import Level using (0ℓ) open import Relation.Nullary.Negation using (¬_; contraposition) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality - using (_≡_; refl; trans; cong; cong₂; module ≡-Reasoning) + using (_≡_; refl; cong₂; module ≡-Reasoning) ------------------------------------------------------------------------ -- Definition From 5e636a8a2ce818175c5a8280fe695f8bc6cc76a2 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 25 Oct 2023 20:24:38 +0100 Subject: [PATCH 08/85] simplified dependenciess --- src/Data/Nat/Divisibility/Core.agda | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 92d1955e53..41d2a9a268 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -45,18 +45,22 @@ record _∣_ (m n : ℕ) : Set where n≡m*quotient : n ≡ m * quotient n≡m*quotient rewrite *-comm m quotient = equality - module _ (11 : (m1 m λ q≤1 → n≮n n (begin-strict + quotient>1 : 1 < quotient + quotient>1 = ≰⇒> λ q≤1 → n≮n n (begin-strict n ≡⟨ equality ⟩ quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ 1 * m ≡⟨ *-identityˡ m ⟩ m <⟨ m Date: Wed, 25 Oct 2023 20:28:08 +0100 Subject: [PATCH 09/85] simplified dependencies; `CHANGELOG` --- src/Data/Nat/Divisibility/Core.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 41d2a9a268..f46fa58530 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -57,11 +57,11 @@ record _∣_ (m n : ℕ) : Set where m <⟨ m Date: Wed, 25 Oct 2023 20:38:19 +0100 Subject: [PATCH 10/85] removed `module` abstractions --- CHANGELOG.md | 4 ++-- src/Data/Nat/Divisibility/Core.agda | 31 +++++++++++------------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa22a30a24..4859b60a40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2758,9 +2758,9 @@ Additions to existing modules pattern divides-refl q = divides q refl quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 - quotient≢0 : .{{NonZero n}} → NonZero quotient + quotient≢0 : .{{NonZero n}} → NonZero quotient n≡m*quotient : n ≡ m * quotient - quotient>1 : (11 : (m1 : (m1 m λ q≤1 → n≮n n (begin-strict + n ≡⟨ equality ⟩ + quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ + 1 * m ≡⟨ *-identityˡ m ⟩ + m <⟨ m1 : 1 < quotient - quotient>1 = ≰⇒> λ q≤1 → n≮n n (begin-strict - n ≡⟨ equality ⟩ - quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ - 1 * m ≡⟨ *-identityˡ m ⟩ - m <⟨ m Date: Fri, 27 Oct 2023 10:42:50 +0100 Subject: [PATCH 11/85] =?UTF-8?q?delegated=20proof=20of=20`quotient?= =?UTF-8?q?=E2=89=A20`=20to=20`Data.Nat.Properties`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ src/Data/Nat/Divisibility/Core.agda | 7 ++----- src/Data/Nat/Properties.agda | 6 ++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4859b60a40..e765c0575d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2784,6 +2784,8 @@ Additions to existing modules n>0⇒n≢0 : n > 0 → n ≢ 0 m^n≢0 : .{{_ : NonZero m}} → NonZero (m ^ n) m*n≢0 : .{{_ : NonZero m}} .{{_ : NonZero n}} → NonZero (m * n) + m*n≢0⇒m≢0 : .{{NonZero (m * n)}} → NonZero m + m*n≢0⇒n≢0 : .{{NonZero (m * n)}} → NonZero n m≤n⇒n∸m≤n : m ≤ n → n ∸ m ≤ n s1 : (m1 m λ q≤1 → n≮n n (begin-strict diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index 37b1f33ee0..b6fb798130 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -905,6 +905,12 @@ m*n≢0 (suc m) (suc n) = _ m*n≡0⇒m≡0 : ∀ m n .{{_ : NonZero n}} → m * n ≡ 0 → m ≡ 0 m*n≡0⇒m≡0 zero (suc _) eq = refl +m*n≢0⇒m≢0 : ∀ m {n} → .{{NonZero (m * n)}} → NonZero m +m*n≢0⇒m≢0 (suc _) = _ + +m*n≢0⇒n≢0 : ∀ m {n} → .{{NonZero (m * n)}} → NonZero n +m*n≢0⇒n≢0 m {n} rewrite *-comm m n = m*n≢0⇒m≢0 n {m} + m*n≡1⇒m≡1 : ∀ m n → m * n ≡ 1 → m ≡ 1 m*n≡1⇒m≡1 (suc zero) n _ = refl m*n≡1⇒m≡1 (suc (suc m)) (suc zero) () From 305d34bd5da9bb215e5f98557901f207cd2fb8f1 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 27 Oct 2023 10:50:57 +0100 Subject: [PATCH 12/85] removed redundant property --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e765c0575d..8e23d27187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2757,7 +2757,6 @@ Additions to existing modules ```agda pattern divides-refl q = divides q refl - quotient≡0⇒n≡0 : quotient ≡ 0 → n ≡ 0 quotient≢0 : .{{NonZero n}} → NonZero quotient n≡m*quotient : n ≡ m * quotient quotient>1 : (m Date: Sat, 28 Oct 2023 09:30:18 +0100 Subject: [PATCH 13/85] cosmetic review changes; others to follow --- CHANGELOG.md | 4 ++-- src/Data/Nat/Divisibility/Core.agda | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e23d27187..6b0f24b322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2759,8 +2759,8 @@ Additions to existing modules quotient≢0 : .{{NonZero n}} → NonZero quotient n≡m*quotient : n ≡ m * quotient - quotient>1 : (m1 : m < n → 1 < quotient + quotient< : 1 < m → .{{NonZero n}} → quotient < n ``` * Added new definitions and proofs to `Data.Nat.Primality`: diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index f26f749dc4..f734eb97b6 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -42,7 +42,7 @@ record _∣_ (m n : ℕ) : Set where n≡m*quotient : n ≡ m * quotient n≡m*quotient rewrite equality = *-comm quotient m - quotient>1 : (m1 : m < n → 1 < quotient quotient>1 m λ q≤1 → n≮n n (begin-strict n ≡⟨ equality ⟩ quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ @@ -50,7 +50,7 @@ record _∣_ (m n : ℕ) : Set where m <⟨ m Date: Sat, 28 Oct 2023 09:39:18 +0100 Subject: [PATCH 14/85] better proof of `quotient>1` --- src/Data/Nat/Divisibility/Core.agda | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index f734eb97b6..6f9a48ed3b 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -43,12 +43,11 @@ record _∣_ (m n : ℕ) : Set where n≡m*quotient rewrite equality = *-comm quotient m quotient>1 : m < n → 1 < quotient - quotient>1 m λ q≤1 → n≮n n (begin-strict - n ≡⟨ equality ⟩ - quotient * m ≤⟨ *-monoˡ-≤ m q≤1 ⟩ - 1 * m ≡⟨ *-identityˡ m ⟩ - m <⟨ m1 m Date: Sat, 28 Oct 2023 09:42:47 +0100 Subject: [PATCH 15/85] `where` clause layout --- src/Data/Nat/Divisibility/Core.agda | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 6f9a48ed3b..c2ce55c43c 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -47,13 +47,15 @@ record _∣_ (m n : ℕ) : Set where m * 1 ≡⟨ *-identityʳ m ⟩ m <⟨ m Date: Mon, 30 Oct 2023 16:15:56 +0000 Subject: [PATCH 16/85] leaving in the flipped equality; moved everything else --- src/Data/Nat/Divisibility/Core.agda | 50 +++++++---------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index c2ce55c43c..f84c8d8261 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -12,10 +12,9 @@ module Data.Nat.Divisibility.Core where -open import Data.Nat.Base using (ℕ; _*_; NonZero; ≢-nonZero; ≢-nonZero⁻¹; _<_) +open import Data.Nat.Base using (ℕ; _*_) open import Data.Nat.Properties -open import Level using (0ℓ) -open import Relation.Nullary.Negation using (¬_; contraposition) +open import Relation.Nullary.Negation using (¬_) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong₂; module ≡-Reasoning) @@ -35,54 +34,29 @@ record _∣_ (m n : ℕ) : Set where constructor divides field quotient : ℕ equality : n ≡ quotient * m + equalityᵒ : n ≡ m * quotient + equalityᵒ rewrite equality = *-comm quotient m - quotient≢0 : .{{NonZero n}} → NonZero quotient - quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient - n≡m*quotient : n ≡ m * quotient - n≡m*quotient rewrite equality = *-comm quotient m - - quotient>1 : m < n → 1 < quotient - quotient>1 m1; quotient<) public - ------------------------------------------------------------------------ -- Basic properties *-pres-∣ : ∀ {m n o p} → o ∣ m → p ∣ n → o * p ∣ m * n -*-pres-∣ {m} {n} {o} {p} (divides c m≡c*o) (divides d n≡d*p) = +*-pres-∣ {m@.(c * o)} {n@.(d * p)} {o} {p} (divides-refl c) (divides-refl d) = divides (c * d) (begin - m * n ≡⟨ cong₂ _*_ m≡c*o n≡d*p ⟩ + m * n ≡⟨⟩ (c * o) * (d * p) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] c o d p ⟩ (c * d) * (o * p) ∎) where open ≡-Reasoning + +------------------------------------------------------------------------ +-- Exports + +open _∣_ using (quotient) public From 8d6cbf6d629c060bbea95e8596d9bd7d9ebe0be5 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 30 Oct 2023 16:17:30 +0000 Subject: [PATCH 17/85] new lemmas moved from `Core`; knock-on consequences; lots of tidying up --- src/Data/Nat/Divisibility.agda | 247 +++++++++++++++++---------------- 1 file changed, 128 insertions(+), 119 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index bb30716e01..eeee603322 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -8,15 +8,13 @@ module Data.Nat.Divisibility where -open import Algebra open import Data.Nat.Base open import Data.Nat.DivMod open import Data.Nat.Properties -open import Data.Unit.Base using (tt) -open import Function.Base using (_∘′_; _$_) +open import Function.Base using (_∘′_; _$_; flip) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (0ℓ) -open import Relation.Nullary.Decidable as Dec using (False; yes; no) +import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Binary.Core using (_⇒_) open import Relation.Binary.Bundles using (Preorder; Poset) @@ -30,39 +28,69 @@ open import Relation.Binary.PropositionalEquality.Core open import Relation.Binary.Reasoning.Syntax import Relation.Binary.PropositionalEquality.Properties as PropEq +private + variable d m n o : ℕ + + ------------------------------------------------------------------------ --- Definition +-- Definition and derived properties open import Data.Nat.Divisibility.Core public +module _ (m∣n : m ∣ n) where + + open _∣_ m∣n renaming (quotient to q) + open ≤-Reasoning + + quotient>1 : m < n → 1 < q + quotient>1 m⇒∤ : ∀ {m n} .{{_ : NonZero n}} → m > n → m ∤ n ->⇒∤ (s≤s m>n) m∣n = contradiction (∣⇒≤ m∣n) (≤⇒≯ m>n) +>⇒∤ : .⦃ _ : NonZero n ⦄ → m > n → m ∤ n +>⇒∤ (sn) m∣n = contradiction (∣⇒≤ m∣n) (≤⇒≯ m>n) ------------------------------------------------------------------------ -- _∣_ is a partial order @@ -80,16 +108,16 @@ m%n≡0⇔n∣m m n = mk⇔ (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n) divides (q * p) (sym (*-assoc q p _)) ∣-antisym : Antisymmetric _≡_ _∣_ -∣-antisym {m} {zero} _ (divides-refl q) = *-zeroʳ q -∣-antisym {zero} {n} (divides p eq) _ = sym (trans eq (*-comm p 0)) -∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p) +∣-antisym {m} {zero} _ q∣p = equalityᵒ where open _∣_ q∣p +∣-antisym {zero} {n} p∣q _ = sym equalityᵒ where open _∣_ p∣q +∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p) infix 4 _∣?_ _∣?_ : Decidable _∣_ -zero ∣? zero = yes (divides-refl 0) -zero ∣? suc m = no ((λ()) ∘′ ∣-antisym (divides-refl 0)) -suc n ∣? m = Dec.map (m%n≡0⇔n∣m m (suc n)) (m % suc n ≟ 0) +zero ∣? zero = Dec.yes (divides-refl 0) +zero ∣? suc m = Dec.no ((λ()) ∘′ ∣-antisym (divides-refl 0)) +n@(suc _) ∣? m = Dec.map (m%n≡0⇔n∣m m n) (m % n ≟ 0) ∣-isPreorder : IsPreorder _≡_ _∣_ ∣-isPreorder = record @@ -126,6 +154,8 @@ module ∣-Reasoning where open ∣-syntax _IsRelatedTo_ _IsRelatedTo_ ∣-go public +open ∣-Reasoning + ------------------------------------------------------------------------ -- Simple properties of _∣_ @@ -137,31 +167,30 @@ infix 10 1∣_ _∣0 _∣0 : ∀ n → n ∣ 0 n ∣0 = divides-refl 0 -0∣⇒≡0 : ∀ {n} → 0 ∣ n → n ≡ 0 +0∣⇒≡0 : 0 ∣ n → n ≡ 0 0∣⇒≡0 {n} 0∣n = ∣-antisym (n ∣0) 0∣n -∣1⇒≡1 : ∀ {n} → n ∣ 1 → n ≡ 1 +∣1⇒≡1 : n ∣ 1 → n ≡ 1 ∣1⇒≡1 {n} n∣1 = ∣-antisym n∣1 (1∣ n) -n∣n : ∀ {n} → n ∣ n +n∣n : n ∣ n n∣n {n} = ∣-refl ------------------------------------------------------------------------ -- Properties of _∣_ and _+_ -∣m∣n⇒∣m+n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m + n +∣m∣n⇒∣m+n : d ∣ m → d ∣ n → d ∣ m + n ∣m∣n⇒∣m+n (divides-refl p) (divides-refl q) = divides (p + q) (sym (*-distribʳ-+ _ p q)) -∣m+n∣m⇒∣n : ∀ {i m n} → i ∣ m + n → i ∣ m → i ∣ n -∣m+n∣m⇒∣n {i} {m} {n} (divides p m+n≡p*i) (divides q m≡q*i) = +∣m+n∣m⇒∣n : d ∣ m + n → d ∣ m → d ∣ n +∣m+n∣m⇒∣n {d} {m} {n} (divides p m+n≡p*d) (divides q m≡q*d) = divides (p ∸ q) $ begin-equality - n ≡⟨ sym (m+n∸n≡m n m) ⟩ + n ≡⟨ m+n∸n≡m n m ⟨ n + m ∸ m ≡⟨ cong (_∸ m) (+-comm n m) ⟩ - m + n ∸ m ≡⟨ cong₂ _∸_ m+n≡p*i m≡q*i ⟩ - p * i ∸ q * i ≡⟨ sym (*-distribʳ-∸ i p q) ⟩ - (p ∸ q) * i ∎ - where open ∣-Reasoning + m + n ∸ m ≡⟨ cong₂ _∸_ m+n≡p*d m≡q*d ⟩ + p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨ + (p ∸ q) * d ∎ ------------------------------------------------------------------------ -- Properties of _∣_ and _*_ @@ -175,136 +204,116 @@ m∣m*n n = divides n (*-comm _ n) n∣m*n*o : ∀ m {n} o → n ∣ m * n * o n∣m*n*o m o = ∣-trans (n∣m*n m) (m∣m*n o) -∣m⇒∣m*n : ∀ {i m} n → i ∣ m → i ∣ m * n -∣m⇒∣m*n {i} {m} n (divides-refl q) = ∣-trans (n∣m*n q) (m∣m*n n) +∣m⇒∣m*n : ∀ n → d ∣ m → d ∣ m * n +∣m⇒∣m*n n (divides-refl q) = ∣-trans (n∣m*n q) (m∣m*n n) -∣n⇒∣m*n : ∀ {i} m {n} → i ∣ n → i ∣ m * n +∣n⇒∣m*n : ∀ m {n} → d ∣ n → d ∣ m * n ∣n⇒∣m*n m {n} rewrite *-comm m n = ∣m⇒∣m*n m -m*n∣⇒m∣ : ∀ {i} m n → m * n ∣ i → m ∣ i +m*n∣⇒m∣ : ∀ m n → m * n ∣ d → m ∣ d m*n∣⇒m∣ m n (divides-refl q) = ∣n⇒∣m*n q (m∣m*n n) -m*n∣⇒n∣ : ∀ {i} m n → m * n ∣ i → n ∣ i +m*n∣⇒n∣ : ∀ m n → m * n ∣ d → n ∣ d m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m -*-monoʳ-∣ : ∀ {i j} k → i ∣ j → k * i ∣ k * j -*-monoʳ-∣ {i} {j@.(q * i)} k (divides-refl q) = divides q $ begin-equality - k * j ≡⟨⟩ - k * (q * i) ≡⟨ sym (*-assoc k q i) ⟩ - (k * q) * i ≡⟨ cong (_* i) (*-comm k q) ⟩ - (q * k) * i ≡⟨ *-assoc q k i ⟩ - q * (k * i) ∎ - where open ≤-Reasoning +*-monoʳ-∣ : ∀ k → m ∣ n → k * m ∣ k * n +*-monoʳ-∣ k = *-pres-∣ (∣-refl {k}) -*-monoˡ-∣ : ∀ {i j} k → i ∣ j → i * k ∣ j * k -*-monoˡ-∣ {i} {j} k rewrite *-comm i k | *-comm j k = *-monoʳ-∣ k +*-monoˡ-∣ : ∀ k → m ∣ n → m * k ∣ n * k +*-monoˡ-∣ k = flip *-pres-∣ (∣-refl {k}) -*-cancelˡ-∣ : ∀ {i j} k .{{_ : NonZero k}} → k * i ∣ k * j → i ∣ j -*-cancelˡ-∣ {i} {j} k@(suc _) (divides q eq) = - divides q $ *-cancelʳ-≡ j (q * i) _ $ begin-equality - j * k ≡⟨ *-comm j k ⟩ - k * j ≡⟨ eq ⟩ - q * (k * i) ≡⟨ cong (q *_) (*-comm k i) ⟩ - q * (i * k) ≡⟨ sym (*-assoc q i k) ⟩ - (q * i) * k ∎ - where open ≤-Reasoning +*-cancelˡ-∣ : ∀ k .⦃ _ : NonZero k ⦄ → k * m ∣ k * n → m ∣ n +*-cancelˡ-∣ {m} {n} k k*m∣k*n = divides q $ *-cancelˡ-≡ n (q * m) k $ begin-equality + k * n ≡⟨ equalityᵒ ⟩ + k * m * q ≡⟨ *-assoc k m q ⟩ + k * (m * q) ≡⟨ cong (k *_) (*-comm q m) ⟨ + k * (q * m) ∎ + where open _∣_ k*m∣k*n renaming (quotient to q) -*-cancelʳ-∣ : ∀ {i j} k .{{_ : NonZero k}} → i * k ∣ j * k → i ∣ j -*-cancelʳ-∣ {i} {j} k rewrite *-comm i k | *-comm j k = *-cancelˡ-∣ k +*-cancelʳ-∣ : ∀ k .⦃ _ : NonZero k ⦄ → m * k ∣ n * k → m ∣ n +*-cancelʳ-∣ {m} {n} k rewrite *-comm m k | *-comm n k = *-cancelˡ-∣ k ------------------------------------------------------------------------ -- Properties of _∣_ and _∸_ -∣m∸n∣n⇒∣m : ∀ i {m n} → n ≤ m → i ∣ m ∸ n → i ∣ n → i ∣ m -∣m∸n∣n⇒∣m i {m} {n} n≤m (divides p m∸n≡p*i) (divides q n≡q*o) = +∣m∸n∣n⇒∣m : ∀ d → n ≤ m → d ∣ m ∸ n → d ∣ n → d ∣ m +∣m∸n∣n⇒∣m {n} {m} d n≤m (divides p m∸n≡p*d) (divides q n≡q*o) = divides (p + q) $ begin-equality - m ≡⟨ sym (m+[n∸m]≡n n≤m) ⟩ + m ≡⟨ m+[n∸m]≡n n≤m ⟨ n + (m ∸ n) ≡⟨ +-comm n (m ∸ n) ⟩ - m ∸ n + n ≡⟨ cong₂ _+_ m∸n≡p*i n≡q*o ⟩ - p * i + q * i ≡⟨ sym (*-distribʳ-+ i p q) ⟩ - (p + q) * i ∎ - where open ≤-Reasoning + m ∸ n + n ≡⟨ cong₂ _+_ m∸n≡p*d n≡q*o ⟩ + p * d + q * d ≡⟨ *-distribʳ-+ d p q ⟨ + (p + q) * d ∎ ------------------------------------------------------------------------ -- Properties of _∣_ and _/_ -m/n∣m : ∀ {m n} .{{_ : NonZero n}} → n ∣ m → m / n ∣ m -m/n∣m {m@.(p * n)} {n} (divides-refl p) = begin +m/n∣m : .⦃ _ : NonZero n ⦄ → n ∣ m → m / n ∣ m +m/n∣m {n} {m@.(p * n)} (divides-refl p) = begin m / n ≡⟨⟩ p * n / n ≡⟨ m*n/n≡m p n ⟩ p ∣⟨ m∣m*n n ⟩ p * n ≡⟨⟩ m ∎ - where open ∣-Reasoning - -m*n∣o⇒m∣o/n : ∀ m n {o} .{{_ : NonZero n}} → m * n ∣ o → m ∣ o / n -m*n∣o⇒m∣o/n m n {o@.(p * (m * n))} (divides-refl p) = begin - m ∣⟨ n∣m*n p ⟩ - p * m ≡⟨ sym (*-identityʳ (p * m)) ⟩ - p * m * 1 ≡⟨ sym (cong (p * m *_) (n/n≡1 n)) ⟩ - p * m * (n / n) ≡⟨ sym (*-/-assoc (p * m) (n∣n {n})) ⟩ - p * m * n / n ≡⟨ cong (_/ n) (*-assoc p m n) ⟩ - p * (m * n) / n ≡⟨⟩ - o / n ∎ - where open ∣-Reasoning - -m*n∣o⇒n∣o/m : ∀ m n {o} .{{_ : NonZero m}} → m * n ∣ o → n ∣ (o / m) + +m*n∣o⇒m∣o/n : ∀ m n .⦃ _ : NonZero n ⦄ → m * n ∣ o → m ∣ o / n +m*n∣o⇒m∣o/n m n (divides-refl p) = divides p $ begin-equality + p * (m * n) / n ≡⟨ *-/-assoc p (n∣m*n m) ⟩ + p * ((m * n) / n) ≡⟨ cong (p *_) (m*n/n≡m m n) ⟩ + p * m ∎ + +m*n∣o⇒n∣o/m : ∀ m n .⦃ _ : NonZero m ⦄ → m * n ∣ o → n ∣ (o / m) m*n∣o⇒n∣o/m m n rewrite *-comm m n = m*n∣o⇒m∣o/n n m -m∣n/o⇒m*o∣n : ∀ {m n o} .{{_ : NonZero o}} → o ∣ n → m ∣ n / o → m * o ∣ n -m∣n/o⇒m*o∣n {m} {n} {o} (divides-refl p) m∣p*o/o = begin +m∣n/o⇒m*o∣n : .⦃ _ : NonZero o ⦄ → o ∣ n → m ∣ n / o → m * o ∣ n +m∣n/o⇒m*o∣n {o} {n} {m} (divides-refl p) m∣p*o/o = begin m * o ∣⟨ *-monoˡ-∣ o (subst (m ∣_) (m*n/n≡m p o) m∣p*o/o) ⟩ p * o ∎ - where open ∣-Reasoning -m∣n/o⇒o*m∣n : ∀ {m n o} .{{_ : NonZero o}} → o ∣ n → m ∣ n / o → o * m ∣ n -m∣n/o⇒o*m∣n {m} {_} {o} rewrite *-comm o m = m∣n/o⇒m*o∣n +m∣n/o⇒o*m∣n : .⦃ _ : NonZero o ⦄ → o ∣ n → m ∣ n / o → o * m ∣ n +m∣n/o⇒o*m∣n {o} {_} {m} rewrite *-comm o m = m∣n/o⇒m*o∣n -m/n∣o⇒m∣o*n : ∀ {m n o} .{{_ : NonZero n}} → n ∣ m → m / n ∣ o → m ∣ o * n -m/n∣o⇒m∣o*n {_} {n} {o} (divides-refl p) p*n/n∣o = begin +m/n∣o⇒m∣o*n : .⦃ _ : NonZero n ⦄ → n ∣ m → m / n ∣ o → m ∣ o * n +m/n∣o⇒m∣o*n {n} {o = o} (divides-refl p) p*n/n∣o = begin p * n ∣⟨ *-monoˡ-∣ n (subst (_∣ o) (m*n/n≡m p n) p*n/n∣o) ⟩ o * n ∎ - where open ∣-Reasoning -m∣n*o⇒m/n∣o : ∀ {m n o} .{{_ : NonZero n}} → n ∣ m → m ∣ o * n → m / n ∣ o -m∣n*o⇒m/n∣o {m@.(p * n)} {n@(suc _)} {o} (divides-refl p) pn∣on = begin +m∣n*o⇒m/n∣o : .⦃ _ : NonZero n ⦄ → n ∣ m → m ∣ o * n → m / n ∣ o +m∣n*o⇒m/n∣o {n} {m@.(p * n)} {o} (divides-refl p) pn∣on = begin m / n ≡⟨⟩ p * n / n ≡⟨ m*n/n≡m p n ⟩ p ∣⟨ *-cancelʳ-∣ n pn∣on ⟩ o ∎ - where open ∣-Reasoning ------------------------------------------------------------------------ -- Properties of _∣_ and _%_ -∣n∣m%n⇒∣m : ∀ {m n d} .{{_ : NonZero n}} → d ∣ n → d ∣ m % n → d ∣ m -∣n∣m%n⇒∣m {m} {n@.(a * d)} {d} (divides-refl a) (divides b m%n≡bd) = - divides (b + (m / n) * a) (begin-equality +∣n∣m%n⇒∣m : .⦃ _ : NonZero n ⦄ → d ∣ n → d ∣ m % n → d ∣ m +∣n∣m%n⇒∣m {n@.(p * d)} {d} {m} (divides-refl p) (divides q m%n≡qd) = + divides (q + (m / n) * p) $ begin-equality m ≡⟨ m≡m%n+[m/n]*n m n ⟩ - m % n + (m / n) * n ≡⟨ cong (_+ (m / n) * n) m%n≡bd ⟩ - b * d + (m / n) * n ≡⟨⟩ - b * d + (m / n) * (a * d) ≡⟨ sym (cong (b * d +_) (*-assoc (m / n) a d)) ⟩ - b * d + ((m / n) * a) * d ≡⟨ sym (*-distribʳ-+ d b _) ⟩ - (b + (m / n) * a) * d ∎) - where open ≤-Reasoning - -%-presˡ-∣ : ∀ {m n d} .{{_ : NonZero n}} → d ∣ m → d ∣ n → d ∣ m % n -%-presˡ-∣ {m@.(a * d)} {n} {d} (divides-refl a) (divides b 1+n≡bd) = - divides (a ∸ m / n * b) $ begin-equality - m % n ≡⟨ m%n≡m∸m/n*n m n ⟩ - m ∸ m / n * n ≡⟨ cong (λ v → m ∸ m / n * v) 1+n≡bd ⟩ - m ∸ m / n * (b * d) ≡⟨ cong (m ∸_) (*-assoc (m / n) b d) ⟨ - m ∸ (m / n * b) * d ≡⟨⟩ - a * d ∸ (m / n * b) * d ≡⟨ *-distribʳ-∸ d a (m / n * b) ⟨ - (a ∸ m / n * b) * d ∎ - where open ≤-Reasoning + m % n + (m / n) * n ≡⟨ cong (_+ (m / n) * n) m%n≡qd ⟩ + q * d + (m / n) * n ≡⟨⟩ + q * d + (m / n) * (p * d) ≡⟨ cong (q * d +_) (*-assoc (m / n) p d) ⟨ + q * d + ((m / n) * p) * d ≡⟨ *-distribʳ-+ d q _ ⟨ + (q + (m / n) * p) * d ∎ + +%-presˡ-∣ : .⦃ _ : NonZero n ⦄ → d ∣ m → d ∣ n → d ∣ m % n +%-presˡ-∣ {n} {d} {m@.(p * d)} (divides-refl p) (divides q 1+n≡qd) = + divides (p ∸ m / n * q) $ begin-equality + m % n ≡⟨ m%n≡m∸m/n*n m n ⟩ + m ∸ m / n * n ≡⟨ cong (λ v → m ∸ m / n * v) 1+n≡qd ⟩ + m ∸ m / n * (q * d) ≡⟨ cong (m ∸_) (*-assoc (m / n) q d) ⟨ + m ∸ (m / n * q) * d ≡⟨⟩ + p * d ∸ (m / n * q) * d ≡⟨ *-distribʳ-∸ d p (m / n * q) ⟨ + (p ∸ m / n * q) * d ∎ ------------------------------------------------------------------------ -- Properties of _∣_ and !_ -m≤n⇒m!∣n! : ∀ {m n} → m ≤ n → m ! ∣ n ! +m≤n⇒m!∣n! : m ≤ n → m ! ∣ n ! m≤n⇒m!∣n! m≤n = help (≤⇒≤′ m≤n) where - help : ∀ {m n} → m ≤′ n → m ! ∣ n ! - help {m} {n} ≤′-refl = ∣-refl - help {m} {suc n} (≤′-step m≤′n) = ∣n⇒∣m*n (suc n) (help m≤′n) + help : m ≤′ n → m ! ∣ n ! + help ≤′-refl = ∣-refl + help {n = n} (≤′-step m≤n) = ∣n⇒∣m*n n (help m≤n) From f1f91a929ab7b355dc68e7ce906d04c2e01879a5 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 30 Oct 2023 16:24:13 +0000 Subject: [PATCH 18/85] tidying up; `CHANGELOG` --- CHANGELOG.md | 16 +++++++++++----- src/Data/Nat/Divisibility.agda | 14 +++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b0f24b322..9b3a88df3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2753,14 +2753,20 @@ Additions to existing modules <-asym : Asymmetric _<_ ``` -* Added new definitions and a new pattern synonym to `Data.Nat.Divisibility.Core`: +* Added a new pattern synonym and a new proof to `Data.Nat.Divisibility.Core`: ```agda pattern divides-refl q = divides q refl - quotient≢0 : .{{NonZero n}} → NonZero quotient - n≡m*quotient : n ≡ m * quotient - quotient>1 : m < n → 1 < quotient - quotient< : 1 < m → .{{NonZero n}} → quotient < n + equalityᵒ : n ≡ m * quotient + ``` + +* Added a new instance and new definitions to `Data.Nat.Divisibility`: + ```agda + instance quotient≢0 : .{{NonZero n}} → NonZero quotient + + quotient∣ : q ∣ n + quotient>1 : m < n → 1 < quotient + quotient< : 1 < m → .{{NonZero n}} → quotient < n ``` * Added new definitions and proofs to `Data.Nat.Primality`: diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index eeee603322..7592a11712 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -42,6 +42,13 @@ module _ (m∣n : m ∣ n) where open _∣_ m∣n renaming (quotient to q) open ≤-Reasoning + instance + quotient≢0 : .⦃ NonZero n ⦄ → NonZero q + quotient≢0 rewrite equality = m*n≢0⇒m≢0 q + + quotient∣ : q ∣ n + quotient∣ = divides m equalityᵒ + quotient>1 : m < n → 1 < q quotient>1 m Date: Mon, 30 Oct 2023 16:58:53 +0000 Subject: [PATCH 19/85] cosmetic tweaks --- src/Data/Nat/Divisibility.agda | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 7592a11712..8e8c028f61 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -24,9 +24,10 @@ open import Relation.Binary.Definitions using (Reflexive; Transitive; Antisymmetric; Decidable) import Relation.Binary.Reasoning.Preorder as PreorderReasoning open import Relation.Binary.PropositionalEquality.Core - using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst) + using (_≡_; refl; sym; cong; cong₂; subst) open import Relation.Binary.Reasoning.Syntax -import Relation.Binary.PropositionalEquality.Properties as PropEq +open import Relation.Binary.PropositionalEquality.Properties + using (isEquivalence; module ≡-Reasoning) private variable d m n o : ℕ @@ -67,11 +68,11 @@ module _ (m∣n : m ∣ n) where -- Relationship with _%_ m%n≡0⇒n∣m : ∀ m n .⦃ _ : NonZero n ⦄ → m % n ≡ 0 → n ∣ m -m%n≡0⇒n∣m m n eq = divides (m / n) $ begin-equality +m%n≡0⇒n∣m m n eq = divides (m / n) $ begin m ≡⟨ m≡m%n+[m/n]*n m n ⟩ m % n + m / n * n ≡⟨ cong₂ (_+_) eq refl ⟩ m / n * n ∎ - where open ≤-Reasoning + where open ≡-Reasoning n∣m⇒m%n≡0 : ∀ m n .⦃ _ : NonZero n ⦄ → n ∣ m → m % n ≡ 0 n∣m⇒m%n≡0 .(q * n) n (divides-refl q) = m*n%n≡0 q n @@ -90,7 +91,7 @@ m%n≡0⇔n∣m m n = mk⇔ (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n) where open ≤-Reasoning >⇒∤ : .⦃ _ : NonZero n ⦄ → m > n → m ∤ n ->⇒∤ (sn) m∣n = contradiction (∣⇒≤ m∣n) (≤⇒≯ m>n) +>⇒∤ {n@(suc _)} n Date: Tue, 31 Oct 2023 07:37:05 +0000 Subject: [PATCH 20/85] reverted to simple version --- src/Data/Nat/Divisibility/Core.agda | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index f84c8d8261..42f3687d66 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -12,13 +12,17 @@ module Data.Nat.Divisibility.Core where -open import Data.Nat.Base using (ℕ; _*_) +open import Data.Nat.Base using (ℕ; _*_; NonZero) open import Data.Nat.Properties open import Relation.Nullary.Negation using (¬_) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong₂; module ≡-Reasoning) + +private + variable m n o p : ℕ + ------------------------------------------------------------------------ -- Definition -- @@ -48,12 +52,12 @@ pattern divides-refl q = divides q refl ------------------------------------------------------------------------ -- Basic properties -*-pres-∣ : ∀ {m n o p} → o ∣ m → p ∣ n → o * p ∣ m * n -*-pres-∣ {m@.(c * o)} {n@.(d * p)} {o} {p} (divides-refl c) (divides-refl d) = - divides (c * d) (begin +*-pres-∣ : o ∣ m → p ∣ n → o * p ∣ m * n +*-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = + divides (q * r) (begin m * n ≡⟨⟩ - (c * o) * (d * p) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] c o d p ⟩ - (c * d) * (o * p) ∎) + (q * o) * (r * p) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] q o r p ⟩ + (q * r) * (o * p) ∎) where open ≡-Reasoning ------------------------------------------------------------------------ From 8fad66912e03c832e940adf7cf6f4d6c15872236 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Tue, 31 Oct 2023 08:02:24 +0000 Subject: [PATCH 21/85] problems with exporting `quotient` --- src/Data/Nat/Divisibility/Core.agda | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 42f3687d66..13bade372c 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -59,8 +59,3 @@ pattern divides-refl q = divides q refl (q * o) * (r * p) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] q o r p ⟩ (q * r) * (o * p) ∎) where open ≡-Reasoning - ------------------------------------------------------------------------- --- Exports - -open _∣_ using (quotient) public From 3a0d8817c146fc96cdd12d36318884b46f290057 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Tue, 31 Oct 2023 10:52:28 +0000 Subject: [PATCH 22/85] added last lemma: defining equation for `_/_` --- CHANGELOG.md | 1 + src/Data/Nat/Divisibility.agda | 43 ++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b3a88df3b..86f3c0802d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2767,6 +2767,7 @@ Additions to existing modules quotient∣ : q ∣ n quotient>1 : m < n → 1 < quotient quotient< : 1 < m → .{{NonZero n}} → quotient < n + n/m≡quotient : .{{ _ : NonZero m }} → n / m ≡ quotient ``` * Added new definitions and proofs to `Data.Nat.Primality`: diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 8e8c028f61..d56e93600e 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -11,7 +11,7 @@ module Data.Nat.Divisibility where open import Data.Nat.Base open import Data.Nat.DivMod open import Data.Nat.Properties -open import Function.Base using (_∘′_; _$_; flip) +open import Function.Base using (_∘′_; _$_; flip; case_returning_of_) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (0ℓ) import Relation.Nullary.Decidable as Dec @@ -40,28 +40,41 @@ open import Data.Nat.Divisibility.Core public module _ (m∣n : m ∣ n) where - open _∣_ m∣n renaming (quotient to q) + open _∣_ m∣n open ≤-Reasoning instance - quotient≢0 : .⦃ NonZero n ⦄ → NonZero q - quotient≢0 rewrite equality = m*n≢0⇒m≢0 q + quotient≢0 : .⦃ NonZero n ⦄ → NonZero quotient + quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient - quotient∣ : q ∣ n + quotient∣ : quotient ∣ n quotient∣ = divides m equalityᵒ - quotient>1 : m < n → 1 < q - quotient>1 m1 : m < n → 1 < quotient + quotient>1 m Date: Tue, 31 Oct 2023 13:23:29 +0000 Subject: [PATCH 23/85] improved `CHANGELOG` --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f3c0802d..82ef8403d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2764,10 +2764,10 @@ Additions to existing modules ```agda instance quotient≢0 : .{{NonZero n}} → NonZero quotient - quotient∣ : q ∣ n - quotient>1 : m < n → 1 < quotient - quotient< : 1 < m → .{{NonZero n}} → quotient < n - n/m≡quotient : .{{ _ : NonZero m }} → n / m ≡ quotient + quotient∣ : m ∣ n → quotient ∣ n + quotient>1 : m ∣ n → m < n → 1 < quotient + quotient< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n + n/m≡quotient : m ∣ n → .{{ _ : NonZero m }} → n / m ≡ quotient ``` * Added new definitions and proofs to `Data.Nat.Primality`: From 8dc3901222cfa2f57d8ff2142da497e85911b7d0 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 1 Nov 2023 12:34:43 +0000 Subject: [PATCH 24/85] revert: simplified imports --- src/Data/Nat/Divisibility.agda | 2 +- src/Data/Nat/Divisibility/Core.agda | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index d56e93600e..950fd331bf 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -11,7 +11,7 @@ module Data.Nat.Divisibility where open import Data.Nat.Base open import Data.Nat.DivMod open import Data.Nat.Properties -open import Function.Base using (_∘′_; _$_; flip; case_returning_of_) +open import Function.Base using (_∘′_; _$_; flip) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (0ℓ) import Relation.Nullary.Decidable as Dec diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 13bade372c..f3da6fd770 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -12,7 +12,7 @@ module Data.Nat.Divisibility.Core where -open import Data.Nat.Base using (ℕ; _*_; NonZero) +open import Data.Nat.Base using (ℕ; _*_) open import Data.Nat.Properties open import Relation.Nullary.Negation using (¬_) open import Relation.Binary.Core using (Rel) From d05b959868c6fe92cc4a42613f2e9aec3b29cc27 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 1 Nov 2023 12:40:35 +0000 Subject: [PATCH 25/85] improved `CHANGELOG` --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ef8403d7..f1d0819979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2762,7 +2762,7 @@ Additions to existing modules * Added a new instance and new definitions to `Data.Nat.Divisibility`: ```agda - instance quotient≢0 : .{{NonZero n}} → NonZero quotient + instance quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient quotient∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient From 33ebce9762166ae7f68e71f2e0b0da6156ddff1a Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 08:33:52 +0000 Subject: [PATCH 26/85] =?UTF-8?q?endpoint=20of=20simplifying=20the=20proof?= =?UTF-8?q?=20of=20`*-pres-=E2=88=A3`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility/Core.agda | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index f3da6fd770..164dd7df2f 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -54,8 +54,4 @@ pattern divides-refl q = divides q refl *-pres-∣ : o ∣ m → p ∣ n → o * p ∣ m * n *-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = - divides (q * r) (begin - m * n ≡⟨⟩ - (q * o) * (r * p) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] q o r p ⟩ - (q * r) * (o * p) ∎) - where open ≡-Reasoning + divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) From a03b552565e50667a64cdeffcac94a82b22e06f5 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 09:28:08 +0000 Subject: [PATCH 27/85] =?UTF-8?q?simplified=20the=20proof=20of=20`n/m?= =?UTF-8?q?=E2=89=A1quotient`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility.agda | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 950fd331bf..faf830a61c 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -63,19 +63,17 @@ module _ (m∣n : m ∣ n) where quotient * m ≡⟨ equality ⟨ n ∎ --- defining equation for _/_ - - n/m≡quotient : .⦃ _ : NonZero m ⦄ → n / m ≡ quotient - n/m≡quotient = *-cancelʳ-≡ _ _ m $ begin-equality - n / m * m ≡⟨ m/n*n≡m m∣n ⟩ - n ≡⟨ equality ⟩ - quotient * m ∎ ------------------------------------------------------------------------ -- Exports open _∣_ using (quotient) public +------------------------------------------------------------------------ +-- defining equation for _/_ + +n/m≡quotient : (m∣n : m ∣ n) .⦃ _ : NonZero m ⦄ → n / m ≡ quotient m∣n +n/m≡quotient {m = m} (divides-refl q) = m*n/n≡m q m ------------------------------------------------------------------------ -- Relationship with _%_ From 4f438cfbe4f752df21f2a85c7b54851f3d528f80 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 09:52:47 +0000 Subject: [PATCH 28/85] =?UTF-8?q?simplified=20the=20proof=20of=20`?= =?UTF-8?q?=E2=88=A3m+n=E2=88=A3m=E2=87=92=E2=88=A3n`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index faf830a61c..661f9c80ed 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -196,11 +196,11 @@ n∣n {n} = ∣-refl divides (p + q) (sym (*-distribʳ-+ _ p q)) ∣m+n∣m⇒∣n : d ∣ m + n → d ∣ m → d ∣ n -∣m+n∣m⇒∣n {d} {m} {n} (divides p m+n≡p*d) (divides q m≡q*d) = +∣m+n∣m⇒∣n {d} {m} {n} (divides p m+n≡p*d) (divides-refl q) = divides (p ∸ q) $ begin-equality n ≡⟨ m+n∸n≡m n m ⟨ n + m ∸ m ≡⟨ cong (_∸ m) (+-comm n m) ⟩ - m + n ∸ m ≡⟨ cong₂ _∸_ m+n≡p*d m≡q*d ⟩ + m + n ∸ m ≡⟨ cong (_∸ m) m+n≡p*d ⟩ p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨ (p ∸ q) * d ∎ From 2ff5f79cb857e7fa7c9c5cdab8ea3bb63f896896 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 09:55:38 +0000 Subject: [PATCH 29/85] =?UTF-8?q?simplified=20the=20proof=20of=20`?= =?UTF-8?q?=E2=88=A3m=E2=88=B8n=E2=88=A3n=E2=87=92=E2=88=A3m`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 661f9c80ed..6d527ce002 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -249,11 +249,11 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m -- Properties of _∣_ and _∸_ ∣m∸n∣n⇒∣m : ∀ d → n ≤ m → d ∣ m ∸ n → d ∣ n → d ∣ m -∣m∸n∣n⇒∣m {n} {m} d n≤m (divides p m∸n≡p*d) (divides q n≡q*o) = +∣m∸n∣n⇒∣m {n} {m} d n≤m (divides p m∸n≡p*d) (divides-refl q) = divides (p + q) $ begin-equality m ≡⟨ m+[n∸m]≡n n≤m ⟨ n + (m ∸ n) ≡⟨ +-comm n (m ∸ n) ⟩ - m ∸ n + n ≡⟨ cong₂ _+_ m∸n≡p*d n≡q*o ⟩ + m ∸ n + n ≡⟨ cong (_+ n) m∸n≡p*d ⟩ p * d + q * d ≡⟨ *-distribʳ-+ d p q ⟨ (p + q) * d ∎ From a3756c9c2db5a961d0694fb0da85cdb53fca1a60 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 12:27:56 +0000 Subject: [PATCH 30/85] simplified `import`s --- src/Data/Nat/Divisibility/Core.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 164dd7df2f..ecd46e2fd1 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -16,8 +16,8 @@ open import Data.Nat.Base using (ℕ; _*_) open import Data.Nat.Properties open import Relation.Nullary.Negation using (¬_) open import Relation.Binary.Core using (Rel) -open import Relation.Binary.PropositionalEquality - using (_≡_; refl; cong₂; module ≡-Reasoning) +open import Relation.Binary.PropositionalEquality.Core + using (_≡_; refl) private From efd0b20c46fb7f104feabc6edf3bd5c7193607b2 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 12:31:03 +0000 Subject: [PATCH 31/85] simplified a lot of proofs, esp. wrt `divides-refl` and `NonZero` reasoning --- src/Data/Nat/DivMod.agda | 115 ++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 51 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index bbb8288838..948f84a85f 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -173,14 +173,14 @@ m<[1+n%d]⇒m≤[n%d] {m} n (suc d-1) = k<1+a[modₕ]n⇒k≤a[modₕ]n 0 m n d- m′ * n′ + (m′ * j + (n′ + j * d) * k) * d ∎ %-remove-+ˡ : ∀ {m} n {d} .{{_ : NonZero d}} → d ∣ m → (m + n) % d ≡ n % d -%-remove-+ˡ {m@.(p * d)} n {d@(suc _)} (divides-refl p) = begin-equality +%-remove-+ˡ {m@.(p * d)} n {d} (divides-refl p) = begin-equality (m + n) % d ≡⟨⟩ (p * d + n) % d ≡⟨ cong (_% d) (+-comm (p * d) n) ⟩ (n + p * d) % d ≡⟨ [m+kn]%n≡m%n n p d ⟩ n % d ∎ %-remove-+ʳ : ∀ m {n d} .{{_ : NonZero d}} → d ∣ n → (m + n) % d ≡ m % d -%-remove-+ʳ m {n} {suc _} eq rewrite +-comm m n = %-remove-+ˡ {n} m eq +%-remove-+ʳ m {n} rewrite +-comm m n = %-remove-+ˡ {n} m ------------------------------------------------------------------------ -- Properties of _/_ @@ -204,16 +204,16 @@ m*n/n≡m : ∀ m n .{{_ : NonZero n}} → m * n / n ≡ m m*n/n≡m m (suc n-1) = a*n[divₕ]n≡a 0 m n-1 m/n*n≡m : ∀ {m n} .{{_ : NonZero n}} → n ∣ m → m / n * n ≡ m -m/n*n≡m {_} {n@(suc _)} (divides-refl q) = cong (_* n) (m*n/n≡m q n) +m/n*n≡m {n = n} (divides-refl q) = cong (_* n) (m*n/n≡m q n) m*[n/m]≡n : .{{_ : NonZero m}} → m ∣ n → m * (n / m) ≡ n m*[n/m]≡n {m} m∣n = trans (*-comm m (_ / m)) (m/n*n≡m m∣n) m/n*n≤m : ∀ m n .{{_ : NonZero n}} → (m / n) * n ≤ m -m/n*n≤m m n@(suc n-1) = begin +m/n*n≤m m n = begin (m / n) * n ≤⟨ m≤m+n ((m / n) * n) (m % n) ⟩ (m / n) * n + m % n ≡⟨ +-comm _ (m % n) ⟩ - m % n + (m / n) * n ≡⟨ sym (m≡m%n+[m/n]*n m n) ⟩ + m % n + (m / n) * n ≡⟨ m≡m%n+[m/n]*n m n ⟨ m ∎ m/n≤m : ∀ m n .{{_ : NonZero n}} → (m / n) ≤ m @@ -222,11 +222,11 @@ m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin m ≤⟨ m≤m*n m n ⟩ m * n ∎) -m/n0 : ∀ {m n} .{{_ : NonZero n}} → m ≥ n → m / n > 0 m≥n⇒m/n>0 {m@(suc _)} {n@(suc _)} m≥n = begin - 1 ≡⟨ sym (n/n≡1 m) ⟩ + 1 ≡⟨ n/n≡1 m ⟨ m / m ≤⟨ /-monoʳ-≤ m m≥n ⟩ m / n ∎ @@ -262,20 +262,20 @@ m≥n⇒m/n>0 {m@(suc _)} {n@(suc _)} m≥n = begin +-distrib-/-∣ˡ : ∀ {m} n {d} .{{_ : NonZero d}} → d ∣ m → (m + n) / d ≡ m / d + n / d -+-distrib-/-∣ˡ {m@.(p * d)} n {d} (divides-refl p) = +-distrib-/ m n (begin-strict ++-distrib-/-∣ˡ {m@.(p * d)} n {d} (divides-refl p) = +-distrib-/ m n $ begin-strict m % d + n % d ≡⟨⟩ p * d % d + n % d ≡⟨ cong (_+ n % d) (m*n%n≡0 p d) ⟩ n % d <⟨ m%n0 (≢-nonZero⁻¹ o)) (≮⇒≥ n≮o) + where + n≥o = ≮⇒≥ n≮o + n∸o0 (≢-nonZero⁻¹ o)) n≥o -m*n/o*n≡m/o : ∀ m n o .⦃ _ : NonZero o ⦄ ⦃ _ : NonZero (o * n) ⦄ → +m*n/o*n≡m/o : ∀ m n o .⦃ _ : NonZero n ⦄ ⦃ _ : NonZero o ⦄ → + let instance _ = m*n≢0 o n in m * n / (o * n) ≡ m / o -m*n/o*n≡m/o m n o ⦃ _ ⦄ ⦃ o*n≢0 ⦄ = begin-equality - m * n / (o * n) ≡⟨ /-congˡ (*-comm m n) ⟩ +m*n/o*n≡m/o m n o = begin-equality + m * n / (o * n) ≡⟨ /-congˡ {o = o * n} (*-comm m n) ⟩ n * m / (o * n) ≡⟨ /-congʳ (*-comm o n) ⟩ n * m / (n * o) ≡⟨ m*n/m*o≡n/o n m o ⟩ m / o ∎ - where instance n*o≢0 = subst NonZero (*-comm o n) o*n≢0 + where + instance _ = m*n≢0 o n + instance _ = m*n≢0 n o m Date: Thu, 2 Nov 2023 12:47:35 +0000 Subject: [PATCH 32/85] simplified more proofs, esp. wrt `divides-refl` reasoning --- src/Data/Nat/Divisibility.agda | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 6d527ce002..8b3ac7844b 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -63,12 +63,11 @@ module _ (m∣n : m ∣ n) where quotient * m ≡⟨ equality ⟨ n ∎ - ------------------------------------------------------------------------- -- Exports open _∣_ using (quotient) public + ------------------------------------------------------------------------ -- defining equation for _/_ @@ -80,10 +79,10 @@ n/m≡quotient {m = m} (divides-refl q) = m*n/n≡m q m m%n≡0⇒n∣m : ∀ m n .⦃ _ : NonZero n ⦄ → m % n ≡ 0 → n ∣ m m%n≡0⇒n∣m m n eq = divides (m / n) $ begin - m ≡⟨ m≡m%n+[m/n]*n m n ⟩ - m % n + m / n * n ≡⟨ cong₂ (_+_) eq refl ⟩ - m / n * n ∎ - where open ≡-Reasoning + m ≡⟨ m≡m%n+[m/n]*n m n ⟩ + m % n + [m/n]*n ≡⟨ cong (_+ [m/n]*n) eq ⟩ + [m/n]*n ∎ + where open ≡-Reasoning; [m/n]*n = m / n * n n∣m⇒m%n≡0 : ∀ m n .⦃ _ : NonZero n ⦄ → n ∣ m → m % n ≡ 0 n∣m⇒m%n≡0 .(q * n) n (divides-refl q) = m*n%n≡0 q n @@ -95,11 +94,7 @@ m%n≡0⇔n∣m m n = mk⇔ (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n) -- Properties of _∣_ and _≤_ ∣⇒≤ : .⦃ _ : NonZero n ⦄ → m ∣ n → m ≤ n -∣⇒≤ {n@(suc _)} {m} (divides q@(suc p) eq) = begin - m ≤⟨ m≤m+n m (p * m) ⟩ - q * m ≡⟨ eq ⟨ - n ∎ - where open ≤-Reasoning +∣⇒≤ {n@.(q * m)} {m} (divides-refl q@(suc p)) = m≤m+n m (p * m) >⇒∤ : .⦃ _ : NonZero n ⦄ → m > n → m ∤ n >⇒∤ {n@(suc _)} n Date: Thu, 2 Nov 2023 12:57:40 +0000 Subject: [PATCH 33/85] simplified `import`s --- src/Data/Nat/Divisibility.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 8b3ac7844b..1a8cbeeab8 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -24,7 +24,7 @@ open import Relation.Binary.Definitions using (Reflexive; Transitive; Antisymmetric; Decidable) import Relation.Binary.Reasoning.Preorder as PreorderReasoning open import Relation.Binary.PropositionalEquality.Core - using (_≡_; refl; sym; cong; cong₂; subst) + using (_≡_; refl; sym; cong; subst) open import Relation.Binary.Reasoning.Syntax open import Relation.Binary.PropositionalEquality.Properties using (isEquivalence; module ≡-Reasoning) From 17ac38832d8f36bba7523327784f8a8fd926727a Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 13:04:44 +0000 Subject: [PATCH 34/85] =?UTF-8?q?moved=20`equality=E1=B5=92`=20proof=20out?= =?UTF-8?q?=20of=20`Core`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility.agda | 11 +++++++---- src/Data/Nat/Divisibility/Core.agda | 3 --- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 1a8cbeeab8..2aa52ce68c 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -47,6 +47,9 @@ module _ (m∣n : m ∣ n) where quotient≢0 : .⦃ NonZero n ⦄ → NonZero quotient quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient + equalityᵒ : n ≡ m * quotient + equalityᵒ rewrite equality = *-comm quotient m + quotient∣ : quotient ∣ n quotient∣ = divides m equalityᵒ @@ -115,8 +118,8 @@ m%n≡0⇔n∣m m n = mk⇔ (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n) divides (q * p) (sym (*-assoc q p _)) ∣-antisym : Antisymmetric _≡_ _∣_ -∣-antisym {m} {zero} _ q∣p = equalityᵒ where open _∣_ q∣p -∣-antisym {zero} {n} p∣q _ = sym equalityᵒ where open _∣_ p∣q +∣-antisym {m} {zero} _ q∣p = equalityᵒ q∣p +∣-antisym {zero} {n} p∣q _ = sym (equalityᵒ p∣q) ∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p) infix 4 _∣?_ @@ -231,11 +234,11 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m *-cancelˡ-∣ : ∀ k .⦃ _ : NonZero k ⦄ → k * m ∣ k * n → m ∣ n *-cancelˡ-∣ {m} {n} k k*m∣k*n = divides q $ *-cancelˡ-≡ n (q * m) k $ begin-equality - k * n ≡⟨ equalityᵒ ⟩ + k * n ≡⟨ equalityᵒ k*m∣k*n ⟩ k * m * q ≡⟨ *-assoc k m q ⟩ k * (m * q) ≡⟨ cong (k *_) (*-comm q m) ⟨ k * (q * m) ∎ - where open _∣_ k*m∣k*n renaming (quotient to q) + where q = quotient k*m∣k*n *-cancelʳ-∣ : ∀ k .⦃ _ : NonZero k ⦄ → m * k ∣ n * k → m ∣ n *-cancelʳ-∣ {m} {n} k rewrite *-comm m k | *-comm n k = *-cancelˡ-∣ k diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index ecd46e2fd1..92649d756a 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -38,9 +38,6 @@ record _∣_ (m n : ℕ) : Set where constructor divides field quotient : ℕ equality : n ≡ quotient * m - equalityᵒ : n ≡ m * quotient - equalityᵒ rewrite equality = *-comm quotient m - _∤_ : Rel ℕ _ m ∤ n = ¬ (m ∣ n) From 72c93a83b847dbd2ff173fdb6441e47042931d7c Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 13:07:02 +0000 Subject: [PATCH 35/85] `CHANGELOG` --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d0819979..8b0e9ec607 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2756,14 +2756,13 @@ Additions to existing modules * Added a new pattern synonym and a new proof to `Data.Nat.Divisibility.Core`: ```agda pattern divides-refl q = divides q refl - - equalityᵒ : n ≡ m * quotient ``` * Added a new instance and new definitions to `Data.Nat.Divisibility`: ```agda instance quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient + equalityᵒ : m ∣ n → n ≡ m * quotient quotient∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient quotient< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n From 6d819ae6f06d2aed79ceb1b03aa0782ad57bb0fd Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 2 Nov 2023 15:27:49 +0000 Subject: [PATCH 36/85] temporary fix: further `NonZero` refactoring advised! --- src/Data/Rational/Properties.agda | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Data/Rational/Properties.agda b/src/Data/Rational/Properties.agda index f0a7d11c96..c7556323b0 100644 --- a/src/Data/Rational/Properties.agda +++ b/src/Data/Rational/Properties.agda @@ -311,12 +311,12 @@ normalize-injective-≃ : ∀ m n c d {{_ : ℕ.NonZero c}} {{_ : ℕ.NonZero d} normalize-injective-≃ m n c d eq = ℕ./-cancelʳ-≡ md∣gcd[m,c]gcd[n,d] nc∣gcd[m,c]gcd[n,d] - (begin + $ begin (m ℕ.* d) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ≡⟨ ℕ./-*-interchange gcd[m,c]∣m gcd[n,d]∣d ⟩ (m ℕ./ gcd[m,c]) ℕ.* (d ℕ./ gcd[n,d]) ≡⟨ cong₂ ℕ._*_ m/gcd[m,c]≡n/gcd[n,d] (sym c/gcd[m,c]≡d/gcd[n,d]) ⟩ (n ℕ./ gcd[n,d]) ℕ.* (c ℕ./ gcd[m,c]) ≡⟨ ℕ./-*-interchange gcd[n,d]∣n gcd[m,c]∣c ⟨ - (n ℕ.* c) ℕ./ (gcd[n,d] ℕ.* gcd[m,c]) ≡⟨ ℕ./-congʳ (ℕ.*-comm gcd[n,d] gcd[m,c]) ⟩ - (n ℕ.* c) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ∎) + (n ℕ.* c) ℕ./ (gcd[n,d] ℕ.* gcd[m,c]) ≡⟨ ℕ./-congʳ (ℕ.*-comm gcd[n,d] gcd[m,c]) ⟩ + (n ℕ.* c) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ∎ where open ≡-Reasoning gcd[m,c] = ℕ.gcd m c @@ -331,14 +331,13 @@ normalize-injective-≃ m n c d eq = ℕ./-cancelʳ-≡ gcd[m,c]≢0′ = ℕ.gcd[m,n]≢0 m c (inj₂ (ℕ.≢-nonZero⁻¹ c)) gcd[n,d]≢0′ = ℕ.gcd[m,n]≢0 n d (inj₂ (ℕ.≢-nonZero⁻¹ d)) - gcd[m,c]*gcd[n,d]≢0′ = Sum.[ gcd[m,c]≢0′ , gcd[n,d]≢0′ ] ∘ ℕ.m*n≡0⇒m≡0∨n≡0 _ instance gcd[m,c]≢0 = ℕ.≢-nonZero gcd[m,c]≢0′ gcd[n,d]≢0 = ℕ.≢-nonZero gcd[n,d]≢0′ c/gcd[m,c]≢0 = ℕ.≢-nonZero (ℕ.n/gcd[m,n]≢0 m c {{gcd≢0 = gcd[m,c]≢0}}) d/gcd[n,d]≢0 = ℕ.≢-nonZero (ℕ.n/gcd[m,n]≢0 n d {{gcd≢0 = gcd[n,d]≢0}}) - gcd[m,c]*gcd[n,d]≢0 = ℕ.≢-nonZero gcd[m,c]*gcd[n,d]≢0′ - gcd[n,d]*gcd[m,c]≢0 = ℕ.≢-nonZero (subst (_≢ 0) (ℕ.*-comm gcd[m,c] gcd[n,d]) gcd[m,c]*gcd[n,d]≢0′) + gcd[m,c]*gcd[n,d]≢0 = ℕ.m*n≢0 gcd[m,c] gcd[n,d] + gcd[n,d]*gcd[m,c]≢0 = ℕ.m*n≢0 gcd[n,d] gcd[m,c] div = mkℚ+-injective eq m/gcd[m,c]≡n/gcd[n,d] = proj₁ div From 54a4444a6edc25c290c429dd9592901c8991a374 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 6 Nov 2023 15:25:22 +0000 Subject: [PATCH 37/85] regularised use of instance brackets --- CHANGELOG.md | 34 +++++++++++++++++----------------- src/Data/Nat/DivMod.agda | 32 ++++++++++++++++---------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0e9ec607..68e1e55379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2766,7 +2766,7 @@ Additions to existing modules quotient∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient quotient< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n - n/m≡quotient : m ∣ n → .{{ _ : NonZero m }} → n / m ≡ quotient + n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient ``` * Added new definitions and proofs to `Data.Nat.Primality`: @@ -2798,7 +2798,7 @@ Additions to existing modules m<1+n⇒m0 (≢-nonZero⁻¹ o)) n≥o -m*n/o*n≡m/o : ∀ m n o .⦃ _ : NonZero n ⦄ ⦃ _ : NonZero o ⦄ → +m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero n}} {{_ : NonZero o}} → let instance _ = m*n≢0 o n in m * n / (o * n) ≡ m / o m*n/o*n≡m/o m n o = begin-equality @@ -330,7 +330,7 @@ m*n/o*n≡m/o m n o = begin-equality instance _ = m*n≢0 o n instance _ = m*n≢0 n o -m Date: Mon, 6 Nov 2023 15:30:54 +0000 Subject: [PATCH 38/85] further instance simplification --- src/Data/Nat/DivMod.agda | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 6da49147c6..929ea87ed8 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -318,7 +318,7 @@ m*n/m*o≡n/o m n o = helper (<-wellFounded n) n≥o = ≮⇒≥ n≮o n∸o0 (≢-nonZero⁻¹ o)) n≥o -m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero n}} {{_ : NonZero o}} → +m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero n}} .{{_ : NonZero o}} → let instance _ = m*n≢0 o n in m * n / (o * n) ≡ m / o m*n/o*n≡m/o m n o = begin-equality @@ -356,8 +356,9 @@ m Date: Mon, 6 Nov 2023 15:59:05 +0000 Subject: [PATCH 39/85] further streamlining --- src/Data/Nat/DivMod.agda | 69 +++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 929ea87ed8..3d7f5ae382 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -34,7 +34,7 @@ open import Data.Nat.Base public using (_%_; _/_) ------------------------------------------------------------------------ --- Relationship between _%_ and _div_ +-- Relationship between _%_ and _/_ m≡m%n+[m/n]*n : ∀ m n .{{_ : NonZero n}} → m ≡ m % n + (m / n) * n m≡m%n+[m/n]*n m (suc n) = div-mod-lemma 0 0 m n @@ -71,7 +71,7 @@ m%n%n≡m%n m (suc n-1) = modₕ-idem 0 m n-1 [m+kn]%n≡m%n : ∀ m k n .{{_ : NonZero n}} → (m + k * n) % n ≡ m % n [m+kn]%n≡m%n m zero n = cong (_% n) (+-identityʳ m) [m+kn]%n≡m%n m (suc k) n = begin-equality - (m + (n + k * n)) % n ≡⟨ cong (_% n) (sym (+-assoc m n (k * n))) ⟩ + (m + (n + k * n)) % n ≡⟨ cong (_% n) (+-assoc m n (k * n)) ⟨ (m + n + k * n) % n ≡⟨ [m+kn]%n≡m%n (m + n) k n ⟩ (m + n) % n ≡⟨ [m+n]%n≡m%n m n ⟩ m % n ∎ @@ -90,26 +90,6 @@ m*n≤o⇒[o∸m*n]%n≡o%n m {n} {o} m*n≤o = begin-equality (o ∸ m * n + m * n) % n ≡⟨ cong (_% n) (m∸n+n≡m m*n≤o) ⟩ o % n ∎ -m∣n⇒o%n%m≡o%m : ∀ m n o .{{_ : NonZero m}} .{{_ : NonZero n}} → m ∣ n → - o % n % m ≡ o % m -m∣n⇒o%n%m≡o%m m n@.(p * m) o (divides-refl p) = begin-equality - o % n % m ≡⟨⟩ - o % pm % m ≡⟨ %-congˡ (m%n≡m∸m/n*n o pm) ⟩ - (o ∸ o / pm * pm) % m ≡⟨ cong (λ # → (o ∸ #) % m) (*-assoc (o / pm) p m) ⟨ - (o ∸ o / pm * p * m) % m ≡⟨ m*n≤o⇒[o∸m*n]%n≡o%n (o / pm * p) lem ⟩ - o % m ∎ - where - pm = p * m - - lem : o / pm * p * m ≤ o - lem = begin - o / pm * p * m ≡⟨ *-assoc (o / pm) p m ⟩ - -- Sort out dependencies in this file, then use m/n*n≤m instead. - o / pm * pm ≤⟨ m≤m+n (o / pm * pm) (o % pm) ⟩ - o / pm * pm + o % pm ≡⟨ +-comm _ (o % pm) ⟩ - o % pm + o / pm * pm ≡⟨ m≡m%n+[m/n]*n o pm ⟨ - o ∎ - m*n%n≡0 : ∀ m n .{{_ : NonZero n}} → (m * n) % n ≡ 0 m*n%n≡0 m n@(suc _) = [m+kn]%n≡m%n 0 m n @@ -123,7 +103,7 @@ m%n≤m : ∀ m n .{{_ : NonZero n}} → m % n ≤ m m%n≤m m (suc n-1) = a[modₕ]n≤a 0 m n-1 m≤n⇒m%n≡m : m ≤ n → m % suc n ≡ m -m≤n⇒m%n≡m {m = m} m≤n with less-than-or-equal {k} refl ← ≤⇒≤″ m≤n +m≤n⇒m%n≡m {m = m} m≤n with ≤″-offset k ← ≤⇒≤″ m≤n = a≤n⇒a[modₕ]n≡a 0 (m + k) m k m Date: Mon, 6 Nov 2023 16:28:16 +0000 Subject: [PATCH 40/85] tidied up `CHANGELOG` --- CHANGELOG.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e1e55379..f86ee95e17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2753,7 +2753,7 @@ Additions to existing modules <-asym : Asymmetric _<_ ``` -* Added a new pattern synonym and a new proof to `Data.Nat.Divisibility.Core`: +* Added a new pattern synonym to `Data.Nat.Divisibility.Core`: ```agda pattern divides-refl q = divides q refl ``` @@ -2798,7 +2798,7 @@ Additions to existing modules m<1+n⇒m Date: Mon, 6 Nov 2023 16:34:09 +0000 Subject: [PATCH 41/85] simplified `NonZero` pattern matching --- src/Data/Nat/Properties.agda | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index b6fb798130..b54ea945fb 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -899,7 +899,7 @@ m*n≡0⇒m≡0∨n≡0 : ∀ m {n} → m * n ≡ 0 → m ≡ 0 ⊎ n ≡ 0 m*n≡0⇒m≡0∨n≡0 zero {n} eq = inj₁ refl m*n≡0⇒m≡0∨n≡0 (suc m) {zero} eq = inj₂ refl -m*n≢0 : ∀ m n → .{{_ : NonZero m}} .{{_ : NonZero n}} → NonZero (m * n) +m*n≢0 : ∀ m n .{{_ : NonZero m}} .{{_ : NonZero n}} → NonZero (m * n) m*n≢0 (suc m) (suc n) = _ m*n≡0⇒m≡0 : ∀ m n .{{_ : NonZero n}} → m * n ≡ 0 → m ≡ 0 @@ -932,9 +932,9 @@ m*n≡1⇒n≡1 m n eq = m*n≡1⇒m≡1 n m (trans (*-comm n m) eq) -- Other properties of _*_ and _≤_/_<_ *-cancelʳ-≤ : ∀ m n o .{{_ : NonZero o}} → m * o ≤ n * o → m ≤ n -*-cancelʳ-≤ zero _ (suc o) _ = z≤n -*-cancelʳ-≤ (suc m) (suc n) (suc o) le = - s≤s (*-cancelʳ-≤ m n (suc o) (+-cancelˡ-≤ _ _ _ le)) +*-cancelʳ-≤ zero _ _ _ = z≤n +*-cancelʳ-≤ (suc m) (suc n) o@(suc _) le = + s≤s (*-cancelʳ-≤ m n o (+-cancelˡ-≤ _ _ _ le)) *-cancelˡ-≤ : ∀ o .{{_ : NonZero o}} → o * m ≤ o * n → m ≤ n *-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n o @@ -954,14 +954,12 @@ m*n≡1⇒n≡1 m n eq = m*n≡1⇒m≡1 n m (trans (*-comm n m) eq) *-mono-< (s Date: Mon, 6 Nov 2023 17:07:48 +0000 Subject: [PATCH 42/85] regularised use of instance brackets --- src/Data/Nat/Divisibility.agda | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 2aa52ce68c..6242a09b37 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -44,7 +44,7 @@ module _ (m∣n : m ∣ n) where open ≤-Reasoning instance - quotient≢0 : .⦃ NonZero n ⦄ → NonZero quotient + quotient≢0 : .{{NonZero n}} → NonZero quotient quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient equalityᵒ : n ≡ m * quotient @@ -60,7 +60,7 @@ module _ (m∣n : m ∣ n) where n ≡⟨ equalityᵒ ⟩ m * quotient ∎ - quotient< : 1 < m → .⦃ NonZero n ⦄ → quotient < n + quotient< : 1 < m → .{{NonZero n}} → quotient < n quotient< 1⇒∤ : .⦃ _ : NonZero n ⦄ → m > n → m ∤ n +>⇒∤ : .{{_ : NonZero n}} → m > n → m ∤ n >⇒∤ {n@(suc _)} n Date: Fri, 10 Nov 2023 15:54:48 +0000 Subject: [PATCH 43/85] simplified proof of `/-*-interchange` --- src/Data/Nat/DivMod.agda | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 3d7f5ae382..ba875ddd51 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -396,15 +396,26 @@ m/n/o≡m/[n*o] m n o = begin-equality n / d + (m * n) / d ≡⟨ cong (n / d +_) (*-/-assoc m d∣n) ⟩ n / d + m * (n / d) ∎ +{- /-*-interchange : ∀ {m n o p} .{{_ : NonZero o}} .{{_ : NonZero p}} → let instance _ = m*n≢0 o p in o ∣ m → p ∣ n → (m * n) / (o * p) ≡ (m / o) * (n / p) /-*-interchange {m} {n} {o} {p} o∣m p∣n = let instance _ = m*n≢0 o p in *-cancelˡ-≡ _ _ (o * p) $ begin-equality - (o * p) * ((m * n) / (o * p)) ≡⟨ m*[n/m]≡n (*-pres-∣ o∣m p∣n) ⟩ + (o * p) * ((m * n) / (o * p)) ≡⟨ m*[n/m]≡n (*-pres-∣ o∣m p∣n) ⟩ m * n ≡⟨ cong₂ _*_ (m*[n/m]≡n o∣m) (m*[n/m]≡n p∣n) ⟨ (o * (m / o)) * (p * (n / p)) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] o (m / o) p (n / p) ⟩ (o * p) * ((m / o) * (n / p)) ∎ +-} +/-*-interchange : .{{_ : NonZero o}} .{{_ : NonZero p}} → + let instance _ = m*n≢0 o p in o ∣ m → p ∣ n → + (m * n) / (o * p) ≡ (m / o) * (n / p) +/-*-interchange {o} {p} {m@.(q * o)} {n@.(r * p)} (divides-refl q) (divides-refl r) + = let instance _ = m*n≢0 o p in begin-equality + q * o * (r * p) / (o * p) ≡⟨ /-congˡ ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) ⟩ + q * r * (o * p) / (o * p) ≡⟨ m*n/n≡m (q * r) (o * p) ⟩ + q * r ≡⟨ cong₂ _*_ (m*n/n≡m q o) (m*n/n≡m r p) ⟨ + (q * o / o) * (r * p / p) ∎ m*n/m!≡n/[m∸1]! : ∀ m n .{{_ : NonZero m}} → let instance _ = m !≢0 ; instance _ = (pred m) !≢0 in From b2df609ebbb20985789235222d5f5030e1ba6b49 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 10 Nov 2023 16:06:04 +0000 Subject: [PATCH 44/85] simplified proof of `/-*-interchange` --- src/Data/Nat/DivMod.agda | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index ba875ddd51..9fe67dcd94 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -396,17 +396,6 @@ m/n/o≡m/[n*o] m n o = begin-equality n / d + (m * n) / d ≡⟨ cong (n / d +_) (*-/-assoc m d∣n) ⟩ n / d + m * (n / d) ∎ -{- -/-*-interchange : ∀ {m n o p} .{{_ : NonZero o}} .{{_ : NonZero p}} → - let instance _ = m*n≢0 o p in o ∣ m → p ∣ n → - (m * n) / (o * p) ≡ (m / o) * (n / p) -/-*-interchange {m} {n} {o} {p} o∣m p∣n = - let instance _ = m*n≢0 o p in *-cancelˡ-≡ _ _ (o * p) $ begin-equality - (o * p) * ((m * n) / (o * p)) ≡⟨ m*[n/m]≡n (*-pres-∣ o∣m p∣n) ⟩ - m * n ≡⟨ cong₂ _*_ (m*[n/m]≡n o∣m) (m*[n/m]≡n p∣n) ⟨ - (o * (m / o)) * (p * (n / p)) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] o (m / o) p (n / p) ⟩ - (o * p) * ((m / o) * (n / p)) ∎ --} /-*-interchange : .{{_ : NonZero o}} .{{_ : NonZero p}} → let instance _ = m*n≢0 o p in o ∣ m → p ∣ n → (m * n) / (o * p) ≡ (m / o) * (n / p) From b2c04062f86f14ea9aea3c95b2e6f2bcc2aba17e Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 10 Nov 2023 16:11:39 +0000 Subject: [PATCH 45/85] =?UTF-8?q?...=20permitting=20the=20migration=20of?= =?UTF-8?q?=20`*-pres-=E2=88=A3`=20to=20`Data.Nat.Divisibility`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 ++++++- src/Data/Nat/Divisibility.agda | 8 ++++++-- src/Data/Nat/Divisibility/Core.agda | 12 +++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f86ee95e17..3947a6db8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1081,7 +1081,7 @@ Non-backwards compatible changes have had their preconditions weakened so the equivalences no longer require congruence proofs. -* In `Data.Nat.Divisibility` the proof `m/n/o≡m/[n*o]` has been removed. In it's +* In `Data.Nat.Divisibility` the proof `m/n/o≡m/[n*o]` has been removed. In its place a new more general proof `m/n/o≡m/[n*o]` has been added to `Data.Nat.DivMod` that doesn't require the `n * o ∣ m` pre-condition. @@ -1482,6 +1482,11 @@ Deprecated names map-<∣>-commute ↦ map-<∣> ``` +* In `Data.Nat.Divisibility.Core`: + ```agda + *-pres-∣ ↦ Data.Nat.Divisibility.*-pres-∣ + ``` + * In `Data.Nat.Properties`: ```agda suc[pred[n]]≡n ↦ suc-pred diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 6242a09b37..e23cb482c3 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -30,13 +30,13 @@ open import Relation.Binary.PropositionalEquality.Properties using (isEquivalence; module ≡-Reasoning) private - variable d m n o : ℕ + variable d m n o p : ℕ ------------------------------------------------------------------------ -- Definition and derived properties -open import Data.Nat.Divisibility.Core public +open import Data.Nat.Divisibility.Core public hiding (*-pres-∣) module _ (m∣n : m ∣ n) where @@ -226,6 +226,10 @@ m*n∣⇒m∣ m n (divides-refl q) = ∣n⇒∣m*n q (m∣m*n n) m*n∣⇒n∣ : ∀ m n → m * n ∣ d → n ∣ d m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m +*-pres-∣ : o ∣ m → p ∣ n → o * p ∣ m * n +*-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = + divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) + *-monoʳ-∣ : ∀ k → m ∣ n → k * m ∣ k * n *-monoʳ-∣ k = *-pres-∣ (∣-refl {k}) diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 92649d756a..c597ae6acd 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -47,8 +47,18 @@ m ∤ n = ¬ (m ∣ n) pattern divides-refl q = divides q refl ------------------------------------------------------------------------ --- Basic properties +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. + +-- Version 2.1 *-pres-∣ : o ∣ m → p ∣ n → o * p ∣ m * n *-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) + +{-# WARNING_ON_USAGE *-pres-∣ +"Warning: *-pres-∣ was deprecated in v2.1. + Please use Data.Nat.Divisibility.*-pres-∣ instead." +#-} From 700aacc57de44b9241f4ee364e8f00800bf8e7a6 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 10 Nov 2023 16:54:29 +0000 Subject: [PATCH 46/85] tweaked proof of `/-*-interchange` --- src/Data/Nat/DivMod.agda | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 9fe67dcd94..ddf9039859 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -401,10 +401,12 @@ m/n/o≡m/[n*o] m n o = begin-equality (m * n) / (o * p) ≡ (m / o) * (n / p) /-*-interchange {o} {p} {m@.(q * o)} {n@.(r * p)} (divides-refl q) (divides-refl r) = let instance _ = m*n≢0 o p in begin-equality + (m * n) / (o * p) ≡⟨⟩ q * o * (r * p) / (o * p) ≡⟨ /-congˡ ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) ⟩ q * r * (o * p) / (o * p) ≡⟨ m*n/n≡m (q * r) (o * p) ⟩ q * r ≡⟨ cong₂ _*_ (m*n/n≡m q o) (m*n/n≡m r p) ⟨ - (q * o / o) * (r * p / p) ∎ + (q * o / o) * (r * p / p) ≡⟨⟩ + (m / o) * (n / p) ∎ m*n/m!≡n/[m∸1]! : ∀ m n .{{_ : NonZero m}} → let instance _ = m !≢0 ; instance _ = (pred m) !≢0 in From ffed96a059da20a89d7f681e7c6ab719a0a3270b Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 10 Nov 2023 16:56:15 +0000 Subject: [PATCH 47/85] narrowed `import`s --- src/Data/Nat/Divisibility.agda | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index e23cb482c3..4a09ad41be 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -10,6 +10,7 @@ module Data.Nat.Divisibility where open import Data.Nat.Base open import Data.Nat.DivMod + using (m≡m%n+[m/n]*n; m%n≡m∸m/n*n; m*n/n≡m; m*n%n≡0; *-/-assoc) open import Data.Nat.Properties open import Function.Base using (_∘′_; _$_; flip) open import Function.Bundles using (_⇔_; mk⇔) From 50bb1654a3229c32291075c50b230177a52dc76b Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 16 Nov 2023 16:51:37 +0000 Subject: [PATCH 48/85] simplified proof; renamed new proofs --- CHANGELOG.md | 4 ++-- src/Data/Nat/Divisibility.agda | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 572317fd8c..e23833946a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2787,9 +2787,9 @@ Additions to existing modules instance quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient equalityᵒ : m ∣ n → n ≡ m * quotient - quotient∣ : m ∣ n → quotient ∣ n + quotient-∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient - quotient< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n + quotient-< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient ``` diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 4a09ad41be..e6789c5d35 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -51,8 +51,8 @@ module _ (m∣n : m ∣ n) where equalityᵒ : n ≡ m * quotient equalityᵒ rewrite equality = *-comm quotient m - quotient∣ : quotient ∣ n - quotient∣ = divides m equalityᵒ + quotient-∣ : quotient ∣ n + quotient-∣ = divides m equalityᵒ quotient>1 : m < n → 1 < quotient quotient>1 m Date: Fri, 17 Nov 2023 06:14:09 +0000 Subject: [PATCH 49/85] Capitalisation --- src/Data/Nat/Divisibility.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index e6789c5d35..91b95995bf 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -73,7 +73,7 @@ open _∣_ using (quotient) public ------------------------------------------------------------------------ --- defining equation for _/_ +-- Defining equation for _/_ n/m≡quotient : (m∣n : m ∣ n) .{{_ : NonZero m}} → n / m ≡ quotient m∣n n/m≡quotient {m = m} (divides-refl q) = m*n/n≡m q m From 16a14d9957ab60bb28ce89a56c8634b38ac67043 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 24 Nov 2023 13:35:36 +0000 Subject: [PATCH 50/85] streamlined `import`s; streamlined proof of decidability --- src/Data/Nat/Coprimality.agda | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Data/Nat/Coprimality.agda b/src/Data/Nat/Coprimality.agda index 1df320ea96..47483a4fff 100644 --- a/src/Data/Nat/Coprimality.agda +++ b/src/Data/Nat/Coprimality.agda @@ -21,8 +21,9 @@ open import Function.Base using (_∘_) open import Level using (0ℓ) open import Relation.Binary.PropositionalEquality.Core as P using (_≡_; _≢_; refl; trans; cong; subst) -open import Relation.Nullary as Nullary hiding (recompute) -open import Relation.Nullary.Negation using (contradiction) +import Relation.Nullary.Decidable as Dec +open import Relation.Nullary.Negation using (¬_; contradiction) +import Relation.Nullary as Nullary open import Relation.Binary.Core using (Rel) open import Relation.Binary.Definitions using (Symmetric; Decidable) @@ -63,18 +64,8 @@ coprime-/gcd m n = GCD≡1⇒coprime (GCD-/gcd m n) sym : Symmetric Coprime sym c = c ∘ swap -private - 0≢1 : 0 ≢ 1 - 0≢1 () - - 2+≢1 : ∀ {n} → suc (suc n) ≢ 1 - 2+≢1 () - coprime? : Decidable Coprime -coprime? i j with mkGCD i j -... | (0 , g) = no (0≢1 ∘ GCD.unique g ∘ coprime⇒GCD≡1) -... | (1 , g) = yes (GCD≡1⇒coprime g) -... | (suc (suc d) , g) = no (2+≢1 ∘ GCD.unique g ∘ coprime⇒GCD≡1) +coprime? m n = Dec.map′ gcd≡1⇒coprime coprime⇒gcd≡1 (gcd m n ≟ 1) ------------------------------------------------------------------------ -- Other basic properties From 7c2d70c88dc9e4fbadabd910a67b79a58d7041de Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 24 Nov 2023 14:06:31 +0000 Subject: [PATCH 51/85] spurious duplication after merge --- src/Data/Nat/Properties.agda | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index c0ec81f321..5bc63a8faf 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -920,12 +920,6 @@ m*n≢0⇒n≢0 m {n} rewrite *-comm m n = m*n≢0⇒m≢0 n {m} m*n≡0⇒m≡0 : ∀ m n .{{_ : NonZero n}} → m * n ≡ 0 → m ≡ 0 m*n≡0⇒m≡0 zero (suc _) eq = refl -m*n≢0⇒m≢0 : ∀ m {n} → .{{NonZero (m * n)}} → NonZero m -m*n≢0⇒m≢0 (suc _) = _ - -m*n≢0⇒n≢0 : ∀ m {n} → .{{NonZero (m * n)}} → NonZero n -m*n≢0⇒n≢0 m {n} rewrite *-comm m n = m*n≢0⇒m≢0 n {m} - m*n≡1⇒m≡1 : ∀ m n → m * n ≡ 1 → m ≡ 1 m*n≡1⇒m≡1 (suc zero) n _ = refl m*n≡1⇒m≡1 (suc (suc m)) (suc zero) () From 08f8f57cc7eb8fe68d695c3ad8561557b5064fc2 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 24 Nov 2023 14:10:51 +0000 Subject: [PATCH 52/85] missing symbol import --- src/Data/Nat/Divisibility.agda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index cf08a61126..4e24dc7a1c 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -25,7 +25,7 @@ open import Relation.Binary.Definitions using (Reflexive; Transitive; Antisymmetric; Decidable) import Relation.Binary.Reasoning.Preorder as PreorderReasoning open import Relation.Binary.PropositionalEquality.Core - using (_≡_; refl; sym; cong; subst) + using (_≡_; _≢_; refl; sym; cong; subst) open import Relation.Binary.Reasoning.Syntax open import Relation.Binary.PropositionalEquality.Properties using (isEquivalence; module ≡-Reasoning) @@ -353,4 +353,4 @@ hasNonTrivialDivisor-∣ (hasNonTrivialDivisor d Date: Fri, 24 Nov 2023 14:13:36 +0000 Subject: [PATCH 53/85] replaced one use of `1 < m` with `{{NonTrivial m}}` --- src/Data/Nat/Divisibility.agda | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 4e24dc7a1c..e2631aa519 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -61,9 +61,9 @@ module _ (m∣n : m ∣ n) where n ≡⟨ equalityᵒ ⟩ m * quotient ∎ - quotient-< : 1 < m → .{{NonZero n}} → quotient < n - quotient-< 11 m) ⟩ quotient * m ≡⟨ equality ⟨ n ∎ From f775e437f2c659f23f98fae12ca61b1605662916 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 24 Nov 2023 14:16:47 +0000 Subject: [PATCH 54/85] fixed `CHANGELOG` --- CHANGELOG.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec87f80479..0e9f5091b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -842,9 +842,9 @@ Non-backwards compatible changes 4. The modules `Relation.Nullary.(Product/Sum/Implication)` have been deprecated and their contents moved to `Relation.Nullary.(Negation/Reflects/Decidable)`. - + 5. The proof `T?` has been moved from `Data.Bool.Properties` to `Relation.Nullary.Decidable.Core` - (but is still re-exported by the former). + (but is still re-exported by the former). as well as the following breaking changes: @@ -1200,7 +1200,7 @@ Other major improvements * We have then moved raw bundles defined in `Data.X.Properties` to `Data.X.Base` for `X` = `Nat`/`Nat.Binary`/`Integer`/`Rational`/`Rational.Unnormalised`. - + ### Upgrades to `README` sub-library * The `README` sub-library has been moved to `doc/README` and a new `doc/standard-library-doc.agda-lib` has been added. @@ -1209,7 +1209,7 @@ Other major improvements using an out-of-the-box standard Agda installation without altering the main `standard-library.agda-lib` file. -* The second is that the `README` files are now their own first-class library +* The second is that the `README` files are now their own first-class library and can be imported like an other library. Deprecated modules @@ -2813,7 +2813,7 @@ Additions to existing modules equalityᵒ : m ∣ n → n ≡ m * quotient quotient-∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient - quotient-< : m ∣ n → 1 < m → .{{NonZero n}} → quotient < n + quotient-< : m ∣ n → .{{NonTrivial m}} → .{{NonZero n}} → quotient < n n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient hasNonTrivialDivisor-≢ : .{{NonTrivial d}} → .{{NonZero n}} → d ≢ n → d ∣ n → n HasNonTrivialDivisorLessThan n @@ -2948,7 +2948,7 @@ Additions to existing modules m%n*o≡m*o%[n*o] : .{{_ : NonZero n}} .{{_ : NonZero o}} → m % n * o ≡ m * o % (n * o) [m*n+o]%[p*n]≡[m*n]%[p*n]+o : .{{_ : NonZero n}} .{{_ : NonZero p}} → o < n → - (m * n + o) % (p * n) ≡ (m * n) % (p * n) + o + (m * n + o) % (p * n) ≡ (m * n) % (p * n) + o ``` * Added new proofs in `Data.Nat.Divisibility`: @@ -2958,7 +2958,7 @@ Additions to existing modules m*n∣⇒n∣ : m * n ∣ i → n ∣ i m≤n⇒m!∣n! : m ≤ n → m ! ∣ n ! m/n/o≡m/[n*o] : .{{_ : NonZero n}} .{{_ : NonZero o}} → - n * o ∣ m → (m / n) / o ≡ m / (n * o) + n * o ∣ m → (m / n) / o ≡ m / (n * o) ``` * Added new proofs in `Data.Nat.GCD`: From 36771c5e91ed1426468854da7b8bea178d53ae24 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Fri, 24 Nov 2023 14:33:35 +0000 Subject: [PATCH 55/85] removed use of identifier `k` --- src/Data/Nat/Divisibility.agda | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index e2631aa519..98ada22bff 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -231,22 +231,22 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m *-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) -*-monoʳ-∣ : ∀ k → m ∣ n → k * m ∣ k * n -*-monoʳ-∣ k = *-pres-∣ (∣-refl {k}) - -*-monoˡ-∣ : ∀ k → m ∣ n → m * k ∣ n * k -*-monoˡ-∣ k = flip *-pres-∣ (∣-refl {k}) - -*-cancelˡ-∣ : ∀ k .{{_ : NonZero k}} → k * m ∣ k * n → m ∣ n -*-cancelˡ-∣ {m} {n} k k*m∣k*n = divides q $ *-cancelˡ-≡ n (q * m) k $ begin-equality - k * n ≡⟨ equalityᵒ k*m∣k*n ⟩ - k * m * q ≡⟨ *-assoc k m q ⟩ - k * (m * q) ≡⟨ cong (k *_) (*-comm q m) ⟨ - k * (q * m) ∎ - where q = quotient k*m∣k*n - -*-cancelʳ-∣ : ∀ k .{{_ : NonZero k}} → m * k ∣ n * k → m ∣ n -*-cancelʳ-∣ {m} {n} k rewrite *-comm m k | *-comm n k = *-cancelˡ-∣ k +*-monoʳ-∣ : ∀ o → m ∣ n → o * m ∣ o * n +*-monoʳ-∣ o = *-pres-∣ (∣-refl {o}) + +*-monoˡ-∣ : ∀ o → m ∣ n → m * o ∣ n * o +*-monoˡ-∣ o = flip *-pres-∣ (∣-refl {o}) + +*-cancelˡ-∣ : ∀ o .{{_ : NonZero o}} → o * m ∣ o * n → m ∣ n +*-cancelˡ-∣ {m} {n} o o*m∣o*n = divides q $ *-cancelˡ-≡ n (q * m) o $ begin-equality + o * n ≡⟨ equalityᵒ o*m∣o*n ⟩ + o * m * q ≡⟨ *-assoc o m q ⟩ + o * (m * q) ≡⟨ cong (o *_) (*-comm q m) ⟨ + o * (q * m) ∎ + where q = quotient o*m∣o*n + +*-cancelʳ-∣ : ∀ o .{{_ : NonZero o}} → m * o ∣ n * o → m ∣ n +*-cancelʳ-∣ {m} {n} o rewrite *-comm m o | *-comm n o = *-cancelˡ-∣ o ------------------------------------------------------------------------ -- Properties of _∣_ and _∸_ From de4ac185c98d4ef7c756741b5323262f718c1771 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 27 Nov 2023 09:01:35 +0000 Subject: [PATCH 56/85] refactoring: more use of `NonTrivial` instances --- src/Data/Nat/DivMod.agda | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index ddf9039859..8a9a05d8fd 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -17,9 +17,11 @@ open import Data.Nat.DivMod.Core open import Data.Nat.Divisibility.Core open import Data.Nat.Induction open import Data.Nat.Properties -open import Function.Base using (_$_) +open import Data.Sum.Base using (inj₁; inj₂) +open import Function.Base using (_$_; _∘_) open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable using (yes; no) +open import Relation.Nullary.Negation using (contradiction) open ≤-Reasoning @@ -202,11 +204,13 @@ m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin m ≤⟨ m≤m*n m n ⟩ m * n ∎) -m/n1 n!} ⟩ m * n ∎ + where instance _ = Nat.nonTrivial⇒nonZero n /-mono-≤ : .{{_ : NonZero o}} .{{_ : NonZero p}} → m ≤ n → o ≥ p → m / o ≤ n / p From 449513a3d11e4139f39bd9ee362c78bde219df3b Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 27 Nov 2023 09:16:47 +0000 Subject: [PATCH 57/85] knock-on consequences: simplified function --- src/Data/Digit.agda | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Data/Digit.agda b/src/Data/Digit.agda index 3f11c1c3af..5e7715db73 100644 --- a/src/Data/Digit.agda +++ b/src/Data/Digit.agda @@ -55,11 +55,8 @@ toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) [] aux : {n : ℕ} → Acc _<_ n → List ℕ → List ℕ aux {zero} _ xs = (0 ∷ xs) aux {n@(suc _)} (acc wf) xs with does (0 Date: Mon, 27 Nov 2023 09:31:45 +0000 Subject: [PATCH 58/85] two new lemmas --- CHANGELOG.md | 2 ++ src/Data/Nat/DivMod.agda | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f829bbb7fa..611b195320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2983,6 +2983,8 @@ Additions to existing modules %-congˡ : .{{_ : NonZero o}} → m ≡ n → m % o ≡ n % o %-congʳ : .{{_ : NonZero m}} .{{_ : NonZero n}} → m ≡ n → o % m ≡ o % n + m/n≡0⇒m1 n!} ⟩ + m <⟨ m1 n) ⟩ m * n ∎ where instance _ = Nat.nonTrivial⇒nonZero n @@ -240,6 +240,17 @@ m≥n⇒m/n>0 {m@(suc _)} {n@(suc _)} m≥n = begin m / m ≤⟨ /-monoʳ-≤ m m≥n ⟩ m / n ∎ +m/n≡0⇒m-nonZero (m≥n⇒m/n>0 n≤m) + +m/n≢0⇒n≤m : ∀ {m n} .{{_ : NonZero n}} → .{{NonZero (m / n)}} → n ≤ m +m/n≢0⇒n≤m {m@(suc _)} {n@(suc _)} with <-≤-connex m n +... | inj₁ m Date: Mon, 27 Nov 2023 09:38:20 +0000 Subject: [PATCH 59/85] refactoring: use of `connex` in proofs --- src/Data/Nat/DivMod.agda | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 545fb98bcd..ae96b4416d 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -281,18 +281,16 @@ m/n≡1+[m∸n]/n {m@(suc m-1)} {n@(suc n-1)} m≥n = begin-equality 1 + (m ∸ n) / n ∎ [m∸n]/n≡m/n∸1 : ∀ m n .{{_ : NonZero n}} → (m ∸ n) / n ≡ pred (m / n) -[m∸n]/n≡m/n∸1 m n with m 0 (≢-nonZero⁻¹ o)) n≥o + where n∸o0 (≢-nonZero⁻¹ o)) n≥o m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero n}} .{{_ : NonZero o}} → let instance _ = m*n≢0 o n in From e4bbcd369e0222355e77d9673e51a5e580de258c Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Mon, 27 Nov 2023 09:44:00 +0000 Subject: [PATCH 60/85] new lemmas about `pred` --- CHANGELOG.md | 8 ++++++++ src/Data/Nat/Properties.agda | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 611b195320..ab0060ee56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3022,6 +3022,14 @@ Additions to existing modules gcd-zero : Zero 1 gcd ``` +* Added new proofs in `Data.Nat.Properties`: + ```agda + pred-cancel-≤ : pred m ≤ pred n → (m ≡ 1 × n ≡ 0) ⊎ m ≤ n + pred-cancel-< : pred m < pred n → m < n + pred-injective : .{{NonZero m}} → .{{NonZero n}} → pred m ≡ pred n → m ≡ n + pred-cancel-≡ : pred m ≡ pred n → ((m ≡ 0 × n ≡ 1) ⊎ (m ≡ 1 × n ≡ 0)) ⊎ m ≡ n + ``` + * Added new patterns in `Data.Nat.Reflection`: ```agda pattern `ℕ = def (quote ℕ) [] diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index a0bff6965b..0316c0a27f 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -1726,6 +1726,25 @@ pred-mono-≤ {suc _} {suc _} m≤n = s≤s⁻¹ m≤n pred-mono-< : .{{NonZero m}} → m < n → pred m < pred n pred-mono-< {m = suc _} {n = suc _} = s Date: Mon, 27 Nov 2023 09:54:36 +0000 Subject: [PATCH 61/85] new lemmas about monus --- CHANGELOG.md | 1 + src/Data/Nat/Properties.agda | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0060ee56..717a87af16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3024,6 +3024,7 @@ Additions to existing modules * Added new proofs in `Data.Nat.Properties`: ```agda + m Date: Mon, 27 Nov 2023 09:57:02 +0000 Subject: [PATCH 62/85] refactoring: use of the new properties, simplifying pattern analysis --- src/Data/Nat/DivMod.agda | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index ae96b4416d..324614321d 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -20,7 +20,6 @@ open import Data.Nat.Properties open import Data.Sum.Base using (inj₁; inj₂) open import Function.Base using (_$_; _∘_) open import Relation.Binary.PropositionalEquality -open import Relation.Nullary.Decidable using (yes; no) open import Relation.Nullary.Negation using (contradiction) open ≤-Reasoning @@ -339,21 +338,15 @@ m*n/o*n≡m/o m n o = begin-equality instance _ = m*n≢0 n o m Date: Mon, 27 Nov 2023 10:02:19 +0000 Subject: [PATCH 63/85] whitespace --- CHANGELOG.md | 13 +++++++------ src/Data/Nat/DivMod.agda | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 717a87af16..c87af3c48e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,7 @@ Bug-fixes Consequently this field has been removed from the record, and the record `IsRingWithoutAnnihilatingZero` in `Algebra.Structures.Biased` has been deprecated as it is now identical to is `IsRing`. - + * In `Algebra.Definitions.RawSemiring` the record `Prime` did not enforce that the number was not divisible by `1#`. To fix this `p∤1 : p ∤ 1#` has been added as a field. @@ -212,7 +212,7 @@ Non-backwards compatible changes * Added new aliases `Is(Meet/Join)(Bounded)Semilattice` for `Is(Bounded)Semilattice` which can be used to indicate meet/join-ness of the original structures, and - the field names in `IsSemilattice` and `Semilattice` have been renamed from + the field names in `IsSemilattice` and `Semilattice` have been renamed from `∧-cong` to `∙-cong`to indicate their undirected nature. * Finally, the following auxiliary files have been moved: @@ -763,10 +763,10 @@ Non-backwards compatible changes - The records in `Function.Structures` and `Function.Bundles` export proofs of these under the names `strictlySurjective`, `strictlyInverseˡ` and `strictlyInverseʳ`, - - Conversion functions for the definitions have been added in both directions - to `Function.Consequences(.Propositional/Setoid)`. - - Conversion functions for structures have been added in - `Function.Structures.Biased`. + - Conversion functions for the definitions have been added in both directions + to `Function.Consequences(.Propositional/Setoid)`. + - Conversion functions for structures have been added in + `Function.Structures.Biased`. ### New `Function.Strict` @@ -3024,6 +3024,7 @@ Additions to existing modules * Added new proofs in `Data.Nat.Properties`: ```agda + m≤n+o⇒m∸n≤o : ∀ m n {o} → m ≤ n + o → m ∸ n ≤ o m Date: Mon, 4 Dec 2023 17:29:23 +0000 Subject: [PATCH 64/85] questionable? revision after comments on #2221 --- CHANGELOG.md | 4 ++++ src/Data/Fin/Properties.agda | 3 +++ src/Data/Nat/DivMod.agda | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c87af3c48e..5dcc38a266 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2529,6 +2529,8 @@ Additions to existing modules * Added new proofs in `Data.Fin.Properties`: ``` + nonZeroIndex : Fin n → ℕ.NonZero n + 1↔⊤ : Fin 1 ↔ ⊤ 2↔Bool : Fin 2 ↔ Bool @@ -2999,6 +3001,8 @@ Additions to existing modules [m*n+o]%[p*n]≡[m*n]%[p*n]+o : .{{_ : NonZero n}} .{{_ : NonZero p}} → o < n → (m * n + o) % (p * n) ≡ (m * n) % (p * n) + o + + nonZero : DivMod dividend divisor → NonZero divisor ``` * Added new proofs in `Data.Nat.Divisibility`: diff --git a/src/Data/Fin/Properties.agda b/src/Data/Fin/Properties.agda index cdcbeb4e85..303cf64905 100644 --- a/src/Data/Fin/Properties.agda +++ b/src/Data/Fin/Properties.agda @@ -65,6 +65,9 @@ private ¬Fin0 : ¬ Fin 0 ¬Fin0 () +nonZeroIndex : Fin n → ℕ.NonZero n +nonZeroIndex {n = suc _} _ = _ + ------------------------------------------------------------------------ -- Bundles diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 5ae54ca921..62144e8824 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -11,8 +11,8 @@ module Data.Nat.DivMod where open import Agda.Builtin.Nat using (div-helper; mod-helper) open import Data.Fin.Base using (Fin; toℕ; fromℕ<) -open import Data.Fin.Properties using (toℕ-fromℕ<) -open import Data.Nat.Base as Nat +open import Data.Fin.Properties using (nonZeroIndex; toℕ-fromℕ<) +open import Data.Nat.Base as Nat hiding (nonZero) open import Data.Nat.DivMod.Core open import Data.Nat.Divisibility.Core open import Data.Nat.Induction @@ -477,6 +477,10 @@ record DivMod (dividend divisor : ℕ) : Set where remainder : Fin divisor property : dividend ≡ toℕ remainder + quotient * divisor + nonZero : NonZero divisor + nonZero = nonZeroIndex remainder + + infixl 7 _div_ _mod_ _divMod_ _div_ : (dividend divisor : ℕ) .{{_ : NonZero divisor}} → ℕ From d83f222125b5734c0beee451374e62cdb18db912 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Tue, 12 Dec 2023 10:37:18 +0000 Subject: [PATCH 65/85] silly argument name typo; remove parens --- src/Data/Nat/DivMod.agda | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 62144e8824..1c3d61af81 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -206,9 +206,9 @@ m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin m/n1 n) ⟩ - m * n ∎ + m / n * n ≤⟨ m/n*n≤m m n ⟩ + m <⟨ m1 n) ⟩ + m * n ∎ where instance _ = Nat.nonTrivial⇒nonZero n /-mono-≤ : .{{_ : NonZero o}} .{{_ : NonZero p}} → @@ -240,9 +240,9 @@ m≥n⇒m/n>0 {m@(suc _)} {n@(suc _)} m≥n = begin m / n ∎ m/n≡0⇒m-nonZero (m≥n⇒m/n>0 n≤m) m/n≢0⇒n≤m : ∀ {m n} .{{_ : NonZero n}} → .{{NonZero (m / n)}} → n ≤ m From f9b3cc0c877cc5ce6788a48b57b30bfb28f2fede Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 14:24:14 +0000 Subject: [PATCH 66/85] tidied up imports of `Relation.Nullary` --- src/Data/Nat/Coprimality.agda | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Data/Nat/Coprimality.agda b/src/Data/Nat/Coprimality.agda index bd22963012..f513e82fa4 100644 --- a/src/Data/Nat/Coprimality.agda +++ b/src/Data/Nat/Coprimality.agda @@ -21,9 +21,7 @@ open import Function.Base using (_∘_) open import Level using (0ℓ) open import Relation.Binary.PropositionalEquality.Core as P using (_≡_; _≢_; refl; trans; cong; subst) -import Relation.Nullary.Decidable as Dec -open import Relation.Nullary.Negation using (¬_; contradiction) -import Relation.Nullary as Nullary +open import Relation.Nullary as Nullary using (¬_; contradiction; map′) open import Relation.Binary.Core using (Rel) open import Relation.Binary.Definitions using (Symmetric; Decidable) @@ -68,7 +66,7 @@ sym : Symmetric Coprime sym c = c ∘ swap coprime? : Decidable Coprime -coprime? m n = Dec.map′ gcd≡1⇒coprime coprime⇒gcd≡1 (gcd m n ≟ 1) +coprime? m n = map′ gcd≡1⇒coprime coprime⇒gcd≡1 (gcd m n ≟ 1) ------------------------------------------------------------------------ -- Other basic properties From 117e6b4c13cf6bc5dd660e7a112fa676d17ae46e Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 14:40:21 +0000 Subject: [PATCH 67/85] removed spurious `instance` --- src/Data/Nat/Divisibility.agda | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 98ada22bff..2e8b346e73 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -44,9 +44,8 @@ module _ (m∣n : m ∣ n) where open _∣_ m∣n open ≤-Reasoning - instance - quotient≢0 : .{{NonZero n}} → NonZero quotient - quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient + quotient≢0 : .{{NonZero n}} → NonZero quotient + quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient equalityᵒ : n ≡ m * quotient equalityᵒ rewrite equality = *-comm quotient m @@ -66,6 +65,7 @@ module _ (m∣n : m ∣ n) where quotient <⟨ m1 m) ⟩ quotient * m ≡⟨ equality ⟨ n ∎ + where instance _ = quotient≢0 -- Exports From 41c2856c959fe18132650fb6b75c86952e9bdd20 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 14:59:31 +0000 Subject: [PATCH 68/85] localised appeals to `Reasoning` --- src/Data/Nat/Divisibility.agda | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 2e8b346e73..bcb316feac 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -165,7 +165,6 @@ module ∣-Reasoning where open ∣-syntax _IsRelatedTo_ _IsRelatedTo_ ∣-go public -open ∣-Reasoning ------------------------------------------------------------------------ -- Simple properties of _∣_ @@ -202,6 +201,7 @@ n∣n = ∣-refl m + n ∸ m ≡⟨ cong (_∸ m) m+n≡p*d ⟩ p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨ (p ∸ q) * d ∎ + where open ∣-Reasoning ------------------------------------------------------------------------ -- Properties of _∣_ and _*_ @@ -243,7 +243,9 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m o * m * q ≡⟨ *-assoc o m q ⟩ o * (m * q) ≡⟨ cong (o *_) (*-comm q m) ⟨ o * (q * m) ∎ - where q = quotient o*m∣o*n + where + open ∣-Reasoning + q = quotient o*m∣o*n *-cancelʳ-∣ : ∀ o .{{_ : NonZero o}} → m * o ∣ n * o → m ∣ n *-cancelʳ-∣ {m} {n} o rewrite *-comm m o | *-comm n o = *-cancelˡ-∣ o @@ -259,6 +261,7 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m m ∸ n + n ≡⟨ cong (_+ n) m∸n≡p*d ⟩ p * d + q * d ≡⟨ *-distribʳ-+ d p q ⟨ (p + q) * d ∎ + where open ∣-Reasoning ------------------------------------------------------------------------ -- Properties of _∣_ and _/_ @@ -268,12 +271,14 @@ m/n∣m {n} {m} n∣m = begin m / n ≡⟨ n/m≡quotient n∣m ⟩ quotient n∣m ∣⟨ quotient-∣ n∣m ⟩ m ∎ + where open ∣-Reasoning m*n∣o⇒m∣o/n : ∀ m n .{{_ : NonZero n}} → m * n ∣ o → m ∣ o / n m*n∣o⇒m∣o/n m n (divides-refl p) = divides p $ begin-equality p * (m * n) / n ≡⟨ *-/-assoc p (n∣m*n m) ⟩ p * ((m * n) / n) ≡⟨ cong (p *_) (m*n/n≡m m n) ⟩ p * m ∎ + where open ∣-Reasoning m*n∣o⇒n∣o/m : ∀ m n .{{_ : NonZero m}} → m * n ∣ o → n ∣ (o / m) m*n∣o⇒n∣o/m m n rewrite *-comm m n = m*n∣o⇒m∣o/n n m @@ -282,6 +287,7 @@ m∣n/o⇒m*o∣n : .{{_ : NonZero o}} → o ∣ n → m ∣ n / o → m * o ∣ m∣n/o⇒m*o∣n {o} {n@.(p * o)} {m} (divides-refl p) m∣p*o/o = begin m * o ∣⟨ *-monoˡ-∣ o (subst (m ∣_) (m*n/n≡m p o) m∣p*o/o) ⟩ p * o ∎ + where open ∣-Reasoning m∣n/o⇒o*m∣n : .{{_ : NonZero o}} → o ∣ n → m ∣ n / o → o * m ∣ n m∣n/o⇒o*m∣n {o} {_} {m} rewrite *-comm o m = m∣n/o⇒m*o∣n @@ -290,6 +296,7 @@ m/n∣o⇒m∣o*n : .{{_ : NonZero n}} → n ∣ m → m / n ∣ o → m ∣ o * m/n∣o⇒m∣o*n {n} {m@.(p * n)} {o} (divides-refl p) p*n/n∣o = begin p * n ∣⟨ *-monoˡ-∣ n (subst (_∣ o) (m*n/n≡m p n) p*n/n∣o) ⟩ o * n ∎ + where open ∣-Reasoning m∣n*o⇒m/n∣o : .{{_ : NonZero n}} → n ∣ m → m ∣ o * n → m / n ∣ o m∣n*o⇒m/n∣o {n} {m@.(p * n)} {o} (divides-refl p) pn∣on = begin @@ -297,6 +304,7 @@ m∣n*o⇒m/n∣o {n} {m@.(p * n)} {o} (divides-refl p) pn∣on = begin p * n / n ≡⟨ m*n/n≡m p n ⟩ p ∣⟨ *-cancelʳ-∣ n pn∣on ⟩ o ∎ + where open ∣-Reasoning ------------------------------------------------------------------------ -- Properties of _∣_ and _%_ @@ -310,6 +318,7 @@ m∣n*o⇒m/n∣o {n} {m@.(p * n)} {o} (divides-refl p) pn∣on = begin q * d + (m / n) * (p * d) ≡⟨ cong (q * d +_) (*-assoc (m / n) p d) ⟨ q * d + ((m / n) * p) * d ≡⟨ *-distribʳ-+ d q _ ⟨ (q + (m / n) * p) * d ∎ + where open ∣-Reasoning %-presˡ-∣ : .{{_ : NonZero n}} → d ∣ m → d ∣ n → d ∣ m % n %-presˡ-∣ {n} {d} {m@.(p * d)} (divides-refl p) (divides q 1+n≡qd) = @@ -320,6 +329,7 @@ m∣n*o⇒m/n∣o {n} {m@.(p * n)} {o} (divides-refl p) pn∣on = begin m ∸ (m / n * q) * d ≡⟨⟩ p * d ∸ (m / n * q) * d ≡⟨ *-distribʳ-∸ d p (m / n * q) ⟨ (p ∸ m / n * q) * d ∎ + where open ∣-Reasoning ------------------------------------------------------------------------ -- Properties of _∣_ and !_ From e48835f8ac3547e74b4795312c8936c820a2b6cc Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 15:00:41 +0000 Subject: [PATCH 69/85] further use of `variable`s --- src/Data/Nat/Divisibility.agda | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index bcb316feac..260f21d3cc 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -346,21 +346,21 @@ m≤n⇒m!∣n! m≤n = help (≤⇒≤′ m≤n) -- Smart constructor -hasNonTrivialDivisor-≢ : ∀ {d n} → .{{NonTrivial d}} → .{{NonZero n}} → +hasNonTrivialDivisor-≢ : .{{NonTrivial d}} → .{{NonZero n}} → d ≢ n → d ∣ n → n HasNonTrivialDivisorLessThan n hasNonTrivialDivisor-≢ d≢n d∣n = hasNonTrivialDivisor (≤∧≢⇒< (∣⇒≤ d∣n) d≢n) d∣n -- Monotonicity wrt ∣ -hasNonTrivialDivisor-∣ : ∀ {m n o} → m HasNonTrivialDivisorLessThan n → m ∣ o → +hasNonTrivialDivisor-∣ : m HasNonTrivialDivisorLessThan n → m ∣ o → o HasNonTrivialDivisorLessThan n hasNonTrivialDivisor-∣ (hasNonTrivialDivisor d Date: Wed, 13 Dec 2023 15:01:42 +0000 Subject: [PATCH 70/85] tidied up `record` name in comment --- src/Data/Nat/Divisibility.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 260f21d3cc..b9749e0cd2 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -342,7 +342,7 @@ m≤n⇒m!∣n! m≤n = help (≤⇒≤′ m≤n) help {n = n} (≤′-step m≤n) = ∣n⇒∣m*n n (help m≤n) ------------------------------------------------------------------------ --- Properties of _BoundedNonTrivialDivisor_ +-- Properties of _HasNonTrivialDivisorLessThan_ -- Smart constructor From 320aec89b7c659bd8b9570b41df4e0c057898075 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 15:19:40 +0000 Subject: [PATCH 71/85] cosmetic --- src/Data/Nat/Divisibility.agda | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index b9749e0cd2..5cf713fe18 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -73,7 +73,7 @@ open _∣_ using (quotient) public ------------------------------------------------------------------------ --- Defining equation for _/_ +-- Relating _/_ and _∣_.quotient n/m≡quotient : (m∣n : m ∣ n) .{{_ : NonZero m}} → n / m ≡ quotient m∣n n/m≡quotient {m = m} (divides-refl q) = m*n/n≡m q m @@ -362,5 +362,5 @@ hasNonTrivialDivisor-∣ (hasNonTrivialDivisor d Date: Wed, 13 Dec 2023 16:14:39 +0000 Subject: [PATCH 72/85] reconciled implicit/explicit arguments in various monus lemmas --- src/Data/Nat/Properties.agda | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Data/Nat/Properties.agda b/src/Data/Nat/Properties.agda index 273afc0e26..b09b46db7d 100644 --- a/src/Data/Nat/Properties.agda +++ b/src/Data/Nat/Properties.agda @@ -1601,15 +1601,15 @@ m≤n+o⇒m∸n≤o m zero le = le m≤n+o⇒m∸n≤o zero (suc n) _ = z≤n m≤n+o⇒m∸n≤o (suc m) (suc n) le = m≤n+o⇒m∸n≤o m n (s≤s⁻¹ le) -m+n≤o⇒m≤o∸n : ∀ m n o → m + n ≤ o → m ≤ o ∸ n -m+n≤o⇒m≤o∸n zero n o le = z≤n -m+n≤o⇒m≤o∸n (suc m) n (suc o) (s≤s le) - rewrite +-∸-assoc 1 (m+n≤o⇒n≤o m le) = s≤s (m+n≤o⇒m≤o∸n m n o le) - -m Date: Wed, 13 Dec 2023 16:37:57 +0000 Subject: [PATCH 73/85] fixed knock-on change re monus; reverted change to `m/n1 n) ⟩ + m <⟨ m Date: Wed, 13 Dec 2023 16:43:07 +0000 Subject: [PATCH 74/85] =?UTF-8?q?reverted=20change=20to=20`m/n=E2=89=A20?= =?UTF-8?q?=E2=87=92n=E2=89=A4m`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/DivMod.agda | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 9c11351aba..44b10a564f 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -244,9 +244,9 @@ m/n≡0⇒m-nonZero (m≥n⇒m/n>0 n≤m) -m/n≢0⇒n≤m : ∀ {m n} .{{_ : NonZero n}} → .{{NonZero (m / n)}} → n ≤ m -m/n≢0⇒n≤m {m@(suc _)} {n@(suc _)} with <-≤-connex m n -... | inj₁ m Date: Wed, 13 Dec 2023 17:15:33 +0000 Subject: [PATCH 75/85] reverted breaking changes involving `NonZero` inference --- src/Data/Nat/DivMod.agda | 49 ++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/Data/Nat/DivMod.agda b/src/Data/Nat/DivMod.agda index 44b10a564f..dacde16163 100644 --- a/src/Data/Nat/DivMod.agda +++ b/src/Data/Nat/DivMod.agda @@ -307,8 +307,7 @@ m∣n⇒o%n%m≡o%m m n@.(p * m) o (divides-refl p) = begin-equality o / pm * pm ≤⟨ m/n*n≤m o pm ⟩ o ∎ -m*n/m*o≡n/o : ∀ m n o .{{_ : NonZero m}} .{{_ : NonZero o}} → - let instance _ = m*n≢0 m o in +m*n/m*o≡n/o : ∀ m n o .{{_ : NonZero o}} .{{_ : NonZero (m * o)}} → (m * n) / (m * o) ≡ n / o m*n/m*o≡n/o m n o = helper (<-wellFounded n) where @@ -316,6 +315,7 @@ m*n/m*o≡n/o m n o = helper (<-wellFounded n) helper : ∀ {n} → Acc _<_ n → (m * n) / (m * o) ≡ n / o helper {n} (acc rec) with <-≤-connex n o ... | inj₁ n0 (≢-nonZero⁻¹ o)) n≥o -m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero n}} .{{_ : NonZero o}} → - let instance _ = m*n≢0 o n in +m*n/o*n≡m/o : ∀ m n o .{{_ : NonZero o}} .{{_ : NonZero (o * n)}} → m * n / (o * n) ≡ m / o m*n/o*n≡m/o m n o = begin-equality - m * n / (o * n) ≡⟨ /-congˡ {o = o * n} (*-comm m n) ⟩ + m * n / (o * n) ≡⟨ /-congˡ (*-comm m n) ⟩ n * m / (o * n) ≡⟨ /-congʳ (*-comm o n) ⟩ n * m / (n * o) ≡⟨ m*n/m*o≡n/o n m o ⟩ m / o ∎ - where - instance _ = m*n≢0 o n - instance _ = m*n≢0 n o + where instance + _ : NonZero n + _ = m*n≢0⇒n≢0 o + _ : NonZero (n * o) + _ = m*n≢0 n o m Date: Wed, 13 Dec 2023 17:42:10 +0000 Subject: [PATCH 76/85] revised `CHANGELOG` --- CHANGELOG.md | 3940 +------------------------------------------------- 1 file changed, 33 insertions(+), 3907 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcc38a266..d631decc65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3938 +1,64 @@ -Version 2.0-rc1 +Version 2.1-dev =============== -The library has been tested using Agda 2.6.4. - -NOTE: Version `2.0` contains various breaking changes and is not backwards -compatible with code written with version `1.X` of the library. +The library has been tested using Agda 2.6.4 and 2.6.4.1. Highlights ---------- -* A new tactic `cong!` available from `Tactic.Cong` which automatically - infers the argument to `cong` for you via anti-unification. - -* Improved the `solve` tactic in `Tactic.RingSolver` to work in a much - wider range of situations. - -* A massive refactoring of the unindexed `Functor`/`Applicative`/`Monad` hierarchy - and the `MonadReader` / `MonadState` type classes. These are now usable with - instance arguments as demonstrated in the tests/monad examples. - -* Significant tightening of `import` statements internally in the library, - drastically decreasing the dependencies and hence load time of many key - modules. - -* A golden testing library in `Test.Golden`. This allows you to run a set - of tests and make sure their output matches an expected `golden` value. - The test runner has many options: filtering tests by name, dumping the - list of failures to a file, timing the runs, coloured output, etc. - Cf. the comments in `Test.Golden` and the standard library's own tests - in `tests/` for documentation on how to use the library. - Bug-fixes --------- -* In `Algebra.Structures` the records `IsRing` and `IsRingWithoutOne` contained an unnecessary field - `zero : RightZero 0# *`, which could be derived from the other ring axioms. - Consequently this field has been removed from the record, and the record - `IsRingWithoutAnnihilatingZero` in `Algebra.Structures.Biased` has been - deprecated as it is now identical to is `IsRing`. - -* In `Algebra.Definitions.RawSemiring` the record `Prime` did not - enforce that the number was not divisible by `1#`. To fix this - `p∤1 : p ∤ 1#` has been added as a field. - -* In `Data.Container.FreeMonad`, we give a direct definition of `_⋆_` as an inductive - type rather than encoding it as an instance of `μ`. This ensures Agda notices that - `C ⋆ X` is strictly positive in `X` which in turn allows us to use the free monad - when defining auxiliary (co)inductive types (cf. the `Tap` example in - `README.Data.Container.FreeMonad`). - -* In `Data.Fin.Properties` the `i` argument to `opposite-suc` was implicit - but could not be inferred in general. It has been made explicit. - -* In `Data.List.Membership.Setoid` the operations `_∷=_` and `_─_` - had an extraneous `{A : Set a}` parameter. This has been removed. - -* In `Data.List.Relation.Ternary.Appending.Setoid` the constructors - were re-exported in their full generality which lead to unsolved meta - variables at their use sites. Now versions of the constructors specialised - to use the setoid's carrier set are re-exported. - -* In `Data.Nat.DivMod` the parameter `o` in the proof `/-monoˡ-≤` was - implicit but not inferrable. It has been changed to be explicit. - -* In `Data.Nat.DivMod` the parameter `m` in the proof `+-distrib-/-∣ʳ` was - implicit but not inferrable, while `n` is explicit but inferrable. - They have been to explicit and implicit respectively. - -* In `Data.Nat.GeneralisedArithmetic` the `s` and `z` arguments to the - following functions were implicit but not inferrable: - `fold-+`, `fold-k`, `fold-*`, `fold-pull`. They have been made explicit. - -* In `Data.Rational(.Unnormalised).Properties` the module `≤-Reasoning` - exported equality combinators using the generic setoid symbol `_≈_`. They - have been renamed to use the same `_≃_` symbol used for non-propositional - equality over `Rational`s, i.e. - ```agda - step-≈ ↦ step-≃ - step-≈˘ ↦ step-≃˘ - ``` - with corresponding associated syntax: - ```agda - _≈⟨_⟩_ ↦ _≃⟨_⟩_ - _≈⟨_⟨_ ↦ _≃⟨_⟨_ - ``` - -* In `Function.Construct.Composition` the combinators - `_⟶-∘_`, `_↣-∘_`, `_↠-∘_`, `_⤖-∘_`, `_⇔-∘_`, `_↩-∘_`, `_↪-∘_`, `_↔-∘_` - had their arguments in the wrong order. They have been flipped so they can - actually be used as a composition operator. - -* In `Function.Definitions` the definitions of `Surjection`, `Inverseˡ`, - `Inverseʳ` were not being re-exported correctly and therefore had an unsolved - meta-variable whenever this module was explicitly parameterised. This has - been fixed. - -* In `System.Exit` the `ExitFailure` constructor is now carrying an integer - rather than a natural. The previous binding was incorrectly assuming that - all exit codes where non-negative. - Non-backwards compatible changes -------------------------------- -### Removed deprecated names - -* All modules and names that were deprecated in `v1.2` and before have - been removed. - -### Changes to `LeftCancellative` and `RightCancellative` in `Algebra.Definitions` - -* The definitions of the types for cancellativity in `Algebra.Definitions` previously - made some of their arguments implicit. This was under the assumption that the operators were - defined by pattern matching on the left argument so that Agda could always infer the - argument on the RHS. - -* Although many of the operators defined in the library follow this convention, this is not - always true and cannot be assumed in user's code. - -* Therefore the definitions have been changed as follows to make all their arguments explicit: - - `LeftCancellative _∙_` - - From: `∀ x {y z} → (x ∙ y) ≈ (x ∙ z) → y ≈ z` - - To: `∀ x y z → (x ∙ y) ≈ (x ∙ z) → y ≈ z` - - - `RightCancellative _∙_` - - From: `∀ {x} y z → (y ∙ x) ≈ (z ∙ x) → y ≈ z` - - To: `∀ x y z → (y ∙ x) ≈ (z ∙ x) → y ≈ z` - - - `AlmostLeftCancellative e _∙_` - - From: `∀ {x} y z → ¬ x ≈ e → (x ∙ y) ≈ (x ∙ z) → y ≈ z` - - To: `∀ x y z → ¬ x ≈ e → (x ∙ y) ≈ (x ∙ z) → y ≈ z` - - - `AlmostRightCancellative e _∙_` - - From: `∀ {x} y z → ¬ x ≈ e → (y ∙ x) ≈ (z ∙ x) → y ≈ z` - - To: `∀ x y z → ¬ x ≈ e → (y ∙ x) ≈ (z ∙ x) → y ≈ z` - -* Correspondingly some proofs of the above types will need additional arguments passed explicitly. - Instances can easily be fixed by adding additional underscores, e.g. - - `∙-cancelˡ x` to `∙-cancelˡ x _ _` - - `∙-cancelʳ y z` to `∙-cancelʳ _ y z` - -### Changes to ring structures in `Algebra` - -* Several ring-like structures now have the multiplicative structure defined by - its laws rather than as a substructure, to avoid repeated proofs that the - underlying relation is an equivalence. These are: - * `IsNearSemiring` - * `IsSemiringWithoutOne` - * `IsSemiringWithoutAnnihilatingZero` - * `IsRing` - -* To aid with migration, structures matching the old style ones have been added - to `Algebra.Structures.Biased`, with conversion functions: - * `IsNearSemiring*` and `isNearSemiring*` - * `IsSemiringWithoutOne*` and `isSemiringWithoutOne*` - * `IsSemiringWithoutAnnihilatingZero*` and `isSemiringWithoutAnnihilatingZero*` - * `IsRing*` and `isRing*` - -### Refactoring of lattices in `Algebra.Structures/Bundles` hierarchy - -* In order to improve modularity and consistency with `Relation.Binary.Lattice`, - the structures & bundles for `Semilattice`, `Lattice`, `DistributiveLattice` - & `BooleanAlgebra` have been moved out of the `Algebra` modules and into their - own hierarchy in `Algebra.Lattice`. - -* All submodules, (e.g. `Algebra.Properties.Semilattice` or `Algebra.Morphism.Lattice`) - have been moved to the corresponding place under `Algebra.Lattice` (e.g. - `Algebra.Lattice.Properties.Semilattice` or `Algebra.Lattice.Morphism.Lattice`). See - the `Deprecated modules` section below for full details. - -* The definition of `IsDistributiveLattice` and `IsBooleanAlgebra` have changed so - that they are no longer right-biased which hindered compositionality. - More concretely, `IsDistributiveLattice` now has fields: - ```agda - ∨-distrib-∧ : ∨ DistributesOver ∧ - ∧-distrib-∨ : ∧ DistributesOver ∨ - ``` - instead of - ```agda - ∨-distribʳ-∧ : ∨ DistributesOverʳ ∧ - ``` - and `IsBooleanAlgebra` now has fields: - ```agda - ∨-complement : Inverse ⊤ ¬ ∨ - ∧-complement : Inverse ⊥ ¬ ∧ - ``` - instead of: - ```agda - ∨-complementʳ : RightInverse ⊤ ¬ ∨ - ∧-complementʳ : RightInverse ⊥ ¬ ∧ - ``` - -* To allow construction of these structures via their old form, smart constructors - have been added to a new module `Algebra.Lattice.Structures.Biased`, which are by - re-exported automatically by `Algebra.Lattice`. For example, if before you wrote: - ```agda - ∧-∨-isDistributiveLattice = record - { isLattice = ∧-∨-isLattice - ; ∨-distribʳ-∧ = ∨-distribʳ-∧ - } - ``` - you can use the smart constructor `isDistributiveLatticeʳʲᵐ` to write: - ```agda - ∧-∨-isDistributiveLattice = isDistributiveLatticeʳʲᵐ (record - { isLattice = ∧-∨-isLattice - ; ∨-distribʳ-∧ = ∨-distribʳ-∧ - }) - ``` - without having to prove full distributivity. - -* Added new `IsBoundedSemilattice`/`BoundedSemilattice` records. - -* Added new aliases `Is(Meet/Join)(Bounded)Semilattice` for `Is(Bounded)Semilattice` - which can be used to indicate meet/join-ness of the original structures, and - the field names in `IsSemilattice` and `Semilattice` have been renamed from - `∧-cong` to `∙-cong`to indicate their undirected nature. - -* Finally, the following auxiliary files have been moved: - ```agda - Algebra.Properties.Semilattice ↦ Algebra.Lattice.Properties.Semilattice - Algebra.Properties.Lattice ↦ Algebra.Lattice.Properties.Lattice - Algebra.Properties.DistributiveLattice ↦ Algebra.Lattice.Properties.DistributiveLattice - Algebra.Properties.BooleanAlgebra ↦ Algebra.Lattice.Properties.BooleanAlgebra - Algebra.Properties.BooleanAlgebra.Expression ↦ Algebra.Lattice.Properties.BooleanAlgebra.Expression - Algebra.Morphism.LatticeMonomorphism ↦ Algebra.Lattice.Morphism.LatticeMonomorphism - ``` - -#### Changes to `Algebra.Morphism.Structures` - -* Previously the record definitions: - ``` - IsNearSemiringHomomorphism - IsSemiringHomomorphism - IsRingHomomorphism - ``` - all had two separate proofs of `IsRelHomomorphism` within them. - -* To fix this they have all been redefined to build up from `IsMonoidHomomorphism`, - `IsNearSemiringHomomorphism`, and `IsSemiringHomomorphism` respectively, - adding a single property at each step. - -* Similarly, `IsLatticeHomomorphism` is now built as - `IsRelHomomorphism` along with proofs that `_∧_` and `_∨_` are homomorphic. - -* Finally `⁻¹-homo` in `IsRingHomomorphism` has been renamed to `-‿homo`. - -#### Renamed `Category` modules to `Effect` - -* As observed by Wen Kokke in issue #1636, it no longer really makes sense - to group the modules which correspond to the variety of concepts of - (effectful) type constructor arising in functional programming (esp. in Haskell) - such as `Monad`, `Applicative`, `Functor`, etc, under `Category.*`, - as this obstructs the importing of the `agda-categories` development into - the Standard Library, and moreover needlessly restricts the applicability of - categorical concepts to this (highly specific) mode of use. - -* Correspondingly, client modules grouped under `*.Categorical.*` which - exploit such structure for effectful programming have been renamed - `*.Effectful`, with the originals being deprecated. - -* Full list of moved modules: - ```agda - Codata.Sized.Colist.Categorical ↦ Codata.Sized.Colist.Effectful - Codata.Sized.Covec.Categorical ↦ Codata.Sized.Covec.Effectful - Codata.Sized.Delay.Categorical ↦ Codata.Sized.Delay.Effectful - Codata.Sized.Stream.Categorical ↦ Codata.Sized.Stream.Effectful - Data.List.Categorical ↦ Data.List.Effectful - Data.List.Categorical.Transformer ↦ Data.List.Effectful.Transformer - Data.List.NonEmpty.Categorical ↦ Data.List.NonEmpty.Effectful - Data.List.NonEmpty.Categorical.Transformer ↦ Data.List.NonEmpty.Effectful.Transformer - Data.Maybe.Categorical ↦ Data.Maybe.Effectful - Data.Maybe.Categorical.Transformer ↦ Data.Maybe.Effectful.Transformer - Data.Product.Categorical.Examples ↦ Data.Product.Effectful.Examples - Data.Product.Categorical.Left ↦ Data.Product.Effectful.Left - Data.Product.Categorical.Left.Base ↦ Data.Product.Effectful.Left.Base - Data.Product.Categorical.Right ↦ Data.Product.Effectful.Right - Data.Product.Categorical.Right.Base ↦ Data.Product.Effectful.Right.Base - Data.Sum.Categorical.Examples ↦ Data.Sum.Effectful.Examples - Data.Sum.Categorical.Left ↦ Data.Sum.Effectful.Left - Data.Sum.Categorical.Left.Transformer ↦ Data.Sum.Effectful.Left.Transformer - Data.Sum.Categorical.Right ↦ Data.Sum.Effectful.Right - Data.Sum.Categorical.Right.Transformer ↦ Data.Sum.Effectful.Right.Transformer - Data.These.Categorical.Examples ↦ Data.These.Effectful.Examples - Data.These.Categorical.Left ↦ Data.These.Effectful.Left - Data.These.Categorical.Left.Base ↦ Data.These.Effectful.Left.Base - Data.These.Categorical.Right ↦ Data.These.Effectful.Right - Data.These.Categorical.Right.Base ↦ Data.These.Effectful.Right.Base - Data.Vec.Categorical ↦ Data.Vec.Effectful - Data.Vec.Categorical.Transformer ↦ Data.Vec.Effectful.Transformer - Data.Vec.Recursive.Categorical ↦ Data.Vec.Recursive.Effectful - Function.Identity.Categorical ↦ Function.Identity.Effectful - IO.Categorical ↦ IO.Effectful - Reflection.TCM.Categorical ↦ Reflection.TCM.Effectful - ``` - -* Full list of new modules: - ``` - Algebra.Construct.Initial - Algebra.Construct.Terminal - Data.List.Effectful.Transformer - Data.List.NonEmpty.Effectful.Transformer - Data.Maybe.Effectful.Transformer - Data.Sum.Effectful.Left.Transformer - Data.Sum.Effectful.Right.Transformer - Data.Vec.Effectful.Transformer - Effect.Empty - Effect.Choice - Effect.Monad.Error.Transformer - Effect.Monad.Identity - Effect.Monad.IO - Effect.Monad.IO.Instances - Effect.Monad.Reader.Indexed - Effect.Monad.Reader.Instances - Effect.Monad.Reader.Transformer - Effect.Monad.Reader.Transformer.Base - Effect.Monad.State.Indexed - Effect.Monad.State.Instances - Effect.Monad.State.Transformer - Effect.Monad.State.Transformer.Base - Effect.Monad.Writer - Effect.Monad.Writer.Indexed - Effect.Monad.Writer.Instances - Effect.Monad.Writer.Transformer - Effect.Monad.Writer.Transformer.Base - IO.Effectful - IO.Instances - ``` - -### Refactoring of the unindexed Functor/Applicative/Monad hierarchy in `Effect` - -* The unindexed versions are not defined in terms of the named versions anymore. - -* The `RawApplicative` and `RawMonad` type classes have been relaxed so that the underlying - functors do not need their domain and codomain to live at the same Set level. - This is needed for level-increasing functors like `IO : Set l → Set (suc l)`. - -* `RawApplicative` is now `RawFunctor + pure + _<*>_` and `RawMonad` is now - `RawApplicative` + `_>>=_`. - This reorganisation means in particular that the functor/applicative of a monad - are not computed using `_>>=_`. This may break proofs. - -* When `F : Set f → Set f` we moreover have a definable join/μ operator - `join : (M : RawMonad F) → F (F A) → F A`. - -* We now have `RawEmpty` and `RawChoice` respectively packing `empty : M A` and - `(<|>) : M A → M A → M A`. `RawApplicativeZero`, `RawAlternative`, `RawMonadZero`, - `RawMonadPlus` are all defined in terms of these. - -* `MonadT T` now returns a `MonadTd` record that packs both a proof that the - `Monad M` transformed by `T` is a monad and that we can `lift` a computation - `M A` to a transformed computation `T M A`. - -* The monad transformer are not mere aliases anymore, they are record-wrapped - which allows constraints such as `MonadIO (StateT S (ReaderT R IO))` to be - discharged by instance arguments. - -* The mtl-style type classes (`MonadState`, `MonadReader`) do not contain a proof - that the underlying functor is a `Monad` anymore. This ensures we do not have - conflicting `Monad M` instances from a pair of `MonadState S M` & `MonadReader R M` - constraints. - -* `MonadState S M` is now defined in terms of - ```agda - gets : (S → A) → M A - modify : (S → S) → M ⊤ - ``` - with `get` and `put` defined as derived notions. - This is needed because `MonadState S M` does not pack a `Monad M` instance anymore - and so we cannot define `modify f` as `get >>= λ s → put (f s)`. - -* `MonadWriter 𝕎 M` is defined similarly: - ```agda - writer : W × A → M A - listen : M A → M (W × A) - pass : M ((W → W) × A) → M A - ``` - with `tell` defined as a derived notion. - Note that `𝕎` is a `RawMonoid`, not a `Set` and `W` is the carrier of the monoid. - - -#### Moved `Codata` modules to `Codata.Sized` - -* Due to the change in Agda 2.6.2 where sized types are no longer compatible - with the `--safe` flag, it has become clear that a third variant of codata - will be needed using coinductive records. - -* Therefore all existing modules in `Codata` which used sized types have been - moved inside a new folder named `Codata.Sized`, e.g. `Codata.Stream` - has become `Codata.Sized.Stream`. - -### New proof-irrelevant for empty type in `Data.Empty` - -* The definition of `⊥` has been changed to - ```agda - private - data Empty : Set where - - ⊥ : Set - ⊥ = Irrelevant Empty - ``` - in order to make ⊥ proof irrelevant. Any two proofs of `⊥` or of a negated - statements are now *judgmentally* equal to each other. - -* Consequently the following two definitions have been modified: - - + In `Relation.Nullary.Decidable.Core`, the type of `dec-no` has changed - ```agda - dec-no : (p? : Dec P) → ¬ P → ∃ λ ¬p′ → p? ≡ no ¬p′ - ↦ - dec-no : (p? : Dec P) (¬p : ¬ P) → p? ≡ no ¬p - ``` - - + In `Relation.Binary.PropositionalEquality`, the type of `≢-≟-identity` has changed - ```agda - ≢-≟-identity : x ≢ y → ∃ λ ¬eq → x ≟ y ≡ no ¬eq - ↦ - ≢-≟-identity : (x≢y : x ≢ y) → x ≟ y ≡ no x≢y - ``` - -### Deprecation of `_≺_` in `Data.Fin.Base` - -* In `Data.Fin.Base` the relation `_≺_` and its single constructor `_≻toℕ_` - have been deprecated in favour of their extensional equivalent `_<_` - but omitting the inversion principle which pattern matching on `_≻toℕ_` - would achieve; this instead is proxied by the property `Data.Fin.Properties.toℕ<`. - -* Consequently in `Data.Fin.Induction`: - ``` - ≺-Rec - ≺-wellFounded - ≺-recBuilder - ≺-rec - ``` - these functions are also deprecated. - -* Likewise in `Data.Fin.Properties` the proofs `≺⇒<′` and `<′⇒≺` have been deprecated - in favour of their proxy counterparts `<⇒<′` and `<′⇒<`. - -### Standardisation of `insertAt`/`updateAt`/`removeAt` in `Data.List`/`Data.Vec` - -* Previously, the names and argument order of index-based insertion, update and removal functions for - various types of lists and vectors were inconsistent. - -* To fix this the names have all been standardised to `insertAt`/`updateAt`/`removeAt`. - -* Correspondingly the following changes have occurred: - -* In `Data.List.Base` the following have been added: - ```agda - insertAt : (xs : List A) → Fin (suc (length xs)) → A → List A - updateAt : (xs : List A) → Fin (length xs) → (A → A) → List A - removeAt : (xs : List A) → Fin (length xs) → List A - ``` - and the following has been deprecated - ``` - _─_ ↦ 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 - ``` - -* In `Data.Vec.Functional`: - ```agda - 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. - -#### Standardisation of `lookup` in `Data.(List/Vec/...)` - -* All the types of `lookup` functions (and variants) in the following modules - have been changed to match the argument convention adopted in the `List` module (i.e. - `lookup` takes its container first and the index, whose type may depend on the - container value, second): - ``` - Codata.Guarded.Stream - Codata.Guarded.Stream.Relation.Binary.Pointwise - Codata.Musical.Colist.Base - Codata.Musical.Colist.Relation.Unary.Any.Properties - Codata.Musical.Covec - Codata.Musical.Stream - Codata.Sized.Colist - Codata.Sized.Covec - Codata.Sized.Stream - Data.Vec.Relation.Unary.All - Data.Star.Environment - Data.Star.Pointer - Data.Star.Vec - Data.Trie - Data.Trie.NonEmpty - Data.Tree.AVL - Data.Tree.AVL.Indexed - Data.Tree.AVL.Map - Data.Tree.AVL.NonEmpty - Data.Vec.Recursive - ``` - -* To accommodate this in in `Data.Vec.Relation.Unary.Linked.Properties` - and `Codata.Guarded.Stream.Relation.Binary.Pointwise`, the proofs - called `lookup` have been renamed `lookup⁺`. - -#### Changes to `Data.(Nat/Integer/Rational)` proofs of `NonZero`/`Positive`/`Negative` to use instance arguments - -* Many numeric operations in the library require their arguments to be non-zero, - and various proofs require their arguments to be non-zero/positive/negative etc. - As discussed on the [mailing list](https://lists.chalmers.se/pipermail/agda/2021/012693.html), - the previous way of constructing and passing round these proofs was extremely - clunky and lead to messy and difficult to read code. - -* We have therefore changed every occurrence where we need a proof of - non-zeroness/positivity/etc. to take it as an irrelevant - [instance argument](https://agda.readthedocs.io/en/latest/language/instance-arguments.html). - See the mailing list discussion for a fuller explanation of the motivation and implementation. - -* For example, whereas the type of division over `ℕ` used to be: - ```agda - _/_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ - ``` - it is now: - ```agda - _/_ : (dividend divisor : ℕ) .{{_ : NonZero divisor}} → ℕ - ``` - -* This means that as long as an instance of `NonZero n` is in scope then you can write - `m / n` without having to explicitly provide a proof, as instance search will fill it in - for you. The full list of such operations changed is as follows: - - In `Data.Nat.DivMod`: `_/_`, `_%_`, `_div_`, `_mod_` - - In `Data.Nat.Pseudorandom.LCG`: `Generator` - - In `Data.Integer.DivMod`: `_divℕ_`, `_div_`, `_modℕ_`, `_mod_` - - In `Data.Rational`: `mkℚ+`, `normalize`, `_/_`, `1/_` - - In `Data.Rational.Unnormalised`: `_/_`, `1/_`, `_÷_` - -* At the moment, there are 4 different ways such instance arguments can be provided, - listed in order of convenience and clarity: - - 1. *Automatic basic instances* - the standard library provides instances based on - the constructors of each numeric type in `Data.X.Base`. For example, - `Data.Nat.Base` constrains an instance of `NonZero (suc n)` for any `n` - and `Data.Integer.Base` contains an instance of `NonNegative (+ n)` for any `n`. - Consequently, if the argument is of the required form, these instances will always - be filled in by instance search automatically, e.g. - ```agda - 0/n≡0 : 0 / suc n ≡ 0 - ``` - - 2. *Add an instance argument parameter* - You can provide the instance argument as - a parameter to your function and Agda's instance search will automatically use it - in the correct place without you having to explicitly pass it, e.g. - ```agda - 0/n≡0 : .{{_ : NonZero n}} → 0 / n ≡ 0 - ``` - - 3. *Define the instance locally* - You can define an instance argument in scope - (e.g. in a `where` clause) and Agda's instance search will again find it automatically, - e.g. - ```agda - instance - n≢0 : NonZero n - n≢0 = ... - - 0/n≡0 : 0 / n ≡ 0 - ``` - - 4. *Pass the instance argument explicitly* - Finally, if all else fails you can pass the - instance argument explicitly into the function using `{{ }}`, e.g. - ``` - 0/n≡0 : ∀ n (n≢0 : NonZero n) → ((0 / n) {{n≢0}}) ≡ 0 - ``` - -* Suitable constructors for `NonZero`/`Positive` etc. can be found in `Data.X.Base`. - -* A full list of proofs that have changed to use instance arguments is available - at the end of this file. Notable changes to proofs are now discussed below. - -* Previously one of the hacks used in proofs was to explicitly refer to everything - in the correct form, e.g. if the argument `n` had to be non-zero then you would - refer to the argument as `suc n` everywhere instead of `n`, e.g. - ``` - n/n≡1 : ∀ n → suc n / suc n ≡ 1 - ``` - This made the proofs extremely difficult to use if your term wasn't in the form `suc n`. - After being updated to use instance arguments instead, the proof above becomes: - ``` - n/n≡1 : ∀ n {{_ : NonZero n}} → n / n ≡ 1 - ``` - However, note that this means that if you passed in the value `x` to these proofs - before, then you will now have to pass in `suc x`. The proofs for which the - arguments have changed form in this way are highlighted in the list at the bottom - of the file. - -* Finally, in `Data.Rational.Unnormalised.Base` the definition of `_≢0` is now - redundant and so has been removed. Additionally the following proofs about it have - also been removed from `Data.Rational.Unnormalised.Properties`: - ``` - p≄0⇒∣↥p∣≢0 : ∀ p → p ≠ 0ℚᵘ → ℤ.∣ (↥ p) ∣ ≢0 - ∣↥p∣≢0⇒p≄0 : ∀ p → ℤ.∣ (↥ p) ∣ ≢0 → p ≠ 0ℚᵘ - ``` - -### Changes to the definition of `_≤″_` in `Data.Nat.Base` (issue #1919) - -* The definition of `_≤″_` 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- - divisibility, `_∣ˡ_` for the `RawMagma` structure of `_+_`. - -* Since the addition of raw bundles to `Data.X.Base`, this definition can now be - made directly. Accordingly, the definition has been changed to: - ```agda - _≤″_ : (m n : ℕ) → Set - _≤″_ = _∣ˡ_ +-rawMagma - - pattern less-than-or-equal {k} prf = k , prf - ``` - -* 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`. +Other major improvements +------------------------ -### Changes to definition of `Prime` in `Data.Nat.Primality` +Deprecated modules +------------------ -* The definition of `Prime` was: - ```agda - Prime 0 = ⊥ - Prime 1 = ⊥ - Prime (suc (suc n)) = (i : Fin n) → 2 + toℕ i ∤ 2 + n - ``` - which was very hard to reason about as, not only did it involve conversion - to and from the `Fin` type, it also required that the divisor was of the form - `2 + toℕ i`, which has exactly the same problem as the `suc n` hack described - above used for non-zeroness. +Deprecated names +---------------- -* To make it easier to use, reason about and read, the definition has been - changed to: +* In `Data.Nat.Divisibility.Core`: ```agda - record Prime (p : ℕ) : Set where - constructor prime - field - .{{nontrivial}} : NonTrivial p - notComposite : ¬ Composite p - ``` - where `Composite` is now defined as the diagonal of the new relation - `_HasNonTrivialDivisorLessThan_` in `Data.Nat.Divisibility.Core`. - -### Changes to operation reduction behaviour in `Data.Rational(.Unnormalised)` - -* Currently arithmetic expressions involving rationals (both normalised and - unnormalised) undergo disastrous exponential normalisation. For example, - `p + q` would often be normalised by Agda to - `(↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q)`. While the normalised form - of `p + q + r + s + t + u + v` would be ~700 lines long. This behaviour - often chokes both type-checking and the display of the expressions in the IDE. - -* To avoid this expansion and make non-trivial reasoning about rationals actually feasible: - 1. the records `ℚᵘ` and `ℚ` have both had the `no-eta-equality` flag enabled - 2. definition of arithmetic operations have trivial pattern matching added to - prevent them reducing, e.g. - ```agda - p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q) - ``` - has been changed to - ``` - p@record{} + q@record{} = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q) - ``` - -* As a consequence of this, some proofs that relied either on this reduction behaviour - or on eta-equality may no longer type-check. - -* There are several ways to fix this: - - 1. The principled way is to not rely on this reduction behaviour in the first place. - The `Properties` files for rational numbers have been greatly expanded in `v1.7` - and `v2.0`, and we believe most proofs should be able to be built up from existing - proofs contained within these files. - - 2. Alternatively, annotating any rational arguments to a proof with either - `@record{}` or `@(mkℚ _ _ _)` should restore the old reduction behaviour for any - terms involving those parameters. - - 3. Finally, if the above approaches are not viable then you may be forced to explicitly - use `cong` combined with a lemma that proves the old reduction behaviour. - -* Similarly, in order to prevent reduction, the equality `_≃_` in `Data.Rational.Base` - has been made into a data type with the single constructor `*≡*`. The destructor - `drop-*≡*` has been added to `Data.Rational.Properties`. - -#### Deprecation of old `Function` hierarchy - -* The new `Function` hierarchy was introduced in `v1.2` which follows - the same `Core`/`Definitions`/`Bundles`/`Structures` as all the other - hierarchies in the library. - -* At the time the old function hierarchy in: - ``` - Function.Equality - Function.Injection - Function.Surjection - Function.Bijection - Function.LeftInverse - Function.Inverse - Function.HalfAdjointEquivalence - Function.Related - ``` - was unofficially deprecated, but could not be officially deprecated because - of it's widespread use in the rest of the library. - -* Now, the old hierarchy modules have all been officially deprecated. All - uses of them in the rest of the library have been switched to use the - new hierarchy. - -* The latter is unfortunately a relatively big breaking change, but was judged - to be unavoidable given how widely used the old hierarchy was. - -#### Changes to the new `Function` hierarchy - -* In `Function.Bundles` the names of the fields in the records have been - changed from `f`, `g`, `cong₁` and `cong₂` to `to`, `from`, `to-cong`, `from-cong`. - -* In `Function.Definitions`, the module 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 two modules have - been removed and their definitions folded into `Function.Definitions`. - -* In `Function.Definitions` the following definitions have been changed from: - ``` - Surjective f = ∀ y → ∃ λ x → f x ≈₂ y - Inverseˡ f g = ∀ y → f (g y) ≈₂ y - Inverseʳ f g = ∀ x → g (f x) ≈₁ x - ``` - to: - ``` - Surjective f = ∀ y → ∃ λ x → ∀ {z} → z ≈₁ x → f z ≈₂ y - Inverseˡ f g = ∀ {x y} → y ≈₁ g x → f y ≈₂ x - Inverseʳ f g = ∀ {x y} → y ≈₂ f x → g y ≈₁ x + *-pres-∣ ↦ Data.Nat.Divisibility.*-pres-∣ ``` - 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ʳ`, - - Conversion functions for the definitions have been added in both directions - to `Function.Consequences(.Propositional/Setoid)`. - - Conversion functions for structures have been added in - `Function.Structures.Biased`. -### New `Function.Strict` - -* The module `Strict` has been deprecated in favour of `Function.Strict` - and the definitions of strict application, `_$!_` and `_$!′_`, have been - moved from `Function.Base` to `Function.Strict`. - -* The contents of `Function.Strict` is now re-exported by `Function`. +New modules +----------- -### Change to the definition of `WfRec` in `Induction.WellFounded` (issue #2083) +Additions to existing modules +----------------------------- -* Previously, the definition of `WfRec` was: +* In `Data.Fin.Properties`: ```agda - WfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _ - WfRec _<_ P x = ∀ y → y < x → P y + nonZeroIndex : Fin n → ℕ.NonZero n ``` - which meant that all arguments involving accessibility and wellfoundedness proofs - were polluted by almost-always-inferrable explicit arguments for the `y` position. -* The definition has now been changed to make that argument *implicit*, as +* In `Data.Nat.Divisibility`: ```agda - WfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _ - WfRec _<_ P x = ∀ {y} → y < x → P y - ``` - -### Reorganisation of `Reflection` modules - -* Under the `Reflection` module, there were various impending name clashes - between the core AST as exposed by Agda and the annotated AST defined in - the library. - -* While the content of the modules remain the same, the modules themselves - have therefore been renamed as follows: - ``` - Reflection.Annotated ↦ Reflection.AnnotatedAST - Reflection.Annotated.Free ↦ Reflection.AnnotatedAST.Free - - Reflection.Abstraction ↦ Reflection.AST.Abstraction - Reflection.Argument ↦ Reflection.AST.Argument - Reflection.Argument.Information ↦ Reflection.AST.Argument.Information - Reflection.Argument.Quantity ↦ Reflection.AST.Argument.Quantity - Reflection.Argument.Relevance ↦ Reflection.AST.Argument.Relevance - Reflection.Argument.Modality ↦ Reflection.AST.Argument.Modality - Reflection.Argument.Visibility ↦ Reflection.AST.Argument.Visibility - Reflection.DeBruijn ↦ Reflection.AST.DeBruijn - Reflection.Definition ↦ Reflection.AST.Definition - Reflection.Instances ↦ Reflection.AST.Instances - Reflection.Literal ↦ Reflection.AST.Literal - Reflection.Meta ↦ Reflection.AST.Meta - Reflection.Name ↦ Reflection.AST.Name - Reflection.Pattern ↦ Reflection.AST.Pattern - Reflection.Show ↦ Reflection.AST.Show - Reflection.Traversal ↦ Reflection.AST.Traversal - Reflection.Universe ↦ Reflection.AST.Universe - - Reflection.TypeChecking.Monad ↦ Reflection.TCM - Reflection.TypeChecking.Monad.Categorical ↦ Reflection.TCM.Categorical - Reflection.TypeChecking.Monad.Format ↦ Reflection.TCM.Format - Reflection.TypeChecking.Monad.Syntax ↦ Reflection.TCM.Instances - Reflection.TypeChecking.Monad.Instances ↦ Reflection.TCM.Syntax - ``` - -* A new module `Reflection.AST` that re-exports the contents of the - submodules has been added. - - -### Reorganisation of the `Relation.Nullary` hierarchy - -* It was very difficult to use the `Relation.Nullary` modules, as - `Relation.Nullary` contained the basic definitions of negation, decidability etc., - and the operations and proofs about these definitions were spread over - `Relation.Nullary.(Negation/Product/Sum/Implication etc.)`. - -* To fix this all the contents of the latter is now exported by `Relation.Nullary`. - -* In order to achieve this the following backwards compatible changes have been made: - - 1. the definition of `Dec` and `recompute` have been moved to `Relation.Nullary.Decidable.Core` - - 2. the definition of `Reflects` has been moved to `Relation.Nullary.Reflects` - - 3. the definition of `¬_` has been moved to `Relation.Nullary.Negation.Core` - - 4. The modules `Relation.Nullary.(Product/Sum/Implication)` have been deprecated - and their contents moved to `Relation.Nullary.(Negation/Reflects/Decidable)`. - - 5. The proof `T?` has been moved from `Data.Bool.Properties` to `Relation.Nullary.Decidable.Core` - (but is still re-exported by the former). - - as well as the following breaking changes: - - 1. `¬?` has been moved from `Relation.Nullary.Negation.Core` to - `Relation.Nullary.Decidable.Core` + quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient - 2. `¬-reflects` has been moved from `Relation.Nullary.Negation.Core` to - `Relation.Nullary.Reflects`. - - 3. `decidable-stable`, `excluded-middle` and `¬-drop-Dec` have been moved - from `Relation.Nullary.Negation` to `Relation.Nullary.Decidable`. - - 4. `fromDec` and `toDec` have been moved from `Data.Sum.Base` to `Data.Sum`. - - -### (Issue #2096) Introduction of flipped and negated relation symbols to bundles in `Relation.Binary.Bundles` - -* Previously, bundles such as `Preorder`, `Poset`, `TotalOrder` etc. did not have the flipped - and negated versions of the operators exposed. In some cases they could obtained by opening the - relevant `Relation.Binary.Properties.X` file but usually they had to be redefined every time. - -* To fix this, these bundles now all export all 4 versions of the operator: normal, converse, negated, - converse-negated. Accordingly they are no longer exported from the corresponding `Properties` file. - -* To make this work for `Preorder`, it was necessary to change the name of the relation symbol. - Previously, the symbol was `_∼_` which is (notationally) symmetric, so that its - converse relation could only be discussed *semantically* in terms of `flip _∼_`. - -* Now, the `Preorder` record field `_∼_` has been renamed to `_≲_`, with `_≳_` - introduced as a definition in `Relation.Binary.Bundles.Preorder`. - Partial backwards compatible has been achieved by redeclaring a deprecated version - of the old symbol in the record. Therefore, only _declarations_ of `PartialOrder` records will - need their field names updating. - - -### Changes to definition of `IsStrictTotalOrder` in `Relation.Binary.Structures` - -* The previous definition of the record `IsStrictTotalOrder` did not - build upon `IsStrictPartialOrder` as would be expected. - Instead it omitted several fields like irreflexivity as they were derivable from the - proof of trichotomy. However, this led to problems further up the hierarchy where - bundles such as `StrictTotalOrder` which contained multiple distinct proofs of - `IsStrictPartialOrder`. + equalityᵒ : m ∣ n → n ≡ m * quotient + quotient-∣ : m ∣ n → quotient ∣ n + quotient>1 : m ∣ n → m < n → 1 < quotient + quotient-< : m ∣ n → .{{NonTrivial m}} → .{{NonZero n}} → quotient < n + n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient -* To remedy this the definition of `IsStrictTotalOrder` has been changed to so - that it builds upon `IsStrictPartialOrder` as would be expected. + m/n≡0⇒m_` have been - generalised so they can now relate `Fin` terms with different indices. - Should be mostly backwards compatible, but very occasionally when proving - properties about the orderings themselves the second index must be provided - explicitly. - -* In `Data.Fin.Properties` the proof `inj⇒≟` that an injection from a type - `A` into `Fin n` induces a decision procedure for `_≡_` on `A` has been - generalised to other equivalences over `A` (i.e. to arbitrary setoids), and - renamed from `eq?` to the more descriptive and `inj⇒decSetoid`. - -* In `Data.Fin.Properties` the proof `pigeonhole` has been strengthened - so that the a proof that `i < j` rather than a mere `i ≢ j` is returned. - -* In `Data.Fin.Substitution.TermSubst` the fixity of `_/Var_` has been changed - from `infix 8` to `infixl 8`. - -* In `Data.Integer.DivMod` the previous implementations of - `_divℕ_`, `_div_`, `_modℕ_`, `_mod_` internally converted to the unary - `Fin` datatype resulting in poor performance. The implementation has been - updated to use the corresponding operations from `Data.Nat.DivMod` which are - efficiently implemented using the Haskell backend. - -* In `Data.Integer.Properties` the first two arguments of `m≡n⇒m-n≡0` - (now renamed `i≡j⇒i-j≡0`) have been made implicit. - -* In `Data.(List|Vec).Relation.Binary.Lex.Strict` the argument `xs` in - `xs≮[]` in introduced in PRs #1648 and #1672 has now been made implicit. - -* In `Data.List.NonEmpty` the functions `split`, `flatten` and `flatten-split` - have been removed from. In their place `groupSeqs` and `ungroupSeqs` - have been added to `Data.List.NonEmpty.Base` which morally perform the same - operations but without computing the accompanying proofs. The proofs can be - found in `Data.List.NonEmpty.Properties` under the names `groupSeqs-groups` - and `ungroupSeqs` and `groupSeqs`. - -* In `Data.List.Relation.Unary.Grouped.Properties` the proofs `map⁺` and `map⁻` - have had their preconditions weakened so the equivalences no longer require congruence - proofs. - -* In `Data.Nat.Divisibility` the proof `m/n/o≡m/[n*o]` has been removed. In its - place a new more general proof `m/n/o≡m/[n*o]` has been added to `Data.Nat.DivMod` - that doesn't require the `n * o ∣ m` pre-condition. - -* In `Data.Product.Relation.Binary.Lex.Strict` the proof of wellfoundedness - of the lexicographic ordering on products, no longer - requires the assumption of symmetry for the first equality relation `_≈₁_`. - -* In `Data.Rational.Base` the constructors `+0` and `+[1+_]` from `Data.Integer.Base` - are no longer re-exported by `Data.Rational.Base`. You will have to open `Data.Integer(.Base)` - directly to use them. - -* In `Data.Rational(.Unnormalised).Properties` the types of the proofs - `pos⇒1/pos`/`1/pos⇒pos` and `neg⇒1/neg`/`1/neg⇒neg` have been switched, - as the previous naming scheme didn't correctly generalise to e.g. `pos+pos⇒pos`. - For example the types of `pos⇒1/pos`/`1/pos⇒pos` were: - ```agda - pos⇒1/pos : ∀ p .{{_ : NonZero p}} .{{Positive (1/ p)}} → Positive p - 1/pos⇒pos : ∀ p .{{_ : Positive p}} → Positive (1/ p) - ``` - but are now: - ```agda - pos⇒1/pos : ∀ p .{{_ : Positive p}} → Positive (1/ p) - 1/pos⇒pos : ∀ p .{{_ : NonZero p}} .{{Positive (1/ p)}} → Positive p - ``` - -* In `Data.Sum.Base` the definitions `fromDec` and `toDec` have been moved to `Data.Sum`. - -* In `Data.Vec.Base` the definition of `_>>=_` under `Data.Vec.Base` has been - moved to the submodule `CartesianBind` in order to avoid clashing with the - new, alternative definition of `_>>=_`, located in the second new submodule - `DiagonalBind`. - -* In `Data.Vec.Base` the definitions `init` and `last` have been changed from the `initLast` - view-derived implementation to direct recursive definitions. - -* In `Data.Vec.Properties` the type of the proof `zipWith-comm` has been generalised from: - ```agda - zipWith-comm : ∀ {f : A → A → B} (comm : ∀ x y → f x y ≡ f y x) (xs ys : Vec A n) → - zipWith f xs ys ≡ zipWith f ys xs - ``` - to - ```agda - zipWith-comm : ∀ {f : A → B → C} {g : B → A → C} (comm : ∀ x y → f x y ≡ g y x) (xs : Vec A n) ys → - zipWith f xs ys ≡ zipWith g ys xs - ``` - -* In `Data.Vec.Relation.Unary.All` the functions `lookup` and `tabulate` have - been moved to `Data.Vec.Relation.Unary.All.Properties` and renamed - `lookup⁺` and `lookup⁻` respectively. - -* In `Data.Vec.Base` and `Data.Vec.Functional` the functions `iterate` and `replicate` - now take the length of vector, `n`, as an explicit rather than an implicit argument, i.e. - the new types are: - ```agda - iterate : (A → A) → A → ∀ n → Vec A n - replicate : ∀ n → A → Vec A n - ``` - -* In `Relation.Binary.Construct.Closure.Symmetric` the operation - `SymClosure` on relations in has been reimplemented - as a data type `SymClosure _⟶_ a b` that is parameterized by the - input relation `_⟶_` (as well as the elements `a` and `b` of the - domain) so that `_⟶_` can be inferred, which it could not from the - previous implementation using the sum type `a ⟶ b ⊎ b ⟶ a`. - -* In `Relation.Nullary.Decidable.Core` the name `excluded-middle` has been - renamed to `¬¬-excluded-middle`. - - -Other major improvements ------------------------- - -### Improvements to ring solver tactic - -* The ring solver tactic has been greatly improved. In particular: - - 1. When the solver is used for concrete ring types, e.g. ℤ, the equality can now use - all the ring operations defined natively for that type, rather than having - to use the operations defined in `AlmostCommutativeRing`. For example - previously you could not use `Data.Integer.Base._*_` but instead had to - use `AlmostCommutativeRing._*_`. - - 2. The solver now supports use of the subtraction operator `_-_` whenever - it is defined immediately in terms of `_+_` and `-_`. This is the case for - `Data.Integer` and `Data.Rational`. - -### Moved `_%_` and `_/_` operators to `Data.Nat.Base` - -* Previously the division and modulus operators were defined in `Data.Nat.DivMod` - which in turn meant that using them required importing `Data.Nat.Properties` - which is a very heavy dependency. - -* To fix this, these operators have been moved to `Data.Nat.Base`. The properties - for them still live in `Data.Nat.DivMod` (which also publicly re-exports them - to provide backwards compatibility). - -* Beneficiaries of this change include `Data.Rational.Unnormalised.Base` whose - dependencies are now significantly smaller. - -### Moved raw bundles from `Data.X.Properties` to `Data.X.Base` - -* Raw bundles by design don't contain any proofs so should in theory be able to live - in `Data.X.Base` rather than `Data.X.Bundles`. - -* To achieve this while keeping the dependency footprint small, the definitions of - raw bundles (`RawMagma`, `RawMonoid` etc.) have been moved from `Algebra(.Lattice)Bundles` to - a new module `Algebra(.Lattice).Bundles.Raw` which can be imported at much lower cost - from `Data.X.Base`. - -* We have then moved raw bundles defined in `Data.X.Properties` to `Data.X.Base` for - `X` = `Nat`/`Nat.Binary`/`Integer`/`Rational`/`Rational.Unnormalised`. - -### Upgrades to `README` sub-library - -* The `README` sub-library has been moved to `doc/README` and a new `doc/standard-library-doc.agda-lib` has been added. - -* The first consequence is that `README` files now can be type-checked in Emacs - using an out-of-the-box standard Agda installation without altering the main - `standard-library.agda-lib` file. - -* The second is that the `README` files are now their own first-class library - and can be imported like an other library. - -Deprecated modules ------------------- - -### Moving `Data.Erased` to `Data.Irrelevant` - -* This fixes the fact we had picked the wrong name originally. The erased modality - corresponds to `@0` whereas the irrelevance one corresponds to `.`. - -### Deprecation of `Data.Fin.Substitution.Example` - -* The module `Data.Fin.Substitution.Example` has been deprecated, and moved to `README.Data.Fin.Substitution.UntypedLambda` - -### Deprecation of `Data.Nat.Properties.Core` - -* The module `Data.Nat.Properties.Core` has been deprecated, and its one lemma moved to `Data.Nat.Base`, renamed as `s≤s⁻¹` - -### Deprecation of `Data.Product.Function.Dependent.Setoid.WithK` - -* This module has been deprecated, as none of its contents actually depended on axiom K. - The contents has been moved to `Data.Product.Function.Dependent.Setoid`. - -### Moving `Function.Related` - -* The module `Function.Related` has been deprecated in favour of `Function.Related.Propositional` - whose code uses the new function hierarchy. This also opens up the possibility of a more - general `Function.Related.Setoid` at a later date. Several of the names have been changed - in this process to bring them into line with the camelcase naming convention used - in the rest of the library: - ```agda - reverse-implication ↦ reverseImplication - reverse-injection ↦ reverseInjection - left-inverse ↦ leftInverse - - Symmetric-kind ↦ SymmetricKind - Forward-kind ↦ ForwardKind - Backward-kind ↦ BackwardKind - Equivalence-kind ↦ EquivalenceKind - ``` - -### Moving `Relation.Binary.Construct.(Converse/Flip)` - -* The following files have been moved: - ```agda - Relation.Binary.Construct.Converse ↦ Relation.Binary.Construct.Flip.EqAndOrd - Relation.Binary.Construct.Flip ↦ Relation.Binary.Construct.Flip.Ord - ``` - -### Moving `Relation.Binary.Properties.XLattice` - -* The following files have been moved: - ```agda - Relation.Binary.Properties.BoundedJoinSemilattice.agda ↦ Relation.Binary.Lattice.Properties.BoundedJoinSemilattice.agda - Relation.Binary.Properties.BoundedLattice.agda ↦ Relation.Binary.Lattice.Properties.BoundedLattice.agda - Relation.Binary.Properties.BoundedMeetSemilattice.agda ↦ Relation.Binary.Lattice.Properties.BoundedMeetSemilattice.agda - Relation.Binary.Properties.DistributiveLattice.agda ↦ Relation.Binary.Lattice.Properties.DistributiveLattice.agda - Relation.Binary.Properties.HeytingAlgebra.agda ↦ Relation.Binary.Lattice.Properties.HeytingAlgebra.agda - Relation.Binary.Properties.JoinSemilattice.agda ↦ Relation.Binary.Lattice.Properties.JoinSemilattice.agda - Relation.Binary.Properties.Lattice.agda ↦ Relation.Binary.Lattice.Properties.Lattice.agda - Relation.Binary.Properties.MeetSemilattice.agda ↦ Relation.Binary.Lattice.Properties.MeetSemilattice.agda - ``` - -Deprecated names ----------------- - -* In `Algebra.Consequences.Propositional`: - ```agda - comm+assoc⇒middleFour ↦ comm∧assoc⇒middleFour - identity+middleFour⇒assoc ↦ identity∧middleFour⇒assoc - identity+middleFour⇒comm ↦ identity∧middleFour⇒comm - comm+distrˡ⇒distrʳ ↦ comm∧distrˡ⇒distrʳ - comm+distrʳ⇒distrˡ ↦ comm∧distrʳ⇒distrˡ - assoc+distribʳ+idʳ+invʳ⇒zeˡ ↦ assoc∧distribʳ∧idʳ∧invʳ⇒zeˡ - assoc+distribˡ+idʳ+invʳ⇒zeʳ ↦ assoc∧distribˡ∧idʳ∧invʳ⇒zeʳ - assoc+id+invʳ⇒invˡ-unique ↦ assoc∧id∧invʳ⇒invˡ-unique - assoc+id+invˡ⇒invʳ-unique ↦ assoc∧id∧invˡ⇒invʳ-unique - subst+comm⇒sym ↦ subst∧comm⇒sym - ``` - -* In `Algebra.Consequences.Setoid`: - ```agda - comm+assoc⇒middleFour ↦ comm∧assoc⇒middleFour - identity+middleFour⇒assoc ↦ identity∧middleFour⇒assoc - identity+middleFour⇒comm ↦ identity∧middleFour⇒comm - comm+cancelˡ⇒cancelʳ ↦ comm∧cancelˡ⇒cancelʳ - comm+cancelʳ⇒cancelˡ ↦ comm∧cancelʳ⇒cancelˡ - comm+almostCancelˡ⇒almostCancelʳ ↦ comm∧almostCancelˡ⇒almostCancelʳ - comm+almostCancelʳ⇒almostCancelˡ ↦ comm∧almostCancelʳ⇒almostCancelˡ - comm+idˡ⇒idʳ ↦ comm∧idˡ⇒idʳ - comm+idʳ⇒idˡ ↦ comm∧idʳ⇒idˡ - comm+zeˡ⇒zeʳ ↦ comm∧zeˡ⇒zeʳ - comm+zeʳ⇒zeˡ ↦ comm∧zeʳ⇒zeˡ - comm+invˡ⇒invʳ ↦ comm∧invˡ⇒invʳ - comm+invʳ⇒invˡ ↦ comm∧invʳ⇒invˡ - comm+distrˡ⇒distrʳ ↦ comm∧distrˡ⇒distrʳ - comm+distrʳ⇒distrˡ ↦ comm∧distrʳ⇒distrˡ - assoc+distribʳ+idʳ+invʳ⇒zeˡ ↦ assoc∧distribʳ∧idʳ∧invʳ⇒zeˡ - assoc+distribˡ+idʳ+invʳ⇒zeʳ ↦ assoc∧distribˡ∧idʳ∧invʳ⇒zeʳ - assoc+id+invʳ⇒invˡ-unique ↦ assoc∧id∧invʳ⇒invˡ-unique - assoc+id+invˡ⇒invʳ-unique ↦ assoc∧id∧invˡ⇒invʳ-unique - subst+comm⇒sym ↦ subst∧comm⇒sym - ``` - -* In `Algebra.Construct.Zero`: - ```agda - rawMagma ↦ Algebra.Construct.Terminal.rawMagma - magma ↦ Algebra.Construct.Terminal.magma - semigroup ↦ Algebra.Construct.Terminal.semigroup - band ↦ Algebra.Construct.Terminal.band - ``` - -* In `Codata.Guarded.Stream.Properties`: - ```agda - map-identity ↦ map-id - map-fusion ↦ map-∘ - drop-fusion ↦ drop-drop - ``` - -* In `Codata.Sized.Colist.Properties`: - ```agda - map-identity ↦ map-id - map-map-fusion ↦ map-∘ - drop-drop-fusion ↦ drop-drop - ``` - -* In `Codata.Sized.Covec.Properties`: - ```agda - map-identity ↦ map-id - map-map-fusion ↦ map-∘ - ``` - -* In `Codata.Sized.Delay.Properties`: - ```agda - map-identity ↦ map-id - map-map-fusion ↦ map-∘ - map-unfold-fusion ↦ map-unfold - ``` - -* In `Codata.Sized.M.Properties`: - ```agda - map-compose ↦ map-∘ - ``` - -* In `Codata.Sized.Stream.Properties`: - ```agda - map-identity ↦ map-id - map-map-fusion ↦ map-∘ - ``` - -* In `Data.Container.Related`: - ```agda - _∼[_]_ ↦ _≲[_]_ - ``` - -* In `Data.Bool.Properties` (Issue #2046): - ```agda - push-function-into-if ↦ if-float - ``` - -* In `Data.Fin.Base`: two new, hopefully more memorable, names `↑ˡ` `↑ʳ` - for the 'left', resp. 'right' injection of a Fin m into a 'larger' type, - `Fin (m + n)`, resp. `Fin (n + m)`, with argument order to reflect the - position of the `Fin m` argument. - ``` - inject+ ↦ flip _↑ˡ_ - raise ↦ _↑ʳ_ - ``` - -* In `Data.Fin.Properties`: - ``` - toℕ-raise ↦ toℕ-↑ʳ - toℕ-inject+ ↦ toℕ-↑ˡ - splitAt-inject+ ↦ splitAt-↑ˡ m i n - splitAt-raise ↦ splitAt-↑ʳ - Fin0↔⊥ ↦ 0↔⊥ - eq? ↦ inj⇒≟ - ``` - -* In `Data.Fin.Permutation.Components`: - ``` - reverse ↦ Data.Fin.Base.opposite - reverse-prop ↦ Data.Fin.Properties.opposite-prop - reverse-involutive ↦ Data.Fin.Properties.opposite-involutive - reverse-suc ↦ Data.Fin.Properties.opposite-suc - ``` - -* In `Data.Integer.DivMod` the operator names have been renamed to - be consistent with those in `Data.Nat.DivMod`: - ``` - _divℕ_ ↦ _/ℕ_ - _div_ ↦ _/_ - _modℕ_ ↦ _%ℕ_ - _mod_ ↦ _%_ - ``` - -* In `Data.Integer.Properties` references to variables in names have - been made consistent so that `m`, `n` always refer to naturals and - `i` and `j` always refer to integers: - ``` - ≤-steps ↦ i≤j⇒i≤k+j - ≤-step ↦ i≤j⇒i≤1+j - - ≤-steps-neg ↦ i≤j⇒i-k≤j - ≤-step-neg ↦ i≤j⇒pred[i]≤j - - n≮n ↦ i≮i - ∣n∣≡0⇒n≡0 ↦ ∣i∣≡0⇒i≡0 - ∣-n∣≡∣n∣ ↦ ∣-i∣≡∣i∣ - 0≤n⇒+∣n∣≡n ↦ 0≤i⇒+∣i∣≡i - +∣n∣≡n⇒0≤n ↦ +∣i∣≡i⇒0≤i - +∣n∣≡n⊎+∣n∣≡-n ↦ +∣i∣≡i⊎+∣i∣≡-i - ∣m+n∣≤∣m∣+∣n∣ ↦ ∣i+j∣≤∣i∣+∣j∣ - ∣m-n∣≤∣m∣+∣n∣ ↦ ∣i-j∣≤∣i∣+∣j∣ - signₙ◃∣n∣≡n ↦ signᵢ◃∣i∣≡i - ◃-≡ ↦ ◃-cong - ∣m-n∣≡∣n-m∣ ↦ ∣i-j∣≡∣j-i∣ - m≡n⇒m-n≡0 ↦ i≡j⇒i-j≡0 - m-n≡0⇒m≡n ↦ i-j≡0⇒i≡j - m≤n⇒m-n≤0 ↦ i≤j⇒i-j≤0 - m-n≤0⇒m≤n ↦ i-j≤0⇒i≤j - m≤n⇒0≤n-m ↦ i≤j⇒0≤j-i - 0≤n-m⇒m≤n ↦ 0≤i-j⇒j≤i - n≤1+n ↦ i≤suc[i] - n≢1+n ↦ i≢suc[i] - m≤pred[n]⇒m-commute ↦ map-<∣> - ``` - -* In `Data.Nat.Divisibility.Core`: - ```agda - *-pres-∣ ↦ Data.Nat.Divisibility.*-pres-∣ - ``` - -* In `Data.Nat.Properties`: - ```agda - suc[pred[n]]≡n ↦ suc-pred - ≤-step ↦ m≤n⇒m≤1+n - ≤-stepsˡ ↦ m≤n⇒m≤o+n - ≤-stepsʳ ↦ m≤n⇒m≤n+o - <-step ↦ m>=_ (Codata.Sized.Cowriter) - infixr 5 _∷_ (Codata.Sized.Stream) - infixr 5 _∷_ (Codata.Sized.Colist.Bisimilarity) - infix 4 _ℕ≤?_ (Codata.Sized.Conat.Properties) - infixr 5 _∷_ (Codata.Sized.Covec.Bisimilarity) - infixr 5 _∷_ (Codata.Sized.Cowriter.Bisimilarity) - infixr 5 _∷_ (Codata.Sized.Stream.Bisimilarity) - infix 4 _ℕ<_ _ℕ≤infinity _ℕ≤_ (Codata.Sized.Conat) - infix 6 _ℕ+_ _+ℕ_ (Codata.Sized.Conat) - infixr 8 _⇒_ _⊸_ (Data.Container.Core) - infixr -1 _<$>_ _<*>_ (Data.Container.FreeMonad) - infixl 1 _>>=_ (Data.Container.FreeMonad) - infix 5 _▷_ (Data.Container.Indexed) - infixr 4 _,_ (Data.Container.Relation.Binary.Pointwise) - infix 4 _≈_ (Data.Float.Base) - infixl 4 _+ _* (Data.List.Kleene.Base) - infixr 4 _++++_ _+++*_ _*+++_ _*++*_ (Data.List.Kleene.Base) - infix 4 _[_]* _[_]+ (Data.List.Kleene.Base) - infix 4 _≢∈_ (Data.List.Membership.Propositional) - infixr 5 _`∷_ (Data.List.Reflection) - infix 4 _≡?_ (Data.List.Relation.Binary.Equality.DecPropositional) - infixr 5 _++ᵖ_ (Data.List.Relation.Binary.Prefix.Heterogeneous) - infixr 5 _++ˢ_ (Data.List.Relation.Binary.Suffix.Heterogeneous) - infixr 5 _++_ _++[] (Data.List.Relation.Ternary.Appending.Propositional) - infixr 5 _∷=_ (Data.List.Relation.Unary.Any) - infixr 5 _++_ (Data.List.Ternary.Appending) - infixl 7 _⊓′_ (Data.Nat.Base) - infixl 6 _⊔′_ (Data.Nat.Base) - infixr 8 _^_ (Data.Nat.Base) - infix 4 _!≢0 _!*_!≢0 (Data.Nat.Properties) - infixl 6.5 _P′_ _P_ _C′_ _C_ (Data.Nat.Combinatorics.Base) - infix 8 _⁻¹ (Data.Parity.Base) - infixr 2 _×-⇔_ _×-↣_ _×-↞_ _×-↠_ _×-↔_ _×-cong_ (Data.Product.Function.NonDependent.Propositional) - infixr 2 _×-⟶_ (Data.Product.Function.NonDependent.Setoid) - infixr 2 _×-equivalence_ _×-injection_ _×-left-inverse_ (Data.Product.Function.NonDependent.Setoid) - infixr 2 _×-surjection_ _×-inverse_ (Data.Product.Function.NonDependent.Setoid) - infix 4 _≃?_ (Data.Rational.Unnormalised.Properties) - infixr 4 _,_ (Data.Refinement) - infixr 1 _⊎-⇔_ _⊎-↣_ _⊎-↞_ _⊎-↠_ _⊎-↔_ _⊎-cong_ (Data.Sum.Function.Propositional) - infixr 1 _⊎-⟶_ (Data.Sum.Function.Setoid) - infixr 1 _⊎-equivalence_ _⊎-injection_ _⊎-left-inverse_ (Data.Sum.Function.Setoid) - infixr 1 _⊎-surjection_ _⊎-inverse_ (Data.Sum.Function.Setoid) - infixr 4 _,_ (Data.Tree.AVL.Value) - infix 4 _≈ₖᵥ_ (Data.Tree.AVL.Map.Membership.Propositional) - infixr 5 _`∷_ (Data.Vec.Reflection) - infixr 5 _∷=_ (Data.Vec.Membership.Setoid) - infix -1 _$ⁿ_ (Data.Vec.N-ary) - infix 4 _≋_ (Data.Vec.Functional.Relation.Binary.Equality.Setoid) - infixl 1 _>>=-cong_ _≡->>=-cong_ (Effect.Monad.Partiality) - infixl 1 _?>=′_ (Effect.Monad.Predicate) - infixl 1 _>>=-cong_ _>>=-congP_ (Effect.Monad.Partiality.All) - infixr 5 _∷_ (Foreign.Haskell.List.NonEmpty) - infixr 4 _,_ (Foreign.Haskell.Pair) - infixr 8 _^_ (Function.Endomorphism.Propositional) - infixr 8 _^_ (Function.Endomorphism.Setoid) - infix 4 _≃_ (Function.HalfAdjointEquivalence) - infix 4 _≈_ _≈ᵢ_ _≤_ (Function.Metric.Bundles) - infixl 6 _∙_ (Function.Metric.Bundles) - infix 4 _≈_ (Function.Metric.Nat.Bundles) - infix 4 _≈_ (Function.Metric.Rational.Bundles) - infix 3 _←_ _↢_ (Function.Related) - infix 4 _<_ (Induction.WellFounded) - infixl 6 _ℕ+_ (Level.Literals) - infixr 4 _,_ (Reflection.AnnotatedAST) - infix 4 _≟_ (Reflection.AST.Definition) - infix 4 _≡ᵇ_ (Reflection.AST.Literal) - infix 4 _≈?_ _≟_ _≈_ (Reflection.AST.Meta) - infix 4 _≈?_ _≟_ _≈_ (Reflection.AST.Name) - infix 4 _≟-Telescope_ (Reflection.AST.Term) - infix 4 _≟_ (Reflection.AST.Argument.Information) - infix 4 _≟_ (Reflection.AST.Argument.Modality) - infix 4 _≟_ (Reflection.AST.Argument.Quantity) - infix 4 _≟_ (Reflection.AST.Argument.Relevance) - infix 4 _≟_ (Reflection.AST.Argument.Visibility) - infixr 4 _,_ (Reflection.AST.Traversal) - infix 4 _∈FV_ (Reflection.AST.DeBruijn) - infixr 9 _;_ (Relation.Binary.Construct.Composition) - infixl 6 _+²_ (Relation.Binary.HeterogeneousEquality.Quotients.Examples) - infixr -1 _atₛ_ (Relation.Binary.Indexed.Heterogeneous.Construct.At) - infixr -1 _atₛ_ (Relation.Binary.Indexed.Homogeneous.Construct.At) - infix 4 _∈_ _∉_ (Relation.Unary.Indexed) - infix 4 _≈_ (Relation.Binary.Bundles) - infixl 6 _∩_ (Relation.Binary.Construct.Intersection) - infix 4 _<₋_ (Relation.Binary.Construct.Add.Infimum.Strict) - infix 4 _≈∙_ (Relation.Binary.Construct.Add.Point.Equality) - infix 4 _≤⁺_ _≤⊤⁺ (Relation.Binary.Construct.Add.Supremum.NonStrict) - infixr 5 _∷ʳ_ (Relation.Binary.Construct.Closure.Transitive) - infixr 6 _∪_ (Relation.Binary.Construct.Union) - infixl 6 _+ℤ_ (Relation.Binary.HeterogeneousEquality.Quotients.Examples) - infix 4 _≉_ _≈ᵢ_ _≤ᵢ_ (Relation.Binary.Indexed.Homogeneous.Bundles) - infixr 9 _⍮_ (Relation.Unary.PredicateTransformer) - infix 8 ∼_ (Relation.Unary.PredicateTransformer) - infix 2 _×?_ _⊙?_ (Relation.Unary.Properties) - infix 10 _~? (Relation.Unary.Properties) - infixr 1 _⊎?_ (Relation.Unary.Properties) - infixr 7 _∩?_ (Relation.Unary.Properties) - infixr 6 _∪?_ (Relation.Unary.Properties) - infixr 5 _∷ᴹ_ _∷⁻¹ᴹ_ (Text.Regex.Search) - infixl 6 _`⊜_ (Tactic.RingSolver) - infix 8 ⊝_ (Tactic.RingSolver.Core.Expression) - infix 4 _∈ᴿ?_ _∉ᴿ?_ _∈?ε _∈?[_] _∈?[^_] (Text.Regex.Properties) - infix 4 _∈?_ _∉?_ (Text.Regex.Derivative.Brzozowski) - infix 4 _∈_ _∉_ _∈?_ _∉?_ (Text.Regex.String.Unsafe) - ``` - -New modules ------------ - -* Constructive algebraic structures with apartness relations: - ``` - Algebra.Apartness - Algebra.Apartness.Bundles - Algebra.Apartness.Structures - Algebra.Apartness.Properties.CommutativeHeytingAlgebra - Relation.Binary.Properties.ApartnessRelation - ``` - -* Algebraic structures obtained by flipping their binary operations: - ``` - Algebra.Construct.Flip.Op - ``` - -* Algebraic structures when freely adding an identity element: - ``` - Algebra.Construct.Add.Identity - ``` - -* Definitions for algebraic modules: - ``` - Algebra.Module - Algebra.Module.Core - Algebra.Module.Definitions.Bi.Simultaneous - Algebra.Module.Morphism.Construct.Composition - Algebra.Module.Morphism.Construct.Identity - Algebra.Module.Morphism.Definitions - Algebra.Module.Morphism.ModuleHomomorphism - Algebra.Module.Morphism.Structures - Algebra.Module.Properties - ``` - -* Identity morphisms and composition of morphisms between algebraic structures: - ``` - Algebra.Morphism.Construct.Composition - Algebra.Morphism.Construct.Identity - ``` - -* Properties of various new algebraic structures: - ``` - Algebra.Properties.MoufangLoop - Algebra.Properties.Quasigroup - Algebra.Properties.MiddleBolLoop - Algebra.Properties.Loop - Algebra.Properties.KleeneAlgebra - ``` - -* Properties of rings without a unit - ``` - Algebra.Properties.RingWithoutOne` - ``` - -* Proof of the Binomial Theorem for semirings - ``` - Algebra.Properties.Semiring.Binomial - Algebra.Properties.CommutativeSemiring.Binomial - ``` - -* 'Optimised' tail-recursive exponentiation properties: - ``` - Algebra.Properties.Semiring.Exp.TailRecursiveOptimised - ``` - -* An implementation of M-types with `--guardedness` flag: - ``` - Codata.Guarded.M - ``` - -* A definition of infinite streams using coinductive records: - ``` - Codata.Guarded.Stream - Codata.Guarded.Stream.Properties - Codata.Guarded.Stream.Relation.Binary.Pointwise - Codata.Guarded.Stream.Relation.Unary.All - Codata.Guarded.Stream.Relation.Unary.Any - ``` - -* A small library for function arguments with default values: - ``` - Data.Default - ``` - -* A small library defining a structurally recursive view of `Fin n`: - ``` - Data.Fin.Relation.Unary.Top - ``` - -* A small library for a non-empty fresh list: - ``` - Data.List.Fresh.NonEmpty - ``` - -* A small library defining a structurally inductive view of lists: - ``` - Data.List.Relation.Unary.Sufficient - ``` - -* Combinations and permutations for ℕ. - ``` - Data.Nat.Combinatorics - Data.Nat.Combinatorics.Base - Data.Nat.Combinatorics.Spec - ``` - -* A small library defining parity and its algebra: - ``` - Data.Parity - Data.Parity.Base - Data.Parity.Instances - Data.Parity.Properties - ``` - -* New base module for `Data.Product` containing only the basic definitions. - ``` - Data.Product.Base - ``` - -* Reflection utilities for some specific types: - ``` - Data.List.Reflection - Data.Vec.Reflection - ``` - -* The `All` predicate over non-empty lists: - ``` - Data.List.NonEmpty.Relation.Unary.All - ``` - -* Some n-ary functions manipulating lists - ``` - Data.List.Nary.NonDependent - ``` - -* Added Logarithm base 2 on natural numbers: - ``` - Data.Nat.Logarithm.Core - Data.Nat.Logarithm - ``` - -* Show module for unnormalised rationals: - ``` - Data.Rational.Unnormalised.Show - ``` - -* Membership relations for maps and sets - ``` - Data.Tree.AVL.Map.Membership.Propositional - Data.Tree.AVL.Map.Membership.Propositional.Properties - Data.Tree.AVL.Sets.Membership - Data.Tree.AVL.Sets.Membership.Properties - ``` - -* Port of `Linked` to `Vec`: - ``` - Data.Vec.Relation.Unary.Linked - Data.Vec.Relation.Unary.Linked.Properties - ``` - -* Combinators for propositional equational reasoning on vectors with different indices - ``` - Data.Vec.Relation.Binary.Equality.Cast - ``` - -* Relations on indexed sets - ``` - Function.Indexed.Bundles - ``` - -* Properties of various types of functions: - ``` - Function.Consequences - Function.Consequences.Setoid - Function.Consequences.Propositional - Function.Properties.Bijection - Function.Properties.RightInverse - Function.Properties.Surjection - Function.Construct.Constant - ``` - -* New interface for `NonEmpty` Haskell lists: - ``` - Foreign.Haskell.List.NonEmpty - ``` - -* In order to improve modularity, the contents of `Relation.Binary.Lattice` has been - split out into the standard: - ``` - Relation.Binary.Lattice.Definitions - Relation.Binary.Lattice.Structures - Relation.Binary.Lattice.Bundles - ``` - All contents is re-exported by `Relation.Binary.Lattice` as before. - - -* Added relational reasoning over apartness relations: - ``` - Relation.Binary.Reasoning.Base.Apartness` - ``` - -* Algebraic properties of `_∩_` and `_∪_` for predicates - ``` - Relation.Unary.Algebra - ``` - -* Both versions of equality on predicates are equivalences - ``` - Relation.Unary.Relation.Binary.Equality - ``` - -* The subset relations on predicates define an order - ``` - Relation.Unary.Relation.Binary.Subset - ``` - -* Polymorphic versions of some unary relations and their properties - ``` - Relation.Unary.Polymorphic - Relation.Unary.Polymorphic.Properties - ``` - -* Alpha equality over reflected terms - ``` - Reflection.AST.AlphaEquality - ``` - -* Various system types and primitives: - ``` - System.Clock.Primitive - System.Clock - System.Console.ANSI - System.Directory.Primitive - System.Directory - System.FilePath.Posix.Primitive - System.FilePath.Posix - System.Process.Primitive - System.Process - ``` - -* A new `cong!` tactic for automatically deriving arguments to `cong` - ``` - Tactic.Cong - ``` - -* A golden testing library with test pools, an options parser, a runner: - ``` - Test.Golden - ``` - -Additions to existing modules ------------------------------ - -* The module `Algebra` now publicly re-exports the contents of - `Algebra.Structures.Biased`. - -* Added new definitions to `Algebra.Bundles`: - ```agda - record UnitalMagma c ℓ : Set (suc (c ⊔ ℓ)) - record InvertibleMagma c ℓ : Set (suc (c ⊔ ℓ)) - record InvertibleUnitalMagma c ℓ : Set (suc (c ⊔ ℓ)) - record Quasigroup c ℓ : Set (suc (c ⊔ ℓ)) - record Loop c ℓ : Set (suc (c ⊔ ℓ)) - record RingWithoutOne c ℓ : Set (suc (c ⊔ ℓ)) - record IdempotentSemiring c ℓ : Set (suc (c ⊔ ℓ)) - record KleeneAlgebra c ℓ : Set (suc (c ⊔ ℓ)) - record Quasiring c ℓ : Set (suc (c ⊔ ℓ)) - record Nearring c ℓ : Set (suc (c ⊔ ℓ)) - record IdempotentMagma c ℓ : Set (suc (c ⊔ ℓ)) - record AlternateMagma c ℓ : Set (suc (c ⊔ ℓ)) - record FlexibleMagma c ℓ : Set (suc (c ⊔ ℓ)) - record MedialMagma c ℓ : Set (suc (c ⊔ ℓ)) - record SemimedialMagma c ℓ : Set (suc (c ⊔ ℓ)) - record LeftBolLoop c ℓ : Set (suc (c ⊔ ℓ)) - record RightBolLoop c ℓ : Set (suc (c ⊔ ℓ)) - record MoufangLoop c ℓ : Set (suc (c ⊔ ℓ)) - record NonAssociativeRing c ℓ : Set (suc (c ⊔ ℓ)) - record MiddleBolLoop c ℓ : Set (suc (c ⊔ ℓ)) - ``` - -* Added new definitions to `Algebra.Bundles.Raw`: - ```agda - record RawLoop c ℓ : Set (suc (c ⊔ ℓ)) - record RawQuasiGroup c ℓ : Set (suc (c ⊔ ℓ)) - record RawRingWithoutOne c ℓ : Set (suc (c ⊔ ℓ)) - ``` - -* Added new definitions to `Algebra.Structures`: - ```agda - record IsUnitalMagma (_∙_ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - record IsInvertibleMagma (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) - record IsInvertibleUnitalMagma (_∙_ : Op₂ A) (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) - record IsQuasigroup (∙ \\ // : Op₂ A) : Set (a ⊔ ℓ) - record IsLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - record IsRingWithoutOne (+ * : Op₂ A) (-_ : Op₁ A) (0# : A) : Set (a ⊔ ℓ) - record IsIdempotentSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) - record IsKleeneAlgebra (+ * : Op₂ A) (⋆ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) - record IsQuasiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where - record IsNearring (+ * : Op₂ A) (0# 1# : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where - record IsIdempotentMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) - record IsAlternativeMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) - record IsFlexibleMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) - record IsMedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) - record IsSemimedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) - record IsLeftBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - record IsRightBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - record IsMoufangLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) - record IsMiddleBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) - ``` - -* Added new proof to `Algebra.Consequences.Base`: - ```agda - reflexive∧selfInverse⇒involutive : Reflexive _≈_ → SelfInverse _≈_ f → Involutive _≈_ f - ``` - -* Added new proofs to `Algebra.Consequences.Propositional`: - ```agda - comm∧assoc⇒middleFour : Commutative _∙_ → Associative _∙_ → _∙_ MiddleFourExchange _∙_ - identity∧middleFour⇒assoc : Identity e _∙_ → _∙_ MiddleFourExchange _∙_ → Associative _∙_ - identity∧middleFour⇒comm : Identity e _+_ → _∙_ MiddleFourExchange _+_ → Commutative _∙_ - ``` - -* Added new proofs to `Algebra.Consequences.Setoid`: - ```agda - comm∧assoc⇒middleFour : Congruent₂ _∙_ → Commutative _∙_ → Associative _∙_ → _∙_ MiddleFourExchange _∙_ - identity∧middleFour⇒assoc : Congruent₂ _∙_ → Identity e _∙_ → _∙_ MiddleFourExchange _∙_ → Associative _∙_ - identity∧middleFour⇒comm : Congruent₂ _∙_ → Identity e _+_ → _∙_ MiddleFourExchange _+_ → Commutative _∙_ - - involutive⇒surjective : Involutive f → Surjective f - selfInverse⇒involutive : SelfInverse f → Involutive f - selfInverse⇒congruent : SelfInverse f → Congruent f - selfInverse⇒inverseᵇ : SelfInverse f → Inverseᵇ f f - selfInverse⇒surjective : SelfInverse f → Surjective f - selfInverse⇒injective : SelfInverse f → Injective f - selfInverse⇒bijective : SelfInverse f → Bijective f - - comm∧idˡ⇒id : Commutative _∙_ → LeftIdentity e _∙_ → Identity e _∙_ - comm∧idʳ⇒id : Commutative _∙_ → RightIdentity e _∙_ → Identity e _∙_ - comm∧zeˡ⇒ze : Commutative _∙_ → LeftZero e _∙_ → Zero e _∙_ - comm∧zeʳ⇒ze : Commutative _∙_ → RightZero e _∙_ → Zero e _∙_ - comm∧invˡ⇒inv : Commutative _∙_ → LeftInverse e _⁻¹ _∙_ → Inverse e _⁻¹ _∙_ - comm∧invʳ⇒inv : Commutative _∙_ → RightInverse e _⁻¹ _∙_ → Inverse e _⁻¹ _∙_ - comm∧distrˡ⇒distr : Commutative _∙_ → _∙_ DistributesOverˡ _◦_ → _∙_ DistributesOver _◦_ - comm∧distrʳ⇒distr : Commutative _∙_ → _∙_ DistributesOverʳ _◦_ → _∙_ DistributesOver _◦_ - distrib∧absorbs⇒distribˡ : Associative _∙_ → Commutative _◦_ → _∙_ Absorbs _◦_ → _◦_ Absorbs _∙_ → _◦_ DistributesOver _∙_ → _∙_ DistributesOverˡ _◦_ - ``` - -* Added new functions to `Algebra.Construct.DirectProduct`: - ```agda - rawSemiring : RawSemiring a ℓ₁ → RawSemiring b ℓ₂ → RawSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - rawRing : RawRing a ℓ₁ → RawRing b ℓ₂ → RawRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero a ℓ₁ → - SemiringWithoutAnnihilatingZero b ℓ₂ → - SemiringWithoutAnnihilatingZero (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - semiring : Semiring a ℓ₁ → Semiring b ℓ₂ → Semiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - commutativeSemiring : CommutativeSemiring a ℓ₁ → - CommutativeSemiring b ℓ₂ → - CommutativeSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - ring : Ring a ℓ₁ → Ring b ℓ₂ → Ring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - commutativeRing : CommutativeRing a ℓ₁ → CommutativeRing b ℓ₂ → CommutativeRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - rawQuasigroup : RawQuasigroup a ℓ₁ → RawQuasigroup b ℓ₂ → RawQuasigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - rawLoop : RawLoop a ℓ₁ → RawLoop b ℓ₂ → RawLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - unitalMagma : UnitalMagma a ℓ₁ → UnitalMagma b ℓ₂ → UnitalMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - invertibleMagma : InvertibleMagma a ℓ₁ → InvertibleMagma b ℓ₂ → InvertibleMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - invertibleUnitalMagma : InvertibleUnitalMagma a ℓ₁ → - InvertibleUnitalMagma b ℓ₂ → - InvertibleUnitalMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - quasigroup : Quasigroup a ℓ₁ → Quasigroup b ℓ₂ → Quasigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - loop : Loop a ℓ₁ → Loop b ℓ₂ → Loop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - idempotentSemiring : IdempotentSemiring a ℓ₁ → - IdempotentSemiring b ℓ₂ → - IdempotentSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - idempotentMagma : IdempotentMagma a ℓ₁ → IdempotentMagma b ℓ₂ → IdempotentMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - alternativeMagma : AlternativeMagma a ℓ₁ → AlternativeMagma b ℓ₂ → AlternativeMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - flexibleMagma : FlexibleMagma a ℓ₁ → FlexibleMagma b ℓ₂ → FlexibleMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - medialMagma : MedialMagma a ℓ₁ → MedialMagma b ℓ₂ → MedialMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - semimedialMagma : SemimedialMagma a ℓ₁ → SemimedialMagma b ℓ₂ → SemimedialMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - kleeneAlgebra : KleeneAlgebra a ℓ₁ → KleeneAlgebra b ℓ₂ → KleeneAlgebra (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - leftBolLoop : LeftBolLoop a ℓ₁ → LeftBolLoop b ℓ₂ → LeftBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - rightBolLoop : RightBolLoop a ℓ₁ → RightBolLoop b ℓ₂ → RightBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - middleBolLoop : MiddleBolLoop a ℓ₁ → MiddleBolLoop b ℓ₂ → MiddleBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - moufangLoop : MoufangLoop a ℓ₁ → MoufangLoop b ℓ₂ → MoufangLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - rawRingWithoutOne : RawRingWithoutOne a ℓ₁ → RawRingWithoutOne b ℓ₂ → RawRingWithoutOne (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - ringWithoutOne : RingWithoutOne a ℓ₁ → RingWithoutOne b ℓ₂ → RingWithoutOne (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - nonAssociativeRing : NonAssociativeRing a ℓ₁ → - NonAssociativeRing b ℓ₂ → - NonAssociativeRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - quasiring : Quasiring a ℓ₁ → Quasiring b ℓ₂ → Quasiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - nearring : Nearring a ℓ₁ → Nearring b ℓ₂ → Nearring (a ⊔ b) (ℓ₁ ⊔ ℓ₂) - ``` - -* Added new definition to `Algebra.Definitions`: - ```agda - _*_ MiddleFourExchange _+_ = ∀ w x y z → ((w + x) * (y + z)) ≈ ((w + y) * (x + z)) - - SelfInverse f = ∀ {x y} → f x ≈ y → f y ≈ x - - LeftDividesˡ _∙_ _\\_ = ∀ x y → (x ∙ (x \\ y)) ≈ y - LeftDividesʳ _∙_ _\\_ = ∀ x y → (x \\ (x ∙ y)) ≈ y - RightDividesˡ _∙_ _//_ = ∀ x y → ((y // x) ∙ x) ≈ y - RightDividesʳ _∙_ _//_ = ∀ x y → ((y ∙ x) // x) ≈ y - LeftDivides ∙ \\ = (LeftDividesˡ ∙ \\) × (LeftDividesʳ ∙ \\) - RightDivides ∙ // = (RightDividesˡ ∙ //) × (RightDividesʳ ∙ //) - - LeftInvertible e _∙_ x = ∃[ x⁻¹ ] (x⁻¹ ∙ x) ≈ e - RightInvertible e _∙_ x = ∃[ x⁻¹ ] (x ∙ x⁻¹) ≈ e - Invertible e _∙_ x = ∃[ x⁻¹ ] ((x⁻¹ ∙ x) ≈ e) × ((x ∙ x⁻¹) ≈ e) - StarRightExpansive e _+_ _∙_ _⁻* = ∀ x → (e + (x ∙ (x ⁻*))) ≈ (x ⁻*) - StarLeftExpansive e _+_ _∙_ _⁻* = ∀ x → (e + ((x ⁻*) ∙ x)) ≈ (x ⁻*) - StarExpansive e _+_ _∙_ _* = (StarLeftExpansive e _+_ _∙_ _*) × (StarRightExpansive e _+_ _∙_ _*) - StarLeftDestructive _+_ _∙_ _* = ∀ a b x → (b + (a ∙ x)) ≈ x → ((a *) ∙ b) ≈ x - StarRightDestructive _+_ _∙_ _* = ∀ a b x → (b + (x ∙ a)) ≈ x → (b ∙ (a *)) ≈ x - StarDestructive _+_ _∙_ _* = (StarLeftDestructive _+_ _∙_ _*) × (StarRightDestructive _+_ _∙_ _*) - LeftAlternative _∙_ = ∀ x y → ((x ∙ x) ∙ y) ≈ (x ∙ (y ∙ y)) - RightAlternative _∙_ = ∀ x y → (x ∙ (y ∙ y)) ≈ ((x ∙ y) ∙ y) - Alternative _∙_ = (LeftAlternative _∙_ ) × (RightAlternative _∙_) - Flexible _∙_ = ∀ x y → ((x ∙ y) ∙ x) ≈ (x ∙ (y ∙ x)) - Medial _∙_ = ∀ x y u z → ((x ∙ y) ∙ (u ∙ z)) ≈ ((x ∙ u) ∙ (y ∙ z)) - LeftSemimedial _∙_ = ∀ x y z → ((x ∙ x) ∙ (y ∙ z)) ≈ ((x ∙ y) ∙ (x ∙ z)) - RightSemimedial _∙_ = ∀ x y z → ((y ∙ z) ∙ (x ∙ x)) ≈ ((y ∙ x) ∙ (z ∙ x)) - Semimedial _∙_ = (LeftSemimedial _∙_) × (RightSemimedial _∙_) - LeftBol _∙_ = ∀ x y z → (x ∙ (y ∙ (x ∙ z))) ≈ ((x ∙ (y ∙ z)) ∙ z ) - RightBol _∙_ = ∀ x y z → (((z ∙ x) ∙ y) ∙ x) ≈ (z ∙ ((x ∙ y) ∙ x)) - MiddleBol _∙_ _\\_ _//_ = ∀ x y z → (x ∙ ((y ∙ z) \\ x)) ≈ ((x // z) ∙ (y \\ x)) - ``` - -* Added new functions to `Algebra.Definitions.RawSemiring`: - ```agda - _^[_]*_ : A → ℕ → A → A - _^ᵗ_ : A → ℕ → A - ``` - -* In `Algebra.Bundles.Lattice` the existing record `Lattice` now provides - ```agda - ∨-commutativeSemigroup : CommutativeSemigroup c ℓ - ∧-commutativeSemigroup : CommutativeSemigroup c ℓ - ``` - and their corresponding algebraic sub-bundles. - -* In `Algebra.Lattice.Structures` the record `IsLattice` now provides - ``` - ∨-isCommutativeSemigroup : IsCommutativeSemigroup ∨ - ∧-isCommutativeSemigroup : IsCommutativeSemigroup ∧ - ``` - and their corresponding algebraic substructures. - -* The module `Algebra.Properties.Magma.Divisibility` now re-exports operations - `_∣ˡ_`, `_∤ˡ_`, `_∣ʳ_`, `_∤ʳ_` from `Algebra.Definitions.Magma`. - -* Added new records to `Algebra.Morphism.Structures`: - ```agda - record IsQuasigroupHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsQuasigroupMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsQuasigroupIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) - record IsLoopHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsLoopMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsLoopIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) - record IsRingWithoutOneHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsRingWithoutOneMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsRingWithoutOneIsoMorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) - record IsKleeneAlgebraHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsKleeneAlgebraMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) - record IsKleeneAlgebraIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) - ``` - -* Added new proofs to `Algebra.Properties.CommutativeSemigroup`: - ```agda - xy∙xx≈x∙yxx : (x ∙ y) ∙ (x ∙ x) ≈ x ∙ (y ∙ (x ∙ x)) - - interchange : Interchangable _∙_ _∙_ - leftSemimedial : LeftSemimedial _∙_ - rightSemimedial : RightSemimedial _∙_ - middleSemimedial : (x ∙ y) ∙ (z ∙ x) ≈ (x ∙ z) ∙ (y ∙ x) - semimedial : Semimedial _∙_ - ``` - -* Added new functions to `Algebra.Properties.CommutativeMonoid` - ```agda - invertibleˡ⇒invertibleʳ : LeftInvertible _≈_ 0# _+_ x → RightInvertible _≈_ 0# _+_ x - invertibleʳ⇒invertibleˡ : RightInvertible _≈_ 0# _+_ x → LeftInvertible _≈_ 0# _+_ x - invertibleˡ⇒invertible : LeftInvertible _≈_ 0# _+_ x → Invertible _≈_ 0# _+_ x - invertibleʳ⇒invertible : RightInvertible _≈_ 0# _+_ x → Invertible _≈_ 0# _+_ x - ``` - -* Added new proof to `Algebra.Properties.Monoid.Mult`: - ```agda - ×-congˡ : (_× x) Preserves _≡_ ⟶ _≈_ - ``` - -* Added new proof to `Algebra.Properties.Monoid.Sum`: - ```agda - sum-init-last : (t : Vector _ (suc n)) → sum t ≈ sum (init t) + last t - ``` - -* Added new proofs to `Algebra.Properties.Semigroup`: - ```agda - leftAlternative : LeftAlternative _∙_ - rightAlternative : RightAlternative _∙_ - alternative : Alternative _∙_ - flexible : Flexible _∙_ - ``` - -* Added new proofs to `Algebra.Properties.Semiring.Exp`: - ```agda - ^-congʳ : (x ^_) Preserves _≡_ ⟶ _≈_ - y*x^m*y^n≈x^m*y^[n+1] : x * y ≈ y * x → y * (x ^ m * y ^ n) ≈ x ^ m * y ^ suc n - ``` - -* Added new proofs to `Algebra.Properties.Semiring.Mult`: - ```agda - 1×-identityʳ : 1 × x ≈ x - ×-comm-* : x * (n × y) ≈ n × (x * y) - ×-assoc-* : (n × x) * y ≈ n × (x * y) - ``` - -* Added new proofs to `Algebra.Properties.Ring`: - ```agda - -1*x≈-x : - 1# * x ≈ - x - x+x≈x⇒x≈0 : x + x ≈ x → x ≈ 0# - x[y-z]≈xy-xz : x * (y - z) ≈ x * y - x * z - [y-z]x≈yx-zx : (y - z) * x ≈ (y * x) - (z * x) - ``` - -* Added new functions in `Codata.Guarded.Stream`: - ``` - transpose : List (Stream A) → Stream (List A) - transpose⁺ : List⁺ (Stream A) → Stream (List⁺ A) - concat : Stream (List⁺ A) → Stream A - ``` - -* Added new proofs in `Codata.Guarded.Stream.Properties`: - ``` - cong-concat : ass ≈ bss → concat ass ≈ concat bss - map-concat : map f (concat ass) ≈ concat (map (List⁺.map f) ass) - lookup-transpose : lookup n (transpose ass) ≡ List.map (lookup n) ass - lookup-transpose⁺ : lookup n (transpose⁺ ass) ≡ List⁺.map (lookup n) ass - ``` - -* Added new proofs in `Data.Bool.Properties`: - ```agda - <-wellFounded : WellFounded _<_ - ∨-conicalˡ : LeftConical false _∨_ - ∨-conicalʳ : RightConical false _∨_ - ∨-conical : Conical false _∨_ - ∧-conicalˡ : LeftConical true _∧_ - ∧-conicalʳ : RightConical true _∧_ - ∧-conical : Conical true _∧_ - - true-xor : true xor x ≡ not x - xor-same : x xor x ≡ false - not-distribˡ-xor : not (x xor y) ≡ (not x) xor y - not-distribʳ-xor : not (x xor y) ≡ x xor (not y) - xor-assoc : Associative _xor_ - xor-comm : Commutative _xor_ - xor-identityˡ : LeftIdentity false _xor_ - xor-identityʳ : RightIdentity false _xor_ - xor-identity : Identity false _xor_ - xor-inverseˡ : LeftInverse true not _xor_ - xor-inverseʳ : RightInverse true not _xor_ - xor-inverse : Inverse true not _xor_ - ∧-distribˡ-xor : _∧_ DistributesOverˡ _xor_ - ∧-distribʳ-xor : _∧_ DistributesOverʳ _xor_ - ∧-distrib-xor : _∧_ DistributesOver _xor_ - xor-annihilates-not : (not x) xor (not y) ≡ x xor y - ``` - -* Exposed container combinator conversion functions from `Data.Container.Combinator.Properties` - separately from their correctness proofs in `Data.Container.Combinator`: - ``` - to-id : F.id A → ⟦ id ⟧ A - from-id : ⟦ id ⟧ A → F.id A - to-const : A → ⟦ const A ⟧ B - from-const : ⟦ const A ⟧ B → A - to-∘ : ⟦ C₁ ⟧ (⟦ C₂ ⟧ A) → ⟦ C₁ ∘ C₂ ⟧ A - from-∘ : ⟦ C₁ ∘ C₂ ⟧ A → ⟦ C₁ ⟧ (⟦ C₂ ⟧ A) - to-× : ⟦ C₁ ⟧ A P.× ⟦ C₂ ⟧ A → ⟦ C₁ × C₂ ⟧ A - from-× : ⟦ C₁ × C₂ ⟧ A → ⟦ C₁ ⟧ A P.× ⟦ C₂ ⟧ A - to-Π : (∀ i → ⟦ Cᵢ i ⟧ A) → ⟦ Π I Cᵢ ⟧ A - from-Π : ⟦ Π I Cᵢ ⟧ A → ∀ i → ⟦ Cᵢ i ⟧ A - to-⊎ : ⟦ C₁ ⟧ A S.⊎ ⟦ C₂ ⟧ A → ⟦ C₁ ⊎ C₂ ⟧ A - from-⊎ : ⟦ C₁ ⊎ C₂ ⟧ A → ⟦ C₁ ⟧ A S.⊎ ⟦ C₂ ⟧ A - to-Σ : (∃ λ i → ⟦ C i ⟧ A) → ⟦ Σ I C ⟧ A - from-Σ : ⟦ Σ I C ⟧ A → ∃ λ i → ⟦ C i ⟧ A - ``` - -* Added new functions in `Data.Fin.Base`: - ``` - finToFun : Fin (m ^ n) → (Fin n → Fin m) - funToFin : (Fin m → Fin n) → Fin (n ^ m) - quotient : Fin (m * n) → Fin m - remainder : Fin (m * n) → Fin n - ``` - -* Added new proofs in `Data.Fin.Induction`: - ```agda - spo-wellFounded : IsStrictPartialOrder _≈_ _⊏_ → WellFounded _⊏_ - spo-noetherian : IsStrictPartialOrder _≈_ _⊏_ → WellFounded (flip _⊏_) - - <-weakInduction-startingFrom : P i → (∀ j → P (inject₁ j) → P (suc j)) → ∀ {j} → j ≥ i → P j - ``` - -* Added new definitions and proofs in `Data.Fin.Permutation`: - ```agda - insert : Fin (suc m) → Fin (suc n) → Permutation m n → Permutation (suc m) (suc n) - insert-punchIn : insert i j π ⟨$⟩ʳ punchIn i k ≡ punchIn j (π ⟨$⟩ʳ k) - insert-remove : insert i (π ⟨$⟩ʳ i) (remove i π) ≈ π - remove-insert : remove i (insert i j π) ≈ π - ``` - -* Added new proofs in `Data.Fin.Properties`: - ``` - nonZeroIndex : Fin n → ℕ.NonZero n - - 1↔⊤ : Fin 1 ↔ ⊤ - 2↔Bool : Fin 2 ↔ Bool - - 0≢1+n : zero ≢ suc i - - ↑ˡ-injective : i ↑ˡ n ≡ j ↑ˡ n → i ≡ j - ↑ʳ-injective : n ↑ʳ i ≡ n ↑ʳ j → i ≡ j - finTofun-funToFin : funToFin ∘ finToFun ≗ id - funTofin-funToFun : finToFun (funToFin f) ≗ f - ^↔→ : Extensionality _ _ → Fin (m ^ n) ↔ (Fin n → Fin m) - - toℕ-mono-< : i < j → toℕ i ℕ.< toℕ j - toℕ-mono-≤ : i ≤ j → toℕ i ℕ.≤ toℕ j - toℕ-cancel-≤ : toℕ i ℕ.≤ toℕ j → i ≤ j - toℕ-cancel-< : toℕ i ℕ.< toℕ j → i < j - - splitAt⁻¹-↑ˡ : splitAt m {n} i ≡ inj₁ j → j ↑ˡ n ≡ i - splitAt⁻¹-↑ʳ : splitAt m {n} i ≡ inj₂ j → m ↑ʳ j ≡ i - - toℕ-combine : toℕ (combine i j) ≡ k ℕ.* toℕ i ℕ.+ toℕ j - combine-injectiveˡ : combine i j ≡ combine k l → i ≡ k - combine-injectiveʳ : combine i j ≡ combine k l → j ≡ l - combine-injective : combine i j ≡ combine k l → i ≡ k × j ≡ l - combine-surjective : ∀ i → ∃₂ λ j k → combine j k ≡ i - combine-monoˡ-< : i < j → combine i k < combine j l - - ℕ-ℕ≡toℕ‿ℕ- : n ℕ-ℕ i ≡ toℕ (n ℕ- i) - - lower₁-injective : lower₁ i n≢i ≡ lower₁ j n≢j → i ≡ j - pinch-injective : suc i ≢ j → suc i ≢ k → pinch i j ≡ pinch i k → j ≡ k - - i<1+i : i < suc i - - injective⇒≤ : ∀ {f : Fin m → Fin n} → Injective f → m ℕ.≤ n - <⇒notInjective : ∀ {f : Fin m → Fin n} → n ℕ.< m → ¬ (Injective f) - ℕ→Fin-notInjective : ∀ (f : ℕ → Fin n) → ¬ (Injective f) - cantor-schröder-bernstein : ∀ {f : Fin m → Fin n} {g : Fin n → Fin m} → Injective f → Injective g → m ≡ n - - cast-is-id : cast eq k ≡ k - subst-is-cast : subst Fin eq k ≡ cast eq k - cast-trans : cast eq₂ (cast eq₁ k) ≡ cast (trans eq₁ eq₂) k - - fromℕ≢inject₁ : {i : Fin n} → fromℕ n ≢ inject₁ i - - inject≤-trans : inject≤ (inject≤ i m≤n) n≤o ≡ inject≤ i (≤-trans m≤n n≤o) - inject≤-irrelevant : inject≤ i m≤n ≡ inject≤ i m≤n′ - i≤inject₁[j]⇒i≤1+j : i ≤ inject₁ j → i ≤ suc j - ``` - -* Added new lemmas in `Data.Fin.Substitution.Lemmas.TermLemmas`: - ``` - map-var≡ : (∀ x → lookup ρ₁ x ≡ f x) → (∀ x → lookup ρ₂ x ≡ T.var (f x)) → map var ρ₁ ≡ ρ₂ - wk≡wk : map var VarSubst.wk ≡ T.wk {n = n} - id≡id : map var VarSubst.id ≡ T.id {n = n} - sub≡sub : map var (VarSubst.sub x) ≡ T.sub (T.var x) - ↑≡↑ : map var (ρ VarSubst.↑) ≡ map T.var ρ T.↑ - /Var≡/ : t /Var ρ ≡ t T./ map T.var ρ - - sub-renaming-commutes : t /Var VarSubst.sub x T./ ρ ≡ t T./ ρ T.↑ T./ T.sub (lookup ρ x) - sub-commutes-with-renaming : t T./ T.sub t′ /Var ρ ≡ t /Var ρ VarSubst.↑ T./ T.sub (t′ /Var ρ) - ``` - -* Added new functions and definitions in `Data.Integer.Base`: - ```agda - _^_ : ℤ → ℕ → ℤ - - +-0-rawGroup : Rawgroup 0ℓ 0ℓ - - *-rawMagma : RawMagma 0ℓ 0ℓ - *-1-rawMonoid : RawMonoid 0ℓ 0ℓ - ``` - -* Added new proofs in `Data.Integer.Properties`: - ```agda - sign-cong′ : s₁ ◃ n₁ ≡ s₂ ◃ n₂ → s₁ ≡ s₂ ⊎ (n₁ ≡ 0 × n₂ ≡ 0) - ≤-⊖ : m ℕ.≤ n → n ⊖ m ≡ + (n ∸ m) - ∣⊖∣-≤ : m ℕ.≤ n → ∣ m ⊖ n ∣ ≡ n ∸ m - ∣-∣-≤ : i ≤ j → + ∣ i - j ∣ ≡ j - i - - i^n≡0⇒i≡0 : i ^ n ≡ 0ℤ → i ≡ 0ℤ - ^-identityʳ : i ^ 1 ≡ i - ^-zeroˡ : 1 ^ n ≡ 1 - ^-*-assoc : (i ^ m) ^ n ≡ i ^ (m ℕ.* n) - ^-distribˡ-+-* : i ^ (m ℕ.+ n) ≡ i ^ m * i ^ n - - ^-isMagmaHomomorphism : IsMagmaHomomorphism ℕ.+-rawMagma *-rawMagma (i ^_) - ^-isMonoidHomomorphism : IsMonoidHomomorphism ℕ.+-0-rawMonoid *-1-rawMonoid (i ^_) - ``` - -* Added new proofs in `Data.Integer.GCD`: - ```agda - gcd-assoc : Associative gcd - gcd-zeroˡ : LeftZero 1ℤ gcd - gcd-zeroʳ : RightZero 1ℤ gcd - gcd-zero : Zero 1ℤ gcd - ``` - -* Added new functions and definitions to `Data.List.Base`: - ```agda - takeWhileᵇ : (A → Bool) → List A → List A - dropWhileᵇ : (A → Bool) → List A → List A - filterᵇ : (A → Bool) → List A → List A - partitionᵇ : (A → Bool) → List A → List A × List A - spanᵇ : (A → Bool) → List A → List A × List A - breakᵇ : (A → Bool) → List A → List A × List A - linesByᵇ : (A → Bool) → List A → List (List A) - wordsByᵇ : (A → Bool) → List A → List (List A) - derunᵇ : (A → A → Bool) → List A → List A - deduplicateᵇ : (A → A → Bool) → List A → List A - - findᵇ : (A → Bool) → List A -> Maybe A - findIndexᵇ : (A → Bool) → (xs : List A) → Maybe $ Fin (length xs) - findIndicesᵇ : (A → Bool) → (xs : List A) → List $ Fin (length xs) - find : Decidable P → List A → Maybe A - findIndex : Decidable P → (xs : List A) → Maybe $ Fin (length xs) - findIndices : Decidable P → (xs : List A) → List $ Fin (length xs) - - catMaybes : List (Maybe A) → List A - ap : List (A → B) → List A → List B - ++-rawMagma : Set a → RawMagma a _ - ++-[]-rawMonoid : Set a → RawMonoid a _ - - iterate : (A → A) → A → ℕ → List A - insertAt : (xs : List A) → Fin (suc (length xs)) → A → List A - updateAt : (xs : List A) → Fin (length xs) → (A → A) → List A - ``` - -* Added new proofs in `Data.List.Relation.Binary.Lex.Strict`: - ```agda - xs≮[] : ¬ xs < [] - ``` - -* Added new proofs to `Data.List.Relation.Binary.Permutation.Propositional.Properties`: - ```agda - Any-resp-[σ⁻¹∘σ] : (σ : xs ↭ ys) → (ix : Any P xs) → Any-resp-↭ (trans σ (↭-sym σ)) ix ≡ ix - ∈-resp-[σ⁻¹∘σ] : (σ : xs ↭ ys) → (ix : x ∈ xs) → ∈-resp-↭ (trans σ (↭-sym σ)) ix ≡ ix - ``` - -* In `Data.List.Relation.Binary.Permutation.Setoid.Properties`: - ```agda - foldr-commMonoid : xs ↭ ys → foldr _∙_ ε xs ≈ foldr _∙_ ε ys - ``` - -* Added new function to `Data.List.Relation.Binary.Permutation.Propositional.Properties` - ```agda - ↭-reverse : reverse xs ↭ xs - ``` - -* Added new proofs to `Data.List.Relation.Binary.Sublist.Setoid.Properties`: - ``` - ⊆-mergeˡ : xs ⊆ merge _≤?_ xs ys - ⊆-mergeʳ : ys ⊆ merge _≤?_ xs ys - ``` - -* Added new functions in `Data.List.Relation.Unary.All`: - ``` - decide : Π[ P ∪ Q ] → Π[ All P ∪ Any Q ] - ``` - -* Added new proof to `Data.List.Relation.Unary.All.Properties`: - ```agda - gmap⁻ : Q ∘ f ⋐ P → All Q ∘ map f ⋐ All P - ``` - -* Added new functions in `Data.List.Fresh.Relation.Unary.All`: - ``` - decide : Π[ P ∪ Q ] → Π[ All {R = R} P ∪ Any Q ] - ``` - -* Added new proofs to `Data.List.Membership.Propositional.Properties`: - ```agda - mapWith∈-id : mapWith∈ xs (λ {x} _ → x) ≡ xs - map-mapWith∈ : map g (mapWith∈ xs f) ≡ mapWith∈ xs (g ∘′ f) - ``` - -* Added new proofs to `Data.List.Membership.Setoid.Properties`: - ```agda - mapWith∈-id : mapWith∈ xs (λ {x} _ → x) ≡ xs - map-mapWith∈ : map g (mapWith∈ xs f) ≡ mapWith∈ xs (g ∘′ f) - index-injective : index x₁∈xs ≡ index x₂∈xs → x₁ ≈ x₂ - - ∈-++⁺∘++⁻ : (p : v ∈ xs ++ ys) → [ ∈-++⁺ˡ , ∈-++⁺ʳ xs ]′ (∈-++⁻ xs p) ≡ p - ∈-++⁻∘++⁺ : (p : v ∈ xs ⊎ v ∈ ys) → ∈-++⁻ xs ([ ∈-++⁺ˡ , ∈-++⁺ʳ xs ]′ p) ≡ p - ∈-++↔ : (v ∈ xs ⊎ v ∈ ys) ↔ v ∈ xs ++ ys - ∈-++-comm : v ∈ xs ++ ys → v ∈ ys ++ xs - ∈-++-comm∘++-comm : (p : v ∈ xs ++ ys) → ∈-++-comm ys xs (∈-++-comm xs ys p) ≡ p - ∈-++↔++ : v ∈ xs ++ ys ↔ v ∈ ys ++ xs - ``` - -* Add new proofs in `Data.List.Properties`: - ```agda - ∈⇒∣product : n ∈ ns → n ∣ product ns - ∷ʳ-++ : xs ∷ʳ a ++ ys ≡ xs ++ a ∷ ys - - concatMap-cong : f ≗ g → concatMap f ≗ concatMap g - concatMap-pure : concatMap [_] ≗ id - concatMap-map : concatMap g (map f xs) ≡ concatMap (g ∘′ f) xs - map-concatMap : map f ∘′ concatMap g ≗ concatMap (map f ∘′ g) - - 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) - - take-suc : take (suc m) xs ≡ take m xs ∷ʳ lookup xs i - take-suc-tabulate : take (suc m) (tabulate f) ≡ take m (tabulate f) ∷ʳ f i - drop-take-suc : drop m (take (suc m) xs) ≡ [ lookup xs i ] - drop-take-suc-tabulate : drop m (take (suc m) (tabulate f)) ≡ [ f i ] - - take-all : n ≥ length xs → take n xs ≡ xs - drop-all : n ≥ length xs → drop n xs ≡ [] - - take-[] : take m [] ≡ [] - drop-[] : drop m [] ≡ [] - - drop-drop : drop n (drop m xs) ≡ drop (m + n) xs - - lookup-replicate : lookup (replicate n x) i ≡ x - map-replicate : map f (replicate n x) ≡ replicate n (f x) - zipWith-replicate : zipWith _⊕_ (replicate n x) (replicate n y) ≡ replicate n (x ⊕ y) - - length-iterate : length (iterate f x n) ≡ n - iterate-id : iterate id x n ≡ replicate n x - lookup-iterate : lookup (iterate f x n) (cast (sym (length-iterate f x n)) i) ≡ ℕ.iterate f x (toℕ i) - - length-insertAt : length (insertAt xs i v) ≡ suc (length xs) - length-removeAt′ : length xs ≡ suc (length (removeAt xs k)) - removeAt-insertAt : removeAt (insertAt xs i v) ((cast (sym (length-insertAt xs i v)) i)) ≡ xs - insertAt-removeAt : insertAt (removeAt xs i) (cast (sym (lengthAt-removeAt xs i)) i) (lookup xs i) ≡ xs - - cartesianProductWith-zeroˡ : cartesianProductWith f [] ys ≡ [] - cartesianProductWith-zeroʳ : cartesianProductWith f xs [] ≡ [] - cartesianProductWith-distribʳ-++ : cartesianProductWith f (xs ++ ys) zs ≡ - cartesianProductWith f xs zs ++ cartesianProductWith f ys zs - - foldr-map : foldr f x (map g xs) ≡ foldr (g -⟨ f ∣) x xs - foldl-map : foldl f x (map g xs) ≡ foldl (∣ f ⟩- g) x xs - ``` - -* In `Data.List.NonEmpty.Base`: - ```agda - drop+ : ℕ → List⁺ A → List⁺ A - ``` - -* Added new proofs in `Data.List.NonEmpty.Properties`: - ```agda - length-++⁺ : length (xs ++⁺ ys) ≡ length xs + length ys - length-++⁺-tail : length (xs ++⁺ ys) ≡ suc (length xs + length (tail ys)) - ++-++⁺ : (xs ++ ys) ++⁺ zs ≡ xs ++⁺ ys ++⁺ zs - ++⁺-cancelˡ′ : xs ++⁺ zs ≡ ys ++⁺ zs′ → List.length xs ≡ List.length ys → zs ≡ zs′ - ++⁺-cancelˡ : xs ++⁺ ys ≡ xs ++⁺ zs → ys ≡ zs - drop+-++⁺ : drop+ (length xs) (xs ++⁺ ys) ≡ ys - map-++⁺-commute : map f (xs ++⁺ ys) ≡ map f xs ++⁺ map f ys - length-map : length (map f xs) ≡ length xs - map-cong : f ≗ g → map f ≗ map g - map-compose : map (g ∘ f) ≗ map g ∘ map f - ``` - -* Added new proof to `Data.Maybe.Properties` - ```agda - <∣>-idem : Idempotent _<∣>_ - ``` - -* Added new patterns and definitions to `Data.Nat.Base`: - ```agda - pattern z1⇒nonTrivial : 1 < n → NonTrivial n - nonZero⇒≢1⇒nonTrivial : .{{NonZero n}} → n ≢ 1 → NonTrivial n - recompute-nonTrivial : .{{NonTrivial n}} → NonTrivial n - nonTrivial⇒nonZero : .{{NonTrivial n}} → NonZero n - nonTrivial⇒n>1 : .{{NonTrivial n}} → 1 < n - nonTrivial⇒≢1 : .{{NonTrivial n}} → n ≢ 1 - - _⊔′_ : ℕ → ℕ → ℕ - _⊓′_ : ℕ → ℕ → ℕ - ∣_-_∣′ : ℕ → ℕ → ℕ - _! : ℕ → ℕ - - parity : ℕ → Parity - - +-rawMagma : RawMagma 0ℓ 0ℓ - +-0-rawMonoid : RawMonoid 0ℓ 0ℓ - *-rawMagma : RawMagma 0ℓ 0ℓ - *-1-rawMonoid : RawMonoid 0ℓ 0ℓ - +-*-rawNearSemiring : RawNearSemiring 0ℓ 0ℓ - +-*-rawSemiring : RawSemiring 0ℓ 0ℓ - ``` - -* Added a new proof to `Data.Nat.Binary.Properties`: - ```agda - suc-injective : Injective _≡_ _≡_ suc - toℕ-inverseˡ : Inverseˡ _≡_ _≡_ toℕ fromℕ - toℕ-inverseʳ : Inverseʳ _≡_ _≡_ toℕ fromℕ - toℕ-inverseᵇ : Inverseᵇ _≡_ _≡_ toℕ fromℕ - - <-asym : Asymmetric _<_ - ``` - -* Added a new pattern synonym and a new definition to `Data.Nat.Divisibility.Core`: - ```agda - pattern divides-refl q = divides q refl - record _HasNonTrivialDivisorLessThan_ (m n : ℕ) : Set where - ``` - -* Added a new instance, new definitions, and new proofs to `Data.Nat.Divisibility`: - ```agda - instance quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient - - equalityᵒ : m ∣ n → n ≡ m * quotient - quotient-∣ : m ∣ n → quotient ∣ n - quotient>1 : m ∣ n → m < n → 1 < quotient - quotient-< : m ∣ n → .{{NonTrivial m}} → .{{NonZero n}} → quotient < n - n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient - - hasNonTrivialDivisor-≢ : .{{NonTrivial d}} → .{{NonZero n}} → d ≢ n → d ∣ n → n HasNonTrivialDivisorLessThan n - hasNonTrivialDivisor-∣ : m HasNonTrivialDivisorLessThan n → m ∣ o → o HasNonTrivialDivisorLessThan n - hasNonTrivialDivisor-≤ : m HasNonTrivialDivisorLessThan n → n ≤ o → m HasNonTrivialDivisorLessThan o - ``` - -* Added new definitions, smart constructors and proofs to `Data.Nat.Primality`: - ```agda - infix 10 _Rough_ - _Rough_ : ℕ → Pred ℕ _ - 0-rough : 0 Rough n - 1-rough : 1 Rough n - 2-rough : 2 Rough n - rough⇒≤ : .{{NonTrivial n}} → m Rough n → m ≤ n - ∤⇒rough-suc : m ∤ n → m Rough n → (suc m) Rough n - rough∧∣⇒rough : m Rough o → n ∣ o → m Rough n - Composite : ℕ → Set - composite-≢ : .{{NonTrivial d}} → .{{NonZero n}} → d ≢ n → d ∣ n → Composite n - composite-∣ : .{{NonZero n}} → Composite m → m ∣ n → Composite n - composite? : Decidable Composite - Irreducible : ℕ → Set - irreducible? : Decidable Irreducible - composite⇒¬prime : Composite n → ¬ Prime n - ¬composite⇒prime : .{{NonTrivial n} → ¬ Composite n → Prime n - prime⇒¬composite : Prime n → ¬ Composite n - ¬prime⇒composite : .{{NonTrivial n} → ¬ Prime n → Composite n - prime⇒irreducible : Prime p → Irreducible p - irreducible⇒prime : .{{NonTrivial p}} → Irreducible p → Prime p - euclidsLemma : Prime p → p ∣ m * n → p ∣ m ⊎ p ∣ n - ``` - -* Added new proofs in `Data.Nat.Properties`: - ```agda - nonZero? : Decidable NonZero - n≮0 : n ≮ 0 - n+1+m≢m : n + suc m ≢ m - m*n≡0⇒m≡0 : .{{_ : NonZero n}} → m * n ≡ 0 → m ≡ 0 - n>0⇒n≢0 : n > 0 → n ≢ 0 - m*n≢0 : .{{_ : NonZero m}} .{{_ : NonZero n}} → NonZero (m * n) - m*n≢0⇒m≢0 : .{{NonZero (m * n)}} → NonZero m - m*n≢0⇒n≢0 : .{{NonZero (m * n)}} → NonZero n - m≢0∧n>1⇒m*n>1 : .{{_ : NonZero m}} .{{_ : NonTrivial n}} → NonTrivial (m * n) - n≢0∧m>1⇒m*n>1 : .{{_ : NonZero n}} .{{_ : NonTrivial m}} → NonTrivial (m * n) - m^n≢0 : .{{_ : NonZero m}} → NonZero (m ^ n) - m≤n⇒n∸m≤n : m ≤ n → n ∸ m ≤ n - - s0 : .{{_ : NonZero m}} n → m ^ n > 0 - - ^-monoˡ-≤ : (_^ n) Preserves _≤_ ⟶ _≤_ - ^-monoʳ-≤ : .{{_ : NonZero m}} → (m ^_) Preserves _≤_ ⟶ _≤_ - ^-monoˡ-< : .{{_ : NonZero n}} → (_^ n) Preserves _<_ ⟶ _<_ - ^-monoʳ-< : 1 < m → (m ^_) Preserves _<_ ⟶ _<_ - - n≡⌊n+n/2⌋ : n ≡ ⌊ n + n /2⌋ - n≡⌈n+n/2⌉ : n ≡ ⌈ n + n /2⌉ - - m-connex : Connex _≥_ _>_ - <-≤-connex : Connex _<_ _≤_ - >-≥-connex : Connex _>_ _≥_ - <-cmp : Trichotomous _≡_ _<_ - anyUpTo? : (P? : Decidable P) → ∀ v → Dec (∃ λ n → n < v × P n) - allUpTo? : (P? : Decidable P) → ∀ v → Dec (∀ {n} → n < v → P n) - ``` - -* Added new proofs in `Data.Nat.Combinatorics`: - ```agda - [n-k]*[n-k-1]!≡[n-k]! : k < n → (n ∸ k) * (n ∸ suc k) ! ≡ (n ∸ k) ! - [n-k]*d[k+1]≡[k+1]*d[k] : k < n → (n ∸ k) * ((suc k) ! * (n ∸ suc k) !) ≡ (suc k) * (k ! * (n ∸ k) !) - k![n∸k]!∣n! : k ≤ n → k ! * (n ∸ k) ! ∣ n ! - nP1≡n : n P 1 ≡ n - nC1≡n : n C 1 ≡ n - nCk+nC[k+1]≡[n+1]C[k+1] : n C k + n C (suc k) ≡ suc n C suc k - ``` - -* Added new proofs in `Data.Nat.DivMod`: - ```agda - m%n≤n : .{{_ : NonZero n}} → m % n ≤ n - m*n/m!≡n/[m∸1]! : .{{_ : NonZero m}} → m * n / m ! ≡ n / (pred m) ! - - %-congˡ : .{{_ : NonZero o}} → m ≡ n → m % o ≡ n % o - %-congʳ : .{{_ : NonZero m}} .{{_ : NonZero n}} → m ≡ n → o % m ≡ o % n - m/n≡0⇒m?_ : Decidable _>_ - - +-*-rawNearSemiring : RawNearSemiring 0ℓ 0ℓ - +-*-rawSemiring : RawSemiring 0ℓ 0ℓ - toℚᵘ-isNearSemiringHomomorphism-+-* : IsNearSemiringHomomorphism +-*-rawNearSemiring ℚᵘ.+-*-rawNearSemiring toℚᵘ - toℚᵘ-isNearSemiringMonomorphism-+-* : IsNearSemiringMonomorphism +-*-rawNearSemiring ℚᵘ.+-*-rawNearSemiring toℚᵘ - toℚᵘ-isSemiringHomomorphism-+-* : IsSemiringHomomorphism +-*-rawSemiring ℚᵘ.+-*-rawSemiring toℚᵘ - toℚᵘ-isSemiringMonomorphism-+-* : IsSemiringMonomorphism +-*-rawSemiring ℚᵘ.+-*-rawSemiring toℚᵘ - - pos⇒nonZero : .{{Positive p}} → NonZero p - neg⇒nonZero : .{{Negative p}} → NonZero p - nonZero⇒1/nonZero : .{{_ : NonZero p}} → NonZero (1/ p) - - <-dense : Dense _<_ - <-isDenseLinearOrder : IsDenseLinearOrder _≡_ _<_ - <-denseLinearOrder : DenseLinearOrder 0ℓ 0ℓ 0ℓ - ``` - -* Added new rounding functions in `Data.Rational.Unnormalised.Base`: - ```agda - floor ceiling truncate round ⌊_⌋ ⌈_⌉ [_] : ℚᵘ → ℤ - fracPart : ℚᵘ → ℚᵘ - ``` - -* Added new definitions in `Data.Rational.Unnormalised.Properties`: - ```agda - ↥p≡0⇒p≃0 : ↥ p ≡ 0ℤ → p ≃ 0ℚᵘ - p≃0⇒↥p≡0 : p ≃ 0ℚᵘ → ↥ p ≡ 0ℤ - ↥p≡↥q≡0⇒p≃q : ↥ p ≡ 0ℤ → ↥ q ≡ 0ℤ → p ≃ q - - +-*-rawNearSemiring : RawNearSemiring 0ℓ 0ℓ - +-*-rawSemiring : RawSemiring 0ℓ 0ℓ - - ≰⇒≥ : _≰_ ⇒ _≥_ - - _≥?_ : Decidable _≥_ - _>?_ : Decidable _>_ - - *-mono-≤-nonNeg : .{{_ : NonNegative p}} .{{_ : NonNegative r}} → p ≤ q → r ≤ s → p * r ≤ q * s - *-mono-<-nonNeg : .{{_ : NonNegative p}} .{{_ : NonNegative r}} → p < q → r < s → p * r < q * s - 1/-antimono-≤-pos : .{{_ : Positive p}} .{{_ : Positive q}} → p ≤ q → 1/ q ≤ 1/ p - ⊓-mono-< : _⊓_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_ - ⊔-mono-< : _⊔_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_ - - pos⇒nonZero : .{{_ : Positive p}} → NonZero p - neg⇒nonZero : .{{_ : Negative p}} → NonZero p - pos+pos⇒pos : .{{_ : Positive p}} .{{_ : Positive q}} → Positive (p + q) - nonNeg+nonNeg⇒nonNeg : .{{_ : NonNegative p}} .{{_ : NonNegative q}} → NonNegative (p + q) - pos*pos⇒pos : .{{_ : Positive p}} .{{_ : Positive q}} → Positive (p * q) - nonNeg*nonNeg⇒nonNeg : .{{_ : NonNegative p}} .{{_ : NonNegative q}} → NonNegative (p * q) - pos⊓pos⇒pos : .{{_ : Positive p}} .{{_ : Positive q}} → Positive (p ⊓ q) - pos⊔pos⇒pos : .{{_ : Positive p}} .{{_ : Positive q}} → Positive (p ⊔ q) - 1/nonZero⇒nonZero : .{{_ : NonZero p}} → NonZero (1/ p) - - 0≄1 : 0ℚᵘ ≄ 1ℚᵘ - ≃-≄-irreflexive : Irreflexive _≃_ _≄_ - ≄-symmetric : Symmetric _≄_ - ≄-cotransitive : Cotransitive _≄_ - ≄⇒invertible : p ≄ q → Invertible _≃_ 1ℚᵘ _*_ (p - q) - - <-dense : Dense _<_ - - <-isDenseLinearOrder : IsDenseLinearOrder _≃_ _<_ - +-*-isHeytingCommutativeRing : IsHeytingCommutativeRing _≃_ _≄_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ - +-*-isHeytingField : IsHeytingField _≃_ _≄_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ - - <-denseLinearOrder : DenseLinearOrder 0ℓ 0ℓ 0ℓ - +-*-heytingCommutativeRing : HeytingCommutativeRing 0ℓ 0ℓ 0ℓ - +-*-heytingField : HeytingField 0ℓ 0ℓ 0ℓ - - module ≃-Reasoning = SetoidReasoning ≃-setoid - ``` - -* Added new functions to `Data.Product.Nary.NonDependent`: - ```agda - zipWith : (∀ k → Projₙ as k → Projₙ bs k → Projₙ cs k) → Product n as → Product n bs → Product n cs - ``` - -* Added new proof to `Data.Product.Properties`: - ```agda - map-cong : f ≗ g → h ≗ i → map f h ≗ map g i - ``` - -* Added new definitions to `Data.Product.Properties`: - ``` - Σ-≡,≡→≡ : (∃ λ (p : proj₁ p₁ ≡ proj₁ p₂) → subst B p (proj₂ p₁) ≡ proj₂ p₂) → p₁ ≡ p₂ - Σ-≡,≡←≡ : p₁ ≡ p₂ → (∃ λ (p : proj₁ p₁ ≡ proj₁ p₂) → subst B p (proj₂ p₁) ≡ proj₂ p₂) - ×-≡,≡→≡ : (proj₁ p₁ ≡ proj₁ p₂ × proj₂ p₁ ≡ proj₂ p₂) → p₁ ≡ p₂ - ×-≡,≡←≡ : p₁ ≡ p₂ → (proj₁ p₁ ≡ proj₁ p₂ × proj₂ p₁ ≡ proj₂ p₂) - ``` - -* Added new proofs to `Data.Product.Relation.Binary.Lex.Strict` - ```agda - ×-respectsʳ : Transitive _≈₁_ → _<₁_ Respectsʳ _≈₁_ → _<₂_ Respectsʳ _≈₂_ → _<ₗₑₓ_ Respectsʳ _≋_ - ×-respectsˡ : Symmetric _≈₁_ → Transitive _≈₁_ → _<₁_ Respectsˡ _≈₁_ → _<₂_ Respectsˡ _≈₂_ → _<ₗₑₓ_ Respectsˡ _≋_ - ×-wellFounded' : Transitive _≈₁_ → _<₁_ Respectsʳ _≈₁_ → WellFounded _<₁_ → WellFounded _<₂_ → WellFounded _<ₗₑₓ_ - ``` - -* Added new definitions to `Data.Sign.Base`: - ```agda - *-rawMagma : RawMagma 0ℓ 0ℓ - *-1-rawMonoid : RawMonoid 0ℓ 0ℓ - *-1-rawGroup : RawGroup 0ℓ 0ℓ - ``` - -* Added new proofs to `Data.Sign.Properties`: - ```agda - *-inverse : Inverse + id _*_ - *-isCommutativeSemigroup : IsCommutativeSemigroup _*_ - *-isCommutativeMonoid : IsCommutativeMonoid _*_ + - *-isGroup : IsGroup _*_ + id - *-isAbelianGroup : IsAbelianGroup _*_ + id - *-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ - *-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ - *-group : Group 0ℓ 0ℓ - *-abelianGroup : AbelianGroup 0ℓ 0ℓ - ≡-isDecEquivalence : IsDecEquivalence _≡_ - ``` - -* Added new functions in `Data.String.Base`: - ```agda - wordsByᵇ : (Char → Bool) → String → List String - linesByᵇ : (Char → Bool) → String → List String - ``` - -* Added new proofs in `Data.String.Properties`: - ```agda - ≤-isDecTotalOrder-≈ : IsDecTotalOrder _≈_ _≤_ - ≤-decTotalOrder-≈ : DecTotalOrder _ _ _ - ``` -* Added new definitions in `Data.Sum.Properties`: - ```agda - swap-↔ : (A ⊎ B) ↔ (B ⊎ A) - ``` - -* Added new proofs in `Data.Sum.Properties`: - ```agda - map-assocˡ : map (map f g) h ∘ assocˡ ≗ assocˡ ∘ map f (map g h) - map-assocʳ : map f (map g h) ∘ assocʳ ≗ assocʳ ∘ map (map f g) h - ``` - -* Made `Map` public in `Data.Tree.AVL.IndexedMap` - -* Added new definitions in `Data.Vec.Base`: - ```agda - truncate : m ≤ n → Vec A n → Vec A m - pad : m ≤ n → A → Vec A m → Vec A n - - FoldrOp A B = A → B n → B (suc n) - FoldlOp A B = B n → A → B (suc n) - - foldr′ : (A → B → B) → B → Vec A n → B - foldl′ : (B → A → B) → B → Vec A n → B - countᵇ : (A → Bool) → Vec A n → ℕ - - iterate : (A → A) → A → Vec A n - - diagonal : Vec (Vec A n) n → Vec A n - DiagonalBind._>>=_ : Vec A n → (A → Vec B n) → Vec B n - - _ʳ++_ : Vec A m → Vec A n → Vec A (m + n) - - cast : .(eq : m ≡ n) → Vec A m → Vec A n - ``` - -* Added new instance in `Data.Vec.Effectful`: - ```agda - monad : RawMonad (λ (A : Set a) → Vec A n) - ``` - -* Added new proofs in `Data.Vec.Properties`: - ```agda - padRight-refl : padRight ≤-refl a xs ≡ xs - padRight-replicate : replicate a ≡ padRight le a (replicate a) - padRight-trans : padRight (≤-trans m≤n n≤p) a xs ≡ padRight n≤p a (padRight m≤n a xs) - - truncate-refl : truncate ≤-refl xs ≡ xs - truncate-trans : truncate (≤-trans m≤n n≤p) xs ≡ truncate m≤n (truncate n≤p xs) - truncate-padRight : truncate m≤n (padRight m≤n a xs) ≡ xs - - map-const : map (const x) xs ≡ replicate x - map-⊛ : map f xs ⊛ map g xs ≡ map (f ˢ g) xs - map-++ : map f (xs ++ ys) ≡ map f xs ++ map f ys - map-is-foldr : map f ≗ foldr (Vec B) (λ x ys → f x ∷ ys) [] - map-∷ʳ : map f (xs ∷ʳ x) ≡ (map f xs) ∷ʳ (f x) - map-reverse : map f (reverse xs) ≡ reverse (map f xs) - map-ʳ++ : map f (xs ʳ++ ys) ≡ map f xs ʳ++ map f ys - map-insert : map f (insert xs i x) ≡ insert (map f xs) i (f x) - toList-map : toList (map f xs) ≡ List.map f (toList xs) - - lookup-concat : lookup (concat xss) (combine i j) ≡ lookup (lookup xss i) j - - ⊛-is->>= : fs ⊛ xs ≡ fs >>= flip map xs - lookup-⊛* : lookup (fs ⊛* xs) (combine i j) ≡ (lookup fs i $ lookup xs j) - ++-is-foldr : xs ++ ys ≡ foldr ((Vec A) ∘ (_+ n)) _∷_ ys xs - []≔-++-↑ʳ : (xs ++ ys) [ m ↑ʳ i ]≔ y ≡ xs ++ (ys [ i ]≔ y) - unfold-ʳ++ : xs ʳ++ ys ≡ reverse xs ++ ys - - foldl-universal : (e : C zero) → ∀ {n} → Vec A n → C n) → - (∀ ... → h C g e [] ≡ e) → - (∀ ... → h C g e ∘ (x ∷_) ≗ h (C ∘ suc) g (g e x)) → - h B f e ≗ foldl B f e - foldl-fusion : h d ≡ e → (∀ ... → h (f b x) ≡ g (h b) x) → h ∘ foldl B f d ≗ foldl C g e - foldl-∷ʳ : foldl B f e (ys ∷ʳ y) ≡ f (foldl B f e ys) y - foldl-[] : foldl B f e [] ≡ e - foldl-reverse : foldl B {n} f e ∘ reverse ≗ foldr B (flip f) e - - foldr-[] : foldr B f e [] ≡ e - foldr-++ : foldr B f e (xs ++ ys) ≡ foldr (B ∘ (_+ n)) f (foldr B f e ys) xs - foldr-∷ʳ : foldr B f e (ys ∷ʳ y) ≡ foldr (B ∘ suc) f (f y e) ys - foldr-ʳ++ : foldr B f e (xs ʳ++ ys) ≡ foldl (B ∘ (_+ n)) (flip f) (foldr B f e ys) xs - foldr-reverse : foldr B f e ∘ reverse ≗ foldl B (flip f) e - - ∷ʳ-injective : xs ∷ʳ x ≡ ys ∷ʳ y → xs ≡ ys × x ≡ y - ∷ʳ-injectiveˡ : xs ∷ʳ x ≡ ys ∷ʳ y → xs ≡ ys - ∷ʳ-injectiveʳ : xs ∷ʳ x ≡ ys ∷ʳ y → x ≡ y - - unfold-∷ʳ : cast eq (xs ∷ʳ x) ≡ xs ++ [ x ] - init-∷ʳ : init (xs ∷ʳ x) ≡ xs - last-∷ʳ : last (xs ∷ʳ x) ≡ x - cast-∷ʳ : cast eq (xs ∷ʳ x) ≡ (cast (cong pred eq) xs) ∷ʳ x - ++-∷ʳ : cast eq ((xs ++ ys) ∷ʳ z) ≡ xs ++ (ys ∷ʳ z) - ∷ʳ-++ : cast eq ((xs ∷ʳ a) ++ ys) ≡ xs ++ (a ∷ ys) - - reverse-∷ : reverse (x ∷ xs) ≡ reverse xs ∷ʳ x - reverse-involutive : Involutive _≡_ reverse - reverse-reverse : reverse xs ≡ ys → reverse ys ≡ xs - reverse-injective : reverse xs ≡ reverse ys → xs ≡ ys - - transpose-replicate : transpose (replicate xs) ≡ map replicate xs - toList-replicate : toList (replicate {n = n} a) ≡ List.replicate n a - - toList-++ : toList (xs ++ ys) ≡ toList xs List.++ toList ys - - cast-is-id : cast eq xs ≡ xs - subst-is-cast : subst (Vec A) eq xs ≡ cast eq xs - cast-sym : cast eq xs ≡ ys → cast (sym eq) ys ≡ xs - cast-trans : cast eq₂ (cast eq₁ xs) ≡ cast (trans eq₁ eq₂) xs - map-cast : map f (cast eq xs) ≡ cast eq (map f xs) - lookup-cast : lookup (cast eq xs) (Fin.cast eq i) ≡ lookup xs i - lookup-cast₁ : lookup (cast eq xs) i ≡ lookup xs (Fin.cast (sym eq) i) - lookup-cast₂ : lookup xs (Fin.cast eq i) ≡ lookup (cast (sym eq) xs) i - cast-reverse : cast eq ∘ reverse ≗ reverse ∘ cast eq - cast-++ˡ : cast (cong (_+ n) eq) (xs ++ ys) ≡ cast eq xs ++ ys - cast-++ʳ : cast (cong (m +_) eq) (xs ++ ys) ≡ xs ++ cast eq ys - - iterate-id : iterate id x n ≡ replicate x - take-iterate : take n (iterate f x (n + m)) ≡ iterate f x n - drop-iterate : drop n (iterate f x n) ≡ [] - lookup-iterate : lookup (iterate f x n) i ≡ ℕ.iterate f x (toℕ i) - toList-iterate : toList (iterate f x n) ≡ List.iterate f x n - - zipwith-++ : zipWith f (xs ++ ys) (xs' ++ ys') ≡ zipWith f xs xs' ++ zipWith f ys ys' - - ++-assoc : cast eq ((xs ++ ys) ++ zs) ≡ xs ++ (ys ++ zs) - ++-identityʳ : cast eq (xs ++ []) ≡ xs - init-reverse : init ∘ reverse ≗ reverse ∘ tail - last-reverse : last ∘ reverse ≗ head - reverse-++ : cast eq (reverse (xs ++ ys)) ≡ reverse ys ++ reverse xs - - toList-cast : toList (cast eq xs) ≡ toList xs - cast-fromList : cast _ (fromList xs) ≡ fromList ys - fromList-map : cast _ (fromList (List.map f xs)) ≡ map f (fromList xs) - fromList-++ : cast _ (fromList (xs List.++ ys)) ≡ fromList xs ++ fromList ys - fromList-reverse : cast (Listₚ.length-reverse xs) (fromList (List.reverse xs)) ≡ reverse (fromList xs) - - ∷-ʳ++ : cast eq ((a ∷ xs) ʳ++ ys) ≡ xs ʳ++ (a ∷ ys) - ++-ʳ++ : cast eq ((xs ++ ys) ʳ++ zs) ≡ ys ʳ++ (xs ʳ++ zs) - ʳ++-ʳ++ : cast eq ((xs ʳ++ ys) ʳ++ zs) ≡ ys ʳ++ (xs ++ zs) - - length-toList : List.length (toList xs) ≡ length xs - toList-insertAt : toList (insertAt xs i v) ≡ List.insertAt (toList xs) (Fin.cast (cong suc (sym (length-toList xs))) i) v - - truncate≡take : .(eq : n ≡ m + o) → truncate m≤n xs ≡ take m (cast eq xs) - take≡truncate : take m xs ≡ truncate (m≤m+n m n) xs - lookup-truncate : lookup (truncate m≤n xs) i ≡ lookup xs (Fin.inject≤ i m≤n) - lookup-take-inject≤ : lookup (take m xs) i ≡ lookup xs (Fin.inject≤ i (m≤m+n m n)) - ``` - -* Added new proofs in `Data.Vec.Membership.Propositional.Properties`: - ```agda - index-∈-fromList⁺ : Any.index (∈-fromList⁺ v∈xs) ≡ indexₗ v∈xs - ``` - -* Added new isomorphisms to `Data.Unit.Polymorphic.Properties`: - ```agda - ⊤↔⊤* : ⊤ ↔ ⊤* - ``` - -* Added new proofs in `Data.Vec.Functional.Properties`: - ``` - map-updateAt : f ∘ g ≗ h ∘ f → map f (updateAt i g xs) ≗ updateAt i h (map f xs) - ``` - -* Added new proofs in `Data.Vec.Relation.Binary.Lex.Strict`: - ```agda - xs≮[] : ¬ xs < [] - - <-respectsˡ : IsPartialEquivalence _≈_ → _≺_ Respectsˡ _≈_ → _<_ Respectsˡ _≋_ - <-respectsʳ : IsPartialEquivalence _≈_ → _≺_ Respectsʳ _≈_ → _<_ _Respectsʳ _≋_ - <-wellFounded : Transitive _≈_ → _≺_ Respectsʳ _≈_ → WellFounded _≺_ → WellFounded _<_ - ``` - -* Added new function to `Data.Vec.Relation.Binary.Pointwise.Inductive` - ```agda - cong-[_]≔ : Pointwise _∼_ xs ys → Pointwise _∼_ (xs [ i ]≔ p) (ys [ i ]≔ p) - ``` - -* Added new function to `Data.Vec.Relation.Binary.Equality.Setoid` - ```agda - map-[]≔ : map f (xs [ i ]≔ p) ≋ map f xs [ i ]≔ f p - ``` - -* Added new functions in `Data.Vec.Relation.Unary.Any`: - ``` - lookup : Any P xs → A - ``` - -* Added new functions in `Data.Vec.Relation.Unary.All`: - ``` - decide : Π[ P ∪ Q ] → Π[ All P ∪ Any Q ] - - lookupAny : All P xs → (i : Any Q xs) → (P ∩ Q) (Any.lookup i) - lookupWith : ∀[ P ⇒ Q ⇒ R ] → All P xs → (i : Any Q xs) → R (Any.lookup i) - lookup : All P xs → (∀ {x} → x ∈ₚ xs → P x) - lookupₛ : P Respects _≈_ → All P xs → (∀ {x} → x ∈ xs → P x) - ``` - -* Added vector associativity proof to `Data.Vec.Relation.Binary.Equality.Setoid`: - ``` - ++-assoc : (xs ++ ys) ++ zs ≋ xs ++ (ys ++ zs) - ``` - -* Added new isomorphisms to `Data.Vec.N-ary`: - ```agda - Vec↔N-ary : ∀ n → (Vec A n → B) ↔ N-ary n A B - ``` - -* Added new isomorphisms to `Data.Vec.Recursive`: - ```agda - lift↔ : A ↔ B → A ^ n ↔ B ^ n - Fin[m^n]↔Fin[m]^n : Fin (m ^ n) ↔ Fin m Vec.^ n - ``` - -* Added new functions in `Effect.Monad.State`: - ``` - runState : State s a → s → a × s - evalState : State s a → s → a - execState : State s a → s → s - ``` - -* Added a non-dependent version of `flip` in `Function.Base`: - ```agda - flip′ : (A → B → C) → (B → A → C) - ``` - -* Added new proofs and definitions in `Function.Bundles`: - ```agda - LeftInverse.isSplitSurjection : LeftInverse → IsSplitSurjection to - LeftInverse.surjection : LeftInverse → Surjection - SplitSurjection = LeftInverse - _⟨$⟩_ = Func.to - ``` - -* Added new proofs to `Function.Properties.Inverse`: - ```agda - ↔-refl : Reflexive _↔_ - ↔-sym : Symmetric _↔_ - ↔-trans : Transitive _↔_ - - ↔⇒↣ : A ↔ B → A ↣ B - ↔-fun : A ↔ B → C ↔ D → (A → C) ↔ (B → D) - - Inverse⇒Injection : Inverse S T → Injection S T - ``` - -* Added new proofs in `Function.Construct.Symmetry`: - ``` - bijective : Bijective ≈₁ ≈₂ f → Symmetric ≈₂ → Transitive ≈₂ → Congruent ≈₁ ≈₂ f → Bijective ≈₂ ≈₁ f⁻¹ - isBijection : IsBijection ≈₁ ≈₂ f → Congruent ≈₂ ≈₁ f⁻¹ → IsBijection ≈₂ ≈₁ f⁻¹ - isBijection-≡ : IsBijection ≈₁ _≡_ f → IsBijection _≡_ ≈₁ f⁻¹ - bijection : Bijection R S → Congruent IB.Eq₂._≈_ IB.Eq₁._≈_ f⁻¹ → Bijection S R - bijection-≡ : Bijection R (setoid B) → Bijection (setoid B) R - sym-⤖ : A ⤖ B → B ⤖ A - ``` - -* Added new operations in `Function.Strict`: - ``` - _!|>_ : (a : A) → (∀ a → B a) → B a - _!|>′_ : A → (A → B) → B - ``` - -* Added new proof and record in `Function.Structures`: - ```agda - record IsSplitSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) - ``` - -* Added new definition to the `Surjection` module in `Function.Related.Surjection`: - ``` - f⁻ = proj₁ ∘ surjective - ``` - -* Added new proof to `Induction.WellFounded` - ```agda - Acc-resp-flip-≈ : _<_ Respectsʳ (flip _≈_) → (Acc _<_) Respects _≈_ - acc⇒asym : Acc _<_ x → x < y → ¬ (y < x) - wf⇒asym : WellFounded _<_ → Asymmetric _<_ - wf⇒irrefl : _<_ Respects₂ _≈_ → Symmetric _≈_ → WellFounded _<_ → Irreflexive _≈_ _<_ - ``` - -* Added new operations in `IO`: - ``` - Colist.forM : Colist A → (A → IO B) → IO (Colist B) - Colist.forM′ : Colist A → (A → IO B) → IO ⊤ - - List.forM : List A → (A → IO B) → IO (List B) - List.forM′ : List A → (A → IO B) → IO ⊤ - ``` - -* Added new operations in `IO.Base`: - ``` - lift! : IO A → IO (Lift b A) - _<$_ : B → IO A → IO B - _=<<_ : (A → IO B) → IO A → IO B - _<<_ : IO B → IO A → IO B - lift′ : Prim.IO ⊤ → IO {a} ⊤ - - when : Bool → IO ⊤ → IO ⊤ - unless : Bool → IO ⊤ → IO ⊤ - - whenJust : Maybe A → (A → IO ⊤) → IO ⊤ - untilJust : IO (Maybe A) → IO A - untilRight : (A → IO (A ⊎ B)) → A → IO B - ``` - -* Added new functions in `Reflection.AST.Term`: - ``` - stripPis : Term → List (String × Arg Type) × Term - prependLams : List (String × Visibility) → Term → Term - prependHLams : List String → Term → Term - prependVLams : List String → Term → Term - ``` - -* Added new types and operations to `Reflection.TCM`: - ``` - Blocker : Set - blockerMeta : Meta → Blocker - blockerAny : List Blocker → Blocker - blockerAll : List Blocker → Blocker - blockTC : Blocker → TC A - ``` - -* Added new operations in `Relation.Binary.Construct.Closure.Equivalence`: - ``` - fold : IsEquivalence _∼_ → _⟶_ ⇒ _∼_ → EqClosure _⟶_ ⇒ _∼_ - gfold : IsEquivalence _∼_ → _⟶_ =[ f ]⇒ _∼_ → EqClosure _⟶_ =[ f ]⇒ _∼_ - return : _⟶_ ⇒ EqClosure _⟶_ - join : EqClosure (EqClosure _⟶_) ⇒ EqClosure _⟶_ - _⋆ : _⟶₁_ ⇒ EqClosure _⟶₂_ → EqClosure _⟶₁_ ⇒ EqClosure _⟶₂_ - ``` - -* Added new operations in `Relation.Binary.Construct.Closure.Symmetric`: - ``` - fold : Symmetric _∼_ → _⟶_ ⇒ _∼_ → SymClosure _⟶_ ⇒ _∼_ - gfold : Symmetric _∼_ → _⟶_ =[ f ]⇒ _∼_ → SymClosure _⟶_ =[ f ]⇒ _∼_ - return : _⟶_ ⇒ SymClosure _⟶_ - join : SymClosure (SymClosure _⟶_) ⇒ SymClosure _⟶_ - _⋆ : _⟶₁_ ⇒ SymClosure _⟶₂_ → SymClosure _⟶₁_ ⇒ SymClosure _⟶₂_ - ``` - -* Added new proofs to `Relation.Binary.Lattice.Properties.{Join,Meet}Semilattice`: - ```agda - isPosemigroup : IsPosemigroup _≈_ _≤_ _∨_ - posemigroup : Posemigroup c ℓ₁ ℓ₂ - ≈-dec⇒≤-dec : Decidable _≈_ → Decidable _≤_ - ≈-dec⇒isDecPartialOrder : Decidable _≈_ → IsDecPartialOrder _≈_ _≤_ - ``` - -* Added new proofs to `Relation.Binary.Lattice.Properties.Bounded{Join,Meet}Semilattice`: - ```agda - isCommutativePomonoid : IsCommutativePomonoid _≈_ _≤_ _∨_ ⊥ - commutativePomonoid : CommutativePomonoid c ℓ₁ ℓ₂ - ``` - -* Added new proofs to `Relation.Binary.Properties.Poset`: - ```agda - ≤-dec⇒≈-dec : Decidable _≤_ → Decidable _≈_ - ≤-dec⇒isDecPartialOrder : Decidable _≤_ → IsDecPartialOrder _≈_ _≤_ - ``` - -* Added new proofs in `Relation.Binary.Properties.StrictPartialOrder`: - ```agda - >-strictPartialOrder : StrictPartialOrder s₁ s₂ s₃ - ``` - -* Added new proofs in `Relation.Binary.PropositionalEquality.Properties`: - ``` - subst-application′ : subst Q eq (f x p) ≡ f y (subst P eq p) - sym-cong : sym (cong f p) ≡ cong f (sym p) - ``` - -* Added new proofs in `Relation.Binary.HeterogeneousEquality`: - ``` - subst₂-removable : subst₂ _∼_ eq₁ eq₂ p ≅ p - ``` - -* Added new definitions in `Relation.Unary`: - ``` - _≐_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _ - _≐′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _ - _∖_ : Pred A ℓ₁ → Pred A ℓ₂ → Pred A _ - ``` - -* Added new proofs in `Relation.Unary.Properties`: - ``` - ⊆-reflexive : _≐_ ⇒ _⊆_ - ⊆-antisym : Antisymmetric _≐_ _⊆_ - ⊆-min : Min _⊆_ ∅ - ⊆-max : Max _⊆_ U - ⊂⇒⊆ : _⊂_ ⇒ _⊆_ - ⊂-trans : Trans _⊂_ _⊂_ _⊂_ - ⊂-⊆-trans : Trans _⊂_ _⊆_ _⊂_ - ⊆-⊂-trans : Trans _⊆_ _⊂_ _⊂_ - ⊂-respʳ-≐ : _⊂_ Respectsʳ _≐_ - ⊂-respˡ-≐ : _⊂_ Respectsˡ _≐_ - ⊂-resp-≐ : _⊂_ Respects₂ _≐_ - ⊂-irrefl : Irreflexive _≐_ _⊂_ - ⊂-antisym : Antisymmetric _≐_ _⊂_ - - ∅-⊆′ : (P : Pred A ℓ) → ∅ ⊆′ P - ⊆′-U : (P : Pred A ℓ) → P ⊆′ U - ⊆′-refl : Reflexive {A = Pred A ℓ} _⊆′_ - ⊆′-reflexive : _≐′_ ⇒ _⊆′_ - ⊆′-trans : Trans _⊆′_ _⊆′_ _⊆′_ - ⊆′-antisym : Antisymmetric _≐′_ _⊆′_ - ⊆′-min : Min _⊆′_ ∅ - ⊆′-max : Max _⊆′_ U - ⊂′-trans : Trans _⊂′_ _⊂′_ _⊂′_ - ⊂′-⊆′-trans : Trans _⊂′_ _⊆′_ _⊂′_ - ⊆′-⊂′-trans : Trans _⊆′_ _⊂′_ _⊂′_ - ⊂′-respʳ-≐′ : _⊂′_ Respectsʳ _≐′_ - ⊂′-respˡ-≐′ : _⊂′_ Respectsˡ _≐′_ - ⊂′-resp-≐′ : _⊂′_ Respects₂ _≐′_ - ⊂′-irrefl : Irreflexive _≐′_ _⊂′_ - ⊂′-antisym : Antisymmetric _≐′_ _⊂′_ - ⊂′⇒⊆′ : _⊂′_ ⇒ _⊆′_ - ⊆⇒⊆′ : _⊆_ ⇒ _⊆′_ - ⊆′⇒⊆ : _⊆′_ ⇒ _⊆_ - ⊂⇒⊂′ : _⊂_ ⇒ _⊂′_ - ⊂′⇒⊂ : _⊂′_ ⇒ _⊂_ - - ≐-refl : Reflexive _≐_ - ≐-sym : Sym _≐_ _≐_ - ≐-trans : Trans _≐_ _≐_ _≐_ - ≐′-refl : Reflexive _≐′_ - ≐′-sym : Sym _≐′_ _≐′_ - ≐′-trans : Trans _≐′_ _≐′_ _≐′_ - ≐⇒≐′ : _≐_ ⇒ _≐′_ - ≐′⇒≐ : _≐′_ ⇒ _≐_ - - U-irrelevant : Irrelevant U - ∁-irrelevant : (P : Pred A ℓ) → Irrelevant (∁ P) - ``` - -* Generalised proofs in `Relation.Unary.Properties`: - ``` - ⊆-trans : Trans _⊆_ _⊆_ _⊆_ - ``` - -* Added new proofs in `Relation.Binary.Properties.Setoid`: - ``` - ≈-isPreorder : IsPreorder _≈_ _≈_ - ≈-isPartialOrder : IsPartialOrder _≈_ _≈_ - - ≈-preorder : Preorder a ℓ ℓ - ≈-poset : Poset a ℓ ℓ - ``` - -* Added new definitions in `Relation.Binary.Definitions`: - ``` - RightTrans R S = Trans R S R - LeftTrans S R = Trans S R R - - Dense _<_ = x < y → ∃[ z ] x < z × z < y - Cotransitive _#_ = x # y → ∀ z → (x # z) ⊎ (z # y) - Tight _≈_ _#_ = (¬ x # y → x ≈ y) × (x ≈ y → ¬ x # y) - - Monotonic₁ _≤_ _⊑_ f = f Preserves _≤_ ⟶ _⊑_ - Antitonic₁ _≤_ _⊑_ f = f Preserves (flip _≤_) ⟶ _⊑_ - Monotonic₂ _≤_ _⊑_ _≼_ ∙ = ∙ Preserves₂ _≤_ ⟶ _⊑_ ⟶ _≼_ - MonotonicAntitonic _≤_ _⊑_ _≼_ ∙ = ∙ Preserves₂ _≤_ ⟶ (flip _⊑_) ⟶ _≼_ - AntitonicMonotonic _≤_ _⊑_ _≼_ ∙ = ∙ Preserves₂ (flip _≤_) ⟶ _⊑_ ⟶ _≼_ - Antitonic₂ _≤_ _⊑_ _≼_ ∙ = ∙ Preserves₂ (flip _≤_) ⟶ (flip _⊑_) ⟶ _≼_ - Adjoint _≤_ _⊑_ f g = (f x ⊑ y → x ≤ g y) × (x ≤ g y → f x ⊑ y) - ``` - -* Added new definitions in `Relation.Binary.Bundles`: - ``` - record DenseLinearOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where - record ApartnessRelation c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where - ``` - -* Added new definitions in `Relation.Binary.Structures`: - ``` - record IsDenseLinearOrder (_<_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where - record IsApartnessRelation (_#_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where - ``` - -* Added new proofs to `Relation.Binary.Consequences`: - ``` - sym⇒¬-sym : Symmetric _∼_ → Symmetric (¬_ ∘₂ _∼_) - cotrans⇒¬-trans : Cotransitive _∼_ → Transitive (¬_ ∘₂ _∼_) - irrefl⇒¬-refl : Reflexive _≈_ → Irreflexive _≈_ _∼_ → Reflexive (¬_ ∘₂ _∼_) - mono₂⇒cong₂ : Symmetric ≈₁ → ≈₁ ⇒ ≤₁ → Antisymmetric ≈₂ ≤₂ → ∀ {f} → - f Preserves₂ ≤₁ ⟶ ≤₁ ⟶ ≤₂ → - f Preserves₂ ≈₁ ⟶ ≈₁ ⟶ ≈₂ - ``` - -* Added new proofs to `Relation.Binary.Construct.Closure.Transitive`: - ``` - accessible⁻ : Acc _∼⁺_ x → Acc _∼_ x - wellFounded⁻ : WellFounded _∼⁺_ → WellFounded _∼_ - accessible : Acc _∼_ x → Acc _∼⁺_ x - ``` - -* Added new operations in `Relation.Binary.PropositionalEquality.Properties`: - ``` - J : (B : (y : A) → x ≡ y → Set b) (p : x ≡ y) → B x refl → B y p - dcong : (p : x ≡ y) → subst B p (f x) ≡ f y - dcong₂ : (p : x₁ ≡ x₂) → subst B p y₁ ≡ y₂ → f x₁ y₁ ≡ f x₂ y₂ - dsubst₂ : (p : x₁ ≡ x₂) → subst B p y₁ ≡ y₂ → C x₁ y₁ → C x₂ y₂ - ddcong₂ : (p : x₁ ≡ x₂) (q : subst B p y₁ ≡ y₂) → dsubst₂ C p q (f x₁ y₁) ≡ f x₂ y₂ - - isPartialOrder : IsPartialOrder _≡_ _≡_ - poset : Set a → Poset _ _ _ - ``` - -* Added new proof in `Relation.Nullary.Reflects`: - ```agda - T-reflects : Reflects (T b) b - T-reflects-elim : Reflects (T a) b → b ≡ a - ``` - -* Added new operations in `System.Exit`: - ``` - isSuccess : ExitCode → Bool - isFailure : ExitCode → Bool - ``` - -NonZero/Positive/Negative changes ---------------------------------- - -This is a full list of proofs that have changed form to use irrelevant instance arguments: - -* In `Data.Nat.Base`: - ``` - ≢-nonZero⁻¹ : ∀ {n} → .(NonZero n) → n ≢ 0 - >-nonZero⁻¹ : ∀ {n} → .(NonZero n) → n > 0 - ``` - -* In `Data.Nat.Properties`: - ``` - *-cancelʳ-≡ : ∀ m n {o} → m * suc o ≡ n * suc o → m ≡ n - *-cancelˡ-≡ : ∀ {m n} o → suc o * m ≡ suc o * n → m ≡ n - *-cancelʳ-≤ : ∀ m n o → m * suc o ≤ n * suc o → m ≤ n - *-cancelˡ-≤ : ∀ {m n} o → suc o * m ≤ suc o * n → m ≤ n - *-monoˡ-< : ∀ n → (_* suc n) Preserves _<_ ⟶ _<_ - *-monoʳ-< : ∀ n → (suc n *_) Preserves _<_ ⟶ _<_ - - m≤m*n : ∀ m {n} → 0 < n → m ≤ m * n - m≤n*m : ∀ m {n} → 0 < n → m ≤ n * m - m⇒∤ : ∀ {m n} → m > suc n → m ∤ suc n - *-cancelˡ-∣ : ∀ {i j} k → suc k * i ∣ suc k * j → i ∣ j - ``` - -* In `Data.Nat.DivMod`: - ``` - m≡m%n+[m/n]*n : ∀ m n → m ≡ m % suc n + (m / suc n) * suc n - m%n≡m∸m/n*n : ∀ m n → m % suc n ≡ m ∸ (m / suc n) * suc n - n%n≡0 : ∀ n → suc n % suc n ≡ 0 - m%n%n≡m%n : ∀ m n → m % suc n % suc n ≡ m % suc n - [m+n]%n≡m%n : ∀ m n → (m + suc n) % suc n ≡ m % suc n - [m+kn]%n≡m%n : ∀ m k n → (m + k * (suc n)) % suc n ≡ m % suc n - m*n%n≡0 : ∀ m n → (m * suc n) % suc n ≡ 0 - m%n 0ℤ - negative⁻¹ : ∀ {i} → Negative i → i < 0ℤ - nonPositive⁻¹ : ∀ {i} → NonPositive i → i ≤ 0ℤ - nonNegative⁻¹ : ∀ {i} → NonNegative i → i ≥ 0ℤ - negative_ - *-monoʳ-<-neg : ∀ n → (_* -[1+ n ]) Preserves _<_ ⟶ _>_ - *-cancelˡ-<-nonPos : ∀ n → NonPositive n → n * i < n * j → i > j - *-cancelʳ-<-nonPos : ∀ n → NonPositive n → i * n < j * n → i > j - - *-distribˡ-⊓-nonNeg : ∀ m j k → + m * (j ⊓ k) ≡ (+ m * j) ⊓ (+ m * k) - *-distribʳ-⊓-nonNeg : ∀ m j k → (j ⊓ k) * + m ≡ (j * + m) ⊓ (k * + m) - *-distribˡ-⊓-nonPos : ∀ i → NonPositive i → ∀ j k → i * (j ⊓ k) ≡ (i * j) ⊔ (i * k) - *-distribʳ-⊓-nonPos : ∀ i → NonPositive i → ∀ j k → (j ⊓ k) * i ≡ (j * i) ⊔ (k * i) - *-distribˡ-⊔-nonNeg : ∀ m j k → + m * (j ⊔ k) ≡ (+ m * j) ⊔ (+ m * k) - *-distribʳ-⊔-nonNeg : ∀ m j k → (j ⊔ k) * + m ≡ (j * + m) ⊔ (k * + m) - *-distribˡ-⊔-nonPos : ∀ i → NonPositive i → ∀ j k → i * (j ⊔ k) ≡ (i * j) ⊓ (i * k) - *-distribʳ-⊔-nonPos : ∀ i → NonPositive i → ∀ j k → (j ⊔ k) * i ≡ (j * i) ⊓ (k * i) - ``` - -* In `Data.Integer.Divisibility`: - ``` - *-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j - *-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j - ``` - -* In `Data.Integer.Divisibility.Signed`: - ``` - *-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j - *-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j - ``` - -* In `Data.Rational.Unnormalised.Properties`: - ```agda - positive⁻¹ : ∀ {q} → .(Positive q) → q > 0ℚᵘ - nonNegative⁻¹ : ∀ {q} → .(NonNegative q) → q ≥ 0ℚᵘ - negative⁻¹ : ∀ {q} → .(Negative q) → q < 0ℚᵘ - nonPositive⁻¹ : ∀ {q} → .(NonPositive q) → q ≤ 0ℚᵘ - positive⇒nonNegative : ∀ {p} → Positive p → NonNegative p - negative⇒nonPositive : ∀ {p} → Negative p → NonPositive p - negative_ - *-monoʳ-<-neg : ∀ r → Negative r → (r *_) Preserves _<_ ⟶ _>_ - - pos⇒1/pos : ∀ p (p>0 : Positive p) → Positive ((1/ p) {{pos⇒≢0 p p>0}}) - neg⇒1/neg : ∀ p (p<0 : Negative p) → Negative ((1/ p) {{neg⇒≢0 p p<0}}) - - *-distribʳ-⊓-nonNeg : ∀ p → NonNegative p → ∀ q r → (q ⊓ r) * p ≃ (q * p) ⊓ (r * p) - *-distribˡ-⊓-nonNeg : ∀ p → NonNegative p → ∀ q r → p * (q ⊓ r) ≃ (p * q) ⊓ (p * r) - *-distribˡ-⊔-nonNeg : ∀ p → NonNegative p → ∀ q r → p * (q ⊔ r) ≃ (p * q) ⊔ (p * r) - *-distribʳ-⊔-nonNeg : ∀ p → NonNegative p → ∀ q r → (q ⊔ r) * p ≃ (q * p) ⊔ (r * p) - *-distribˡ-⊔-nonPos : ∀ p → NonPositive p → ∀ q r → p * (q ⊔ r) ≃ (p * q) ⊓ (p * r) - *-distribʳ-⊔-nonPos : ∀ p → NonPositive p → ∀ q r → (q ⊔ r) * p ≃ (q * p) ⊓ (r * p) - *-distribˡ-⊓-nonPos : ∀ p → NonPositive p → ∀ q r → p * (q ⊓ r) ≃ (p * q) ⊔ (p * r) - *-distribʳ-⊓-nonPos : ∀ p → NonPositive p → ∀ q r → (q ⊓ r) * p ≃ (q * p) ⊔ (r * p) - ``` - -* In `Data.Rational.Properties`: - ``` - positive⁻¹ : Positive p → p > 0ℚ - nonNegative⁻¹ : NonNegative p → p ≥ 0ℚ - negative⁻¹ : Negative p → p < 0ℚ - nonPositive⁻¹ : NonPositive p → p ≤ 0ℚ - negative q - *-cancelʳ-<-nonPos : ∀ r → NonPositive r → ∀ {p q} → p * r < q * r → p > q - *-monoʳ-≤-nonNeg : ∀ r → NonNegative r → (_* r) Preserves _≤_ ⟶ _≤_ - *-monoˡ-≤-nonNeg : ∀ r → NonNegative r → (r *_) Preserves _≤_ ⟶ _≤_ - *-monoʳ-≤-nonPos : ∀ r → NonPositive r → (_* r) Preserves _≤_ ⟶ _≥_ - *-monoˡ-≤-nonPos : ∀ r → NonPositive r → (r *_) Preserves _≤_ ⟶ _≥_ - *-monoˡ-<-pos : ∀ r → Positive r → (_* r) Preserves _<_ ⟶ _<_ - *-monoʳ-<-pos : ∀ r → Positive r → (r *_) Preserves _<_ ⟶ _<_ - *-monoˡ-<-neg : ∀ r → Negative r → (_* r) Preserves _<_ ⟶ _>_ - *-monoʳ-<-neg : ∀ r → Negative r → (r *_) Preserves _<_ ⟶ _>_ - - *-distribˡ-⊓-nonNeg : ∀ p → NonNegative p → ∀ q r → p * (q ⊓ r) ≡ (p * q) ⊓ (p * r) - *-distribʳ-⊓-nonNeg : ∀ p → NonNegative p → ∀ q r → (q ⊓ r) * p ≡ (q * p) ⊓ (r * p) - *-distribˡ-⊔-nonNeg : ∀ p → NonNegative p → ∀ q r → p * (q ⊔ r) ≡ (p * q) ⊔ (p * r) - *-distribʳ-⊔-nonNeg : ∀ p → NonNegative p → ∀ q r → (q ⊔ r) * p ≡ (q * p) ⊔ (r * p) - *-distribˡ-⊔-nonPos : ∀ p → NonPositive p → ∀ q r → p * (q ⊔ r) ≡ (p * q) ⊓ (p * r) - *-distribʳ-⊔-nonPos : ∀ p → NonPositive p → ∀ q r → (q ⊔ r) * p ≡ (q * p) ⊓ (r * p) - *-distribˡ-⊓-nonPos : ∀ p → NonPositive p → ∀ q r → p * (q ⊓ r) ≡ (p * q) ⊔ (p * r) - *-distribʳ-⊓-nonPos : ∀ p → NonPositive p → ∀ q r → (q ⊓ r) * p ≡ (q * p) ⊔ (r * p) - - pos⇒1/pos : ∀ p (p>0 : Positive p) → Positive ((1/ p) {{pos⇒≢0 p p>0}}) - neg⇒1/neg : ∀ p (p<0 : Negative p) → Negative ((1/ p) {{neg⇒≢0 p p<0}}) - 1/pos⇒pos : ∀ p .{{_ : NonZero p}} → (1/p : Positive (1/ p)) → Positive p - 1/neg⇒neg : ∀ p .{{_ : NonZero p}} → (1/p : Negative (1/ p)) → Negative p + m≤n+o⇒m∸n≤o : ∀ m n {o} → m ≤ n + o → m ∸ n ≤ o + m Date: Wed, 13 Dec 2023 18:01:56 +0000 Subject: [PATCH 77/85] restored deleted proof --- src/Data/Digit.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Digit.agda b/src/Data/Digit.agda index 5e7715db73..4b3ecb22f5 100644 --- a/src/Data/Digit.agda +++ b/src/Data/Digit.agda @@ -56,7 +56,7 @@ toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) [] aux {zero} _ xs = (0 ∷ xs) aux {n@(suc _)} (acc wf) xs with does (0 Date: Wed, 13 Dec 2023 19:35:31 +0000 Subject: [PATCH 78/85] fix whitespace --- src/Data/Rational/Properties.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Rational/Properties.agda b/src/Data/Rational/Properties.agda index c7556323b0..6ff6a8bc6d 100644 --- a/src/Data/Rational/Properties.agda +++ b/src/Data/Rational/Properties.agda @@ -316,7 +316,7 @@ normalize-injective-≃ m n c d eq = ℕ./-cancelʳ-≡ (m ℕ./ gcd[m,c]) ℕ.* (d ℕ./ gcd[n,d]) ≡⟨ cong₂ ℕ._*_ m/gcd[m,c]≡n/gcd[n,d] (sym c/gcd[m,c]≡d/gcd[n,d]) ⟩ (n ℕ./ gcd[n,d]) ℕ.* (c ℕ./ gcd[m,c]) ≡⟨ ℕ./-*-interchange gcd[n,d]∣n gcd[m,c]∣c ⟨ (n ℕ.* c) ℕ./ (gcd[n,d] ℕ.* gcd[m,c]) ≡⟨ ℕ./-congʳ (ℕ.*-comm gcd[n,d] gcd[m,c]) ⟩ - (n ℕ.* c) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ∎ + (n ℕ.* c) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ∎ where open ≡-Reasoning gcd[m,c] = ℕ.gcd m c From 032506dd97302e4c8733c4197f09650ae2123c9e Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Wed, 13 Dec 2023 19:41:24 +0000 Subject: [PATCH 79/85] renaming: `DivMod.nonZeroDivisor` --- CHANGELOG.md | 4 ++-- src/Data/Nat/DivMod.agda | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f509607178..8466a58c3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Additions to existing modules m/n≡0⇒m Date: Thu, 14 Dec 2023 01:26:07 +0000 Subject: [PATCH 80/85] =?UTF-8?q?localised=20use=20of=20`=E2=89=A4-Reasoni?= =?UTF-8?q?ng`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Nat/Divisibility.agda | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 5cf713fe18..31adbc58c0 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -42,7 +42,6 @@ open import Data.Nat.Divisibility.Core public hiding (*-pres-∣) module _ (m∣n : m ∣ n) where open _∣_ m∣n - open ≤-Reasoning quotient≢0 : .{{NonZero n}} → NonZero quotient quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient @@ -59,13 +58,16 @@ module _ (m∣n : m ∣ n) where m <⟨ m1 m) ⟩ quotient * m ≡⟨ equality ⟨ n ∎ - where instance _ = quotient≢0 + where + open ≤-Reasoning + instance _ = quotient≢0 -- Exports From 9708ca8a6b528180d59025892aa8df941b9e3141 Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 14 Dec 2023 01:42:51 +0000 Subject: [PATCH 81/85] reverted export; removed anonymous module --- src/Data/Nat/Divisibility.agda | 59 ++++++++++++----------------- src/Data/Nat/Divisibility/Core.agda | 2 + 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 31adbc58c0..ccc2d3fae2 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -39,43 +39,32 @@ private open import Data.Nat.Divisibility.Core public hiding (*-pres-∣) -module _ (m∣n : m ∣ n) where - - open _∣_ m∣n - - quotient≢0 : .{{NonZero n}} → NonZero quotient - quotient≢0 rewrite equality = m*n≢0⇒m≢0 quotient - - equalityᵒ : n ≡ m * quotient - equalityᵒ rewrite equality = *-comm quotient m - - quotient-∣ : quotient ∣ n - quotient-∣ = divides m equalityᵒ - - quotient>1 : m < n → 1 < quotient - quotient>1 m1 m) ⟩ - quotient * m ≡⟨ equality ⟨ - n ∎ - where - open ≤-Reasoning - instance _ = quotient≢0 - --- Exports - -open _∣_ using (quotient) public - +quotient≢0 : (m∣n : m ∣ n) → .{{NonZero n}} → NonZero (quotient m∣n) +quotient≢0 m∣n rewrite _∣_.equality m∣n = m*n≢0⇒m≢0 (quotient m∣n) + +equalityᵒ : (m∣n : m ∣ n) → n ≡ m * (quotient m∣n) +equalityᵒ {m = m} m∣n rewrite _∣_.equality m∣n = *-comm (quotient m∣n) m + +quotient-∣ : (m∣n : m ∣ n) → (quotient m∣n) ∣ n +quotient-∣ {m = m} m∣n = divides m (equalityᵒ m∣n) + +quotient>1 : (m∣n : m ∣ n) → m < n → 1 < quotient m∣n +quotient>1 {m} {n} m∣n m1 m) ⟩ + quotient m∣n * m ≡⟨ _∣_.equality m∣n ⟨ + n ∎ + where open ≤-Reasoning; instance _ = quotient≢0 m∣n ------------------------------------------------------------------------ --- Relating _/_ and _∣_.quotient +-- Relating _/_ and quotient n/m≡quotient : (m∣n : m ∣ n) .{{_ : NonZero m}} → n / m ≡ quotient m∣n n/m≡quotient {m = m} (divides-refl q) = m*n/n≡m q m diff --git a/src/Data/Nat/Divisibility/Core.agda b/src/Data/Nat/Divisibility/Core.agda index 92192c7d8d..1b43ab22d6 100644 --- a/src/Data/Nat/Divisibility/Core.agda +++ b/src/Data/Nat/Divisibility/Core.agda @@ -46,6 +46,8 @@ m ∤ n = ¬ (m ∣ n) pattern divides-refl q = divides q refl +open _∣_ using (quotient) public + ------------------------------------------------------------------------ -- Restricted divisor relation From ca0bdc898423c57320ef236d9f378eff16b124de Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 14 Dec 2023 04:36:48 +0000 Subject: [PATCH 82/85] revert commit re `yes/no` --- src/Data/Nat/Divisibility.agda | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index ccc2d3fae2..b1b925703f 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -15,7 +15,7 @@ open import Data.Nat.Properties open import Function.Base using (_∘′_; _$_; flip) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (0ℓ) -import Relation.Nullary.Decidable as Dec +open import Relation.Nullary.Decidable as Dec using (yes; no) open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Binary.Core using (_⇒_) open import Relation.Binary.Bundles using (Preorder; Poset) @@ -117,8 +117,8 @@ m%n≡0⇔n∣m m n = mk⇔ (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n) infix 4 _∣?_ _∣?_ : Decidable _∣_ -zero ∣? zero = Dec.yes (divides-refl 0) -zero ∣? suc m = Dec.no ((λ()) ∘′ ∣-antisym (divides-refl 0)) +zero ∣? zero = yes (divides-refl 0) +zero ∣? suc m = no ((λ()) ∘′ ∣-antisym (divides-refl 0)) n@(suc _) ∣? m = Dec.map (m%n≡0⇔n∣m m n) (m % n ≟ 0) ∣-isPreorder : IsPreorder _≡_ _∣_ From e5006e37877c8059e435125fc17e9f29e9ff5dca Mon Sep 17 00:00:00 2001 From: jamesmckinna Date: Thu, 14 Dec 2023 04:47:45 +0000 Subject: [PATCH 83/85] renamed flipped equality --- CHANGELOG.md | 12 ++++++------ src/Data/Nat/Divisibility.agda | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54487ea12e..a76d349d39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,13 +43,13 @@ Additions to existing modules * In `Data.Nat.Divisibility`: ```agda - quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient + quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient - equalityᵒ : m ∣ n → n ≡ m * quotient - quotient-∣ : m ∣ n → quotient ∣ n - quotient>1 : m ∣ n → m < n → 1 < quotient - quotient-< : m ∣ n → .{{NonTrivial m}} → .{{NonZero n}} → quotient < n - n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient + m|n⇒n≡m*quotient : m ∣ n → n ≡ m * quotient + quotient-∣ : m ∣ n → quotient ∣ n + quotient>1 : m ∣ n → m < n → 1 < quotient + quotient-< : m ∣ n → .{{NonTrivial m}} → .{{NonZero n}} → quotient < n + n/m≡quotient : m ∣ n → .{{_ : NonZero m}} → n / m ≡ quotient m/n≡0⇒m1 : (m∣n : m ∣ n) → m < n → 1 < quotient m∣n quotient>1 {m} {n} m∣n m Date: Thu, 14 Dec 2023 04:50:37 +0000 Subject: [PATCH 84/85] tweaked comment --- src/Data/Digit.agda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Digit.agda b/src/Data/Digit.agda index 4b3ecb22f5..207b0280b7 100644 --- a/src/Data/Digit.agda +++ b/src/Data/Digit.agda @@ -55,7 +55,7 @@ toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) [] aux : {n : ℕ} → Acc _<_ n → List ℕ → List ℕ aux {zero} _ xs = (0 ∷ xs) aux {n@(suc _)} (acc wf) xs with does (0 Date: Thu, 14 Dec 2023 05:03:37 +0000 Subject: [PATCH 85/85] added alias for `equality` --- CHANGELOG.md | 1 + src/Data/Nat/Divisibility.agda | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a76d349d39..c0d795f443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Additions to existing modules ```agda quotient≢0 : m ∣ n → .{{NonZero n}} → NonZero quotient + m|n⇒n≡quotient*m : m ∣ n → n ≡ quotient * m m|n⇒n≡m*quotient : m ∣ n → n ≡ m * quotient quotient-∣ : m ∣ n → quotient ∣ n quotient>1 : m ∣ n → m < n → 1 < quotient diff --git a/src/Data/Nat/Divisibility.agda b/src/Data/Nat/Divisibility.agda index 5933d6ea6f..abac2915a7 100644 --- a/src/Data/Nat/Divisibility.agda +++ b/src/Data/Nat/Divisibility.agda @@ -42,6 +42,9 @@ open import Data.Nat.Divisibility.Core public hiding (*-pres-∣) quotient≢0 : (m∣n : m ∣ n) → .{{NonZero n}} → NonZero (quotient m∣n) quotient≢0 m∣n rewrite _∣_.equality m∣n = m*n≢0⇒m≢0 (quotient m∣n) +m|n⇒n≡quotient*m : (m∣n : m ∣ n) → n ≡ (quotient m∣n) * m +m|n⇒n≡quotient*m m∣n = _∣_.equality m∣n + m|n⇒n≡m*quotient : (m∣n : m ∣ n) → n ≡ m * (quotient m∣n) m|n⇒n≡m*quotient {m = m} m∣n rewrite _∣_.equality m∣n = *-comm (quotient m∣n) m