proarrow:testing
Safe HaskellNone
LanguageGHC2024

Proarrow.Testing.Laws

Description

Reusable law-checking properties, parameterized over any Testable kind: testCategory, testMonoidal, testBinaryProducts, testClosed, and friends. Wiring a new category into a test suite is a Testable instance plus calls to these; the test/Props directory of proarrow's source repository has many examples.

A test returns a TestTree, ready for a testGroup. A prop returns a Property (), to be composed into a property of your own. Where both exist (e.g. testMonoid and propMonoid), the test one wraps the prop one.

Many of these take an explicit witness that TestOb is closed under the structure being tested (e.g. that TestOb (a ** b) follows from TestOb a and TestOb b). The _-suffixed variant (e.g. testMonoidal_) supplies it from a TestObIsOb constraint, for categories where every object is a TestOb, typically those that leave TestOb at its Ob default.

Synopsis

Isomorphisms

propIso :: forall {k} (a :: k) (b :: k). (Testable k, TestOb a, TestOb b) => (a ~> b) -> (b ~> a) -> Property () Source Github #

Two arrows are mutually inverse: f . g = id and g . f = id.

propIso' :: forall {k} (c :: (k -> k -> Type) -> Constraint) (a :: k) (b :: k). (Testable k, TestOb a, TestOb b, Ob b => c (ExOptic (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) b b), Ob b => c (ExOptic (Flip (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint)) b b)) => Optic c a a b b -> Property () Source Github #

An optic is an isomorphism: its view and review are mutually inverse, by propIso.

propIsoP :: forall {j1} {k1} {j2} {k2} p q (a :: k1) (b :: j1) (c :: k2) (d :: j2). (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 () Source Github #

Two functions between the elements of p a b and of q c d are mutually inverse, at generated elements.

propNaturalIsoP :: forall {j} {k} (p :: j +-> k) (q :: j +-> k). (TestableProfunctor p, TestableTypeP p, TestableProfunctor q, TestableTypeP q) => (p :~> q) -> (q :~> p) -> Property () Source Github #

Two natural transformations are mutually inverse: propIsoP at generated objects, and each is natural (propNaturalTransformation).

Categories

testCategory :: Testable k => TestTree Source Github #

The category laws: id is a left and right identity for (.), and (.) is associative.

testDagger :: (Testable k, Dagger k) => TestTree Source Github #

The laws of a dagger category: ProLaws DaggerProfunctor at the hom profunctor, so dagger is an involution and reverses composition.

testDaggerProfunctor :: forall {k} (p :: k +-> k). (DaggerProfunctor p, TestableProfunctor p) => TestTree Source Github #

The DaggerProfunctor laws of p stated as code: dagger is an involution that reverses dimap.

Profunctors

testCategoryProLaws :: forall {j} {k} (cl :: (TESTED '[CategoryOf] j +-> TESTED '[CategoryOf] k) -> Constraint) (p :: j +-> k). (ProLaws cl, TestableProfunctor p, cl (TestedP p :: TESTED '[CategoryOf] k -> TESTED '[CategoryOf] j -> Type)) => TestOptions -> String -> TestTree Source Github #

testProLaws for a profunctor class whose laws need only the categories of p, with the given options.

defaultTestOptions :: TestOptions Source Github #

The falsify options of a plain testProperty, to adjust for one test, e.g. a larger overrideMaxRatio where a law's arrows rarely exist.

testProfunctor :: forall {j} {k} (p :: j +-> k). TestableProfunctor p => TestTree Source Github #

The profunctor laws of p stated as code (ProLaws Profunctor).

testProfunctorWith :: forall {j} {k} (p :: j +-> k). TestableProfunctor p => TestOptions -> TestTree Source Github #

testProfunctor with the given falsify options for each law.

propDecidable :: forall {j} {k} (p :: j +-> k). (DecidableProfunctor p, Testable j, Testable k, TestableTypeP p) => Property () Source Github #

decide agrees with the generator: an element of p a b can be generated exactly when Holds p a b decides to TRU, and then (the profunctor being thin) it is the decided element.

propNaturalTransformation :: forall {j} {k} (p :: j +-> k) (q :: j +-> k). (TestableProfunctor p, TestableProfunctor q) => (p :~> q) -> Property () Source Github #

A transformation n :: p :~> q is natural: n (dimap f g p) = dimap f g (n p).

testFinitary :: forall {j} {k} (p :: j +-> k). (Finitary p, TestableProfunctor p, TestableTypeP p) => String -> TestTree Source Github #

The numbering laws of a Finitary profunctor: elements has size entries and is numbered in order, and fromIndex recovers any element from its index (ProLaws Finitary), including elements the instance did not itself produce. That law, fromIndex . toIndex, checks that size is correct and not merely self-consistent, but only as far as the TestableType generator is independent of the instance. One defined as optGen elements makes it vacuous. The label names the profunctor, which nothing in its type can supply.

propNumbering :: forall {j} {k} (p :: j +-> k). (Finitary p, TestableProfunctor p, TestableTypeP p) => Property () Source Github #

elements has size entries, numbered in order, and every index is below size.

Functors, representability and adjunctions

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 () Source Github #

Check the functor laws of a Functor f: map id = id and map (g . f) = map g . map f. The witness lifts TestOb along f (usually \ @a r -> r when TestOb (f a) follows from TestOb a). Functors encoded as representable profunctors (FunctorForRep) are instead tested via their Rep with testProfunctor, since the profunctor laws on Rep f are the functor laws on f.

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 Source Github #

The functor laws of f (propFunctor) as a ready-made test.

testFunctor_ :: forall {k1} {k2} (f :: k1 -> k2). (Functor f, Testable k1, Testable k2, forall (a :: k1). TestOb a => TestOb' (f a)) => TestTree Source Github #

testMonoidalProfunctor :: forall {j} {k} (p :: j +-> k). (MonoidalProfunctor p, TestableProfunctor p, TestOb (Unit :: j), TestOb (Unit :: k)) => WithTestOb2 j -> WithTestOb2 k -> TestTree Source Github #

The MonoidalProfunctor laws of p stated as code (ProLaws MonoidalProfunctor). The witnesses say how TestOb is closed under the tensor of j and of k.

testMonStrong :: forall {k} (p :: k +-> k). (Strong (Tensor :: k -> (k, k) -> Type) p, Monoidal k, TestableProfunctor p, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of strength of p for the tensor acting on its own category, stated as code (ProLaws (Strong Tensor)). The witness says how TestOb is closed under the tensor.

testMonStrong_ :: forall {k} (p :: k +-> k). (Strong (Tensor :: k -> (k, k) -> Type) p, Monoidal k, TestableProfunctor p, TestObIsOb k) => TestTree Source Github #

testMonCostrong :: forall {k} (p :: k +-> k). (Costrong (Tensor :: k -> (k, k) -> Type) p, Monoidal k, TestableProfunctor p, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of costrength of p for the tensor acting on its own category, stated as code (ProLaws (Costrong Tensor)). The witness says how TestOb is closed under the tensor.

testMonCostrong_ :: forall {k} (p :: k +-> k). (Costrong (Tensor :: k -> (k, k) -> Type) p, Monoidal k, TestableProfunctor p, TestObIsOb k) => TestTree Source Github #

testRepresentable :: forall {j} {k} (p :: j +-> k). (Representable p, TestableProfunctor p) => WithTestObRep j p -> TestTree Source Github #

The Representable laws of p stated as code (ProLaws Representable): index and tabulate are inverse and natural. The witness lifts TestOb along p % -.

testCorepresentable :: forall {j} {k} (p :: j +-> k). (Corepresentable p, TestableProfunctor p) => WithTestObCorep k p -> TestTree Source Github #

The Corepresentable laws of p stated as code (ProLaws Corepresentable): coindex and cotabulate are inverse and natural. The witness lifts TestOb along p %% -.

testPromonad :: forall {k} (p :: k +-> k). (Promonad p, TestableProfunctor p) => TestTree Source Github #

The Promonad laws of p stated as code: id is a unit for composition, which is associative, and both are natural.

testProcomonad :: forall {k} (p :: k +-> k). (Procomonad p, TestableProfunctor p, TestObIsOb k) => TestTree Source Github #

The Procomonad laws of p stated as code: proextract is natural and a counit for produplicate. The middle object of produplicate is only known to be an object, hence TestObIsOb.

testProadjunction :: forall {j} {k} (p :: j +-> k) (q :: k +-> j). (Proadjunction p q, TestableProfunctor p, TestableProfunctor q, TestObIsOb j, TestObIsOb k) => TestTree Source Github #

The zigzag laws of the adjunction between p and q stated as code, for elements of each: ProLaws (LeftProadjoint q) and (Proadjunction p). The middle object of the unit is only known to be an object, hence TestObIsOb.

testAdjunction :: forall {j} {k} (p :: j +-> k). (Adjunction p, TestableProfunctor p) => WithTestObCorep k p -> WithTestObRep j p -> TestTree Source Github #

Check the adjunction laws of an Adjunction p. An adjunction here is a profunctor that is both Representable and Corepresentable, with left adjoint L = p %% - and right adjoint R = p % -. It carries no laws of its own beyond theirs (leftAdjunct/rightAdjunct are just index . cotabulate and coindex . tabulate), so this groups testCorepresentable (for L) and testRepresentable (for R). The two witnesses lift TestOb along L and R respectively.

Limits and colimits

testBinaryProducts :: (Testable k, HasBinaryProducts k) => WithTestObProd k -> TestTree Source Github #

The universal property of the binary product, from Laws '[HasBinaryProducts]: the projections recover the components of f &&& g, pairing commutes with precomposition, and pairing the projections is the identity.

testBinaryCoproducts :: (Testable k, HasBinaryCoproducts k) => WithTestObCoprod k -> TestTree Source Github #

The universal property of the binary coproduct, dual to testBinaryProducts, from Laws '[HasBinaryCoproducts].

propReflectsEq :: TestingEqShow x => String -> String -> Bool -> x -> x -> Property () Source Github #

Check that composing with an arrow reflects equality: the composites agree exactly when the two arrows already did. eqComposed is the caller's comparison of the composites (a conjunction, where two projections have to be checked together), and desc names it for the failure message.

This is the mono half of an equalizer, the epi half of a coequalizer, and the jointly-monic and jointly-epic halves of a pullback and a pushout.

testEqualizers :: (Testable k, HasEqualizers k) => WithTestOb k -> TestTree Source Github #

Checks the equalizer laws: the equalizer arrow e equalizes f and g; any h that factors through e (generated as e . p) is recovered by factorEqualizer; and e is mono.

The equalizer object is not computed by a type family, so its Ob comes from the arrow via Objs, and withTestOb only has to bridge that one Ob to TestOb.

testCoequalizers :: (Testable k, HasCoequalizers k) => WithTestOb k -> TestTree Source Github #

Checks the coequalizer laws, dual to testEqualizers: the coequalizer arrow c coequalizes f and g; any h that factors through c (built here as p . c for an arbitrary p, so the precondition holds by construction) is correctly recovered by factorCoequalizer; and c is epi (post-composing with it on the right reflects equality).

testPullbacks :: (Testable k, HasPullbacks k) => WithTestOb k -> TestTree Source Github #

Checks the pullback laws: the pullback cone commutes; it's jointly monic (composing with both legs at once reflects equality); and any compatible cone (built here as (p1 . j, p2 . j) for an arbitrary j, so compatibility holds by construction) is correctly recovered by factorPullback.

testPushouts :: (Testable k, HasPushouts k) => WithTestOb k -> TestTree Source Github #

Checks the pushout laws, dual to testPullbacks: the pushout cocone commutes; it's jointly epic (post-composing with both legs at once reflects equality); and any compatible cocone (built here as (j . p1, j . p2) for an arbitrary j, so compatibility holds by construction) is correctly recovered by factorPushout.

testEpiMonoFactorization :: (Testable k, HasEpiMonoFactorization k) => WithTestOb k -> TestTree Source Github #

Checks the epi-mono factorization laws: factorize splits f as m . e through an image object, with e epi and m mono.

As with testEqualizers the image object is revealed at runtime rather than computed by a type family, so withTestOb bridges its recovered Ob to TestOb. The epi and mono halves are the two directions of propReflectsEq: composing on the right with e, and on the left with m.

Monoidal structure

testMonoidal :: (Testable k, Monoidal k, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The monoidal laws, from Laws '[Monoidal]: the unitors and the associator are natural isomorphisms satisfying the triangle and pentagon identities.

testSymMonoidal :: (Testable k, SymMonoidal k, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a symmetric monoidal category, from Laws SymMonoidalStructures: swap is a natural self-inverse satisfying the hexagon identity.

testCopyDiscard :: (Testable k, CopyDiscard k, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a copy-discard category: every object is a cocommutative comonoid (the laws of its supply, in Proarrow.Monoid), and copy and discard are that comonoid and respect the tensor (CopyDiscardStructures).

testCartesian :: (Testable k, Cartesian k, TestOb (Unit :: k)) => (forall (a :: k) r. TestOb a => (Ob a => r) -> r) -> WithTestOb2 k -> TestTree Source Github #

The coherence law tying Cartesian to its CopyDiscard superclass (Fox's theorem): the comonoid supplied on every object is the natural one, copy = id &&& id and discard = terminate.

propCartesianAt :: forall {k} (a :: k). (Testable k, Cartesian k, TensorIsProduct a a, TestOb (Unit :: k), TestOb a, Ob a, TestOb (a ** a)) => Property () Source Github #

testDistributive :: (Testable k, Distributive k, TestOb (Unit :: k), TestOb (InitialObject :: k)) => WithTestOb2 k -> WithTestObCoprod k -> TestTree Source Github #

The tensor distributes over coproducts and is absorbed by the initial object, from Laws DistributiveStructures: distL, distR, absorbL and absorbR are isomorphisms, with the inverses distLInv, distRInv and initiate.

testClosed :: (Testable k, Closed k, TestOb (Unit :: k)) => WithTestOb2 k -> WithTestObExp k -> TestTree Source Github #

The laws of a closed monoidal category, from Laws ClosedStructures: apply undoes curry and every arrow into an exponential is the curry of one, curry is natural, and ^^^ is defined from curry and apply.

testDialogue :: (Testable k, Dialogue k, TestOb (Unit :: k)) => WithTestOb2 k -> WithTestObDual k -> TestTree Source Github #

Laws of a dialogue category, from Laws DialogueStructures: dual is a contravariant functor, linDist is a natural bijection Hom(a ** b, Dual c) ≅ Hom(a, Dual (b ** c)) with inverse linDistInv, and doubleNegInv is the one they give.

testStarAutonomous :: (Testable k, StarAutonomous k, TestOb (Unit :: k)) => WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree Source Github #

Laws of a *-autonomous category, from Laws StarAutonomousStructures: dual is bijective on hom-sets with inverse dualInv, and doubleNeg is an isomorphism. The rest is testDialogue. The exponential witness is needed because Closed is a superclass, although no law builds an exponential.

testIsoMix :: (Testable k, IsoMix k, TestOb (Unit :: k)) => WithTestOb2 k -> WithTestObDual k -> TestTree Source Github #

Laws of an isomix category, from Laws IsoMixStructures: dualUnit and dualUnitInv are inverses, and dualityCounit is the one the dialogue structure gives.

testCompactClosed :: (Testable k, CompactClosed k, TestOb (Unit :: k)) => WithTestOb2 k -> WithTestObExp k -> WithTestObDual k -> TestTree Source Github #

Laws of a compact closed category, from Laws CompactClosedStructures: distribDual and dualUnit are isomorphisms (so Dual is strong monoidal), and dualityUnit and dualityCounit satisfy the zigzag identities. See testStarAutonomous for the exponential witness.

testHypergraph :: (Testable k, SymMonoidal k, Supplies CommutativeMonoid k, Supplies CocommutativeComonoid k, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a category that supplies special commutative Frobenius algebras, stated for every object: the monoid and comonoid laws of its points, their commutativity, and the Frobenius laws of FrobeniusStructures.

Traced monoidal categories

Monoids and comonoids

propMonoid :: forall {k} (m :: k). (Testable k, Monoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> Property () Source Github #

The monoid laws of m: mempty is a left and right unit for mappend (up to the unitors), and mappend is associative (up to the associator).

propCommutativeMonoid :: forall {k} (m :: k). (Testable k, CommutativeMonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> Property () Source Github #

The laws of a commutative monoid: propMonoid, and mappend is unchanged by swap.

propCocommutativeComonoid :: forall {k} (m :: k). (Testable k, CocommutativeComonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> Property () Source Github #

The laws of a cocommutative comonoid, as those of a commutative monoid in the opposite category.

propFrobenius :: forall {k} (m :: k). (Testable k, SymMonoidal k, CommutativeMonoid m, CocommutativeComonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> Property () Source Github #

Check that the object m is a special commutative Frobenius algebra: it is a CommutativeMonoid (via propCommutativeMonoid) and a CocommutativeComonoid (via propCocommutativeComonoid), and satisfies speciality (mappend . comult = id) and the Frobenius condition. A Hypergraph category supplies this structure, and testHypergraph samples an object and delegates here.

testMonoid :: forall {k} (m :: k). (Testable k, Monoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The monoid laws of m (propMonoid) as a ready-made test.

testMonoid_ :: forall {k} (m :: k). (Testable k, Monoid m, TestObIsOb k) => TestTree Source Github #

testComonoid :: forall {k} (m :: k). (Testable k, Comonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The comonoid laws of m, as the monoid laws of m in the opposite category.

testComonoid_ :: forall {k} (m :: k). (Testable k, Comonoid m, TestObIsOb k) => TestTree Source Github #

testCommutativeMonoid :: forall {k} (m :: k). (Testable k, CommutativeMonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a commutative monoid (propCommutativeMonoid) as a ready-made test.

testCocommutativeComonoid :: forall {k} (m :: k). (Testable k, CocommutativeComonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a cocommutative comonoid (propCocommutativeComonoid) as a ready-made test.

testFrobenius :: forall {k} (m :: k). (Testable k, CommutativeMonoid m, CocommutativeComonoid m, TestOb m, TestOb (Unit :: k)) => WithTestOb2 k -> TestTree Source Github #

The laws of a special commutative Frobenius algebra (propFrobenius) as a ready-made test.

Toposes

testSubobjectClassifier :: (Testable k, HasSubobjectClassifier k, HasEpiMonoFactorization k, HasPushouts k, HasPullbacks k, TestOb (Omega :: k)) => WithTestObProd k -> TestTree Source Github #

Checks the subobject classifier Omega, the object of truth values: a map into it is a predicate, and each mono m has one classifying map, true on m and nowhere else. The laws quantify over generalized elements (arrows into the object):

  • classifyGraph f is true at (x, y) iff y = f . x. This is the pullback condition for the graph <id, f>. At f = id it is isEq, so equality testing is pinned down too.
  • Distinct arrows get distinct classifiers, the testable consequence of the classifying map being unique.
  • classifyKernelPair f is true at (x, x') iff f identifies them, in both directions.
  • classifyImage f is true on the image of f and nowhere else: every element it calls true factors through the image mono, by factorPullback. This is the law that separates a subobject classifier from an arbitrary map into Omega.

The elements come from the Testable palette, which is sound iff that palette generates: true for the concrete finite categories, not for a presheaf topos.

testNegation :: (Testable k, ElementaryTopos k, TestOb (Omega :: k)) => TestTree Source Github #

Negation is implication into false: not = implies . (id &&& const false). A theorem of every topos; not is defined as the classifying map of false instead, so this checks the two agree.

testLawvereTierney :: (Testable k, ElementaryTopos k, TestOb (Omega :: k), TestOb (TerminalObject :: k)) => WithTestObProd k -> ((Omega :: k) ~> (Omega :: k)) -> TestTree Source Github #

The three equations a Lawvere–Tierney topology satisfies, for an arrow j :: Omega ~> Omega: it fixes true, is idempotent, and preserves meets.

Such a j is the same data as a Grothendieck topology: the covering sieves are the ones j sends to true. lawvereTierney is the j a coverage induces, so this is how a coverage's stability and composition get checked, without quantifying over arrows the coverage was never handed.

lawvereTierneyLaws :: (Testable k, ElementaryTopos k, TestOb (Omega :: k), TestOb (TerminalObject :: k)) => WithTestObProd k -> [(String, ((Omega :: k) ~> (Omega :: k)) -> Property ())] Source Github #

The three laws of testLawvereTierney, by name, for an arrow given later. Shared by it and testLawvereTierneyFamily.

testLawvereTierneyFamily :: (Testable k, ElementaryTopos k, TestOb (Omega :: k), TestOb (TerminalObject :: k)) => String -> WithTestObProd k -> (((TerminalObject :: k) ~> (Omega :: k)) -> (Omega :: k) ~> (Omega :: k)) -> TestTree Source Github #

testLawvereTierney for a family of arrows indexed by the truth values, at a generated one: openTopology and closedTopology are the ones the internal logic gives.

Sites and sheaves

testSiteLaws :: forall t j k. (StableSite t k, HasFiniteCovers t k, FiniteCat j, FiniteCat k) => TestTree Source Github #

The three laws a listable, stable coverage owes, as one group: testStableSite, testGeneratedSieveIsSieve and testDenseIsCovering. Checking a site starts here.

The rest of this section checks what is built on the coverage: testGluesBack and testGluesBackAt the sheaf condition, testEqualizersAreSheaves the category of sheaves, and testSheafification (with testPlusFixes) the reflector. testLawvereTierney, under Toposes, checks the generated topology and with it HasFiniteCovers's Composition law.

testStableSite :: (StableSite t k, HasFiniteCovers t k, FiniteCat k) => TestTree Source Github #

StableSite's law: pulling a cover back along f gives a cover. For every leg l' of the cover pullbackCover returns, the instance names a leg l of the original and a factor u with f . legArrow l' = legArrow l . u. This checks that equation, and that the pulled-back legs generate a covering sieve, which matters for covers that are built instead of listed, like the meets of Joins. Covering is checked instead of dense so that the check does not assume covers compose. It runs at j ~ (), since whether a sieve covers does not depend on j.

On a thin site (at most one arrow between two objects) the equation holds as soon as it typechecks. It bites only where two legs share a source and target: the ends of an edge in the graph schema E ⇉ V, or ByImage, whose legs are named by elements.

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 () Source Github #

One leg's half of testStableSite: the arrow is the leg it factors through, composed with the factor.

testGeneratedSieveIsSieve :: forall t j k. (HasFiniteCovers t k, FiniteCat j, FiniteCat k) => TestTree Source Github #

A cover's generated sieve (the arrows that factor through one of its legs) is a sieve: closed under composing on either side, as closedUnder decides. That holds for any coverage, lawful or not, so this checks factorsThrough and the hom-profunctor's elements, which every verdict in Proarrow.Category.Enriched.Finitary.Sheaf is read off. It catches, for instance, an argument-swapped factorsThrough.

testAtomicIsDoubleNegation :: (HasPullbacks k, FiniteCat k, Testable (PROD (FINITARY () k)), TestOb (Omega :: PROD (FINITARY () k))) => TestTree Source Github #

On a category with pullbacks (which give the Ore condition), the topology Atomic generates is the double-negation one: lawvereTierney and doubleNegation are the same arrow, one computed by closing sieves and one from the internal logic. At j ~ () only: over a non-trivial j, ¬¬ is the dense topology along j as well, while the coverage acts on k alone.

testRanFullyFaithful :: forall {j} {k} (p :: j +-> k). (Finitary p, FiniteCat j, FiniteCat k) => TestTree Source Github #

A profunctor p :: j +-> k is fully faithful in the sense of Ran when the functor from k to copresheaves on j sending a to p a (-) is: each hom-set a ~> a' is in bijection with the natural transformations p a' (-) -> p a (-), which are (p |> p) a a'. For a corepresentable p that is the functor p %% - being fully faithful, which is ByImage's Fully faithful law. testRiftFullyFaithful is the other side, and neither implies the other.

testRiftFullyFaithful :: forall {j} {k} (p :: j +-> k). (Finitary p, FiniteCat j, FiniteCat k) => TestTree Source Github #

A profunctor p :: j +-> k is fully faithful in the sense of Rift when the functor from j to presheaves on k sending b to p (-) b is: each hom-set b ~> b' is in bijection with the natural transformations p (-) b -> p (-) b', which are (p <| p) b b'. For a representable p that is the functor p % - being fully faithful. For a corepresentable p it says the image of p %% - is dense. That makes ByImage subcanonical, and when p %% - is fully faithful the converse holds too. The comparison lemma asks for something else, testCoveredByImage.

testCoveredByImage :: forall t {j} {k} (w :: j +-> k). (HasFiniteCovers t j, Corepresentable w, Finitary w, FiniteCat j, FiniteCat k) => TestTree Source Github #

Every object of j is covered, for the coverage t, by the arrows into it from the image of the functor w %% -: the sieve they generate is covering. With w %% - fully faithful (testRanFullyFaithful) this is the hypothesis of the comparison lemma, see Induced. Neither this nor testRiftFullyFaithful implies the other.

testDenseIsCovering :: forall t j k. (HasFiniteCovers t k, FiniteCat j, FiniteCat k) => TestTree Source Github #

For every sieve at every pair of objects of a finite site: it is covering exactly when it is dense, that is when its closure is the maximal sieve. Two independent computations of one fact: isCovering reads it off the coverage, closure off the induced topology.

propGluesBack :: forall {j} {k} t p (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 () Source Github #

The uniqueness half of the sheaf condition at one cover: an element x at the covered object is the gluing of its own restrictions to the legs.

The other half (a glued element restricts back to the family) has no generic test: the only matching family generic code can build is an element's own restrictions, and there it follows from uniqueness. Other families come from the site, so that test is written per site. At a finite site isSheaf decides both halves at once, by checking that restriction is a bijection onto the matching families.

testGluesBack :: forall {j} {k} t (p :: j +-> k). (HasFiniteCovers t k, Sheaf t p, TestableProfunctor p, TestableTypeP p, TestObIsOb k) => TestTree Source Github #

propGluesBack at every cover of a random element's object. Named for the law and not for the class, since it is half of what Sheaf asks for (see propGluesBack for the other half).

The object is drawn from those that actually have a cover: on a site where only some objects are covered, drawing uniformly would leave most runs asserting nothing while reporting successes.

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 Source Github #

propGluesBack at one named cover, for a site whose covers cannot be listed. The label names the profunctor and cover, which nothing in the type can supply.

testEqualizersAreSheaves :: (Testable (SHEAVES t j k), HasFiniteCovers t k, FiniteCat j, FiniteCat k) => TestTree Source Github #

An equalizer of sheaves is a sheaf, for every coverage: the Sheaf instance for Reindex presupposes that the table cuts out a subsheaf, and this decides it, by isSheaf, on the equalizer of every pair of parallel arrows the palette of SHEAVES t j k can form.

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 Source Github #

Sheafification is the reflector into the sheaves: it turns a presheaf p into the closest sheaf, and every map from p to a sheaf factors uniquely through it. For a finitary p and a sheaf q, decided at a finite site:

  • unitPlus is natural;
  • Sheafify t p is a sheaf, by isSheaf;
  • one plus construction fixes q (testPlusFixes);
  • maps Sheafify t p ~> q correspond to maps p ~> q. The hom-sets of FINITARY j k are finite, so this is a count, made a bijection by extendSheafify: extending every map p ~> q gives every map out of the sheafification once, and restricting an extension along the unit gives the map back.

This also makes extendPlus's choice of cover safe to leave unspecified: another choice would show up here as an extension that is not one of the maps.

testPlusFixes :: forall t {j} {k} (q :: j +-> k). (HasFiniteCovers t k, Finitary q, FiniteCat j, FiniteCat k) => TestTree Source Github #

One plus leaves a sheaf as it was: unitPlus is a bijection at every pair of objects. Stated for any finitary q (the property needs no Sheaf instance, only isSheaf to be true of q), so it also serves at a coverage no profunctor has an instance for, such as the trivial one, which fixes everything.