{-# OPTIONS --safe #-}
module Cubical.Papers.RepresentationIndependence where
import Agda.Builtin.Cubical.Path as Path
import Cubical.Foundations.Prelude as Prelude
import Cubical.Foundations.Univalence as Univalence
import Cubical.Foundations.HLevels as HLevels
import Cubical.Foundations.Equiv as Equivalences
import Cubical.Data.Sigma.Properties as Sigma
import Cubical.HITs.PropositionalTruncation as PropositionalTruncation
import Cubical.HITs.Cost.Base as CostMonad
import Cubical.HITs.SetQuotients as SetQuotients
import Cubical.Data.Rationals as SetQuoQ
import Cubical.Data.Rationals.MoreRationals.SigmaQ
as SigmaQ
import Cubical.Foundations.SIP as SIP
import Cubical.Structures.Axioms as Axioms
import Cubical.Algebra.Semigroup.Base as Semigroup
open import Cubical.Data.Sigma.Base
import Cubical.Structures.Pointed as PointedStr
import Cubical.Structures.Constant as ConstantStr
import Cubical.Structures.Product as ProductStr
import Cubical.Structures.Function as FunctionStr
import Cubical.Structures.Maybe as MaybeStr
import Cubical.Foundations.Structure as Structure
import Cubical.Structures.Auto as Auto
open import Cubical.Data.Maybe.Base
import Cubical.Data.Vec.Base as Vector
import Cubical.Algebra.Matrix as Matrices
import Cubical.Data.FinData.Base as Finite
open import Cubical.Algebra.AbGroup.Base
open import Cubical.Data.Bool.Base
import Cubical.Structures.Queue as Queues
import Cubical.Data.Queue.Truncated2List as BatchedQueues
import Cubical.Relation.Binary.Base as BinRel
import Cubical.Relation.ZigZag.Base as QER
import Cubical.Relation.ZigZag.Applications.MultiSet
as MultiSets
import Cubical.Foundations.RelationalStructure as RelStructure
import Cubical.Structures.Relational.Function as RelFunction
open Path using (PathP) public
open Prelude using (_≡_ ; refl ; cong ; funExt
; transport ; subst ; J) public
open Univalence using (ua ; uaβ) public
open Prelude using (isProp ; isSet) public
open HLevels using (isPropΠ) public
open Prelude using (isContr) public
open Equivalences using (isEquiv ; _≃_) public
open Equivalences renaming (fiber to preim) public
open Sigma using (ΣPath≃PathΣ) public
open Equivalences renaming (propBiimpl→Equiv to prop≃) public
open PropositionalTruncation using (∥_∥₁ ; map) public
open CostMonad using (Cost ; Cost≡ ; _>>=_ ; return
; fib ; fibTail) public
_ : fib 20 ≡ (6765 , PropositionalTruncation.∣ 21890 ∣₁)
_ = refl
_ : fibTail 20 ≡ (6765 , PropositionalTruncation.∣ 19 ∣₁)
_ = refl
open SetQuotients using (_/_ ; setQuotUniversal) public
open SetQuoQ using (_∼_ ; ℚ) public
open SigmaQ renaming (ℚ to ℚ') public
open SIP using (TypeWithStr ; StrEquiv ; _≃[_]_
; UnivalentStr ; SIP ; sip) public
open Axioms using ( AxiomsStructure ; AxiomsEquivStr
; axiomsUnivalentStr ; transferAxioms) public
RawMonoidStructure : Type → Type
RawMonoidStructure X = X × (X → X → X)
MonoidAxioms : (M : Type) → RawMonoidStructure M → Type
MonoidAxioms M (e , _·_) = Semigroup.IsSemigroup _·_
× ((x : M) → (x · e ≡ x) × (e · x ≡ x))
MonoidStructure : Type → Type
MonoidStructure = AxiomsStructure RawMonoidStructure MonoidAxioms
Monoid : Type₁
Monoid = TypeWithStr ℓ-zero MonoidStructure
MonoidEquiv : (M N : Monoid) → fst M ≃ fst N → Type
MonoidEquiv (_ , (εᴹ , _·_) , _) (_ , (εᴺ , _∗_) , _) (φ , _) =
(φ εᴹ ≡ εᴺ) × (∀ x y → φ (x · y) ≡ (φ x) ∗ (φ y))
open PointedStr using (PointedStructure ; PointedEquivStr
; pointedUnivalentStr) public
open ConstantStr using (ConstantStructure ; ConstantEquivStr
; constantUnivalentStr) public
open ProductStr using (ProductStructure ; ProductEquivStr
; productUnivalentStr) public
open FunctionStr using (FunctionEquivStr) public
open MaybeStr using (MaybeEquivStr) public
open Structure using (EquivAction) public
open SIP using (TransportStr ; TransportStr→UnivalentStr
; UnivalentStr→TransportStr) public
open Structure using (EquivAction→StrEquiv) public
open FunctionStr using (FunctionEquivStr+) public
RawMonoid : Type₁
RawMonoid = TypeWithStr _ RawMonoidStructure
Monoid→RawMonoid : Monoid → RawMonoid
Monoid→RawMonoid (A , r , _) = (A , r)
RawMonoidEquivStr = Auto.AutoEquivStr RawMonoidStructure
rawMonoidUnivalentStr : UnivalentStr _ RawMonoidEquivStr
rawMonoidUnivalentStr = Auto.autoUnivalentStr RawMonoidStructure
isPropMonoidAxioms : (M : Type) (s : RawMonoidStructure M) → isProp (MonoidAxioms M s)
isPropMonoidAxioms M (e , _·_) =
HLevels.isPropΣ
(Semigroup.isPropIsSemigroup _·_)
(λ α → isPropΠ λ _ →
HLevels.isProp×
(Semigroup.IsSemigroup.is-set α _ _)
(Semigroup.IsSemigroup.is-set α _ _))
MonoidEquivStr : StrEquiv MonoidStructure ℓ-zero
MonoidEquivStr = AxiomsEquivStr RawMonoidEquivStr MonoidAxioms
monoidUnivalentStr : UnivalentStr MonoidStructure MonoidEquivStr
monoidUnivalentStr = axiomsUnivalentStr _ isPropMonoidAxioms rawMonoidUnivalentStr
MonoidΣPath : (M N : Monoid) → (M ≃[ MonoidEquivStr ] N) ≃ (M ≡ N)
MonoidΣPath = SIP monoidUnivalentStr
InducedMonoid : (M : Monoid) (N : RawMonoid) (e : M .fst ≃ N .fst)
→ RawMonoidEquivStr (Monoid→RawMonoid M) N e → Monoid
InducedMonoid M N e r =
Axioms.inducedStructure rawMonoidUnivalentStr M N (e , r)
InducedMonoidPath : (M : Monoid) (N : RawMonoid) (e : M .fst ≃ N .fst)
(E : RawMonoidEquivStr (Monoid→RawMonoid M) N e)
→ M ≡ InducedMonoid M N e E
InducedMonoidPath M N e E =
MonoidΣPath M (InducedMonoid M N e E) .fst (e , E)
open Auto using (Transp[_] ; AutoEquivStr ; autoUnivalentStr) public
module _ (A : Type) (Aset : isSet A) where
RawQueueEquivStr =
AutoEquivStr (λ (X : Type) → X × (A → X → X) × (X → Transp[ Maybe (X × A) ]))
open Vector using (Vec) public
open Finite using (Fin ; _==_) public
open Matrices using (VecMatrix ; FinMatrix ; FinMatrix≡VecMatrix
; FinMatrix≃VecMatrix) public
open Matrices.FinMatrixAbGroup using (addFinMatrix ; addFinMatrixComm) public
open import Cubical.Data.Int hiding (-_)
ℤ-AbGroup : AbGroup ℓ-zero
ℤ-AbGroup = makeAbGroup {G = ℤ} 0 _+_ -_ isSetℤ +Assoc (λ x _ → x) rem +Comm
where
-_ : ℤ → ℤ
- x = 0 - x
rem : (x : ℤ) → x + (- x) ≡ 0
rem x = +Comm x (pos 0 - x) Prelude.∙ minusPlus x 0
module experiment where
open Prelude
M : FinMatrix ℤ 2 2
M i j = if i == j then 1 else 0
N : FinMatrix ℤ 2 2
N i j = if i == j then 0 else 1
replaceGoal : {A B : Type} {x y : A} → (e : A ≃ B)
(h : invEq e (equivFun e x) ≡ invEq e (equivFun e y)) → x ≡ y
replaceGoal e h = sym (retEq e _) ∙∙ h ∙∙ retEq e _
_ : addFinMatrix ℤ-AbGroup M N ≡ (λ _ _ → 1)
_ = replaceGoal (FinMatrix≃VecMatrix) refl
open Queues.Queues-on using (RawQueueStructure ; QueueAxioms) public
open BatchedQueues.Truncated2List renaming (Q to BatchedQueueHIT)
using (Raw-1≡2 ; WithLaws) public
open BinRel using (idPropRel ; invPropRel
; compPropRel ; graphRel) public
open QER using (isZigZagComplete ; isQuasiEquivRel) public
open QER.QER→Equiv using (Thm ; bwd≡ToRel) public
open MultiSets renaming (AList to AssocList) public
open MultiSets.Lists&ALists using (addIfEq ; R ; φ ; ψ
; List/Rᴸ≃AList/Rᴬᴸ) public
open MultiSets.Lists&ALists.L using (insert ; union ; count)
open MultiSets.Lists&ALists.AL using (insert ; union ; count)
open RelStructure using (StrRel) public
open RelStructure using (SuitableStrRel) public
open RelStructure using (structuredQER→structuredEquiv) public
open RelStructure using (StrRelAction) public
open RelStructure using (strRelQuotientComparison) public
open RelStructure using (PositiveStrRel) public
open RelFunction using (functionSuitableRel) public
open MultiSets.Lists&ALists using (multisetShape ; isStructuredR ; main ; List/Rᴸ≡AList/Rᴬᴸ)
renaming ( hasAssociativeUnion to unionAssocAxiom
; LQassoc to LUnionAssoc
; ALQassoc to ALUnionAssoc) public