|
| 1 | +/- |
| 2 | +Copyright (c) 2024 Daniel Weber. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Daniel Weber |
| 5 | +-/ |
| 6 | +import Mathlib.RingTheory.Derivation.Basic |
| 7 | + |
| 8 | +/-! |
| 9 | +# Differential and Algebras |
| 10 | +
|
| 11 | +This file defines derivations from a commutative ring to itself as a typeclass, which lets us |
| 12 | +use the x′ notation for the derivative of x. |
| 13 | +-/ |
| 14 | + |
| 15 | +/-- A derivation from a ring to itself, as a typeclass. -/ |
| 16 | +class Differential (R : Type*) [CommRing R] where |
| 17 | + /-- The `Derivation` assosiated with the ring. -/ |
| 18 | + deriv : Derivation ℤ R R |
| 19 | + |
| 20 | +@[inherit_doc] |
| 21 | +scoped[Differential] postfix:max "′" => Differential.deriv |
| 22 | + |
| 23 | +open scoped Differential |
| 24 | + |
| 25 | +open Lean PrettyPrinter Delaborator SubExpr in |
| 26 | +/-- |
| 27 | +A delaborator for the x′ notation. This is required because it's not direct function application, |
| 28 | +so the default delaborator doesn't work. |
| 29 | +-/ |
| 30 | +@[delab app.DFunLike.coe] |
| 31 | +def delabDeriv : Delab := do |
| 32 | + let e ← getExpr |
| 33 | + guard <| e.isAppOfArity' ``DFunLike.coe 6 |
| 34 | + guard <| (e.getArg!' 4).isAppOf' ``Differential.deriv |
| 35 | + let arg ← withAppArg delab |
| 36 | + `($arg′) |
| 37 | + |
| 38 | +/-- |
| 39 | +A differential algebra is an `Algebra` where the derivation commutes with `algebraMap`. |
| 40 | +-/ |
| 41 | +class DifferentialAlgebra (A B : Type*) [CommRing A] [CommRing B] [Algebra A B] |
| 42 | + [Differential A] [Differential B] : Prop where |
| 43 | + deriv_algebraMap : ∀ a : A, (algebraMap A B a)′ = algebraMap A B a′ |
| 44 | + |
| 45 | +export DifferentialAlgebra (deriv_algebraMap) |
| 46 | + |
| 47 | +@[norm_cast] |
| 48 | +lemma algebraMap.coe_deriv {A : Type*} {B : Type*} [CommRing A] [CommRing B] [Algebra A B] |
| 49 | + [Differential A] [Differential B] [DifferentialAlgebra A B] (a : A) : |
| 50 | + (a′ : A) = (a : B)′ := |
| 51 | + (DifferentialAlgebra.deriv_algebraMap _).symm |
| 52 | + |
| 53 | +/-- |
| 54 | +A differential ring `A` and an algebra over it `B` share constants if all |
| 55 | +constants in B are in the range of `algberaMap A B`. |
| 56 | +-/ |
| 57 | +class Differential.ContainConstants (A B : Type*) [CommRing A] [CommRing B] |
| 58 | + [Algebra A B] [Differential B] : Prop where |
| 59 | + /-- If the derivative of x is 0, then it's in the range of `algberaMap A B`. -/ |
| 60 | + protected mem_range_of_deriv_eq_zero {x : B} (h : x′ = 0) : x ∈ (algebraMap A B).range |
| 61 | + |
| 62 | +lemma mem_range_of_deriv_eq_zero (A : Type*) {B : Type*} [CommRing A] [CommRing B] [Algebra A B] |
| 63 | + [Differential B] [Differential.ContainConstants A B] {x : B} (h : x′ = 0) : |
| 64 | + x ∈ (algebraMap A B).range := |
| 65 | + Differential.ContainConstants.mem_range_of_deriv_eq_zero h |
| 66 | + |
| 67 | +instance (A : Type*) [CommRing A] [Differential A] : DifferentialAlgebra A A where |
| 68 | + deriv_algebraMap _ := rfl |
| 69 | + |
| 70 | +instance (A : Type*) [CommRing A] [Differential A] : Differential.ContainConstants A A where |
| 71 | + mem_range_of_deriv_eq_zero {x} _ := ⟨x, rfl⟩ |
| 72 | + |
| 73 | +/-- Transfer a `Differential` instance accross a `RingEquiv`. -/ |
| 74 | +@[reducible] |
| 75 | +def Differential.equiv {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂] |
| 76 | + (h : R ≃+* R₂) : Differential R := |
| 77 | + ⟨Derivation.mk' (h.symm.toAddMonoidHom.toIntLinearMap ∘ₗ |
| 78 | + Differential.deriv.toLinearMap ∘ₗ h.toAddMonoidHom.toIntLinearMap) (by simp)⟩ |
| 79 | + |
| 80 | +/-- |
| 81 | +Transfer a `DifferentialAlgebra` instance accross a `AlgEquiv`. |
| 82 | +-/ |
| 83 | +lemma DifferentialAlgebra.equiv {A : Type*} [CommRing A] [Differential A] |
| 84 | + {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂] [Algebra A R] |
| 85 | + [Algebra A R₂] [DifferentialAlgebra A R₂] (h : R ≃ₐ[A] R₂) : |
| 86 | + letI := Differential.equiv h.toRingEquiv |
| 87 | + DifferentialAlgebra A R := |
| 88 | + letI := Differential.equiv h.toRingEquiv |
| 89 | + ⟨fun a ↦ by |
| 90 | + change (LinearMap.comp ..) _ = _ |
| 91 | + simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.toAddMonoidHom_eq_coe, |
| 92 | + RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, LinearMap.coe_comp, |
| 93 | + AddMonoidHom.coe_toIntLinearMap, AddMonoidHom.coe_coe, RingHom.coe_coe, Derivation.coeFn_coe, |
| 94 | + Function.comp_apply, AlgEquiv.commutes, deriv_algebraMap] |
| 95 | + apply h.symm.commutes⟩ |
0 commit comments