Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Basic.lean   Sprache: Lean

 

/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/

module

public import Mathlib.Algebra.MvPolynomial.Counit
public import Mathlib.Algebra.MvPolynomial.Invertible
public import Mathlib.RingTheory.WittVector.Defs

/-!
# Witt vectors

This file verifies that the ring operations on `WittVector p R`
satisfy the axioms of a commutative ring.

## Main definitions

* `WittVector.map`: lifts a ring homomorphism `R →+* S` to a ring homomorphism `�� R →+* �� S`.
* `WittVector.ghostComponent n x`: evaluates the `n`th Witt polynomial
  on the first `n` coefficients of `x`, producing a value in `R`.
  This is a ring homomorphism.
* `WittVector.ghostMap`: a ring homomorphism `�� R →+* (ℕ → R)`, obtained by packaging
  all the ghost components together.
  If `p` is invertible in `R`, then the ghost map is an equivalence,
  which we use to define the ring operations on `�� R`.
* `WittVector.CommRing`: the ring structure induced by the ghost components.

## Notation

We use notation `�� R`, entered `\bbW`, for the Witt vectors over `R`.

## Implementation details

As we prove that the ghost components respect the ring operations, we face a number of repetitive
proofs. To avoid duplicating code we factor these proofs into a custom tactic, only slightly more
powerful than a tactic macro. This tactic is not particularly useful outside of its applications
in this file.

## References

* [Hazewinkel, *Witt Vectors*][Haze09]

* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]
-/


@[expose] public section


noncomputable section

open MvPolynomial Function

variable {p : ℕ} {R S : Type*} [CommRing R] [CommRing S]
variable {α : Type*} {β : Type*}

local notation "��" => WittVector p
local notation "W_" => wittPolynomial p

-- type as `\bbW`
open scoped Witt

namespace WittVector

/-- `f : α → β` induces a map from `�� α` to `�� β` by applying `f` componentwise.
If `f` is a ring homomorphism, then so is `f`, see `WittVector.map f`. -/

def mapFun (f : α → β) : �� α → �� β := fun x => mk _ (f ∘ x.coeff)

namespace mapFun

theorem injective (f : α → β) (hf : Injective f) : Injective (mapFun f : �� α → �� β) :=
  fun _ _ h => ext fun n => hf congr(coeff $h n)

theorem surjective (f : α → β) (hf : Surjective f) : Surjective (mapFun f : �� α → �� β) := fun x =>
  ⟨mk _ fun n => Classical.choose <| hf <| x.coeff n,
    by ext n; simp only [mapFun, coeff_mk, comp_apply, Classical.choose_spec (hf (x.coeff n))]⟩

/-- Auxiliary tactic for showing that `mapFun` respects the ring operations. -/
local macro "map_fun_tac" : tactic => `(tactic| (
  -- TODO: the Lean 3 version of this tactic was more functional
  ext n
  simp only [mapFun, mk, comp_apply, zero_coeff, map_zero,
    -- the lemmas on the next line do not have the `simp` tag in mathlib4
    add_coeff, sub_coeff, mul_coeff, neg_coeff, nsmul_coeff, zsmul_coeff, pow_coeff,
    peval, map_aeval, algebraMap_int_eq, coe_eval₂Hom] <;>
  try { cases n <;> simp <;> done } <;> -- this line solves `one`
  apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl <;>
  ext ⟨i, k⟩ <;>
    fin_cases i <;> rfl))

variable [Fact p.Prime]
-- Porting note: using `(x y : �� R)` instead of `(x y : WittVector p R)` produced sorries.
variable (f : R →+* S) (x y : WittVector p R)

--  and until `pow`.
-- We do not tag these lemmas as `@[simp]` because they will be bundled in `map` later on.
theorem zero : mapFun f (0 : �� R) = 0 := by map_fun_tac

theorem one : mapFun f (1 : �� R) = 1 := by map_fun_tac

theorem add : mapFun f (x + y) = mapFun f x + mapFun f y := by map_fun_tac

theorem sub : mapFun f (x - y) = mapFun f x - mapFun f y := by map_fun_tac

theorem mul : mapFun f (x * y) = mapFun f x * mapFun f y := by map_fun_tac

theorem neg : mapFun f (-x) = -mapFun f x := by map_fun_tac

theorem nsmul (n : ℕ) (x : WittVector p R) : mapFun f (n • x) = n • mapFun f x := by map_fun_tac

theorem zsmul (z : ℤ) (x : WittVector p R) : mapFun f (z • x) = z • mapFun f x := by map_fun_tac

theorem pow (n : ℕ) : mapFun f (x ^ n) = mapFun f x ^ n := by map_fun_tac

theorem natCast (n : ℕ) : mapFun f (n : �� R) = n :=
  show mapFun f n.unaryCast = (n : WittVector p S) by
    induction n <;> simp [*, Nat.unaryCast, add, one, zero] <;> rfl

theorem intCast (n : ℤ) : mapFun f (n : �� R) = n :=
  show mapFun f n.castDef = (n : WittVector p S) by
    cases n <;> simp [*, Int.castDef, neg, natCast] <;> rfl

end mapFun

end WittVector

namespace WittVector

set_option backward.privateInPublic true in
/-- Evaluates the `n`th Witt polynomial on the first `n` coefficients of `x`,
producing a value in `R`.
This function will be bundled as the ring homomorphism `WittVector.ghostMap`
once the ring structure is available,
but we rely on it to set up the ring structure in the first place. -/

private def ghostFun : �� R → ℕ → R := fun x n => aeval x.coeff (W_ ℤ n)

section Tactic
open Lean Elab Tactic

/-- An auxiliary tactic for proving that `ghostFun` respects the ring operations. -/
elab "ghost_fun_tac " φ:term ", " fn:term : tactic => do
  evalTactic (← `(tactic| (
  ext n
  have := congr_fun (congr_arg (@peval R _ _) (wittStructureInt_prop p $φ n)) $fn
  simp only [wittZero, OfNat.ofNat, Zero.zero, wittOne, One.one,
    HAdd.hAdd, Add.add, HSub.hSub, Sub.sub, Neg.neg, HMul.hMul, Mul.mul, HPow.hPow, Pow.pow,
    wittNSMul, wittZSMul, HSMul.hSMul, SMul.smul]
  simpa +unfoldPartialApp [WittVector.ghostFun, aeval_rename, aeval_bind₁,
    comp, uncurry, peval, eval] using! this
  )))

end Tactic

section GhostFun

-- The following lemmas are not `@[simp]` because they will be bundled in `ghostMap` later on.

@[local simp]
theorem matrix_vecEmpty_coeff {R} (i j) :
    @coeff p R (Matrix.vecEmpty i) j = (Matrix.vecEmpty i : ℕ → R) j := by
  rcases i with ⟨_ | _ | _ | _ | i_val, ⟨⟩⟩

variable [Fact p.Prime]
variable (x y : WittVector p R)

set_option backward.privateInPublic true in
private theorem ghostFun_zero : ghostFun (0 : �� R) = 0 := by
  ghost_fun_tac 0, ![]

set_option backward.privateInPublic true in
private theorem ghostFun_one : ghostFun (1 : �� R) = 1 := by
  ghost_fun_tac 1, ![]

set_option backward.privateInPublic true in
private theorem ghostFun_add : ghostFun (x + y) = ghostFun x + ghostFun y := by
  ghost_fun_tac X 0 + X 1, ![x.coeff, y.coeff]

private theorem ghostFun_natCast (i : ℕ) : ghostFun (i : �� R) = i :=
  show ghostFun i.unaryCast = _ by
    induction i <;> simp [*, Nat.unaryCast, ghostFun_zero, ghostFun_one, ghostFun_add]

private theorem ghostFun_sub : ghostFun (x - y) = ghostFun x - ghostFun y := by
  ghost_fun_tac X 0 - X 1, ![x.coeff, y.coeff]

set_option backward.privateInPublic true in
private theorem ghostFun_mul : ghostFun (x * y) = ghostFun x * ghostFun y := by
  ghost_fun_tac X 0 * X 1, ![x.coeff, y.coeff]

private theorem ghostFun_neg : ghostFun (-x) = -ghostFun x := by ghost_fun_tac -X 0, ![x.coeff]

private theorem ghostFun_intCast (i : ℤ) : ghostFun (i : �� R) = i :=
  show ghostFun i.castDef = _ by
    cases i <;> simp [*, Int.castDef, ghostFun_natCast, ghostFun_neg]

private lemma ghostFun_nsmul (m : ℕ) (x : WittVector p R) : ghostFun (m • x) = m • ghostFun x := by
  ghost_fun_tac m • (X 0), ![x.coeff]

private lemma ghostFun_zsmul (m : ℤ) (x : WittVector p R) : ghostFun (m • x) = m • ghostFun x := by
  ghost_fun_tac m • (X 0), ![x.coeff]

private theorem ghostFun_pow (m : ℕ) : ghostFun (x ^ m) = ghostFun x ^ m := by
  ghost_fun_tac X 0 ^ m, ![x.coeff]

end GhostFun

variable (p) (R)

set_option backward.privateInPublic true in
/-- The bijection between `�� R` and `ℕ → R`, under the assumption that `p` is invertible in `R`.
In `WittVector.ghostEquiv` we upgrade this to an isomorphism of rings. -/

private def ghostEquiv' [Invertible (p : R)] : �� R ≃ (ℕ → R) where
  toFun := ghostFun
  invFun x := mk p fun n => aeval x (xInTermsOfW p R n)
  left_inv := by
    intro x
    ext n
    have := bind₁_wittPolynomial_xInTermsOfW p R n
    apply_fun aeval x.coeff at this
    simpa +unfoldPartialApp only [aeval_bind₁, aeval_X, ghostFun,
      aeval_wittPolynomial]
  right_inv := by
    intro x
    ext n
    have := bind₁_xInTermsOfW_wittPolynomial p R n
    apply_fun aeval x at this
    simpa only [aeval_bind₁, aeval_X, ghostFun, aeval_wittPolynomial]

variable [Fact p.Prime]

private local instance comm_ring_aux₁ : CommRing (�� (MvPolynomial R ℚ)) :=
  (ghostEquiv' p (MvPolynomial R ℚ)).injective.commRing ghostFun ghostFun_zero ghostFun_one
    ghostFun_add ghostFun_mul ghostFun_neg ghostFun_sub ghostFun_nsmul ghostFun_zsmul
    ghostFun_pow ghostFun_natCast ghostFun_intCast

set_option backward.privateInPublic true in
private local instance comm_ring_aux₂ : CommRing (�� (MvPolynomial R ℤ)) :=
  (mapFun.injective _ <| map_injective (Int.castRingHom ℚ) Int.cast_injective).commRing _
    (mapFun.zero _) (mapFun.one _) (mapFun.add _) (mapFun.mul _) (mapFun.neg _) (mapFun.sub _)
    (mapFun.nsmul _) (mapFun.zsmul _) (mapFun.pow _) (mapFun.natCast _) (mapFun.intCast _)

/-- The commutative ring structure on `�� R`. -/
instance : CommRing (�� R) :=
  (mapFun.surjective _ <| counit_surjective _).commRing (mapFun <| MvPolynomial.counit _)
    (mapFun.zero _) (mapFun.one _) (mapFun.add _) (mapFun.mul _) (mapFun.neg _) (mapFun.sub _)
    (mapFun.nsmul _) (mapFun.zsmul _) (mapFun.pow _) (mapFun.natCast _) (mapFun.intCast _)

variable {p R}

/-- `WittVector.map f` is the ring homomorphism `�� R →+* �� S` naturally induced
by a ring homomorphism `f : R →+* S`. It acts coefficientwise. -/

noncomputable def map (f : R →+* S) : �� R →+* �� S where
  toFun := mapFun f
  map_zero' := mapFun.zero f
  map_one' := mapFun.one f
  map_add' := mapFun.add f
  map_mul' := mapFun.mul f

theorem map_injective (f : R →+* S) (hf : Injective f) : Injective (map f : �� R → �� S) :=
  mapFun.injective f hf

theorem map_surjective (f : R →+* S) (hf : Surjective f) : Surjective (map f : �� R → �� S) :=
  mapFun.surjective f hf

@[simp]
theorem map_coeff (f : R →+* S) (x : �� R) (n : ℕ) : (map f x).coeff n = f (x.coeff n) :=
  rfl

variable (R) in
@[simp]
theorem map_id : WittVector.map (RingHom.id R) = RingHom.id (�� R) := by
  ext; simp

theorem map_eq_zero_iff (f : R →+* S) {x : WittVector p R} :
    ((map f) x) = 0 ↔ ∀ n, f (x.coeff n) = 0 := by
  refine ⟨fun h n ↦ ?_, fun h ↦ ?_⟩
  · apply_fun (·.coeff n) at h
    simpa using h
  · ext n
    simpa using h n

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
/-- `WittVector.ghostMap` is a ring homomorphism that maps each Witt vector
to the sequence of its ghost components. -/

def ghostMap : �� R →+* ℕ → R where
  toFun := ghostFun
  map_zero' := ghostFun_zero
  map_one' := ghostFun_one
  map_add' := ghostFun_add
  map_mul' := ghostFun_mul

/-- Evaluates the `n`th Witt polynomial on the first `n` coefficients of `x`,
producing a value in `R`. -/

def ghostComponent (n : ℕ) : �� R →+* R :=
  (Pi.evalRingHom _ n).comp ghostMap

theorem ghostComponent_apply (n : ℕ) (x : �� R) : ghostComponent n x = aeval x.coeff (W_ ℤ n) :=
  rfl

theorem pow_dvd_ghostComponent_of_dvd_coeff {x : �� R} {n : ℕ}
    (hx : ∀ i ≤ n, (p : R) ∣ x.coeff i) : (p : R) ^ (n + 1) ∣ ghostComponent n x := by
  rw [WittVector.ghostComponent_apply, wittPolynomial, MvPolynomial.aeval_sum]
  apply Finset.dvd_sum
  intro i hi
  simp only [Finset.mem_range] at hi
  have : (MvPolynomial.aeval x.coeff) ((MvPolynomial.monomial (R := ℤ)
      (Finsupp.single i (p ^ (n - i)))) (p ^ i)) = ((p : R) ^ i) * (x.coeff i) ^ (p ^ (n - i)) := by
    simp [MvPolynomial.aeval_monomial, map_pow]
  rw [this, show n + 1 = (n - i) + 1 + i by lia, pow_add, mul_comm]
  gcongr
  · exact hx i (Nat.le_of_lt_succ hi)
  · exact ((n - i).lt_two_pow_self).succ_le.trans
        (pow_left_mono (n - i) (Nat.Prime.two_le Fact.out))

@[simp]
theorem ghostMap_apply (x : �� R) (n : ℕ) : ghostMap x n = ghostComponent n x :=
  rfl

section Invertible

variable (p R)
variable [Invertible (p : R)]

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
/-- `WittVector.ghostMap` is a ring isomorphism when `p` is invertible in `R`. -/
def ghostEquiv : �� R ≃+* (ℕ → R) :=
  { (ghostMap : �� R →+* ℕ → R), ghostEquiv' p R with }

@[simp]
theorem ghostEquiv_coe : (ghostEquiv p R : �� R →+* ℕ → R) = ghostMap :=
  rfl

theorem ghostMap.bijective_of_invertible : Function.Bijective (ghostMap : �� R → ℕ → R) :=
  (ghostEquiv p R).bijective

end Invertible

/-- `WittVector.coeff x 0` as a `RingHom` -/
@[simps]
noncomputable def constantCoeff : �� R →+* R where
  toFun x := x.coeff 0
  map_zero' := by simp
  map_one' := by simp
  map_add' := add_coeff_zero
  map_mul' := mul_coeff_zero

instance [Nontrivial R] : Nontrivial (�� R) :=
  constantCoeff.domain_nontrivial

end WittVector

Messung
CHZG
9010010096

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,113
#Domains=863,199