Skip to content

Add ∣m+n∣n⇒∣m to Data.Nat.Divisiblity#2989

Open
Taneb wants to merge 2 commits intomasterfrom
divisibility-add-the-other-way
Open

Add ∣m+n∣n⇒∣m to Data.Nat.Divisiblity#2989
Taneb wants to merge 2 commits intomasterfrom
divisibility-add-the-other-way

Conversation

@Taneb
Copy link
Copy Markdown
Member

@Taneb Taneb commented Apr 28, 2026

Also slightly simplify the proof of ∣m+n∣m⇒∣n, which is closely related

Comment thread src/Data/Nat/Divisibility.agda Outdated
Comment on lines +200 to +205
∣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

Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
@Taneb Taneb requested a review from gallais April 30, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants