Add more Data.Rational.Properties#2996
Open
kleinreact wants to merge 1 commit into
Open
Conversation
0ab7060 to
e4da88b
Compare
JacquesCarette
requested changes
May 29, 2026
| ↥p/↧p≡p (mkℚ -[1+ n ] d-1 prf) = cong (-_) (normalize-coprime prf) | ||
|
|
||
| ↥[i/1]≡i : (i : ℤ) → ↥ (i / 1) ≡ i | ||
| ↥[i/1]≡i i = begin |
Collaborator
There was a problem hiding this comment.
This feels like an awfully complicated proof for something so simple. I wonder if a "first principles" proof, by matching on i, would be simpler?
| where open ≡-Reasoning | ||
|
|
||
| ↧ₙ[i/1]≡1 : (i : ℤ) → ↧ₙ (i / 1) ≡ 1 | ||
| ↧ₙ[i/1]≡1 i = ℤ.+-injective $ begin |
Collaborator
There was a problem hiding this comment.
Possibly the same here.
| n/g≢0 = ℕ.≢-nonZero (ℕ.n/gcd[m,n]≢0 n n {{gcd≢0 = g≢0}}) | ||
|
|
||
| gcd[n,n]≡n : ∀ n → ℕ.gcd n n ≡ n | ||
| gcd[n,n]≡n n rewrite sym (ℕ.*-identityʳ n) |
Collaborator
There was a problem hiding this comment.
We tend not to use rewrite in stdlib. Also this lemma should go in to Data.Nat.GCD.
| p*g≢0 = ℕ.m*n≢0 p (ℕ.gcd qₙ r) | ||
|
|
||
| lemma : ∀ n → (p ℕ.* n) ℕ./ ℕ.gcd (p ℕ.* qₙ) (p ℕ.* r) ≡ n ℕ./ ℕ.gcd qₙ r | ||
| lemma n = trans (ℕ./-congʳ $ sym $ ℕ.c*gcd[m,n]≡gcd[cm,cn] p qₙ r) |
Collaborator
There was a problem hiding this comment.
an equational proof would be more readable here
| (ℕ.m*n/m*o≡n/o p n $ ℕ.gcd qₙ r) | ||
|
|
||
| proof : ∀ q → (+ p ℤ.* q) / (p ℕ.* r) ≡ q / r | ||
| proof (+ qₙ) rewrite sym (ℤ.pos-* p qₙ) = *-cancelˡ-/-helper qₙ |
Collaborator
There was a problem hiding this comment.
Please make these explicit instead of using rewrite
|
|
||
| ↥≡ : (↥ pᵢ ℤ.* ↧ qⱼ ℤ.+ ↥ qⱼ ℤ.* ↧ pᵢ) ℤ.* gcd[j,n] ℤ.* gcd[i,n] | ||
| ≡ (i ℤ.+ j) ℤ.* + n | ||
| ↥≡ rewrite ℤ.*-distribʳ-+ gcd[j,n] (↥ pᵢ ℤ.* ↧ qⱼ) (↥ qⱼ ℤ.* ↧ pᵢ) |
Collaborator
There was a problem hiding this comment.
most definitely needs to be done equationally!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I needed the following common properties over normalized rationals for some proofs, but found them to be missing in the library.
Hence, my proposal to add them with this PR.