{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ImpredicativeTypes #-}
module Proarrow.Testing.Laws where
import Control.Monad (when)
import Data.Default (def)
import Data.Foldable (for_)
import Data.List (genericLength, sort)
import Numeric.Natural (Natural)
import Test.Falsify (Property)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Falsify (TestOptions, testProperty)
import Prelude hiding (elem, fst, id, snd, (.), (>>))
import Proarrow.Adjunction (Adjunction)
import Proarrow.Adjunction qualified as Adj
import Proarrow.Category.Enriched.Dagger qualified as Dagger
import Proarrow.Category.Enriched.Finitary qualified as Finitary
import Proarrow.Category.Enriched.Finitary.Sheaf qualified as FinSheaf
import Proarrow.Category.Enriched.Finitary.Topos qualified as FinTopos
import Proarrow.Category.Enriched.Thin qualified as Thin
import Proarrow.Category.Instance.Opposite (OPPOSITE (..))
import Proarrow.Category.Instance.Prof (Prof (..))
import Proarrow.Category.Instance.Sub (Sub (..))
import Proarrow.Category.Monoidal qualified as M
import Proarrow.Category.Monoidal.Cartesian qualified as Cartesian
import Proarrow.Category.Monoidal.Closed qualified as Exponential
import Proarrow.Category.Monoidal.CompactClosed qualified as CC
import Proarrow.Category.Monoidal.CopyDiscard qualified as CopyDiscard
import Proarrow.Category.Monoidal.Dialogue qualified as SA
import Proarrow.Category.Monoidal.Distributive qualified as Distributive
import Proarrow.Category.Monoidal.Hypergraph qualified as Hypergraph
import Proarrow.Category.Monoidal.IsoMix qualified as IsoMix
import Proarrow.Category.Monoidal.StarAutonomous qualified as SA
import Proarrow.Category.Monoidal.Strength qualified as Strength
import Proarrow.Category.Sheaf qualified as Sheaf
import Proarrow.Category.Topos qualified as Topos
import Proarrow.Colimit.BinaryCoproduct qualified as BinaryCoproduct
import Proarrow.Colimit.Coequalizer qualified as Coequalizer
import Proarrow.Colimit.Initial qualified as Initial
import Proarrow.Colimit.Pushout qualified as Pushout
import Proarrow.Core
( CategoryOf (..)
, Hom
, Profunctor (..)
, Promonad (..)
, lmap
, obj
, rmap
, (//)
, (:~>)
, type (+->)
)
import Proarrow.Functor qualified as Functor
import Proarrow.Limit.BinaryProduct qualified as BinaryProduct
import Proarrow.Limit.Equalizer qualified as Equalizer
import Proarrow.Limit.Pullback qualified as Pullback
import Proarrow.Limit.Terminal qualified as Terminal
import Proarrow.Monoid qualified as Monoid
import Proarrow.Object (pattern Objs)
import Proarrow.Optic (ExOptic, Flip, Optic)
import Proarrow.Optic.Getter (GetterFl, review, view)
import Proarrow.Profunctor.Corepresentable (Corepresentable, coindex, withObCorep, type (%%))
import Proarrow.Profunctor.Instance.Composition ((:.:) (..))
import Proarrow.Profunctor.Instance.Ran (Ran (..))
import Proarrow.Profunctor.Instance.Rift (Rift (..))
import Proarrow.Profunctor.Instance.Sieve (Sieve (..))
import Proarrow.Profunctor.Instance.Yoneda (Yo (..))
import Proarrow.Profunctor.Representable (Representable, withObRep, type (%))
import Proarrow.Promonad qualified as Promonad
import Proarrow.Testing
import Proarrow.Testing.Laws.Run
( CorepresentedBy
, RepresentedBy
, TESTED
, TestedP
, Witness (..)
, Witnesses (..)
, testLaws
, testLawsWith
, testProLaws
)
import Proarrow.Tools.Laws qualified as Laws
propIso :: forall {k} (a :: k) b. (Testable k, TestOb a, TestOb b) => a ~> b -> b ~> a -> Property ()
propIso :: forall {k} (a :: k) (b :: k).
(Testable k, TestOb a, TestOb b) =>
(a ~> b) -> (b ~> a) -> Property ()
propIso a ~> b
f b ~> a
g = forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @a ((Ob a => Property ()) -> Property ())
-> (Ob a => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @b ((Ob b => Property ()) -> Property ())
-> (Ob b => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ do
String -> String -> (b ~> b) -> String -> (b ~> b) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"right inverse" String
"f . g" (a ~> b
f (a ~> b) -> (b ~> a) -> b ~> b
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. b ~> a
g) String
"id" b ~> b
forall (a :: k). Ob a => a ~> a
forall {k} (p :: CAT k) (a :: k). (Promonad p, Ob a) => p a a
id
String -> String -> (a ~> a) -> String -> (a ~> a) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"left inverse" String
"g . f" (b ~> a
g (b ~> a) -> (a ~> b) -> a ~> a
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. a ~> b
f) String
"id" a ~> a
forall (a :: k). Ob a => a ~> a
forall {k} (p :: CAT k) (a :: k). (Promonad p, Ob a) => p a a
id
propIso'
:: forall {k} c (a :: k) b
. (Testable k, TestOb a, TestOb b, (Ob b) => c (ExOptic GetterFl b b), (Ob b) => c (ExOptic (Flip GetterFl) b b))
=> Optic c a a b b -> Property ()
propIso' :: forall {k} (c :: (k -> k -> Type) -> Constraint) (a :: k) (b :: k).
(Testable k, TestOb a, TestOb b, Ob b => c (ExOptic GetterFl b b),
Ob b => c (ExOptic (Flip GetterFl) b b)) =>
Optic c a a b b -> Property ()
propIso' Optic c a a b b
o = (a ~> b) -> (b ~> a) -> Property ()
forall {k} (a :: k) (b :: k).
(Testable k, TestOb a, TestOb b) =>
(a ~> b) -> (b ~> a) -> Property ()
propIso (Optic c a a b b -> a ~> b
forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k)
(t :: j) (a :: k) (b :: j).
(CategoryOf j, CategoryOf k,
(Ob a, Ob b) => c (ExOptic GetterFl a b)) =>
Optic c s t a b -> s ~> a
view Optic c a a b b
o) (Optic c a a b b -> b ~> a
forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k)
(t :: j) (a :: k) (b :: j).
(CategoryOf j, CategoryOf k,
(Ob a, Ob b) => c (ExOptic (Flip GetterFl) a b)) =>
Optic c s t a b -> b ~> t
review Optic c a a b b
o)
propIsoP
:: forall p q a b c d
. (TestableTypeP p, TestableTypeP q, TestOb a, TestOb b, TestOb c, TestOb d)
=> (p a b -> q c d) -> (q c d -> p a b) -> Property ()
propIsoP :: forall {j} {k} {j} {k} (p :: j +-> k) (q :: j +-> k) (a :: k)
(b :: j) (c :: k) (d :: j).
(TestableTypeP p, TestableTypeP q, TestOb a, TestOb b, TestOb c,
TestOb d) =>
(p a b -> q c d) -> (q c d -> p a b) -> Property ()
propIsoP p a b -> q c d
f q c d -> p a b
g = do
p <- forall a. TestableType a => String -> Property a
genNamed @(p a b) String
"p"
testEq "left inverse" "g (f p)" (g (f p)) "p" p
q <- genNamed @(q c d) "q"
testEq "right inverse" "f (g q)" (f (g q)) "q" q
propNaturalIsoP
:: forall {j} {k} (p :: j +-> k) q
. (TestableProfunctor p, TestableTypeP p, TestableProfunctor q, TestableTypeP q)
=> (p :~> q) -> (q :~> p) -> Property ()
propNaturalIsoP :: forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(TestableProfunctor p, TestableTypeP p, TestableProfunctor q,
TestableTypeP q) =>
(p :~> q) -> (q :~> p) -> Property ()
propNaturalIsoP p :~> q
f q :~> p
g = do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @j
propIsoP @p @q @a @b f g
propNaturalTransformation f
propNaturalTransformation g
testCategory :: forall k. (Testable k) => TestTree
testCategory :: forall k. Testable k => TestTree
testCategory = forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[CategoryOf] @k String
"Category" (Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[] k -> Witnesses '[CategoryOf] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testDagger :: forall k. (Testable k, Dagger.Dagger k) => TestTree
testDagger :: forall k. (Testable k, Dagger k) => TestTree
testDagger = forall {k} (p :: k +-> k).
(DaggerProfunctor p, TestableProfunctor p) =>
TestTree
forall (p :: k +-> k).
(DaggerProfunctor p, TestableProfunctor p) =>
TestTree
testDaggerProfunctor @(Hom k)
testDaggerProfunctor :: forall {k} (p :: k +-> k). (Dagger.DaggerProfunctor p, TestableProfunctor p) => TestTree
testDaggerProfunctor :: forall {k} (p :: k +-> k).
(DaggerProfunctor p, TestableProfunctor p) =>
TestTree
testDaggerProfunctor =
forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] k +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: k +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @Dagger.DaggerProfunctor @p TestOptions
defaultTestOptions String
"Dagger"
testCategoryProLaws
:: forall {j} {k} cl (p :: j +-> k)
. (Laws.ProLaws cl, TestableProfunctor p, cl (TestedP p :: TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k))
=> TestOptions -> String -> TestTree
testCategoryProLaws :: forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws TestOptions
opts String
name = forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf] @'[CategoryOf] @cl @p TestOptions
opts Gen (Some i)
forall i. Testable i => Gen (Some i)
genSome String
name (Witness CategoryOf j
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf j
-> Witnesses '[] j -> Witnesses '[CategoryOf] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] j
forall k. Witnesses '[] k
WNil) (Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[] k -> Witnesses '[CategoryOf] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
defaultTestOptions :: TestOptions
defaultTestOptions :: TestOptions
defaultTestOptions = TestOptions
forall a. Default a => a
def
testProfunctor :: forall {j} {k} (p :: j +-> k). (TestableProfunctor p) => TestTree
testProfunctor :: forall {j} {k} (p :: j +-> k). TestableProfunctor p => TestTree
testProfunctor = forall {j} {k} (p :: j +-> k).
TestableProfunctor p =>
TestOptions -> TestTree
forall (p :: j +-> k).
TestableProfunctor p =>
TestOptions -> TestTree
testProfunctorWith @p TestOptions
defaultTestOptions
testProfunctorWith :: forall {j} {k} (p :: j +-> k). (TestableProfunctor p) => TestOptions -> TestTree
testProfunctorWith :: forall {j} {k} (p :: j +-> k).
TestableProfunctor p =>
TestOptions -> TestTree
testProfunctorWith TestOptions
opts =
forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @Profunctor @p TestOptions
opts String
"Profunctor"
propDecidable
:: forall {j} {k} (p :: j +-> k)
. (Thin.DecidableProfunctor p, Testable j, Testable k, TestableTypeP p)
=> Property ()
propDecidable :: forall {j} {k} (p :: j +-> k).
(DecidableProfunctor p, Testable j, Testable k, TestableTypeP p) =>
Property ()
propDecidable = do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @j
obFromTestOb @_ @a $
obFromTestOb @_ @b $
case Thin.decide @p @a @b of
Thin.Yes p x x
x -> do
String -> Bool -> Property ()
check String
"decide: TRU, but no element can be generated" (forall a. TestableType a => Bool
isGenNonEmpty @(p a b))
y <- forall a. TestableType a => String -> Property a
genNamed @(p a b) String
"y"
testEq "decide" "decide" x "y" y
Decision p x x (Holds p x x)
Thin.No -> String -> Bool -> Property ()
check String
"decide: FLS, but an element can be generated" (Bool -> Bool
not (forall a. TestableType a => Bool
isGenNonEmpty @(p a b)))
propNaturalTransformation
:: forall {j} {k} (p :: j +-> k) q. (TestableProfunctor p, TestableProfunctor q) => p :~> q -> Property ()
propNaturalTransformation :: forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(TestableProfunctor p, TestableProfunctor q) =>
(p :~> q) -> Property ()
propNaturalTransformation p :~> q
n = do
SomeP @a @b p <- forall {j} {k} (p :: j +-> k).
TestableProfunctor p =>
String -> Property (SomeProfunctorElt p)
forall (p :: j +-> k).
TestableProfunctor p =>
String -> Property (SomeProfunctorElt p)
genProfunctorElt @p String
"p"
Some @c <- genObSuchThat @k \(Some @c) -> forall a. TestableType a => Bool
isGenNonEmpty @(c ~> a)
Some @d <- genObSuchThat @j \(Some @d) -> forall a. TestableType a => Bool
isGenNonEmpty @(b ~> d)
f <- genNamed @(c ~> a) "f"
g <- genNamed @(b ~> d) "g"
testEq "naturality" "n (dimap f g p)" (n (dimap f g p)) "dimap f g (n p)" (dimap f g (n p))
testFinitary
:: forall {j} {k} (p :: j +-> k)
. (Finitary.Finitary p, TestableProfunctor p, TestableTypeP p)
=> String
-> TestTree
testFinitary :: forall {j} {k} (p :: j +-> k).
(Finitary p, TestableProfunctor p, TestableTypeP p) =>
String -> TestTree
testFinitary String
nm =
String -> [TestTree] -> TestTree
testGroup
(String
"Finitary " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
nm)
[ String -> Property () -> TestTree
testProperty String
"numbering" (forall {j} {k} (p :: j +-> k).
(Finitary p, TestableProfunctor p, TestableTypeP p) =>
Property ()
forall (p :: j +-> k).
(Finitary p, TestableProfunctor p, TestableTypeP p) =>
Property ()
propNumbering @p)
, forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @Finitary.Finitary @p TestOptions
defaultTestOptions String
"laws"
]
propNumbering
:: forall {j} {k} (p :: j +-> k). (Finitary.Finitary p, TestableProfunctor p, TestableTypeP p) => Property ()
propNumbering :: forall {j} {k} (p :: j +-> k).
(Finitary p, TestableProfunctor p, TestableTypeP p) =>
Property ()
propNumbering = do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @j
obFromTestOb @_ @a $ obFromTestOb @_ @b $ do
let n = forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
forall (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
Finitary.size @p @a @b
es = forall {j} {k} (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]
Finitary.elements @p @a @b
check
("size is " ++ show n ++ " but elements has " ++ show (genericLength es :: Natural) ++ " entries")
(genericLength es == n)
check
("elements should be numbered in order, found " ++ show (map (Finitary.toIndex @p @a @b) es))
(map (Finitary.toIndex @p @a @b) es == Finitary.indices n)
x <- genNamed @(p a b) "x"
check
("toIndex " ++ showP x ++ " is " ++ show (Finitary.toIndex x) ++ ", not below size " ++ show n)
(Finitary.toIndex x < n)
propFunctor
:: forall {k1} {k2} (f :: k1 -> k2)
. (Functor.Functor f, Testable k1, Testable k2)
=> (forall (a :: k1) r. (TestOb a) => ((TestOb (f a)) => r) -> r)
-> Property ()
propFunctor :: forall {k1} {k2} (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> Property ()
propFunctor forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r
withTestObF = do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k1
Some @b <- genObSuchThat @k1 \(Some @b) -> forall a. TestableType a => Bool
isGenNonEmpty @(a ~> b)
Some @c <- genObSuchThat @k1 \(Some @c) -> forall a. TestableType a => Bool
isGenNonEmpty @(b ~> c)
f <- genNamed @(a ~> b) "f"
g <- genNamed @(b ~> c) "g"
withTestObF @a $
withTestObF @c $
obFromTestOb @_ @a $
obFromTestOb @_ @c $
Functor.withObF @f @a $
Functor.withObF @f @c $ do
testEq "identity" "map id" (Functor.map @f (obj @a)) "id" (obj @(f a))
testEq
"composition"
"map (g . f)"
(Functor.map @f (g . f))
"map g . map f"
(Functor.map @f g . Functor.map @f f)
testFunctor
:: forall {k1} {k2} (f :: k1 -> k2)
. (Functor.Functor f, Testable k1, Testable k2)
=> (forall (a :: k1) r. (TestOb a) => ((TestOb (f a)) => r) -> r)
-> TestTree
testFunctor :: forall {k1} {k2} (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> TestTree
testFunctor forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r
withTestObF = String -> Property () -> TestTree
testProperty String
"Functor" (forall {k1} {k2} (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> Property ()
forall (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> Property ()
propFunctor @f (\ @a TestOb (f a) => r
r -> forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r
withTestObF @a r
TestOb (f a) => r
r))
testFunctor_
:: forall {k1} {k2} (f :: k1 -> k2)
. (Functor.Functor f, Testable k1, Testable k2, forall (a :: k1). (TestOb a) => TestOb' (f a))
=> TestTree
testFunctor_ :: forall {k1} {k2} (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2,
forall (a :: k1). TestOb a => TestOb' (f a)) =>
TestTree
testFunctor_ = forall {k1} {k2} (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> TestTree
forall (f :: k1 -> k2).
(Functor f, Testable k1, Testable k2) =>
(forall (a :: k1) r. TestOb a => (TestOb (f a) => r) -> r)
-> TestTree
testFunctor @f (\TestOb (f a) => r
r -> r
TestOb (f a) => r
r)
testMonoidalProfunctor
:: forall {j} {k} (p :: j +-> k)
. (M.MonoidalProfunctor p, TestableProfunctor p, TestOb (M.Unit :: j), TestOb (M.Unit :: k))
=> WithTestOb2 j
-> WithTestOb2 k
-> TestTree
testMonoidalProfunctor :: forall {j} {k} (p :: j +-> k).
(MonoidalProfunctor p, TestableProfunctor p, TestOb Unit,
TestOb Unit) =>
WithTestOb2 j -> WithTestOb2 k -> TestTree
testMonoidalProfunctor WithTestOb2 j
withTestOb2J WithTestOb2 k
withTestOb2K =
forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf, M.Monoidal] @'[CategoryOf, M.Monoidal] @M.MonoidalProfunctor @p
TestOptions
defaultTestOptions
Gen (Some i)
forall i. Testable i => Gen (Some i)
genSome
String
"MonoidalProfunctor"
(Witness CategoryOf j
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf j
-> Witnesses '[Monoidal] j -> Witnesses '[CategoryOf, Monoidal] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestOb2 j -> Witness Monoidal j
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 j
withTestOb2J @a @b r
TestOb (a ** b) => r
r) Witness Monoidal j -> Witnesses '[] j -> Witnesses '[Monoidal] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] j
forall k. Witnesses '[] k
WNil)
(Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[Monoidal] k -> Witnesses '[CategoryOf, Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2K @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k -> Witnesses '[] k -> Witnesses '[Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testMonStrong
:: forall {k} (p :: k +-> k)
. (Strength.Strong M.Tensor p, M.Monoidal k, TestableProfunctor p, TestOb (M.Unit :: k))
=> WithTestOb2 k
-> TestTree
testMonStrong :: forall {k} (p :: k +-> k).
(Strong Tensor p, Monoidal k, TestableProfunctor p, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonStrong WithTestOb2 k
withTestOb2 =
forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj k +-> TESTED csk k) -> Constraint)
(p :: k +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj k
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf, M.Monoidal] @'[CategoryOf, M.Monoidal] @(Strength.Strong M.Tensor) @p
TestOptions
defaultTestOptions
Gen (Some i)
forall i. Testable i => Gen (Some i)
genSome
String
"Strong Tensor"
Witnesses '[CategoryOf, Monoidal] k
ws
Witnesses '[CategoryOf, Monoidal] k
ws
where
ws :: Witnesses '[CategoryOf, Monoidal] k
ws = Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[Monoidal] k -> Witnesses '[CategoryOf, Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k -> Witnesses '[] k -> Witnesses '[Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
testMonStrong_
:: forall {k} (p :: k +-> k). (Strength.Strong M.Tensor p, M.Monoidal k, TestableProfunctor p, TestObIsOb k) => TestTree
testMonStrong_ :: forall {k} (p :: k +-> k).
(Strong Tensor p, Monoidal k, TestableProfunctor p,
TestObIsOb k) =>
TestTree
testMonStrong_ = forall {k} (p :: k +-> k).
(Strong Tensor p, Monoidal k, TestableProfunctor p, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall (p :: k +-> k).
(Strong Tensor p, Monoidal k, TestableProfunctor p, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonStrong @p (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testMonCostrong
:: forall {k} (p :: k +-> k)
. (Strength.Costrong M.Tensor p, M.Monoidal k, TestableProfunctor p, TestOb (M.Unit :: k))
=> WithTestOb2 k
-> TestTree
testMonCostrong :: forall {k} (p :: k +-> k).
(Costrong Tensor p, Monoidal k, TestableProfunctor p,
TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonCostrong WithTestOb2 k
withTestOb2 =
forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj k +-> TESTED csk k) -> Constraint)
(p :: k +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj k
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf, M.Monoidal] @'[CategoryOf, M.Monoidal] @(Strength.Costrong M.Tensor) @p
TestOptions
defaultTestOptions
Gen (Some i)
forall i. Testable i => Gen (Some i)
genSomeSmall
String
"Costrong Tensor"
Witnesses '[CategoryOf, Monoidal] k
ws
Witnesses '[CategoryOf, Monoidal] k
ws
where
ws :: Witnesses '[CategoryOf, Monoidal] k
ws = Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[Monoidal] k -> Witnesses '[CategoryOf, Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k -> Witnesses '[] k -> Witnesses '[Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
testMonCostrong_
:: forall {k} (p :: k +-> k). (Strength.Costrong M.Tensor p, M.Monoidal k, TestableProfunctor p, TestObIsOb k) => TestTree
testMonCostrong_ :: forall {k} (p :: k +-> k).
(Costrong Tensor p, Monoidal k, TestableProfunctor p,
TestObIsOb k) =>
TestTree
testMonCostrong_ = forall {k} (p :: k +-> k).
(Costrong Tensor p, Monoidal k, TestableProfunctor p,
TestOb Unit) =>
WithTestOb2 k -> TestTree
forall (p :: k +-> k).
(Costrong Tensor p, Monoidal k, TestableProfunctor p,
TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonCostrong @p (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testRepresentable
:: forall {j} {k} (p :: j +-> k)
. (Representable p, TestableProfunctor p)
=> WithTestObRep j p
-> TestTree
testRepresentable :: forall {j} {k} (p :: j +-> k).
(Representable p, TestableProfunctor p) =>
WithTestObRep j p -> TestTree
testRepresentable WithTestObRep j p
withTestObRep =
forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf] @'[CategoryOf, RepresentedBy '[CategoryOf] p] @Representable @p
TestOptions
defaultTestOptions
Gen (Some i)
forall i. Testable i => Gen (Some i)
genSome
String
"Representable"
(Witness CategoryOf j
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf j
-> Witnesses '[] j -> Witnesses '[CategoryOf] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] j
forall k. Witnesses '[] k
WNil)
(Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[RepresentedBy '[CategoryOf] p] k
-> Witnesses '[CategoryOf, RepresentedBy '[CategoryOf] p] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[CategoryOf] j
-> WithTestObRep j p -> Witness (RepresentedBy '[CategoryOf] p) k
forall (csj :: [Type -> Constraint]) j k (p :: j +-> k) k'.
Witnesses csj j
-> WithTestObRep j p -> Witness (RepresentedBy csj p) k'
RepresentedW (Witness CategoryOf j
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf j
-> Witnesses '[] j -> Witnesses '[CategoryOf] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] j
forall k. Witnesses '[] k
WNil) (\ @b TestOb (p % a) => r
r -> WithTestObRep j p
withTestObRep @b r
TestOb (p % a) => r
r) Witness (RepresentedBy '[CategoryOf] p) k
-> Witnesses '[] k -> Witnesses '[RepresentedBy '[CategoryOf] p] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testRepresentable_ :: forall {j} {k} (p :: j +-> k). (Representable p, TestableProfunctor p, TestObIsOb k) => TestTree
testRepresentable_ :: forall {j} {k} (p :: j +-> k).
(Representable p, TestableProfunctor p, TestObIsOb k) =>
TestTree
testRepresentable_ = forall {j} {k} (p :: j +-> k).
(Representable p, TestableProfunctor p) =>
WithTestObRep j p -> TestTree
forall (p :: j +-> k).
(Representable p, TestableProfunctor p) =>
WithTestObRep j p -> TestTree
testRepresentable @p (\ @b TestOb (p % a) => r
r -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @b (forall {j} {k} (p :: j +-> k) (a :: j) r.
(Representable p, Ob a) =>
(Ob (p % a) => r) -> r
forall (p :: j +-> k) (a :: j) r.
(Representable p, Ob a) =>
(Ob (p % a) => r) -> r
withObRep @p @b r
Ob (p % a) => r
TestOb (p % a) => r
r))
testCorepresentable
:: forall {j} {k} (p :: j +-> k)
. (Corepresentable p, TestableProfunctor p)
=> WithTestObCorep k p
-> TestTree
testCorepresentable :: forall {j} {k} (p :: j +-> k).
(Corepresentable p, TestableProfunctor p) =>
WithTestObCorep k p -> TestTree
testCorepresentable WithTestObCorep k p
withTestObCorep =
forall (csj :: [Type -> Constraint]) (csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
forall {j} {k} (csj :: [Type -> Constraint])
(csk :: [Type -> Constraint])
(cl :: (TESTED csj j +-> TESTED csk k) -> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions
-> (forall i. Testable i => Gen (Some i))
-> String
-> Witnesses csj j
-> Witnesses csk k
-> TestTree
testProLaws @'[CategoryOf, CorepresentedBy '[CategoryOf] p] @'[CategoryOf] @Corepresentable @p
TestOptions
defaultTestOptions
Gen (Some i)
forall i. Testable i => Gen (Some i)
genSome
String
"Corepresentable"
(Witness CategoryOf j
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf j
-> Witnesses '[CorepresentedBy '[CategoryOf] p] j
-> Witnesses '[CategoryOf, CorepresentedBy '[CategoryOf] p] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[CategoryOf] k
-> WithTestObCorep k p
-> Witness (CorepresentedBy '[CategoryOf] p) j
forall (csk :: [Type -> Constraint]) j k (p :: j +-> k) j'.
Witnesses csk k
-> WithTestObCorep k p -> Witness (CorepresentedBy csk p) j'
CorepresentedW (Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[] k -> Witnesses '[CategoryOf] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil) (\ @a TestOb (p %% a) => r
r -> WithTestObCorep k p
withTestObCorep @a r
TestOb (p %% a) => r
r) Witness (CorepresentedBy '[CategoryOf] p) j
-> Witnesses '[] j
-> Witnesses '[CorepresentedBy '[CategoryOf] p] j
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] j
forall k. Witnesses '[] k
WNil)
(Witness CategoryOf k
forall k. Witness CategoryOf k
CategoryW Witness CategoryOf k
-> Witnesses '[] k -> Witnesses '[CategoryOf] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testCorepresentable_
:: forall {j} {k} (p :: j +-> k)
. (Corepresentable p, TestableProfunctor p, TestObIsOb j)
=> TestTree
testCorepresentable_ :: forall {j} {k} (p :: j +-> k).
(Corepresentable p, TestableProfunctor p, TestObIsOb j) =>
TestTree
testCorepresentable_ = forall {j} {k} (p :: j +-> k).
(Corepresentable p, TestableProfunctor p) =>
WithTestObCorep k p -> TestTree
forall (p :: j +-> k).
(Corepresentable p, TestableProfunctor p) =>
WithTestObCorep k p -> TestTree
testCorepresentable @p (\ @a TestOb (p %% a) => r
r -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @a (forall {k1} {k2} (p :: k1 +-> k2) (a :: k2) r.
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) r.
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @p @a r
Ob (p %% a) => r
TestOb (p %% a) => r
r))
testPromonad :: forall {k} (p :: k +-> k). (Promonad p, TestableProfunctor p) => TestTree
testPromonad :: forall {k} (p :: k +-> k).
(Promonad p, TestableProfunctor p) =>
TestTree
testPromonad =
forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] k +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: k +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @Promonad @p TestOptions
defaultTestOptions String
"Promonad"
testProcomonad :: forall {k} (p :: k +-> k). (Promonad.Procomonad p, TestableProfunctor p, TestObIsOb k) => TestTree
testProcomonad :: forall {k} (p :: k +-> k).
(Procomonad p, TestableProfunctor p, TestObIsOb k) =>
TestTree
testProcomonad =
forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] k +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: k +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @Promonad.Procomonad @p TestOptions
defaultTestOptions String
"Procomonad"
testProadjunction
:: forall {j} {k} (p :: j +-> k) (q :: k +-> j)
. (Adj.Proadjunction p q, TestableProfunctor p, TestableProfunctor q, TestObIsOb j, TestObIsOb k)
=> TestTree
testProadjunction :: forall {j} {k} (p :: j +-> k) (q :: k +-> j).
(Proadjunction p q, TestableProfunctor p, TestableProfunctor q,
TestObIsOb j, TestObIsOb k) =>
TestTree
testProadjunction =
String -> [TestTree] -> TestTree
testGroup
String
"Proadjunction"
[ forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @(Adj.LeftProadjoint (TestedP q)) @p TestOptions
defaultTestOptions String
"left adjoint"
, forall {j} {k}
(cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k)
-> Constraint)
(p :: j +-> k).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
forall (cl :: (TESTED '[CategoryOf] k +-> TESTED '[CategoryOf] j)
-> Constraint)
(p :: k +-> j).
(ProLaws cl, TestableProfunctor p, cl (TestedP p)) =>
TestOptions -> String -> TestTree
testCategoryProLaws @(Adj.Proadjunction (TestedP p)) @q TestOptions
defaultTestOptions String
"right adjoint"
]
testAdjunction
:: forall {j} {k} (p :: j +-> k)
. (Adjunction p, TestableProfunctor p)
=> WithTestObCorep k p
-> WithTestObRep j p
-> TestTree
testAdjunction :: forall {j} {k} (p :: j +-> k).
(Adjunction p, TestableProfunctor p) =>
WithTestObCorep k p -> WithTestObRep j p -> TestTree
testAdjunction WithTestObCorep k p
withTestObL WithTestObRep j p
withTestObR =
String -> [TestTree] -> TestTree
testGroup
String
"Adjunction"
[ forall {j} {k} (p :: j +-> k).
(Corepresentable p, TestableProfunctor p) =>
WithTestObCorep k p -> TestTree
forall (p :: j +-> k).
(Corepresentable p, TestableProfunctor p) =>
WithTestObCorep k p -> TestTree
testCorepresentable @p (\ @a TestOb (p %% a) => r
r -> WithTestObCorep k p
withTestObL @a r
TestOb (p %% a) => r
r)
, forall {j} {k} (p :: j +-> k).
(Representable p, TestableProfunctor p) =>
WithTestObRep j p -> TestTree
forall (p :: j +-> k).
(Representable p, TestableProfunctor p) =>
WithTestObRep j p -> TestTree
testRepresentable @p (\ @b TestOb (p % a) => r
r -> WithTestObRep j p
withTestObR @b r
TestOb (p % a) => r
r)
]
testAdjunction_
:: forall {j} {k} (p :: j +-> k)
. (Adjunction p, TestableProfunctor p, TestObIsOb j, TestObIsOb k)
=> TestTree
testAdjunction_ :: forall {j} {k} (p :: j +-> k).
(Adjunction p, TestableProfunctor p, TestObIsOb j, TestObIsOb k) =>
TestTree
testAdjunction_ =
forall {j} {k} (p :: j +-> k).
(Adjunction p, TestableProfunctor p) =>
WithTestObCorep k p -> WithTestObRep j p -> TestTree
forall (p :: j +-> k).
(Adjunction p, TestableProfunctor p) =>
WithTestObCorep k p -> WithTestObRep j p -> TestTree
testAdjunction @p
(\ @a TestOb (p %% a) => r
r -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @a (forall {k1} {k2} (p :: k1 +-> k2) (a :: k2) r.
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
forall (p :: j +-> k) (a :: k) r.
(Corepresentable p, Ob a) =>
(Ob (p %% a) => r) -> r
withObCorep @p @a (forall (a :: j) r. (TestObIsOb j, Ob a) => (TestOb a => r) -> r
forall {k} (a :: k) r. (TestObIsOb k, Ob a) => (TestOb a => r) -> r
testObFromOb @(p %% a) r
TestOb (p %% a) => r
r)))
(\ @b TestOb (p % a) => r
r -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @b (forall {j} {k} (p :: j +-> k) (a :: j) r.
(Representable p, Ob a) =>
(Ob (p % a) => r) -> r
forall (p :: j +-> k) (a :: j) r.
(Representable p, Ob a) =>
(Ob (p % a) => r) -> r
withObRep @p @b (forall (a :: k) r. (TestObIsOb k, Ob a) => (TestOb a => r) -> r
forall {k} (a :: k) r. (TestObIsOb k, Ob a) => (TestOb a => r) -> r
testObFromOb @(p % b) r
TestOb (p % a) => r
r)))
testTerminalObject
:: forall k
. (Testable k, Terminal.HasTerminalObject k, TestOb (Terminal.TerminalObject :: k))
=> TestTree
testTerminalObject :: forall k.
(Testable k, HasTerminalObject k, TestOb TerminalObject) =>
TestTree
testTerminalObject = forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[Terminal.HasTerminalObject] String
"Terminal object" (forall k. Witness HasTerminalObject k
TerminalW @k Witness HasTerminalObject k
-> Witnesses '[] k -> Witnesses '[HasTerminalObject] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testInitialObject :: forall k. (Testable k, Initial.HasInitialObject k, TestOb (Initial.InitialObject :: k)) => TestTree
testInitialObject :: forall k.
(Testable k, HasInitialObject k, TestOb InitialObject) =>
TestTree
testInitialObject = forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[Initial.HasInitialObject] String
"Initial object" (forall k. Witness HasInitialObject k
InitialW @k Witness HasInitialObject k
-> Witnesses '[] k -> Witnesses '[HasInitialObject] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testBinaryProducts :: forall k. (Testable k, BinaryProduct.HasBinaryProducts k) => WithTestObProd k -> TestTree
testBinaryProducts :: forall k.
(Testable k, HasBinaryProducts k) =>
WithTestObProd k -> TestTree
testBinaryProducts WithTestObProd k
withTestObProd =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[BinaryProduct.HasBinaryProducts] String
"Binary products" (WithTestObProd k -> Witness HasBinaryProducts k
forall k. WithTestObProd k -> Witness HasBinaryProducts k
ProductsW (\ @a @b TestOb (a && b) => r
r -> WithTestObProd k
withTestObProd @a @b r
TestOb (a && b) => r
r) Witness HasBinaryProducts k
-> Witnesses '[] k -> Witnesses '[HasBinaryProducts] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testBinaryProducts_ :: forall k. (Testable k, BinaryProduct.HasBinaryProducts k, TestObIsOb k) => TestTree
testBinaryProducts_ :: forall k.
(Testable k, HasBinaryProducts k, TestObIsOb k) =>
TestTree
testBinaryProducts_ = forall k.
(Testable k, HasBinaryProducts k) =>
WithTestObProd k -> TestTree
testBinaryProducts @k (\ @a @b -> WithTestObProd k
forall {k}. (TestObIsOb k, HasBinaryProducts k) => WithTestObProd k
withTestObProdDef @a @b)
testBinaryCoproducts :: forall k. (Testable k, BinaryCoproduct.HasBinaryCoproducts k) => WithTestObCoprod k -> TestTree
testBinaryCoproducts :: forall k.
(Testable k, HasBinaryCoproducts k) =>
WithTestObCoprod k -> TestTree
testBinaryCoproducts WithTestObCoprod k
withTestObCoprod =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[BinaryCoproduct.HasBinaryCoproducts]
String
"Binary coproducts"
(WithTestObCoprod k -> Witness HasBinaryCoproducts k
forall k. WithTestObCoprod k -> Witness HasBinaryCoproducts k
CoproductsW (\ @a @b TestOb (a || b) => r
r -> WithTestObCoprod k
withTestObCoprod @a @b r
TestOb (a || b) => r
r) Witness HasBinaryCoproducts k
-> Witnesses '[] k -> Witnesses '[HasBinaryCoproducts] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testBinaryCoproducts_ :: forall k. (Testable k, BinaryCoproduct.HasBinaryCoproducts k, TestObIsOb k) => TestTree
testBinaryCoproducts_ :: forall k.
(Testable k, HasBinaryCoproducts k, TestObIsOb k) =>
TestTree
testBinaryCoproducts_ = forall k.
(Testable k, HasBinaryCoproducts k) =>
WithTestObCoprod k -> TestTree
testBinaryCoproducts @k (\ @a @b -> WithTestObCoprod k
forall {k}.
(TestObIsOb k, HasBinaryCoproducts k) =>
WithTestObCoprod k
withTestObCoprodDef @a @b)
propReflectsEq :: (TestingEqShow x) => String -> String -> Bool -> x -> x -> Property ()
propReflectsEq :: forall x.
TestingEqShow x =>
String -> String -> Bool -> x -> x -> Property ()
propReflectsEq String
label String
desc Bool
eqComposed x
k1 x
k2 = do
eqDirect <- x -> x -> Property Bool
forall a. TestingEqShow a => a -> a -> Property Bool
eqP x
k1 x
k2
check
("Failed " ++ label ++ ": (" ++ desc ++ ") = " ++ show eqComposed ++ " but (k1 == k2) = " ++ show eqDirect)
(eqComposed == eqDirect)
testEqualizers :: forall k. (Testable k, Equalizer.HasEqualizers k) => WithTestOb k -> TestTree
testEqualizers :: forall k. (Testable k, HasEqualizers k) => WithTestOb k -> TestTree
testEqualizers WithTestOb k
withTestOb = String -> Property () -> TestTree
testProperty String
"Equalizers" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @k
f <- genNamed @(a ~> b) "f"
g <- genNamed @(a ~> b) "g"
Equalizer.equalize f g \ @e ee :: e ~> x
ee@e ~> x
Objs -> WithTestOb k
withTestOb @e do
String -> String -> (e ~> x) -> String -> (e ~> x) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"equalizing" String
"f . e" (x ~> x
f (x ~> x) -> (e ~> x) -> e ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. e ~> x
ee) String
"g . e" (x ~> x
g (x ~> x) -> (e ~> x) -> e ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. e ~> x
ee)
Some @z <- forall k. Testable k => Property (Some k)
genOb @k
p <- genNamed @(z ~> e) "p"
let h = e ~> x
ee (e ~> x) -> (x ~> e) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> e
p
factored = (e ~> x) -> (x ~> x) -> x ~> e
forall (e :: k) (x :: k) (e' :: k).
(e ~> x) -> (e' ~> x) -> e' ~> e
forall k (e :: k) (x :: k) (e' :: k).
HasEqualizers k =>
(e ~> x) -> (e' ~> x) -> e' ~> e
Equalizer.factorEqualizer e ~> x
ee x ~> x
h
testEq "factorization" "e . factored" (ee . factored) "h" h
m <- genNamed @(z ~> a) "m"
equalizes <- eqP (f . m) (g . m)
when equalizes $
testEq "existence" "e . factorEqualizer e m" (ee . Equalizer.factorEqualizer ee m) "m" m
k1 <- genNamed @(z ~> e) "k1"
k2 <- genNamed @(z ~> e) "k2"
eqComposed <- eqP (ee . k1) (ee . k2)
propReflectsEq "mono" "e . k1 == e . k2" eqComposed k1 k2
testEqualizers_ :: forall k. (Testable k, Equalizer.HasEqualizers k, TestObIsOb k) => TestTree
testEqualizers_ :: forall k. (Testable k, HasEqualizers k, TestObIsOb k) => TestTree
testEqualizers_ = forall k. (Testable k, HasEqualizers k) => WithTestOb k -> TestTree
testEqualizers @k (\TestOb a => r
r -> r
TestOb a => r
r)
testCoequalizers :: forall k. (Testable k, Coequalizer.HasCoequalizers k) => WithTestOb k -> TestTree
testCoequalizers :: forall k.
(Testable k, HasCoequalizers k) =>
WithTestOb k -> TestTree
testCoequalizers WithTestOb k
withTestOb = String -> Property () -> TestTree
testProperty String
"Coequalizers" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @k
f <- genNamed @(a ~> b) "f"
g <- genNamed @(a ~> b) "g"
Coequalizer.coequalize f g \ @c cq :: x ~> c
cq@x ~> c
Objs -> WithTestOb k
withTestOb @c do
String -> String -> (x ~> c) -> String -> (x ~> c) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"coequalizing" String
"c . f" (x ~> c
cq (x ~> c) -> (x ~> x) -> x ~> c
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> x
f) String
"c . g" (x ~> c
cq (x ~> c) -> (x ~> x) -> x ~> c
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> x
g)
Some @z <- forall k. Testable k => Property (Some k)
genOb @k
p <- genNamed @(c ~> z) "p"
let h = c ~> x
p (c ~> x) -> (x ~> c) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> c
cq
factored = (x ~> c) -> (x ~> x) -> c ~> x
forall (c :: k) (x :: k) (c' :: k).
(x ~> c) -> (x ~> c') -> c ~> c'
forall k (c :: k) (x :: k) (c' :: k).
HasCoequalizers k =>
(x ~> c) -> (x ~> c') -> c ~> c'
Coequalizer.factorCoequalizer x ~> c
cq x ~> x
h
testEq "factorization" "factored . c" (factored . cq) "h" h
m <- genNamed @(b ~> z) "m"
coequalizes <- eqP (m . f) (m . g)
when coequalizes $
testEq "existence" "factorCoequalizer c m . c" (Coequalizer.factorCoequalizer cq m . cq) "m" m
k1 <- genNamed @(c ~> z) "k1"
k2 <- genNamed @(c ~> z) "k2"
eqComposed <- eqP (k1 . cq) (k2 . cq)
propReflectsEq "epi" "k1 . c == k2 . c" eqComposed k1 k2
testCoequalizers_ :: forall k. (Testable k, Coequalizer.HasCoequalizers k, TestObIsOb k) => TestTree
testCoequalizers_ :: forall k. (Testable k, HasCoequalizers k, TestObIsOb k) => TestTree
testCoequalizers_ = forall k.
(Testable k, HasCoequalizers k) =>
WithTestOb k -> TestTree
testCoequalizers @k (\TestOb a => r
r -> r
TestOb a => r
r)
testPullbacks :: forall k. (Testable k, Pullback.HasPullbacks k) => WithTestOb k -> TestTree
testPullbacks :: forall k. (Testable k, HasPullbacks k) => WithTestOb k -> TestTree
testPullbacks WithTestOb k
withTestOb = String -> Property () -> TestTree
testProperty String
"Pullbacks" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @o <- forall k. Testable k => Property (Some k)
genOb @k
Some @a <- genOb @k
Some @b <- genOb @k
f <- genNamed @(a ~> o) "f"
g <- genNamed @(b ~> o) "g"
Pullback.pullback f g \ @p p1 :: p ~> x
p1@p ~> x
Objs p ~> x
p2 -> WithTestOb k
withTestOb @p do
String -> String -> (p ~> x) -> String -> (p ~> x) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"commutes" String
"f . p1" (x ~> x
f (x ~> x) -> (p ~> x) -> p ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. p ~> x
p1) String
"g . p2" (x ~> x
g (x ~> x) -> (p ~> x) -> p ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. p ~> x
p2)
Some @z <- forall k. Testable k => Property (Some k)
genOb @k
k1' <- genNamed @(z ~> p) "k1"
k2' <- genNamed @(z ~> p) "k2"
eq1 <- eqP (p1 . k1') (p1 . k2')
eq2 <- eqP (p2 . k1') (p2 . k2')
propReflectsEq "jointly monic" "p1 . k1 == p1 . k2 && p2 . k1 == p2 . k2" (eq1 && eq2) k1' k2'
j <- genNamed @(z ~> p) "j"
let k1 = p ~> x
p1 (p ~> x) -> (x ~> p) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> p
j
k2 = p ~> x
p2 (p ~> x) -> (x ~> p) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> p
j
factored = (p ~> x) -> (p ~> x) -> (x ~> x) -> (x ~> x) -> x ~> p
forall (a :: k) (b :: k) (p :: k) (q :: k).
(p ~> a) -> (p ~> b) -> (q ~> a) -> (q ~> b) -> q ~> p
forall k (a :: k) (b :: k) (p :: k) (q :: k).
HasPullbacks k =>
(p ~> a) -> (p ~> b) -> (q ~> a) -> (q ~> b) -> q ~> p
Pullback.factorPullback p ~> x
p1 p ~> x
p2 x ~> x
k1 x ~> x
k2
testEq "factorization (1)" "p1 . factored" (p1 . factored) "k1" k1
testEq "factorization (2)" "p2 . factored" (p2 . factored) "k2" k2
x <- genNamed @(z ~> a) "x"
y <- genNamed @(z ~> b) "y"
commutes <- eqP (f . x) (g . y)
when commutes $ do
let fac = (p ~> x) -> (p ~> x) -> (x ~> x) -> (x ~> x) -> x ~> p
forall (a :: k) (b :: k) (p :: k) (q :: k).
(p ~> a) -> (p ~> b) -> (q ~> a) -> (q ~> b) -> q ~> p
forall k (a :: k) (b :: k) (p :: k) (q :: k).
HasPullbacks k =>
(p ~> a) -> (p ~> b) -> (q ~> a) -> (q ~> b) -> q ~> p
Pullback.factorPullback p ~> x
p1 p ~> x
p2 x ~> x
x x ~> x
y
testEq "existence (1)" "p1 . factorPullback p1 p2 x y" (p1 . fac) "x" x
testEq "existence (2)" "p2 . factorPullback p1 p2 x y" (p2 . fac) "y" y
testPullbacks_ :: forall k. (Testable k, Pullback.HasPullbacks k, TestObIsOb k) => TestTree
testPullbacks_ :: forall k. (Testable k, HasPullbacks k, TestObIsOb k) => TestTree
testPullbacks_ = forall k. (Testable k, HasPullbacks k) => WithTestOb k -> TestTree
testPullbacks @k (\TestOb a => r
r -> r
TestOb a => r
r)
testPushouts :: forall k. (Testable k, Pushout.HasPushouts k) => WithTestOb k -> TestTree
testPushouts :: forall k. (Testable k, HasPushouts k) => WithTestOb k -> TestTree
testPushouts WithTestOb k
withTestOb = String -> Property () -> TestTree
testProperty String
"Pushouts" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @o <- forall k. Testable k => Property (Some k)
genOb @k
Some @a <- genOb @k
Some @b <- genOb @k
f <- genNamed @(o ~> a) "f"
g <- genNamed @(o ~> b) "g"
Pushout.pushout f g \ @p p1 :: x ~> p
p1@x ~> p
Objs x ~> p
p2 -> WithTestOb k
withTestOb @p do
String -> String -> (x ~> p) -> String -> (x ~> p) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"commutes" String
"p1 . f" (x ~> p
p1 (x ~> p) -> (x ~> x) -> x ~> p
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> x
f) String
"p2 . g" (x ~> p
p2 (x ~> p) -> (x ~> x) -> x ~> p
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> x
g)
Some @z <- forall k. Testable k => Property (Some k)
genOb @k
k1' <- genNamed @(p ~> z) "k1"
k2' <- genNamed @(p ~> z) "k2"
eq1 <- eqP (k1' . p1) (k2' . p1)
eq2 <- eqP (k1' . p2) (k2' . p2)
propReflectsEq "jointly epic" "k1 . p1 == k2 . p1 && k1 . p2 == k2 . p2" (eq1 && eq2) k1' k2'
j <- genNamed @(p ~> z) "j"
let k1 = p ~> x
j (p ~> x) -> (x ~> p) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> p
p1
k2 = p ~> x
j (p ~> x) -> (x ~> p) -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> p
p2
factored = (x ~> p) -> (x ~> p) -> (x ~> x) -> (x ~> x) -> p ~> x
forall (a :: k) (b :: k) (p :: k) (q :: k).
(a ~> p) -> (b ~> p) -> (a ~> q) -> (b ~> q) -> p ~> q
forall k (a :: k) (b :: k) (p :: k) (q :: k).
HasPushouts k =>
(a ~> p) -> (b ~> p) -> (a ~> q) -> (b ~> q) -> p ~> q
Pushout.factorPushout x ~> p
p1 x ~> p
p2 x ~> x
k1 x ~> x
k2
testEq "factorization (1)" "factored . p1" (factored . p1) "k1" k1
testEq "factorization (2)" "factored . p2" (factored . p2) "k2" k2
x <- genNamed @(a ~> z) "x"
y <- genNamed @(b ~> z) "y"
commutes <- eqP (x . f) (y . g)
when commutes $ do
let fac = (x ~> p) -> (x ~> p) -> (x ~> x) -> (x ~> x) -> p ~> x
forall (a :: k) (b :: k) (p :: k) (q :: k).
(a ~> p) -> (b ~> p) -> (a ~> q) -> (b ~> q) -> p ~> q
forall k (a :: k) (b :: k) (p :: k) (q :: k).
HasPushouts k =>
(a ~> p) -> (b ~> p) -> (a ~> q) -> (b ~> q) -> p ~> q
Pushout.factorPushout x ~> p
p1 x ~> p
p2 x ~> x
x x ~> x
y
testEq "existence (1)" "factorPushout p1 p2 x y . p1" (fac . p1) "x" x
testEq "existence (2)" "factorPushout p1 p2 x y . p2" (fac . p2) "y" y
testPushouts_ :: forall k. (Testable k, Pushout.HasPushouts k, TestObIsOb k) => TestTree
testPushouts_ :: forall k. (Testable k, HasPushouts k, TestObIsOb k) => TestTree
testPushouts_ = forall k. (Testable k, HasPushouts k) => WithTestOb k -> TestTree
testPushouts @k (\TestOb a => r
r -> r
TestOb a => r
r)
testEpiMonoFactorization
:: forall k. (Testable k, Topos.HasEpiMonoFactorization k) => WithTestOb k -> TestTree
testEpiMonoFactorization :: forall k.
(Testable k, HasEpiMonoFactorization k) =>
WithTestOb k -> TestTree
testEpiMonoFactorization WithTestOb k
withTestOb = String -> Property () -> TestTree
testProperty String
"Epi-mono factorization" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @k
f <- genNamed @(a ~> b) "f"
case Topos.factorize f of
(:.:) @x e :: Hom k x b
e@Hom k x b
Objs Hom k b x
m -> WithTestOb k
withTestOb @x do
String -> String -> (x ~> x) -> String -> (x ~> x) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"factorization" String
"m . e" (Hom k b x
m Hom k b x -> Hom k x b -> x ~> x
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. Hom k x b
e) String
"f" x ~> x
f
Some @z <- forall k. Testable k => Property (Some k)
genOb @k
k1 <- genNamed @(x ~> z) "k1"
k2 <- genNamed @(x ~> z) "k2"
eqEpi <- eqP (k1 . e) (k2 . e)
propReflectsEq "epi" "k1 . e == k2 . e" eqEpi k1 k2
j1 <- genNamed @(z ~> x) "k1"
j2 <- genNamed @(z ~> x) "k2"
eqMono <- eqP (m . j1) (m . j2)
propReflectsEq "mono" "m . k1 == m . k2" eqMono j1 j2
testEpiMonoFactorization_
:: forall k. (Testable k, Topos.HasEpiMonoFactorization k, TestObIsOb k) => TestTree
testEpiMonoFactorization_ :: forall k.
(Testable k, HasEpiMonoFactorization k, TestObIsOb k) =>
TestTree
testEpiMonoFactorization_ = forall k.
(Testable k, HasEpiMonoFactorization k) =>
WithTestOb k -> TestTree
testEpiMonoFactorization @k (\TestOb a => r
r -> r
TestOb a => r
r)
testMonoidal :: forall k. (Testable k, M.Monoidal k, TestOb (M.Unit @k)) => WithTestOb2 k -> TestTree
testMonoidal :: forall k.
(Testable k, Monoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonoidal WithTestOb2 k
withTestOb2 = forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal] String
"Monoidal" (WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k -> Witnesses '[] k -> Witnesses '[Monoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testMonoidal_ :: forall k. (Testable k, M.Monoidal k, TestObIsOb k) => TestTree
testMonoidal_ :: forall k. (Testable k, Monoidal k, TestObIsOb k) => TestTree
testMonoidal_ = forall k.
(Testable k, Monoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonoidal @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testSymMonoidal :: forall k. (Testable k, M.SymMonoidal k, TestOb (M.Unit @k)) => WithTestOb2 k -> TestTree
testSymMonoidal :: forall k.
(Testable k, SymMonoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testSymMonoidal WithTestOb2 k
withTestOb2 =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @M.SymMonoidalStructures
String
"Symmetric monoidal"
(WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k
-> Witnesses '[SymMonoidal] k -> Witnesses SymMonoidalStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[] k -> Witnesses '[SymMonoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testSymMonoidal_ :: forall k. (Testable k, M.SymMonoidal k, TestObIsOb k) => TestTree
testSymMonoidal_ :: forall k. (Testable k, SymMonoidal k, TestObIsOb k) => TestTree
testSymMonoidal_ = forall k.
(Testable k, SymMonoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testSymMonoidal @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testCopyDiscard
:: forall k. (Testable k, CopyDiscard.CopyDiscard k, TestOb (M.Unit @k)) => WithTestOb2 k -> TestTree
testCopyDiscard :: forall k.
(Testable k, CopyDiscard k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCopyDiscard WithTestOb2 k
withTestOb2 =
String -> [TestTree] -> TestTree
testGroup
String
"CopyDiscard"
[ forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, Monoid.Supplies Monoid.Comonoid] @k
String
"Comonoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[Supplies Comonoid] k
-> Witnesses '[Monoidal, Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies Comonoid) k
forall k. Witness (Supplies Comonoid) k
ComonoidSupplyW Witness (Supplies Comonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, M.SymMonoidal, Monoid.Supplies Monoid.CocommutativeComonoid] @k
String
"Cocommutative comonoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[SymMonoidal, Supplies CocommutativeComonoid] k
-> Witnesses
'[Monoidal, SymMonoidal, Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[Supplies CocommutativeComonoid] k
-> Witnesses '[SymMonoidal, Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies CocommutativeComonoid) k
forall k. Witness (Supplies CocommutativeComonoid) k
CocommutativeComonoidSupplyW Witness (Supplies CocommutativeComonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @CopyDiscard.CopyDiscardStructures String
"Copy and discard" (Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[SymMonoidal, CopyDiscard] k
-> Witnesses CopyDiscardStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[CopyDiscard] k
-> Witnesses '[SymMonoidal, CopyDiscard] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness CopyDiscard k
forall k. Witness CopyDiscard k
CopyDiscardW Witness CopyDiscard k
-> Witnesses '[] k -> Witnesses '[CopyDiscard] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
]
where
monoidal :: Witness Monoidal k
monoidal = WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
testCopyDiscard_ :: forall k. (Testable k, CopyDiscard.CopyDiscard k, TestObIsOb k) => TestTree
testCopyDiscard_ :: forall k. (Testable k, CopyDiscard k, TestObIsOb k) => TestTree
testCopyDiscard_ = forall k.
(Testable k, CopyDiscard k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCopyDiscard @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testCartesian
:: forall k
. (Testable k, Cartesian.Cartesian k, TestOb (M.Unit @k))
=> (forall (a :: k) r. (TestOb a) => ((Ob a) => r) -> r)
-> WithTestOb2 k
-> TestTree
testCartesian :: forall k.
(Testable k, Cartesian k, TestOb Unit) =>
(forall (a :: k) r. TestOb a => (Ob a => r) -> r)
-> WithTestOb2 k -> TestTree
testCartesian forall (a :: k) r. TestOb a => (Ob a => r) -> r
withOb WithTestOb2 k
withTestOb2 = String -> Property () -> TestTree
testProperty String
"Cartesian" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
withOb @a (withTestOb2 @a @a (propCartesianAt @a))
propCartesianAt
:: forall {k} (a :: k)
. ( Testable k
, Cartesian.Cartesian k
, Cartesian.TensorIsProduct a a
, TestOb (M.Unit @k)
, TestOb a
, Ob a
, TestOb (a M.** a)
)
=> Property ()
propCartesianAt :: forall {k} (a :: k).
(Testable k, Cartesian k, TensorIsProduct a a, TestOb Unit,
TestOb a, Ob a, TestOb (a ** a)) =>
Property ()
propCartesianAt = do
String
-> String
-> (a ~> (a ** a))
-> String
-> (a ~> (a ** a))
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"copy" String
"copy" (forall k (a :: k). (CopyDiscard k, Ob a) => a ~> (a ** a)
CopyDiscard.copy @k @a) String
"id &&& id" (forall (a :: k). (HasBinaryProducts k, Ob a) => a ~> (a && a)
forall {k} (a :: k). (HasBinaryProducts k, Ob a) => a ~> (a && a)
BinaryProduct.diag @a)
String
-> String -> (a ~> Unit) -> String -> (a ~> Unit) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"discard" String
"discard" (forall k (a :: k). (CopyDiscard k, Ob a) => a ~> Unit
CopyDiscard.discard @k @a) String
"terminate" (forall k (a :: k).
(HasTerminalObject k, Ob a) =>
a ~> TerminalObject
Terminal.terminate @k @a)
testCartesian_ :: forall k. (Testable k, Cartesian.Cartesian k, TestObIsOb k, TestOb (M.Unit @k)) => TestTree
testCartesian_ :: forall k.
(Testable k, Cartesian k, TestObIsOb k, TestOb Unit) =>
TestTree
testCartesian_ =
forall k.
(Testable k, Cartesian k, TestOb Unit) =>
(forall (a :: k) r. TestOb a => (Ob a => r) -> r)
-> WithTestOb2 k -> TestTree
testCartesian @k (\ @a Ob a => r
r -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @a r
Ob a => r
r) (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testDistributive
:: forall k
. (Testable k, Distributive.Distributive k, TestOb (M.Unit @k), TestOb (Initial.InitialObject :: k))
=> WithTestOb2 k
-> WithTestObCoprod k
-> TestTree
testDistributive :: forall k.
(Testable k, Distributive k, TestOb Unit, TestOb InitialObject) =>
WithTestOb2 k -> WithTestObCoprod k -> TestTree
testDistributive WithTestOb2 k
withTestOb2 WithTestObCoprod k
withTestObCoprod =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @Distributive.DistributiveStructures
String
"Distributive"
( WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
Witness Monoidal k
-> Witnesses
'[HasInitialObject, HasBinaryCoproducts, Distributive] k
-> Witnesses DistributiveStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness HasInitialObject k
forall k. Witness HasInitialObject k
InitialW
Witness HasInitialObject k
-> Witnesses '[HasBinaryCoproducts, Distributive] k
-> Witnesses
'[HasInitialObject, HasBinaryCoproducts, Distributive] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObCoprod k -> Witness HasBinaryCoproducts k
forall k. WithTestObCoprod k -> Witness HasBinaryCoproducts k
CoproductsW (\ @a @b TestOb (a || b) => r
r -> WithTestObCoprod k
withTestObCoprod @a @b r
TestOb (a || b) => r
r)
Witness HasBinaryCoproducts k
-> Witnesses '[Distributive] k
-> Witnesses '[HasBinaryCoproducts, Distributive] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness Distributive k
forall k. Witness Distributive k
DistributiveW
Witness Distributive k
-> Witnesses '[] k -> Witnesses '[Distributive] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
)
testDistributive_ :: forall k. (Testable k, Distributive.Distributive k, TestObIsOb k) => TestTree
testDistributive_ :: forall k. (Testable k, Distributive k, TestObIsOb k) => TestTree
testDistributive_ =
forall k.
(Testable k, Distributive k, TestOb Unit, TestOb InitialObject) =>
WithTestOb2 k -> WithTestObCoprod k -> TestTree
testDistributive @k
(\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
(\ @a @b -> WithTestObCoprod k
forall {k}.
(TestObIsOb k, HasBinaryCoproducts k) =>
WithTestObCoprod k
withTestObCoprodDef @a @b)
testClosed
:: forall k
. (Testable k, Exponential.Closed k, TestOb (M.Unit @k))
=> WithTestOb2 k
-> WithTestObExp k
-> TestTree
testClosed :: forall k.
(Testable k, Closed k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> TestTree
testClosed WithTestOb2 k
withTestOb2 WithTestObExp k
withTestObExp =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
Property (Some k) -> String -> Witnesses cs k -> TestTree
testLawsWith @Exponential.ClosedStructures
(forall k. Testable k => Property (Some k)
genObSmall @k)
String
"Closed"
(WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k
-> Witnesses '[Closed] k -> Witnesses ClosedStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObExp k -> Witness Closed k
forall k. WithTestObExp k -> Witness Closed k
ClosedW (\ @a @b TestOb (a ~~> b) => r
r -> WithTestObExp k
withTestObExp @a @b r
TestOb (a ~~> b) => r
r) Witness Closed k -> Witnesses '[] k -> Witnesses '[Closed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testClosed_ :: forall k. (Testable k, Exponential.Closed k, TestObIsOb k) => TestTree
testClosed_ :: forall k. (Testable k, Closed k, TestObIsOb k) => TestTree
testClosed_ =
forall k.
(Testable k, Closed k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> TestTree
testClosed @k
(\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
(\ @a @b -> WithTestObExp k
forall {k}. (TestObIsOb k, Closed k) => WithTestObExp k
withTestObExpDef @a @b)
testDialogue
:: forall k
. (Testable k, SA.Dialogue k, TestOb (M.Unit @k))
=> WithTestOb2 k
-> WithTestObDual k
-> TestTree
testDialogue :: forall k.
(Testable k, Dialogue k, TestOb Unit) =>
WithTestOb2 k -> WithTestObDual k -> TestTree
testDialogue WithTestOb2 k
withTestOb2 WithTestObDual k
withTestObDual =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @SA.DialogueStructures
String
"Dialogue"
( WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
Witness Monoidal k
-> Witnesses '[SymMonoidal, Dialogue] k
-> Witnesses DialogueStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW
Witness SymMonoidal k
-> Witnesses '[Dialogue] k -> Witnesses '[SymMonoidal, Dialogue] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObDual k -> Witness Dialogue k
forall k. WithTestObDual k -> Witness Dialogue k
DialogueW (\ @a TestOb (Dual a) => r
r -> WithTestObDual k
withTestObDual @a r
TestOb (Dual a) => r
r)
Witness Dialogue k -> Witnesses '[] k -> Witnesses '[Dialogue] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
)
testDialogue_ :: forall k. (Testable k, SA.Dialogue k, TestObIsOb k) => TestTree
testDialogue_ :: forall k. (Testable k, Dialogue k, TestObIsOb k) => TestTree
testDialogue_ = forall k.
(Testable k, Dialogue k, TestOb Unit) =>
WithTestOb2 k -> WithTestObDual k -> TestTree
testDialogue @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b) (\ @a -> WithTestObDual k
forall {k}. (TestObIsOb k, Dialogue k) => WithTestObDual k
withTestObDualDef @a)
testStarAutonomous
:: forall k
. (Testable k, SA.StarAutonomous k, TestOb (M.Unit @k))
=> WithTestOb2 k
-> WithTestObExp k
-> WithTestObDual k
-> TestTree
testStarAutonomous :: forall k.
(Testable k, StarAutonomous k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree
testStarAutonomous WithTestOb2 k
withTestOb2 WithTestObExp k
withTestObExp WithTestObDual k
withTestObDual =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @SA.StarAutonomousStructures
String
"*-autonomous"
( WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
Witness Monoidal k
-> Witnesses '[SymMonoidal, Closed, Dialogue, StarAutonomous] k
-> Witnesses StarAutonomousStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW
Witness SymMonoidal k
-> Witnesses '[Closed, Dialogue, StarAutonomous] k
-> Witnesses '[SymMonoidal, Closed, Dialogue, StarAutonomous] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObExp k -> Witness Closed k
forall k. WithTestObExp k -> Witness Closed k
ClosedW (\ @a @b TestOb (a ~~> b) => r
r -> WithTestObExp k
withTestObExp @a @b r
TestOb (a ~~> b) => r
r)
Witness Closed k
-> Witnesses '[Dialogue, StarAutonomous] k
-> Witnesses '[Closed, Dialogue, StarAutonomous] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObDual k -> Witness Dialogue k
forall k. WithTestObDual k -> Witness Dialogue k
DialogueW (\ @a TestOb (Dual a) => r
r -> WithTestObDual k
withTestObDual @a r
TestOb (Dual a) => r
r)
Witness Dialogue k
-> Witnesses '[StarAutonomous] k
-> Witnesses '[Dialogue, StarAutonomous] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness StarAutonomous k
forall k. Witness StarAutonomous k
StarAutonomousW
Witness StarAutonomous k
-> Witnesses '[] k -> Witnesses '[StarAutonomous] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
)
testStarAutonomous_ :: forall k. (Testable k, SA.StarAutonomous k, TestObIsOb k) => TestTree
testStarAutonomous_ :: forall k. (Testable k, StarAutonomous k, TestObIsOb k) => TestTree
testStarAutonomous_ =
forall k.
(Testable k, StarAutonomous k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree
testStarAutonomous @k
(\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
(\ @a @b -> WithTestObExp k
forall {k}. (TestObIsOb k, Closed k) => WithTestObExp k
withTestObExpDef @a @b)
(\ @a -> WithTestObDual k
forall {k}. (TestObIsOb k, Dialogue k) => WithTestObDual k
withTestObDualDef @a)
testIsoMix
:: forall k
. (Testable k, IsoMix.IsoMix k, TestOb (M.Unit @k))
=> WithTestOb2 k
-> WithTestObDual k
-> TestTree
testIsoMix :: forall k.
(Testable k, IsoMix k, TestOb Unit) =>
WithTestOb2 k -> WithTestObDual k -> TestTree
testIsoMix WithTestOb2 k
withTestOb2 WithTestObDual k
withTestObDual =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @IsoMix.IsoMixStructures
String
"Isomix"
( WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
Witness Monoidal k
-> Witnesses '[SymMonoidal, Dialogue, IsoMix] k
-> Witnesses IsoMixStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW
Witness SymMonoidal k
-> Witnesses '[Dialogue, IsoMix] k
-> Witnesses '[SymMonoidal, Dialogue, IsoMix] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObDual k -> Witness Dialogue k
forall k. WithTestObDual k -> Witness Dialogue k
DialogueW (\ @a TestOb (Dual a) => r
r -> WithTestObDual k
withTestObDual @a r
TestOb (Dual a) => r
r)
Witness Dialogue k
-> Witnesses '[IsoMix] k -> Witnesses '[Dialogue, IsoMix] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness IsoMix k
forall k. Witness IsoMix k
IsoMixW
Witness IsoMix k -> Witnesses '[] k -> Witnesses '[IsoMix] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
)
testIsoMix_ :: forall k. (Testable k, IsoMix.IsoMix k, TestObIsOb k) => TestTree
testIsoMix_ :: forall k. (Testable k, IsoMix k, TestObIsOb k) => TestTree
testIsoMix_ = forall k.
(Testable k, IsoMix k, TestOb Unit) =>
WithTestOb2 k -> WithTestObDual k -> TestTree
testIsoMix @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b) (\ @a -> WithTestObDual k
forall {k}. (TestObIsOb k, Dialogue k) => WithTestObDual k
withTestObDualDef @a)
testCompactClosed
:: forall k
. (Testable k, CC.CompactClosed k, TestOb (M.Unit @k))
=> WithTestOb2 k
-> WithTestObExp k
-> WithTestObDual k
-> TestTree
testCompactClosed :: forall k.
(Testable k, CompactClosed k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree
testCompactClosed WithTestOb2 k
withTestOb2 WithTestObExp k
withTestObExp WithTestObDual k
withTestObDual =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @CC.CompactClosedStructures
String
"Compact closed"
( WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
Witness Monoidal k
-> Witnesses
'[SymMonoidal, Closed, Dialogue, StarAutonomous, IsoMix,
CompactClosed]
k
-> Witnesses CompactClosedStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW
Witness SymMonoidal k
-> Witnesses
'[Closed, Dialogue, StarAutonomous, IsoMix, CompactClosed] k
-> Witnesses
'[SymMonoidal, Closed, Dialogue, StarAutonomous, IsoMix,
CompactClosed]
k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObExp k -> Witness Closed k
forall k. WithTestObExp k -> Witness Closed k
ClosedW (\ @a @b TestOb (a ~~> b) => r
r -> WithTestObExp k
withTestObExp @a @b r
TestOb (a ~~> b) => r
r)
Witness Closed k
-> Witnesses '[Dialogue, StarAutonomous, IsoMix, CompactClosed] k
-> Witnesses
'[Closed, Dialogue, StarAutonomous, IsoMix, CompactClosed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& WithTestObDual k -> Witness Dialogue k
forall k. WithTestObDual k -> Witness Dialogue k
DialogueW (\ @a TestOb (Dual a) => r
r -> WithTestObDual k
withTestObDual @a r
TestOb (Dual a) => r
r)
Witness Dialogue k
-> Witnesses '[StarAutonomous, IsoMix, CompactClosed] k
-> Witnesses '[Dialogue, StarAutonomous, IsoMix, CompactClosed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness StarAutonomous k
forall k. Witness StarAutonomous k
StarAutonomousW
Witness StarAutonomous k
-> Witnesses '[IsoMix, CompactClosed] k
-> Witnesses '[StarAutonomous, IsoMix, CompactClosed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness IsoMix k
forall k. Witness IsoMix k
IsoMixW
Witness IsoMix k
-> Witnesses '[CompactClosed] k
-> Witnesses '[IsoMix, CompactClosed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness CompactClosed k
forall k. Witness CompactClosed k
CompactClosedW
Witness CompactClosed k
-> Witnesses '[] k -> Witnesses '[CompactClosed] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil
)
testCompactClosed_ :: forall k. (Testable k, CC.CompactClosed k, TestObIsOb k) => TestTree
testCompactClosed_ :: forall k. (Testable k, CompactClosed k, TestObIsOb k) => TestTree
testCompactClosed_ =
forall k.
(Testable k, CompactClosed k, TestOb Unit) =>
WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree
testCompactClosed @k
(\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
(\ @a @b -> WithTestObExp k
forall {k}. (TestObIsOb k, Closed k) => WithTestObExp k
withTestObExpDef @a @b)
(\ @a -> WithTestObDual k
forall {k}. (TestObIsOb k, Dialogue k) => WithTestObDual k
withTestObDualDef @a)
testHypergraph
:: forall k
. ( Testable k
, M.SymMonoidal k
, Monoid.Supplies Monoid.CommutativeMonoid k
, Monoid.Supplies Monoid.CocommutativeComonoid k
, TestOb (M.Unit @k)
)
=> WithTestOb2 k
-> TestTree
testHypergraph :: forall k.
(Testable k, SymMonoidal k, Supplies CommutativeMonoid k,
Supplies CocommutativeComonoid k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testHypergraph WithTestOb2 k
withTestOb2 =
String -> [TestTree] -> TestTree
testGroup
String
"Hypergraph (Frobenius supply)"
[ forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, Monoid.Supplies Monoid.Monoid] @k
String
"Monoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[Supplies Monoid] k
-> Witnesses '[Monoidal, Supplies Monoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies Monoid) k
forall k. Witness (Supplies Monoid) k
MonoidSupplyW Witness (Supplies Monoid) k
-> Witnesses '[] k -> Witnesses '[Supplies Monoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, Monoid.Supplies Monoid.Comonoid] @k
String
"Comonoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[Supplies Comonoid] k
-> Witnesses '[Monoidal, Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies Comonoid) k
forall k. Witness (Supplies Comonoid) k
ComonoidSupplyW Witness (Supplies Comonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, M.SymMonoidal, Monoid.Supplies Monoid.CommutativeMonoid] @k
String
"Commutative monoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[SymMonoidal, Supplies CommutativeMonoid] k
-> Witnesses '[Monoidal, SymMonoidal, Supplies CommutativeMonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[Supplies CommutativeMonoid] k
-> Witnesses '[SymMonoidal, Supplies CommutativeMonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies CommutativeMonoid) k
forall k. Witness (Supplies CommutativeMonoid) k
CommutativeMonoidSupplyW Witness (Supplies CommutativeMonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies CommutativeMonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @'[M.Monoidal, M.SymMonoidal, Monoid.Supplies Monoid.CocommutativeComonoid] @k
String
"Cocommutative comonoids"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[SymMonoidal, Supplies CocommutativeComonoid] k
-> Witnesses
'[Monoidal, SymMonoidal, Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[Supplies CocommutativeComonoid] k
-> Witnesses '[SymMonoidal, Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies CocommutativeComonoid) k
forall k. Witness (Supplies CocommutativeComonoid) k
CocommutativeComonoidSupplyW Witness (Supplies CocommutativeComonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies CocommutativeComonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
, forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
String -> Witnesses cs k -> TestTree
testLaws @Hypergraph.FrobeniusStructures @k
String
"Frobenius"
(Witness Monoidal k
monoidal Witness Monoidal k
-> Witnesses '[SymMonoidal, Supplies Monoid, Supplies Comonoid] k
-> Witnesses FrobeniusStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[Supplies Monoid, Supplies Comonoid] k
-> Witnesses '[SymMonoidal, Supplies Monoid, Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies Monoid) k
forall k. Witness (Supplies Monoid) k
MonoidSupplyW Witness (Supplies Monoid) k
-> Witnesses '[Supplies Comonoid] k
-> Witnesses '[Supplies Monoid, Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness (Supplies Comonoid) k
forall k. Witness (Supplies Comonoid) k
ComonoidSupplyW Witness (Supplies Comonoid) k
-> Witnesses '[] k -> Witnesses '[Supplies Comonoid] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
]
where
monoidal :: Witness Monoidal k
monoidal = WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r)
testHypergraph_
:: forall k
. ( Testable k
, M.SymMonoidal k
, TestObIsOb k
, Monoid.Supplies Monoid.CommutativeMonoid k
, Monoid.Supplies Monoid.CocommutativeComonoid k
)
=> TestTree
testHypergraph_ :: forall k.
(Testable k, SymMonoidal k, TestObIsOb k,
Supplies CommutativeMonoid k, Supplies CocommutativeComonoid k) =>
TestTree
testHypergraph_ = forall k.
(Testable k, SymMonoidal k, Supplies CommutativeMonoid k,
Supplies CocommutativeComonoid k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testHypergraph @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testTraced
:: forall k. (Testable k, Strength.TracedMonoidal k, TestOb (M.Unit @k)) => WithTestOb2 k -> TestTree
testTraced :: forall k.
(Testable k, TracedMonoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testTraced WithTestOb2 k
withTestOb2 =
forall (cs :: [Type -> Constraint]) k.
(Laws cs, Testable k, All cs (TESTED cs k)) =>
Property (Some k) -> String -> Witnesses cs k -> TestTree
testLawsWith @Strength.TracedStructures
(forall k. Testable k => Property (Some k)
genObSmall @k)
String
"Traced"
(WithTestOb2 k -> Witness Monoidal k
forall k. WithTestOb2 k -> Witness Monoidal k
MonoidalW (\ @a @b TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @a @b r
TestOb (a ** b) => r
r) Witness Monoidal k
-> Witnesses '[SymMonoidal, TracedMonoidal] k
-> Witnesses TracedStructures k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness SymMonoidal k
forall k. Witness SymMonoidal k
SymMonoidalW Witness SymMonoidal k
-> Witnesses '[TracedMonoidal] k
-> Witnesses '[SymMonoidal, TracedMonoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witness TracedMonoidal k
forall k. Witness TracedMonoidal k
TracedW Witness TracedMonoidal k
-> Witnesses '[] k -> Witnesses '[TracedMonoidal] k
forall (c :: Type -> Constraint) k (cs1 :: [Type -> Constraint]).
Witness c k -> Witnesses cs1 k -> Witnesses (c : cs1) k
:& Witnesses '[] k
forall k. Witnesses '[] k
WNil)
testTraced_ :: forall k. (Testable k, Strength.TracedMonoidal k, TestObIsOb k) => TestTree
testTraced_ :: forall k. (Testable k, TracedMonoidal k, TestObIsOb k) => TestTree
testTraced_ = forall k.
(Testable k, TracedMonoidal k, TestOb Unit) =>
WithTestOb2 k -> TestTree
testTraced @k (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
propMonoid
:: forall {k} m
. (Testable k, Monoid.Monoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> Property ()
propMonoid :: forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propMonoid WithTestOb2 k
withTestOb2 =
WithTestOb2 k
withTestOb2 @M.Unit @m ((TestOb (Unit ** m) => Property ()) -> Property ())
-> (TestOb (Unit ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$
WithTestOb2 k
withTestOb2 @m @M.Unit ((TestOb (m ** Unit) => Property ()) -> Property ())
-> (TestOb (m ** Unit) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ do
String
-> String
-> ((Unit ** m) ~> m)
-> String
-> ((Unit ** m) ~> m)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"left identity"
String
"μ . (η ⊗ 1)"
((m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend ((m ** m) ~> m) -> ((Unit ** m) ~> (m ** m)) -> (Unit ** m) ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (forall (m :: k). Monoid m => Unit ~> m
forall {k} (m :: k). Monoid m => Unit ~> m
Monoid.mempty @m (Unit ~> m) -> (m ~> m) -> (Unit ** m) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m))
String
"λ"
(forall k (a :: k). (Monoidal k, Ob a) => (Unit ** a) ~> a
M.leftUnitor @k @m)
String
-> String
-> ((m ** Unit) ~> m)
-> String
-> ((m ** Unit) ~> m)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"right identity"
String
"μ . (1 ⊗ η)"
((m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend ((m ** m) ~> m) -> ((m ** Unit) ~> (m ** m)) -> (m ** Unit) ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m (m ~> m) -> (Unit ~> m) -> (m ** Unit) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (m :: k). Monoid m => Unit ~> m
forall {k} (m :: k). Monoid m => Unit ~> m
Monoid.mempty @m))
String
"ρ"
(forall k (a :: k). (Monoidal k, Ob a) => (a ** Unit) ~> a
M.rightUnitor @k @m)
WithTestOb2 k
withTestOb2 @m @m ((TestOb (m ** m) => Property ()) -> Property ())
-> (TestOb (m ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ WithTestOb2 k
withTestOb2 @(m M.** m) @m ((TestOb ((m ** m) ** m) => Property ()) -> Property ())
-> (TestOb ((m ** m) ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ do
String
-> String
-> (((m ** m) ** m) ~> m)
-> String
-> (((m ** m) ** m) ~> m)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"associativity"
String
"μ . (μ ⊗ 1)"
(forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m ((m ** m) ~> m)
-> (((m ** m) ** m) ~> (m ** m)) -> ((m ** m) ** m) ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m ((m ** m) ~> m) -> (m ~> m) -> ((m ** m) ** m) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m))
String
"μ . (1 ⊗ μ) . α"
((m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend ((m ** m) ~> m)
-> (((m ** m) ** m) ~> (m ** m)) -> ((m ** m) ** m) ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m (m ~> m) -> ((m ** m) ~> m) -> (m ** (m ** m)) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m) ((m ** (m ** m)) ~> (m ** m))
-> (((m ** m) ** m) ~> (m ** (m ** m)))
-> ((m ** m) ** m) ~> (m ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. forall k (a :: k) (b :: k) (c :: k).
(Monoidal k, Ob a, Ob b, Ob c) =>
((a ** b) ** c) ~> (a ** (b ** c))
M.associator @k @m @m @m)
propCommutativeMonoid
:: forall {k} m
. (Testable k, Monoid.CommutativeMonoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> Property ()
propCommutativeMonoid :: forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCommutativeMonoid WithTestOb2 k
withTestOb2 = do
forall (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propMonoid @m (\ @x @y TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @x @y r
TestOb (a ** b) => r
r)
WithTestOb2 k
withTestOb2 @m @m ((TestOb (m ** m) => Property ()) -> Property ())
-> (TestOb (m ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$
String
-> String
-> ((m ** m) ~> m)
-> String
-> ((m ** m) ~> m)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"commutativity"
String
"mappend . swap"
(forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m ((m ** m) ~> m) -> ((m ** m) ~> (m ** m)) -> (m ** m) ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. forall k (a :: k) (b :: k).
(SymMonoidal k, Ob a, Ob b) =>
(a ** b) ~> (b ** a)
M.swap @k @m @m)
String
"mappend"
(forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m)
propCocommutativeComonoid
:: forall {k} m
. (Testable k, Monoid.CocommutativeComonoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> Property ()
propCocommutativeComonoid :: forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCocommutativeComonoid WithTestOb2 k
withTestOb2 = do
forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall (m :: OPPOSITE k).
(Testable (OPPOSITE k), CommutativeMonoid m, TestOb m,
TestOb Unit) =>
WithTestOb2 (OPPOSITE k) -> Property ()
propCommutativeMonoid @(OP m) (\ @(OP x) @(OP y) TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @x @y r
TestOb (UN OP a ** UN OP b) => r
TestOb (a ** b) => r
r)
propFrobenius
:: forall {k} m
. ( Testable k
, M.SymMonoidal k
, Monoid.CommutativeMonoid (m :: k)
, Monoid.CocommutativeComonoid m
, TestOb m
, TestOb (M.Unit @k)
)
=> WithTestOb2 k
-> Property ()
propFrobenius :: forall {k} (m :: k).
(Testable k, SymMonoidal k, CommutativeMonoid m,
CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propFrobenius WithTestOb2 k
withTestOb2 = do
forall (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCommutativeMonoid @m (\ @x @y TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @x @y r
TestOb (a ** b) => r
r)
forall (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCocommutativeComonoid @m (\ @x @y TestOb (a ** b) => r
r -> WithTestOb2 k
withTestOb2 @x @y r
TestOb (a ** b) => r
r)
WithTestOb2 k
withTestOb2 @m @m ((TestOb (m ** m) => Property ()) -> Property ())
-> (TestOb (m ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$
WithTestOb2 k
withTestOb2 @(m M.** m) @m ((TestOb ((m ** m) ** m) => Property ()) -> Property ())
-> (TestOb ((m ** m) ** m) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$ do
let mu :: (m ** m) ~> m
mu = forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
Monoid.mappend @m
delta :: m ~> (m ** m)
delta = forall (c :: k). Comonoid c => c ~> (c ** c)
forall {k} (c :: k). Comonoid c => c ~> (c ** c)
Monoid.comult @m
String -> String -> (m ~> m) -> String -> (m ~> m) -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"speciality"
String
"mappend . comult"
((m ** m) ~> m
mu ((m ** m) ~> m) -> (m ~> (m ** m)) -> m ~> m
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. m ~> (m ** m)
delta)
String
"id"
(forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m)
String
-> String
-> ((m ** m) ~> (m ** m))
-> String
-> ((m ** m) ~> (m ** m))
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"Frobenius condition (left)"
String
"(mappend ** id) . associatorInv . (id ** comult)"
(((m ** m) ~> m
mu ((m ** m) ~> m) -> (m ~> m) -> ((m ** m) ** m) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m) (((m ** m) ** m) ~> (m ** m))
-> ((m ** m) ~> ((m ** m) ** m)) -> (m ** m) ~> (m ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. forall k (a :: k) (b :: k) (c :: k).
(Monoidal k, Ob a, Ob b, Ob c) =>
(a ** (b ** c)) ~> ((a ** b) ** c)
M.associatorInv @k @m @m @m ((m ** (m ** m)) ~> ((m ** m) ** m))
-> ((m ** m) ~> (m ** (m ** m))) -> (m ** m) ~> ((m ** m) ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m (m ~> m) -> (m ~> (m ** m)) -> (m ** m) ~> (m ** (m ** m))
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** m ~> (m ** m)
delta))
String
"comult . mappend"
(m ~> (m ** m)
delta (m ~> (m ** m)) -> ((m ** m) ~> m) -> (m ** m) ~> (m ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (m ** m) ~> m
mu)
String
-> String
-> ((m ** m) ~> (m ** m))
-> String
-> ((m ** m) ~> (m ** m))
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"Frobenius condition (right)"
String
"(id ** mappend) . associator . (comult ** id)"
((forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m (m ~> m) -> ((m ** m) ~> m) -> (m ** (m ** m)) ~> (m ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** (m ** m) ~> m
mu) ((m ** (m ** m)) ~> (m ** m))
-> ((m ** m) ~> (m ** (m ** m))) -> (m ** m) ~> (m ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. forall k (a :: k) (b :: k) (c :: k).
(Monoidal k, Ob a, Ob b, Ob c) =>
((a ** b) ** c) ~> (a ** (b ** c))
M.associator @k @m @m @m (((m ** m) ** m) ~> (m ** (m ** m)))
-> ((m ** m) ~> ((m ** m) ** m)) -> (m ** m) ~> (m ** (m ** m))
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (m ~> (m ** m)
delta (m ~> (m ** m)) -> (m ~> m) -> (m ** m) ~> ((m ** m) ** m)
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
(y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
M.** forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m))
String
"comult . mappend"
(m ~> (m ** m)
delta (m ~> (m ** m)) -> ((m ** m) ~> m) -> (m ** m) ~> (m ** m)
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (m ** m) ~> m
mu)
testMonoid
:: forall {k} m
. (Testable k, Monoid.Monoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> TestTree
testMonoid :: forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonoid WithTestOb2 k
f = String -> Property () -> TestTree
testProperty (String
"Monoid " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall k (a :: k). (Testable k, TestOb a) => String
showOb @k @m) (forall (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propMonoid @m \ @a @b -> WithTestOb2 k
f @a @b)
testMonoid_ :: forall {k} m. (Testable k, Monoid.Monoid (m :: k), TestObIsOb k) => TestTree
testMonoid_ :: forall {k} (m :: k).
(Testable k, Monoid m, TestObIsOb k) =>
TestTree
testMonoid_ = forall (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testMonoid @m (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testComonoid
:: forall {k} m
. (Testable k, Monoid.Comonoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> TestTree
testComonoid :: forall {k} (m :: k).
(Testable k, Comonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testComonoid WithTestOb2 k
f = String -> Property () -> TestTree
testProperty (String
"Comonoid " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall k (a :: k). (Testable k, TestOb a) => String
showOb @k @m) (forall {k} (m :: k).
(Testable k, Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall (m :: OPPOSITE k).
(Testable (OPPOSITE k), Monoid m, TestOb m, TestOb Unit) =>
WithTestOb2 (OPPOSITE k) -> Property ()
propMonoid @(OP m) \ @(OP a) @(OP b) TestOb (a ** b) => r
r -> WithTestOb2 k
f @a @b r
TestOb (UN OP a ** UN OP b) => r
TestOb (a ** b) => r
r)
testComonoid_ :: forall {k} m. (Testable k, Monoid.Comonoid (m :: k), TestObIsOb k) => TestTree
testComonoid_ :: forall {k} (m :: k).
(Testable k, Comonoid m, TestObIsOb k) =>
TestTree
testComonoid_ = forall (m :: k).
(Testable k, Comonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall {k} (m :: k).
(Testable k, Comonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testComonoid @m (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testCommutativeMonoid
:: forall {k} m
. (Testable k, Monoid.CommutativeMonoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> TestTree
testCommutativeMonoid :: forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCommutativeMonoid WithTestOb2 k
f = String -> Property () -> TestTree
testProperty (String
"CommutativeMonoid " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall k (a :: k). (Testable k, TestOb a) => String
showOb @k @m) (forall (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCommutativeMonoid @m \ @a @b -> WithTestOb2 k
f @a @b)
testCommutativeMonoid_ :: forall {k} m. (Testable k, Monoid.CommutativeMonoid (m :: k), TestObIsOb k) => TestTree
testCommutativeMonoid_ :: forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestObIsOb k) =>
TestTree
testCommutativeMonoid_ = forall (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall {k} (m :: k).
(Testable k, CommutativeMonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCommutativeMonoid @m (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testCocommutativeComonoid
:: forall {k} m
. (Testable k, Monoid.CocommutativeComonoid (m :: k), TestOb m, TestOb (M.Unit @k))
=> WithTestOb2 k
-> TestTree
testCocommutativeComonoid :: forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCocommutativeComonoid WithTestOb2 k
f = String -> Property () -> TestTree
testProperty (String
"CocommutativeComonoid " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall k (a :: k). (Testable k, TestOb a) => String
showOb @k @m) (forall (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propCocommutativeComonoid @m \ @a @b -> WithTestOb2 k
f @a @b)
testCocommutativeComonoid_
:: forall {k} m
. (Testable k, Monoid.CocommutativeComonoid (m :: k), TestObIsOb k)
=> TestTree
testCocommutativeComonoid_ :: forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestObIsOb k) =>
TestTree
testCocommutativeComonoid_ = forall (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall {k} (m :: k).
(Testable k, CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testCocommutativeComonoid @m (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testFrobenius
:: forall {k} (m :: k)
. ( Testable k
, Monoid.CommutativeMonoid m
, Monoid.CocommutativeComonoid m
, TestOb m
, TestOb (M.Unit @k)
)
=> WithTestOb2 k
-> TestTree
testFrobenius :: forall {k} (m :: k).
(Testable k, CommutativeMonoid m, CocommutativeComonoid m,
TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testFrobenius WithTestOb2 k
f = String -> Property () -> TestTree
testProperty (String
"Frobenius " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall k (a :: k). (Testable k, TestOb a) => String
showOb @k @m) (forall (m :: k).
(Testable k, SymMonoidal k, CommutativeMonoid m,
CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
forall {k} (m :: k).
(Testable k, SymMonoidal k, CommutativeMonoid m,
CocommutativeComonoid m, TestOb m, TestOb Unit) =>
WithTestOb2 k -> Property ()
propFrobenius @m \ @a @b -> WithTestOb2 k
f @a @b)
testFrobenius_
:: forall {k} (m :: k)
. ( Testable k
, Monoid.CommutativeMonoid m
, Monoid.CocommutativeComonoid m
, TestObIsOb k
)
=> TestTree
testFrobenius_ :: forall {k} (m :: k).
(Testable k, CommutativeMonoid m, CocommutativeComonoid m,
TestObIsOb k) =>
TestTree
testFrobenius_ = forall (m :: k).
(Testable k, CommutativeMonoid m, CocommutativeComonoid m,
TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
forall {k} (m :: k).
(Testable k, CommutativeMonoid m, CocommutativeComonoid m,
TestOb m, TestOb Unit) =>
WithTestOb2 k -> TestTree
testFrobenius @m (\ @a @b -> WithTestOb2 k
forall {k}. (TestObIsOb k, Monoidal k) => WithTestOb2 k
withTestOb2Def @a @b)
testSubobjectClassifier
:: forall k
. ( Testable k
, Topos.HasSubobjectClassifier k
, Topos.HasEpiMonoFactorization k
, Pushout.HasPushouts k
, Pullback.HasPullbacks k
, TestOb (Topos.Omega :: k)
)
=> WithTestObProd k
-> TestTree
testSubobjectClassifier :: forall k.
(Testable k, HasSubobjectClassifier k, HasEpiMonoFactorization k,
HasPushouts k, HasPullbacks k, TestOb Omega) =>
WithTestObProd k -> TestTree
testSubobjectClassifier WithTestObProd k
withTestObProd = String -> Property () -> TestTree
testProperty String
"Subobject classifier" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ do
Some @a <- forall k. Testable k => Property (Some k)
genOb @k
Some @b <- genOb @k
Some @z <- genOb @k
f <- genNamed @(a ~> b) "f"
x@Objs <- genNamed @(z ~> a) "x"
y <- genNamed @(z ~> b) "y"
inGraph <- eqP (f . x) y
classified <-
eqP (Topos.classifyGraph f . (x BinaryProduct.&&& y)) (Terminal.const Topos.true)
expect "classifyGraph is true exactly on the graph of f" inGraph classified
g <- genNamed @(a ~> b) "g"
withTestObProd @a @b @(Property ()) do
eqChi <- eqP (Topos.classifyGraph f) (Topos.classifyGraph g)
propReflectsEq "classifier injective" "classifyGraph f == classifyGraph g" eqChi f g
x' <- genNamed @(z ~> a) "x'"
identified <- eqP (f . x) (f . x')
kernelPair <-
eqP (Topos.classifyKernelPair f . (x BinaryProduct.&&& x')) (Terminal.const Topos.true)
expect "classifyKernelPair is true exactly when f identifies the pair" identified kernelPair
let chi = (x ~> x) -> x ~> Omega
forall {k} (a :: k) (b :: k).
(HasSubobjectClassifier k, HasPushouts k) =>
(a ~> b) -> b ~> Omega
Topos.classifyImage x ~> x
f
onImage <- eqP (chi . (f . x)) (Terminal.const Topos.true)
expect "classifyImage f is true on the image of f" True onImage
case Topos.factorize f of
(:.:) Hom k x b
_ m :: Hom k b x
m@Hom k b x
Objs -> do
w <- forall a. TestableType a => String -> Property a
genNamed @(z ~> b) String
"w"
classifiedTrue <- eqP (chi . w) (Terminal.const Topos.true)
when classifiedTrue $
testEq
"image factorization"
"m . factorPullback m terminate w terminate"
(m . Pullback.factorPullback m Terminal.terminate w Terminal.terminate)
"w"
w
testSubobjectClassifier_
:: forall k
. ( Testable k
, Topos.HasSubobjectClassifier k
, Topos.HasEpiMonoFactorization k
, Pushout.HasPushouts k
, Pullback.HasPullbacks k
, TestObIsOb k
, TestOb (Topos.Omega :: k)
)
=> TestTree
testSubobjectClassifier_ :: forall k.
(Testable k, HasSubobjectClassifier k, HasEpiMonoFactorization k,
HasPushouts k, HasPullbacks k, TestObIsOb k, TestOb Omega) =>
TestTree
testSubobjectClassifier_ =
forall k.
(Testable k, HasSubobjectClassifier k, HasEpiMonoFactorization k,
HasPushouts k, HasPullbacks k, TestOb Omega) =>
WithTestObProd k -> TestTree
testSubobjectClassifier @k (\ @a @b -> WithTestObProd k
forall {k}. (TestObIsOb k, HasBinaryProducts k) => WithTestObProd k
withTestObProdDef @a @b)
testNegation :: forall k. (Testable k, Topos.ElementaryTopos k, TestOb (Topos.Omega :: k)) => TestTree
testNegation :: forall k. (Testable k, ElementaryTopos k, TestOb Omega) => TestTree
testNegation =
String -> Property () -> TestTree
testProperty String
"negation is implication into false" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
String
-> String
-> (Omega ~> Omega)
-> String
-> (Omega ~> Omega)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"not"
String
"not"
(forall k. ElementaryTopos k => Omega ~> Omega
Topos.not @k)
String
"implies . (id &&& const false)"
((Omega && Omega) ~> Omega
forall k. ElementaryTopos k => (Omega && Omega) ~> Omega
Topos.implies ((Omega && Omega) ~> Omega)
-> (Omega ~> (Omega && Omega)) -> Omega ~> Omega
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (Omega ~> Omega
forall (a :: k). Ob a => a ~> a
forall {k} (p :: CAT k) (a :: k). (Promonad p, Ob a) => p a a
id (Omega ~> Omega) -> (Omega ~> Omega) -> Omega ~> (Omega && Omega)
forall (a :: k) (x :: k) (y :: k).
(a ~> x) -> (a ~> y) -> a ~> (x && y)
forall k (a :: k) (x :: k) (y :: k).
HasBinaryProducts k =>
(a ~> x) -> (a ~> y) -> a ~> (x && y)
BinaryProduct.&&& El Omega -> Omega ~> Omega
forall {k} (a :: k) (b :: k).
(HasTerminalObject k, Ob a) =>
El b -> a ~> b
Terminal.const El Omega
forall k. ElementaryTopos k => TerminalObject ~> Omega
Topos.false))
testLawvereTierney
:: forall k
. (Testable k, Topos.ElementaryTopos k, TestOb (Topos.Omega :: k), TestOb (Terminal.TerminalObject :: k))
=> WithTestObProd k
-> (Topos.Omega :: k) ~> Topos.Omega
-> TestTree
testLawvereTierney :: forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
WithTestObProd k -> (Omega ~> Omega) -> TestTree
testLawvereTierney WithTestObProd k
withTestObProd Omega ~> Omega
j =
String -> [TestTree] -> TestTree
testGroup
String
"Lawvere-Tierney topology"
[String -> Property () -> TestTree
testProperty String
name ((Omega ~> Omega) -> Property ()
law Omega ~> Omega
j) | (String
name, (Omega ~> Omega) -> Property ()
law) <- forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
WithTestObProd k -> [(String, (Omega ~> Omega) -> Property ())]
lawvereTierneyLaws @k (\ @a @b TestOb (a && b) => r
r -> WithTestObProd k
withTestObProd @a @b r
TestOb (a && b) => r
r)]
lawvereTierneyLaws
:: forall k
. (Testable k, Topos.ElementaryTopos k, TestOb (Topos.Omega :: k), TestOb (Terminal.TerminalObject :: k))
=> WithTestObProd k
-> [(String, (Topos.Omega :: k) ~> Topos.Omega -> Property ())]
lawvereTierneyLaws :: forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
WithTestObProd k -> [(String, (Omega ~> Omega) -> Property ())]
lawvereTierneyLaws WithTestObProd k
withTestObProd =
[ (String
"fixes true", \Omega ~> Omega
j -> String
-> String
-> (TerminalObject ~> Omega)
-> String
-> (TerminalObject ~> Omega)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"true" String
"j . true" (Omega ~> Omega
j (Omega ~> Omega)
-> (TerminalObject ~> Omega) -> TerminalObject ~> Omega
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. TerminalObject ~> Omega
forall k. HasSubobjectClassifier k => TerminalObject ~> Omega
Topos.true) String
"true" TerminalObject ~> Omega
forall k. HasSubobjectClassifier k => TerminalObject ~> Omega
Topos.true)
, (String
"idempotent", \Omega ~> Omega
j -> String
-> String
-> (Omega ~> Omega)
-> String
-> (Omega ~> Omega)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"idempotent" String
"j . j" (Omega ~> Omega
j (Omega ~> Omega) -> (Omega ~> Omega) -> Omega ~> Omega
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. Omega ~> Omega
j) String
"j" Omega ~> Omega
j)
,
( String
"preserves meets"
, \Omega ~> Omega
j ->
WithTestObProd k
withTestObProd @Topos.Omega @Topos.Omega @(Property ()) ((TestOb (Omega && Omega) => Property ()) -> Property ())
-> (TestOb (Omega && Omega) => Property ()) -> Property ()
forall a b. (a -> b) -> a -> b
$
String
-> String
-> ((Omega && Omega) ~> Omega)
-> String
-> ((Omega && Omega) ~> Omega)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq String
"meets" String
"j . and" (Omega ~> Omega
j (Omega ~> Omega)
-> ((Omega && Omega) ~> Omega) -> (Omega && Omega) ~> Omega
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (Omega && Omega) ~> Omega
forall k. ElementaryTopos k => (Omega && Omega) ~> Omega
Topos.and) String
"and . (j *** j)" ((Omega && Omega) ~> Omega
forall k. ElementaryTopos k => (Omega && Omega) ~> Omega
Topos.and ((Omega && Omega) ~> Omega)
-> ((Omega && Omega) ~> (Omega && Omega))
-> (Omega && Omega) ~> Omega
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (Omega ~> Omega
j (Omega ~> Omega)
-> (Omega ~> Omega) -> (Omega && Omega) ~> (Omega && Omega)
forall (a :: k) (b :: k) (x :: k) (y :: k).
(a ~> x) -> (b ~> y) -> (a && b) ~> (x && y)
forall k (a :: k) (b :: k) (x :: k) (y :: k).
HasBinaryProducts k =>
(a ~> x) -> (b ~> y) -> (a && b) ~> (x && y)
BinaryProduct.*** Omega ~> Omega
j))
)
]
testLawvereTierneyFamily
:: forall k
. (Testable k, Topos.ElementaryTopos k, TestOb (Topos.Omega :: k), TestOb (Terminal.TerminalObject :: k))
=> String
-> WithTestObProd k
-> ((Terminal.TerminalObject :: k) ~> Topos.Omega -> (Topos.Omega :: k) ~> Topos.Omega)
-> TestTree
testLawvereTierneyFamily :: forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
String
-> WithTestObProd k
-> ((TerminalObject ~> Omega) -> Omega ~> Omega)
-> TestTree
testLawvereTierneyFamily String
name WithTestObProd k
withTestObProd (TerminalObject ~> Omega) -> Omega ~> Omega
family =
String -> [TestTree] -> TestTree
testGroup
String
name
[ String -> Property () -> TestTree
testProperty String
lawName (String -> Property (TerminalObject ~> Omega)
forall a. TestableType a => String -> Property a
genNamed String
"u" Property (TerminalObject ~> Omega)
-> ((TerminalObject ~> Omega) -> Property ()) -> Property ()
forall a b.
Property' String a
-> (a -> Property' String b) -> Property' String b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Omega ~> Omega) -> Property ()
law ((Omega ~> Omega) -> Property ())
-> ((TerminalObject ~> Omega) -> Omega ~> Omega)
-> (TerminalObject ~> Omega)
-> Property ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (TerminalObject ~> Omega) -> Omega ~> Omega
family)
| (String
lawName, (Omega ~> Omega) -> Property ()
law) <- forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
WithTestObProd k -> [(String, (Omega ~> Omega) -> Property ())]
lawvereTierneyLaws @k (\ @a @b TestOb (a && b) => r
r -> WithTestObProd k
withTestObProd @a @b r
TestOb (a && b) => r
r)
]
testLawvereTierney_
:: forall k
. ( Testable k
, Topos.ElementaryTopos k
, TestObIsOb k
, TestOb (Topos.Omega :: k)
, TestOb (Terminal.TerminalObject :: k)
)
=> (Topos.Omega :: k) ~> Topos.Omega
-> TestTree
testLawvereTierney_ :: forall k.
(Testable k, ElementaryTopos k, TestObIsOb k, TestOb Omega,
TestOb TerminalObject) =>
(Omega ~> Omega) -> TestTree
testLawvereTierney_ =
forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
WithTestObProd k -> (Omega ~> Omega) -> TestTree
testLawvereTierney @k (\ @a @b -> WithTestObProd k
forall {k}. (TestObIsOb k, HasBinaryProducts k) => WithTestObProd k
withTestObProdDef @a @b)
testLawvereTierneyFamily_
:: forall k
. ( Testable k
, Topos.ElementaryTopos k
, TestObIsOb k
, TestOb (Topos.Omega :: k)
, TestOb (Terminal.TerminalObject :: k)
)
=> String
-> ((Terminal.TerminalObject :: k) ~> Topos.Omega -> (Topos.Omega :: k) ~> Topos.Omega)
-> TestTree
testLawvereTierneyFamily_ :: forall k.
(Testable k, ElementaryTopos k, TestObIsOb k, TestOb Omega,
TestOb TerminalObject) =>
String -> ((TerminalObject ~> Omega) -> Omega ~> Omega) -> TestTree
testLawvereTierneyFamily_ String
name =
forall k.
(Testable k, ElementaryTopos k, TestOb Omega,
TestOb TerminalObject) =>
String
-> WithTestObProd k
-> ((TerminalObject ~> Omega) -> Omega ~> Omega)
-> TestTree
testLawvereTierneyFamily @k String
name (\ @a @b -> WithTestObProd k
forall {k}. (TestObIsOb k, HasBinaryProducts k) => WithTestObProd k
withTestObProdDef @a @b)
testSiteLaws
:: forall t j k
. (Sheaf.StableSite t k, Sheaf.HasFiniteCovers t k, Finitary.FiniteCat j, Finitary.FiniteCat k)
=> TestTree
testSiteLaws :: forall t j k.
(StableSite t k, HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
TestTree
testSiteLaws =
String -> [TestTree] -> TestTree
testGroup
String
"site laws"
[forall t k.
(StableSite t k, HasFiniteCovers t k, FiniteCat k) =>
TestTree
testStableSite @t @k, forall t j k.
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
TestTree
testGeneratedSieveIsSieve @t @j @k, forall t j k.
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
TestTree
testDenseIsCovering @t @j @k]
testStableSite
:: forall t k. (Sheaf.StableSite t k, Sheaf.HasFiniteCovers t k, Finitary.FiniteCat k) => TestTree
testStableSite :: forall t k.
(StableSite t k, HasFiniteCovers t k, FiniteCat k) =>
TestTree
testStableSite =
String -> Property () -> TestTree
testProperty String
"covers pull back" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @b ->
[ case Cover t k a c -> (a ~> a) -> PulledBack t k a c a
forall (b :: k) (a :: k) c.
Ob b =>
Cover t k a c -> (b ~> a) -> PulledBack t k a c b
forall t k (b :: k) (a :: k) c.
(StableSite t k, Ob b) =>
Cover t k a c -> (b ~> a) -> PulledBack t k a c b
Sheaf.pullbackCover Cover t k a c
c a ~> a
f of
Sheaf.AlreadyFactors Factors t k a c a
fs -> forall t {k} (a :: k) c (x :: k).
(Site t k, FiniteCat k, Ob a) =>
(x ~> a) -> Factors t k a c x -> Property ()
propFactorsThroughLeg @t a ~> a
f Factors t k a c a
fs
Sheaf.PulledBack Cover t k a c'
c' forall (x :: k). Leg t k a c' x -> Factors t k a c x
fs -> do
String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
(String
"the pulled-back cover of object " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @b) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" covers it")
Bool
True
(forall t {j} {k} (a :: k) (b :: j).
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
Sieve a b -> Bool
FinSheaf.isCovering @t (forall t {j} {k} (a :: k) (b :: j) c.
(Site t k, LocallyFinite k, CategoryOf j, Ob a, Ob b) =>
Cover t k a c -> Sieve a b
FinSheaf.generatedSieve @t @b @'() Cover t k a c'
c'))
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_ [forall t {k} (a :: k) c (x :: k).
(Site t k, FiniteCat k, Ob a) =>
(x ~> a) -> Factors t k a c x -> Property ()
propFactorsThroughLeg @t (a ~> a
f (a ~> a) -> (x ~> a) -> x ~> a
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. Leg t k a c' x -> x ~> a
forall (a :: k) c (x :: k). Leg t k a c x -> x ~> a
forall t k (a :: k) c (x :: k). Site t k => Leg t k a c x -> x ~> a
Sheaf.legArrow Leg t k a c' x
l) (Leg t k a c' x -> Factors t k a c x
forall (x :: k). Leg t k a c' x -> Factors t k a c x
fs Leg t k a c' x
l) | Sheaf.SomeLeg Leg t k a c' x
l <- Cover t k a c' -> [SomeLeg t k a c']
forall (a :: k) c. Cover t k a c -> [SomeLeg t k a c]
forall t k (a :: k) c.
Site t k =>
Cover t k a c -> [SomeLeg t k a c]
Sheaf.legs Cover t k a c'
c']
| Sheaf.SomeCover Cover t k a c
c <- forall t k (a :: k).
(HasFiniteCovers t k, Ob a) =>
[SomeCover t k a]
Sheaf.covers @t @k @a
, a ~> a
f <- forall {j} {k} (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]
Finitary.elements @(Hom k) @b @a
]
)
propFactorsThroughLeg
:: forall t {k} (a :: k) c x
. (Sheaf.Site t k, Finitary.FiniteCat k, Ob a)
=> x ~> a
-> Sheaf.Factors t k a c x
-> Property ()
propFactorsThroughLeg :: forall t {k} (a :: k) c (x :: k).
(Site t k, FiniteCat k, Ob a) =>
(x ~> a) -> Factors t k a c x -> Property ()
propFactorsThroughLeg x ~> a
f (Sheaf.Factors Leg t k a c y
l x ~> y
u) =
x ~> y
u (x ~> y) -> ((Ob x, Ob y) => Property ()) -> Property ()
forall {k1} {k2} (p :: k1 +-> k2) (a :: k2) (b :: k1) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
//
String -> Natural -> Natural -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
String
"the arrow factors through the leg the pullback names"
(forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex @(Hom k) @x @a x ~> a
f)
((x ~> a) -> Natural
forall (a :: k) (b :: k). (Ob a, Ob b) => Hom k a b -> Natural
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex (Leg t k a c y -> y ~> a
forall (a :: k) c (x :: k). Leg t k a c x -> x ~> a
forall t k (a :: k) c (x :: k). Site t k => Leg t k a c x -> x ~> a
Sheaf.legArrow Leg t k a c y
l (y ~> a) -> (x ~> y) -> x ~> a
forall (b :: k) (c :: k) (a :: k). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: CAT k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. x ~> y
u))
testGeneratedSieveIsSieve
:: forall t j k. (Sheaf.HasFiniteCovers t k, Finitary.FiniteCat j, Finitary.FiniteCat k) => TestTree
testGeneratedSieveIsSieve :: forall t j k.
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
TestTree
testGeneratedSieveIsSieve =
String -> Property () -> TestTree
testProperty String
"generated sieves are sieves" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @b ->
[ case forall t {j} {k} (a :: k) (b :: j) c.
(Site t k, LocallyFinite k, CategoryOf j, Ob a, Ob b) =>
Cover t k a c -> Sieve a b
FinSheaf.generatedSieve @t @a @b Cover t k a c
c of
Sieve forall (c :: k) (d :: j). (c ~> a) -> (a ~> d) -> Bool
inSieve ->
String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
(String
"the sieve a cover of object " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @a) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" generates")
Bool
True
(forall {j} {k} (p :: j +-> k).
(Finitary p, FiniteCat j, FiniteCat k) =>
(forall (a :: k) (b :: j). (Ob a, Ob b) => p a b -> Bool) -> Bool
forall (p :: j +-> k).
(Finitary p, FiniteCat j, FiniteCat k) =>
(forall (a :: k) (b :: j). (Ob a, Ob b) => p a b -> Bool) -> Bool
FinTopos.closedUnder @(Yo a (OP b)) \(Yo a ~> a
g b1 ~> b
h) -> (a ~> a) -> (a ~> b) -> Bool
forall (c :: k) (d :: j). (c ~> a) -> (a ~> d) -> Bool
inSieve a ~> a
g a ~> b
b1 ~> b
h)
| Sheaf.SomeCover Cover t k a c
c <- forall t k (a :: k).
(HasFiniteCovers t k, Ob a) =>
[SomeCover t k a]
Sheaf.covers @t @k @a
]
)
testAtomicIsDoubleNegation
:: forall k
. ( Pullback.HasPullbacks k
, Finitary.FiniteCat k
, Testable (BinaryProduct.PROD (FinTopos.FINITARY () k))
, TestOb (Topos.Omega :: BinaryProduct.PROD (FinTopos.FINITARY () k))
)
=> TestTree
testAtomicIsDoubleNegation :: forall k.
(HasPullbacks k, FiniteCat k, Testable (PROD (FINITARY () k)),
TestOb Omega) =>
TestTree
testAtomicIsDoubleNegation =
String -> Property () -> TestTree
testProperty String
"double negation is the atomic topology" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
String
-> String
-> (Omega ~> Omega)
-> String
-> (Omega ~> Omega)
-> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"¬¬"
String
"doubleNegation"
(forall k. ElementaryTopos k => Omega ~> Omega
Topos.doubleNegation @(BinaryProduct.PROD (FinTopos.FINITARY () k)))
String
"lawvereTierney @Atomic"
(forall t j k.
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
Omega ~> Omega
FinSheaf.lawvereTierney @Sheaf.Atomic)
testRanFullyFaithful
:: forall {j} {k} (p :: j +-> k). (Finitary.Finitary p, Finitary.FiniteCat j, Finitary.FiniteCat k) => TestTree
testRanFullyFaithful :: forall {j} {k} (p :: j +-> k).
(Finitary p, FiniteCat j, FiniteCat k) =>
TestTree
testRanFullyFaithful =
String -> Property () -> TestTree
testProperty String
"fully faithful into copresheaves" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a' ->
let ix :: Ran (OP p) p a a -> Natural
ix = forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex @(Ran (OP p) p) @a @a'
in [ String -> [Natural] -> [Natural] -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
( String
"each arrow from object "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @a)
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to object "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @a')
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is one transformation"
)
(Natural -> [Natural]
Finitary.indices (forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
forall (p :: k +-> k) (a :: k) (b :: k).
(Finitary p, Ob a, Ob b) =>
Natural
Finitary.size @(Ran (OP p) p) @a @a'))
([Natural] -> [Natural]
forall a. Ord a => [a] -> [a]
sort [Ran (OP p) p a a -> Natural
ix ((forall (x :: j). p a x -> p a x) -> Ran (OP p) p a a
forall {k} {j} {i} (a :: k) (b :: j) (j2 :: i +-> j)
(p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). j2 b x -> p a x) -> Ran (OP j2) p a b
Ran ((a ~> a) -> p a x -> p a x
forall (c :: k) (a :: k) (b :: j). (c ~> a) -> p a b -> p c b
forall {j} {k} (p :: j +-> k) (c :: k) (a :: k) (b :: j).
Profunctor p =>
(c ~> a) -> p a b -> p c b
lmap a ~> a
f)) | a ~> a
f <- forall {j} {k} (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]
Finitary.elements @(Hom k) @a @a'])
]
)
testRiftFullyFaithful
:: forall {j} {k} (p :: j +-> k). (Finitary.Finitary p, Finitary.FiniteCat j, Finitary.FiniteCat k) => TestTree
testRiftFullyFaithful :: forall {j} {k} (p :: j +-> k).
(Finitary p, FiniteCat j, FiniteCat k) =>
TestTree
testRiftFullyFaithful =
String -> Property () -> TestTree
testProperty String
"fully faithful into presheaves" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @b -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @b' ->
let ix :: Rift (OP p) p a a -> Natural
ix = forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
forall (p :: j +-> j) (a :: j) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex @(Rift (OP p) p) @b @b'
in [ String -> [Natural] -> [Natural] -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
( String
"each arrow from object "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: j). (Enumerable j, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @b)
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to object "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: j). (Enumerable j, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @b')
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is one transformation"
)
(Natural -> [Natural]
Finitary.indices (forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
forall (p :: j +-> j) (a :: j) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
Finitary.size @(Rift (OP p) p) @b @b'))
([Natural] -> [Natural]
forall a. Ord a => [a] -> [a]
sort [Rift (OP p) p a a -> Natural
ix ((forall (x :: k). p x a -> p x a) -> Rift (OP p) p a a
forall {k} {j} {i} (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 ((a ~> a) -> p x a -> p x a
forall (b :: j) (d :: j) (a :: k). (b ~> d) -> p a b -> p a d
forall {j} {k} (p :: j +-> k) (b :: j) (d :: j) (a :: k).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap a ~> a
f)) | a ~> a
f <- forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
forall (p :: j +-> j) (a :: j) (b :: j).
(Finitary p, Ob a, Ob b) =>
[p a b]
Finitary.elements @(Hom j) @b @b'])
]
)
testCoveredByImage
:: forall t {j} {k} (w :: j +-> k)
. (Sheaf.HasFiniteCovers t j, Corepresentable w, Finitary.Finitary w, Finitary.FiniteCat j, Finitary.FiniteCat k)
=> TestTree
testCoveredByImage :: forall t {j} {k} (w :: j +-> k).
(HasFiniteCovers t j, Corepresentable w, Finitary w, FiniteCat j,
FiniteCat k) =>
TestTree
testCoveredByImage =
String -> Property () -> TestTree
testProperty String
"every object is covered by the image" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @c ->
[ String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
(String
"object " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: j). (Enumerable j, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @c) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is covered")
Bool
True
(forall t {j} {k} (a :: k) (b :: j).
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
Sieve a b -> Bool
FinSheaf.isCovering @t (forall (a :: j) (b :: ()).
(Ob a, Ob b) =>
(forall (c :: j) (d :: ()). (c ~> a) -> (b ~> d) -> Bool)
-> Sieve a b
forall {k} {j} (a :: k) (b :: j).
(Ob a, Ob b) =>
(forall (c :: k) (d :: j). (c ~> a) -> (b ~> d) -> Bool)
-> Sieve a b
Sieve @c @'() \c ~> a
g '() ~> d
_ -> [Bool] -> Bool
forall (t :: Type -> Type). Foldable t => t Bool -> Bool
or ((c ~> a) -> [Bool]
forall (c :: j) (x :: j). (Ob c, Ob x) => (x ~> c) -> [Bool]
fromImage c ~> a
g) ((Ob c, Ob a) => Bool) -> (c ~> a) -> Bool
forall (a :: j) (b :: j) r. ((Ob a, Ob b) => r) -> (a ~> b) -> r
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
\\ c ~> a
g))
]
)
where
fromImage :: forall (c :: j) x. (Ob c, Ob x) => x ~> c -> [Bool]
fromImage :: forall (c :: j) (x :: j). (Ob c, Ob x) => (x ~> c) -> [Bool]
fromImage x ~> c
g =
forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k \ @e -> [(x ~> c) -> ((w %% a) ~> c) -> Bool
forall {k} (x :: k) (y :: k) (a :: k).
(LocallyFinite k, Ob x, Ob y, Ob a) =>
(x ~> a) -> (y ~> a) -> Bool
Finitary.factorsThrough x ~> c
g (w %% a) ~> c
f ((Ob (w %% a), Ob c) => Bool) -> ((w %% a) ~> c) -> Bool
forall (a :: j) (b :: j) r. ((Ob a, Ob b) => r) -> (a ~> b) -> r
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
\\ (w %% a) ~> c
f | w a c
x <- forall {j} {k} (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]
Finitary.elements @w @e @c, let f :: (w %% a) ~> c
f = w a c -> (w %% a) ~> c
forall (a :: k) (b :: j). w a b -> (w %% a) ~> b
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
Corepresentable p =>
p a b -> (p %% a) ~> b
coindex w a c
x]
testDenseIsCovering
:: forall t j k. (Sheaf.HasFiniteCovers t k, Finitary.FiniteCat j, Finitary.FiniteCat k) => TestTree
testDenseIsCovering :: forall t j k.
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
TestTree
testDenseIsCovering =
String -> Property () -> TestTree
testProperty String
"covering sieves are the dense ones" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @b ->
[ String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
(String
"sieve " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (Sieve a a -> Natural
forall (a :: k) (b :: j). (Ob a, Ob b) => Sieve a b -> Natural
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex Sieve a a
s) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" at object " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @a))
(forall t {j} {k} (a :: k) (b :: j).
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
Sieve a b -> Bool
FinSheaf.isCovering @t Sieve a a
s)
(forall t {j} {k} (a :: k) (b :: j).
(HasFiniteCovers t k, FiniteCat j, FiniteCat k) =>
Sieve a b -> Bool
FinSheaf.isDense @t Sieve a a
s)
| Sieve a a
s <- forall {j} {k} (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]
Finitary.elements @(Sieve :: j +-> k) @a @b
]
)
propGluesBack
:: forall {j} {k} t (p :: j +-> k) (a :: k) (b :: j) c
. (Sheaf.Sheaf t p, Ob a, Ob b, TestingEqShow (p a b))
=> Sheaf.Cover t k a c
-> p a b
-> Property ()
propGluesBack :: forall {j} {k} t (p :: j +-> k) (a :: k) (b :: j) c.
(Sheaf t p, Ob a, Ob b, TestingEqShow (p a b)) =>
Cover t k a c -> p a b -> Property ()
propGluesBack Cover t k a c
c p a b
x =
String -> String -> p a b -> String -> p a b -> Property ()
forall a.
TestingEqShow a =>
String -> String -> a -> String -> a -> Property ()
testEq
String
"uniqueness"
String
"glue c (\\g -> lmap (legArrow g) x)"
(forall {j} {k} t (p :: j +-> k) (a :: k) c (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 (p :: j +-> k) (a :: k) c (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
Sheaf.glue @t Cover t k a c
c \Leg t k a c x
g -> (x ~> a) -> p a b -> p x b
forall (c :: k) (a :: k) (b :: j). (c ~> a) -> p a b -> p c b
forall {j} {k} (p :: j +-> k) (c :: k) (a :: k) (b :: j).
Profunctor p =>
(c ~> a) -> p a b -> p c b
lmap (Leg t k a c x -> x ~> a
forall (a :: k) c (x :: k). Leg t k a c x -> x ~> a
forall t k (a :: k) c (x :: k). Site t k => Leg t k a c x -> x ~> a
Sheaf.legArrow Leg t k a c x
g) p a b
x)
String
"x"
p a b
x
testGluesBack
:: forall {j} {k} t (p :: j +-> k)
. (Sheaf.HasFiniteCovers t k, Sheaf.Sheaf t p, TestableProfunctor p, TestableTypeP p, TestObIsOb k)
=> TestTree
testGluesBack :: forall {j} {k} t (p :: j +-> k).
(HasFiniteCovers t k, Sheaf t p, TestableProfunctor p,
TestableTypeP p, TestObIsOb k) =>
TestTree
testGluesBack = String -> Property () -> TestTree
testProperty String
"glues back" do
Some @a <- forall k. Testable k => (Some k -> Bool) -> Property (Some k)
genObSuchThat @k \(Some @a) -> forall k (a :: k) r. (Testable k, TestOb a) => (Ob a => r) -> r
obFromTestOb @_ @a (Bool -> Bool
not ([SomeCover t k x] -> Bool
forall a. [a] -> Bool
forall (t :: Type -> Type) a. Foldable t => t a -> Bool
null (forall t k (a :: k).
(HasFiniteCovers t k, Ob a) =>
[SomeCover t k a]
Sheaf.covers @t @k @a)))
Some @b <- genOb @j
x <- genNamed @(p a b) "x"
obFromTestOb @_ @a $
obFromTestOb @_ @b $
for_ (Sheaf.covers @t @k @a) \(Sheaf.SomeCover Cover t k x c
c) -> forall {j} {k} t (p :: j +-> k) (a :: k) (b :: j) c.
(Sheaf t p, Ob a, Ob b, TestingEqShow (p a b)) =>
Cover t k a c -> p a b -> Property ()
forall t (p :: j +-> k) (a :: k) (b :: j) c.
(Sheaf t p, Ob a, Ob b, TestingEqShow (p a b)) =>
Cover t k a c -> p a b -> Property ()
propGluesBack @t Cover t k x c
c p x x
x
testGluesBackAt
:: forall {j} {k} t (p :: j +-> k) (a :: k) c
. (Sheaf.Sheaf t p, TestableProfunctor p, TestableTypeP p, TestOb a)
=> String
-> Sheaf.Cover t k a c
-> TestTree
testGluesBackAt :: forall {j} {k} t (p :: j +-> k) (a :: k) c.
(Sheaf t p, TestableProfunctor p, TestableTypeP p, TestOb a) =>
String -> Cover t k a c -> TestTree
testGluesBackAt String
lbl Cover t k a c
c = String -> Property () -> TestTree
testProperty (String
"glues back at " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
lbl) do
Some @b <- forall k. Testable k => Property (Some k)
genOb @j
x <- genNamed @(p a b) "x"
obFromTestOb @_ @a $ obFromTestOb @_ @b $ propGluesBack @t c x
testEqualizersAreSheaves
:: forall t j k
. (Testable (FinSheaf.SHEAVES t j k), Sheaf.HasFiniteCovers t k, Finitary.FiniteCat j, Finitary.FiniteCat k)
=> TestTree
testEqualizersAreSheaves :: forall t j k.
(Testable (SHEAVES t j k), HasFiniteCovers t k, FiniteCat j,
FiniteCat k) =>
TestTree
testEqualizersAreSheaves = String -> Property () -> TestTree
testProperty String
"equalizers are sheaves" do
SomeP @a @b f <- forall {j} {k} (p :: j +-> k).
TestableProfunctor p =>
String -> Property (SomeProfunctorElt p)
forall (p :: SHEAVES t j k +-> SHEAVES t j k).
TestableProfunctor p =>
String -> Property (SomeProfunctorElt p)
genProfunctorElt @(Hom (FinSheaf.SHEAVES t j k)) String
"f"
g <- genNamed @(a ~> b) "g"
Equalizer.equalize f g \(Sub (Prof @e a1 :~> b1
_)) -> String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect String
"isSheaf of the equalizer" Bool
True (forall t {j} {k} (p :: j +-> k).
(HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k) =>
Bool
FinSheaf.isSheaf @t @e)
testSheafification
:: forall t {j} {k} (p :: j +-> k) (q :: j +-> k)
. ( Sheaf.HasFiniteCovers t k
, Sheaf.Sheaf t q
, Finitary.Finitary p
, Finitary.Finitary q
, Finitary.FiniteCat j
, Finitary.FiniteCat k
, Testable j
, Testable k
, TestableProfunctor p
)
=> TestTree
testSheafification :: forall t {j} {k} (p :: j +-> k) (q :: j +-> k).
(HasFiniteCovers t k, Sheaf t q, Finitary p, Finitary q,
FiniteCat j, FiniteCat k, Testable j, Testable k,
TestableProfunctor p) =>
TestTree
testSheafification =
String -> [TestTree] -> TestTree
testGroup
String
"sheafification"
[ String -> Property () -> TestTree
testProperty String
"unit is natural" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(TestableProfunctor p, TestableProfunctor q) =>
(p :~> q) -> Property ()
forall (p :: j +-> k) (q :: j +-> k).
(TestableProfunctor p, TestableProfunctor q) =>
(p :~> q) -> Property ()
propNaturalTransformation @p @(FinSheaf.Plus t p) (forall t {j} {k} (p :: j +-> k). Profunctor p => p :~> Plus t p
FinSheaf.unitPlus @t)
, String -> Property () -> TestTree
testProperty String
"Sheafify p is a sheaf" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$ String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect String
"isSheaf" Bool
True (forall t {j} {k} (p :: j +-> k).
(HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k) =>
Bool
FinSheaf.isSheaf @t @(FinSheaf.Sheafify t p))
, forall t {j} {k} (q :: j +-> k).
(HasFiniteCovers t k, Finitary q, FiniteCat j, FiniteCat k) =>
TestTree
testPlusFixes @t @q
, String -> Property () -> TestTree
testProperty String
"left adjoint to inclusion" do
let maps :: [p ~> q]
maps = forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
[p ~> q]
forall (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
[p ~> q]
FinTopos.natTransformations @p @q
exts :: [[Natural]]
exts = forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
[[Natural]]
forall (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
[[Natural]]
FinTopos.natElements @(FinSheaf.Sheafify t p) @q
String -> Bool -> Bool -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect String
"there are maps to extend" Bool
True (Bool -> Bool
not ([p ~> q] -> Bool
forall a. [a] -> Bool
forall (t :: Type -> Type) a. Foldable t => t a -> Bool
null [p ~> q]
maps))
String -> Int -> Int -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect String
"as many maps out of the sheafification as out of p" ([p ~> q] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [p ~> q]
maps) ([[Natural]] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [[Natural]]
exts)
String -> [[Natural]] -> [[Natural]] -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
String
"the extensions are exactly the maps out of the sheafification"
([[Natural]] -> [[Natural]]
forall a. Ord a => [a] -> [a]
sort [[Natural]]
exts)
([[Natural]] -> [[Natural]]
forall a. Ord a => [a] -> [a]
sort [forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
forall (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
FinTopos.natTable @(FinSheaf.Sheafify t p) @q (forall t {j} {k} (p :: j +-> k) (q :: j +-> k).
(HasFiniteCovers t k, Sheaf t q) =>
(p :~> q) -> Sheafify t p :~> q
FinSheaf.extendSheafify @t p a b -> q a b
p :~> q
n) | Prof p :~> q
n <- [p ~> q]
maps])
[p ~> q] -> ((p ~> q) -> Property ()) -> Property ()
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ [p ~> q]
maps \(Prof p :~> q
n) ->
String -> [Natural] -> [Natural] -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
String
"restricting an extension along the unit gives the map back"
(forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
forall (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
FinTopos.natTable @p @q p a b -> q a b
p :~> q
n)
(forall {j} {k} (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
forall (p :: j +-> k) (q :: j +-> k).
(Finitary p, Finitary q, FiniteCat j, FiniteCat k) =>
(p :~> q) -> [Natural]
FinTopos.natTable @p @q \p a b
x -> forall t {j} {k} (p :: j +-> k) (q :: j +-> k).
(HasFiniteCovers t k, Sheaf t q) =>
(p :~> q) -> Sheafify t p :~> q
FinSheaf.extendSheafify @t p a b -> q a b
p :~> q
n (forall t {j} {k} (p :: j +-> k). Profunctor p => p :~> Sheafify t p
FinSheaf.unitSheafify @t p a b
x))
]
testPlusFixes
:: forall t {j} {k} (q :: j +-> k)
. (Sheaf.HasFiniteCovers t k, Finitary.Finitary q, Finitary.FiniteCat j, Finitary.FiniteCat k)
=> TestTree
testPlusFixes :: forall t {j} {k} (q :: j +-> k).
(HasFiniteCovers t k, Finitary q, FiniteCat j, FiniteCat k) =>
TestTree
testPlusFixes =
String -> Property () -> TestTree
testProperty String
"one plus fixes q" (Property () -> TestTree) -> Property () -> TestTree
forall a b. (a -> b) -> a -> b
$
[Property ()] -> Property ()
forall (t :: Type -> Type) (m :: Type -> Type) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
( forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @k @(Property ()) \ @a -> forall k r. Enumerable k => (forall (a :: k). Ob a => [r]) -> [r]
Finitary.foreachOb @j @(Property ()) \ @b ->
let ix :: Plus t q a a -> Natural
ix = forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
forall (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
p a b -> Natural
Finitary.toIndex @(FinSheaf.Plus t q) @a @b
in [ String -> [Natural] -> [Natural] -> Property ()
forall a. (Eq a, Show a) => String -> a -> a -> Property ()
expect
(String
"unit is a bijection at object " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show (forall (a :: k). (Enumerable k, Ob a) => Natural
forall {k} (a :: k). (Enumerable k, Ob a) => Natural
Finitary.objIndex @a))
(Natural -> [Natural]
Finitary.indices (forall {j} {k} (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
forall (p :: j +-> k) (a :: k) (b :: j).
(Finitary p, Ob a, Ob b) =>
Natural
Finitary.size @(FinSheaf.Plus t q) @a @b))
([Natural] -> [Natural]
forall a. Ord a => [a] -> [a]
sort [Plus t q a a -> Natural
ix (forall t {j} {k} (p :: j +-> k). Profunctor p => p :~> Plus t p
FinSheaf.unitPlus @t q a a
x) | q a a
x <- forall {j} {k} (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]
Finitary.elements @q @a @b])
]
)