|
| 1 | +/- |
| 2 | +Copyright (c) 2026 Oliver Nash. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Oliver Nash, Jon Bannon |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.Algebra.BigOperators.Fin |
| 9 | +public import Mathlib.Algebra.Exact.Basic |
| 10 | +public import Mathlib.LinearAlgebra.Dimension.Constructions |
| 11 | +public import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas |
| 12 | + |
| 13 | +/-! # Exactness of sequences |
| 14 | +
|
| 15 | +In this file we provide some API for handling exact sequences. |
| 16 | +
|
| 17 | +## Main definitions / results: |
| 18 | +
|
| 19 | +* `Module.sum_neg_one_pow_finrank_eq_zero_of_exact`: the Euler characteristic of a finite exact |
| 20 | + sequence is zero. |
| 21 | +
|
| 22 | +## TODO |
| 23 | +
|
| 24 | +Write a simproc to generate unrolled, universe-polymorphic versions of |
| 25 | +`Module.sum_neg_one_pow_finrank_eq_zero_of_exact` on the fly and so obviate the need for |
| 26 | +`Module.sum_neg_one_pow_finrank_eq_zero_of_exact_six`. |
| 27 | +
|
| 28 | +-/ |
| 29 | + |
| 30 | +universe u₀ u₁ u₂ u₃ u₄ u₅ |
| 31 | + |
| 32 | +namespace Module |
| 33 | + |
| 34 | +open Function |
| 35 | + |
| 36 | +variable {k : Type*} [DivisionRing k] |
| 37 | + |
| 38 | +/-- The Euler characteristic of a finite exact sequence is zero. -/ |
| 39 | +public lemma sum_neg_one_pow_finrank_eq_zero_of_exact {n : ℕ} (V : Fin (n + 2) → Type*) |
| 40 | + [∀ i, AddCommGroup (V i)] [∀ i, Module k (V i)] [∀ i, FiniteDimensional k (V i)] |
| 41 | + (f : (i : Fin (n + 1)) → V i.castSucc →ₗ[k] V i.succ) |
| 42 | + (inj : Injective (f 0)) |
| 43 | + (h_exact : ∀ i : Fin n, Exact (f i.castSucc) (f i.succ)) |
| 44 | + (surj : Surjective (f (Fin.last _))) : |
| 45 | + ∑ i, (-1) ^ i.val * (finrank k (V i) : ℤ) = 0 := by |
| 46 | + replace inj := LinearMap.finrank_range_of_inj inj |
| 47 | + replace surj := LinearMap.range_eq_top.mpr surj |
| 48 | + simp_rw [← smul_eq_mul] |
| 49 | + refine Fin.sum_neg_one_pow_eq_zero _ (fun i ↦ finrank k (f i).range) ?_ (fun i ↦ ?_) ?_ |
| 50 | + · aesop |
| 51 | + · grind [(h_exact i).linearMap_ker_eq, (f i.succ).finrank_range_add_finrank_ker] |
| 52 | + · grind [finrank_top] |
| 53 | + |
| 54 | +/- An unrolled version of `Module.sum_neg_one_pow_finrank_eq_zero_of_exact`. This is an auxiliary |
| 55 | +lemma en route to `Module.sum_neg_one_pow_finrank_eq_zero_of_exact_six`. -/ |
| 56 | +private lemma sum_neg_one_pow_finrank_eq_zero_of_exact_six_aux {V₀ V₁ V₂ V₃ V₄ V₅ : Type u₀} |
| 57 | + [AddCommGroup V₀] [Module k V₀] [FiniteDimensional k V₀] |
| 58 | + [AddCommGroup V₁] [Module k V₁] [FiniteDimensional k V₁] |
| 59 | + [AddCommGroup V₂] [Module k V₂] [FiniteDimensional k V₂] |
| 60 | + [AddCommGroup V₃] [Module k V₃] [FiniteDimensional k V₃] |
| 61 | + [AddCommGroup V₄] [Module k V₄] [FiniteDimensional k V₄] |
| 62 | + [AddCommGroup V₅] [Module k V₅] [FiniteDimensional k V₅] |
| 63 | + (f₀ : V₀ →ₗ[k] V₁) (f₁ : V₁ →ₗ[k] V₂) (f₂ : V₂ →ₗ[k] V₃) (f₃ : V₃ →ₗ[k] V₄) (f₄ : V₄ →ₗ[k] V₅) |
| 64 | + (inj : Injective f₀) |
| 65 | + (exact₁ : Exact f₀ f₁) |
| 66 | + (exact₂ : Exact f₁ f₂) |
| 67 | + (exact₃ : Exact f₂ f₃) |
| 68 | + (exact₄ : Exact f₃ f₄) |
| 69 | + (surj : Surjective f₄) : |
| 70 | + (finrank k V₀ : ℤ) - finrank k V₁ + finrank k V₂ - |
| 71 | + finrank k V₃ + finrank k V₄ - finrank k V₅ = 0 := by |
| 72 | + letI Vs := ![V₀, V₁, V₂, V₃, V₄, V₅] |
| 73 | + letI (i : Fin 6) : AddCommGroup (Vs i) := match i with |
| 74 | + | 0 => ‹_› | 1 => ‹_› | 2 => ‹_› | 3 => ‹_› | 4 => ‹_› | 5 => ‹_› |
| 75 | + letI (i : Fin 6) : Module k (Vs i) := match i with |
| 76 | + | 0 => ‹_› | 1 => ‹_› | 2 => ‹_› | 3 => ‹_› | 4 => ‹_› | 5 => ‹_› |
| 77 | + have (i : Fin 6) : FiniteDimensional k (Vs i) := match i with |
| 78 | + | 0 => ‹_› | 1 => ‹_› | 2 => ‹_› | 3 => ‹_› | 4 => ‹_› | 5 => ‹_› |
| 79 | + letI fs (i : Fin 5) : Vs i.castSucc →ₗ[k] Vs i.succ := match i with |
| 80 | + | 0 => f₀ | 1 => f₁ | 2 => f₂ | 3 => f₃ | 4 => f₄ |
| 81 | + simpa [Fin.sum_univ_six] using Module.sum_neg_one_pow_finrank_eq_zero_of_exact Vs fs inj |
| 82 | + (fun i ↦ by fin_cases i; exacts [exact₁, exact₂, exact₃, exact₄]) surj |
| 83 | + |
| 84 | +/-- This is an unrolled, universe-polymorphic version of |
| 85 | +`Module.sum_neg_one_pow_finrank_eq_zero_of_exact`. This special case exists because of the role that |
| 86 | +this lemma plays in the proof of `LinearMap.index_comp`. |
| 87 | +
|
| 88 | +In theory one could write a `simproc` which conjured up this lemma for a sequence of any length and |
| 89 | +then one would not need to have this special-case lemma at all. -/ |
| 90 | +public lemma sum_neg_one_pow_finrank_eq_zero_of_exact_six |
| 91 | + {V₀ : Type u₀} [AddCommGroup V₀] [Module k V₀] [FiniteDimensional k V₀] |
| 92 | + {V₁ : Type u₁} [AddCommGroup V₁] [Module k V₁] [FiniteDimensional k V₁] |
| 93 | + {V₂ : Type u₂} [AddCommGroup V₂] [Module k V₂] [FiniteDimensional k V₂] |
| 94 | + {V₃ : Type u₃} [AddCommGroup V₃] [Module k V₃] [FiniteDimensional k V₃] |
| 95 | + {V₄ : Type u₄} [AddCommGroup V₄] [Module k V₄] [FiniteDimensional k V₄] |
| 96 | + {V₅ : Type u₅} [AddCommGroup V₅] [Module k V₅] [FiniteDimensional k V₅] |
| 97 | + (f₀ : V₀ →ₗ[k] V₁) (f₁ : V₁ →ₗ[k] V₂) (f₂ : V₂ →ₗ[k] V₃) (f₃ : V₃ →ₗ[k] V₄) (f₄ : V₄ →ₗ[k] V₅) |
| 98 | + (inj : Injective f₀) |
| 99 | + (exact₁ : Exact f₀ f₁) |
| 100 | + (exact₂ : Exact f₁ f₂) |
| 101 | + (exact₃ : Exact f₂ f₃) |
| 102 | + (exact₄ : Exact f₃ f₄) |
| 103 | + (surj : Surjective f₄) : |
| 104 | + (finrank k V₀ : ℤ) - finrank k V₁ + finrank k V₂ - |
| 105 | + finrank k V₃ + finrank k V₄ - finrank k V₅ = 0 := by |
| 106 | + let W₀ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₀ |
| 107 | + let W₁ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₁ |
| 108 | + let W₂ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₂ |
| 109 | + let W₃ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₃ |
| 110 | + let W₄ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₄ |
| 111 | + let W₅ := ULift.{max u₀ u₁ u₂ u₃ u₄ u₅} V₅ |
| 112 | + let g₀ : W₀ →ₗ[k] W₁ := ULift.moduleEquiv.symm.toLinearMap ∘ₗ f₀ ∘ₗ ULift.moduleEquiv.toLinearMap |
| 113 | + let g₁ : W₁ →ₗ[k] W₂ := ULift.moduleEquiv.symm.toLinearMap ∘ₗ f₁ ∘ₗ ULift.moduleEquiv.toLinearMap |
| 114 | + let g₂ : W₂ →ₗ[k] W₃ := ULift.moduleEquiv.symm.toLinearMap ∘ₗ f₂ ∘ₗ ULift.moduleEquiv.toLinearMap |
| 115 | + let g₃ : W₃ →ₗ[k] W₄ := ULift.moduleEquiv.symm.toLinearMap ∘ₗ f₃ ∘ₗ ULift.moduleEquiv.toLinearMap |
| 116 | + let g₄ : W₄ →ₗ[k] W₅ := ULift.moduleEquiv.symm.toLinearMap ∘ₗ f₄ ∘ₗ ULift.moduleEquiv.toLinearMap |
| 117 | + have := sum_neg_one_pow_finrank_eq_zero_of_exact_six_aux g₀ g₁ g₂ g₃ g₄ |
| 118 | + (inj := by simpa [g₀]) (surj := by simpa [g₄]) |
| 119 | + simp only [W₀, W₁, W₂, W₃, W₄, W₅, finrank_ulift] at this |
| 120 | + apply this <;> |
| 121 | + simpa only [g₀, g₁, g₂, g₃, g₄, LinearEquiv.postcomp_exact_iff_exact, |
| 122 | + LinearEquiv.conj_symm_exact_iff_exact, LinearEquiv.precomp_exact_iff_exact] |
| 123 | + |
| 124 | +end Module |
0 commit comments