Grace/Cumulus/Algebra/Algebras/Basic.g17

Open in Workbench Download source

Imports

Grace.Cumulus.Algebra.Ring

Declarations

Source

1-- Algebras over a commutative ring: a commutative ring with a structure map2-- from the base ring, their homomorphisms f : A →ₐ B, which are ring3-- homomorphisms commuting with the structure maps, and isomorphisms.4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Algebras.Basic10import Grace.Cumulus.Algebra.Ring1112-- The definitions.1314-- An algebra over its base: the base ring, the ring, and the structure map15-- from the base into the ring.16structure Algebra17  | base ring map : Set18  where19    base_ring : CommRing(base)20    ring_ring : CommRing(ring)21    structure_map : map : base →+* ring2223def algebraCarrier (A : Set) : Set := Ring.carrier(Algebra.ring(A))2425-- A homomorphism of algebras over one base: a ring homomorphism that26-- commutes with the structure maps.27predicate AlgebraHom (f A B : Set) :=28  Algebra(A) ∧ Algebra(B) ∧ Algebra.base(A) = Algebra.base(B) ∧29  RingHom(f, Algebra.ring(A), Algebra.ring(B)) ∧30  (∀ a ∈ Ring.carrier(Algebra.base(A)),31    f(Algebra.map(A)(a)) = Algebra.map(B)(a))3233predicate AlgebraIso (f A B : Set) :=34  AlgebraHom(f, A, B) ∧35  BijectiveBetween(f, algebraCarrier(A), algebraCarrier(B))3637notation guard "_ : _ →ₐ _" => AlgebraHom38notation guard "_ : _ ≃ₐ _" => AlgebraIso3940-- Restriction of scalars: an algebra over B is an algebra over K along a41-- homomorphism K →+* B.42def restrictScalars (A K ι : Set) : Set :=43  Algebra.mk(K, Algebra.ring(A),44    compose(Algebra.map(A), ι, Ring.carrier(K), Ring.carrier(Algebra.base(A)),45      algebraCarrier(A)))4647-- The members: what an algebra provides. The ring and the images of base48-- elements are instances, so that `typecheck`, `ring`, and the notation49-- place them without a destructuring of the algebra each time.50section Members51variable (A : Set)52hypothesis algebra : Algebra(A)5354instance Algebra.comm_ring55  shows CommRing(Algebra.ring(A))56proof57  exact algebra.right.right.left5859theorem Algebra.base_comm_ring60  shows CommRing(Algebra.base(A))61proof62  exact algebra.right.left6364theorem Algebra.structure_hom65  shows Algebra.map(A) : Algebra.base(A) →+* Algebra.ring(A)66proof67  exact algebra.right.right.right6869instance Algebra.map_mem (a : Set)70  requires member : a ∈ Ring.carrier(Algebra.base(A))71  shows Algebra.map(A)(a) ∈ Ring.carrier(Algebra.ring(A))72proof73  have structureMap := Algebra.structure_hom with algebra74  exact RingHom.map_mem with structureMap, member7576theorem Algebra.map_function77  shows Algebra.map(A) : Ring.carrier(Algebra.base(A)) → algebraCarrier(A)78proof79  obtain ⟨source, target, function, rest⟩ := Algebra.structure_hom with algebra80  unfold algebraCarrier81  exact function8283end Members8485-- The projections of the restriction of scalars.86theorem restrictScalars.base (A K ι : Set)87  shows Algebra.base(restrictScalars(A, K, ι)) = K88proof89  simp [restrictScalars, Algebra.mk.base]9091theorem restrictScalars.ring (A K ι : Set)92  shows Algebra.ring(restrictScalars(A, K, ι)) = Algebra.ring(A)93proof94  simp [restrictScalars, Algebra.mk.ring]9596theorem restrictScalars.map (A K ι : Set)97  shows Algebra.map(restrictScalars(A, K, ι)) =98    compose(Algebra.map(A), ι, Ring.carrier(K), Ring.carrier(Algebra.base(A)),99      algebraCarrier(A))100proof101  simp [restrictScalars, Algebra.mk.map]102103theorem restrictScalars.carrier (A K ι : Set)104  shows algebraCarrier(restrictScalars(A, K, ι)) = algebraCarrier(A)105proof106  unfold algebraCarrier107  rw restrictScalars.ring108109-- The parts of a homomorphism: its source and target algebras, the110-- common base, the underlying ring homomorphism and function, and the111-- commutation with the structure maps.112theorem AlgebraHom.source (f A B : Set)113  requires hom : f : A →ₐ B114  shows Algebra(A)115proof116  exact hom.left117118theorem AlgebraHom.target (f A B : Set)119  requires hom : f : A →ₐ B120  shows Algebra(B)121proof122  exact hom.right.left123124theorem AlgebraHom.base_eq (f A B : Set)125  requires hom : f : A →ₐ B126  shows Algebra.base(A) = Algebra.base(B)127proof128  exact hom.right.right.left129130theorem AlgebraHom.ring_hom (f A B : Set)131  requires hom : f : A →ₐ B132  shows f : Algebra.ring(A) →+* Algebra.ring(B)133proof134  exact hom.right.right.right.left135136theorem AlgebraHom.function (f A B : Set)137  requires hom : f : A →ₐ B138  shows f : algebraCarrier(A) → algebraCarrier(B)139proof140  obtain ⟨source, target, function, rest⟩ := AlgebraHom.ring_hom with hom141  unfold algebraCarrier142  exact function143144theorem AlgebraHom.map_base (f A B a : Set)145  requires hom : f : A →ₐ B146  requires member : a ∈ Ring.carrier(Algebra.base(A))147  shows f(Algebra.map(A)(a)) = Algebra.map(B)(a)148proof149  exact hom.right.right.right.right with a, member150151-- The category: identities and composites of homomorphisms.152theorem AlgebraHom.identity (A : Set)153  requires algebra : Algebra(A)154  shows identity(algebraCarrier(A)) : A →ₐ A155proof156  have ringRing := Algebra.comm_ring with algebra157  unfold AlgebraHom158  refine ⟨algebra, algebra, rfl, ?_, ?_⟩159  . unfold algebraCarrier160    exact RingHom.id with ringRing161  . intros a aIn162    have image := Algebra.map_mem with algebra, aIn163    unfold algebraCarrier164    exact identity.apply with image165166theorem AlgebraHom.compose (f g A B C : Set)167  requires first : f : A →ₐ B168  requires second : g : B →ₐ C169  shows compose(g, f, algebraCarrier(A), algebraCarrier(B), algebraCarrier(C)) :170    A →ₐ C171proof172  obtain ⟨algebraA, algebraB, sameBase, homF, commuteF⟩ := first173  obtain ⟨algebraB2, algebraC, sameBase2, homG, commuteG⟩ := second174  have ringRing := Algebra.comm_ring with algebraA175  have ringHom := RingHom.comp with ringRing, homF, homG176  have functionF := AlgebraHom.function with first177  have functionG := AlgebraHom.function with second178  unfold AlgebraHom179  refine ⟨algebraA, algebraC, ?_, ?_, ?_⟩180  . rw sameBase181    exact sameBase2182  . unfold algebraCarrier183    exact ringHom184  . intros a aIn185    have image : Algebra.map(A)(a) ∈ algebraCarrier(A)186      unfold algebraCarrier187      exact Algebra.map_mem with algebraA, aIn188    rw compose.apply with functionF, functionG, image189    rw AlgebraHom.map_base with first, aIn190    rw sameBase at aIn191    exact AlgebraHom.map_base with second, aIn192193-- Isomorphisms: from a two-sided inverse, their inverses, composites,194-- and identities.195196-- Two homomorphisms inverse to each other on the carriers are isomorphisms.197theorem AlgebraIso.of_inverse (f g A B : Set)198  requires forward : f : A →ₐ B199  requires backward : g : B →ₐ A200  requires left : ∀ x ∈ algebraCarrier(A), g(f(x)) = x201  requires right : ∀ y ∈ algebraCarrier(B), f(g(y)) = y202  shows f : A ≃ₐ B203proof204  have functionF := AlgebraHom.function with forward205  have functionG := AlgebraHom.function with backward206  have bijective := Bijective.of_two_sided_inverse with functionF, functionG,207    left, right208  unfold AlgebraIso209  exact ⟨forward, bijective⟩210211theorem AlgebraIso.inverse (f A B : Set)212  requires iso : f : A ≃ₐ B213  shows converse(f, algebraCarrier(A), algebraCarrier(B)) : B ≃ₐ A214proof215  obtain ⟨hom, bijective⟩ := iso216  obtain ⟨algebraA, algebraB, sameBase, ringHom, commute⟩ := hom217  have ringRingA := Algebra.comm_ring with algebraA218  have ringRingB := Algebra.comm_ring with algebraB219  unfold algebraCarrier at bijective220  have ringIso : f : A.ring ≃+* B.ring221    unfold RingIso222    exact ⟨ringHom, bijective⟩223  have inverseIso := RingIso.symm with ringRingA, ringRingB, ringIso224  have inverseHom := RingIso.hom_of with inverseIso225  unfold AlgebraIso226  unfold algebraCarrier227  constructor228  . unfold AlgebraHom229    refine ⟨algebraB, algebraA, ?_, inverseHom, ?_⟩230    . rw sameBase231    . intros a aIn232      rw ← sameBase at aIn233      have image := Algebra.map_mem with algebraA, aIn234      have forward := commute with a, aIn235      rw ← forward236      exact Bijective.inverse_apply with bijective, image237  . exact converse.bijective with bijective238239-- The inverse of an isomorphism, named on the carriers.240def algebraInverse (f A B : Set) : Set :=241  converse(f, algebraCarrier(A), algebraCarrier(B))242243theorem AlgebraIso.inverse_hom (f A B : Set)244  requires iso : f : A ≃ₐ B245  shows algebraInverse(f, A, B) : B →ₐ A246proof247  have inverse := AlgebraIso.inverse with iso248  unfold algebraInverse249  exact inverse.left250251theorem AlgebraIso.compose (f g A B C : Set)252  requires first : f : A ≃ₐ B253  requires second : g : B ≃ₐ C254  shows compose(g, f, algebraCarrier(A), algebraCarrier(B), algebraCarrier(C)) :255    A ≃ₐ C256proof257  obtain ⟨homF, bijectiveF⟩ := first258  obtain ⟨homG, bijectiveG⟩ := second259  have hom := AlgebraHom.compose with homF, homG260  have bijective := compose.bijective with bijectiveF, bijectiveG261  unfold AlgebraIso262  exact ⟨hom, bijective⟩263264theorem AlgebraIso.identity (A : Set)265  requires algebra : Algebra(A)266  shows identity(algebraCarrier(A)) : A ≃ₐ A267proof268  have hom := AlgebraHom.identity with algebra269  have bijective := identity.bijective at algebraCarrier(A)270  unfold AlgebraIso271  exact ⟨hom, bijective⟩272273-- Isomorphisms compose, as existence statements.274theorem AlgebraIso.exists_compose (A B C : Set)275  requires first : ∃ e, e : A ≃ₐ B276  requires second : ∃ f, f : B ≃ₐ C277  shows ∃ g, g : A ≃ₐ C278proof279  obtain ⟨e, eIso⟩ := first280  obtain ⟨f, fIso⟩ := second281  have composite := AlgebraIso.compose with eIso, fIso282  witness compose(f, e, algebraCarrier(A), algebraCarrier(B), algebraCarrier(C))283  exact composite284285-- Restriction of scalars is an algebra, and homomorphisms over B are286-- homomorphisms over K.287theorem restrictScalars.algebra (A K ι : Set)288  requires algebra : Algebra(A)289  requires base : CommRing(K)290  requires scalars : ι : K →+* Algebra.base(A)291  shows Algebra(restrictScalars(A, K, ι))292proof293  have ringRing := Algebra.comm_ring with algebra294  have structureMap := Algebra.structure_hom with algebra295  have composite := RingHom.comp with base, scalars, structureMap296  unfold restrictScalars297  unfold algebraCarrier298  exact Algebra.intro with base, ringRing, composite299300theorem AlgebraHom.restrict (f A B K ι : Set)301  requires hom : f : A →ₐ B302  requires base : CommRing(K)303  requires scalars : ι : K →+* Algebra.base(A)304  shows f : restrictScalars(A, K, ι) →ₐ restrictScalars(B, K, ι)305proof306  obtain ⟨algebraA, algebraB, sameBase, ringHom, commute⟩ := hom307  have scalarsB : ι : K →+* Algebra.base(B)308    rw ← sameBase309    exact scalars310  have restrictedA := restrictScalars.algebra with algebraA, base, scalars311  have restrictedB := restrictScalars.algebra with algebraB, base, scalarsB312  obtain ⟨sourceK, targetA, functionI, restI⟩ := scalars313  obtain ⟨sourceK2, targetB, functionIB, restIB⟩ := scalarsB314  have functionA := Algebra.map_function with algebraA315  have functionB := Algebra.map_function with algebraB316  unfold AlgebraHom317  refine ⟨restrictedA, restrictedB, ?_, ?_, ?_⟩318  . rw [restrictScalars.base, restrictScalars.base]319  . rw [restrictScalars.ring, restrictScalars.ring]320    exact ringHom321  . intros a aIn322    rw restrictScalars.base at aIn323    rw [restrictScalars.map, restrictScalars.map]324    have image := RingHom.map_mem with scalars, aIn325    rw compose.apply with functionI, functionA, aIn326    rw compose.apply with functionIB, functionB, aIn327    exact AlgebraHom.map_base with hom, image328329theorem AlgebraIso.restrict (f A B K ι : Set)330  requires iso : f : A ≃ₐ B331  requires base : CommRing(K)332  requires scalars : ι : K →+* Algebra.base(A)333  shows f : restrictScalars(A, K, ι) ≃ₐ restrictScalars(B, K, ι)334proof335  obtain ⟨hom, bijective⟩ := iso336  have restricted := AlgebraHom.restrict with hom, base, scalars337  unfold AlgebraIso338  rw [restrictScalars.carrier, restrictScalars.carrier]339  exact ⟨restricted, bijective⟩340341-- A homomorphism into an algebra is one into any algebra with the same342-- base, ring, and structure map values.343theorem AlgebraHom.transfer (f X A B : Set)344  requires hom : f : X →ₐ B345  requires algebra : Algebra(A)346  requires base : Algebra.base(B) = Algebra.base(A)347  requires ring : Algebra.ring(B) = Algebra.ring(A)348  requires map : ∀ a ∈ Ring.carrier(Algebra.base(A)),349    Algebra.map(B)(a) = Algebra.map(A)(a)350  shows f : X →ₐ A351proof352  obtain ⟨algebraX, algebraB, sameBase, ringHom, commute⟩ := hom353  unfold AlgebraHom354  refine ⟨algebraX, algebra, ?_, ?_, ?_⟩355  . rw sameBase356    exact base357  . rw ← ring358    exact ringHom359  . intros a aIn360    have value := commute with a, aIn361    rw [sameBase, base] at aIn362    rw value363    exact map with a, aIn364