AFTD Auto-Formalizing Theoretical Domains

quadratic_func_at_most_two_roots

theoremverified

A nonzero quadratic polynomial t ↦ A * t^2 + B * t + C with A ≠ 0 has at most two real roots.

Statement

theorem quadratic_func_at_most_two_roots (A B C : ℝ) (hA : A ≠ 0) (s : Finset ℝ)
    (hs : ∀ t ∈ s, A * t ^ 2 + B * t + C = 0) : s.card ≤ 2
Source
folklore
Verified
08 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

Read back from the Lean

For any real numbers $A, B, C$ with $A \neq 0$, and for any finite set $s$ of real numbers, if every element $t \in s$ satisfies $A t^2 + B t + C = 0$, then the cardinality of $s$ is at most 2.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The proof constructs the formal polynomial p(X) = A * X^2 + B * X + C over ℝ. Since A ≠ 0, p is not the zero polynomial, and by hypothesis every point in s is a root of p. Summing the degree bounds of the individual monomial terms shows that the degree of p is at most 2, so the number of distinct roots in s cannot exceed 2.

  1. Define the polynomial p(X) = A * X^2 + B * X + C and establish that p ≠ 0.

    We construct p as the formal polynomial A * X^2 + B * X + C in ℝ[X]. Assuming p = 0 for contradiction, the coefficient of X^2 must be zero, which simplifies to A = 0 via `congr_arg`, contradicting the hypothesis A ≠ 0.

    lines 4–9

    uses congr_arg

      let p : Polynomial ℝ := Polynomial.C A * Polynomial.X ^ 2 + Polynomial.C B * Polynomial.X + Polynomial.C C
      have hp : p ≠ 0 := by
        intro h
        have hc := congr_arg (Polynomial.coeff · 2) h
        simp [p] at hc
        exact hA hc
  2. Every point in s is a root of the polynomial p, so s ⊆ p.roots.

    For any t ∈ s, since p ≠ 0, t is in the multiset of roots of p if and only if p(t) = 0 by `Polynomial.mem_roots` and `Polynomial.IsRoot.def`. Evaluating p at t gives A * t^2 + B * t + C, which vanishes by the hypothesis hs on s.

    lines 10–15

    uses Polynomial.mem_roots, Polynomial.IsRoot.def

      have hroots : s.val ⊆ p.roots := by
        intro t ht
        rw [Polynomial.mem_roots hp, Polynomial.IsRoot.def]
        have heval : p.eval t = A * t ^ 2 + B * t + C := by simp [p]
        rw [heval]
        exact hs t ht
  3. The degree of p is at most 2.

    The degree of a sum of polynomials is at most the maximum of their degrees (by `Polynomial.natDegree_add_le_of_degree_le`). We decompose p as (A * X^2 + B * X) + C: the constant C has degree at most 2, A * X^2 has degree at most 2 by `Polynomial.natDegree_C_mul_X_pow_le`, and B * X = B * X^1 has degree at most 1 ≤ 2 by `pow_one` and linear arithmetic.

    lines 16–21

    uses Polynomial.natDegree_add_le_of_degree_le, Polynomial.natDegree_C_mul_X_pow_le, pow_one

      have hdeg : p.natDegree ≤ 2 := by
        refine Polynomial.natDegree_add_le_of_degree_le ?_ (by simp)
        refine Polynomial.natDegree_add_le_of_degree_le (Polynomial.natDegree_C_mul_X_pow_le A 2) ?_
        have h1 := Polynomial.natDegree_C_mul_X_pow_le B 1
        simp only [pow_one] at h1
        omega
  4. The set s contains at most 2 elements.

    By `Polynomial.card_le_degree_of_subset_roots`, the size of any finite subset of roots of p is bounded by the degree of p. Chaining |s| ≤ deg(p) with deg(p) ≤ 2 yields |s| ≤ 2.

    lines 22–23

    uses Polynomial.card_le_degree_of_subset_roots

      have hcard := Polynomial.card_le_degree_of_subset_roots hroots
      exact hcard.trans hdeg
congr_arg
If two inputs are equal, applying a function to both gives equal results: x = y implies f(x) = f(y).
Polynomial.mem_roots
For a nonzero polynomial p over an integral domain, an element a is in the multiset of roots of p if and only if a is a root of p.
Polynomial.IsRoot.def
An element a is a root of p if and only if p evaluated at a equals 0.
Polynomial.natDegree_add_le_of_degree_le
If two polynomials each have degree at most n, their sum also has degree at most n.
Polynomial.natDegree_C_mul_X_pow_le
The polynomial a * X^n has degree at most n.
pow_one
An element raised to the first power equals itself: a^1 = a.
Polynomial.card_le_degree_of_subset_roots
The cardinality of any finite set contained in the roots of a polynomial is at most the degree of that polynomial.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- A nonzero quadratic polynomial has at most two real roots. -/theorem quadratic_func_at_most_two_roots (A B C : ℝ) (hA : A ≠ 0) (s : Finset ℝ)    (hs : ∀ t ∈ s, A * t ^ 2 + B * t + C = 0) : s.card ≤ 2 := by  let p : Polynomial ℝ := Polynomial.C A * Polynomial.X ^ 2 + Polynomial.C B * Polynomial.X + Polynomial.C C  have hp : p ≠ 0 := by    intro h    have hc := congr_arg (Polynomial.coeff · 2) h    simp [p] at hc    exact hA hc  have hroots : s.val ⊆ p.roots := by    intro t ht    rw [Polynomial.mem_roots hp, Polynomial.IsRoot.def]    have heval : p.eval t = A * t ^ 2 + B * t + C := by simp [p]    rw [heval]    exact hs t ht  have hdeg : p.natDegree ≤ 2 := by    refine Polynomial.natDegree_add_le_of_degree_le ?_ (by simp)    refine Polynomial.natDegree_add_le_of_degree_le (Polynomial.natDegree_C_mul_X_pow_le A 2) ?_    have h1 := Polynomial.natDegree_C_mul_X_pow_le B 1    simp only [pow_one] at h1    omega  have hcard := Polynomial.card_le_degree_of_subset_roots hroots  exact hcard.trans hdeg
See it in the graphDiscuss this resultChallenge it