import Mathlib.LinearAlgebra.TensorProduct.Map import Mathlib.LinearAlgebra.Prod /-! # Kernel Detector Tensor -/ namespace OAI.AlgebraicGeometry.AbelianModuli.ReferenceFamily.KernelDetectorTensor noncomputable section /-! A left inverse to the unit detects a tensor differential's kernel whenever that kernel is generated by the tensor unit map. -/ open scoped TensorProduct theorem tensor_kernel_detector_injective {R M N A : Type} [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] [AddCommGroup A] [Module R A] (d : M →ₗ[R] N) (s : M →ₗ[R] R) (u : R →ₗ[R] M) (hs : s.comp u = LinearMap.id) (hex : (d.lTensor A).ker = (u.lTensor A).range) : Function.Injective ((d.prod s).lTensor A) := by apply LinearMap.ker_eq_bot.mp apply bot_unique intro x hx have he : (d.prod s).lTensor A x = 0 := hx have hfst : (LinearMap.fst R N R).comp (d.prod s) = d := rfl have hsnd : (LinearMap.snd R N R).comp (d.prod s) = s := rfl have hdX : d.lTensor A x = 0 := by rw [← hfst, LinearMap.lTensor_comp, LinearMap.comp_apply, he, map_zero] have hsX : s.lTensor A x = 0 := by rw [← hsnd, LinearMap.lTensor_comp, LinearMap.comp_apply, he, map_zero] have hm : x ∈ (u.lTensor A).range := hex ▸ hdX obtain ⟨y, hy⟩ := hm have hsu := congrArg (fun f : Module.End R R => f.lTensor A) hs rw [LinearMap.lTensor_comp, LinearMap.lTensor_id] at hsu have hy0 : y = 0 := by have hv := LinearMap.congr_fun hsu y rw [LinearMap.comp_apply, hy, hsX, LinearMap.id_apply] at hv exact hv.symm change x = 0 rw [← hy, hy0, map_zero] end end OAI.AlgebraicGeometry.AbelianModuli.ReferenceFamily.KernelDetectorTensor