Skip to content

Proof for divX_mul_X_add#87

Merged
dhsorens merged 2 commits intodhsorens/unipoly-apifrom
ai-prover-20260213_151653
Feb 13, 2026
Merged

Proof for divX_mul_X_add#87
dhsorens merged 2 commits intodhsorens/unipoly-apifrom
ai-prover-20260213_151653

Conversation

@aleph-prover
Copy link
Contributor

@aleph-prover aleph-prover bot commented Feb 13, 2026

Proven lemmas: 3/3

The goal is to prove the polynomial identity divX p * X + C (p.coeff 0) = p for any CPolynomial p over a nontrivial ring/semiring R: informally, dividing by X and then multiplying back by X recovers all higher-degree terms, and the missing constant term is restored by adding C(p₀). The proof was decomposed into two coefficient “shift” lemmas about multiplication by X, and then a final step that compares coefficients on both sides. First, coeff_mul_X_zero shows that the constant coefficient of p * X is 0. Second, coeff_mul_X_succ shows that for every n, the (n+1)-st coefficient of p * X equals the n-th coefficient of p (multiplication by X shifts coefficients up by one). With these in hand, the main theorem divX_mul_X_add is proved by coefficient extensionality: check k = 0 separately (the X-multiple contributes 0 and C(p₀) contributes p₀), and check k = n+1 using the shift lemma plus the defining coefficient rule for divX.

Progress: all 3 sub-problems out of 3 are solved (both shift lemmas and the final coefficient-extensionality argument). There is no remaining mathematical gap; what’s left is only to integrate/clean up the proven Lean code so the file compiles smoothly with the intended imports and instances. One interesting technical challenge handled along the way is that only one term in the convolution sum for coeff(p * X) can survive (because coeff X j is 0 unless j = 1), so the proof collapses a finite sum to a single index using a “sum equals single term” argument, together with small arithmetic facts about n+1−i. Another minor gotcha is disambiguating similarly named lemmas for coeff_X coming from different namespaces, which the proof resolves by using the appropriate qualified lemma when rewriting.

Automated commit at 20260213_151653
@github-actions
Copy link

github-actions bot commented Feb 13, 2026

🤖 Gemini PR Summary

This Pull Request completes the formal proof of the polynomial identity divX p * X + C (p.coeff 0) = p within the CompPoly library. This identity establishes that dividing a polynomial by $X$, multiplying it back by $X$, and adding the original constant term recovers the original polynomial.

Features

  • Main Theorem Implementation: Proved divX_mul_X_add, demonstrating that for any polynomial $p$ over a nontrivial (semi)ring, the relation between divX and multiplication by $X$ holds via coefficient extensionality.
  • Auxiliary Coefficient Lemmas:
    • coeff_mul_X_zero: Proves that the constant coefficient of $p * X$ is always $0$.
    • coeff_mul_X_succ: Proves that the $(n+1)$-th coefficient of $p * X$ is equal to the $n$-th coefficient of $p$ (modeling the coefficient shift).
  • Summation Logic: Implemented the logic to collapse the convolution sum for coeff (p * X), handling the index simplification where coeff X j is non-zero only at $j=1$.

Refactoring

  • Code Cleanup: Removed redundant whitespace in CompPoly/Univariate/ToPoly.lean to adhere to formatting standards.
  • Namespace Resolution: Standardized the use of qualified names for coeff_X to resolve ambiguity between conflicting namespaces.

Technical Notes

The proof handles the edge case of index $k=0$ separately from $k=n+1$. It successfully manages the arithmetic of $n+1-i$ within the finite sum index range and leverages the specific properties of the divX coefficient definition to bridge the gap between shifted coefficients.


Analysis of Changes

Metric Count
📝 Files Changed 2
Lines Added 50
Lines Removed 2

sorry Tracking

✅ **Removed:** 1 `sorry`(s)
  • lemma divX_mul_X_add [Nontrivial R] (p : CPolynomial R) : divX p * X + C (p.coeff 0) = p in CompPoly/Univariate/Basic.lean

🎨 **Style Guide Adherence**

Based on the provided style guide, here are the violations found in the code changes:

  • Line 265, 294, 318: "Every definition and major theorem should have a docstring." (Theorems coeff_mul_X_succ, coeff_mul_X_zero, and divX_mul_X_add are missing docstrings).
  • Line 268: "Avoid parentheses where possible." (The double parentheses in change ((p.val * X.val).coeff (n + 1) = p.val.coeff n) are redundant; a single pair or none are required depending on context).
  • Line 274: "Prefer fun x ↦ ... over λ x, ...." (The code uses fun i => ... instead of the preferred arrow for a mathematical function).
  • Line 335: "Avoid parentheses where possible." (The parentheses around (coeff_divX (p := p) (i := n)) are redundant for the simpa using tactic).

📄 **Per-File Summaries**
  • CompPoly/Univariate/Basic.lean: This change completes the proof of the identity divX p * X + C (p.coeff 0) = p by establishing auxiliary lemmas for the coefficients of polynomials multiplied by X.
  • CompPoly/Univariate/ToPoly.lean: Remove a redundant blank line between theorem definitions to improve code formatting.

Last updated: 2026-02-13 15:29 UTC.

@dhsorens dhsorens merged commit e5c2ca0 into dhsorens/unipoly-api Feb 13, 2026
4 checks passed
dhsorens added a commit that referenced this pull request Feb 13, 2026
* feat: first commit introducing full API for canonical polynomials, with sorrys

* feat: progress on proofs

* feat: progress on proofs

* Proof for degree_eq_support_max (#80)

* Proof for degree_eq_support_max

Automated commit at 20260211_230303

* fix: linting errors and warnings

* fix: reintroduce docstring

* fix: annotate lemmas

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
Co-authored-by: Derek Sorensen <d@dhsorens.com>

* Proof for induction_on (#81)

* Proof for induction_on

Automated commit at 20260211_232242

* fix: linting errors, warnings, docstrings, annotation

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
Co-authored-by: Derek Sorensen <d@dhsorens.com>

* feat: add proofs for remaining sorrys

* fix: stylistic fixes

* feat: remove unnecessary, commented TODO

* fix: improve proof quality

* fix: remove applications of the classical tactic

* feat: improve proofs, change tail to (correct) divX

* feat: add division to (canonical) polynomials

* feat: improve API with further lemmas from Raw polynomials

* feat: stylistic improvements, consistent assumptions, etc

* feat: rename lemmas to be more in line with mathlib naming conventions

* fix: typo

* feat: README, small formatting refactor, some TODOs

* feat: proof of coeff_toPoly

* Proof for divX_toPoly (#85)

* Proof for divX_toPoly

Automated commit at 20260213_143852

* fix: incorporate existing proof

* fix docstring

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
Co-authored-by: Derek Sorensen <d@dhsorens.com>

* add divX_mul_X_add statement

* Proof for eval₂_toPoly (#86)

* Proof for eval₂_toPoly

Automated commit at 20260213_145823

* fix: docstrings, formatting, warnings

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
Co-authored-by: Derek Sorensen <d@dhsorens.com>

* Proof for divX_mul_X_add (#87)

* Proof for divX_mul_X_add

Automated commit at 20260213_151653

* fix: formatting errors and warnings

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
Co-authored-by: Derek Sorensen <d@dhsorens.com>

---------

Co-authored-by: aleph-prover[bot] <247409690+aleph-prover[bot]@users.noreply.github.com>
@dhsorens dhsorens deleted the ai-prover-20260213_151653 branch February 13, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant