{
  "id": "4274",
  "ident": "NS.04274",
  "slug": "hilbert-17--hilbert17thproblemhomogenouspoly-zero-right",
  "title": "Hilbert's 17th problem · Hilbert17thProblemHomogenousPoly_zero_right",
  "status": "test",
  "statement_status": "reviewed",
  "statement_md": null,
  "subjects": [
    "math.AC",
    "msc:12"
  ],
  "tags": [],
  "collection": "hilbert",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Hilbert17.Hilbert17thProblemHomogenousPoly_zero_right",
  "statement_lean": "theorem Hilbert17thProblemHomogenousPoly_zero_right (n : ℕ) :\n    Hilbert17thProblemHomogenousPoly n 0",
  "challenge_source": "/-\nCopyright 2025 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Hilbert's 17th problem\n\nLet $f(x_1, \\dots, x_n)$ be a multivariable polynomial with real coefficients that takes only\nnonnegative values for all real inputs.\nHilbert's 17th problem asks whether there exist rational functions $g_1, \\dots, g_m$ such that\n$f = g_1^2 + g_2^2 + \\cdots + g_m^2$. Resolved affirmatively by Artin in 1927.\n*References:*\n- [Wikipedia](https://en.wikipedia.org/wiki/Hilbert%27s_seventeenth_problem)\n- Motzkin, \"The arithmetic-geometric inequality\". In Shisha, Oved (ed.). Inequalities. Academic Press. pp. 205–224.\n-/\n\n@[expose] public section\n\nopen Real MvPolynomial\n\nnamespace Hilbert17\n\n/--\nHilbert's 17th problem: every non-negative multivariate polynomial is a sum of\nsquares of rational functions.\n-/\n@[category research solved, AMS 12]\ntheorem hilbert_17th_problem {n : ℕ} (hn : 0 < n) (f : MvPolynomial (Fin n) ℝ)\n    (h : ∀ x : Fin n → ℝ, 0 ≤ f.eval x) :\n    ∃ (m : ℕ) (g : Fin m → MvRatFunc (Fin n) ℝ), algebraMap _ _ f = ∑ i, (g i) ^ 2 := by\n  sorry\n\n/--\nThe statement is false in general if we restrict to polynomials. The polynomial (by Motzkin)\n$f(x, y) = x^4 y^2 + x^2 y^4 - 3 x^2 y^2 + 1$ takes only nonnegative values but cannot be\nwritten as a sum of squares of polynomials.\n-/\nnoncomputable def f : MvPolynomial (Fin 2) ℝ :=\n  X 0 ^ 4 * X 1 ^ 2 + X 0 ^ 2 * X 1 ^ 4 - 3 * X 0 ^ 2 * X 1 ^ 2 + 1\n\n-- Proof taken from `motzkin_polynomial_nonneg` in mathlib\n/-- The Motzkin polynomial is non-negative everywhere. -/\n@[category textbook, AMS 12]\ntheorem f_nonneg : ∀ x y : ℝ, 0 ≤ f.eval ![x, y] := by\n  intro x y\n  simp only [Nat.succ_eq_add_one, Nat.reduceAdd, f, Fin.isValue, map_add, map_sub, map_mul, map_pow,\n    eval_X, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_fin_one, eval_ofNat, map_one]\n  by_cases hx : x = 0\n  · simp [hx]\n  have h : 0 < (x ^ 2 + y ^ 2) ^ 2 := by positivity\n  refine nonneg_of_mul_nonneg_left ?_ h\n  have H : 0 ≤ (x ^ 3 * y + x * y ^ 3 - 2 * x * y) ^ 2 * (1 + x ^ 2 + y ^ 2)\n    + (x ^ 2 - y ^ 2) ^ 2 := by positivity\n  linear_combination H\n\n/-- The Motzkin polynomial cannot be written as a sum of squares of polynomials. -/\n@[category textbook, AMS 12]\ntheorem f_not_sum_of_squares :\n    ¬∃ (n : ℕ) (hn : 0 < n) (S : Fin n → MvPolynomial (Fin 2) ℝ), f = ∑ i, S i ^ 2 := by\n  sorry\n\n/--\nFor the polynomial version, Hilbert showed that every nonnegative homogeneous polynomial in\n$n$ variables of degree $2d$ can be written as a sum of squares of polynomials if and only if\n- $n = 1$\n- $n = 2$\n- $d = 1$\n- $(n, d) = (3, 2)$.\n-/\ndef Hilbert17thProblemHomogenousPoly (n d : ℕ) : Prop :=\n  ∀ f : MvPolynomial (Fin n) ℝ, f.IsHomogeneous (2 * d) →\n    (∀ x : Fin n → ℝ, 0 ≤ f.eval x) →\n      ∃ (m : ℕ) (g : Fin m → MvPolynomial (Fin n) ℝ), f = ∑ i, (g i) ^ 2\n\n@[category test, AMS 12]\ntheorem Hilbert17thProblemHomogenousPoly_zero_left (d : ℕ) :\n    Hilbert17thProblemHomogenousPoly 0 d := by\n  refine fun f hf hf₀ ↦ ⟨1, fun _ ↦ C √(f.coeff 0), ?_⟩\n  have hfd := hf.totalDegree\n  rw [f.eq_C_of_isEmpty] at hf₀ ⊢\n  rw [Finset.sum_congr rfl fun _ _ ↦ (map_pow _ _ _).symm, Real.sq_sqrt <| by simpa using hf₀]\n  simp\n\n@[category test, AMS 12]\ntheorem Hilbert17thProblemHomogenousPoly_zero_right (n : ℕ) :\n    Hilbert17thProblemHomogenousPoly n 0 := by\n  intro f hf hf₀\n  rcases eq_or_ne f 0 with (rfl | hf_zero); · exact ⟨0, 0, by simp⟩\n  have hfd := f.totalDegree_eq_zero_iff_eq_C.1 <| by simpa using hf.totalDegree hf_zero\n  use 1, fun _ ↦ C √(f.coeff 0)\n  rw [Finset.sum_congr rfl fun _ _ ↦ (map_pow _ _ _).symm, Real.sq_sqrt <| by\n    simpa [constantCoeff] using hf₀ 0]\n  simpa using hfd\n\n/--\nHilbert's 17th problem for homogeneous polynomials: characterization of dimensions and degrees\nwhere non-negative polynomials are sums of squares of polynomials.\n-/\n@[category research solved, AMS 12]\ntheorem hilbert_17th_problem_poly {n d : ℕ} (hn : 0 < n) (hd : 0 < d) :\n    Hilbert17thProblemHomogenousPoly n d ↔ n = 1 ∨ n = 2 ∨ d = 1 ∨ n = 3 ∧ d = 2 := by\n  sorry\n\nend Hilbert17\n",
  "statement_hash": "d51938cb71ace0c9147d74b0b8252a2437685e4bbb3ec58dc7bcb114e5f96be5",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}