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 fibration over a Kleisli category. The poset of predicates sitting above each type is the fiber; lifting a morphism through the fibration computes wp.
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.
Lifting through the Kleisli category
A stochastic function f: X โ D(Y) lives in the Kleisli 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.
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.
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.
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
- ๐ Staton 2025 โ Hoare rules as theorems in imperative categories (uses wp)
- ๐ Cho, Jacobs 2015 โ effectus theory (same author, predicates as effects)
- ๐ Ho, Wu 2026 โ Bayesian separation logic (wp for probabilistic programs)
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.
Framework connection: The fibration-based wp construction is the theoretical backbone for computing weakest preconditions in the Natural Framework's ambient Kleisli category. (
Ambient Category)