← Back to Pull requests

[Merged by Bors] - feat: condition for `Polynomial.coeffs p ⊆ s` #44795

Closed
vihdzp closed this pull request without merging on Oct 13, 2026 19:23 UTC
View on GitHub
vihdzp vihdzp commented on Oct 12, 2026 11:41 UTC
Author

---
<!-- Your PR title will become the first line of the commit message.

In this box, the text above the --- (if not empty) will be appended
to the commit message, and can be used to give additional context or
details. Please leave a blank newline before the ---, otherwise GitHub
will format the text above it as a title.

For details on the "pull request lifecycle" in mathlib, please see:
https://leanprover-community.github.io/contribute/index.html

In particular, note that most reviewers will only notice your PR
if it passes the continuous integration checks.
Please ask for help on https://leanprover.zulipchat.com if needed.

When merging, all the commits will be squashed into a single commit
listing all co-authors.

Co-authors in the squash commit are gathered from two sources:

First, all authors of commits to this PR branch are included. Thus,
one way to add co-authors is to include at least one commit authored by
each co-author among the commits in the pull request. If necessary, you
may create empty commits to indicate co-authorship, using commands like so:

git commit --author="Author Name <author@email.com>" --allow-empty -m "add Author Name as coauthor"

Second, co-authors can also be listed in lines at the very bottom of
the commit message (that is, directly before the ---) using the following format:

Co-authored-by: Author Name <author@email.com>

If you are moving or deleting declarations, please include these lines
at the bottom of the commit message (before the ---, and also before
any "Co-authored-by" lines) using the following format:

Moves:

  • Vector. -> List.Vector.

  • ...
  • Deletions:

  • Nat.bit1_add_bit1

  • ...
  • Any other comments you want to keep out of the PR commit should go
    below the ---, and placed outside this HTML comment, or else they
    will be invisible to reviewers.

    If this PR depends on other PRs, please list them below this comment,
    using the following format:

  • depends on: #abc [optional extra text]

  • depends on: #xyz [optional extra text]
  • -->

    Diff: 20 lines (+11 / -9) across 1 files Reviewer: chenson2018 Review duration: 1902m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.21) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.21 · 20 lines diff across 1 files
    0.21
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.73 · 5 substantive comment(s)
    0.73
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    84%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.182
    Real PR Conversation Timeline
    13 items
    github-actions[bot] github-actions[bot] commented on Oct 12, 2026 11:42 UTC
    Bot

    PR summary ddb69a6390

    Import changes for modified files

    No significant changes to the import graph

    <details><summary>Import changes for all files</summary>

    |Files|Import difference|
    |-|-|

    </details>

    ---

    <details><summary>

    Declarations diff (regex)

    </summary>

    + coe_coeffs_subset_iff
    + coeffs_subset_iff
    <details>
    <summary>You can run this locally as follows</summary>

    ## from your `mathlib4` directory:
    git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
    
    ## summary with just the declaration names:
    ../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>
    
    ## more verbose report:
    ../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>
    

    </details>

    The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

    </details>

    <!-- DECLS_DIFF_LEAN_BEGIN -->

    Declarations diff (Lean)

    ✅ Lean-aware diff — post-build, computed from the Lean environment (commit ddb69a6).

    +2 new declarations
    −0 removed declarations

    +Polynomial.coe_coeffs_subset_iff
    +Polynomial.coeffs_subset_iff
    

    <!-- DECLS_DIFF_LEAN_END -->

    ---

    No changes to strong technical debt.
    No changes to weak technical debt.

    Current commit ddb69a6390
    Reference commit 260040a48c

    This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

    git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
    ../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
    

    The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
    The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

    github-actions[bot] github-actions[bot] commented on Oct 12, 2026 11:42 UTC
    Bot

    ✅ PR Title Formatted Correctly


    The title of this PR has been updated to match our commit style conventions.
    Thank you!
    <!-- Sticky Pull Request CommentPR Title Check -->

    chenson2018 chenson2018 commented on code on Oct 12, 2026 12:34 UTC
    Code Review
    Mathlib/Algebra/Polynomial/Basic.lean:1
    @@ -1040,23 +1040,27 @@ theorem coeffs_zero : coeffs (0 : R[X]) = ∅ :=
     theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
       simp [coeffs, eq_comm, (Finset.mem_image)]
     
    +theorem coe_coeffs_subset_iff {s : Set R} :
    +    (p.coeffs : Set R) ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    +  simp only [Set.subset_def, SetLike.mem_coe, mem_coeffs_iff]
    +  grind

    I'd probably write

      grind [mem_coeffs_iff]
    

    rather than mixing simp and grind?

    chenson2018 chenson2018 commented on code on Oct 12, 2026 12:35 UTC
    Code Review
    Mathlib/Algebra/Polynomial/Basic.lean:1
    @@ -1040,23 +1040,27 @@ theorem coeffs_zero : coeffs (0 : R[X]) = ∅ :=
     theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
       simp [coeffs, eq_comm, (Finset.mem_image)]
     
    +theorem coe_coeffs_subset_iff {s : Set R} :
    +    (p.coeffs : Set R) ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    +  simp only [Set.subset_def, SetLike.mem_coe, mem_coeffs_iff]
    +  grind
    +
    +theorem coeffs_subset_iff {s : Finset R} :
    +    p.coeffs ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by

    This fits on one line?

    theorem coeffs_subset_iff {s : Finset R} : p.coeffs ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    

    vihdzp vihdzp commented on code on Oct 12, 2026 16:08 UTC
    Code Review
    Mathlib/Algebra/Polynomial/Basic.lean:1
    @@ -1040,23 +1040,27 @@ theorem coeffs_zero : coeffs (0 : R[X]) = ∅ :=
     theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
       simp [coeffs, eq_comm, (Finset.mem_image)]
     
    +theorem coe_coeffs_subset_iff {s : Set R} :
    +    (p.coeffs : Set R) ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    +  simp only [Set.subset_def, SetLike.mem_coe, mem_coeffs_iff]
    +  grind
    +
    +theorem coeffs_subset_iff {s : Finset R} :
    +    p.coeffs ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by

    I'm indenting it like this to match coe_coeffs_subset_iff above, which doesn't fit in one line.

    themathqueen themathqueen commented on code on Oct 13, 2026 12:04 UTC
    Code Review
    Mathlib/Algebra/Polynomial/Basic.lean:1
    @@ -1040,23 +1040,26 @@ theorem coeffs_zero : coeffs (0 : R[X]) = ∅ :=
     theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
       simp [coeffs, eq_comm, (Finset.mem_image)]
     
    +theorem coe_coeffs_subset_iff {s : Set R} :
    +    (p.coeffs : Set R) ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    +  grind [mem_coeffs_iff]
    +
    +theorem coeffs_subset_iff {s : Finset R} :
    +    p.coeffs ⊆ s ↔ ∀ n, p.coeff n ≠ 0 → p.coeff n ∈ s := by
    +  simpa using coe_coeffs_subset_iff (s := (s : Set R))
    +
     theorem coeffs_one : coeffs (1 : R[X]) ⊆ {1} := by
    -  simp_rw [coeffs, Finset.image_subset_iff]
    -  simp_all [coeff_one]
    +  rw [coeffs_subset_iff]
    +  simp [coeff_one]
     
     theorem coeff_mem_coeffs {p : R[X]} {n : ℕ} (h : p.coeff n ≠ 0) : p.coeff n ∈ p.coeffs := by
       simp only [coeffs, mem_support_iff, Finset.mem_image, Ne]
       exact ⟨n, h, rfl⟩
     
     @[simp]
     theorem coeffs_empty_iff {p : R[X]} : coeffs p = ∅ ↔ p = 0 := by
    -  refine ⟨?_, fun h ↦ by simp [h]⟩
    -  contrapose!
    -  intro h
    -  rw [← support_nonempty] at h
    -  obtain ⟨n, hn⟩ := h
    -  rw [mem_support_iff] at hn
    -  exact ⟨p.coeff n, coeff_mem_coeffs hn⟩
    +  rw [← Finset.subset_empty, coeffs_subset_iff, Polynomial.ext_iff]
    +  simp

      simp [← Finset.subset_empty, coeffs_subset_iff, Polynomial.ext_iff]
    

    themathqueen themathqueen commented on Oct 13, 2026 12:24 UTC
    Reviewer

    Thanks,

    maintainer delegate

    github-actions[bot] github-actions[bot] commented on Oct 13, 2026 12:24 UTC
    Bot

    🚀 Pull request has been placed on the maintainer queue by themathqueen.

    j-loreaux j-loreaux commented on Oct 13, 2026 18:09 UTC
    Reviewer

    bors d+

    mathlib-bors[bot] mathlib-bors[bot] commented on Oct 13, 2026 18:09 UTC
    Bot

    :v: vihdzp can now approve this pull request until 2026-10-27 18:09 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

    :warning: This delegation only covers changes within Archive/, Counterexamples/, docs/, DownstreamTest/, Mathlib/, MathlibTest/, Wanted/, widget/, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean, Wanted.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

    vihdzp vihdzp commented on Oct 13, 2026 18:20 UTC
    Author

    bors r+

    mathlib-bors[bot] mathlib-bors[bot] commented on Oct 13, 2026 19:23 UTC
    Bot
    Reviewers
    Assignees
    vihdzp vihdzp
    Labels
    risk: low confidence: 84.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 21.2% (LOW) · Higher = larger blast radius
    21.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.3% · Lower = rushed or shallow review
    84.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.3% · Safe to merge
    3.3%