Skip to content

Commit eeb0690

Browse files
gallaisMatthewDaggitt
authored andcommitted
[ re #192 ] Make _|_ a record (#196)
1 parent 6c45841 commit eeb0690

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Non-backwards compatible changes
4949
* Moved `Data.Vec.Equality` to `Data.Vec.Relation.Equality` (see "Deprecated
5050
features" section for explanation)
5151

52+
* Changed Data.Nat.Divisibility's `_|_` from data to record. As a consequence,
53+
the two parameters are not implicit arguments of the constructor anymore (but
54+
such values can be destructed using a let-binding rather than a with-clause).
55+
5256
Deprecated features
5357
-------------------
5458

src/Data/Nat/Divisibility.agda

+8-7
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ open import Function
3030

3131
infix 4 _∣_ _∤_
3232

33-
data _∣_ : Set where
34-
divides : {m n : ℕ} (q : ℕ) (eq : n ≡ q * m) m ∣ n
33+
record _∣_ (m n : ℕ) : Set where
34+
constructor divides
35+
field quotient :
36+
equality : n ≡ quotient * m
3537

3638
_∤_ : Rel ℕ _
3739
m ∤ n = ¬ (m ∣ n)
@@ -61,11 +63,10 @@ quotient (divides q _) = q
6163
divides (q * p) (sym (*-assoc q p _))
6264

6365
∣-antisym : Antisymmetric _≡_ _∣_
64-
∣-antisym (divides {n = zero} _ _) (divides q refl) = *-comm q 0
65-
∣-antisym (divides p eq) (divides {n = zero} _ _) =
66-
trans (*-comm 0 p) (sym eq)
67-
∣-antisym (divides {n = suc _} p eq₁) (divides {n = suc _} q eq₂) =
68-
≤-antisym (∣⇒≤ (divides p eq₁)) (∣⇒≤ (divides q eq₂))
66+
∣-antisym {m} {0} _ (divides q eq) = trans eq (*-comm q 0)
67+
∣-antisym {0} {n} (divides p eq) _ = sym (trans eq (*-comm p 0))
68+
∣-antisym {suc m} {suc n} (divides p eq₁) (divides q eq₂) =
69+
≤-antisym (∣⇒≤ (divides p eq₁)) (∣⇒≤ (divides q eq₂))
6970

7071
∣-isPreorder : IsPreorder _≡_ _∣_
7172
∣-isPreorder = record

0 commit comments

Comments
 (0)