|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Kenny Lau. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Kenny Lau, Anne Baanen |
| 5 | +-/ |
| 6 | + |
| 7 | +import Mathlib.Algebra.Polynomial.Degree.Definitions |
| 8 | +import Mathlib.LinearAlgebra.Matrix.Determinant.Basic |
| 9 | + |
| 10 | +/-! |
| 11 | +# Resultant of two polynomials |
| 12 | +
|
| 13 | +This file contains basic facts about resultant of two polynomials over commutative rings. |
| 14 | +
|
| 15 | +## Main definitions |
| 16 | +
|
| 17 | +* `Polynomial.resultant`: The resultant of two polynomials `p` and `q` is defined as the determinant |
| 18 | + of the Sylvester matrix of `p` and `q`. |
| 19 | +
|
| 20 | +## TODO |
| 21 | +
|
| 22 | +* The eventual goal is to prove the following property: |
| 23 | + `resultant (∏ a ∈ s, (X - C a)) f = ∏ a ∈ s, f.eval a`. |
| 24 | + This allows us to write the `resultant f g` as the product of terms of the form `a - b` where `a` |
| 25 | + is a root of `f` and `b` is a root of `g`. |
| 26 | +* A smaller intermediate goal is to show that the Sylvester matrix corresponds to the linear map |
| 27 | + that we will call the Sylvester map, which is `R[X]_n × R[X]_m →ₗ[R] R[X]_(n + m)` given by |
| 28 | + `(p, q) ↦ f * p + g * q`, where `R[X]_n` is |
| 29 | + `Polynomial.degreeLT` in `Mathlib.RingTheory.Polynomial.Basic`. |
| 30 | +* Resultant of two binary forms (i.e. homogeneous polynomials in two variables), after binary forms |
| 31 | + are implemented. |
| 32 | +
|
| 33 | +-/ |
| 34 | + |
| 35 | + |
| 36 | +universe u |
| 37 | + |
| 38 | +namespace Polynomial |
| 39 | + |
| 40 | +section sylvester |
| 41 | + |
| 42 | +variable {R : Type u} [Semiring R] |
| 43 | + |
| 44 | +/-- The Sylvester matrix of two polynomials `f` and `g` of degrees `m` and `n` respectively is a |
| 45 | +`(n+m) × (n+m)` matrix with the coefficients of `f` and `g` arranged in a specific way. Here, `m` |
| 46 | +and `n` are free variables, not necessarily equal to the actual degrees of the polynomials `f` and |
| 47 | +`g`. -/ |
| 48 | +def sylvester (f g : R[X]) (m n : ℕ) : Matrix (Fin (n + m)) (Fin (n + m)) R := |
| 49 | + .of fun i j ↦ j.addCases |
| 50 | + (fun j₁ ↦ if (i : ℕ) ∈ Set.Icc (j₁ : ℕ) (j₁ + m) then f.coeff (i - j₁) else 0) |
| 51 | + (fun j₁ ↦ if (i : ℕ) ∈ Set.Icc (j₁ : ℕ) (j₁ + n) then g.coeff (i - j₁) else 0) |
| 52 | + |
| 53 | +variable (f g : R[X]) (m n : ℕ) |
| 54 | + |
| 55 | +@[simp] theorem sylvester_C_right (a : R) : |
| 56 | + sylvester f (C a) m 0 = Matrix.diagonal (fun _ ↦ a) := |
| 57 | + Matrix.ext fun i j ↦ j.addCases nofun fun j ↦ by |
| 58 | + rw [sylvester, Matrix.of_apply, Fin.addCases_right, Matrix.diagonal_apply] |
| 59 | + split_ifs <;> simp_all [Fin.ext_iff] |
| 60 | + |
| 61 | +end sylvester |
| 62 | + |
| 63 | + |
| 64 | +section resultant |
| 65 | + |
| 66 | +variable {R : Type u} [CommRing R] |
| 67 | + |
| 68 | +/-- The resultant of two polynomials `f` and `g` is the determinant of the Sylvester matrix of `f` |
| 69 | +and `g`. The size arguments `m` and `n` are implemented as `optParam`, meaning that the default |
| 70 | +values are `f.natDegree` and `g.natDegree` respectively, but they can also be specified to be |
| 71 | +other values. -/ |
| 72 | +def resultant (f g : R[X]) (m : ℕ := f.natDegree) (n : ℕ := g.natDegree) : R := |
| 73 | + (sylvester f g m n).det |
| 74 | + |
| 75 | +variable (f g : R[X]) (m n : ℕ) |
| 76 | + |
| 77 | +/-- For polynomial `f` and constant `a`, `Res(f, a) = a ^ m`. -/ |
| 78 | +@[simp] |
| 79 | +theorem resultant_C_zero_right (a : R) : resultant f (C a) m 0 = a ^ m := by simp [resultant] |
| 80 | + |
| 81 | +/-- For polynomial `f` and constant `a`, `Res(f, a) = a ^ m`. -/ |
| 82 | +theorem resultant_C_right (a : R) : resultant f (C a) m = a ^ m := by simp |
| 83 | + |
| 84 | +end resultant |
| 85 | + |
| 86 | +end Polynomial |
0 commit comments