import Mathlib import Definitions.Def_AlgebraicGeometry_OrderedAffineCoverCech import Definitions.Def_AlgebraicGeometry_OrderedAffineCoverComap set_option autoImplicit false noncomputable section universe u namespace AlgebraicGeometry.Scheme.OrderedAffineCover open CategoryTheory Opposite TopologicalSpace variable {X Y : Scheme.{u}} (h : X โŸถ Y) (๐’ฒ : X.OrderedAffineCover) (๐’ฆ : Y.OrderedAffineCover) (lam : ๐’ฒ.ฮน โ†’ ๐’ฆ.ฮน) def sortIdx {n : โ„•} (s : ๐’ฒ.Idx n) (hinj : Function.Injective (lam โˆ˜ s.1)) : ๐’ฆ.Idx n := โŸจ(lam โˆ˜ s.1) โˆ˜ (Tuple.sort (lam โˆ˜ s.1)), (Tuple.monotone_sort (lam โˆ˜ s.1)).strictMono_of_injective (hinj.comp (Tuple.sort (lam โˆ˜ s.1)).injective)โŸฉ theorem sortIdx_val {n : โ„•} (s : ๐’ฒ.Idx n) (hinj : Function.Injective (lam โˆ˜ s.1)) : (๐’ฒ.sortIdx ๐’ฆ lam s hinj).1 = (lam โˆ˜ s.1) โˆ˜ (Tuple.sort (lam โˆ˜ s.1)) := rfl theorem inter_le_preimage_inter_sortIdx (hlam : โˆ€ w, ๐’ฒ.U w โ‰ค h โปยนแต ๐’ฆ.U (lam w)) {n : โ„•} (s : ๐’ฒ.Idx n) (hinj : Function.Injective (lam โˆ˜ s.1)) : ๐’ฒ.inter s โ‰ค h โปยนแต ๐’ฆ.inter (๐’ฒ.sortIdx ๐’ฆ lam s hinj) := by change ๐’ฒ.inter s โ‰ค h โปยนแต (โจ… j, ๐’ฆ.U ((๐’ฒ.sortIdx ๐’ฆ lam s hinj).1 j)) rw [Scheme.OrderedAffineCover.preimage_iInf_fin] refine le_iInf fun j => ?_ exact (iInf_le (fun i => ๐’ฒ.U (s.1 i)) (Tuple.sort (lam โˆ˜ s.1) j)).trans (hlam _) end AlgebraicGeometry.Scheme.OrderedAffineCover namespace AlgebraicGeometry.OModulePresheaf open CategoryTheory Opposite TopologicalSpace variable {R : Type u} [CommRing R] {R' : Type u} [CommRing R'] variable {X Y : Scheme.{u}} {ฯ€X : X โŸถ Spec (.of R')} {ฯ€Y : Y โŸถ Spec (.of R)} def unitPullback (h : X โŸถ Y) (๐’ฒ : X.OrderedAffineCover) (๐’ฆ : Y.OrderedAffineCover) (lam : ๐’ฒ.ฮน โ†’ ๐’ฆ.ฮน) (hlam : โˆ€ w, ๐’ฒ.U w โ‰ค h โปยนแต ๐’ฆ.U (lam w)) (n : โ„•) (z : (unit ฯ€Y).cochain ๐’ฆ n) : (unit ฯ€X).cochain ๐’ฒ n := fun s => by classical exact if hinj : Function.Injective (lam โˆ˜ s.1) then ((Equiv.Perm.sign (Tuple.sort (lam โˆ˜ s.1)) : โ„คหฃ) : โ„ค) โ€ข (X.presheaf.map (homOfLE (๐’ฒ.inter_le_preimage_inter_sortIdx h ๐’ฆ lam hlam s hinj)).op).hom ((h.app (๐’ฆ.inter (๐’ฒ.sortIdx ๐’ฆ lam s hinj))).hom (z (๐’ฒ.sortIdx ๐’ฆ lam s hinj))) else 0 theorem unitPullback_apply_of_injective (h : X โŸถ Y) (๐’ฒ : X.OrderedAffineCover) (๐’ฆ : Y.OrderedAffineCover) (lam : ๐’ฒ.ฮน โ†’ ๐’ฆ.ฮน) (hlam : โˆ€ w, ๐’ฒ.U w โ‰ค h โปยนแต ๐’ฆ.U (lam w)) (n : โ„•) (z : (unit ฯ€Y).cochain ๐’ฆ n) (s : ๐’ฒ.Idx n) (hinj : Function.Injective (lam โˆ˜ s.1)) : unitPullback (ฯ€X := ฯ€X) h ๐’ฒ ๐’ฆ lam hlam n z s = ((Equiv.Perm.sign (Tuple.sort (lam โˆ˜ s.1)) : โ„คหฃ) : โ„ค) โ€ข (X.presheaf.map (homOfLE (๐’ฒ.inter_le_preimage_inter_sortIdx h ๐’ฆ lam hlam s hinj)).op).hom ((h.app (๐’ฆ.inter (๐’ฒ.sortIdx ๐’ฆ lam s hinj))).hom (z (๐’ฒ.sortIdx ๐’ฆ lam s hinj))) := by classical simp only [unitPullback, dif_pos hinj] theorem unitPullback_apply_of_not_injective (h : X โŸถ Y) (๐’ฒ : X.OrderedAffineCover) (๐’ฆ : Y.OrderedAffineCover) (lam : ๐’ฒ.ฮน โ†’ ๐’ฆ.ฮน) (hlam : โˆ€ w, ๐’ฒ.U w โ‰ค h โปยนแต ๐’ฆ.U (lam w)) (n : โ„•) (z : (unit ฯ€Y).cochain ๐’ฆ n) (s : ๐’ฒ.Idx n) (hinj : ยฌ Function.Injective (lam โˆ˜ s.1)) : unitPullback (ฯ€X := ฯ€X) h ๐’ฒ ๐’ฆ lam hlam n z s = 0 := by classical simp only [unitPullback, dif_neg hinj] end AlgebraicGeometry.OModulePresheaf end