Conversation
|
@katyhr, would love your feedback and comments on this! Main questions:
|
🤖 Gemini PR SummaryThis Pull Request introduces the foundational implementation for computable bivariate polynomials ( Features
Refactoring & Infrastructure
Documentation
Next Steps: Analysis of Changes
Lean Declarations ❌ **Added:** 55 declaration(s)
❌ **Added:** 3 `sorry`(s)
🎨 **Style Guide Adherence**Based on the provided style guide, the following lines in the code changes violate the guidelines: CompPoly/Bivariate/Basic.lean
CompPoly/Bivariate/ToPoly.lean
CompPoly/Univariate/Basic.lean
CompPoly/Univariate/ToPoly.lean
📄 **Per-File Summaries**
Last updated: 2026-02-25 07:25 UTC. |
|
Currently kind of waffling on the namespace definition - we should either have bivariate polynomials defined within |
|
I kinda lean in favour of CBivariate for conciseness |
|
/review External: Internal: Comments: |
|
weird .. something went wrong with the history of this branch, it should only affect |
1d8b6f9 to
f72eb43
Compare
|
ok, fixed - now properly ready for review. |
🤖 AI Review (with external context)🤖 AI ReviewOverall Summary: 📄 **Review for `CompPoly.lean`**Hello. I have reviewed the changes in 1. Analysis of ImplementationThe changes in this PR involve adding two new import statements to the
Logic and Consistency: Specification Compliance: 2. Check for Misformalization
3. Verdict & FeedbackVerdict: The formalization is correct. The changes are low-risk and structural, properly integrating the new Bivariate modules into the top-level library entry point. No misformalization issues are present. 📄 **Review for `CompPoly/Bivariate/Basic.lean`**This review focuses on The file introduces a computable bivariate polynomial type 1. Critical Misformalization in
|
…e to prove API correct
…ry, improve quality and documentation
|
the ToPoly section is basically there, with a ring equivalence included. proofs of correctness for all the operations implemented incoming |
@dhsorens sorry for the slow reply! I think yes to 1 and 3, and for 2 I also prefer the CompPoly.CBivariate. Btw are there any naming conventions/rules for lemmas, namespaces, etc in CompPoly? Maybe this would be a good thing to have if it's not there yet :) |
|
@katyhr amazing, thank you for looking at this! we don't yet have explicit conventions/rules for lemmas, namespaces, etc in CompPoly, but I think it is a good idea to implement them. Julian had some good feedback on the Univariate interface which now needs to be improved, but this is something I would like to establish what do you think about this as a starting point for bivariate? are we off to a reasonably good start? |
|
/review External: Internal: CompPoly/Bivariate/* Comments: Review this pull request, focusing on the Bivariate polynomials; review for correctness, style, and make any suggested improvements to the code. Review for the additions to Univariate/ for any redundancy or misplacement of the added lemmas |
🤖 AI Review (with external context)🤖 AI ReviewOverall Summary: The PR correctly implements Bivariate polynomials and establishes the necessary algebraic isomorphisms to Mathlib, with sound logic and definitions throughout. However, this PR cannot be merged in its current state due to critical incompleteness in 📄 **Review for `CompPoly.lean`**This is a review of the changes in 1. Analysis of ImplementationThe diff adds two import statements to the top-level file of the library:
Observation:
2. Check for Misformalization
3. Verdict & FeedbackVerdict: Correct. Feedback: 📄 **Review for `CompPoly/Bivariate/Basic.lean`**This review focuses on the file Analysis of Logic and Correctness
Potential Specification/Style Ambiguities
VerdictThe formalization is Correct. The logic matches the docstrings and standard algebraic definitions for bivariate polynomials implemented as nested univariate polynomials. Verdict: Correct 📄 **Review for `CompPoly/Bivariate/ToPoly.lean`**To: Derek Sorensen (Author) I have reviewed the new file Verdict: Correct (with Incomplete Proofs) The formalization correctly implements the isomorphism between the array-based bivariate polynomials ( However, there are several proofs left as Analysis of Changes
Findings1. Incomplete Proofs (
2. Minor Duplication
3. Type Class Constraints
ConclusionThe code is a correct formalization of the intended isomorphism. The logic for the conversion functions and the statements of the equivalence theorems are sound. The only action items are to finish the proofs marked with Formalization Check:
No critical issues found. 📄 **Review for `CompPoly/Univariate/Basic.lean`**1. Implementation Analysis
2. Misformalization Checklist & Assessment
3. Verdict & Feedback The formalization in this file is correct. The changes consistently implement standard polynomial operations and typeclasses for a computational polynomial type ( Verdict: Correct. 📄 **Review for `CompPoly/Univariate/ToPoly.lean`**This is a review of the changes in General Verdict: Findings:
Refined Code Snippet: /-- `toPoly` maps a canonical polynomial to `0` iff the polynomial is `0`. -/
theorem toPoly_eq_zero_iff [LawfulBEq R] (p : CPolynomial R) :
p.toPoly = 0 ↔ p = 0 := by
constructor
· intro hp
have hround : p.toPoly.toImpl = p := toImpl_toPoly_of_canonical p
rw [eq_comm] at hround
-- Substitutes p.toPoly = 0 -> p = 0.toImpl.
-- Assuming 0.toImpl = 0 (canonical zero), which aesop should handle.
aesop
· aesopSummary: |
|
OK, implementations seem to be correct. There are three outstanding For now, though, I think this is a reasonable start and I am inclined to merge as-is @alexanderlhicks @katyhr - are you happy with that? |
|
|
||
| /-- Extensionality: two bivariate polynomials are equal iff their underlying values are. -/ | ||
| @[ext] theorem ext {p q : CBivariate R} (h : p.val = q.val) : p = q := | ||
| CPolynomial.ext h |
There was a problem hiding this comment.
The docstring says this is an "if and only if" statement but we only seem to have the p.val = q.val => p=q direction.
Also, are values the coefficients?
There was a problem hiding this comment.
the @[ext] automatically derives ext_iff from this theorem which gives the iff statement,
p = q ↔ ↑p = ↑q
bivariate polynomials are defined in terms of CPolynomial which is a subtype, so p.val refers to the underlying (possibly untrimmed) coefficient array corresponding to p - p.property gives the proof that it is canonical (no trailing zeros)
CompPoly/Bivariate/Basic.lean
Outdated
|
|
||
| /-- The `X`-degree: maximum over all Y-coefficients of their degree in X. | ||
| ArkLib: `Polynomial.Bivariate.degreeX`. -/ | ||
| def degreeX (f : CBivariate R) : ℕ := |
There was a problem hiding this comment.
Don't we want this to be natDegreeX too?
PS will PR a change in ArkLib
There was a problem hiding this comment.
Yep! Passed over this while importing the corresponding Arklib statements (changing docstring to reflect change in Arklib)
CompPoly/Bivariate/Basic.lean
Outdated
|
|
||
| /-- Leading coefficient when viewed as a polynomial in Y. | ||
| ArkLib: `Polynomial.Bivariate.leadingCoeffY`. -/ | ||
| def leadingCoeffY (f : CBivariate R) : CPolynomial R := |
There was a problem hiding this comment.
Good call - leadingCoeffX relies on the definition of swap - so I've opted to move leadingCoefficientY down to be next to leadingCoeffX
@dhsorens some random thoughts!
|
|
@katyhr thank you for these comments! I have made fixes. I think a more detailed style guide is definitely in order. Since all the polynomials in this section follow the convention of I have not thought too much about the outstanding |
As described on the Roadmap, for Phase 1 we want to have a basic, computable implementation for Bivariate polynomials. This pull request adds a
Bivariatedirectory and a new typeCBivariate. It defines bivariate polynomials as nested computable Univariate polynomials:CPolynomial (CPolynomial R). It includes the basic type definition, basic definitions for operations, and a basic structure for the equivalence with Mathlib'sR[X][Y].The rough outline of continued work on this, mimicking what's on Univariate:
CBivariateR[X][Y]