Skip to content

Commit c0b6044

Browse files
Make Cancellative be more consistent in whole library (#1823)
1 parent 5c27f90 commit c0b6044

19 files changed

+111
-73
lines changed

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,38 @@ Non-backwards compatible changes
366366
3. Finally, if the above approaches are not viable then you may be forced to explicitly
367367
use `cong` combined with a lemma that proves the old reduction behaviour.
368368
369+
### Change to the definition of `LeftCancellative` and `RightCancellative`
370+
371+
* The definitions of the types for cancellativity in `Algebra.Definitions` previously
372+
made some of their arguments implicit. This was under the assumption that the operators were
373+
defined by pattern matching on the left argument so that Agda could always infer the
374+
argument on the RHS.
375+
376+
* Although many of the operators defined in the library follow this convention, this is not
377+
always true and cannot be assumed in user's code.
378+
379+
* Therefore the definitions have been changed as follows to make all their arguments explicit:
380+
- `LeftCancellative _•_`
381+
- From: `∀ x {y z} → (x • y) ≈ (x • z) → y ≈ z`
382+
- To: `∀ x y z → (x • y) ≈ (x • z) → y ≈ z`
383+
384+
- `RightCancellative _•_`
385+
- From: `∀ {x} y z → (y • x) ≈ (z • x) → y ≈ z`
386+
- To: `∀ x y z → (y • x) ≈ (z • x) → y ≈ z`
387+
388+
- `AlmostLeftCancellative e _•_`
389+
- From: `∀ {x} y z → ¬ x ≈ e → (x • y) ≈ (x • z) → y ≈ z`
390+
- To: `∀ x y z → ¬ x ≈ e → (x • y) ≈ (x • z) → y ≈ z`
391+
392+
- `AlmostRightCancellative e _•_`
393+
- From: `∀ {x} y z → ¬ x ≈ e → (y • x) ≈ (z • x) → y ≈ z`
394+
- To: `∀ x y z → ¬ x ≈ e → (y • x) ≈ (z • x) → y ≈ z`
395+
396+
* Correspondingly some proofs of the above types will need additional arguments passed explicitly.
397+
Instances can easily be fixed by adding additional underscores, e.g.
398+
- `∙-cancelˡ x` to `∙-cancelˡ x _ _`
399+
- `∙-cancelʳ y z` to `∙-cancelʳ _ y z`
400+
369401
### Change in the definition of `Prime`
370402
371403
* The definition of `Prime` in `Data.Nat.Primality` was:

src/Algebra/Consequences/Setoid.agda

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ open import Algebra.Consequences.Base public
3434
module _ {_•_ : Op₂ A} (comm : Commutative _•_) where
3535

3636
comm+cancelˡ⇒cancelʳ : LeftCancellative _•_ RightCancellative _•_
37-
comm+cancelˡ⇒cancelʳ cancelˡ {x} y z eq = cancelˡ x $ begin
37+
comm+cancelˡ⇒cancelʳ cancelˡ x y z eq = cancelˡ x y z $ begin
3838
x • y ≈⟨ comm x y ⟩
3939
y • x ≈⟨ eq ⟩
4040
z • x ≈⟨ comm z x ⟩
4141
x • z ∎
4242

4343
comm+cancelʳ⇒cancelˡ : RightCancellative _•_ LeftCancellative _•_
44-
comm+cancelʳ⇒cancelˡ cancelʳ x {y} {z} eq = cancelʳ y z $ begin
44+
comm+cancelʳ⇒cancelˡ cancelʳ x y z eq = cancelʳ x y z $ begin
4545
y • x ≈⟨ comm y x ⟩
4646
x • y ≈⟨ eq ⟩
4747
x • z ≈⟨ comm x z ⟩
@@ -90,17 +90,17 @@ module _ {_•_ : Op₂ A} (comm : Commutative _•_) {e : A} where
9090

9191
comm+almostCancelˡ⇒almostCancelʳ : AlmostLeftCancellative e _•_
9292
AlmostRightCancellative e _•_
93-
comm+almostCancelˡ⇒almostCancelʳ cancelˡ-nonZero {x} y z x≉e yx≈zx =
94-
cancelˡ-nonZero y z x≉e $ begin
93+
comm+almostCancelˡ⇒almostCancelʳ cancelˡ-nonZero x y z x≉e yx≈zx =
94+
cancelˡ-nonZero x y z x≉e $ begin
9595
x • y ≈⟨ comm x y ⟩
9696
y • x ≈⟨ yx≈zx ⟩
9797
z • x ≈⟨ comm z x ⟩
9898
x • z ∎
9999

100100
comm+almostCancelʳ⇒almostCancelˡ : AlmostRightCancellative e _•_
101101
AlmostLeftCancellative e _•_
102-
comm+almostCancelʳ⇒almostCancelˡ cancelʳ-nonZero {x} y z x≉e xy≈xz =
103-
cancelʳ-nonZero y z x≉e $ begin
102+
comm+almostCancelʳ⇒almostCancelˡ cancelʳ-nonZero x y z x≉e xy≈xz =
103+
cancelʳ-nonZero x y z x≉e $ begin
104104
y • x ≈⟨ comm y x ⟩
105105
x • y ≈⟨ xy≈xz ⟩
106106
x • z ≈⟨ comm x z ⟩

src/Algebra/Definitions.agda

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
-- The contents of this module should be accessed via `Algebra`, unless
88
-- you want to parameterise it via the equality relation.
99

10+
-- Note that very few of the element arguments are made implicit here,
11+
-- as we do not assume that the Agda can infer either the right or left
12+
-- argument of the binary operators. This is despite the fact that the
13+
-- library defines most of its concrete operators (e.g. in
14+
-- `Data.Nat.Base`) as being left-biased.
15+
1016
{-# OPTIONS --without-K --safe #-}
1117

1218
open import Relation.Binary.Core
@@ -124,19 +130,19 @@ Involutive : Op₁ A → Set _
124130
Involutive f = x f (f x) ≈ x
125131

126132
LeftCancellative : Op₂ A Set _
127-
LeftCancellative _•_ = x {y z} (x • y) ≈ (x • z) y ≈ z
133+
LeftCancellative _•_ = x y z (x • y) ≈ (x • z) y ≈ z
128134

129135
RightCancellative : Op₂ A Set _
130-
RightCancellative _•_ = {x} y z (y • x) ≈ (z • x) y ≈ z
136+
RightCancellative _•_ = x y z (y • x) ≈ (z • x) y ≈ z
131137

132138
Cancellative : Op₂ A Set _
133139
Cancellative _•_ = (LeftCancellative _•_) × (RightCancellative _•_)
134140

135141
AlmostLeftCancellative : A Op₂ A Set _
136-
AlmostLeftCancellative e _•_ = {x} y z ¬ x ≈ e (x • y) ≈ (x • z) y ≈ z
142+
AlmostLeftCancellative e _•_ = x y z ¬ x ≈ e (x • y) ≈ (x • z) y ≈ z
137143

138144
AlmostRightCancellative : A Op₂ A Set _
139-
AlmostRightCancellative e _•_ = {x} y z ¬ x ≈ e (y • x) ≈ (z • x) y ≈ z
145+
AlmostRightCancellative e _•_ = x y z ¬ x ≈ e (y • x) ≈ (z • x) y ≈ z
140146

141147
AlmostCancellative : A Op₂ A Set _
142148
AlmostCancellative e _•_ = AlmostLeftCancellative e _•_ × AlmostRightCancellative e _•_

src/Algebra/Morphism/MagmaMonomorphism.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ module _ (◦-isMagma : IsMagma _≈₂_ _◦_) where
7979
⟦ y ⟧ ∎))
8080

8181
cancelˡ : LeftCancellative _≈₂_ _◦_ LeftCancellative _≈₁_ _∙_
82-
cancelˡ cancelˡ x {y} {z} x∙y≈x∙z = injective (cancelˡ ⟦ x ⟧ (begin
82+
cancelˡ cancelˡ x y z x∙y≈x∙z = injective (cancelˡ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ (begin
8383
⟦ x ⟧ ◦ ⟦ y ⟧ ≈˘⟨ homo x y ⟩
8484
⟦ x ∙ y ⟧ ≈⟨ ⟦⟧-cong x∙y≈x∙z ⟩
8585
⟦ x ∙ z ⟧ ≈⟨ homo x z ⟩
8686
⟦ x ⟧ ◦ ⟦ z ⟧ ∎))
8787

8888
cancelʳ : RightCancellative _≈₂_ _◦_ RightCancellative _≈₁_ _∙_
89-
cancelʳ cancelʳ {x} y z y∙x≈z∙x = injective (cancelʳ ⟦ y ⟧ ⟦ z ⟧ (begin
89+
cancelʳ cancelʳ x y z y∙x≈z∙x = injective (cancelʳ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ (begin
9090
⟦ y ⟧ ◦ ⟦ x ⟧ ≈˘⟨ homo y x ⟩
9191
⟦ y ∙ x ⟧ ≈⟨ ⟦⟧-cong y∙x≈z∙x ⟩
9292
⟦ z ∙ x ⟧ ≈⟨ homo z x ⟩

src/Algebra/Properties/CancellativeCommutativeSemiring.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ xy≈0⇒x≈0∨y≈0 _≟_ {x} {y} xy≈0 with x ≟ 0# | y ≟ 0#
3131
... | no x≉0 | no y≉0 = contradiction y≈0 y≉0
3232
where
3333
xy≈x*0 = trans xy≈0 (sym (zeroʳ x))
34-
y≈0 = *-cancelˡ-nonZero y 0# x≉0 xy≈x*0
34+
y≈0 = *-cancelˡ-nonZero _ y 0# x≉0 xy≈x*0
3535

3636
x≉0∧y≉0⇒xy≉0 : Decidable _≈_ {x y} x ≉ 0# y ≉ 0# x * y ≉ 0#
3737
x≉0∧y≉0⇒xy≉0 _≟_ x≉0 y≉0 xy≈0 with xy≈0⇒x≈0∨y≈0 _≟_ xy≈0

src/Algebra/Properties/Group.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ private
3939
x ⁻¹ ∙ (x ∙ y) ∎
4040

4141
∙-cancelˡ : LeftCancellative _∙_
42-
∙-cancelˡ x {y} {z} eq = begin
42+
∙-cancelˡ x y z eq = begin
4343
y ≈⟨ right-helper x y ⟩
4444
x ⁻¹ ∙ (x ∙ y) ≈⟨ ∙-congˡ eq ⟩
4545
x ⁻¹ ∙ (x ∙ z) ≈˘⟨ right-helper x z ⟩
4646
z ∎
4747

4848
∙-cancelʳ : RightCancellative _∙_
49-
∙-cancelʳ {x} y z eq = begin
49+
∙-cancelʳ x y z eq = begin
5050
y ≈⟨ left-helper y x ⟩
5151
y ∙ x ∙ x ⁻¹ ≈⟨ ∙-congʳ eq ⟩
5252
z ∙ x ∙ x ⁻¹ ≈˘⟨ left-helper z x ⟩
@@ -63,14 +63,14 @@ private
6363
x ∎
6464

6565
⁻¹-injective : {x y} x ⁻¹ ≈ y ⁻¹ x ≈ y
66-
⁻¹-injective {x} {y} eq = ∙-cancelʳ x y ( begin
66+
⁻¹-injective {x} {y} eq = ∙-cancelʳ _ _ _ ( begin
6767
x ∙ x ⁻¹ ≈⟨ inverseʳ x ⟩
6868
ε ≈˘⟨ inverseʳ y ⟩
6969
y ∙ y ⁻¹ ≈˘⟨ ∙-congˡ eq ⟩
7070
y ∙ x ⁻¹ ∎ )
7171

7272
⁻¹-anti-homo-∙ : x y (x ∙ y) ⁻¹ ≈ y ⁻¹ ∙ x ⁻¹
73-
⁻¹-anti-homo-∙ x y = ∙-cancelˡ _ ( begin
73+
⁻¹-anti-homo-∙ x y = ∙-cancelˡ _ _ _ ( begin
7474
x ∙ y ∙ (x ∙ y) ⁻¹ ≈⟨ inverseʳ _ ⟩
7575
ε ≈˘⟨ inverseʳ _ ⟩
7676
x ∙ x ⁻¹ ≈⟨ ∙-congʳ (left-helper x y) ⟩

src/Algebra/Properties/Quasigroup.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ open import Relation.Binary.Reasoning.Setoid setoid
1616
open import Data.Product
1717

1818
cancelˡ : LeftCancellative _∙_
19-
cancelˡ x {y} {z} eq = begin
19+
cancelˡ x y z eq = begin
2020
y ≈⟨ sym( leftDividesʳ x y) ⟩
2121
x \\ (x ∙ y) ≈⟨ \\-congˡ eq ⟩
2222
x \\ (x ∙ z) ≈⟨ leftDividesʳ x z ⟩
2323
z ∎
2424

2525
cancelʳ : RightCancellative _∙_
26-
cancelʳ {x} y z eq = begin
26+
cancelʳ x y z eq = begin
2727
y ≈⟨ sym( rightDividesʳ x y) ⟩
2828
(y ∙ x) // x ≈⟨ //-congʳ eq ⟩
2929
(z ∙ x) // x ≈⟨ rightDividesʳ x z ⟩

src/Data/Fin/Properties.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ with <-cmp i k
654654
combine-injectiveʳ : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n)
655655
combine i j ≡ combine k l j ≡ l
656656
combine-injectiveʳ {m} {n} i j k l cᵢⱼ≡cₖₗ with combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ
657-
... | refl = toℕ-injective (ℕₚ.+-cancelˡ-≡ (n ℕ.* toℕ i) (begin
657+
... | refl = toℕ-injective (ℕₚ.+-cancelˡ-≡ (n ℕ.* toℕ i) _ _ (begin
658658
n ℕ.* toℕ i ℕ.+ toℕ j ≡˘⟨ toℕ-combine i j ⟩
659659
toℕ (combine i j) ≡⟨ cong toℕ cᵢⱼ≡cₖₗ ⟩
660660
toℕ (combine i l) ≡⟨ toℕ-combine i l ⟩

src/Data/Integer/Properties.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -1599,8 +1599,8 @@ abs-*-commute i j = abs-◃ _ _
15991599
*-cancelʳ-≡ : i j k .{{_ : NonZero k}} i * k ≡ j * k i ≡ j
16001600
*-cancelʳ-≡ i j k eq with sign-cong′ eq
16011601
... | inj₁ s[ik]≡s[jk] = ◃-cong
1602-
(𝕊ₚ.*-cancelʳ-≡ {sign k} (sign i) (sign j) s[ik]≡s[jk])
1603-
(ℕ.*-cancelʳ-≡ ∣ i ∣ ∣ j ∣ (abs-cong eq))
1602+
(𝕊ₚ.*-cancelʳ-≡ (sign k) (sign i) (sign j) s[ik]≡s[jk])
1603+
(ℕ.*-cancelʳ-≡ ∣ i ∣ ∣ j ∣ _ (abs-cong eq))
16041604
... | inj₂ (∣ik∣≡0 , ∣jk∣≡0) = trans
16051605
(∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣ik∣≡0))
16061606
(sym (∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣jk∣≡0)))
@@ -1785,10 +1785,10 @@ neg-distribʳ-* i j = begin
17851785
*-monoʳ-<-pos i {j} {k} rewrite *-comm j i | *-comm k i = *-monoˡ-<-pos i
17861786

17871787
*-cancelˡ-<-nonNeg : k .{{_ : NonNegative k}} k * i < k * j i < j
1788-
*-cancelˡ-<-nonNeg {+ i} {+ j} (+ n) leq = +<+ (ℕ.*-cancelˡ-< n (+◃-cancel-< leq))
1788+
*-cancelˡ-<-nonNeg {+ i} {+ j} (+ n) leq = +<+ (ℕ.*-cancelˡ-< n _ _ (+◃-cancel-< leq))
17891789
*-cancelˡ-<-nonNeg {+ i} { -[1+ j ]} (+ n) leq = contradiction leq +◃≮-◃
17901790
*-cancelˡ-<-nonNeg { -[1+ i ]} {+ j} (+ n)leq = -<+
1791-
*-cancelˡ-<-nonNeg { -[1+ i ]} { -[1+ j ]} (+ n) leq = -<- (ℕ.≤-pred (ℕ.*-cancelˡ-< n (neg◃-cancel-< leq)))
1791+
*-cancelˡ-<-nonNeg { -[1+ i ]} { -[1+ j ]} (+ n) leq = -<- (ℕ.≤-pred (ℕ.*-cancelˡ-< n _ _ (neg◃-cancel-< leq)))
17921792

17931793
*-cancelʳ-<-nonNeg : k .{{_ : NonNegative k}} i * k < j * k i < j
17941794
*-cancelʳ-<-nonNeg {i} {j} k rewrite *-comm i k | *-comm j k = *-cancelˡ-<-nonNeg k

src/Data/List/Properties.agda

+9-9
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,18 @@ module _ {A : Set a} where
183183
++-identityˡ-unique {xs = x ∷ xs} (y ∷ [] ) eq | ()
184184
++-identityˡ-unique {xs = x ∷ xs} (y ∷ _ ∷ _) eq | ()
185185

186-
++-cancelˡ : xs {ys zs : List A} xs ++ ys ≡ xs ++ zs ys ≡ zs
187-
++-cancelˡ [] ys≡zs = ys≡zs
188-
++-cancelˡ (x ∷ xs) x∷xs++ys≡x∷xs++zs = ++-cancelˡ xs (∷-injectiveʳ x∷xs++ys≡x∷xs++zs)
186+
++-cancelˡ : LeftCancellative _++_
187+
++-cancelˡ [] _ _ ys≡zs = ys≡zs
188+
++-cancelˡ (x ∷ xs) _ _ x∷xs++ys≡x∷xs++zs = ++-cancelˡ xs _ _ (∷-injectiveʳ x∷xs++ys≡x∷xs++zs)
189189

190-
++-cancelʳ : {xs : List A} ys zs ys ++ xs ≡ zs ++ xs ys ≡ zs
191-
++-cancelʳ {_} [] [] _ = refl
192-
++-cancelʳ {xs} [] (z ∷ zs) eq =
190+
++-cancelʳ : RightCancellative _++_
191+
++-cancelʳ _ [] [] _ = refl
192+
++-cancelʳ xs [] (z ∷ zs) eq =
193193
contradiction (trans (cong length eq) (length-++ (z ∷ zs))) (m≢1+n+m (length xs))
194-
++-cancelʳ {xs} (y ∷ ys) [] eq =
194+
++-cancelʳ xs (y ∷ ys) [] eq =
195195
contradiction (trans (sym (length-++ (y ∷ ys))) (cong length eq)) (m≢1+n+m (length xs) ∘ sym)
196-
++-cancelʳ {_} (y ∷ ys) (z ∷ zs) eq =
197-
cong₂ _∷_ (∷-injectiveˡ eq) (++-cancelʳ ys zs (∷-injectiveʳ eq))
196+
++-cancelʳ _ (y ∷ ys) (z ∷ zs) eq =
197+
cong₂ _∷_ (∷-injectiveˡ eq) (++-cancelʳ _ ys zs (∷-injectiveʳ eq))
198198

199199
++-cancel : Cancellative _++_
200200
++-cancel = ++-cancelˡ , ++-cancelʳ

src/Data/Nat/Binary/Properties.agda

+6-6
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ toℕ-injective : Injective _≡_ _≡_ toℕ
179179
toℕ-injective {zero} {zero} _ = refl
180180
toℕ-injective {2[1+ x ]} {2[1+ y ]} 2[1+xN]≡2[1+yN] = cong 2[1+_] x≡y
181181
where
182-
1+xN≡1+yN = ℕₚ.*-cancelˡ-≡ {ℕ.suc _} {ℕ.suc _} 2 2[1+xN]≡2[1+yN]
182+
1+xN≡1+yN = ℕₚ.*-cancelˡ-≡ (ℕ.suc _) (ℕ.suc _) 2 2[1+xN]≡2[1+yN]
183183
xN≡yN = cong ℕ.pred 1+xN≡1+yN
184184
x≡y = toℕ-injective xN≡yN
185185

@@ -192,7 +192,7 @@ toℕ-injective {1+[2 x ]} {2[1+ y ]} 1+2xN≡2[1+yN] =
192192
toℕ-injective {1+[2 x ]} {1+[2 y ]} 1+2xN≡1+2yN = cong 1+[2_] x≡y
193193
where
194194
2xN≡2yN = cong ℕ.pred 1+2xN≡1+2yN
195-
xN≡yN = ℕₚ.*-cancelˡ-≡ 2 2xN≡2yN
195+
xN≡yN = ℕₚ.*-cancelˡ-≡ _ _ 2 2xN≡2yN
196196
x≡y = toℕ-injective xN≡yN
197197

198198
toℕ-surjective : Surjective _≡_ toℕ
@@ -302,17 +302,17 @@ toℕ-cancel-< : ∀ {x y} → toℕ x ℕ.< toℕ y → x < y
302302
toℕ-cancel-< {zero} {2[1+ y ]} x<y = 0<even
303303
toℕ-cancel-< {zero} {1+[2 y ]} x<y = 0<odd
304304
toℕ-cancel-< {2[1+ x ]} {2[1+ y ]} x<y =
305-
even<even (toℕ-cancel-< (ℕ.≤-pred (ℕₚ.*-cancelˡ-< 2 x<y)))
305+
even<even (toℕ-cancel-< (ℕ.≤-pred (ℕₚ.*-cancelˡ-< 2 _ _ x<y)))
306306
toℕ-cancel-< {2[1+ x ]} {1+[2 y ]} x<y
307307
rewrite ℕₚ.*-distribˡ-+ 2 1 (toℕ x) =
308-
even<odd (toℕ-cancel-< (ℕₚ.*-cancelˡ-< 2 (ℕₚ.≤-trans (s≤s (ℕₚ.n≤1+n _)) (ℕₚ.≤-pred x<y))))
308+
even<odd (toℕ-cancel-< (ℕₚ.*-cancelˡ-< 2 _ _ (ℕₚ.≤-trans (s≤s (ℕₚ.n≤1+n _)) (ℕₚ.≤-pred x<y))))
309309
toℕ-cancel-< {1+[2 x ]} {2[1+ y ]} x<y with toℕ x ℕₚ.≟ toℕ y
310310
... | yes x≡y = odd<even (inj₂ (toℕ-injective x≡y))
311311
... | no x≢y
312312
rewrite ℕₚ.+-suc (toℕ y) (toℕ y ℕ.+ 0) =
313-
odd<even (inj₁ (toℕ-cancel-< (ℕₚ.≤∧≢⇒< (ℕₚ.*-cancelˡ-≤ 2 (ℕₚ.+-cancelˡ-≤ 2 x<y)) x≢y)))
313+
odd<even (inj₁ (toℕ-cancel-< (ℕₚ.≤∧≢⇒< (ℕₚ.*-cancelˡ-≤ 2 (ℕₚ.+-cancelˡ-≤ 2 _ _ x<y)) x≢y)))
314314
toℕ-cancel-< {1+[2 x ]} {1+[2 y ]} x<y =
315-
odd<odd (toℕ-cancel-< (ℕₚ.*-cancelˡ-< 2 (ℕ.≤-pred x<y)))
315+
odd<odd (toℕ-cancel-< (ℕₚ.*-cancelˡ-< 2 _ _ (ℕ.≤-pred x<y)))
316316

317317
fromℕ-cancel-< : {x y} fromℕ x < fromℕ y x ℕ.< y
318318
fromℕ-cancel-< = subst₂ ℕ._<_ (toℕ-fromℕ _) (toℕ-fromℕ _) ∘ toℕ-mono-<

src/Data/Nat/Binary/Subtraction.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ x<y⇒y∸x>0 {x} {y} = toℕ-cancel-< ∘ subst (ℕ._> 0) (sym (toℕ-homo-∸
146146
where open ≡-Reasoning
147147

148148
x+y∸y≡x : x y (x + y) ∸ y ≡ x
149-
x+y∸y≡x x y = +-cancelʳ-≡ _ x ([x∸y]+y≡x (x≤y+x y x))
149+
x+y∸y≡x x y = +-cancelʳ-≡ _ _ x ([x∸y]+y≡x (x≤y+x y x))
150150

151151
[x+y]∸x≡y : x y (x + y) ∸ x ≡ y
152152
[x+y]∸x≡y x y = trans (cong (_∸ x) (+-comm x y)) (x+y∸y≡x y x)

src/Data/Nat/DivMod.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin
222222
m * n ∎)
223223

224224
m/n<m : m n .{{_ : NonZero m}} .{{_ : NonZero n}} n ≥ 2 m / n < m
225-
m/n<m m n n≥2 = *-cancelʳ-< (m / n) m (begin-strict
225+
m/n<m m n n≥2 = *-cancelʳ-< _ (m / n) m (begin-strict
226226
(m / n) * n ≤⟨ m/n*n≤m m n ⟩
227227
m <⟨ m<m*n m n n≥2 ⟩
228228
m * n ∎)
@@ -390,7 +390,7 @@ m/n/o≡m/[n*o] m n o = begin-equality
390390

391391
/-*-interchange : {m n o p} .{{_ : NonZero o}} .{{_ : NonZero p}} .{{_ : NonZero (o * p)}}
392392
o ∣ m p ∣ n (m * n) / (o * p) ≡ (m / o) * (n / p)
393-
/-*-interchange {m} {n} {o@(suc _)} {p@(suc _)} o∣m p∣n = *-cancelˡ-≡ (o * p) (begin-equality
393+
/-*-interchange {m} {n} {o@(suc _)} {p@(suc _)} o∣m p∣n = *-cancelˡ-≡ _ _ (o * p) (begin-equality
394394
(o * p) * ((m * n) / (o * p)) ≡⟨ m*[n/m]≡n (*-pres-∣ o∣m p∣n) ⟩
395395
m * n ≡˘⟨ cong₂ _*_ (m*[n/m]≡n o∣m) (m*[n/m]≡n p∣n) ⟩
396396
(o * (m / o)) * (p * (n / p)) ≡⟨ [m*n]*[o*p]≡[m*o]*[n*p] o (m / o) p (n / p) ⟩

src/Data/Nat/DivMod/Core.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ a*n[divₕ]n≡a acc (suc a) n = begin-equality
244244
acc + divₕ 0 (k + j) n j ≡⟨ cong (acc +_) (divₕ-offsetEq _ n j _ (m≤n+m j k) ≤-refl case) ⟩
245245
acc + divₕ 0 (k + j) n (k + j) ∎
246246
where
247-
case = inj₂′ (refl , +-cancelˡ-≤ (suc k) leq , m≤n+m j k)
247+
case = inj₂′ (refl , +-cancelˡ-≤ (suc k) _ _ leq , m≤n+m j k)
248248

249249
divₕ-mono-≤ : {acc} k {m n o p} m ≤ n p ≤ o divₕ acc (k + o) m o ≤ divₕ acc (k + p) n p
250250
divₕ-mono-≤ {acc} k {0} {n} {_} {p} z≤n p≤o = acc≤divₕ[acc] (k + p) n p

src/Data/Nat/Divisibility.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m
199199

200200
*-cancelˡ-∣ : {i j} k .{{_ : NonZero k}} k * i ∣ k * j i ∣ j
201201
*-cancelˡ-∣ {i} {j} k@(suc _) (divides q eq) =
202-
divides q $ *-cancelʳ-≡ j (q * i) $ begin-equality
202+
divides q $ *-cancelʳ-≡ j (q * i) _ $ begin-equality
203203
j * k ≡⟨ *-comm j k ⟩
204204
k * j ≡⟨ eq ⟩
205205
q * (k * i) ≡⟨ cong (q *_) (*-comm k i) ⟩

src/Data/Nat/GCD/Lemmas.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ lem₁₀ : ∀ {a′} b c {d} e f → let a = suc a′ in
150150
lem₁₀ {a′} b c {d} e f eq =
151151
m*n≡1⇒n≡1 (e * f ∸ b * c) d
152152
(lem₀ (e * f) (b * c) d 1
153-
(*-cancelʳ-≡ (e * f * d) (b * c * d + 1) (begin
153+
(*-cancelʳ-≡ (e * f * d) (b * c * d + 1) _ (begin
154154
e * f * d * a ≡⟨ solve 4 (λ e f d a e :* f :* d :* a
155155
:= e :* (f :* d :* a))
156156
refl e f d a ⟩

0 commit comments

Comments
 (0)