Skip to content

Commit 47b458c

Browse files
MatthewDaggittjamesmckinna
authored andcommitted
Fix #2216 by making divisibility definitions records (#2217)
* Fix #2216 by making divisibility definitions records * remove spurious/ambiguous `import` --------- Co-authored-by: jamesmckinna <[email protected]>
1 parent b6ac7e0 commit 47b458c

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@ Non-backwards compatible changes
10481048

10491049
* In `Algebra.Core` the operations `Opₗ` and `Opᵣ` have moved to `Algebra.Module.Core`.
10501050

1051+
* In `Algebra.Definitions.RawMagma.Divisibility` the definitions for `_∣ˡ_` and `_∣ʳ_`
1052+
have been changed from being defined as raw products to being defined as records. However,
1053+
the record constructors are called `_,_` so the changes required are minimal.
1054+
10511055
* In `Codata.Guarded.Stream` the following functions have been modified to have simpler definitions:
10521056
* `cycle`
10531057
* `interleave⁺`

src/Algebra/Definitions/RawMagma.agda

+19-6
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,31 @@ open RawMagma M renaming (Carrier to A)
2727

2828
infix 5 _∣ˡ_ _∤ˡ_ _∣ʳ_ _∤ʳ_ _∣_ _∤_
2929

30-
-- Divisibility from the left
31-
32-
_∣ˡ_ : Rel A (a ⊔ ℓ)
33-
x ∣ˡ y =λ q (x ∙ q) ≈ y
30+
-- Divisibility from the left.
31+
--
32+
-- This and, the definition of right divisibility below, are defined as
33+
-- records rather than in terms of the base product type in order to
34+
-- make the use of pattern synonyms more ergonomic (see #2216 for
35+
-- further details). The record field names are not designed to be
36+
-- used explicitly and indeed aren't re-exported publicly by
37+
-- `Algebra.X.Properties.Divisibility` modules.
38+
39+
record _∣ˡ_ (x y : A) : Set (a ⊔ ℓ) where
40+
constructor _,_
41+
field
42+
quotient : A
43+
equality : x ∙ quotient ≈ y
3444

3545
_∤ˡ_ : Rel A (a ⊔ ℓ)
3646
x ∤ˡ y = ¬ x ∣ˡ y
3747

3848
-- Divisibility from the right
3949

40-
_∣ʳ_ : Rel A (a ⊔ ℓ)
41-
x ∣ʳ y =λ q (q ∙ x) ≈ y
50+
record _∣ʳ_ (x y : A) : Set (a ⊔ ℓ) where
51+
constructor _,_
52+
field
53+
quotient : A
54+
equality : quotient ∙ x ≈ y
4255

4356
_∤ʳ_ : Rel A (a ⊔ ℓ)
4457
x ∤ʳ y = ¬ x ∣ʳ y

src/Algebra/Properties/Magma/Divisibility.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ open Magma M
1818
-- Re-export divisibility relations publicly
1919

2020
open import Algebra.Definitions.RawMagma rawMagma public
21-
using (_∣_; _∤_; _∣∣_; _∤∤_; _∣ˡ_; _∤ˡ_; _∣ʳ_; _∤ʳ_)
21+
using (_∣_; _∤_; _∣∣_; _∤∤_; _∣ˡ_; _∤ˡ_; _∣ʳ_; _∤ʳ_; _,_)
2222

2323
------------------------------------------------------------------------
2424
-- Properties of divisibility

src/Data/Nat/Base.agda

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
module Data.Nat.Base where
1313

1414
open import Algebra.Bundles.Raw using (RawMagma; RawMonoid; RawNearSemiring; RawSemiring)
15-
open import Algebra.Definitions.RawMagma using (_∣ˡ_)
15+
open import Algebra.Definitions.RawMagma using (_∣ˡ_; _,_)
1616
open import Data.Bool.Base using (Bool; true; false; T; not)
1717
open import Data.Parity.Base using (Parity; 0ℙ; 1ℙ)
18-
open import Data.Product.Base using (_,_)
1918
open import Level using (0ℓ)
2019
open import Relation.Binary.Core using (Rel)
2120
open import Relation.Binary.PropositionalEquality.Core

0 commit comments

Comments
 (0)