Grace/Cumulus/AlgebraicGeometry/Coordinates/Lifting.g17

Open in Workbench Download source

Imports

Grace.Cumulus.AlgebraicGeometry.Coordinates.LiftingIdentities · Grace.Cumulus.Algebra.Algebras · Grace.Cumulus.Set.Function.Quadruples

Declarations

Source

1-- The lifting lemma: over a commutative ring B with elements h, x, y, s2-- satisfying the cusp relation x² + y³ = hs and Bézout coefficients3-- αh + βy = 1, the algebra B[U, V, W] ⧸ (U³ + hV − x, −U² + hW − y,4-- S(h, U, V, W) − s) is a polynomial algebra in one variable T over B, by5-- T = αU + β(V + UW) and the inverse formulas.6-- Part of Cumulus, the Grace17 mathematics library.7-- Copyright (c) 2026 Grant Passmore.8-- Released under the Apache License 2.0. See LICENSE in the repository root.9-- Authors: Grant Passmore1011module Grace.Cumulus.AlgebraicGeometry.Coordinates.Lifting12import Grace.Cumulus.AlgebraicGeometry.Coordinates.LiftingIdentities13import Grace.Cumulus.Algebra.Algebras14import Grace.Cumulus.Set.Function.Quadruples1516-- The relations.17section Relations18variable (B : Set)19hypothesis base : CommRing(B)20hypothesis polynomials : CommRing(polynomialRing(B, 3))2122-- The three relations in B[U, V, W], with U, V, W the variables 0, 1, 2.23def relX (h x : Set) : Set :=24  X(B, 3, 0)^3 + polynomialConstant(B, 3)(h)*X(B, 3, 1) -25    polynomialConstant(B, 3)(x)2627def relY (h y : Set) : Set :=28  -X(B, 3, 0)^2 + polynomialConstant(B, 3)(h)*X(B, 3, 2) -29    polynomialConstant(B, 3)(y)3031def relS (h s : Set) : Set :=32  Ring.sub(polynomialRing(B, 3),33    cuspS(polynomialRing(B, 3), polynomialConstant(B, 3)(h), X(B, 3, 0),34      X(B, 3, 1), X(B, 3, 2)),35    polynomialConstant(B, 3)(s))3637-- The relations are members of B[U, V, W].38instance relX.mem (h x : Set)39  requires hIn : h ∈ Ring.carrier(B)40  requires xIn : x ∈ Ring.carrier(B)41  shows relX(B, h, x) ∈ Ring.carrier(polynomialRing(B, 3))42proof43  unfold relX44  typecheck4546instance relY.mem (h y : Set)47  requires hIn : h ∈ Ring.carrier(B)48  requires yIn : y ∈ Ring.carrier(B)49  shows relY(B, h, y) ∈ Ring.carrier(polynomialRing(B, 3))50proof51  unfold relY52  typecheck5354instance relS.mem (h s : Set)55  requires hIn : h ∈ Ring.carrier(B)56  requires sIn : s ∈ Ring.carrier(B)57  shows relS(B, h, s) ∈ Ring.carrier(polynomialRing(B, 3))58proof59  unfold relS60  typecheck6162end Relations6364-- The presented algebra, the two homomorphisms, and the parameter.6566def liftingRelations (B h x y s : Set) : Set :=67  {relX(B, h, x), relY(B, h, y), relS(B, h, s)}6869def liftingIdeal (B h x y s : Set) : Set :=70  generatedIdeal(polynomialRing(B, 3), liftingRelations(B, h, x, y, s))7172-- The presented algebra Q = B[U, V, W] ⧸ (relX, relY, relS).73def liftingAlgebra (B h x y s : Set) : Set :=74  quotientAlgebra(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))7576-- The classes of U, V, W in the presented algebra.77def liftingVariable (B h x y s i : Set) : Set :=78  algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))(79    X(B, 3, i))8081-- The values of U, V, W in B[T] given by the inverse formulas, with T the82-- variable 0 of B[1].83def polyU (B h x β : Set) : Set :=84  inverseU(polynomialRing(B, 1), polynomialConstant(B, 1)(h),85    polynomialConstant(B, 1)(x), polynomialConstant(B, 1)(β), X(B, 1, 0))8687def polyG (B x y α : Set) : Set :=88  inverseG(polynomialRing(B, 1), polynomialConstant(B, 1)(x),89    polynomialConstant(B, 1)(y), polynomialConstant(B, 1)(α), X(B, 1, 0))9091def polyW (B h x y s α β : Set) : Set :=92  inverseW(polynomialRing(B, 1), polynomialConstant(B, 1)(h),93    polynomialConstant(B, 1)(y), polynomialConstant(B, 1)(s),94    polynomialConstant(B, 1)(α), polynomialConstant(B, 1)(β),95    polyU(B, h, x, β), polyG(B, x, y, α))9697def polyV (B h x y s α β : Set) : Set :=98  inverseV(polynomialRing(B, 1), polyU(B, h, x, β), polyG(B, x, y, α),99    polyW(B, h, x, y, s, α, β))100101def liftingValues (B h x y s α β : Set) : Set :=102  tripleMap(Ring.carrier(polynomialRing(B, 1)), polyU(B, h, x, β),103    polyV(B, h, x, y, s, α, β), polyW(B, h, x, y, s, α, β))104105-- Forward: Q → B[T], the evaluation at the inverse formulas, lifted.106def liftingForward (B h x y s α β : Set) : Set :=107  algebraLift(evaluationHom(B, polynomialRing(B, 1), 3,108      polynomialConstant(B, 1), liftingValues(B, h, x, y, s, α, β)),109    polynomialAlgebra(B, 3), polynomialAlgebra(B, 1),110    liftingIdeal(B, h, x, y, s))111112-- The parameter T = αU + β(V + UW) in Q.113def liftingParameter (B h x y s α β : Set) : Set :=114  parameter(Algebra.ring(liftingAlgebra(B, h, x, y, s)),115    Algebra.map(liftingAlgebra(B, h, x, y, s))(α),116    Algebra.map(liftingAlgebra(B, h, x, y, s))(β),117    liftingVariable(B, h, x, y, s, 0), liftingVariable(B, h, x, y, s, 1),118    liftingVariable(B, h, x, y, s, 2))119120-- Backward: B[T] → Q, the evaluation at the parameter.121def liftingBackward (B h x y s α β : Set) : Set :=122  evaluationHom(B, Algebra.ring(liftingAlgebra(B, h, x, y, s)), 1,123    Algebra.map(liftingAlgebra(B, h, x, y, s)),124    pointMap(algebraCarrier(liftingAlgebra(B, h, x, y, s)),125      liftingParameter(B, h, x, y, s, α, β)))126127-- The projections of the presented algebra, and the classes of the128-- variables as values of the projection.129theorem liftingAlgebra.base (B h x y s : Set)130  shows Algebra.base(liftingAlgebra(B, h, x, y, s)) = B131proof132  unfold liftingAlgebra133  rw [quotientAlgebra.baseOf, polynomialAlgebra.base]134135theorem liftingAlgebra.ring (B h x y s : Set)136  shows Algebra.ring(liftingAlgebra(B, h, x, y, s)) =137    quotientRing(polynomialRing(B, 3), liftingIdeal(B, h, x, y, s))138proof139  unfold liftingAlgebra140  rw [quotientAlgebra.ringOf, polynomialAlgebra.ring]141142theorem liftingProjection.variable (B h x y s i : Set)143  shows algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))(144    X(B, 3, i)) = liftingVariable(B, h, x, y, s, i)145proof146  simp [liftingVariable]147148-- The members and instances: Q is an algebra, its projection a149-- homomorphism that kills the relations, and the classes of the variables150-- and the constants are members of its ring.151section Members152variable (B h x y s : Set)153hypothesis base : CommRing(B)154hypothesis hIn : h ∈ Ring.carrier(B)155hypothesis xIn : x ∈ Ring.carrier(B)156hypothesis yIn : y ∈ Ring.carrier(B)157hypothesis sIn : s ∈ Ring.carrier(B)158159theorem liftingRelations.subset160  shows liftingRelations(B, h, x, y, s) ⊆161    algebraCarrier(polynomialAlgebra(B, 3))162proof163  have polynomials := polynomialRing.comm_ring at B, 3 with base164  have memberX := relX.mem at B, h, x with *165  have memberY := relY.mem at B, h, y with *166  have memberS := relS.mem at B, h, s with *167  intros g hg168  unfold liftingRelations at hg169  simp at hg170  rw (polynomialAlgebra.carrierOf at B, 3)171  rcases hg with hX | hY | hS172  . rw hX173    exact memberX174  . rw hY175    exact memberY176  . rw hS177    exact memberS178179theorem liftingIdeal.ideal180  shows Ideal(Algebra.ring(polynomialAlgebra(B, 3)),181    liftingIdeal(B, h, x, y, s))182proof183  have polynomials := polynomialRing.comm_ring at B, 3 with base184  rw polynomialAlgebra.ring185  unfold liftingIdeal186  exact generatedIdeal.ideal at _, liftingRelations(B, h, x, y, s)187    with polynomials188189theorem liftingAlgebra.algebra190  shows Algebra(liftingAlgebra(B, h, x, y, s))191proof192  have polynomial := polynomialAlgebra.algebra at B, 3 with base193  have ideal := liftingIdeal.ideal at B, h, x, y, s with *194  unfold liftingAlgebra195  exact quotientAlgebra.algebra with polynomial, ideal196197-- The projection onto the presented algebra: a function, a ring198-- homomorphism, an algebra homomorphism; it kills the relations and199-- carries the constants to the structure map.200theorem liftingProjection.function201  shows algebraProjection(polynomialAlgebra(B, 3),202      liftingIdeal(B, h, x, y, s)) :203    algebraCarrier(polynomialAlgebra(B, 3)) →204      algebraCarrier(liftingAlgebra(B, h, x, y, s))205proof206  have polynomial := polynomialAlgebra.algebra at B, 3 with base207  have ideal := liftingIdeal.ideal at B, h, x, y, s with *208  have function := algebraProjection.function with polynomial, ideal209  unfold liftingAlgebra210  rw quotientAlgebra.carrierOf211  exact function212213theorem liftingProjection.ring_hom214  shows algebraProjection(polynomialAlgebra(B, 3),215      liftingIdeal(B, h, x, y, s)) :216    polynomialRing(B, 3) →+* Algebra.ring(liftingAlgebra(B, h, x, y, s))217proof218  have polynomial := polynomialAlgebra.algebra at B, 3 with base219  have ideal := liftingIdeal.ideal at B, h, x, y, s with *220  have projection := algebraProjection.ring_hom with polynomial, ideal221  rw polynomialAlgebra.ring at projection222  rw liftingAlgebra.ring223  exact projection224225theorem liftingProjection.hom226  shows algebraProjection(polynomialAlgebra(B, 3),227      liftingIdeal(B, h, x, y, s)) :228    polynomialAlgebra(B, 3) →ₐ liftingAlgebra(B, h, x, y, s)229proof230  have polynomial := polynomialAlgebra.algebra at B, 3 with base231  have ideal := liftingIdeal.ideal at B, h, x, y, s with *232  unfold liftingAlgebra233  exact algebraProjection.hom with polynomial, ideal234235theorem liftingProjection.constant (a : Set)236  requires member : a ∈ Ring.carrier(B)237  shows algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))(238    polynomialConstant(B, 3)(a)) = Algebra.map(liftingAlgebra(B, h, x, y, s))(a)239proof240  have projection := liftingProjection.hom at B, h, x, y, s with *241  have inBase : a ∈ Ring.carrier(Algebra.base(polynomialAlgebra(B, 3)))242    rw polynomialAlgebra.base243    exact member244  have commutes := AlgebraHom.map_base with projection, inBase245  rw polynomialAlgebra.map at commutes246  exact commutes247248theorem liftingProjection.kills (g : Set)249  requires member : g ∈ liftingRelations(B, h, x, y, s)250  shows algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))(251    g) = Ring.zero(Algebra.ring(liftingAlgebra(B, h, x, y, s)))252proof253  have polynomial := polynomialAlgebra.algebra at B, 3 with base254  have generators := liftingRelations.subset at B, h, x, y, s with *255  have killed := algebraProjection.kills_generator256    with polynomial, generators, member257  rw polynomialAlgebra.ring at killed258  rw liftingAlgebra.ring259  unfold liftingIdeal260  exact killed261262theorem liftingAlgebra.structure_hom263  shows Algebra.map(liftingAlgebra(B, h, x, y, s)) :264    B →+* Algebra.ring(liftingAlgebra(B, h, x, y, s))265proof266  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *267  have raw := algebra.right.right.right268  rw liftingAlgebra.base at raw269  exact raw270271theorem liftingVariable.mem (i : Set)272  requires index : i ∈ 3273  shows liftingVariable(B, h, x, y, s, i) ∈274    Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s)))275proof276  have function := liftingProjection.function at B, h, x, y, s with *277  have member : X(B, 3, i) ∈ algebraCarrier(polynomialAlgebra(B, 3))278    rw (polynomialAlgebra.carrierOf at B, 3)279    exact X.mem at B, 3, i with base280  have image := FunctionBetween.apply_closed with function, member281  unfold algebraCarrier at image282  unfold liftingVariable283  exact image284285instance liftingU.mem286  shows liftingVariable(B, h, x, y, s, 0) ∈287    Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s)))288proof289  have zero : 0 ∈ 3 by simp [membership.three]290  exact liftingVariable.mem with zero, *291292instance liftingV.mem293  shows liftingVariable(B, h, x, y, s, 1) ∈294    Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s)))295proof296  have one : 1 ∈ 3 by simp [membership.three]297  exact liftingVariable.mem with one, *298299instance liftingW.mem300  shows liftingVariable(B, h, x, y, s, 2) ∈301    Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s)))302proof303  have two : 2 ∈ 3 by simp [membership.three]304  exact liftingVariable.mem with two, *305306instance liftingConstant.mem (a : Set)307  requires member : a ∈ Ring.carrier(B)308  shows Algebra.map(liftingAlgebra(B, h, x, y, s))(a) ∈309    Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s)))310proof311  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *312  have inBase : a ∈ Ring.carrier(Algebra.base(liftingAlgebra(B, h, x, y, s)))313    rw liftingAlgebra.base314    exact member315  exact Algebra.map_mem with algebra, inBase316317instance liftingAlgebra.comm_ring318  shows CommRing(Algebra.ring(liftingAlgebra(B, h, x, y, s)))319proof320  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *321  exact Algebra.comm_ring with algebra322323end Members324325-- The inverse formulas as members of B[T], the values as a function on 3,326-- and the evaluation at them as a homomorphism out of B[U, V, W].327section Values328variable (B h x y s α β : Set)329hypothesis base : CommRing(B)330hypothesis polynomials : CommRing(polynomialRing(B, 1))331hypothesis hIn : h ∈ Ring.carrier(B)332hypothesis xIn : x ∈ Ring.carrier(B)333hypothesis yIn : y ∈ Ring.carrier(B)334hypothesis sIn : s ∈ Ring.carrier(B)335hypothesis αIn : α ∈ Ring.carrier(B)336hypothesis βIn : β ∈ Ring.carrier(B)337338theorem polyU.mem339  shows polyU(B, h, x, β) ∈ Ring.carrier(polynomialRing(B, 1))340proof341  unfold polyU342  typecheck343344theorem polyG.mem345  shows polyG(B, x, y, α) ∈ Ring.carrier(polynomialRing(B, 1))346proof347  unfold polyG348  typecheck349350theorem polyW.mem351  shows polyW(B, h, x, y, s, α, β) ∈ Ring.carrier(polynomialRing(B, 1))352proof353  have first := polyU.mem at B, h, x, y, s, α, β with *354  have second := polyG.mem at B, h, x, y, s, α, β with *355  unfold polyW356  typecheck357358theorem polyV.mem359  shows polyV(B, h, x, y, s, α, β) ∈ Ring.carrier(polynomialRing(B, 1))360proof361  have first := polyU.mem at B, h, x, y, s, α, β with *362  have second := polyG.mem at B, h, x, y, s, α, β with *363  have third := polyW.mem at B, h, x, y, s, α, β with *364  unfold polyV365  typecheck366367theorem liftingValues.function368  shows liftingValues(B, h, x, y, s, α, β) :369    3 → Ring.carrier(polynomialRing(B, 1))370proof371  have first := polyU.mem at B, h, x, y, s, α, β with *372  have second := polyV.mem at B, h, x, y, s, α, β with *373  have third := polyW.mem at B, h, x, y, s, α, β with *374  unfold liftingValues375  exact tripleMap.function with first, second, third376377theorem liftingValues.value378  shows liftingValues(B, h, x, y, s, α, β)(0) = polyU(B, h, x, β) ∧379    liftingValues(B, h, x, y, s, α, β)(1) = polyV(B, h, x, y, s, α, β) ∧380    liftingValues(B, h, x, y, s, α, β)(2) = polyW(B, h, x, y, s, α, β)381proof382  have first := polyU.mem at B, h, x, y, s, α, β with *383  have second := polyV.mem at B, h, x, y, s, α, β with *384  have third := polyW.mem at B, h, x, y, s, α, β with *385  unfold liftingValues386  exact tripleMap.value with first, second, third387388theorem liftingEvaluation.hom389  shows evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),390      liftingValues(B, h, x, y, s, α, β)) :391    polynomialAlgebra(B, 3) →ₐ polynomialAlgebra(B, 1)392proof393  have polynomial := polynomialAlgebra.algebra at B, 1 with base394  have over := polynomialAlgebra.base at B, 1395  have assignment : liftingValues(B, h, x, y, s, α, β) : 3 →396      algebraCarrier(polynomialAlgebra(B, 1))397    rw (polynomialAlgebra.carrierOf at B, 1)398    exact liftingValues.function with *399  have hom := evaluationHom.algebra_hom at B, 3, polynomialAlgebra(B, 1),400    liftingValues(B, h, x, y, s, α, β) with base, polynomial, over, assignment401  rw [polynomialAlgebra.ring, polynomialAlgebra.map] at hom402  exact hom403404theorem liftingEvaluation.ring_hom405  shows evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),406      liftingValues(B, h, x, y, s, α, β)) :407    polynomialRing(B, 3) →+* polynomialRing(B, 1)408proof409  have constants := polynomialConstant.hom at B, 1 with base410  have assignment := liftingValues.function at B, h, x, y, s, α, β with *411  exact evaluationHom.hom at B, polynomialRing(B, 1), 3,412    polynomialConstant(B, 1), liftingValues(B, h, x, y, s, α, β)413    with base, polynomials, constants, assignment414415-- The cusp and Bézout relations carried into B[T] by the constants.416theorem liftingValues.cusp417  requires cusp : x^2 + y^3 = h*s418  shows polynomialConstant(B, 1)(x)^2 + polynomialConstant(B, 1)(y)^3 =419    polynomialConstant(B, 1)(h) * polynomialConstant(B, 1)(s)420proof421  have constants := polynomialConstant.hom at B, 1 with base422  exact RingHom.map_cusp at B, polynomialRing(B, 1), polynomialConstant(B, 1),423    h, x, y, s with base, polynomials, constants, cusp424425theorem liftingValues.bezout426  requires bezout : α*h + β*y = B[1]427  shows polynomialConstant(B, 1)(α) * polynomialConstant(B, 1)(h) +428    polynomialConstant(B, 1)(β) * polynomialConstant(B, 1)(y) =429    Ring.one(polynomialRing(B, 1))430proof431  have constants := polynomialConstant.hom at B, 1 with base432  exact RingHom.map_bezout at B, polynomialRing(B, 1),433    polynomialConstant(B, 1), h, y, α, β with base, polynomials, constants,434    bezout435436end Values437438-- The lifting lemma: the forward and backward homomorphisms are mutually439-- inverse, so Q ≅ B[T].440section Lifting441variable (B h x y s α β : Set)442hypothesis base : CommRing(B)443hypothesis hIn : h ∈ Ring.carrier(B)444hypothesis xIn : x ∈ Ring.carrier(B)445hypothesis yIn : y ∈ Ring.carrier(B)446hypothesis sIn : s ∈ Ring.carrier(B)447hypothesis αIn : α ∈ Ring.carrier(B)448hypothesis βIn : β ∈ Ring.carrier(B)449hypothesis cusp : x^2 + y^3 = h*s450hypothesis bezout : α*h + β*y = B[1]451hypothesis quotient : CommRing(Algebra.ring(liftingAlgebra(B, h, x, y, s)))452453-- The Bézout relation carried into Q by the structure map.454theorem liftingAlgebra.bezout455  shows Algebra.map(liftingAlgebra(B, h, x, y, s))(α) *456      Algebra.map(liftingAlgebra(B, h, x, y, s))(h) +457    Algebra.map(liftingAlgebra(B, h, x, y, s))(β) *458      Algebra.map(liftingAlgebra(B, h, x, y, s))(y) =459    Ring.one(Algebra.ring(liftingAlgebra(B, h, x, y, s)))460proof461  have structureMap := liftingAlgebra.structure_hom at B, h, x, y, s with *462  exact RingHom.map_bezout at B, Algebra.ring(liftingAlgebra(B, h, x, y, s)),463    Algebra.map(liftingAlgebra(B, h, x, y, s)), h, y, α, β464    with base, quotient, structureMap, bezout465466-- The parameter is a member of Q.467theorem liftingParameter.mem468  shows liftingParameter(B, h, x, y, s, α, β) ∈469    algebraCarrier(liftingAlgebra(B, h, x, y, s))470proof471  unfold liftingParameter472  unfold algebraCarrier473  typecheck474475-- The relations hold between the classes of U, V, W.476theorem liftingAlgebra.relations477  shows liftingVariable(B, h, x, y, s, 0)^3 +478      Algebra.map(liftingAlgebra(B, h, x, y, s))(h) *479        liftingVariable(B, h, x, y, s, 1) =480      Algebra.map(liftingAlgebra(B, h, x, y, s))(x) ∧481    -liftingVariable(B, h, x, y, s, 0)^2 +482      Algebra.map(liftingAlgebra(B, h, x, y, s))(h) *483        liftingVariable(B, h, x, y, s, 2) =484      Algebra.map(liftingAlgebra(B, h, x, y, s))(y) ∧485    cuspS(Algebra.ring(liftingAlgebra(B, h, x, y, s)),486      Algebra.map(liftingAlgebra(B, h, x, y, s))(h),487      liftingVariable(B, h, x, y, s, 0), liftingVariable(B, h, x, y, s, 1),488      liftingVariable(B, h, x, y, s, 2)) =489      Algebra.map(liftingAlgebra(B, h, x, y, s))(s)490proof491  have projection := liftingProjection.ring_hom at B, h, x, y, s with *492  have polynomials := polynomialRing.comm_ring at B, 3 with base493  have constantH := liftingProjection.constant at B, h, x, y, s, h with *494  have constantX := liftingProjection.constant at B, h, x, y, s, x with *495  have constantY := liftingProjection.constant at B, h, x, y, s, y with *496  have constantS := liftingProjection.constant at B, h, x, y, s, s with *497  have variableU := liftingProjection.variable at B, h, x, y, s, 0498  have variableV := liftingProjection.variable at B, h, x, y, s, 1499  have variableW := liftingProjection.variable at B, h, x, y, s, 2500  -- The projection kills each relation; push it through the relation.501  have memberX : relX(B, h, x) ∈ liftingRelations(B, h, x, y, s)502    unfold liftingRelations503    simp504  have memberY : relY(B, h, y) ∈ liftingRelations(B, h, x, y, s)505    unfold liftingRelations506    simp507  have memberS : relS(B, h, s) ∈ liftingRelations(B, h, x, y, s)508    unfold liftingRelations509    simp510  have killX := liftingProjection.kills at B, h, x, y, s, relX(B, h, x) with *511  have killY := liftingProjection.kills at B, h, x, y, s, relY(B, h, y) with *512  have killS := liftingProjection.kills at B, h, x, y, s, relS(B, h, s) with *513  unfold relX at killX514  unfold relY at killY515  unfold relS at killS516  simp [RingHom.map_sub, RingHom.map_add, RingHom.map_mul, RingHom.map_pow,517    constantH, constantX, variableU, variableV] at killX518  simp [RingHom.map_sub, RingHom.map_add, RingHom.map_neg, RingHom.map_mul,519    RingHom.map_pow, constantH, constantY, variableU, variableW] at killY520  simp [RingHom.map_sub, cuspS.map, constantH, constantS, variableU, variableV,521    variableW] at killS522  -- The value of S in Q is placed in the ring for linear_combination.523  have cuspIn : cuspS(Algebra.ring(liftingAlgebra(B, h, x, y, s)),524      Algebra.map(liftingAlgebra(B, h, x, y, s))(h),525      liftingVariable(B, h, x, y, s, 0), liftingVariable(B, h, x, y, s, 1),526      liftingVariable(B, h, x, y, s, 2)) ∈527      Ring.carrier(Algebra.ring(liftingAlgebra(B, h, x, y, s))) :=528    cuspS.mem with *529  constructor530  . linear_combination killX531  constructor532  . linear_combination killY533  . unfold cuspS at killS534    unfold cuspS535    linear_combination killS536537-- The inverse formulas satisfy the relations in B[T].538theorem liftingValues.relations539  shows evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),540      liftingValues(B, h, x, y, s, α, β))(relX(B, h, x)) =541      Ring.zero(polynomialRing(B, 1)) ∧542    evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),543      liftingValues(B, h, x, y, s, α, β))(relY(B, h, y)) =544      Ring.zero(polynomialRing(B, 1)) ∧545    evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),546      liftingValues(B, h, x, y, s, α, β))(relS(B, h, s)) =547      Ring.zero(polynomialRing(B, 1))548proof549  have polynomials := polynomialRing.comm_ring at B, 1 with base550  -- The constants and T are members of B[T], so ring can place the terms.551  have memberH : polynomialConstant(B, 1)(h) ∈552      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *553  have memberX : polynomialConstant(B, 1)(x) ∈554      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *555  have memberY : polynomialConstant(B, 1)(y) ∈556      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *557  have memberS : polynomialConstant(B, 1)(s) ∈558      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *559  have memberα : polynomialConstant(B, 1)(α) ∈560      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *561  have memberβ : polynomialConstant(B, 1)(β) ∈562      Ring.carrier(polynomialRing(B, 1)) := polynomialConstant.mem with *563  have memberT : X(B, 1, 0) ∈ Ring.carrier(polynomialRing(B, 1)) :=564    X.mem with *565  have constants := polynomialConstant.hom at B, 1 with base566  have assignment := liftingValues.function at B, h, x, y, s, α, β with *567  have evaluation := liftingEvaluation.ring_hom at B, h, x, y, s, α, β with *568  have zero : 0 ∈ 3 by simp [membership.three]569  have one : 1 ∈ 3 by simp [membership.three]570  have two : 2 ∈ 3 by simp [membership.three]571  obtain ⟨valueU, valueV, valueW⟩ :=572    liftingValues.value at B, h, x, y, s, α, β with *573  -- The relations hold in B[T] by inverse_relations over the constants.574  have cuspP := liftingValues.cusp at B, h, x, y, s, α, β with *575  have bezoutP := liftingValues.bezout at B, h, x, y, s, α, β with *576  obtain ⟨relationX, relationY, relationS⟩ := inverse_relations at577    polynomialRing(B, 1), polynomialConstant(B, 1)(h),578    polynomialConstant(B, 1)(x), polynomialConstant(B, 1)(y),579    polynomialConstant(B, 1)(s), polynomialConstant(B, 1)(α),580    polynomialConstant(B, 1)(β), X(B, 1, 0)581    with polynomials, cuspP, bezoutP582  unfold polyV at valueV583  unfold polyW at valueV, valueW584  unfold polyU at valueU, valueV, valueW585  unfold polyG at valueV, valueW586  constructor587  . unfold relX588    simp [RingHom.map_sub, RingHom.map_add, RingHom.map_mul, RingHom.map_pow,589      evaluationHom.map_constant, evaluationHom.map_X, valueU, valueV,590      relationX]591    rw Ring.sub.value592    ring593  constructor594  . unfold relY595    simp [RingHom.map_sub, RingHom.map_add, RingHom.map_neg, RingHom.map_mul,596      RingHom.map_pow, evaluationHom.map_constant, evaluationHom.map_X, valueU,597      valueW, relationY]598    rw Ring.sub.value599    ring600  . unfold relS601    simp [RingHom.map_sub, cuspS.map, evaluationHom.map_constant,602      evaluationHom.map_X, valueU, valueV, valueW, relationS]603    rw Ring.sub.value604    ring605606-- The evaluation kills the relations.607theorem liftingEvaluation.kills608  shows ∀ g ∈ liftingRelations(B, h, x, y, s),609    evaluationHom(B, polynomialRing(B, 1), 3, polynomialConstant(B, 1),610      liftingValues(B, h, x, y, s, α, β))(g) =611      Ring.zero(Algebra.ring(polynomialAlgebra(B, 1)))612proof613  obtain ⟨relationX, relationY, relationS⟩ :=614    liftingValues.relations at B, h, x, y, s, α, β with *615  intros g hg616  rw polynomialAlgebra.ring617  unfold liftingRelations at hg618  simp at hg619  rcases hg with hX | hY | hS620  . rw hX621    exact relationX622  . rw hY623    exact relationY624  . rw hS625    exact relationS626627-- The forward homomorphism, and its values on the classes of U, V, W.628theorem liftingForward.hom629  shows liftingForward(B, h, x, y, s, α, β) :630    liftingAlgebra(B, h, x, y, s) →ₐ polynomialAlgebra(B, 1)631proof632  have polynomial := polynomialAlgebra.algebra at B, 3 with base633  have generators := liftingRelations.subset at B, h, x, y, s with *634  have hom := liftingEvaluation.hom at B, h, x, y, s, α, β with *635  have killed := liftingEvaluation.kills at B, h, x, y, s, α, β with *636  have lifted := AlgebraHom.lift_generated637    with polynomial, generators, hom, killed638  rw polynomialAlgebra.ring at lifted639  unfold liftingForward640  unfold liftingAlgebra641  unfold liftingIdeal642  exact lifted643644theorem liftingForward.variable (i : Set)645  requires index : i ∈ 3646  shows liftingForward(B, h, x, y, s, α, β)(647    liftingVariable(B, h, x, y, s, i)) = liftingValues(B, h, x, y, s, α, β)(i)648proof649  have polynomial := polynomialAlgebra.algebra at B, 3 with base650  have generators := liftingRelations.subset at B, h, x, y, s with *651  have hom := liftingEvaluation.hom at B, h, x, y, s, α, β with *652  have killed := liftingEvaluation.kills at B, h, x, y, s, α, β with *653  have member : X(B, 3, i) ∈ algebraCarrier(polynomialAlgebra(B, 3))654    rw (polynomialAlgebra.carrierOf at B, 3)655    exact X.mem at B, 3, i with base656  have factors := AlgebraHom.lift_generated_factors with polynomial, generators,657    hom, killed, member658  rw polynomialAlgebra.ring at factors659  have polynomials := polynomialRing.comm_ring at B, 1 with base660  have constants := polynomialConstant.hom at B, 1 with base661  have assignment := liftingValues.function at B, h, x, y, s, α, β with *662  have value := evaluationHom.map_X at B, polynomialRing(B, 1), 3,663    polynomialConstant(B, 1), liftingValues(B, h, x, y, s, α, β), i664    with base, polynomials, constants, assignment, index665  unfold liftingForward666  unfold liftingVariable667  unfold liftingIdeal668  rw factors669  exact value670671-- The backward homomorphism, and its value on T.672theorem liftingBackward.hom673  shows liftingBackward(B, h, x, y, s, α, β) :674    polynomialAlgebra(B, 1) →ₐ liftingAlgebra(B, h, x, y, s)675proof676  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *677  have over := liftingAlgebra.base at B, h, x, y, s678  have parameterIn := liftingParameter.mem at B, h, x, y, s, α, β with *679  have values := pointMap.function with parameterIn680  unfold liftingBackward681  exact evaluationHom.algebra_hom with base, algebra, over, values682683theorem liftingBackward.variable684  shows liftingBackward(B, h, x, y, s, α, β)(X(B, 1, 0)) =685    liftingParameter(B, h, x, y, s, α, β)686proof687  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *688  have over := liftingAlgebra.base at B, h, x, y, s689  have parameterIn := liftingParameter.mem at B, h, x, y, s, α, β with *690  have values := pointMap.function with parameterIn691  have zero : 0 ∈ 1 by simp [membership.one]692  have value := evaluationHom.algebra_X at B, 1, liftingAlgebra(B, h, x, y, s),693    pointMap(algebraCarrier(liftingAlgebra(B, h, x, y, s)),694      liftingParameter(B, h, x, y, s, α, β)), 0695    with base, algebra, over, values, zero696  have point := pointMap.zero with parameterIn697  unfold liftingBackward698  rw value699  exact point700701-- The two homomorphisms on the constants, the forward one on the702-- parameter, and the backward one on the inverse formulas.703theorem liftingForward.constant (a : Set)704  requires member : a ∈ Ring.carrier(B)705  shows liftingForward(B, h, x, y, s, α, β)(706    Algebra.map(liftingAlgebra(B, h, x, y, s))(a)) = polynomialConstant(B, 1)(a)707proof708  have forward := liftingForward.hom at B, h, x, y, s, α, β with *709  have inBase : a ∈ Ring.carrier(Algebra.base(liftingAlgebra(B, h, x, y, s)))710    rw liftingAlgebra.base711    exact member712  have commutes := AlgebraHom.map_base with forward, inBase713  rw polynomialAlgebra.map at commutes714  exact commutes715716theorem liftingBackward.constant (a : Set)717  requires member : a ∈ Ring.carrier(B)718  shows liftingBackward(B, h, x, y, s, α, β)(polynomialConstant(B, 1)(a)) =719    Algebra.map(liftingAlgebra(B, h, x, y, s))(a)720proof721  have backward := liftingBackward.hom at B, h, x, y, s, α, β with *722  have inBase : a ∈ Ring.carrier(Algebra.base(polynomialAlgebra(B, 1)))723    rw polynomialAlgebra.base724    exact member725  have commutes := AlgebraHom.map_base with backward, inBase726  rw polynomialAlgebra.map at commutes727  exact commutes728729theorem liftingForward.parameter730  shows liftingForward(B, h, x, y, s, α, β)(731    liftingParameter(B, h, x, y, s, α, β)) = X(B, 1, 0)732proof733  have forwardHom := AlgebraHom.ring_hom734    with (liftingForward.hom at B, h, x, y, s, α, β with *)735  rw polynomialAlgebra.ring at forwardHom736  have polynomials := polynomialRing.comm_ring at B, 1 with base737  have zero : 0 ∈ 3 by simp [membership.three]738  have one : 1 ∈ 3 by simp [membership.three]739  have two : 2 ∈ 3 by simp [membership.three]740  have forwardU := liftingForward.variable at B, h, x, y, s, α, β, 0 with *741  have forwardV := liftingForward.variable at B, h, x, y, s, α, β, 1 with *742  have forwardW := liftingForward.variable at B, h, x, y, s, α, β, 2 with *743  obtain ⟨valueU, valueV, valueW⟩ :=744    liftingValues.value at B, h, x, y, s, α, β with *745  have constantα := liftingForward.constant at B, h, x, y, s, α, β, α with *746  have constantβ := liftingForward.constant at B, h, x, y, s, α, β, β with *747  have bezoutP := liftingValues.bezout at B, h, x, y, s, α, β with *748  -- The parameter goes to the parameter of the inverse formulas, which is749  -- T by inverse_parameter.750  unfold liftingParameter751  simp [parameter.map, constantα, constantβ, forwardU, forwardV, forwardW,752    valueU, valueV, valueW]753  unfold polyV754  unfold polyW755  unfold polyU756  unfold polyG757  exact inverse_parameter at polynomialRing(B, 1), polynomialConstant(B, 1)(h),758    polynomialConstant(B, 1)(x), polynomialConstant(B, 1)(y),759    polynomialConstant(B, 1)(s), polynomialConstant(B, 1)(α),760    polynomialConstant(B, 1)(β), X(B, 1, 0) with polynomials, bezoutP761762theorem liftingBackward.values763  shows liftingBackward(B, h, x, y, s, α, β)(polyU(B, h, x, β)) =764      liftingVariable(B, h, x, y, s, 0) ∧765    liftingBackward(B, h, x, y, s, α, β)(polyV(B, h, x, y, s, α, β)) =766      liftingVariable(B, h, x, y, s, 1) ∧767    liftingBackward(B, h, x, y, s, α, β)(polyW(B, h, x, y, s, α, β)) =768      liftingVariable(B, h, x, y, s, 2)769proof770  have backwardHom := AlgebraHom.ring_hom771    with (liftingBackward.hom at B, h, x, y, s, α, β with *)772  rw polynomialAlgebra.ring at backwardHom773  have polynomials := polynomialRing.comm_ring at B, 1 with base774  have constantH := liftingBackward.constant at B, h, x, y, s, α, β, h with *775  have constantX := liftingBackward.constant at B, h, x, y, s, α, β, x with *776  have constantY := liftingBackward.constant at B, h, x, y, s, α, β, y with *777  have constantS := liftingBackward.constant at B, h, x, y, s, α, β, s with *778  have constantα := liftingBackward.constant at B, h, x, y, s, α, β, α with *779  have constantβ := liftingBackward.constant at B, h, x, y, s, α, β, β with *780  have variableT := liftingBackward.variable at B, h, x, y, s, α, β with *781  -- The inverse formulas go to the inverse formulas at the parameter in782  -- Q, which return the classes of U, V, W by original_reconstruction.783  have bezoutQ := liftingAlgebra.bezout at B, h, x, y, s, α, β with *784  obtain ⟨relationX, relationY, relationS⟩ :=785    liftingAlgebra.relations at B, h, x, y, s, α, β with *786  obtain ⟨recoveredU, recoveredV, recoveredW⟩ := original_reconstruction at787    Algebra.ring(liftingAlgebra(B, h, x, y, s)),788    Algebra.map(liftingAlgebra(B, h, x, y, s))(h),789    Algebra.map(liftingAlgebra(B, h, x, y, s))(x),790    Algebra.map(liftingAlgebra(B, h, x, y, s))(y),791    Algebra.map(liftingAlgebra(B, h, x, y, s))(s),792    Algebra.map(liftingAlgebra(B, h, x, y, s))(α),793    Algebra.map(liftingAlgebra(B, h, x, y, s))(β),794    liftingVariable(B, h, x, y, s, 0), liftingVariable(B, h, x, y, s, 1),795    liftingVariable(B, h, x, y, s, 2)796    with quotient, bezoutQ, relationX, relationY, relationS797  unfold liftingParameter at variableT798  unfold polyV799  unfold polyW800  unfold polyU801  unfold polyG802  simp [inverseU.map, inverseG.map, inverseW.map, inverseV.map, constantH,803    constantX, constantY, constantS, constantα, constantβ, variableT,804    recoveredU, recoveredV, recoveredW]805806-- The main theorems: the composites are the identities, by the two807-- extensionality principles, and the forward map is an isomorphism.808809-- Forward after backward is the identity of B[T]: T goes to the parameter810-- and back to T by inverse_parameter.811theorem liftingForward.after_backward (p : Set)812  requires member : p ∈ Ring.carrier(polynomialRing(B, 1))813  shows liftingForward(B, h, x, y, s, α, β)(814    liftingBackward(B, h, x, y, s, α, β)(p)) = p815proof816  have forward := liftingForward.hom at B, h, x, y, s, α, β with *817  have backward := liftingBackward.hom at B, h, x, y, s, α, β with *818  have polynomial := polynomialAlgebra.algebra at B, 1 with base819  have composite := AlgebraHom.compose with backward, forward820  have identityHom := AlgebraHom.identity with polynomial821  have forwardFunction := AlgebraHom.function with forward822  have backwardFunction := AlgebraHom.function with backward823  have memberP : p ∈ algebraCarrier(polynomialAlgebra(B, 1))824    rw (polynomialAlgebra.carrierOf at B, 1)825    exact member826  -- The composite and the identity agree on the variable T.827  have agree : ∀ j ∈ 1,828      compose(liftingForward(B, h, x, y, s, α, β),829        liftingBackward(B, h, x, y, s, α, β),830        algebraCarrier(polynomialAlgebra(B, 1)),831        algebraCarrier(liftingAlgebra(B, h, x, y, s)),832        algebraCarrier(polynomialAlgebra(B, 1)))(X(B, 1, j)) =833      identity(algebraCarrier(polynomialAlgebra(B, 1)))(X(B, 1, j))834    intros j hj835    have index := membership.one.forward with hj836    rw index837    have memberT : X(B, 1, 0) ∈ algebraCarrier(polynomialAlgebra(B, 1))838      rw (polynomialAlgebra.carrierOf at B, 1)839      exact X.mem at B, 1, 0 with base840    rw compose.apply with backwardFunction, forwardFunction, memberT841    rw identity.apply with memberT842    rw (liftingBackward.variable at B, h, x, y, s, α, β with *)843    exact liftingForward.parameter at B, h, x, y, s, α, β with *844  have same := AlgebraHom.polynomial_ext845    with base, composite, identityHom, agree846  have composed := compose.apply with backwardFunction, forwardFunction, memberP847  have identityP := identity.apply with memberP848  rw ← composed849  rw same850  exact identityP851852-- Backward after forward is the identity of Q: the classes of U, V, W are853-- recovered from the parameter by original_reconstruction.854theorem liftingBackward.after_forward (q : Set)855  requires member : q ∈ algebraCarrier(liftingAlgebra(B, h, x, y, s))856  shows liftingBackward(B, h, x, y, s, α, β)(857    liftingForward(B, h, x, y, s, α, β)(q)) = q858proof859  have forward := liftingForward.hom at B, h, x, y, s, α, β with *860  have backward := liftingBackward.hom at B, h, x, y, s, α, β with *861  have algebra := liftingAlgebra.algebra at B, h, x, y, s with *862  have polynomial := polynomialAlgebra.algebra at B, 3 with base863  have ideal := liftingIdeal.ideal at B, h, x, y, s with *864  have projection := liftingProjection.hom at B, h, x, y, s with *865  have projectionFunction := liftingProjection.function at B, h, x, y, s with *866  have composite := AlgebraHom.compose with forward, backward867  have compositeFunction := AlgebraHom.function with composite868  have forwardFunction := AlgebraHom.function with forward869  have backwardFunction := AlgebraHom.function with backward870  have composed := AlgebraHom.compose with projection, composite871  have identityHom := AlgebraHom.identity with algebra872  obtain ⟨backU, backV, backW⟩ :=873    liftingBackward.values at B, h, x, y, s, α, β with *874  obtain ⟨valueU, valueV, valueW⟩ :=875    liftingValues.value at B, h, x, y, s, α, β with *876  unfold liftingVariable at backU, backV, backW877  -- The composite after the projection agrees with the projection on the878  -- variables U, V, W, hence on all of B[U, V, W].879  have agreeX : ∀ j ∈ 3,880      compose(compose(liftingBackward(B, h, x, y, s, α, β),881          liftingForward(B, h, x, y, s, α, β),882          algebraCarrier(liftingAlgebra(B, h, x, y, s)),883          algebraCarrier(polynomialAlgebra(B, 1)),884          algebraCarrier(liftingAlgebra(B, h, x, y, s))),885        algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s)),886        algebraCarrier(polynomialAlgebra(B, 3)),887        algebraCarrier(liftingAlgebra(B, h, x, y, s)),888        algebraCarrier(liftingAlgebra(B, h, x, y, s)))(X(B, 3, j)) =889      algebraProjection(polynomialAlgebra(B, 3), liftingIdeal(B, h, x, y, s))(890        X(B, 3, j))891    intros j hj892    have memberX : X(B, 3, j) ∈ algebraCarrier(polynomialAlgebra(B, 3))893      rw (polynomialAlgebra.carrierOf at B, 3)894      exact X.mem at B, 3, j with base895    have projected := FunctionBetween.apply_closed896      with projectionFunction, memberX897    rw compose.apply with projectionFunction, compositeFunction, memberX898    rw compose.apply with forwardFunction, backwardFunction, projected899    have forwardValue := liftingForward.variable at B, h, x, y, s, α, β, j900      with *901    unfold liftingVariable at forwardValue902    rw forwardValue903    have cases := membership.three.forward with hj904    rcases cases with rfl | rfl | rfl905    . rw valueU906      exact backU907    . rw valueV908      exact backV909    . rw valueW910      exact backW911  have sameHom := AlgebraHom.polynomial_ext912    with base, composed, projection, agreeX913  -- So the composite is the identity on every class, by quotient_ext.914  have agree : ∀ z ∈ algebraCarrier(polynomialAlgebra(B, 3)),915      compose(liftingBackward(B, h, x, y, s, α, β),916        liftingForward(B, h, x, y, s, α, β),917        algebraCarrier(liftingAlgebra(B, h, x, y, s)),918        algebraCarrier(polynomialAlgebra(B, 1)),919        algebraCarrier(liftingAlgebra(B, h, x, y, s)))(920        algebraProjection(polynomialAlgebra(B, 3),921          liftingIdeal(B, h, x, y, s))(z)) =922      identity(algebraCarrier(liftingAlgebra(B, h, x, y, s)))(923        algebraProjection(polynomialAlgebra(B, 3),924          liftingIdeal(B, h, x, y, s))(z))925    intros z hz926    have projected := FunctionBetween.apply_closed with projectionFunction, hz927    have step := compose.apply with projectionFunction, compositeFunction, hz928    rw identity.apply with projected929    rw ← step930    rw sameHom931  unfold liftingAlgebra at composite, identityHom, agree932  have same := AlgebraHom.quotient_ext with polynomial, ideal, composite,933    identityHom, agree934  have composedQ := compose.apply with forwardFunction, backwardFunction, member935  rw ← composedQ936  unfold liftingAlgebra937  unfold liftingAlgebra at member938  rw same939  exact identity.apply with member940941theorem lifting_equivalence942  shows liftingForward(B, h, x, y, s, α, β) :943    liftingAlgebra(B, h, x, y, s) ≃ₐ polynomialAlgebra(B, 1)944proof945  have forward := liftingForward.hom at B, h, x, y, s, α, β with *946  have backward := liftingBackward.hom at B, h, x, y, s, α, β with *947  have left : ∀ q ∈ algebraCarrier(liftingAlgebra(B, h, x, y, s)),948      liftingBackward(B, h, x, y, s, α, β)(949        liftingForward(B, h, x, y, s, α, β)(q)) = q950    intros q hq951    exact liftingBackward.after_forward at B, h, x, y, s, α, β, q with *952  have right : ∀ p ∈ algebraCarrier(polynomialAlgebra(B, 1)),953      liftingForward(B, h, x, y, s, α, β)(954        liftingBackward(B, h, x, y, s, α, β)(p)) = p955    intros p hp956    rw (polynomialAlgebra.carrierOf at B, 1) at hp957    exact liftingForward.after_backward at B, h, x, y, s, α, β, p with *958  exact AlgebraIso.of_inverse with forward, backward, left, right959960end Lifting961