โ† back to index

Weakest Preconditions in Fibrations

Bart Jacobs ยท 2014 ยท preprint

Prereqs: ๐Ÿž Staton 2025 (Hoare triples, weakest precondition). ๐Ÿž Fritz 2020 (Kleisli categories) helps.

Weakest preconditions arise automatically from a wpfibration over a Kleisli category. The poset of predicates sitting above each type is the fiber; lifting a morphism through the fibration computes wp.

base category (Kleisli) p X Y f : X → D(Y) Pred(Y) Q y > 0 true Pred(X) wp(f,Q) x > 1 wp lift

Predicates as a poset fibration

Above each type X sits a poset of predicates on X โ€” propositions ordered by implication. "x > 5" implies "x > 0", so "x > 5" sits above "x > 0" in the fiber over integers. A fibration is this layered structure: types on the bottom, predicates stacked above, ordered by strength.

Scheme

Lifting through the Kleisli category

A stochastic function f: X โ†’ D(Y) lives in the wpKleisli category of the distribution monad. To compute wp(f, Q), you lift the predicate Q on Y back through f: for each input x, check whether every possible output satisfies Q.

Scheme

Order enrichment makes wp monotone

The fibers are posets (predicates ordered by implication). The wp functor is monotone: if Qโ‚ implies Qโ‚‚, then wp(f, Qโ‚) implies wp(f, Qโ‚‚). Stronger postconditions give stronger preconditions. This monotonicity comes for free from the order-enriched Kleisli structure.

Scheme

Composition of wp via Kleisli composition

wp(f;g, Q) = wp(f, wp(g, Q)). Composing two stochastic functions and computing wp in one step gives the same result as computing wp for g first, then using that as the postcondition for f. The fibration structure guarantees this โ€” it's not a coincidence, it's functoriality.

Scheme

Notation reference

Paper Scheme Meaning
Pred(X)(lambda (x) ...)Fiber: predicates on X
P โ‰ค Q(implies? P Q dom)P implies Q (stronger precondition)
wp(f, Q)(wp f Q)Weakest precondition via lifting
Kl(D); Kleisli(Distribution)Kleisli category of distribution monad
p*(wp f ...)Reindexing functor (pullback along f)
Neighbors

Other paper pages

Foundations (Wikipedia)

Translation notes

All examples use finite distributions and boolean predicates. Jacobs works with order-enriched categories, where predicates form complete lattices and the fibration carries a rich adjunction structure (left and right adjoints to reindexing). For example: the wp computation on this page checks all elements of a small support set. In the paper, wp is a right adjoint to substitution in the fibration โ€” a universal construction that works over arbitrary effect monads, not just distributions. The pointwise "for all y" check is the same; the categorical machinery that guarantees it exists is not.

Every example is Simplified.

Ready for the real thing? Start at ยง3 for the fibration of predicates over Kleisli categories, ยง5 for the wp-semantics.

Framework connection: The fibration-based wp construction is the theoretical backbone for computing weakest preconditions in the Natural Framework's ambient Kleisli category. (jkAmbient Category)