{-# LANGUAGE AllowAmbiguousTypes #-}
module Proarrow.Category.Sheaf where
import Data.Kind (Constraint, Type)
import Data.List (subsequences, tails)
import Data.Maybe (fromMaybe, listToMaybe)
import Prelude (Bool, Maybe (..), and, error, not, null, (||))
import Proarrow.Category.Enriched.Finitary (Finitary (..), FiniteCat, LocallyFinite, factorThrough, foreachOb)
import Proarrow.Category.Enriched.Thin (Thin)
import Proarrow.Category.Instance.Free (Elem, FREE)
import Proarrow.Category.Instance.Opposite (OPPOSITE (..))
import Proarrow.Category.Monoidal.Cartesian (Bicartesian)
import Proarrow.Colimit.BinaryCoproduct (HasBinaryCoproducts (..), type (+))
import Proarrow.Colimit.Initial (HasInitialObject (..))
import Proarrow.Core (CAT, CategoryOf (..), Hom, Kind, Profunctor (..), Promonad (..), obj, rmap, (//), type (+->))
import Proarrow.Limit.BinaryProduct (HasBinaryProducts (..))
import Proarrow.Limit.Pullback (HasPullbacks (..))
import Proarrow.Object (pattern Objs)
import Proarrow.Profunctor.Corepresentable (Corepresentable (..), withObCorep)
import Proarrow.Profunctor.Instance.Product (fstP, sndP, (:*:) (..))
import Proarrow.Profunctor.Instance.Rift (Rift (..))
import Proarrow.Profunctor.Instance.Terminal (TerminalProfunctor (..))
import Proarrow.Profunctor.Instance.Yoneda (Yo (..))
type Coverage :: Kind
type Coverage = Type
type Site :: Coverage -> Kind -> Constraint
class (CategoryOf k) => Site t k where
data Cover t k (a :: k) (c :: Type)
data Leg t k (a :: k) (c :: Type) (x :: k)
legArrow :: Leg t k a c x -> x ~> a
legs :: Cover t k a c -> [SomeLeg t k a c]
type SomeLeg :: Coverage -> forall (k :: Kind) -> k -> Type -> Type
data SomeLeg t k a c where
SomeLeg :: Leg t k a c x -> SomeLeg t k a c
class (Site t k) => HasFiniteCovers t k where
covers :: forall (a :: k). (Ob a) => [SomeCover t k a]
type SomeCover :: Coverage -> forall (k :: Kind) -> k -> Type
data SomeCover t k a where
SomeCover :: Cover t k a c -> SomeCover t k a
type Factors :: Coverage -> forall (k :: Kind) -> k -> Type -> k -> Type
data Factors t k a c x where
Factors :: Leg t k a c y -> x ~> y -> Factors t k a c x
factorThroughCover :: (Site t k, LocallyFinite k) => Cover t k a c -> x ~> a -> Maybe (Factors t k a c x)
factorThroughCover :: forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
(Site t k, LocallyFinite k) =>
Cover t k a c -> (x ~> a) -> Maybe (Factors t k a c x)
factorThroughCover Cover t k a c
c x ~> a
h = [Factors t k a c x] -> Maybe (Factors t k a c x)
forall (a :: Coverage). [a] -> Maybe a
listToMaybe [Leg t k a c x -> (x ~> x) -> Factors t k a c x
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors Leg t k a c x
l x ~> x
u | SomeLeg Leg t k a c x
l <- Cover t k a c -> [SomeLeg t k a c]
forall (a :: k) (c :: Coverage). Cover t k a c -> [SomeLeg t k a c]
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage).
Site t k =>
Cover t k a c -> [SomeLeg t k a c]
legs Cover t k a c
c, Just x ~> x
u <- [x ~> a
h (x ~> a) -> ((Ob x, Ob a) => Maybe (x ~> x)) -> Maybe (x ~> x)
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// Leg t k a c x -> x ~> a
forall (a :: k) (c :: Coverage) (x :: k). Leg t k a c x -> x ~> a
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
Site t k =>
Leg t k a c x -> x ~> a
legArrow Leg t k a c x
l (x ~> a) -> ((Ob x, Ob a) => Maybe (x ~> x)) -> Maybe (x ~> x)
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (x ~> a) -> (x ~> a) -> Maybe (x ~> x)
forall {k :: Coverage} (x :: k) (y :: k) (a :: k).
(LocallyFinite k, Ob x, Ob y, Ob a) =>
(x ~> a) -> (y ~> a) -> Maybe (x ~> y)
factorThrough x ~> a
h (Leg t k a c x -> x ~> a
forall (a :: k) (c :: Coverage) (x :: k). Leg t k a c x -> x ~> a
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
Site t k =>
Leg t k a c x -> x ~> a
legArrow Leg t k a c x
l)]]
type PulledBack :: Coverage -> forall (k :: Kind) -> k -> Type -> k -> Type
data PulledBack t k a c b where
AlreadyFactors :: Factors t k a c b -> PulledBack t k a c b
PulledBack :: Cover t k b c' -> (forall x. Leg t k b c' x -> Factors t k a c x) -> PulledBack t k a c b
class (Site t k) => StableSite t k where
pullbackCover :: (Ob b) => Cover t k a c -> b ~> a -> PulledBack t k a c b
pullbackAlongId :: (Site t k) => Cover t k a c -> PulledBack t k a c a
pullbackAlongId :: forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage).
Site t k =>
Cover t k a c -> PulledBack t k a c a
pullbackAlongId Cover t k a c
c = Cover t k a c
-> (forall (x :: k). Leg t k a c x -> Factors t k a c x)
-> PulledBack t k a c a
forall (t :: Coverage) (k :: Coverage) (b :: k) (d :: Coverage)
(a :: k) (c :: Coverage).
Cover t k b d
-> (forall (x :: k). Leg t k b d x -> Factors t k a c x)
-> PulledBack t k a c b
PulledBack Cover t k a c
c \Leg t k a c x
l -> Leg t k a c x -> x ~> a
forall (a :: k) (c :: Coverage) (x :: k). Leg t k a c x -> x ~> a
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
Site t k =>
Leg t k a c x -> x ~> a
legArrow Leg t k a c x
l (x ~> a)
-> ((Ob x, Ob a) => Factors t k a c x) -> Factors t k a c x
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// Leg t k a c x -> (x ~> x) -> Factors t k a c x
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors Leg t k a c x
l x ~> x
forall (a :: k). Ob a => a ~> a
forall {k :: Coverage} (p :: CAT k) (a :: k).
(Promonad p, Ob a) =>
p a a
id
type Sheaf :: forall {j} {k}. Coverage -> j +-> k -> Constraint
class (Site t k, Profunctor p) => Sheaf t (p :: j +-> k) where
glue
:: forall (a :: k) c (b :: j)
. (Ob a, Ob b)
=> Cover t k a c
-> (forall x. Leg t k a c x -> p x b)
-> p a b
instance (Site t k, CategoryOf j) => Sheaf t (TerminalProfunctor :: j +-> k) where
glue :: forall (a :: k) (c :: Coverage) (b :: j).
(Ob a, Ob b) =>
Cover t k a c
-> (forall (x :: k). Leg t k a c x -> TerminalProfunctor x b)
-> TerminalProfunctor a b
glue Cover t k a c
_ forall (x :: k). Leg t k a c x -> TerminalProfunctor x b
_ = TerminalProfunctor a b
forall {j :: Coverage} {k :: Coverage} (a :: j) (b :: k).
(CategoryOf j, CategoryOf k, Ob a, Ob b) =>
TerminalProfunctor a b
TerminalProfunctor
instance (Sheaf t p, Sheaf t q) => Sheaf t (p :*: q) where
glue :: forall (a :: k) (c :: Coverage) (b :: j).
(Ob a, Ob b) =>
Cover t k a c
-> (forall (x :: k). Leg t k a c x -> (:*:) p q x b)
-> (:*:) p q a b
glue Cover t k a c
c forall (x :: k). Leg t k a c x -> (:*:) p q x b
m = forall {j :: Coverage} {k :: Coverage} (t :: Coverage)
(p :: j +-> k) (a :: k) (c :: Coverage) (b :: j).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
forall (t :: Coverage) (p :: j +-> k) (a :: k) (c :: Coverage)
(b :: j).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
glue @t Cover t k a c
c (\Leg t k a c x
g -> (:*:) p q x b -> p x b
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j) (q :: j +-> k).
(:*:) p q a b -> p a b
fstP (Leg t k a c x -> (:*:) p q x b
forall (x :: k). Leg t k a c x -> (:*:) p q x b
m Leg t k a c x
g)) p a b -> q a b -> (:*:) p q a b
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j) (q :: j +-> k).
p a b -> q a b -> (:*:) p q a b
:*: forall {j :: Coverage} {k :: Coverage} (t :: Coverage)
(p :: j +-> k) (a :: k) (c :: Coverage) (b :: j).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
forall (t :: Coverage) (p :: j +-> k) (a :: k) (c :: Coverage)
(b :: j).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
glue @t Cover t k a c
c (\Leg t k a c x
g -> (:*:) p q x b -> q x b
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j) (q :: j +-> k).
(:*:) p q a b -> q a b
sndP (Leg t k a c x -> (:*:) p q x b
forall (x :: k). Leg t k a c x -> (:*:) p q x b
m Leg t k a c x
g))
type Trivial :: Coverage
type data Trivial
instance (CategoryOf k) => Site Trivial k where
data Cover Trivial k a c
data Leg Trivial k a c x
legArrow :: forall (a :: k) (c :: Coverage) (x :: k).
Leg Trivial k a c x -> x ~> a
legArrow Leg Trivial k a c x
g = case Leg Trivial k a c x
g of {}
legs :: forall (a :: k) (c :: Coverage).
Cover Trivial k a c -> [SomeLeg Trivial k a c]
legs Cover Trivial k a c
c = case Cover Trivial k a c
c of {}
instance (CategoryOf k) => HasFiniteCovers Trivial k where
covers :: forall (a :: k). Ob a => [SomeCover Trivial k a]
covers = []
instance (CategoryOf k) => StableSite Trivial k where
pullbackCover :: forall (b :: k) (a :: k) (c :: Coverage).
Ob b =>
Cover Trivial k a c -> (b ~> a) -> PulledBack Trivial k a c b
pullbackCover Cover Trivial k a c
c b ~> a
_ = case Cover Trivial k a c
c of {}
glueTrivial :: Cover Trivial k a c -> (forall x. Leg Trivial k a c x -> p x b) -> p a b
glueTrivial :: forall {k :: Coverage} (k :: Coverage) (a :: k) (c :: Coverage)
(p :: k -> k -> Coverage) (b :: k).
Cover Trivial k a c
-> (forall (x :: k). Leg Trivial k a c x -> p x b) -> p a b
glueTrivial Cover Trivial k a c
c forall (x :: k). Leg Trivial k a c x -> p x b
_ = case Cover Trivial k a c
c of {}
type Atomic :: Coverage
type data Atomic
type data Along (b :: k)
instance (HasPullbacks k, FiniteCat k) => Site Atomic k where
data Cover Atomic k a c where
Solely :: (Ob b) => b ~> a -> Cover Atomic k a (Along b)
data Leg Atomic k a c x where
Only :: (Ob b) => b ~> a -> Leg Atomic k a (Along b) b
legArrow :: forall (a :: k) (c :: Coverage) (x :: k).
Leg Atomic k a c x -> x ~> a
legArrow (Only x ~> a
f) = x ~> a
f
legs :: forall (a :: k) (c :: Coverage).
Cover Atomic k a c -> [SomeLeg Atomic k a c]
legs (Solely b ~> a
f) = [Leg Atomic k a c b -> SomeLeg Atomic k a c
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg ((b ~> a) -> Leg Atomic k a (Along b) b
forall (k :: Coverage) (b :: k) (a :: k).
Ob b =>
(b ~> a) -> Leg Atomic k a (Along b) b
Only b ~> a
f)]
instance (HasPullbacks k, FiniteCat k) => HasFiniteCovers Atomic k where
covers :: forall (a :: k). Ob a => [SomeCover Atomic k a]
covers @a = forall (k :: Coverage) (r :: Coverage).
Enumerable k =>
(forall (a :: k). Ob a => [r]) -> [r]
foreachOb @k \ @b -> [Cover Atomic k a (Along a) -> SomeCover Atomic k a
forall (t :: Coverage) (k :: Coverage) (a :: k) (d :: Coverage).
Cover t k a d -> SomeCover t k a
SomeCover ((a ~> a) -> Cover Atomic k a (Along a)
forall (k :: Coverage) (d :: k) (a :: k).
Ob d =>
(d ~> a) -> Cover Atomic k a (Along d)
Solely a ~> a
f) | a ~> a
f <- forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
[p a b]
elements @(Hom k) @b @a]
instance (HasPullbacks k, FiniteCat k) => StableSite Atomic k where
pullbackCover :: forall (b :: k) (a :: k) (c :: Coverage).
Ob b =>
Cover Atomic k a c -> (b ~> a) -> PulledBack Atomic k a c b
pullbackCover (Solely b ~> a
f) b ~> a
g = (b ~> a)
-> (b ~> a)
-> (forall (p :: k).
(p ~> b) -> (p ~> b) -> PulledBack Atomic k a c b)
-> PulledBack Atomic k a c b
forall (o :: k) (a :: k) (b :: k) (r :: Coverage).
(a ~> o)
-> (b ~> o) -> (forall (p :: k). (p ~> a) -> (p ~> b) -> r) -> r
forall (k :: Coverage) (o :: k) (a :: k) (b :: k) (r :: Coverage).
HasPullbacks k =>
(a ~> o)
-> (b ~> o) -> (forall (p :: k). (p ~> a) -> (p ~> b) -> r) -> r
pullback b ~> a
f b ~> a
g \p ~> b
p1 p ~> b
p2 -> p ~> b
p1 (p ~> b)
-> ((Ob p, Ob b) => PulledBack Atomic k a c b)
-> PulledBack Atomic k a c b
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// Cover Atomic k b (Along p)
-> (forall (x :: k).
Leg Atomic k b (Along p) x -> Factors Atomic k a c x)
-> PulledBack Atomic k a c b
forall (t :: Coverage) (k :: Coverage) (b :: k) (d :: Coverage)
(a :: k) (c :: Coverage).
Cover t k b d
-> (forall (x :: k). Leg t k b d x -> Factors t k a c x)
-> PulledBack t k a c b
PulledBack ((p ~> b) -> Cover Atomic k b (Along p)
forall (k :: Coverage) (d :: k) (a :: k).
Ob d =>
(d ~> a) -> Cover Atomic k a (Along d)
Solely p ~> b
p2) \(Only x ~> b
_) -> Leg Atomic k a c b -> (x ~> b) -> Factors Atomic k a c x
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors ((b ~> a) -> Leg Atomic k a (Along b) b
forall (k :: Coverage) (b :: k) (a :: k).
Ob b =>
(b ~> a) -> Leg Atomic k a (Along b) b
Only b ~> a
f) p ~> b
x ~> b
p1
type Joins :: Coverage
type data Joins
type data Join
instance (Thin k, FiniteCat k, Bicartesian k) => Site Joins k where
data Cover Joins k a c where
ByJoin :: [SomeLeg Joins k a Join] -> Cover Joins k a Join
data Leg Joins k a c x where
Under :: (Ob x) => x ~> a -> Leg Joins k a Join x
legArrow :: forall (a :: k) (c :: Coverage) (x :: k).
Leg Joins k a c x -> x ~> a
legArrow (Under x ~> a
f) = x ~> a
f
legs :: forall (a :: k) (c :: Coverage).
Cover Joins k a c -> [SomeLeg Joins k a c]
legs (ByJoin [SomeLeg Joins k a Join]
ls) = [SomeLeg Joins k a c]
[SomeLeg Joins k a Join]
ls
instance (Thin k, FiniteCat k, Bicartesian k) => HasFiniteCovers Joins k where
covers :: forall (a :: k). Ob a => [SomeCover Joins k a]
covers @a = [Cover Joins k a Join -> SomeCover Joins k a
forall (t :: Coverage) (k :: Coverage) (a :: k) (d :: Coverage).
Cover t k a d -> SomeCover t k a
SomeCover ([SomeLeg Joins k a Join] -> Cover Joins k a Join
forall (k :: Coverage) (a :: k).
[SomeLeg Joins k a Join] -> Cover Joins k a Join
ByJoin [SomeLeg Joins k a Join]
ls) | [SomeLeg Joins k a Join]
ls <- [SomeLeg Joins k a Join] -> [[SomeLeg Joins k a Join]]
forall (a :: Coverage). [a] -> [[a]]
subsequences [SomeLeg Joins k a Join]
strictlyBelow, [SomeLeg Joins k a Join] -> Bool
forall {k :: Coverage} {a :: k}.
(Enumerable k, Finitary (~>)) =>
[SomeLeg Joins k a Join] -> Bool
isAntichain [SomeLeg Joins k a Join]
ls, [SomeLeg Joins k a Join] -> Bool
isJoin [SomeLeg Joins k a Join]
ls]
where
strictlyBelow :: [SomeLeg Joins k a Join]
strictlyBelow :: [SomeLeg Joins k a Join]
strictlyBelow = forall (k :: Coverage) (r :: Coverage).
Enumerable k =>
(forall (a :: k). Ob a => [r]) -> [r]
foreachOb @k \ @x -> [Leg Joins k a Join a -> SomeLeg Joins k a Join
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg ((a ~> a) -> Leg Joins k a Join a
forall (k :: Coverage) (x :: k) (a :: k).
Ob x =>
(x ~> a) -> Leg Joins k a Join x
Under a ~> a
f) | Bool -> Bool
not ((a ~> a) -> (a ~> a) -> Bool
forall {k :: Coverage} (x :: k) (y :: k) (a :: k) (b :: k).
FiniteCat k =>
(x ~> a) -> (y ~> b) -> Bool
sourceBelow (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k :: Coverage} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @a) (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k :: Coverage} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @x)), a ~> a
f <- forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
[p a b]
elements @(Hom k) @x @a]
isAntichain :: [SomeLeg Joins k a Join] -> Bool
isAntichain [SomeLeg Joins k a Join]
ls = [Bool] -> Bool
forall (t :: Coverage -> Coverage). Foldable t => t Bool -> Bool
and [Bool -> Bool
not (SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
forall (k :: Coverage) (a :: k).
FiniteCat k =>
SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
legBelow SomeLeg Joins k a Join
l SomeLeg Joins k a Join
m Bool -> Bool -> Bool
|| SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
forall (k :: Coverage) (a :: k).
FiniteCat k =>
SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
legBelow SomeLeg Joins k a Join
m SomeLeg Joins k a Join
l) | SomeLeg Joins k a Join
l : [SomeLeg Joins k a Join]
ms <- [SomeLeg Joins k a Join] -> [[SomeLeg Joins k a Join]]
forall (a :: Coverage). [a] -> [[a]]
tails [SomeLeg Joins k a Join]
ls, SomeLeg Joins k a Join
m <- [SomeLeg Joins k a Join]
ms]
isJoin :: [SomeLeg Joins k a Join] -> Bool
isJoin [SomeLeg Joins k a Join]
ls = [SomeLeg Joins k a Join]
-> (forall (j :: k). (j ~> a) -> Bool) -> Bool
forall {k :: Coverage} (a :: k) (r :: Coverage).
(HasBinaryCoproducts k, HasInitialObject k, Ob a) =>
[SomeLeg Joins k a Join] -> (forall (j :: k). (j ~> a) -> r) -> r
joinOf [SomeLeg Joins k a Join]
ls ((a ~> a) -> (j ~> a) -> Bool
forall {k :: Coverage} (x :: k) (y :: k) (a :: k) (b :: k).
FiniteCat k =>
(x ~> a) -> (y ~> b) -> Bool
sourceBelow (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k :: Coverage} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @a))
instance (Thin k, FiniteCat k, Bicartesian k) => StableSite Joins k where
pullbackCover :: forall (b :: k) (a :: k) (c :: Coverage).
Ob b =>
Cover Joins k a c -> (b ~> a) -> PulledBack Joins k a c b
pullbackCover c :: Cover Joins k a c
c@(ByJoin [SomeLeg Joins k a Join]
ls) b ~> a
f = Cover Joins k a Join
-> [SomeLeg Joins k a Join]
-> (b ~> a)
-> PulledBack Joins k a Join b
forall {k :: Coverage} (b :: k) (a :: k).
(Thin k, FiniteCat k, Bicartesian k, Ob b) =>
Cover Joins k a Join
-> [SomeLeg Joins k a Join]
-> (b ~> a)
-> PulledBack Joins k a Join b
pullbackJoin Cover Joins k a c
Cover Joins k a Join
c [SomeLeg Joins k a Join]
ls b ~> a
f
sourceBelow :: forall {k} (x :: k) (y :: k) a b. (FiniteCat k) => x ~> a -> y ~> b -> Bool
sourceBelow :: forall {k :: Coverage} (x :: k) (y :: k) (a :: k) (b :: k).
FiniteCat k =>
(x ~> a) -> (y ~> b) -> Bool
sourceBelow x ~> a
f y ~> b
g = x ~> a
f (x ~> a) -> ((Ob x, Ob a) => Bool) -> Bool
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// y ~> b
g (y ~> b) -> ((Ob y, Ob b) => Bool) -> Bool
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// Bool -> Bool
not ([x ~> y] -> Bool
forall (a :: Coverage). [a] -> Bool
forall (t :: Coverage -> Coverage) (a :: Coverage).
Foldable t =>
t a -> Bool
null (forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
[p a b]
elements @(Hom k) @x @y))
legBelow :: (FiniteCat k) => SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
legBelow :: forall (k :: Coverage) (a :: k).
FiniteCat k =>
SomeLeg Joins k a Join -> SomeLeg Joins k a Join -> Bool
legBelow (SomeLeg (Under x ~> a
f)) (SomeLeg (Under x ~> a
g)) = (x ~> a) -> (x ~> a) -> Bool
forall {k :: Coverage} (x :: k) (y :: k) (a :: k) (b :: k).
FiniteCat k =>
(x ~> a) -> (y ~> b) -> Bool
sourceBelow x ~> a
f x ~> a
g
joinOf
:: forall {k} (a :: k) r
. (HasBinaryCoproducts k, HasInitialObject k, Ob a)
=> [SomeLeg Joins k a Join]
-> (forall j. j ~> a -> r)
-> r
joinOf :: forall {k :: Coverage} (a :: k) (r :: Coverage).
(HasBinaryCoproducts k, HasInitialObject k, Ob a) =>
[SomeLeg Joins k a Join] -> (forall (j :: k). (j ~> a) -> r) -> r
joinOf [] forall (j :: k). (j ~> a) -> r
kont = (InitialObject ~> a) -> r
forall (j :: k). (j ~> a) -> r
kont (forall (k :: Coverage) (a :: k).
(HasInitialObject k, Ob a) =>
InitialObject ~> a
initiate @k @a)
joinOf (SomeLeg (Under x ~> a
f) : [SomeLeg Joins k a Join]
ls) forall (j :: k). (j ~> a) -> r
kont = [SomeLeg Joins k a Join] -> (forall (j :: k). (j ~> a) -> r) -> r
forall {k :: Coverage} (a :: k) (r :: Coverage).
(HasBinaryCoproducts k, HasInitialObject k, Ob a) =>
[SomeLeg Joins k a Join] -> (forall (j :: k). (j ~> a) -> r) -> r
joinOf [SomeLeg Joins k a Join]
ls ((x ~> a) -> (j ~> a) -> r
forall (x :: k) (j :: k). (x ~> a) -> (j ~> a) -> r
copair x ~> a
f)
where
copair :: forall x j. x ~> a -> j ~> a -> r
copair :: forall (x :: k) (j :: k). (x ~> a) -> (j ~> a) -> r
copair x ~> a
g j ~> a
h = x ~> a
g (x ~> a) -> ((Ob x, Ob a) => r) -> r
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// j ~> a
h (j ~> a) -> ((Ob j, Ob a) => r) -> r
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// forall (k :: Coverage) (a :: k) (b :: k) (r :: Coverage).
(HasBinaryCoproducts k, Ob a, Ob b) =>
(Ob (a || b) => r) -> r
withObCoprod @k @x @j (((x || j) ~> a) -> r
forall (j :: k). (j ~> a) -> r
kont (x ~> a
g (x ~> a) -> (j ~> a) -> (x || j) ~> a
forall (x :: k) (a :: k) (y :: k).
(x ~> a) -> (y ~> a) -> (x || y) ~> a
forall (k :: Coverage) (x :: k) (a :: k) (y :: k).
HasBinaryCoproducts k =>
(x ~> a) -> (y ~> a) -> (x || y) ~> a
||| j ~> a
h))
pullbackJoin
:: forall {k} (b :: k) a
. (Thin k, FiniteCat k, Bicartesian k, Ob b)
=> Cover Joins k a Join
-> [SomeLeg Joins k a Join]
-> b ~> a
-> PulledBack Joins k a Join b
pullbackJoin :: forall {k :: Coverage} (b :: k) (a :: k).
(Thin k, FiniteCat k, Bicartesian k, Ob b) =>
Cover Joins k a Join
-> [SomeLeg Joins k a Join]
-> (b ~> a)
-> PulledBack Joins k a Join b
pullbackJoin Cover Joins k a Join
c [SomeLeg Joins k a Join]
ls b ~> a
f = Cover Joins k b Join
-> (forall (x :: k).
Leg Joins k b Join x -> Factors Joins k a Join x)
-> PulledBack Joins k a Join b
forall (t :: Coverage) (k :: Coverage) (b :: k) (d :: Coverage)
(a :: k) (c :: Coverage).
Cover t k b d
-> (forall (x :: k). Leg t k b d x -> Factors t k a c x)
-> PulledBack t k a c b
PulledBack ([SomeLeg Joins k b Join] -> Cover Joins k b Join
forall (k :: Coverage) (a :: k).
[SomeLeg Joins k a Join] -> Cover Joins k a Join
ByJoin [(x ~> a) -> SomeLeg Joins k b Join
forall (x :: k). Ob x => (x ~> a) -> SomeLeg Joins k b Join
meet x ~> a
g | SomeLeg (Under x ~> a
g) <- [SomeLeg Joins k a Join]
ls]) \(Under x ~> b
h) ->
Factors Joins k a Join x
-> Maybe (Factors Joins k a Join x) -> Factors Joins k a Join x
forall (a :: Coverage). a -> Maybe a -> a
fromMaybe ([Char] -> Factors Joins k a Join x
forall a. HasCallStack => [Char] -> a
error [Char]
"pullbackJoin: not a leg of the pulled-back cover (Site's Naming law)") (Cover Joins k a Join
-> (x ~> a) -> Maybe (Factors Joins k a Join x)
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
(Site t k, LocallyFinite k) =>
Cover t k a c -> (x ~> a) -> Maybe (Factors t k a c x)
factorThroughCover Cover Joins k a Join
c (b ~> a
f (b ~> a) -> (x ~> b) -> x ~> a
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k :: Coverage} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> b
h))
where
meet :: forall x. (Ob x) => x ~> a -> SomeLeg Joins k b Join
meet :: forall (x :: k). Ob x => (x ~> a) -> SomeLeg Joins k b Join
meet x ~> a
_ = forall (k :: Coverage) (a :: k) (b :: k) (r :: Coverage).
(HasBinaryProducts k, Ob a, Ob b) =>
(Ob (a && b) => r) -> r
withObProd @k @b @x (Leg Joins k b Join (b && x) -> SomeLeg Joins k b Join
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg (((b && x) ~> b) -> Leg Joins k b Join (b && x)
forall (k :: Coverage) (x :: k) (a :: k).
Ob x =>
(x ~> a) -> Leg Joins k a Join x
Under (forall (k :: Coverage) (a :: k) (b :: k).
(HasBinaryProducts k, Ob a, Ob b) =>
(a && b) ~> a
fst @k @b @x)))
type Sums :: Coverage
type data Sums
type Summands :: k -> k -> Type
type data Summands x y
instance (HasBinaryCoproducts `Elem` cs) => Site Sums (FREE cs (p :: CAT k)) where
data Cover Sums (FREE cs p) a c where
BySummands :: (Ob x, Ob y) => Cover Sums (FREE cs p) (x + y) (Summands x y)
data Leg Sums (FREE cs p) a c z where
AtLeft :: (Ob x, Ob y) => Leg Sums (FREE cs p) (x + y) (Summands x y) x
AtRight :: (Ob x, Ob y) => Leg Sums (FREE cs p) (x + y) (Summands x y) y
legArrow :: forall (a :: FREE cs p) (c :: Coverage) (x :: FREE cs p).
Leg Sums (FREE cs p) a c x -> x ~> a
legArrow Leg Sums (FREE cs p) a c x
R:LegSumsFREEacz k cs p a c x
AtLeft = x ~> a
x ~> (x || y)
forall (k :: Coverage) (a :: k) (b :: k).
(HasBinaryCoproducts k, Ob a, Ob b) =>
a ~> (a || b)
forall (a :: FREE cs p) (b :: FREE cs p).
(Ob a, Ob b) =>
a ~> (a || b)
lft
legArrow Leg Sums (FREE cs p) a c x
R:LegSumsFREEacz k cs p a c x
AtRight = x ~> a
x ~> (x || x)
forall (k :: Coverage) (a :: k) (b :: k).
(HasBinaryCoproducts k, Ob a, Ob b) =>
b ~> (a || b)
forall (a :: FREE cs p) (b :: FREE cs p).
(Ob a, Ob b) =>
b ~> (a || b)
rgt
legs :: forall (a :: FREE cs p) (c :: Coverage).
Cover Sums (FREE cs p) a c -> [SomeLeg Sums (FREE cs p) a c]
legs Cover Sums (FREE cs p) a c
R:CoverSumsFREEac k cs p a c
BySummands = [Leg Sums (FREE cs p) a c x -> SomeLeg Sums (FREE cs p) a c
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg Leg Sums (FREE cs p) a c x
Leg Sums (FREE cs p) (x + y) (Summands x y) x
forall {k :: Coverage} (cs :: [Coverage -> Constraint])
(p :: CAT k) (x :: FREE cs p) (d :: FREE cs p).
(Ob x, Ob d) =>
Leg Sums (FREE cs p) (x + d) (Summands x d) x
AtLeft, Leg Sums (FREE cs p) a c y -> SomeLeg Sums (FREE cs p) a c
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg Leg Sums (FREE cs p) a c y
Leg Sums (FREE cs p) (x + y) (Summands x y) y
forall {k :: Coverage} (cs :: [Coverage -> Constraint])
(p :: CAT k) (d :: FREE cs p) (y :: FREE cs p).
(Ob d, Ob y) =>
Leg Sums (FREE cs p) (d + y) (Summands d y) y
AtRight]
instance
(HasBinaryCoproducts `Elem` cs, HasInitialObject `Elem` cs, CategoryOf j)
=> Sheaf Sums (Yo (x :: FREE cs (p :: CAT k)) (OP (b :: j)) :: j +-> FREE cs p)
where
glue :: forall (a :: FREE cs p) (c :: Coverage) (b :: j).
(Ob a, Ob b) =>
Cover Sums (FREE cs p) a c
-> (forall (x :: FREE cs p).
Leg Sums (FREE cs p) a c x -> Yo x (OP b) x b)
-> Yo x (OP b) a b
glue Cover Sums (FREE cs p) a c
R:CoverSumsFREEac k cs p a c
BySummands forall (x :: FREE cs p).
Leg Sums (FREE cs p) a c x -> Yo x (OP b) x b
m = case (Leg Sums (FREE cs p) a c x -> Yo x (OP b) x b
forall (x :: FREE cs p).
Leg Sums (FREE cs p) a c x -> Yo x (OP b) x b
m Leg Sums (FREE cs p) a c x
Leg Sums (FREE cs p) (x + y) (Summands x y) x
forall {k :: Coverage} (cs :: [Coverage -> Constraint])
(p :: CAT k) (x :: FREE cs p) (d :: FREE cs p).
(Ob x, Ob d) =>
Leg Sums (FREE cs p) (x + d) (Summands x d) x
AtLeft, Leg Sums (FREE cs p) a c y -> Yo x (OP b) y b
forall (x :: FREE cs p).
Leg Sums (FREE cs p) a c x -> Yo x (OP b) x b
m Leg Sums (FREE cs p) a c y
Leg Sums (FREE cs p) (x + y) (Summands x y) y
forall {k :: Coverage} (cs :: [Coverage -> Constraint])
(p :: CAT k) (d :: FREE cs p) (y :: FREE cs p).
(Ob d, Ob y) =>
Leg Sums (FREE cs p) (d + y) (Summands d y) y
AtRight) of
(Yo x ~> x
f b1 ~> b
h, Yo y ~> x
g b1 ~> b
_) -> (a ~> x) -> (b ~> b) -> Yo x (OP b) a b
forall {k :: Coverage} {j :: Coverage} (c :: k) (a :: k) (b1 :: j)
(d :: j).
(c ~> a) -> (b1 ~> d) -> Yo a (OP b1) c d
Yo (x ~> x
f (x ~> x) -> (y ~> x) -> (x || y) ~> x
forall (k :: Coverage) (x :: k) (a :: k) (y :: k).
HasBinaryCoproducts k =>
(x ~> a) -> (y ~> a) -> (x || y) ~> a
forall (x :: FREE cs p) (a :: FREE cs p) (y :: FREE cs p).
(x ~> a) -> (y ~> a) -> (x || y) ~> a
||| y ~> x
g) b ~> b
b1 ~> b
h
type ByImage :: forall {j} {k}. (j +-> k) -> Coverage
type data ByImage w
type data Image
instance (Corepresentable w, Finitary w, FiniteCat k) => Site (ByImage (w :: j +-> k)) j where
data Cover (ByImage w) j a c where
Images :: (Ob a) => Cover (ByImage w) j a Image
data Leg (ByImage w) j a c x where
FromImage :: (Ob d) => w d a -> Leg (ByImage w) j a Image (w %% d)
legArrow :: forall (a :: j) (c :: Coverage) (x :: j).
Leg (ByImage w) j a c x -> x ~> a
legArrow (FromImage w d a
x) = w d a -> (w %% d) ~> a
forall (a :: k) (b :: j). w a b -> (w %% a) ~> b
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
Corepresentable p =>
p a b -> (p %% a) ~> b
coindex w d a
x
legs :: forall (a :: j) (c :: Coverage).
Cover (ByImage w) j a c -> [SomeLeg (ByImage w) j a c]
legs @a Cover (ByImage w) j a c
R:CoverByImagejac j k w a c
Images = forall (k :: Coverage) (r :: Coverage).
Enumerable k =>
(forall (a :: k). Ob a => [r]) -> [r]
foreachOb @k \ @d -> [Leg (ByImage w) j a c (w %% a) -> SomeLeg (ByImage w) j a c
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg (w a a -> Leg (ByImage w) j a Image (w %% a)
forall {k :: Coverage} (d :: k) (j :: Coverage) (w :: j +-> k)
(a :: j).
Ob d =>
w d a -> Leg (ByImage w) j a Image (w %% d)
FromImage w a a
x) | w a a
x <- forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
elements @w @d @a]
instance (Corepresentable w, Finitary w, FiniteCat k) => HasFiniteCovers (ByImage (w :: j +-> k)) j where
covers :: forall (a :: j). Ob a => [SomeCover (ByImage w) j a]
covers = [Cover (ByImage w) j a Image -> SomeCover (ByImage w) j a
forall (t :: Coverage) (k :: Coverage) (a :: k) (d :: Coverage).
Cover t k a d -> SomeCover t k a
SomeCover Cover (ByImage w) j a Image
forall {k :: Coverage} (j :: Coverage) (a :: j) (w :: j +-> k).
Ob a =>
Cover (ByImage w) j a Image
Images]
instance (Corepresentable w, Finitary w, FiniteCat k) => StableSite (ByImage (w :: j +-> k)) j where
pullbackCover :: forall (b :: j) (a :: j) (c :: Coverage).
Ob b =>
Cover (ByImage w) j a c
-> (b ~> a) -> PulledBack (ByImage w) j a c b
pullbackCover Cover (ByImage w) j a c
R:CoverByImagejac j k w a c
Images b ~> a
g = Cover (ByImage w) j b Image
-> (forall (x :: j).
Leg (ByImage w) j b Image x -> Factors (ByImage w) j a c x)
-> PulledBack (ByImage w) j a c b
forall (t :: Coverage) (k :: Coverage) (b :: k) (d :: Coverage)
(a :: k) (c :: Coverage).
Cover t k b d
-> (forall (x :: k). Leg t k b d x -> Factors t k a c x)
-> PulledBack t k a c b
PulledBack Cover (ByImage w) j b Image
forall {k :: Coverage} (j :: Coverage) (a :: j) (w :: j +-> k).
Ob a =>
Cover (ByImage w) j a Image
Images \(FromImage (w d b
x :: w d b)) -> forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) (r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @w @d (Leg (ByImage w) j a c x -> (x ~> x) -> Factors (ByImage w) j a c x
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors (w d a -> Leg (ByImage w) j a Image (w %% d)
forall {k :: Coverage} (d :: k) (j :: Coverage) (w :: j +-> k)
(a :: j).
Ob d =>
w d a -> Leg (ByImage w) j a Image (w %% d)
FromImage ((b ~> a) -> w d b -> w d a
forall (b :: j) (d :: j) (a :: k). (b ~> d) -> w a b -> w a d
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (b :: j)
(d :: j) (a :: k).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap b ~> a
g w d b
x)) x ~> x
forall (a :: j). Ob a => a ~> a
forall {k :: Coverage} (p :: CAT k) (a :: k).
(Promonad p, Ob a) =>
p a a
id)
instance
(Corepresentable w, Finitary w, FiniteCat k, Profunctor q)
=> Sheaf (ByImage (w :: j +-> k)) (Rift (OP w) q :: i +-> j)
where
glue :: forall (a :: j) (c :: Coverage) (b :: i).
(Ob a, Ob b) =>
Cover (ByImage w) j a c
-> (forall (x :: j). Leg (ByImage w) j a c x -> Rift (OP w) q x b)
-> Rift (OP w) q a b
glue Cover (ByImage w) j a c
R:CoverByImagejac j k w a c
Images forall (x :: j). Leg (ByImage w) j a c x -> Rift (OP w) q x b
m = (forall (x :: k). w x a -> q x b) -> Rift (OP w) q a b
forall {k :: Coverage} {j :: Coverage} {i :: Coverage} (a :: k)
(b :: j) (j2 :: k +-> i) (p :: j +-> i).
(Ob a, Ob b) =>
(forall (x :: i). j2 x a -> p x b) -> Rift (OP j2) p a b
Rift \(w x a
x :: w d a) -> w x a
x w x a -> ((Ob x, Ob a) => q x b) -> q x b
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(b :: k1) (r :: Coverage).
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// case Leg (ByImage w) j a c (w %% x) -> Rift (OP w) q (w %% x) b
forall (x :: j). Leg (ByImage w) j a c x -> Rift (OP w) q x b
m (w x a -> Leg (ByImage w) j a Image (w %% x)
forall {k :: Coverage} (d :: k) (j :: Coverage) (w :: j +-> k)
(a :: j).
Ob d =>
w d a -> Leg (ByImage w) j a Image (w %% d)
FromImage w x a
x) of Rift forall (x :: k). j2 x (w %% x) -> q x b
f -> j2 x (w %% x) -> q x b
forall (x :: k). j2 x (w %% x) -> q x b
f (forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k).
(Corepresentable p, Ob a) =>
p a (p %% a)
forall (p :: j +-> k) (a :: k).
(Corepresentable p, Ob a) =>
p a (p %% a)
corepUniv @w @d)
type Induced :: forall {j} {k}. Coverage -> (j +-> k) -> Coverage
type data Induced t w
instance (Site t j, Corepresentable w, LocallyFinite j, FiniteCat k) => Site (Induced t (w :: j +-> k)) k where
data Cover (Induced t w) k d c where
Induce :: (Ob d) => Cover t j (w %% d) c -> Cover (Induced t w) k d c
data Leg (Induced t w) k d c e where
Induces :: (Ob e) => e ~> d -> Factors t j (w %% d) c (w %% e) -> Leg (Induced t w) k d c e
legArrow :: forall (a :: k) (c :: Coverage) (x :: k).
Leg (Induced t w) k a c x -> x ~> a
legArrow (Induces x ~> a
h Factors t j (w %% a) c (w %% x)
_) = x ~> a
h
legs :: forall (a :: k) (c :: Coverage).
Cover (Induced t w) k a c -> [SomeLeg (Induced t w) k a c]
legs @d (Induce Cover t j (w %% a) c
c) =
forall (k :: Coverage) (r :: Coverage).
Enumerable k =>
(forall (a :: k). Ob a => [r]) -> [r]
foreachOb @k \ @e ->
[Leg (Induced t w) k a c a -> SomeLeg (Induced t w) k a c
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k).
Leg t k a c d -> SomeLeg t k a c
SomeLeg ((a ~> a)
-> Factors t j (w %% a) c (w %% a) -> Leg (Induced t w) k a c a
forall (k :: Coverage) (e :: k) (d :: k) (t :: Coverage)
(j :: Coverage) (w :: j +-> k) (c :: Coverage).
Ob e =>
(e ~> d)
-> Factors t j (w %% d) c (w %% e) -> Leg (Induced t w) k d c e
Induces a ~> a
h Factors t j (w %% a) c (w %% a)
fs) | a ~> a
h <- forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
[p a b]
elements @(Hom k) @e @d, Just Factors t j (w %% a) c (w %% a)
fs <- [Cover t j (w %% a) c
-> ((w %% a) ~> (w %% a))
-> Maybe (Factors t j (w %% a) c (w %% a))
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(x :: k).
(Site t k, LocallyFinite k) =>
Cover t k a c -> (x ~> a) -> Maybe (Factors t k a c x)
factorThroughCover Cover t j (w %% a) c
c (forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: k).
Corepresentable p =>
(a ~> b) -> (p %% a) ~> (p %% b)
forall (p :: j +-> k) (a :: k) (b :: k).
Corepresentable p =>
(a ~> b) -> (p %% a) ~> (p %% b)
corepMap @w a ~> a
h)]]
instance (HasFiniteCovers t j, Corepresentable w, LocallyFinite j, FiniteCat k) => HasFiniteCovers (Induced t (w :: j +-> k)) k where
covers :: forall (a :: k). Ob a => [SomeCover (Induced t w) k a]
covers @d = forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) (r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @w @d [Cover (Induced t w) k a c -> SomeCover (Induced t w) k a
forall (t :: Coverage) (k :: Coverage) (a :: k) (d :: Coverage).
Cover t k a d -> SomeCover t k a
SomeCover (Cover t j (w %% a) c -> Cover (Induced t w) k a c
forall (k :: Coverage) (d :: k) (t :: Coverage) (j :: Coverage)
(w :: j +-> k) (c :: Coverage).
Ob d =>
Cover t j (w %% d) c -> Cover (Induced t w) k d c
Induce Cover t j (w %% a) c
c) | SomeCover Cover t j (w %% a) c
c <- forall (t :: Coverage) (k :: Coverage) (a :: k).
(HasFiniteCovers t k, Ob a) =>
[SomeCover t k a]
covers @t @j @(w %% d)]
instance (StableSite t j, Corepresentable w, LocallyFinite j, FiniteCat k) => StableSite (Induced t (w :: j +-> k)) k where
pullbackCover :: forall (b :: k) (a :: k) (c :: Coverage).
Ob b =>
Cover (Induced t w) k a c
-> (b ~> a) -> PulledBack (Induced t w) k a c b
pullbackCover @d' (Induce Cover t j (w %% a) c
c) b ~> a
h' =
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) (r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @w @d'
( case Cover t j (w %% a) c
-> ((w %% b) ~> (w %% a)) -> PulledBack t j (w %% a) c (w %% b)
forall (b :: j) (a :: j) (c :: Coverage).
Ob b =>
Cover t j a c -> (b ~> a) -> PulledBack t j a c b
forall (t :: Coverage) (k :: Coverage) (b :: k) (a :: k)
(c :: Coverage).
(StableSite t k, Ob b) =>
Cover t k a c -> (b ~> a) -> PulledBack t k a c b
pullbackCover Cover t j (w %% a) c
c (forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: k).
Corepresentable p =>
(a ~> b) -> (p %% a) ~> (p %% b)
forall (p :: j +-> k) (a :: k) (b :: k).
Corepresentable p =>
(a ~> b) -> (p %% a) ~> (p %% b)
corepMap @w b ~> a
h') of
AlreadyFactors Factors t j (w %% a) c (w %% b)
fs -> Factors (Induced t w) k a c b -> PulledBack (Induced t w) k a c b
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(b :: k).
Factors t k a c b -> PulledBack t k a c b
AlreadyFactors (Leg (Induced t w) k a c b
-> (b ~> b) -> Factors (Induced t w) k a c b
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors ((b ~> a)
-> Factors t j (w %% a) c (w %% b) -> Leg (Induced t w) k a c b
forall (k :: Coverage) (e :: k) (d :: k) (t :: Coverage)
(j :: Coverage) (w :: j +-> k) (c :: Coverage).
Ob e =>
(e ~> d)
-> Factors t j (w %% d) c (w %% e) -> Leg (Induced t w) k d c e
Induces b ~> a
h' Factors t j (w %% a) c (w %% b)
fs) b ~> b
forall (a :: k). Ob a => a ~> a
forall {k :: Coverage} (p :: CAT k) (a :: k).
(Promonad p, Ob a) =>
p a a
id)
PulledBack Cover t j (w %% b) c'
c' forall (x :: j). Leg t j (w %% b) c' x -> Factors t j (w %% a) c x
fs -> Cover (Induced t w) k b c'
-> (forall (x :: k).
Leg (Induced t w) k b c' x -> Factors (Induced t w) k a c x)
-> PulledBack (Induced t w) k a c b
forall (t :: Coverage) (k :: Coverage) (b :: k) (d :: Coverage)
(a :: k) (c :: Coverage).
Cover t k b d
-> (forall (x :: k). Leg t k b d x -> Factors t k a c x)
-> PulledBack t k a c b
PulledBack (Cover t j (w %% b) c' -> Cover (Induced t w) k b c'
forall (k :: Coverage) (d :: k) (t :: Coverage) (j :: Coverage)
(w :: j +-> k) (c :: Coverage).
Ob d =>
Cover t j (w %% d) c -> Cover (Induced t w) k d c
Induce Cover t j (w %% b) c'
c') \(Induces x ~> b
h (Factors Leg t j (w %% b) c' y
l' (w %% x) ~> y
u)) -> case Leg t j (w %% b) c' y -> Factors t j (w %% a) c y
forall (x :: j). Leg t j (w %% b) c' x -> Factors t j (w %% a) c x
fs Leg t j (w %% b) c' y
l' of
Factors Leg t j (w %% a) c y
l y ~> y
u' -> Leg (Induced t w) k a c x
-> (x ~> x) -> Factors (Induced t w) k a c x
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors ((x ~> a)
-> Factors t j (w %% a) c (w %% x) -> Leg (Induced t w) k a c x
forall (k :: Coverage) (e :: k) (d :: k) (t :: Coverage)
(j :: Coverage) (w :: j +-> k) (c :: Coverage).
Ob e =>
(e ~> d)
-> Factors t j (w %% d) c (w %% e) -> Leg (Induced t w) k d c e
Induces (b ~> a
h' (b ~> a) -> (x ~> b) -> x ~> a
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k :: Coverage} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> b
h) (Leg t j (w %% a) c y
-> ((w %% x) ~> y) -> Factors t j (w %% a) c (w %% x)
forall (t :: Coverage) (k :: Coverage) (a :: k) (c :: Coverage)
(d :: k) (x :: k).
Leg t k a c d -> (x ~> d) -> Factors t k a c x
Factors Leg t j (w %% a) c y
l (y ~> y
u' (y ~> y) -> ((w %% x) ~> y) -> (w %% x) ~> y
forall (b :: j) (c :: j) (a :: j). (b ~> c) -> (a ~> b) -> a ~> c
forall {k :: Coverage} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (w %% x) ~> y
u))) x ~> x
forall (a :: k). Ob a => a ~> a
forall {k :: Coverage} (p :: CAT k) (a :: k).
(Promonad p, Ob a) =>
p a a
id
)
glueExtension
:: forall t {i} {j} {k} (w :: j +-> k) (q :: i +-> k) (a :: j) c (b :: i)
. (StableSite t j, Corepresentable w, LocallyFinite j, FiniteCat k, Sheaf (Induced t w) q, Ob a, Ob b)
=> Cover t j a c
-> (forall x. Leg t j a c x -> Rift (OP w) q x b)
-> Rift (OP w) q a b
glueExtension :: forall (t :: Coverage) {i :: Coverage} {j :: Coverage}
{k :: Coverage} (w :: j +-> k) (q :: i +-> k) (a :: j)
(c :: Coverage) (b :: i).
(StableSite t j, Corepresentable w, LocallyFinite j, FiniteCat k,
Sheaf (Induced t w) q, Ob a, Ob b) =>
Cover t j a c
-> (forall (x :: j). Leg t j a c x -> Rift (OP w) q x b)
-> Rift (OP w) q a b
glueExtension Cover t j a c
c forall (x :: j). Leg t j a c x -> Rift (OP w) q x b
m = (forall (x :: k). w x a -> q x b) -> Rift (OP w) q a b
forall {k :: Coverage} {j :: Coverage} {i :: Coverage} (a :: k)
(b :: j) (j2 :: k +-> i) (p :: j +-> i).
(Ob a, Ob b) =>
(forall (x :: i). j2 x a -> p x b) -> Rift (OP j2) p a b
Rift \(x :: w x a
x@w x a
Objs :: w e a) ->
forall {k1 :: Coverage} {k2 :: Coverage} (p :: k1 +-> k2) (a :: k2)
(r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) (r :: Coverage).
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @w @e
( case Cover t j a c -> ((w %% x) ~> a) -> PulledBack t j a c (w %% x)
forall (b :: j) (a :: j) (c :: Coverage).
Ob b =>
Cover t j a c -> (b ~> a) -> PulledBack t j a c b
forall (t :: Coverage) (k :: Coverage) (b :: k) (a :: k)
(c :: Coverage).
(StableSite t k, Ob b) =>
Cover t k a c -> (b ~> a) -> PulledBack t k a c b
pullbackCover Cover t j a c
c (w x a -> (w %% x) ~> a
forall (a :: k) (b :: j). w a b -> (w %% a) ~> b
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k)
(b :: j).
Corepresentable p =>
p a b -> (p %% a) ~> b
coindex w x a
x) of
AlreadyFactors (Factors Leg t j a c y
l (w %% x) ~> y
u) -> Leg t j a c y -> w x y -> q x b
forall (y :: j) (e' :: k). Leg t j a c y -> w e' y -> q e' b
at Leg t j a c y
l (((w %% x) ~> y) -> w x (w %% x) -> w x y
forall (b :: j) (d :: j) (a :: k). (b ~> d) -> w a b -> w a d
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (b :: j)
(d :: j) (a :: k).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap (w %% x) ~> y
u (forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k).
(Corepresentable p, Ob a) =>
p a (p %% a)
forall (p :: j +-> k) (a :: k).
(Corepresentable p, Ob a) =>
p a (p %% a)
corepUniv @w @e))
PulledBack Cover t j (w %% x) c'
c' forall (x :: j). Leg t j (w %% x) c' x -> Factors t j a c x
fs -> forall {j :: Coverage} {k :: Coverage} (t :: Coverage)
(p :: j +-> k) (a :: k) (c :: Coverage) (b :: j).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
forall (t :: Coverage) (p :: i +-> k) (a :: k) (c :: Coverage)
(b :: i).
(Sheaf t p, Ob a, Ob b) =>
Cover t k a c -> (forall (x :: k). Leg t k a c x -> p x b) -> p a b
glue @(Induced t w) (Cover t j (w %% x) c' -> Cover (Induced t w) k x c'
forall (k :: Coverage) (d :: k) (t :: Coverage) (j :: Coverage)
(w :: j +-> k) (c :: Coverage).
Ob d =>
Cover t j (w %% d) c -> Cover (Induced t w) k d c
Induce Cover t j (w %% x) c'
c') \(Induces x ~> x
_ (Factors Leg t j (w %% x) c' y
l' (w %% x) ~> y
u)) -> case Leg t j (w %% x) c' y -> Factors t j a c y
forall (x :: j). Leg t j (w %% x) c' x -> Factors t j a c x
fs Leg t j (w %% x) c' y
l' of
Factors Leg t j a c y
l y ~> y
u' -> Leg t j a c y -> w x y -> q x b
forall (y :: j) (e' :: k). Leg t j a c y -> w e' y -> q e' b
at Leg t j a c y
l (((w %% x) ~> y) -> w x (w %% x) -> w x y
forall (b :: j) (d :: j) (a :: k). (b ~> d) -> w a b -> w a d
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (b :: j)
(d :: j) (a :: k).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap (y ~> y
u' (y ~> y) -> ((w %% x) ~> y) -> (w %% x) ~> y
forall (b :: j) (c :: j) (a :: j). (b ~> c) -> (a ~> b) -> a ~> c
forall {k :: Coverage} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (w %% x) ~> y
u) w x (w %% x)
forall (a :: k). Ob a => w a (w %% a)
forall {j :: Coverage} {k :: Coverage} (p :: j +-> k) (a :: k).
(Corepresentable p, Ob a) =>
p a (p %% a)
corepUniv)
)
where
at :: Leg t j a c y -> w e' y -> q e' b
at :: forall (y :: j) (e' :: k). Leg t j a c y -> w e' y -> q e' b
at Leg t j a c y
l w e' y
y = case Leg t j a c y -> Rift (OP w) q y b
forall (x :: j). Leg t j a c x -> Rift (OP w) q x b
m Leg t j a c y
l of Rift forall (x :: k). j2 x y -> q x b
f -> j2 e' y -> q e' b
forall (x :: k). j2 x y -> q x b
f w e' y
j2 e' y
y