{-# OPTIONS --safe --cubical-compatible --guardedness --exact-split --double-check #-}
module Cosmos.M.GenCongruence where
open import Agda.Primitive using (Level; _⊔_)
open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Sigma using (Σ; _,_)
open import Data.Product.Base using (proj₁; proj₂)
open import Relation.Binary.PropositionalEquality.Core using (cong)
open import Categories.Category.Core using (Category)
open import Categories.Functor.Core using (Functor)
open import Base.MCorr using (M)
open import Base.MCorr.Setoid using
(EqOn; SysEq; propEqOn; FiberAdjˢ; symAdjˢ; compAdjˢ; Morphˢ; here-eq
; below-eq; ≈Mˢ-refl; ≈Mˢ-sym; ≈Mˢ-trans)
open import Base.MCorr.SetoidCat using (FMapˢ; FMˢ)
open import Cosmos.ContCategory using (ContCat)
open import Cosmos.ContCatEquiv using (ShapeCat)
open import Cosmos.M.Object using (I; E; sys; CosmosM; CosmosData; ≈CosmosM)
module _ {o h e s p : Level}
(C : Category o h e)
(FC : Functor C (ContCat s p)) where
private
iL = o ⊔ s
aL = o ⊔ h ⊔ e ⊔ s ⊔ p
bL = o ⊔ s ⊔ p
propLabel : (i : I C FC) → EqOn {ℓ = aL} (CosmosData C FC)
propLabel _ = propEqOn _
sysP : SysEq iL aL bL aL bL
sysP = sys C FC propLabel
≈A = SysEq.≈A sysP
≈E = SysEq.≈E sysP
EM = E C FC
record GenDet (S : Functor (ShapeCat C FC) (ShapeCat C FC))
: Set aL where
field
σ : (x : I C FC) → CosmosData C FC → CosmosData C FC
pb : (v : I C FC)
→ Σ (I C FC) λ x' → Functor.F₀ S x' ≡ v
adj : (x : I C FC) (d : CosmosData C FC) (v : I C FC)
→ FiberAdjˢ (propEqOn (EM (Functor.F₀ S x) (σ x d) v))
(propEqOn (EM x d (proj₁ (pb v))))
open GenDet public
genFMapˢ : (S : Functor (ShapeCat C FC) (ShapeCat C FC))
(g : GenDet S) → FMapˢ sysP sysP
FMapˢ.u (genFMapˢ S g) = Functor.F₀ S
FMapˢ.shape (genFMapˢ S g) x d = σ g x d
FMapˢ.childF (genFMapˢ S g) x d v = pb g v
FMapˢ.adjFˢ (genFMapˢ S g) x d v = adj g x d v
private
edge-reloc : ∀ {x y : I C FC}
(u : CosmosM C FC x)
{e e' : EM x (M.here u) y}
→ e ≡ e'
→ ≈CosmosM C FC propLabel
(M.below u y e) (M.below u y e')
edge-reloc u {e = z} {e' = .z} refl =
≈Mˢ-refl ≈A ≈E (M.below u _ z)
private
mapR-of : (S : Functor (ShapeCat C FC) (ShapeCat C FC))
(g : GenDet S)
→ ∀ {x v} → Functor.F₀ S x ≡ v
→ CosmosM C FC x → CosmosM C FC v
mapR-of S g = Morphˢ.mapR (FMapˢ.asMorphˢ (genFMapˢ S g))
private
go : (S : Functor (ShapeCat C FC) (ShapeCat C FC))
(g : GenDet S)
→ ∀ {x v : I C FC} (r : Functor.F₀ S x ≡ v)
{t s : CosmosM C FC x}
→ ≈CosmosM C FC propLabel t s
→ ≈CosmosM C FC propLabel (mapR-of S g r t) (mapR-of S g r s)
go S g {x = x} {.(Functor.F₀ S x)} refl {t = t} {s = s} h
.here-eq = cong (σ g x) (h .here-eq)
go S g {x = x} {.(Functor.F₀ S x)} refl {t = t} {s = s} h
.below-eq v =
adjOut , ( (λ q → go S g eqw (hF q))
, (λ r → go S g eqw (≈Mˢ-sym ≈A ≈E (hT r))) )
where
dT = M.here t
dS = M.here s
dTσ = σ g x dT
dSσ = σ g x dS
x' = proj₁ (pb g v)
eqw = proj₂ (pb g v)
Aₜ : FiberAdjˢ (propEqOn (EM (Functor.F₀ S x) dTσ v))
(propEqOn (EM x dT x'))
Aₜ = adj g x dT v
Aₛ : FiberAdjˢ (propEqOn (EM (Functor.F₀ S x) dSσ v))
(propEqOn (EM x dS x'))
Aₛ = adj g x dS v
adjH : FiberAdjˢ (propEqOn (EM x dS x'))
(propEqOn (EM x dT x'))
adjH = proj₁ (h .below-eq x')
hfwd : ∀ (e₁ : EM x dT x')
→ ≈CosmosM C FC propLabel
(M.below t x' e₁)
(M.below s x' (FiberAdjˢ.to adjH e₁))
hfwd = proj₁ (proj₂ (h .below-eq x'))
hbwd : ∀ (e₂ : EM x dS x')
→ ≈CosmosM C FC propLabel
(M.below s x' e₂)
(M.below t x' (FiberAdjˢ.fro adjH e₂))
hbwd = proj₂ (proj₂ (h .below-eq x'))
c1 : FiberAdjˢ (propEqOn (EM x dS x'))
(propEqOn (EM (Functor.F₀ S x) dTσ v))
c1 = compAdjˢ (propEqOn (EM (Functor.F₀ S x) dTσ v))
(propEqOn (EM x dT x'))
(propEqOn (EM x dS x'))
(symAdjˢ Aₜ) adjH
adjOut : FiberAdjˢ (propEqOn (EM (Functor.F₀ S x) dSσ v))
(propEqOn (EM (Functor.F₀ S x) dTσ v))
adjOut = compAdjˢ (propEqOn (EM (Functor.F₀ S x) dTσ v))
(propEqOn (EM x dS x'))
(propEqOn (EM (Functor.F₀ S x) dSσ v))
c1 Aₛ
hF : ∀ (q : EM (Functor.F₀ S x) dTσ v)
→ ≈CosmosM C FC propLabel
(M.below t x' (FiberAdjˢ.fro Aₜ q))
(M.below s x' (FiberAdjˢ.fro Aₛ (FiberAdjˢ.to adjOut q)))
hF q =
let eT = FiberAdjˢ.fro Aₜ q
eS = FiberAdjˢ.to adjH eT
in ≈Mˢ-trans ≈A ≈E (hfwd eT)
(≈Mˢ-sym ≈A ≈E (edge-reloc s (FiberAdjˢ.η Aₛ eS)))
hT : ∀ (r : EM (Functor.F₀ S x) dSσ v)
→ ≈CosmosM C FC propLabel
(M.below t x' (FiberAdjˢ.fro Aₜ (FiberAdjˢ.fro adjOut r)))
(M.below s x' (FiberAdjˢ.fro Aₛ r))
hT r =
let eSsrc = FiberAdjˢ.fro Aₛ r
z = FiberAdjˢ.fro adjH eSsrc
in ≈Mˢ-trans ≈A ≈E (edge-reloc t (FiberAdjˢ.η Aₜ z))
(≈Mˢ-sym ≈A ≈E (hbwd eSsrc))
gen-map-cong : (S : Functor (ShapeCat C FC) (ShapeCat C FC))
(g : GenDet S)
→ ∀ {x : I C FC} {t s : CosmosM C FC x}
→ ≈CosmosM C FC propLabel t s
→ ≈CosmosM C FC propLabel
(FMapˢ.mapFˢ (genFMapˢ S g) x t)
(FMapˢ.mapFˢ (genFMapˢ S g) x s)
gen-map-cong S g = go S g refl
genFMˢ : (S : Functor (ShapeCat C FC) (ShapeCat C FC))
(g : GenDet S) → FMˢ sysP sysP
genFMˢ S g = record
{ mor = genFMapˢ S g
; shape-cong = λ {x} {d} {d'} eq → cong (σ g x) eq
; map-cong = gen-map-cong S g
}