{-# OPTIONS --safe --cubical-compatible --guardedness --exact-split --double-check #-}
module ALMA.Cosmos.M.ContainerAutomorphism where
open import Agda.Primitive using (Level; _⊔_)
open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Sigma using (_,_)
open import Algebra.Bundles using (Group)
open import Relation.Binary.PropositionalEquality.Core using (cong; sym; trans)
open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning)
open import Relation.Binary.Structures using (IsEquivalence)
open import ALMA.Base.MCorrSetoid using (EqOn; FiberAdjˢ; idAdjˢ; symAdjˢ; compAdjˢ)
module PositionPermutationGroup {s p : Level}
(S : Set s) (P : S → Set p) where
record PosAutˢ : Set (s ⊔ p) where
field
τ : (sh : S) → P sh → P sh
τ⁻¹ : (sh : S) → P sh → P sh
τ-τ⁻¹ : (sh : S) (q : P sh) → τ sh (τ⁻¹ sh q) ≡ q
τ⁻¹-τ : (sh : S) (q : P sh) → τ⁻¹ sh (τ sh q) ≡ q
open PosAutˢ public
idPosAutˢ : PosAutˢ
idPosAutˢ = record
{ τ = λ _ q → q
; τ⁻¹ = λ _ q → q
; τ-τ⁻¹ = λ _ _ → refl
; τ⁻¹-τ = λ _ _ → refl
}
infixl 20 _∘PosAutˢ_
_∘PosAutˢ_ : PosAutˢ → PosAutˢ → PosAutˢ
φ ∘PosAutˢ ψ = record
{ τ = λ sh q → τ φ sh (τ ψ sh q)
; τ⁻¹ = λ sh q → τ⁻¹ ψ sh (τ⁻¹ φ sh q)
; τ-τ⁻¹ = λ sh q →
begin
τ φ sh (τ ψ sh (τ⁻¹ ψ sh (τ⁻¹ φ sh q)))
≡⟨ cong (τ φ sh) (τ-τ⁻¹ ψ sh (τ⁻¹ φ sh q)) ⟩
τ φ sh (τ⁻¹ φ sh q)
≡⟨ τ-τ⁻¹ φ sh q ⟩
q
∎
; τ⁻¹-τ = λ sh q →
begin
τ⁻¹ ψ sh (τ⁻¹ φ sh (τ φ sh (τ ψ sh q)))
≡⟨ cong (τ⁻¹ ψ sh) (τ⁻¹-τ φ sh (τ ψ sh q)) ⟩
τ⁻¹ ψ sh (τ ψ sh q)
≡⟨ τ⁻¹-τ ψ sh q ⟩
q
∎
}
where open ≡-Reasoning
invPosAutˢ : PosAutˢ → PosAutˢ
invPosAutˢ φ = record
{ τ = τ⁻¹ φ
; τ⁻¹ = τ φ
; τ-τ⁻¹ = λ sh q → τ⁻¹-τ φ sh q
; τ⁻¹-τ = λ sh q → τ-τ⁻¹ φ sh q
}
infix 4 _≈PAˢ_
_≈PAˢ_ : PosAutˢ → PosAutˢ → Set (s ⊔ p)
φ ≈PAˢ ψ = ∀ (sh : S) (q : P sh) → τ φ sh q ≡ τ ψ sh q
≈PAˢ-isEquivalence : IsEquivalence _≈PAˢ_
≈PAˢ-isEquivalence = record
{ refl = λ _ _ → refl
; sym = λ eq sh q → sym (eq sh q)
; trans = λ eq₁ eq₂ sh q → trans (eq₁ sh q) (eq₂ sh q)
}
∘PosAutˢ-resp-≈ : ∀ {φ φ' ψ ψ'} → φ ≈PAˢ φ' → ψ ≈PAˢ ψ'
→ (φ ∘PosAutˢ ψ) ≈PAˢ (φ' ∘PosAutˢ ψ')
∘PosAutˢ-resp-≈ {φ} {φ'} {ψ} {ψ'} φ≈φ' ψ≈ψ' sh q =
begin
τ φ sh (τ ψ sh q)
≡⟨ cong (τ φ sh) (ψ≈ψ' sh q) ⟩
τ φ sh (τ ψ' sh q)
≡⟨ φ≈φ' sh (τ ψ' sh q) ⟩
τ φ' sh (τ ψ' sh q)
∎
where open ≡-Reasoning
τ⁻¹-unique : {φ ψ : PosAutˢ} → φ ≈PAˢ ψ
→ (sh : S) (q : P sh) → τ⁻¹ φ sh q ≡ τ⁻¹ ψ sh q
τ⁻¹-unique {φ} {ψ} φ≈ψ sh q =
trans
(sym (τ⁻¹-τ φ sh (τ⁻¹ φ sh q)))
(trans
(cong (τ⁻¹ φ sh) eq)
(τ⁻¹-τ φ sh (τ⁻¹ ψ sh q)))
where
eq : τ φ sh (τ⁻¹ φ sh q) ≡ τ φ sh (τ⁻¹ ψ sh q)
eq = trans
(τ-τ⁻¹ φ sh q)
(sym (trans (φ≈ψ sh (τ⁻¹ ψ sh q)) (τ-τ⁻¹ ψ sh q)))
invPosAutˢ-cong : {φ ψ : PosAutˢ} → φ ≈PAˢ ψ
→ invPosAutˢ φ ≈PAˢ invPosAutˢ ψ
invPosAutˢ-cong {φ} {ψ} φ≈ψ sh q = τ⁻¹-unique {φ} {ψ} φ≈ψ sh q
∘PosAutˢ-assoc : ∀ φ ψ χ
→ (φ ∘PosAutˢ ψ) ∘PosAutˢ χ ≈PAˢ φ ∘PosAutˢ (ψ ∘PosAutˢ χ)
∘PosAutˢ-assoc _ _ _ _ _ = refl
∘PosAutˢ-identityˡ : ∀ φ → idPosAutˢ ∘PosAutˢ φ ≈PAˢ φ
∘PosAutˢ-identityˡ _ _ _ = refl
∘PosAutˢ-identityʳ : ∀ φ → φ ∘PosAutˢ idPosAutˢ ≈PAˢ φ
∘PosAutˢ-identityʳ _ _ _ = refl
invPosAutˢ-left-inverse : ∀ φ → invPosAutˢ φ ∘PosAutˢ φ ≈PAˢ idPosAutˢ
invPosAutˢ-left-inverse φ sh q = τ⁻¹-τ φ sh q
invPosAutˢ-right-inverse : ∀ φ → φ ∘PosAutˢ invPosAutˢ φ ≈PAˢ idPosAutˢ
invPosAutˢ-right-inverse φ sh q = τ-τ⁻¹ φ sh q
posAutˢGroup : Group (s ⊔ p) (s ⊔ p)
posAutˢGroup = record
{ Carrier = PosAutˢ
; _≈_ = _≈PAˢ_
; _∙_ = _∘PosAutˢ_
; ε = idPosAutˢ
; _⁻¹ = invPosAutˢ
; isGroup = record
{ isMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = ≈PAˢ-isEquivalence
; ∙-cong = λ {x y u v} x≈y u≈v →
∘PosAutˢ-resp-≈ {x} {y} {u} {v} x≈y u≈v
}
; assoc = ∘PosAutˢ-assoc
}
; identity = ( ∘PosAutˢ-identityˡ , ∘PosAutˢ-identityʳ )
}
; inverse = ( invPosAutˢ-left-inverse , invPosAutˢ-right-inverse )
; ⁻¹-cong = λ {x y} x≈y → invPosAutˢ-cong {x} {y} x≈y
}
}
module FibreSelfAdjunctionGroup {c ℓ : Level} {P : Set c}
(E : EqOn {ℓ = ℓ} P) where
open EqOn E using (_≈_) renaming (refl to ≈refl)
SelfAdj : Set (c ⊔ ℓ)
SelfAdj = FiberAdjˢ E E
idSelf : SelfAdj
idSelf = idAdjˢ E
compSelf : SelfAdj → SelfAdj → SelfAdj
compSelf a₁ a₂ = compAdjˢ E E E a₁ a₂
invSelf : SelfAdj → SelfAdj
invSelf = symAdjˢ
comp-identityʳ-to : (a : SelfAdj) (p : P)
→ FiberAdjˢ.to (compSelf a idSelf) p ≈ FiberAdjˢ.to a p
comp-identityʳ-to a p = ≈refl
comp-identityˡ-to : (a : SelfAdj) (p : P)
→ FiberAdjˢ.to (compSelf idSelf a) p ≈ FiberAdjˢ.to a p
comp-identityˡ-to a p = ≈refl
comp-inverseˡ-to : (a : SelfAdj) (r : P)
→ FiberAdjˢ.to (compSelf a (invSelf a)) r ≈ r
comp-inverseˡ-to a r = FiberAdjˢ.η a r
comp-inverseʳ-to : (a : SelfAdj) (p : P)
→ FiberAdjˢ.to (compSelf (invSelf a) a) p ≈ p
comp-inverseʳ-to a p = FiberAdjˢ.ε a p
comp-assoc-to : (a b c : SelfAdj) (p : P)
→ FiberAdjˢ.to (compSelf (compSelf a b) c) p
≈ FiberAdjˢ.to (compSelf a (compSelf b c)) p
comp-assoc-to a b c p = ≈refl