Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ Additions to existing modules

* In `Data.Nat.Divisibility`:
```agda
∣m+n∣n⇒∣m : d ∣ m + n → d ∣ n → d ∣ m
m∣n⇒m^o∣n^o : ∀ o → m ∣ n → m ^ o ∣ n ^ o
n≤o⇒m^n∣m^o : ∀ m → .(n ≤ o) → m ^ n ∣ m ^ o
```
Expand Down
12 changes: 10 additions & 2 deletions src/Data/Nat/Divisibility.agda
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,21 @@ n∣n = ∣-refl
∣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-refl q) =
divides (p ∸ q) $ begin-equality
n ≡⟨ m+n∸n≡m n m ⟨
n + m ∸ m ≡⟨ cong (_∸ m) (+-comm n m) ⟩
n ≡⟨ m+n∸m≡n m n ⟨
m + n ∸ m ≡⟨ cong (_∸ m) m+n≡p*d ⟩
p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨
(p ∸ q) * d ∎
where open ∣-Reasoning

∣m+n∣n⇒∣m : d ∣ m + n → d ∣ n → d ∣ m
∣m+n∣n⇒∣m {d} {m} {n} (divides p m*n≡p*d) (divides-refl q) =
divides (p ∸ q) $ begin-equality
m ≡⟨ m+n∸n≡m m n ⟨
m + n ∸ n ≡⟨ cong (_∸ q * d) m*n≡p*d ⟩
p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨
(p ∸ q) * d ∎
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the other proof, I presume that this is a typo on the variable name.

Suggested change
∣m+n∣n⇒∣m {d} {m} {n} (divides p m*n≡p*d) (divides-refl q) =
divides (p ∸ q) $ begin-equality
m ≡⟨ m+n∸n≡m m n ⟨
m + n ∸ n ≡⟨ cong (_∸ q * d) m*n≡p*d ⟩
p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨
(p ∸ q) * d ∎
∣m+n∣n⇒∣m {d} {m} {n} (divides p m+n≡p*d) (divides-refl q) =
divides (p ∸ q) $ begin-equality
m ≡⟨ m+n∸n≡m m n ⟨
m + n ∸ n ≡⟨ cong (_∸ q * d) m+n≡p*d ⟩
p * d ∸ q * d ≡⟨ *-distribʳ-∸ d p q ⟨
(p ∸ q) * d ∎

Also, why prove it by going back to the core argument instead of invoking ∣m+n∣m⇒∣n and
the fact _+_ is commutative?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why prove it by going back to the core argument instead of invoking ∣m+n∣m⇒∣n and
the fact _+_ is commutative?

I felt like this new proof is the more natural variant (the other already uses +-comm in its proof) and I don't like using subst if I can help it

where open ∣-Reasoning

------------------------------------------------------------------------
-- Properties of _∣_ and _*_

Expand Down
Loading