Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/FieldTheory/RatFunc/     Datei vom 15.10.2026 mit Größe 12 kB image not shown  

Quelle  AsPolynomial.lean   Sprache: Lean

 

/-
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, María Inés de Frutos-Fernández, Filippo A. E. Nuccio
-/

module

public import Mathlib.FieldTheory.RatFunc.Basic
public import Mathlib.RingTheory.Adjoin.Polynomial.Transcendental
public import Mathlib.RingTheory.DedekindDomain.AdicValuation.Completion

import Mathlib.RingTheory.Valuation.IsTrivialOn

/-!
# Generalities on the polynomial structure of rational functions

* Main evaluation properties
* Study of the X-adic valuation

## Main definitions
- `RatFunc.C` is the constant polynomial
- `RatFunc.X` is the indeterminate
- `RatFunc.eval` evaluates a rational function given a value for the indeterminate
- `idealX` is the principal ideal generated by `X` in the ring of polynomials over a field K,
  regarded as an element of the height-one-spectrum.
-/


@[expose] public section

noncomputable section

universe u

variable {K : Type u}

namespace RatFunc

section Eval

open scoped nonZeroDivisors Polynomial

open RatFunc

/-! ### Polynomial structure: `C`, `X`, `eval` -/

section Domain

variable [CommRing K] [IsDomain K]

/-- `RatFunc.C a` is the constant rational function `a`. -/
def C : K →+* K⟮X⟯ := algebraMap _ _

@[simp]
theorem algebraMap_eq_C : algebraMap K K⟮X⟯ = C :=
  rfl

@[simp]
theorem algebraMap_C (a : K) : algebraMap K[X] K⟮X⟯ (Polynomial.C a) = C a :=
  rfl

@[simp]
theorem algebraMap_comp_C : (algebraMap K[X] K⟮X⟯).comp Polynomial.C = C :=
  rfl

theorem smul_eq_C_mul (r : K) (x : K⟮X⟯) : r • x = C r * x := by
  rw [Algebra.smul_def, algebraMap_eq_C]

theorem C_injective : Function.Injective (RatFunc.C (K := K)) := by
  rw [← algebraMap_comp_C, RingHom.coe_comp]
  exact Function.Injective.comp (algebraMap_injective K) (Polynomial.C_injective)

/-- `RatFunc.X` is the polynomial variable (aka indeterminate). -/
def X : K⟮X⟯ :=
  algebraMap K[X] K⟮X⟯ Polynomial.X

@[simp]
theorem algebraMap_X : algebraMap K[X] K⟮X⟯ Polynomial.X = X :=
  rfl

@[simp]
theorem algebraMap_monomial (n : ℕ) (a : K) :
    algebraMap K[X] K⟮X⟯ (Polynomial.monomial n a) = C a * X ^ n := by
  simp [← Polynomial.C_mul_X_pow_eq_monomial]

@[simp]
theorem aeval_X_left_eq_algebraMap (p : K[X]) :
    p.aeval (X : K⟮X⟯) = algebraMap K[X] K⟮X⟯ p := by
  induction p using Polynomial.induction_on' <;> simp_all

@[simp]
theorem coePolynomial_eq_algebraMap (p : K[X]) :
    (p : RatFunc K) = algebraMap (Polynomial K) (RatFunc K) p := rfl

@[simp]
lemma liftRingHom_C {L : Type*} [Field L] (φ : K[X] →+* L) (hφ : K[X]⁰ ≤ L⁰.comap φ) (x : K) :
    liftRingHom φ hφ (C x) = φ (.C x) :=
  RatFunc.liftRingHom_algebraMap _ _ _

@[simp]
lemma liftRingHom_X {L : Type*} [Field L] (φ : K[X] →+* L) (hφ : K[X]⁰ ≤ L⁰.comap φ) :
    RatFunc.liftRingHom φ hφ X = φ (.X) :=
  RatFunc.liftRingHom_algebraMap _ _ _

end Domain

section Field

variable [Field K]

@[simp]
theorem num_C (c : K) : num (C c) = Polynomial.C c :=
  num_algebraMap _

@[simp]
theorem denom_C (c : K) : denom (C c) = 1 :=
  denom_algebraMap _

@[simp]
theorem num_X : num (X : K⟮X⟯) = Polynomial.X :=
  num_algebraMap _

@[simp]
theorem denom_X : denom (X : K⟮X⟯) = 1 :=
  denom_algebraMap _

theorem X_ne_zero : (X : K⟮X⟯) ≠ 0 :=
  RatFunc.algebraMap_ne_zero Polynomial.X_ne_zero

theorem eq_C_iff (f : K⟮X⟯) :
    (∃ c, f = C c) ↔ f.num.natDegree = 0 ∧ f.denom.natDegree = 0 := by
  refine ⟨by rintro ⟨c, rfl⟩; simp, ?_⟩
  rw [Polynomial.natDegree_eq_zero, Polynomial.natDegree_eq_zero]
  rintro ⟨⟨a, ha⟩, ⟨b, hb⟩⟩
  use a / b
  rw [← num_div_denom f, ← ha, ← hb, algebraMap_C, algebraMap_C, map_div₀]

variable {L : Type u} [Field L]

/-- Evaluate a rational function `p` given a ring hom `f` from the scalar field
to the target and a value `x` for the variable in the target.

Fractions are reduced by clearing common denominators before evaluating:
`eval id 1 ((X^2 - 1) / (X - 1)) = eval id 1 (X + 1) = 2`, not `0 / 0 = 0`.
-/

def eval (f : K →+* L) (a : L) (p : K⟮X⟯) : L :=
  (num p).eval₂ f a / (denom p).eval₂ f a

variable {f : K →+* L} {a : L}

theorem eval_eq_zero_of_eval₂_denom_eq_zero {x : K⟮X⟯}
    (h : Polynomial.eval₂ f a (denom x) = 0) : eval f a x = 0 := by rw [eval, h, div_zero]

theorem eval₂_denom_ne_zero {x : K⟮X⟯} (h : eval f a x ≠ 0) :
    Polynomial.eval₂ f a (denom x) ≠ 0 :=
  mt eval_eq_zero_of_eval₂_denom_eq_zero h

variable (f a)

@[simp]
theorem eval_C {c : K} : eval f a (C c) = f c := by simp [eval]

@[simp]
theorem eval_X : eval f a X = a := by simp [eval]

@[simp]
theorem eval_zero : eval f a 0 = 0 := by simp [eval]

@[simp]
theorem eval_one : eval f a 1 = 1 := by simp [eval]

@[simp]
theorem eval_algebraMap {S : Type*} [CommSemiring S] [Algebra S K[X]] (p : S) :
    eval f a (algebraMap _ _ p) = (algebraMap _ K[X] p).eval₂ f a := by
  simp [eval, IsScalarTower.algebraMap_apply S K[X] K⟮X⟯]

/-- `eval` is an additive homomorphism except when a denominator evaluates to `0`.

Counterexample: `eval _ 1 (X / (X-1)) + eval _ 1 (-1 / (X-1)) = 0`
`... ≠ 1 = eval _ 1 ((X-1) / (X-1))`.

See also `RatFunc.eval₂_denom_ne_zero` to make the hypotheses simpler but less general.
-/

theorem eval_add {x y : K⟮X⟯} (hx : Polynomial.eval₂ f a (denom x) ≠ 0)
    (hy : Polynomial.eval₂ f a (denom y) ≠ 0) : eval f a (x + y) = eval f a x + eval f a y := by
  unfold eval
  by_cases hxy : Polynomial.eval₂ f a (denom (x + y)) = 0
  · have := Polynomial.eval₂_eq_zero_of_dvd_of_eval₂_eq_zero f a (denom_add_dvd x y) hxy
    rw [Polynomial.eval₂_mul] at this
    cases mul_eq_zero.mp this <;> contradiction
  rw [div_add_div _ _ hx hy, eq_div_iff (mul_ne_zero hx hy), div_eq_mul_inv, mul_right_comm, ←
    div_eq_mul_inv, div_eq_iff hxy]
  simp only [← Polynomial.eval₂_mul, ← Polynomial.eval₂_add]
  congr 1
  apply num_denom_add

/-- `eval` is a multiplicative homomorphism except when a denominator evaluates to `0`.

Counterexample: `eval _ 0 X * eval _ 0 (1/X) = 0 ≠ 1 = eval _ 0 1 = eval _ 0 (X * 1/X)`.

See also `RatFunc.eval₂_denom_ne_zero` to make the hypotheses simpler but less general.
-/

theorem eval_mul {x y : K⟮X⟯} (hx : Polynomial.eval₂ f a (denom x) ≠ 0)
    (hy : Polynomial.eval₂ f a (denom y) ≠ 0) : eval f a (x * y) = eval f a x * eval f a y := by
  unfold eval
  by_cases hxy : Polynomial.eval₂ f a (denom (x * y)) = 0
  · have := Polynomial.eval₂_eq_zero_of_dvd_of_eval₂_eq_zero f a (denom_mul_dvd x y) hxy
    rw [Polynomial.eval₂_mul] at this
    cases mul_eq_zero.mp this <;> contradiction
  rw [div_mul_div_comm, eq_div_iff (mul_ne_zero hx hy), div_eq_mul_inv, mul_right_comm, ←
    div_eq_mul_inv, div_eq_iff hxy]
  repeat' rw [← Polynomial.eval₂_mul]
  congr 1
  apply num_denom_mul

end Field

end Eval

section algEquivOfTranscendental

open Polynomial IntermediateField algebraAdjoinAdjoin

variable {K L : Type*} [Field K] [Field L] [Algebra K L] (f : L) (h : Transcendental K f)

/-- Given a transcendental `f : L`, the `K`-algebra isomorphism between `RatFunc K` and `L` given
by sending `X` to `f`. -/

noncomputable def algEquivOfTranscendental : RatFunc K ≃ₐ[K] K⟮f⟯ :=
  IsFractionRing.algEquivOfAlgEquiv (Polynomial.algEquivOfTranscendental K f h)

@[simp]
theorem algEquivOfTranscendental_algebraMap (g : K[X]) :
    algEquivOfTranscendental f h (algebraMap K[X] (RatFunc K) g) =
    aeval (AdjoinSimple.gen K f) g := by
  ext
  simp [algEquivOfTranscendental]

@[simp]
theorem algEquivOfTranscendental_X :
    algEquivOfTranscendental f h (X : RatFunc K) = f := by
  simp [← algebraMap_X]

theorem algEquivOfTranscendental_apply (u : RatFunc K) :
    algEquivOfTranscendental f h u = aeval f u.num / aeval f u.denom := by
  conv_lhs => rw [← num_div_denom u]
  simp [-num_div_denom]

@[simp]
theorem algEquivOfTranscendental_symm_aeval (g : K[X]) :
    (algEquivOfTranscendental f h).symm (aeval (AdjoinSimple.gen _ f) g) = algebraMap _ _ g := by
  simp [algEquivOfTranscendental, ← algebraMap_eq_gen_self, aeval_algebraMap_apply]

@[simp]
theorem algEquivOfTranscendental_symm_gen :
    (algEquivOfTranscendental f h).symm (AdjoinSimple.gen _ f) = (X : RatFunc K) := by
  simp [algEquivOfTranscendental, ← algebraMap_eq_gen_self]

end algEquivOfTranscendental

section Algebra

variable [CommRing K] [IsDomain K]

lemma transcendental_X : Transcendental K (X : K⟮X⟯) := by
  rw [← RatFunc.algebraMap_X, transcendental_algebraMap_iff (algebraMap_injective K)]
  exact Polynomial.transcendental_X K

instance transcendental : Algebra.Transcendental K K⟮X⟯ := ⟨X, transcendental_X⟩

end Algebra

end RatFunc

section AdicValuation

variable (K : Type*) [Field K]

namespace Polynomial

open RatFunc

section HeightOneSpectrum

open IsDedekindDomain.HeightOneSpectrum WithZero

set_option linter.style.whitespace false in -- manual alignment is not recognised
/-- This is the principal ideal generated by `X` in the ring of polynomials over a field K,
  regarded as an element of the height-one-spectrum. -/

def idealX : IsDedekindDomain.HeightOneSpectrum K[X] where
  asIdeal := Ideal.span {X}
  isPrime := by rw [Ideal.span_singleton_prime]; exacts [Polynomial.prime_X, Polynomial.X_ne_zero]
  ne_bot  := by rw [ne_eq, Ideal.span_singleton_eq_bot]; exact Polynomial.X_ne_zero

@[simp]
theorem idealX_span : (idealX K).asIdeal = Ideal.span {X} := rfl

@[simp]
theorem valuation_X_eq_neg_one :
    (idealX K).valuation K⟮X⟯ RatFunc.X = exp (-1 : ℤ) := by
  rw [← RatFunc.algebraMap_X, valuation_of_algebraMap, intValuation_singleton
      _ (Polynomial.X_ne_zero) (idealX_span K)]

theorem valuation_of_mk (f g : Polynomial K) :
    (Polynomial.idealX K).valuation _ (RatFunc.mk f g) =
      (Polynomial.idealX K).intValuation f / (Polynomial.idealX K).intValuation g := by
  rcases eq_or_ne g 0 with rfl | hg
  · simp
  simp only [RatFunc.mk_eq_mk' _ hg, valuation_of_mk']

end HeightOneSpectrum

section TrivialOnConstants

variable {Γ : Type*} [LinearOrderedCommGroupWithZero Γ]

variable {v : Valuation K⟮X⟯ Γ} [hv : v.IsTrivialOn K]

open Valuation

/-- If a valuation `v` is trivial on constants then for every `n : ℕ` the valuation of
`(monomial n a)` is equal to `(v RatFunc.X) ^ n`. -/

lemma valuation_monomial_eq_valuation_X_pow (n : ℕ) {a : K} (ha : a ≠ 0) :
    v (monomial n a) = v RatFunc.X ^ n := by
  simp_all [← RatFunc.algebraMap_eq_C, hv.eq_one]

/-- If a valuation `v` is trivial on constants and `1 < v RatFunc.X` then for every polynomial `p`,
`v p = v RatFunc.X ^ p.natDegree`.

Note: The condition `1 < v RatFunc.X` is typically satisfied by the valuation at infinity. -/

theorem valuation_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X
     (hlt : 1 < v RatFunc.X) {p : K[X]} (hp : p ≠ 0) : v p = v RatFunc.X ^ p.natDegree := by
  convert! valuation_aeval_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X .X hlt hp
  ext p
  nth_rw 1 [RatFunc.X, ← aeval_X_left_apply p (R := K)]
  exact (aeval_algebraMap_apply K⟮X⟯ X p).symm


/-- If a valuation `v` is trivial on constants and `v RatFunc.X ≤ 1` then for every polynomial `p`,
`v p ≤ 1`. -/

theorem valuation_le_one_of_valuation_X_le_one (hle : v RatFunc.X ≤ 1) (p : K[X]) : v p ≤ 1 := by
  rw [as_sum_range p, RatFunc.coePolynomial, map_sum]
  apply map_sum_le v
  intro i
  by_cases h0 : p.coeff i = 0
  · simp_all
  · rw [← RatFunc.coePolynomial]
    simp_all [pow_le_one', ← RatFunc.algebraMap_eq_C, hv.eq_one _ h0]

/-- If a valuation `v` is trivial on constants then for every `n : ℕ` the valuation of
`1 / (monomial n a)` (as an element of the field of rational functions) is equal
to `(v RatFunc.X) ^ (- n)`. -/

lemma valuation_inv_monomial_eq_valuation_X_zpow (n : ℕ) {a : K} (ha : a ≠ 0) :
    v (1 / monomial n a) = v RatFunc.X ^ (-(n : ℤ)) := by
  simp [← RatFunc.algebraMap_eq_C, hv.eq_one _ ha]

end TrivialOnConstants

end Polynomial

namespace RatFunc

open scoped WithZero

open Polynomial

/-- We give this instance a name so that it can be locally disabled when defining `FqtInfty`.
Something similar might be needed after the refactor from `Valued` to `ValuativeRel`. -/

instance valuedRatFunc : Valued K⟮X⟯ ℤᵐ⁰ := Valued.mk' ((idealX K).valuation _)

@[simp]
theorem v_def {x : K⟮X⟯} :
    Valued.v x = (idealX K).valuation _ x := rfl

lemma valuation_surjective : Function.Surjective (Valued.v (R := RatFunc K)) := by
  intro n
  by_cases hn0 : n = 0
  · use 0; simp [hn0]
  · use (RatFunc.X ^ (-WithZero.log n))
    simp [WithZero.exp_log hn0]

end RatFunc

end AdicValuation

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland