import OAI.AlgebraicGeometry.CharacterVarieties.Foundation.GaugeEquivalences namespace OAI noncomputable section open scoped Classical Matrix namespace IntegralCharacterVarieties.SurfacePresentation.Diagram open scoped Classical Matrix open OccurrenceIncidence MatrixExpression SurfaceSurgery variable {F S V R A : Type} {arity : S → ℕ} [CommRing R] [CommRing A] variable (D : Diagram F S V arity) (φ : R →+* A) variable (g : (e : D.Generator) → (Matrix (Fin (D.generatorRank e)) (Fin (D.generatorRank e)) A)ˣ) /-- The explicit inverse prefix product at every boundary corner. -/ def normalizingBoundaryBases : D.BoundaryBases (A:=A) := fun f b i => MatrixIso.unit (prefixBasis (fun j => (D.boundaryEdgeWord f b j).eval φ g) i) def normalizingCorners : D.CornerBases (R:=A) := D.cornerBasesOfBoundary (D.normalizingBoundaryBases φ g) lemma normalizingCorners_based : CornerBases.Based D (D.normalizingCorners φ g) := by apply D.cornerBasesOfBoundary_based intro f b dsimp only [normalizingBoundaryBases] rw [prefixBasis_zero] apply MatrixIso.ext <;> ext i j <;> simp [MatrixIso.unit,MatrixIso.refl,Matrix.one_apply] /-- This changes all side and frame coordinates, so it respects every named quotient at every vertex, not just a list of boundary conjugacy classes. -/ def normalizeBoundaryGenerators := D.cornerGaugeGenerators (D.normalizingCorners φ g) g lemma normalized_boundaryEdge (f : F) (b : Fin (D.boundaryCount f)) (i : Fin (D.boundaryLength f b)) : (D.boundaryEdgeWord f b i).eval φ (D.normalizeBoundaryGenerators φ g)= if i.val+1 (D.normalizingCorners (algebraMap R A) x.val.val a).symm) (D.basedCorner_inverse _ (D.normalizingCorners_based (algebraMap R A) x.val.val)) P (D.normalizeBoundarySolution P x)=x := by apply Subtype.ext apply Subtype.ext exact D.cornerGaugeGenerators_inverse _ x.val.val theorem normalizeBoundarySolution_edge (P : D.Punctures R) (x : D.Solution P A) (f : F) (b : Fin (D.boundaryCount f)) (i : Fin (D.boundaryLength f b)) : (D.boundaryEdgeWord f b i).eval (algebraMap R A) (D.normalizeBoundarySolution P x).val.val= if i.val+1