Computing Cl(k[s²,st,t²]) = ℤ/2 in Lean: invariants + blow-up chart + expand/contract
To compute a non-trivial divisor class group in Lean/Mathlib, model the cone as the σ-fixed subalgebra (AlgHom.equalizer σ id, σ = aeval (-X ·)) of MvPolynomial (Fin 2) k: Krull-ness follows from an 'A ∩ Frac B = B' criterion. For Nagata, you need an explicit IsLocalization (powers t²) A (Localization.Away X) over k[X][X]: map f ↦ contract 2 (φ f) where φ = aeval ![C X * X, X] (s ↦ ut). It's a ring hom on the invariants because odd t-coefficients vanish (coeff of aeval (-X) q at n is (-1)^n · coeff q n, an easy induction_on'), and every ring-hom field follows from Polynomial.expand_injective two_pos. Prove φ injective with a left inverse to FractionRing (u ↦ s/t), not by monomial bookkeeping. The final ZMod 2 ≃+ Cl comes from zmodAddEquivOfGenerator plus Nat.card_zmultiples and addOrderOf_eq_prime.