Grace/Cumulus/AlgebraicGeometry/Coordinates/Plane.g17

Open in Workbench Download source

Imports

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

Declarations

Source

1-- The plane presentation: over a commutative ring K, the algebra2-- K[h, x, y, s] ⧸ (h − 1 − P(x, y, s), x² + y³ − sh) is the polynomial3-- algebra K[2], by x ↦ X₀ − S³, y ↦ X₁ + S², s ↦ S = X₀² + X₁³,4-- h ↦ 1 + P, with the inverse X₀ ↦ x + s³, X₁ ↦ y − s².5-- Part of Cumulus, the Grace17 mathematics library.6-- Copyright (c) 2026 Grant Passmore.7-- Released under the Apache License 2.0. See LICENSE in the repository root.8-- Authors: Grant Passmore910module Grace.Cumulus.AlgebraicGeometry.Coordinates.Plane11import Grace.Cumulus.AlgebraicGeometry.Coordinates.Identities12import Grace.Cumulus.Algebra.Algebras13import Grace.Cumulus.Set.Function.Quadruples1415-- The relations.1617section Relations18variable (K : Set)19hypothesis base : CommRing(K)20hypothesis polynomials : CommRing(polynomialRing(K, 4))2122-- The relations in K[h, x, y, s], with h, x, y, s the variables 0, 1, 2, 3.23def relH : Set :=24  X(K, 4, 0) - Ring.one(polynomialRing(K, 4)) -25    shiftP(polynomialRing(K, 4), X(K, 4, 1), X(K, 4, 2), X(K, 4, 3))2627def relCusp : Set := X(K, 4, 1)^2 + X(K, 4, 2)^3 - X(K, 4, 3)*X(K, 4, 0)2829instance relH.mem30  shows relH(K) ∈ Ring.carrier(polynomialRing(K, 4))31proof32  unfold relH33  typecheck3435instance relCusp.mem36  shows relCusp(K) ∈ Ring.carrier(polynomialRing(K, 4))37proof38  unfold relCusp39  typecheck4041end Relations4243-- The images of the relations under a ring homomorphism out of K[4].44section RelationTransport45variable (K S f : Set)46hypothesis base : CommRing(K)47hypothesis target : CommRing(S)48hypothesis hom : f : polynomialRing(K, 4) →+* S4950theorem RingHom.map_relH51  shows f(relH(K)) = f(X(K, 4, 0)) - Ring.one(S) -52    shiftP(S, f(X(K, 4, 1)), f(X(K, 4, 2)), f(X(K, 4, 3)))53proof54  have polynomials := polynomialRing.comm_ring at K, 4 with base55  have shift := RingHom.map_shiftP at polynomialRing(K, 4), S, f, X(K, 4, 1),56    X(K, 4, 2), X(K, 4, 3) with *57  have one := RingHom.map_one with hom58  unfold relH59  simp [RingHom.map_sub, one, shift]6061theorem RingHom.map_relCusp62  shows f(relCusp(K)) =63    f(X(K, 4, 1))^2 + f(X(K, 4, 2))^3 - f(X(K, 4, 3))*f(X(K, 4, 0))64proof65  have polynomials := polynomialRing.comm_ring at K, 4 with base66  unfold relCusp67  simp [RingHom.map_sub, RingHom.map_add, RingHom.map_mul, RingHom.map_pow]6869end RelationTransport7071-- The presented algebra and the forward map.7273def planeRelations (K : Set) : Set := {relH(K), relCusp(K)}7475def planeIdeal (K : Set) : Set :=76  generatedIdeal(polynomialRing(K, 4), planeRelations(K))7778-- The presented algebra K[h, x, y, s] ⧸ (relH, relCusp).79def planeAlgebra (K : Set) : Set :=80  quotientAlgebra(polynomialAlgebra(K, 4), planeIdeal(K))8182-- The classes of h, x, y, s.83def planeVariable (K i : Set) : Set :=84  algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K))(X(K, 4, i))8586section Values87variable (K : Set)88hypothesis base : CommRing(K)89hypothesis plane : CommRing(polynomialRing(K, 2))9091-- The images of s, x, y, h in K[2].92def planeS : Set := X(K, 2, 0)^2 + X(K, 2, 1)^39394instance planeS.mem95  shows planeS(K) ∈ Ring.carrier(polynomialRing(K, 2))96proof97  unfold planeS98  typecheck99100def planeX : Set := X(K, 2, 0) - planeS(K)^3101102instance planeX.mem103  shows planeX(K) ∈ Ring.carrier(polynomialRing(K, 2))104proof105  unfold planeX106  typecheck107108def planeY : Set := X(K, 2, 1) + planeS(K)^2109110instance planeY.mem111  shows planeY(K) ∈ Ring.carrier(polynomialRing(K, 2))112proof113  unfold planeY114  typecheck115116def planeH : Set :=117  Ring.one(polynomialRing(K, 2)) +118    shiftP(polynomialRing(K, 2), planeX(K), planeY(K), planeS(K))119120instance planeH.mem121  shows planeH(K) ∈ Ring.carrier(polynomialRing(K, 2))122proof123  unfold planeH124  typecheck125126end Values127128-- The values of h, x, y, s, as a function on 4.129def planeValues (K : Set) : Set :=130  quadrupleMap(Ring.carrier(polynomialRing(K, 2)), planeH(K), planeX(K),131    planeY(K), planeS(K))132133-- Forward: the presented algebra to K[2], the evaluation at the values,134-- lifted.135def planeForward (K : Set) : Set :=136  algebraLift(137    evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),138      planeValues(K)),139    polynomialAlgebra(K, 4), polynomialAlgebra(K, 2), planeIdeal(K))140141-- The members and instances.142143section Members144variable (K : Set)145hypothesis base : CommRing(K)146147-- The relations lie in K[4], and the plane ideal is the ideal of the148-- polynomial algebra they generate.149theorem planeRelations.subset150  shows planeRelations(K) ⊆ algebraCarrier(polynomialAlgebra(K, 4))151proof152  have relH := relH.mem with *153  have relCusp := relCusp.mem with *154  rw polynomialAlgebra.carrierOf155  unfold planeRelations156  intros g hg157  simp [pair.membership] at hg158  rcases hg with rfl | rfl159  . exact relH160  . exact relCusp161162theorem planeIdeal.generated163  shows planeIdeal(K) =164    generatedIdeal(Algebra.ring(polynomialAlgebra(K, 4)), planeRelations(K))165proof166  unfold planeIdeal167  rw polynomialAlgebra.ring168169theorem planeIdeal.ideal170  shows Ideal(Algebra.ring(polynomialAlgebra(K, 4)), planeIdeal(K))171proof172  have ring := polynomialRing.comm_ring at K, 4 with base173  rw polynomialAlgebra.ring174  unfold planeIdeal175  exact generatedIdeal.ideal with ring176177-- The presented algebra is an algebra over K with a commutative ring.178theorem planeAlgebra.algebra179  shows Algebra(planeAlgebra(K))180proof181  have polynomial := polynomialAlgebra.algebra at K, 4 with base182  have ideal := planeIdeal.ideal with base183  unfold planeAlgebra184  exact quotientAlgebra.algebra with polynomial, ideal185186theorem planeAlgebra.over187  shows Algebra.base(planeAlgebra(K)) = K188proof189  unfold planeAlgebra190  rw quotientAlgebra.baseOf191  exact polynomialAlgebra.base at K, 4192193instance planeAlgebra.comm_ring194  shows CommRing(Algebra.ring(planeAlgebra(K)))195proof196  have algebra := planeAlgebra.algebra with base197  exact Algebra.comm_ring with algebra198199-- The four classes lie in the presented algebra.200theorem planeVariable.mem (i : Set)201  requires index : i ∈ 4202  shows planeVariable(K, i) ∈ Ring.carrier(Algebra.ring(planeAlgebra(K)))203proof204  have polynomial := polynomialAlgebra.algebra at K, 4 with base205  have ideal := planeIdeal.ideal with base206  have function := algebraProjection.function with polynomial, ideal207  have member : X(K, 4, i) ∈ algebraCarrier(polynomialAlgebra(K, 4))208    rw polynomialAlgebra.carrierOf209    exact X.mem at K, 4, i with base210  unfold planeAlgebra211  rw quotientAlgebra.ringOf212  unfold planeVariable213  exact FunctionBetween.apply_closed with function, member214215instance planeH.class_mem216  shows planeVariable(K, 0) ∈ Ring.carrier(Algebra.ring(planeAlgebra(K)))217proof218  have zero : 0 ∈ 4 by simp [membership.four]219  exact planeVariable.mem with base, zero220221instance planeX.class_mem222  shows planeVariable(K, 1) ∈ Ring.carrier(Algebra.ring(planeAlgebra(K)))223proof224  have one : 1 ∈ 4 by simp [membership.four]225  exact planeVariable.mem with base, one226227instance planeY.class_mem228  shows planeVariable(K, 2) ∈ Ring.carrier(Algebra.ring(planeAlgebra(K)))229proof230  have two : 2 ∈ 4 by simp [membership.four]231  exact planeVariable.mem with base, two232233instance planeS.class_mem234  shows planeVariable(K, 3) ∈ Ring.carrier(Algebra.ring(planeAlgebra(K)))235proof236  have three : 3 ∈ 4 by simp [membership.four]237  exact planeVariable.mem with base, three238239end Members240241-- The projection onto the presented algebra.242243section Projection244variable (K : Set)245hypothesis base : CommRing(K)246247-- The projection of K[4] onto the presented algebra is a ring248-- homomorphism killing the relations.249theorem planeProjection.hom250  shows algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K)) :251    polynomialRing(K, 4) →+* Algebra.ring(planeAlgebra(K))252proof253  have polynomial := polynomialAlgebra.algebra at K, 4 with base254  have ideal := planeIdeal.ideal with base255  have projection := algebraProjection.ring_hom with polynomial, ideal256  unfold planeAlgebra257  rw quotientAlgebra.ringOf258  rw polynomialAlgebra.ring at projection259  rw polynomialAlgebra.ring260  exact projection261262theorem planeProjection.kills_h263  shows algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K))(relH(K)) =264    Ring.zero(Algebra.ring(planeAlgebra(K)))265proof266  have polynomial := polynomialAlgebra.algebra at K, 4 with base267  have generators := planeRelations.subset with base268  have member : relH(K) ∈ planeRelations(K)269    unfold planeRelations270    exact pair.left at relH(K), relCusp(K)271  have killed := algebraProjection.kills_generator with polynomial, generators,272    member273  unfold planeAlgebra274  rw quotientAlgebra.ringOf275  rw planeIdeal.generated276  exact killed277278theorem planeProjection.kills_cusp279  shows algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K))(relCusp(K)) =280    Ring.zero(Algebra.ring(planeAlgebra(K)))281proof282  have polynomial := polynomialAlgebra.algebra at K, 4 with base283  have generators := planeRelations.subset with base284  have member : relCusp(K) ∈ planeRelations(K)285    unfold planeRelations286    exact pair.right at relH(K), relCusp(K)287  have killed := algebraProjection.kills_generator with polynomial, generators,288    member289  unfold planeAlgebra290  rw quotientAlgebra.ringOf291  rw planeIdeal.generated292  exact killed293294-- Homomorphisms out of the presented algebra agreeing on the four classes295-- are equal.296theorem planeAlgebra.hom_ext (g h B : Set)297  requires first : g : planeAlgebra(K) →ₐ B298  requires second : h : planeAlgebra(K) →ₐ B299  requires agree : ∀ i ∈ 4, g(planeVariable(K, i)) = h(planeVariable(K, i))300  shows g = h301proof302  have polynomial := polynomialAlgebra.algebra at K, 4 with base303  have ideal := planeIdeal.ideal with base304  have projection := algebraProjection.hom with polynomial, ideal305  have carrierQ := quotientAlgebra.carrierOf at polynomialAlgebra(K, 4),306    planeIdeal(K)307  have projectionFunction := algebraProjection.function with polynomial, ideal308  rw ← carrierQ at projectionFunction309  unfold planeAlgebra at first310  unfold planeAlgebra at second311  have gFunction := AlgebraHom.function with first312  have hFunction := AlgebraHom.function with second313  have gComposite := AlgebraHom.compose with projection, first314  have hComposite := AlgebraHom.compose with projection, second315  -- The composites with the projection agree on the variables of K[4],316  -- hence everywhere, and the projection is onto.317  have agreeX : ∀ i ∈ 4,318      compose(g, algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K)),319        algebraCarrier(polynomialAlgebra(K, 4)),320        algebraCarrier(quotientAlgebra(polynomialAlgebra(K, 4), planeIdeal(K))),321        algebraCarrier(B))(X(K, 4, i)) =322      compose(h, algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K)),323        algebraCarrier(polynomialAlgebra(K, 4)),324        algebraCarrier(quotientAlgebra(polynomialAlgebra(K, 4), planeIdeal(K))),325        algebraCarrier(B))(X(K, 4, i))326    intros i hi327    have xIn : X(K, 4, i) ∈ algebraCarrier(polynomialAlgebra(K, 4))328      rw polynomialAlgebra.carrierOf329      exact X.mem at K, 4, i with base330    have left := compose.apply with projectionFunction, gFunction, xIn331    have right := compose.apply with projectionFunction, hFunction, xIn332    have same := agree with i, hi333    unfold planeVariable at same334    rw [left, right]335    exact same336  have equal := AlgebraHom.polynomial_ext with gComposite, hComposite, agreeX337  have agreeAll : ∀ x ∈ algebraCarrier(polynomialAlgebra(K, 4)),338      g(algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K))(x)) =339      h(algebraProjection(polynomialAlgebra(K, 4), planeIdeal(K))(x))340    intros x hx341    have left := compose.apply with projectionFunction, gFunction, hx342    have right := compose.apply with projectionFunction, hFunction, hx343    rw equal at left344    cc345  exact AlgebraHom.quotient_ext with polynomial, ideal, first, second, agreeAll346347end Projection348349-- The evaluation at the values.350351section Evaluation352variable (K : Set)353hypothesis base : CommRing(K)354hypothesis plane : CommRing(polynomialRing(K, 2))355356-- The values form a function on 4, and the evaluation at them is a ring357-- homomorphism K[4] → K[2] sending the variables to the values.358theorem planeValues.function359  shows planeValues(K) : 4 → Ring.carrier(polynomialRing(K, 2))360proof361  unfold planeValues362  exact quadrupleMap.function with *363364theorem planeEvaluation.hom365  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),366    planeValues(K)) : polynomialRing(K, 4) →+* polynomialRing(K, 2)367proof368  have constants := polynomialConstant.hom at K, 2 with base369  have values := planeValues.function with *370  exact evaluationHom.hom with base, plane, constants, values371372theorem planeEvaluation.X (i : Set)373  requires index : i ∈ 4374  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),375    planeValues(K))(X(K, 4, i)) = planeValues(K)(i)376proof377  have constants := polynomialConstant.hom at K, 2 with base378  have values := planeValues.function with *379  exact evaluationHom.map_X with base, plane, constants, values, index380381-- The values, by name.382theorem planeValues.zero383  shows planeValues(K)(0) = planeH(K)384proof385  unfold planeValues386  exact quadrupleMap.zero with *387388theorem planeValues.one389  shows planeValues(K)(1) = planeX(K)390proof391  unfold planeValues392  exact quadrupleMap.one with *393394theorem planeValues.two395  shows planeValues(K)(2) = planeY(K)396proof397  unfold planeValues398  exact quadrupleMap.two with *399400theorem planeValues.three401  shows planeValues(K)(3) = planeS(K)402proof403  unfold planeValues404  exact quadrupleMap.three with *405406-- The evaluation on the variables, by name.407theorem planeEvaluation.H408  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),409    planeValues(K))(X(K, 4, 0)) = planeH(K)410proof411  have zero : 0 ∈ 4 by simp [membership.four]412  have value := planeEvaluation.X with base, plane, zero413  have named := planeValues.zero with *414  rw [value, named]415416theorem planeEvaluation.X1417  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),418    planeValues(K))(X(K, 4, 1)) = planeX(K)419proof420  have one : 1 ∈ 4 by simp [membership.four]421  have value := planeEvaluation.X with base, plane, one422  have named := planeValues.one with *423  rw [value, named]424425theorem planeEvaluation.Y426  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),427    planeValues(K))(X(K, 4, 2)) = planeY(K)428proof429  have two : 2 ∈ 4 by simp [membership.four]430  have value := planeEvaluation.X with base, plane, two431  have named := planeValues.two with *432  rw [value, named]433434theorem planeEvaluation.S435  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),436    planeValues(K))(X(K, 4, 3)) = planeS(K)437proof438  have three : 3 ∈ 4 by simp [membership.four]439  have value := planeEvaluation.X with base, plane, three440  have named := planeValues.three with *441  rw [value, named]442443-- The values satisfy the cusp relation in K[2].444theorem plane_cusp445  shows planeX(K)^2 + planeY(K)^3 = planeH(K) * planeS(K)446proof447  have shift := shift_universal at polynomialRing(K, 2), planeX(K), planeY(K),448    planeS(K) with *449  have value : X(K, 2, 0)^2 + X(K, 2, 1)^3 = planeS(K)450    unfold planeS451    rfl452  have collapse : (planeX(K) + planeS(K)^3)^2 + (planeY(K) - planeS(K)^2)^3 =453      planeS(K)454    unfold planeX455    unfold planeY456    linear_combination value457  unfold planeH458  linear_combination collapse - shift459460end Evaluation461462-- The backward map, on the variables of K[2].463464section Backward465variable (K : Set)466hypothesis base : CommRing(K)467hypothesis quotient : CommRing(Algebra.ring(planeAlgebra(K)))468469-- Backward: K[2] to the presented algebra, X₀ ↦ x + s³ and X₁ ↦ y − s².470def planeBackward : Set :=471  evaluationHom(K, Algebra.ring(planeAlgebra(K)), 2,472    Algebra.map(planeAlgebra(K)),473    pairMap(Ring.carrier(Algebra.ring(planeAlgebra(K))),474      planeVariable(K, 1) + planeVariable(K, 3)^3,475      planeVariable(K, 2) - planeVariable(K, 3)^2))476477-- The assigned values of X₀ and X₁ lie in the presented algebra.478theorem planeBackward.first_mem479  shows planeVariable(K, 1) + planeVariable(K, 3)^3 ∈480    Ring.carrier(Algebra.ring(planeAlgebra(K)))481proof482  typecheck483484theorem planeBackward.second_mem485  shows planeVariable(K, 2) - planeVariable(K, 3)^2 ∈486    Ring.carrier(Algebra.ring(planeAlgebra(K)))487proof488  typecheck489490theorem planeBackward.values491  shows pairMap(Ring.carrier(Algebra.ring(planeAlgebra(K))),492      planeVariable(K, 1) + planeVariable(K, 3)^3,493      planeVariable(K, 2) - planeVariable(K, 3)^2) :494    2 → algebraCarrier(planeAlgebra(K))495proof496  have first := planeBackward.first_mem with *497  have second := planeBackward.second_mem with *498  unfold algebraCarrier499  exact pairMap.function with first, second500501theorem planeBackward.X0502  shows planeBackward(K)(X(K, 2, 0)) =503    planeVariable(K, 1) + planeVariable(K, 3)^3504proof505  have algebra := planeAlgebra.algebra with base506  have over := planeAlgebra.over at K with base507  have values := planeBackward.values with *508  have first := planeBackward.first_mem with *509  have second := planeBackward.second_mem with *510  have zero : 0 ∈ 2 by simp [membership.two]511  have value := evaluationHom.algebra_X at K, 2, planeAlgebra(K), pairMap(512      Ring.carrier(Algebra.ring(planeAlgebra(K))),513      planeVariable(K, 1) + planeVariable(K, 3)^3,514      planeVariable(K, 2) - planeVariable(K, 3)^2), 0515    with base, algebra, over, values, zero516  have named := pairMap.zero with first, second517  unfold planeBackward518  rw [value, named]519520theorem planeBackward.X1521  shows planeBackward(K)(X(K, 2, 1)) =522    planeVariable(K, 2) - planeVariable(K, 3)^2523proof524  have algebra := planeAlgebra.algebra with base525  have over := planeAlgebra.over at K with base526  have values := planeBackward.values with *527  have first := planeBackward.first_mem with *528  have second := planeBackward.second_mem with *529  have one : 1 ∈ 2 by simp [membership.two]530  have value := evaluationHom.algebra_X at K, 2, planeAlgebra(K), pairMap(531      Ring.carrier(Algebra.ring(planeAlgebra(K))),532      planeVariable(K, 1) + planeVariable(K, 3)^3,533      planeVariable(K, 2) - planeVariable(K, 3)^2), 1534    with base, algebra, over, values, one535  have named := pairMap.one with first, second536  unfold planeBackward537  rw [value, named]538539theorem planeBackward.hom540  shows planeBackward(K) : polynomialAlgebra(K, 2) →ₐ planeAlgebra(K)541proof542  have algebra := planeAlgebra.algebra with base543  have over := planeAlgebra.over at K with base544  have values := planeBackward.values with *545  unfold planeBackward546  exact evaluationHom.algebra_hom at K, 2, planeAlgebra(K), pairMap(547      Ring.carrier(Algebra.ring(planeAlgebra(K))),548      planeVariable(K, 1) + planeVariable(K, 3)^3,549      planeVariable(K, 2) - planeVariable(K, 3)^2)550    with base, algebra, over, values551552theorem planeBackward.ring_hom553  shows planeBackward(K) :554    polynomialRing(K, 2) →+* Algebra.ring(planeAlgebra(K))555proof556  have hom := planeBackward.hom with *557  have ringHom := AlgebraHom.ring_hom with hom558  rw polynomialAlgebra.ring at ringHom559  exact ringHom560561end Backward562563-- The laws in the presented algebra, the two maps, and the equivalence.564565section Plane566variable (K : Set)567hypothesis base : CommRing(K)568hypothesis quotient : CommRing(Algebra.ring(planeAlgebra(K)))569hypothesis plane : CommRing(polynomialRing(K, 2))570571-- The two relations, read in the presented algebra.572theorem planeAlgebra.relation_h573  shows planeVariable(K, 0) = Ring.one(Algebra.ring(planeAlgebra(K))) +574    shiftP(Algebra.ring(planeAlgebra(K)), planeVariable(K, 1),575      planeVariable(K, 2), planeVariable(K, 3))576proof577  have hom := planeProjection.hom with base578  have killed := planeProjection.kills_h with base579  have mapped := RingHom.map_relH with base, quotient, hom580  rw mapped at killed581  unfold planeVariable582  linear_combination killed583584theorem planeAlgebra.relation_cusp585  shows planeVariable(K, 1)^2 + planeVariable(K, 2)^3 =586    planeVariable(K, 0) * planeVariable(K, 3)587proof588  have hom := planeProjection.hom with base589  have killed := planeProjection.kills_cusp with base590  have mapped := RingHom.map_relCusp with base, quotient, hom591  rw mapped at killed592  unfold planeVariable593  linear_combination killed594595-- Their consequences: the shifted cusp is s, and h, y are coprime.596theorem planeAlgebra.shift_s597  shows (planeVariable(K, 1) + planeVariable(K, 3)^3)^2 +598    (planeVariable(K, 2) - planeVariable(K, 3)^2)^3 = planeVariable(K, 3)599proof600  have cusp := planeAlgebra.relation_cusp with *601  have relation := planeAlgebra.relation_h with *602  have shift := shift_universal at Algebra.ring(planeAlgebra(K)),603    planeVariable(K, 1), planeVariable(K, 2), planeVariable(K, 3) with *604  linear_combination shift + cusp + planeVariable(K, 3) * relation605606theorem planeAlgebra.bezout607  shows bezoutAlpha(Algebra.ring(planeAlgebra(K)), planeVariable(K, 1),608      planeVariable(K, 3)) * planeVariable(K, 0) +609    bezoutBeta(Algebra.ring(planeAlgebra(K)), planeVariable(K, 1),610      planeVariable(K, 2), planeVariable(K, 3)) * planeVariable(K, 2) =611    Ring.one(Algebra.ring(planeAlgebra(K)))612proof613  have cusp := planeAlgebra.relation_cusp with *614  have relation := planeAlgebra.relation_h with *615  have certificate := bezout_certificate at Algebra.ring(planeAlgebra(K)),616    planeVariable(K, 0), planeVariable(K, 1), planeVariable(K, 2),617    planeVariable(K, 3) with *618  -- Both factors on the right of the certificate are the relations.619  have relationH :620      planeVariable(K, 0) - Ring.one(Algebra.ring(planeAlgebra(K))) -621      shiftP(Algebra.ring(planeAlgebra(K)), planeVariable(K, 1),622        planeVariable(K, 2), planeVariable(K, 3)) =623      Ring.zero(Algebra.ring(planeAlgebra(K)))624    linear_combination relation625  have relationCusp : planeVariable(K, 1)^2 + planeVariable(K, 2)^3 -626      planeVariable(K, 3) * planeVariable(K, 0) =627      Ring.zero(Algebra.ring(planeAlgebra(K)))628    linear_combination cusp629  rw [relationH, relationCusp] at certificate630  linear_combination certificate631632-- The evaluation kills both relations, so it is an algebra homomorphism633-- out of K[4] that lifts to the presented algebra.634theorem planeValues.relations635  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),636      planeValues(K))(relH(K)) = Ring.zero(polynomialRing(K, 2)) ∧637    evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),638      planeValues(K))(relCusp(K)) = Ring.zero(polynomialRing(K, 2))639proof640  have hom := planeEvaluation.hom with *641  have mapH := RingHom.map_relH with base, plane, hom642  have mapCusp := RingHom.map_relCusp with base, plane, hom643  have h := planeEvaluation.H with *644  have x := planeEvaluation.X1 with *645  have y := planeEvaluation.Y with *646  have s := planeEvaluation.S with *647  have cusp := plane_cusp with *648  constructor649  . rw [mapH, h, x, y, s]650    unfold planeH651    ring652  . rw [mapCusp, h, x, y, s]653    linear_combination cusp654655theorem planeEvaluation.algebra_hom656  shows evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),657    planeValues(K)) : polynomialAlgebra(K, 4) →ₐ polynomialAlgebra(K, 2)658proof659  have algebra2 := polynomialAlgebra.algebra at K, 2 with base660  have values : planeValues(K) : 4 → algebraCarrier(polynomialAlgebra(K, 2))661    rw polynomialAlgebra.carrierOf662    exact planeValues.function with *663  have over := polynomialAlgebra.base at K, 2664  have hom := evaluationHom.algebra_hom at K, 4, polynomialAlgebra(K, 2),665    planeValues(K) with base, algebra2, over, values666  rw [polynomialAlgebra.ring, polynomialAlgebra.map] at hom667  exact hom668669theorem planeEvaluation.kills670  shows ∀ g ∈ planeRelations(K),671    evaluationHom(K, polynomialRing(K, 2), 4, polynomialConstant(K, 2),672      planeValues(K))(g) = Ring.zero(Algebra.ring(polynomialAlgebra(K, 2)))673proof674  have relations := planeValues.relations with *675  intros g hg676  unfold planeRelations at hg677  simp [pair.membership] at hg678  rw polynomialAlgebra.ring679  rcases hg with rfl | rfl680  . exact relations.left681  . exact relations.right682683theorem planeForward.hom684  shows planeForward(K) : planeAlgebra(K) →ₐ polynomialAlgebra(K, 2)685proof686  have polynomial := polynomialAlgebra.algebra at K, 4 with base687  have generators := planeRelations.subset with base688  have hom := planeEvaluation.algebra_hom with *689  have killed := planeEvaluation.kills with *690  have lifted := AlgebraHom.lift_generated with polynomial, generators, hom,691    killed692  unfold planeForward693  unfold planeAlgebra694  rw planeIdeal.generated695  exact lifted696697theorem planeForward.variable (i : Set)698  requires index : i ∈ 4699  shows planeForward(K)(planeVariable(K, i)) = planeValues(K)(i)700proof701  have polynomial := polynomialAlgebra.algebra at K, 4 with base702  have generators := planeRelations.subset with base703  have hom := planeEvaluation.algebra_hom with *704  have killed := planeEvaluation.kills with *705  have member : X(K, 4, i) ∈ algebraCarrier(polynomialAlgebra(K, 4))706    rw polynomialAlgebra.carrierOf707    exact X.mem at K, 4, i with base708  have factors := AlgebraHom.lift_generated_factors with polynomial, generators,709    hom, killed, member710  unfold planeForward711  unfold planeVariable712  rw planeIdeal.generated713  rw factors714  exact planeEvaluation.X with base, plane, index715716-- The forward map as a ring homomorphism, and on the four classes.717theorem planeForward.ring_hom718  shows planeForward(K) :719    Algebra.ring(planeAlgebra(K)) →+* polynomialRing(K, 2)720proof721  have hom := planeForward.hom with *722  have ringHom := AlgebraHom.ring_hom with hom723  rw polynomialAlgebra.ring at ringHom724  exact ringHom725726theorem planeForward.H727  shows planeForward(K)(planeVariable(K, 0)) = planeH(K)728proof729  have zero : 0 ∈ 4 by simp [membership.four]730  have value := planeForward.variable with base, quotient, plane, zero731  have named := planeValues.zero with *732  rw [value, named]733734theorem planeForward.X735  shows planeForward(K)(planeVariable(K, 1)) = planeX(K)736proof737  have one : 1 ∈ 4 by simp [membership.four]738  have value := planeForward.variable with base, quotient, plane, one739  have named := planeValues.one with *740  rw [value, named]741742theorem planeForward.Y743  shows planeForward(K)(planeVariable(K, 2)) = planeY(K)744proof745  have two : 2 ∈ 4 by simp [membership.four]746  have value := planeForward.variable with base, quotient, plane, two747  have named := planeValues.two with *748  rw [value, named]749750theorem planeForward.S751  shows planeForward(K)(planeVariable(K, 3)) = planeS(K)752proof753  have three : 3 ∈ 4 by simp [membership.four]754  have value := planeForward.variable with base, quotient, plane, three755  have named := planeValues.three with *756  rw [value, named]757758-- The forward map sends the assigned values of X₀ and X₁ back to them.759theorem planeForward.X0760  shows planeForward(K)(planeVariable(K, 1) + planeVariable(K, 3)^3) =761    X(K, 2, 0)762proof763  have hom := planeForward.ring_hom with *764  have fX := planeForward.X with *765  have fS := planeForward.S with *766  have mapped : planeForward(K)(planeVariable(K, 1) + planeVariable(K, 3)^3) =767      planeForward(K)(planeVariable(K, 1)) +768        planeForward(K)(planeVariable(K, 3))^3769    simp [RingHom.map_add, RingHom.map_pow]770  rw [mapped, fX, fS]771  unfold planeX772  ring773774theorem planeForward.X1775  shows planeForward(K)(planeVariable(K, 2) - planeVariable(K, 3)^2) =776    X(K, 2, 1)777proof778  have hom := planeForward.ring_hom with *779  have fY := planeForward.Y with *780  have fS := planeForward.S with *781  have mapped : planeForward(K)(planeVariable(K, 2) - planeVariable(K, 3)^2) =782      planeForward(K)(planeVariable(K, 2)) -783        planeForward(K)(planeVariable(K, 3))^2784    simp [RingHom.map_sub, RingHom.map_pow]785  rw [mapped, fY, fS]786  unfold planeY787  ring788789-- The backward map on the values s, x, y, h.790theorem planeBackward.S791  shows planeBackward(K)(planeS(K)) = planeVariable(K, 3)792proof793  have hom := planeBackward.ring_hom with *794  have x0 := planeBackward.X0 with *795  have x1 := planeBackward.X1 with *796  have shift := planeAlgebra.shift_s with *797  have mapped : planeBackward(K)(X(K, 2, 0)^2 + X(K, 2, 1)^3) =798      planeBackward(K)(X(K, 2, 0))^2 + planeBackward(K)(X(K, 2, 1))^3799    simp [RingHom.map_add, RingHom.map_pow]800  unfold planeS801  rw [mapped, x0, x1]802  exact shift803804theorem planeBackward.X805  shows planeBackward(K)(planeX(K)) = planeVariable(K, 1)806proof807  have hom := planeBackward.ring_hom with *808  have x0 := planeBackward.X0 with *809  have s := planeBackward.S with *810  have sIn := planeS.mem with *811  have mapped : planeBackward(K)(X(K, 2, 0) - planeS(K)^3) =812      planeBackward(K)(X(K, 2, 0)) - planeBackward(K)(planeS(K))^3813    simp [RingHom.map_sub, RingHom.map_pow]814  unfold planeX815  rw [mapped, x0, s]816  ring817818theorem planeBackward.Y819  shows planeBackward(K)(planeY(K)) = planeVariable(K, 2)820proof821  have hom := planeBackward.ring_hom with *822  have x1 := planeBackward.X1 with *823  have s := planeBackward.S with *824  have sIn := planeS.mem with *825  have mapped : planeBackward(K)(X(K, 2, 1) + planeS(K)^2) =826      planeBackward(K)(X(K, 2, 1)) + planeBackward(K)(planeS(K))^2827    simp [RingHom.map_add, RingHom.map_pow]828  unfold planeY829  rw [mapped, x1, s]830  ring831832theorem planeBackward.H833  shows planeBackward(K)(planeH(K)) = planeVariable(K, 0)834proof835  have hom := planeBackward.ring_hom with *836  have x := planeBackward.X with *837  have y := planeBackward.Y with *838  have s := planeBackward.S with *839  have xIn := planeX.mem with *840  have yIn := planeY.mem with *841  have sIn := planeS.mem with *842  have relation := planeAlgebra.relation_h with *843  have mapped : planeBackward(K)(Ring.one(polynomialRing(K, 2)) +844        shiftP(polynomialRing(K, 2), planeX(K), planeY(K), planeS(K))) =845      Ring.one(Algebra.ring(planeAlgebra(K))) +846        shiftP(Algebra.ring(planeAlgebra(K)), planeBackward(K)(planeX(K)),847          planeBackward(K)(planeY(K)), planeBackward(K)(planeS(K)))848    simp [RingHom.map_add, RingHom.map_one, RingHom.map_shiftP]849  unfold planeH850  rw [mapped, x, y, s]851  symm852  exact relation853854-- The two composites are the identities, by extensionality on generators.855theorem planeForward.after_backward (p : Set)856  requires member : p ∈ Ring.carrier(polynomialRing(K, 2))857  shows planeForward(K)(planeBackward(K)(p)) = p858proof859  have forward := planeForward.hom with *860  have backward := planeBackward.hom with *861  have forwardFunction := AlgebraHom.function with forward862  have backwardFunction := AlgebraHom.function with backward863  have algebra2 := polynomialAlgebra.algebra at K, 2 with base864  have carrier := polynomialAlgebra.carrierOf at K, 2865  have composite := AlgebraHom.compose with backward, forward866  have identity2 := AlgebraHom.identity with algebra2867  have f0 := planeForward.X0 with *868  have f1 := planeForward.X1 with *869  have x0 := planeBackward.X0 with *870  have x1 := planeBackward.X1 with *871  -- Going to the presented algebra and back fixes each variable of K[2].872  have agree : ∀ j ∈ 2,873      compose(planeForward(K), planeBackward(K),874        algebraCarrier(polynomialAlgebra(K, 2)),875        algebraCarrier(planeAlgebra(K)),876        algebraCarrier(polynomialAlgebra(K, 2)))(X(K, 2, j)) =877      identity(algebraCarrier(polynomialAlgebra(K, 2)))(X(K, 2, j))878    intros j hj879    have xIn : X(K, 2, j) ∈ algebraCarrier(polynomialAlgebra(K, 2))880      rw carrier881      exact X.mem at K, 2, j with base882    have step := compose.apply with backwardFunction, forwardFunction, xIn883    have fixed := identity.apply with xIn884    rw [step, fixed]885    have cases := membership.two.forward with hj886    rcases cases with rfl | rfl887    . rw x0888      exact f0889    . rw x1890      exact f1891  have equal := AlgebraHom.polynomial_ext with composite, identity2, agree892  have pIn : p ∈ algebraCarrier(polynomialAlgebra(K, 2))893    rw carrier894    exact member895  have step := compose.apply with backwardFunction, forwardFunction, pIn896  have fixed := identity.apply with pIn897  rw equal at step898  cc899900theorem planeBackward.after_forward (q : Set)901  requires member : q ∈ algebraCarrier(planeAlgebra(K))902  shows planeBackward(K)(planeForward(K)(q)) = q903proof904  have forward := planeForward.hom with *905  have backward := planeBackward.hom with *906  have forwardFunction := AlgebraHom.function with forward907  have backwardFunction := AlgebraHom.function with backward908  have algebra := planeAlgebra.algebra with base909  have composite := AlgebraHom.compose with forward, backward910  have identityQ := AlgebraHom.identity with algebra911  have fH := planeForward.H with *912  have fX := planeForward.X with *913  have fY := planeForward.Y with *914  have fS := planeForward.S with *915  have bH := planeBackward.H with *916  have bX := planeBackward.X with *917  have bY := planeBackward.Y with *918  have bS := planeBackward.S with *919  -- Going to K[2] and back fixes each of the four classes.920  have agree : ∀ i ∈ 4,921      compose(planeBackward(K), planeForward(K),922        algebraCarrier(planeAlgebra(K)),923        algebraCarrier(polynomialAlgebra(K, 2)),924        algebraCarrier(planeAlgebra(K)))(planeVariable(K, i)) =925      identity(algebraCarrier(planeAlgebra(K)))(planeVariable(K, i))926    intros i hi927    have vIn : planeVariable(K, i) ∈ algebraCarrier(planeAlgebra(K))928      unfold algebraCarrier929      exact planeVariable.mem with base, hi930    have step := compose.apply with forwardFunction, backwardFunction, vIn931    have fixed := identity.apply with vIn932    rw [step, fixed]933    have cases := membership.four.forward with hi934    rcases cases with rfl | rfl | rfl | rfl935    . rw [fH, bH]936    . rw [fX, bX]937    . rw [fY, bY]938    . rw [fS, bS]939  have equal := planeAlgebra.hom_ext with base, composite, identityQ, agree940  have step := compose.apply with forwardFunction, backwardFunction, member941  have fixed := identity.apply with member942  rw equal at step943  cc944945theorem plane_equivalence946  shows planeForward(K) : planeAlgebra(K) ≃ₐ polynomialAlgebra(K, 2)947proof948  have forward := planeForward.hom with *949  have backward := planeBackward.hom with *950  have carrier := polynomialAlgebra.carrierOf at K, 2951  have left : ∀ x ∈ algebraCarrier(planeAlgebra(K)),952      planeBackward(K)(planeForward(K)(x)) = x953    intros x hx954    exact planeBackward.after_forward with base, quotient, plane, hx955  have right : ∀ y ∈ algebraCarrier(polynomialAlgebra(K, 2)),956      planeForward(K)(planeBackward(K)(y)) = y957    intros y hy958    rw carrier at hy959    exact planeForward.after_backward with base, quotient, plane, hy960  exact AlgebraIso.of_inverse with forward, backward, left, right961962end Plane963