proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Category.Topos

Description

Elementary toposes: HasSubobjectClassifier provides the object Omega of truth values classifying monomorphisms, HasEpiMonoFactorization the image factorization, and ElementaryTopos combines these with finite (co)limits and exponentials, yielding the internal logic (false, and, or, implies).

Synopsis

Documentation

class (HasProducts k, Ob (Omega :: k)) => HasSubobjectClassifier k where Source Github #

Minimal complete definition

classifyGraph

Associated Types

type Omega :: k Source Github #

Methods

true :: (TerminalObject :: k) ~> (Omega :: k) Source Github #

default true :: (HasProducts k, HasPushouts k) => (TerminalObject :: k) ~> (Omega :: k) Source Github #

classifyGraph :: forall (a :: k) (b :: k). (a ~> b) -> (a && b) ~> (Omega :: k) Source Github #

Classify the graph (id *** f :: a ~> a && b) of a morphism f. This is a minimal primitive that works for any morphism.

Instances

Instances details
HasSubobjectClassifier FINHASK Source Github #
>>> import Proarrow.Colimit.Pushout (isEpi)
>>> let f :: FinHask (FH (Fin 3)) (FH (Fin 3)) = fromList [(0,2), (1,0), (2,1)]
>>> (pushout f f \(FinHask g1) (FinHask g2) -> P.show (g1, g2)) :: P.String
"(fromList [(0,0),(1,1),(2,2)],fromList [(0,0),(1,1),(2,2)])"
>>> isEpi (f :: FinHask (FH (Fin 3)) (FH (Fin 3)))
True
>>> import Proarrow.Limit.Pullback (isMono)
>>> (pullback f f \(FinHask l) (FinHask r) -> P.show (l, r)) :: P.String
"(fromList [(0,0),(1,1),(2,2)],fromList [(0,0),(1,1),(2,2)])"
>>> isMono f
True
>>> import Proarrow.Category.Topos (classifyImage, classifyKernelPair, and, or, implies, false)
>>> (case factorize f of p :.: q -> P.show (p, q) \\ p \\ q) :: P.String
"(fromList [(0,0),(1,1),(2,2)],fromList [(0,2),(1,0),(2,1)])"
>>> (classifyImage f, classifyKernelPair f)
(fromList [(0,True),(1,True),(2,True)],fromList [((0,0),True),((0,1),False),((0,2),False),((1,0),False),((1,1),True),((1,2),False),((2,0),False),((2,1),False),((2,2),True)])
>>> [and, or, implies] :: [FinHask (FH (Bool, Bool)) (FH Bool)]
[fromList [((False,False),False),((False,True),False),((True,False),False),((True,True),True)],fromList [((False,False),False),((False,True),True),((True,False),True),((True,True),True)],fromList [((False,False),True),((False,True),True),((True,False),False),((True,True),True)]]
>>> false :: FinHask (FH ()) (FH Bool)
fromList [((),False)]
Instance details

Defined in Proarrow.Category.Instance.FinHask

Associated Types

type Omega 
Instance details

Defined in Proarrow.Category.Instance.FinHask

type Omega = 'FH Bool

Methods

true :: (TerminalObject :: FINHASK) ~> (Omega :: FINHASK) Source Github #

classifyGraph :: forall (a :: FINHASK) (b :: FINHASK). (a ~> b) -> (a && b) ~> (Omega :: FINHASK) Source Github #

HasSubobjectClassifier FINSET Source Github #
>>> import Proarrow.Colimit.Pushout (isEpi)
>>> import Data.Fin
>>> import Data.Type.Nat
>>> let f :: FinSet (FS Nat3) (FS Nat3) = FinSet $ fin2 ::: fin0 ::: fin1 ::: VNil
>>> (pushout f f \(FinSet g1) (FinSet g2) -> P.show (g1, g2)) :: P.String
"(0 ::: 1 ::: 2 ::: VNil,0 ::: 1 ::: 2 ::: VNil)"
>>> isEpi f
True
>>> import Proarrow.Limit.Pullback (isMono)
>>> (pullback f f \(FinSet l) (FinSet r) -> P.show (l, r)) :: P.String
"(0 ::: 1 ::: 2 ::: VNil,0 ::: 1 ::: 2 ::: VNil)"
>>> isMono f
True
>>> import Proarrow.Category.Topos (classifyImage, classifyKernelPair, and, or, implies, false)
>>> (classifyImage f, classifyKernelPair f)
(FinSet {unFinSet = 1 ::: 1 ::: 1 ::: VNil},FinSet {unFinSet = 1 ::: 0 ::: 0 ::: 0 ::: 1 ::: 0 ::: 0 ::: 0 ::: 1 ::: VNil})
>>> [and, or, implies] :: [FinSet (FS Nat4) (FS Nat2)]
[FinSet {unFinSet = 0 ::: 0 ::: 0 ::: 1 ::: VNil},FinSet {unFinSet = 0 ::: 1 ::: 1 ::: 1 ::: VNil},FinSet {unFinSet = 1 ::: 1 ::: 0 ::: 1 ::: VNil}]
>>> false :: FinSet (FS Nat1) (FS Nat2)
FinSet {unFinSet = 0 ::: VNil}
Instance details

Defined in Proarrow.Category.Instance.FinSet

Associated Types

type Omega 
Instance details

Defined in Proarrow.Category.Instance.FinSet

type Omega = 'FS Nat2

Methods

true :: (TerminalObject :: FINSET) ~> (Omega :: FINSET) Source Github #

classifyGraph :: forall (a :: FINSET) (b :: FINSET). (a ~> b) -> (a && b) ~> (Omega :: FINSET) Source Github #

(StableSite t k, HasFiniteCovers t k, FiniteCat j, FiniteCat k) => HasSubobjectClassifier (PROD (SHEAVES t j k)) Source Github #

The classifier is the closed sieves, and an arrow is classified by FINITARY's graph sieve, closed. For an arrow of sheaves that sieve is already closed, since a sheaf is separated. The closedSieve call guards against a Sheaf instance that was asserted instead of decided, which would otherwise fail later in familyIndex as "not a closed sieve".

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

Associated Types

type Omega 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

type Omega = 'PR ('SUB (ClosedSieve t :: k -> j -> Type) :: SUBCAT ((Finitary :: (j +-> k) -> Constraint) :&&: (Sheaf t :: (j +-> k) -> Constraint)))

Methods

true :: (TerminalObject :: PROD (SHEAVES t j k)) ~> (Omega :: PROD (SHEAVES t j k)) Source Github #

classifyGraph :: forall (a :: PROD (SHEAVES t j k)) (b :: PROD (SHEAVES t j k)). (a ~> b) -> (a && b) ~> (Omega :: PROD (SHEAVES t j k)) Source Github #

(FiniteCat j, FiniteCat k) => HasSubobjectClassifier (PROD (FINITARY j k)) Source Github #

The subobject classifier is the profunctor of sieves, and an arrow classifies its graph.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Associated Types

type Omega 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

type Omega = 'PR ('SUB (Sieve :: k -> j -> Type) :: SUBCAT (Finitary :: (j +-> k) -> Constraint))

Methods

true :: (TerminalObject :: PROD (FINITARY j k)) ~> (Omega :: PROD (FINITARY j k)) Source Github #

classifyGraph :: forall (a :: PROD (FINITARY j k)) (b :: PROD (FINITARY j k)). (a ~> b) -> (a && b) ~> (Omega :: PROD (FINITARY j k)) Source Github #

isEq :: forall {k} (a :: k). (HasSubobjectClassifier k, Ob a) => (a && a) ~> (Omega :: k) Source Github #

classifyImage :: forall {k} (a :: k) (b :: k). (HasSubobjectClassifier k, HasPushouts k) => (a ~> b) -> b ~> (Omega :: k) Source Github #

classify f classifies the image of f. If f is mono, then this returns its characteristic map.

classifyKernelPair :: forall {k} (a :: k) (b :: k). HasSubobjectClassifier k => (a ~> b) -> (a && a) ~> (Omega :: k) Source Github #

class CategoryOf k => HasEpiMonoFactorization k where Source Github #

Minimal complete definition

Nothing

Methods

factorize :: forall (a :: k) (b :: k). (a ~> b) -> (Hom k :.: Hom k) a b Source Github #

Factor an arrow as an epi followed by a mono. Defaults to defaultFactorize, the image factorization via the cokernel pair, which applies whenever k has pushouts and equalizers.

default factorize :: forall (a :: k) (b :: k). (HasPushouts k, HasEqualizers k) => (a ~> b) -> (Hom k :.: Hom k) a b Source Github #

Instances

Instances details
HasEpiMonoFactorization COST Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Cost

Methods

factorize :: forall (a :: COST) (b :: COST). (a ~> b) -> (Hom COST :.: Hom COST) a b Source Github #

HasEpiMonoFactorization FINHASK Source Github # 
Instance details

Defined in Proarrow.Category.Instance.FinHask

Methods

factorize :: forall (a :: FINHASK) (b :: FINHASK). (a ~> b) -> (Hom FINHASK :.: Hom FINHASK) a b Source Github #

HasEpiMonoFactorization FINSET Source Github # 
Instance details

Defined in Proarrow.Category.Instance.FinSet

Methods

factorize :: forall (a :: FINSET) (b :: FINSET). (a ~> b) -> (Hom FINSET :.: Hom FINSET) a b Source Github #

Indexed k => HasEpiMonoFactorization (CODISCRETE k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Discrete

Methods

factorize :: forall (a :: CODISCRETE k) (b :: CODISCRETE k). (a ~> b) -> (Hom (CODISCRETE k) :.: Hom (CODISCRETE k)) a b Source Github #

Indexed k => HasEpiMonoFactorization (DISCRETE k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Discrete

Methods

factorize :: forall (a :: DISCRETE k) (b :: DISCRETE k). (a ~> b) -> (Hom (DISCRETE k) :.: Hom (DISCRETE k)) a b Source Github #

(Fractional a, Eq a) => HasEpiMonoFactorization (MatK a) Source Github #

Epi-mono factorization is computed via defaultFactorize: f factors as the coequalizer of its cokernel pair (the epi onto its image) followed by the equalizer factorization of f through that epi (the mono inclusion of the image).

>>> import Proarrow.Profunctor.Instance.Composition ((:.:) (..))
>>> let h = Mat @(S (S Z)) @(S (S Z)) ((1 ::: 2 ::: VNil) ::: (2 ::: 4 ::: VNil) ::: VNil) :: Mat (M (S (S Z))) (M (S (S Z)) :: MatK P.Double)
>>> (case factorize h of e :.: m -> case (e, m) of (Mat ev, Mat mv) -> P.show (ev, mv, unMat (m . e))) :: P.String
"((2.0 ::: 4.0 ::: VNil) ::: VNil,(0.5 ::: VNil) ::: (1.0 ::: VNil) ::: VNil,(1.0 ::: 2.0 ::: VNil) ::: (2.0 ::: 4.0 ::: VNil) ::: VNil)"
Instance details

Defined in Proarrow.Category.Instance.Mat

Methods

factorize :: forall (a0 :: MatK a) (b :: MatK a). (a0 ~> b) -> (Hom (MatK a) :.: Hom (MatK a)) a0 b Source Github #

HasEpiMonoFactorization (ORDINAL n) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Ordinal

Methods

factorize :: forall (a :: ORDINAL n) (b :: ORDINAL n). (a ~> b) -> (Hom (ORDINAL n) :.: Hom (ORDINAL n)) a b Source Github #

HasEpiMonoFactorization k => HasEpiMonoFactorization (PROD k) Source Github #

Image factorization is unchanged by making the tensor the product.

Instance details

Defined in Proarrow.Category.Topos

Methods

factorize :: forall (a :: PROD k) (b :: PROD k). (a ~> b) -> (Hom (PROD k) :.: Hom (PROD k)) a b Source Github #

(Enumerable j, Enumerable k) => HasEpiMonoFactorization (FINITARY j k) Source Github #

The image of a natural transformation is the equalizer of its cokernel pair.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

factorize :: forall (a :: FINITARY j k) (b :: FINITARY j k). (a ~> b) -> (Hom (FINITARY j k) :.: Hom (FINITARY j k)) a b Source Github #

(HasPushouts j, HasEqualizers j, HasPushouts k, HasEqualizers k) => HasEpiMonoFactorization (COPRODUCT j k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Coproduct

Methods

factorize :: forall (a :: COPRODUCT j k) (b :: COPRODUCT j k). (a ~> b) -> (Hom (COPRODUCT j k) :.: Hom (COPRODUCT j k)) a b Source Github #

(HasFiniteCovers t k, FiniteCat j, FiniteCat k) => HasEpiMonoFactorization (SHEAVES t j k) Source Github #

The image of an arrow of sheaves, by the same cokernel-pair construction as in FINITARY: the pushout is a colimit and so sheafified, the equalizer that follows it is not.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

Methods

factorize :: forall (a :: SHEAVES t j k) (b :: SHEAVES t j k). (a ~> b) -> (Hom (SHEAVES t j k) :.: Hom (SHEAVES t j k)) a b Source Github #

defaultFactorize :: forall k (a :: k) (b :: k). (HasPushouts k, HasEqualizers k) => (a ~> b) -> (Hom k :.: Hom k) a b Source Github #

defaultFactorizeDual :: forall k (a :: k) (b :: k). (HasPullbacks k, HasCoequalizers k) => (a ~> b) -> (Hom k :.: Hom k) a b Source Github #

class (HasFiniteLimits k, HasFiniteColimits k, CCC k, HasSubobjectClassifier k, HasEpiMonoFactorization k) => ElementaryTopos k Source Github #

Instances

Instances details
ElementaryTopos FINHASK Source Github # 
Instance details

Defined in Proarrow.Category.Instance.FinHask

ElementaryTopos FINSET Source Github # 
Instance details

Defined in Proarrow.Category.Instance.FinSet

(StableSite t k, HasFiniteCovers t k, FiniteCat j, FiniteCat k) => ElementaryTopos (PROD (SHEAVES t j k)) Source Github #

The topos of sheaves. Finite limits and colimits, cartesian closed, a subobject classifier, and image factorization, all defined above and none of them postulated.

The exponential needs StableSite. A full subcategory is closed when it contains its internal homs, and an internal hom is a sheaf by gluing pointwise into the codomain, which needs the cover pulled back along the argument.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

(FiniteCat j, FiniteCat k) => ElementaryTopos (PROD (FINITARY j k)) Source Github #

Finitary profunctors between finite categories form an elementary topos: finite limits and colimits, cartesian closed, a subobject classifier, and image factorization.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

and :: ElementaryTopos k => ((Omega :: k) && (Omega :: k)) ~> (Omega :: k) Source Github #

or :: ElementaryTopos k => ((Omega :: k) && (Omega :: k)) ~> (Omega :: k) Source Github #

implies :: ElementaryTopos k => ((Omega :: k) && (Omega :: k)) ~> (Omega :: k) Source Github #

not :: ElementaryTopos k => (Omega :: k) ~> (Omega :: k) Source Github #

Negation: the classifying map of false, which is a mono as every arrow out of the terminal object is. The same arrow as u ⇒ false.

Lawvere–Tierney topologies

A Lawvere–Tierney topology is an arrow j :: Omega ~> Omega that fixes true, is idempotent and preserves and. Its sheaves form a subtopos. Every topos has the two extremes, id (every object a sheaf) and const true (only the terminal one), and the internal logic gives the ones below. A coverage gives another, by closing sieves: lawvereTierney. Proarrow.Testing.Laws.testLawvereTierney checks the three laws.

doubleNegation :: ElementaryTopos k => (Omega :: k) ~> (Omega :: k) Source Github #

The double-negation topology ¬¬, whose sheaves form the smallest dense subtopos, and a Boolean one. On a presheaf topos it is the dense topology: a sieve on a covers when every arrow into a can be extended to one in the sieve. When every cospan can be completed to a commuting square (the Ore condition, which pullbacks provide), that is the atomic topology, so there Atomic computes this by closing sieves. In a Boolean topos it is id.

openTopology :: ElementaryTopos k => ((TerminalObject :: k) ~> (Omega :: k)) -> (Omega :: k) ~> (Omega :: k) Source Github #

The open topology of a truth value u: u ⇒ -. Its sheaves are the open subtopos of the subterminal object u classifies, the part of the topos lying over u. openTopology true is id and openTopology false is const true.

closedTopology :: ElementaryTopos k => ((TerminalObject :: k) ~> (Omega :: k)) -> (Omega :: k) ~> (Omega :: k) Source Github #

The closed topology of a truth value u: u ∨ -, complementary to openTopology. Its sheaves are the part of the topos lying away from u. closedTopology true is const true and closedTopology false is id.