Up-To Techniques for Behavioural Metrics via Fibrations

Up-to techniques are a well-known method for enhancing coinductive proofs of behavioural equivalences. We introduce up-to techniques for behavioural metrics between systems modelled as coalgebras and we provide abstract results to prove their oundness in a compositional way. In order to obtain a general framework, we need a systematic way to lift functors: we show that the Wasserstein lifting of a functor, introduced in a previous work, corresponds to a change of base in a fibrational sense. This observation enables us to reuse existing results about soundness of up-to techniques in a fibrational setting. We focus on the fibrations of predicates and relations valued in a quantale, for which pseudo-metric spaces are an example. To illustrate our approach we provide an example on distances between regular languages.


Introduction
Checking whether two systems have an equivalent (or similar) behaviour is a crucial problem in computer science.In concurrency theory, one standard methodology for establishing behavioural equivalence of two systems is constructing a bisimulation relation between them.
When the systems display a quantitative behaviour, the notion of behavioural equivalence is replaced with the more robust notion of behavioural metric [43,16,17].Due to the sheer complexity of state-based systems, computing their behavioural equivalences and metrics can be very costly, therefore optimization techniques-the so called up-to techniques-have been developed to render these computations more efficient.These techniques found applications in various domains such as checking algorithms [12,9], abstract arXiv:1806.11064v1[cs.LO] 28 Jun 2018

17:2
Up-To Techniques for Behavioural Metrics via Fibrations interpretation [8] and proof assistants [15].In the qualitative setting and in particular in concurrency, the theory of up-to techniques for bisimulations and various other coinductive predicates has been thoroughly studied [31,35,22].On the other hand, in the quantitative setting, so far, only [14] has studied up-to techniques for behavioural metrics.However, the notion of up-to techniques therein and the accompanying theory of soundness are specific for probabilistic automata and are not instances of the standard lattice theoretic framework, which we will briefly recall next.
Suppose we want to verify whether two states in a system behave in the same way, (e.g.whether two states of an NFA accept the same language).The starting observation is that the relation of interest (e.g.behavioural equivalence or language equivalence) can be expressed as the greatest fixed point νb of a monotone function b : Rel Q → Rel Q on the complete lattice Rel Q of relations on the state space Q of the system.Hence, in order to prove that two states x and y are behaviourally equivalent, i.e., (x, y) ∈ νb, it suffices to find a witness relation r which on one hand is a post-fixpoint of b, that is, r ⊆ b(r) and on the other hand contains the pair (x, y).This is simply the coinduction proof principle.However, exhibiting such a witness relation r can be sometimes computationally expensive.In many situations this computation can be significantly optimized, if instead of computing a post-fixpoint of b one exhibits a relaxed invariant, that is a relation r such that r ⊆ b(f (r)) for a suitable function f .The function f is called a sound up-to technique when the proof principle (x, y) ∈ r r ⊆ b(f (r)) (x, y) ∈ νb is valid.Establishing the soundness of up-to techniques on a case-by-case basis can be a tedious and sometimes delicate problem, see e.g.[30].For this reason, several works [37,33,35,22,32,34] have established a lattice-theoretic framework for proving soundness results in a modular fashion.The key notion is compatibility: for arbitrary monotone maps b and f on a complete lattice (C, ≤), the up-to technique f is b-compatible iff f • b ≤ b • f .Compatible techniques are sound and, most importantly, can be combined in several useful ways.
In this paper we develop a generic theory of up-to techniques for behavioural metrics applicable to different kinds of systems and metrics, which reuses established methodology.
To achieve this we exploit the theory developed in [10] by modelling systems as coalgebras [36,24] and behavioural metrics as coinductive predicates in a fibration [20].In order to provide general soundness results, we need a principled way to lift functors from Set to metric spaces, a problem that has been studied in [21] and [4].Our key observation is that these liftings arise from a change-of-base situation between V-Rel and V-Pred, namely the fibrations of relations, respectively predicates, valued over a quantale V (see Section 4 and 5).
In Section 6 we provide sufficient conditions ensuring the compatibility of basic quantitative up-to techniques, as well as proper ways to compose them.Interestingly enough, the conditions ensuring compatibility of the quantitative analogue of up-to reflexivity and up-to transitivity are subsumed by those used in [21] to extend monads to a bicategory of many-valued relations and generalize those in [4] (see the discussion after Theorem 21).
When the state space of a system is equipped with an algebraic structure, e.g. in process algebras, one can usually exploit this structure by reasoning up-to context.Assuming that the system forms a bialgebra [41,28], i.e., that the algebraic structure distributes over the coalgebraic behaviour as in GSOS specifications, we give sufficient conditions ensuring the compatibility of the quantitative version of contextual closure (Theorem 27).
In the qualitative setting, the sufficient conditions for compatibility are automatically met when taking as lifting the canonical relational one (see [10]).We show that the situation is similar in the quantitative setting for a certain notion of quantitative canonical lifting.In particular, up-to context is compatible for the canonical lifting under very mild assumptions (Theorem 30).As an immediate corollary we have that, in a bialgebra, syntactic contexts are non-expansive with respect to the behavioural metric induced by the canonical lifting.This property and weaker variants of it (such as non-extensiveness or uniform continuity), considered to be the quantitative analogue of behavioural equivalence being a congruence, have recently received considerable attention (see e.g.[17,1,40]).
To fix the intuition, Section 2 provides a motivating example, formally treated in Section 7. We conclude with a comparison to related work and a discussion of open problems in Section 8.
All proofs and additional material are provided in the appendix.

Motivating example: distances between regular languages
Computing various distances (such as the edit-distance or Cantor metric) between strings, and more generally between regular languages or string distributions, has found various practical applications in various areas such as speech and handwriting recognition or computational biology.In this section we focus on a simple distance between regular languages, which we will call shortest-distinguishing-word-distance and is defined as d sdw (L, K) = c |w| -where w is the shortest word which belongs to exactly one of the languages L, K and c is a constant such that 0 < c < 1.As a running example, which will be formally explained in Section 7, we consider the non-deterministic finite automaton in Figure 1 and the languages accepted by the states x 0 , respectively y 0 .We can similarly define a distance on the states of an automaton as the aforementioned distance between the languages accepted by the two states.The inequality holds in this example since no word of length smaller than n is accepted by either state.Note that computing this distance is PSPACE-hard since the language equivalence problem for non-deterministic automata can be reduced to it.One way to show this is to determinize the automaton in Figure 1 and to use the fact that for deterministic automata the shortest-distinguishing-word-distance can be expressed as the greatest fixpoint for a monotone function.Indeed, for a finite deterministic automaton (Q, (δ a : is the greatest fixpoint of a function b defined on the complete lattice [0, 1] Q×Q of functions ordered with the reversed pointwise order and given by b Notice that we use the reversed order on [0, 1], for technical reasons (see Section 4).
In order to prove (1) we can define a witness distance d on the states of the determinized automaton such that d({x 0 }, {y 0 }) ≤ c n and which is a post-fixpoint for b, i.e., d b( d).Notice that this would entail d d sdw and hence d sdw ({x 0 }, {y 0 }) ≤ d({x 0 }, {y 0 }) ≤ c n .

Up-To Techniques for Behavioural Metrics via Fibrations
This approach is problematic since the determinization of the automaton is of exponential size, so we have to define d for exponentially many pairs of sets of states.In order to mitigate the state space explosion we will use an up-to technique, which, just as up-to congruence in [12], exploits the join-semilattice structure of the state set PQ of the determinization of an NFA with state set Q.The crucial observation is the fact that given the states PQ in the determinization of an NFA, the following inference rule holds Based on this, we can define a monotone function f on [0, 1] PQ×PQ that closes a function d according to such proof rules, producing f (d) such that d f (d) (the formal definition of f is given in Section 7).The general theory developed in this paper allows us to show in Section 7 that f is a sound up-to technique, i.e., it is sufficient to prove d b(f ( d)) in order to establish d d sdw .
Using this technique it suffices to consider a quadratic number of pairs of sets of states in the example.In particular we define a function d : PQ × PQ → [0, 1] as follows: and d(X 1 , X 2 ) = 1 for all other values.Note that this function is not a metric but rather, what we will call in Section 4, a relation valued in For instance, when i = j = 0 we compute the sets of a-successors, which are {x 0 , x 1 }, {y 0 }.We have that d({x 0 }, {y 0 }) = c n ≤ c n−1 , d({x 0 }, {y 1 }) = c n−1 and using the up-to proof rule introduced above we obtain that f ( d)({x 0 , x 1 }, {y 0 }) ≤ c n−1 .The same holds for the sets of b-successors and since x 0 and y 0 are both non-final we infer b(f ( d))({x 0 }, {y 0 }) ≤ c • c n−1 = c n = d({x 0 }, {y 0 }).The remaining cases (when i = 0 = j) are analogous.
Our aim is to introduce such proof techniques for behavioural metrics, to make this kind of reasoning precise, not only for this specific example, but for coalgebras in general.Furthermore, we will not limit ourselves to metrics and distances, but we will consider more general relations valued in arbitrary quantales, of which the interval [0, 1] is an example.

Preliminaries
We recall here formal definitions for notions such as coalgebras, bialgebras or fibrations.

Definition 1.
A coalgebra for a functor F : C → C, or an F -coalgebra is a morphism γ : X → F X for some object X of C, referred to as the carrier of the coalgebra γ.A morphism between two coalgebras γ : Algebras for the functor F , or F -algebras, are defined dually as morphisms of the form α : F X → X.

Definition 2. Consider two functors F, T and a natural transformation
O O an F -coalgebra so that the diagram on the left commutes.We call ζ the distributive law of the bialgebra (X, α, γ), even when T is not a monad.
Example 3. The determinization of an NFA can be seen as a bialgebra with X = PQ, the algebra µ Q : PPQ → PQ given by the multiplication of the powerset monad, a coalgebra for the functor F (X) = 2 × X A , and a distributive law [39,25] for more details.
We now introduce the notions of fibration and bifibration.Definition 4. A functor p : E → B is called a fibration when for every morphism f : satisfying the following universal property: For all maps g : Z → X in B and u For X in B we denote by E X the fibre above X, i.e., the subcategory of E with objects mapped by p to X and arrows sitting above the identity on X.
A map f as above is called a Cartesian lifting of f and is unique up to isomorphism.If we make a choice of Cartesian liftings, the association R → f * (R) gives rise to the so-called reindexing functor In what follows we will only consider split fibrations, that is, the Cartesian liftings are chosen such that we have (f g) * = g * f * .
A functor p : E → B is called a bifibration if both p : E → B and p op : E op → B op are fibrations.Interestingly, a fibration is a bifibration if and only if each reindexing functor Two important examples of bifibrations are those of relations over sets, p : Rel → Set, and of predicates over sets, p : Pred → Set, which played a crucial role in [10].We do not recall their exact definitions here, as they arise as instances of the more general bifibrations of quantale-valued relations and predicates described in detail in the next section.Notice that a lifting F restricts to a functor between the fibres F X : E X → E F X .We omit the subscript X when it is clear from the context.Consider an arbitrary lifting F of F and a morphism f : sit above F f .Using the universal property in Definition 4, we obtain a canonical morphism ( A lifting F is called a fibred lifting when the natural transformation in (3) is an isomorphism.

Up-To Techniques for Behavioural Metrics via Fibrations
If ⊗ has an identity element or unit 1 for ⊗ the quantale is called unital.If x ⊗ y = y ⊗ x for every x, y ∈ V the quantale is called commutative and we have [x, −] = x, − .Hereafter, we only work with unital, commutative quantales.Example 6.The Boolean algebra 2 with ⊗ = ∧ is a unital and commutative quantale: the unit is 1 and [y, z] = y → z.The complete lattice [0, ∞] ordered by the reversed order1 of the reals, i.e., ≤=≥ R and with ⊗ = + is a unital commutative quantale: the unit is 0 and for every y, z ∈ [0, ∞] we have [y, z] = z .
Definition 7. Given a set X and a quantale V, a V-valued predicate on X is a map p : Given two V-valued predicates p, q : X → V, we say that p ≤ q ⇐⇒ ∀x ∈ X. p(x) ≤ q(x).Definition 8.A morphism between V-valued predicates p : X → V and q : Y → V is a map f : X → Y such that p ≤ q • f .We consider the category V-Pred whose objects are V-valued predicates and arrows are as above.
We consider the category V-Rel whose objects are V-valued relations and arrows are as above.
The bifibration of V-valued predicates.The forgetful functor V-Pred → Set mapping a predicate p : X → V to X is a bifibration.The fibre V-Pred X is the lattice of V-valued predicates on X.For f : X → Y in Set the reindexing and direct image functors on a predicate p ∈ V-Pred Y are given by The bifibration of V-valued relations.Notice that we have the following pullback in Cat, where ∆X = X × X.This is a change-of-base situation and thus the functor V-Rel → Set mapping each V-valued relation to its underlying set is also a bifibration.
We denote by V-Rel X the fibre above a set X.For each set X the functor ι restricts to an isomorphism ι X : For f : X → Y in Set the reindexing and direct image on p ∈ V-Rel Y are given by For two relations p, q ∈ V-Rel X , we define their composition p Definition 10.We say that a V-valued relation r : We denote by V-Cat the full subcategory of V-Rel consisting of reflexive, transitive relations and by V-Cat sym the full subcategory of V-Rel that are additionally symmetric.
Note that V-Cat is the category of small categories enriched over the V in the sense of [27].
Example 11.For V = 2, V-valued relations are just relations.Reflexivity, transitivity and symmetry coincide with the standard notions, so V-Cat is the category of preorders, while V-Cat sym is the category of equivalence relations.
For V = [0, ∞], V-Cat is the category of generalized metric spaces à la Lawvere [29] (i.e., directed pseudo-metrics and non-expansive maps), while V-Cat sym is the one of pseudo-metrics.

5
Lifting functors to V-Pred and V-Rel In the previous section, we have introduced the fibrations of interest for quantitative reasoning.
In order to deal with coinductive predicates in this setting, it is convenient to have a structured way to lift Set-functors to V-valued predicates and relations, and eventually to V-enriched categories.Our strategy is to first lift functors to V-Pred and then, by exploiting the change of base, move these liftings to V-Rel.A comparison with the extensions of Set-monads to the bicategory of V-matrices [21] is provided in Section 8.

V-predicate liftings
Liftings of Set-functors to the category Pred (for V = 2) of predicates have been widely studied in the context of coalgebraic modal logic, as they correspond to modal operators (see e.g.[38]).For V-Pred, we proceed in a similar way.Let us analyse what it means to have a fibred lifting F to V-Pred of an endofunctor F on Set.First, recall that the fibre V-Pred X is just the preorder V X .So the restriction F X to such a fibre corresponds to a monotone map V X → V F X .The fact that F is a fibred lifting essentially means that the maps (V X → V F X ) X form a natural transformation between the contravariant functors V − and V F − .Furthermore, by Yoneda lemma we know that natural transformations V − ⇒ V F − are in one-to-one correspondence with maps ev : F V → V, which we will call hereafter evaluation maps.One can characterise the evaluation maps which correspond to the monotone natural transformations.These are the monotone evaluation maps ev : (F V, ) → (V, ≤) with respect to the usual order ≤ on V and an order on F V defined by applying the standard canonical relation lifting of F to ≤. Proposition 12.There is a one-to-one correspondence between Notice that the correspondence between fibred liftings and monotone evaluation maps is given in one direction by ev = F (id V ), and conversely, by F (p : Evaluation maps as Eilenberg-Moore algebras.Evaluation maps have also been extensively considered in the coalgebraic approach to modal logics [38].A special kind of evaluation map arises when the truth values V have an algebraic structure for a given monad (T, µ, η), that is, we have V = T Ω for some object Ω and the evaluation map T V → V is an Eilenberg-Moore algebra for T .This notion of monadic modality has been studied in [19] where the category of free algebras for T was assumed to be order enriched.In Lemma 37 in Appendix B.2.1 we show that under reasonable assumptions, the evaluation map obtained as the free Eilenberg-Moore algebra on Ω (i.e., ev : T V → V is just µ Ω : T 2 Ω → T Ω) is a monotone evaluation map, and hence gives rise to a fibred lifting of T .
We provide next several examples of monotone evaluation maps which arise in this fashion.

probability distribution (expectation of the identity random variable).
The canonical evaluation map.In the case V = 2, there exists a simple way of lifting a functor F : Set → Set: given a predicate p : U X, one defines the canonical predicate lifting F can (U ) of F as the epi-mono factorization of F p : F U → F X.This lifting corresponds to a canonical evaluation map true : 1 → 2 which maps the unique element of 1 into the element 1 of the quantale 2. For V-relations, a generalized notion of canonical evaluation map was introduced in [21].For r ∈ V consider the subset ↑ r = {v ∈ V | v ≥ r} and write true r : ↑ r → V for the inclusion.Given u ∈ F V we write u ∈ F (↑ r) when u is in the image of the injective function F (true r ).Following [21], we define ev can : F V → V as follows: Example 15.Assume F is the powerset functor P and let u ∈ P(V).We obtain that ev can (u) = {r | u ⊆ ↑ r}, or equivalently, ev can (u) = u .
Example 16.The canonical evaluation map for the distribution monad D and The canonical evaluation map ev can is monotone whenever the functor F preserves weak pullbacks (see Lemma 43 in Appendix B.2.2).For such functors, by Proposition 12, the map ev can induces a fibred lifting F can of F , called the canonical V-Pred-lifting of F and defined by

From predicates to relations via Wasserstein
We describe next how functor liftings to V-Rel can be systematically obtained using the change-of-base situation described above.In particular, we see how the Wasserstein metric between probability distributions (defined in terms of couplings of distributions) can be naturally modelled in the fibrational setting.
Consider a V-predicate lifting F of a Set-functor F .A natural way to lift F to V-relations using F is to regard a V-relation r : X × X → V as a V-predicate on the product X × X. Formally, we will use the isomorphism ι X described in Section 4. We can apply the functor F to the predicate ι X (r) in order to obtain the predicate F • ι X (r) on the set F (X × X).
Ideally, we would want to transform this predicate into a relation on F X.So first, we have to transform it into a predicate on F X × F X. To this end, we use the natural transformation We drop the superscript and simply write λ when the functor F is clear from the context.Additionally, the bifibrational structure of V-Rel plays a crucial role, as we can use the direct image functor Σ λ X to transform F • ι X (r) into a predicate on F X × F X. Putting all the pieces together, we define a lifting of F on the fibre V-Rel X as the composite F X given by: The aim is to define a lifting F of F to V-Rel.The above construction provides the definition of F on the fibres and, in particular, on the objects of V-Rel.For a morphism between V-relations p ∈ V-Rel X and q ∈ V-Rel Y , i.e., a map f : X → Y such that p ≤ f * (q), we define F (f ) as the map F f : F X → F Y .To see that this is well defined it remains to show that F p ≤ (F f ) * (F q).This is the first part of the next proposition.
Proposition 17.The functor F defined above is a well defined lifting of F to V-Rel.Furthermore, when F preserves weak pullbacks and F is a fibred lifting of F to V-Pred, then F is a fibred lifting of F to V-Rel.
Spelling out the concrete description of the direct image functor and of λ X , we obtain for a relation p ∈ V-Rel X and t 1 , t 2 ∈ F X, that Unraveling the definition of F (p)(t) = ev • F (p), we obtain for F (p) the same formula as for the extension of F on V-matrices, as given in [21, Definition 3.4].This definition in [21] is obtained by a direct generalisation of the Barr extensions of Set-functors to the bicategory of relations.In contrast, we obtained (6) by exploiting the fibrational change-of-base situation and by first considering a V-Pred-lifting.
We call a lifting of the form F the Wasserstein lifting of F corresponding to F .This terminology is motivated by the next example.
Example 18.When F = D (the distribution functor), V = [0, 1] and ev F is as in Example 14 then F is the original Wasserstein metric from transportation theory [44], which -by the Kantorovich-Rubinstein duality -is the same as the Kantorovich metric.Here we compare two probability distributions t 1 , t 2 ∈ DX and obtain as a result the coupling t ∈ D(X × X) with marginal distributions t 1 , t 2 , giving us the optimal plan to transport the "supply" t 1 to the "demand" t 2 .More concretely, given a metric d : X × X → V, the (discrete) Wasserstein metric is defined as On the other hand, when ev F is the canonical evaluation map of Example 16 the corresponding V-Rel-lifting F minimizes the longest distance (and hence the required time) rather than the total cost of transport.

Example 19. Let us spell out the definition when
and ev F : P[0, 1] → [0, 1] corresponds to sup, which is clearly monotone and is the canonical evaluation map as in Example 15.
Then, given a metric d : X × X → [0, 1] and X 1 , X 2 ⊆ X, the lifted metric is defined as follows (remember that the order is reversed on [0, 1]): As explained in [6], this is the same as the Hausdorff metric d H defined by: The next lemma establishes that this construction is functorial: liftings of natural transformations to V-Pred can be converted into liftings of natural transformations between the corresponding Wasserstein liftings on V-Rel.
one is also interested in lifting functors to the category of (generalized) pseudo-metric spaces, not just of [0, ∞]-valued relations.This motivates the next question: when does the lifting F restrict to a functor on V-Cat and V-Cat sym ?We have the following characterization theorem, where κ X :

hence F preserves reflexive relations;
If F is a fibred lifting, F preserves weak pullbacks and F (p ⊗ q) ≥ F (p) ⊗ F (q) then F (p • q) ≥ F (p) • F (q), hence F preserves transitive relations; F preserves symmetric relations.
Consequently, when all the above hypotheses are satisfied, then the corresponding V-Rel Wasserstein lifting F restricts to a lifting of F to both V-Cat and V-Cat sym .
For V = [0, ∞], the first condition of Theorem 21 is a relaxed version of a condition in [6, Definition 5.14] used to guarantee reflexivity.The second condition (for transitivity) is equivalent to a non-symmetric variant of a condition in [6] (see Lemma 45 in Appendix B.2.2).
We can establish generic sufficient conditions on a monotone evaluation map ev so that the corresponding V-Pred-lifting F satisfies the conditions of Theorem 21.In Proposition 44 in Appendix B.2.2 we show that An immediate consequence of Proposition 22 and of Theorem 21 is that the Wasserstein lifting F can that corresponds to F can restricts to a lifting of F to both V-Cat and V-Cat sym .

6
Quantitative up-to techniques The fibrational constructions of the previous section provides a convenient setting to develop an abstract theory of quantitative up-to techniques.The coinductive object of interest is the greatest fixpoint of a monotone map b on V-Rel, hereafter denoted by νb.Recall that an up-to technique, namely a monotone map f on V-Rel, is sound whenever It is well-known that compatibility entails soundness.Another useful property is: Following [10], we assume hereafter that b can be seen as the composite where ξ : X → F X is some coalgebra for F : Set → Set.When F admits a final coalgebra ω : Ω → F Ω, the unique morphism !: In the reminder of this section, we focus on quantitative generalizations of the up-to contextual closure technique, which given an algebra α : T X → X, is seen as the composite: T Σα (10)

17:12
Up-To Techniques for Behavioural Metrics via Fibrations Example 24.Consider a signature Σ and the algebra of Σ-terms with variables in X µ X : where C ranges over arbitrary contexts and s i j over terms.Notice that for V = 2, this boils down to the usual notion of contextual closure of a relation.All details are in Appendix B.3.2.
. This can be obtained as in (10) by taking the lifting of D from Example 18 and the algebra given by the multiplication µ X : DDX → DX.All details are in Appendix B. 3

.3.
We consider next systems modelled as bialgebras (X, α : (1) lifts the identity natural transformation on T • F .Its existence is proved using the hypothesis T The next proposition establishes sufficient conditions for the second hypothesis of Theorem 27.We need a property on V that holds for the quantales in Example 6 and was also assumed in [21].Given u, v ∈ V we write u≪v (u is totally below v) if for every W ⊆ V, v ≤ W implies that there exists w ∈ W with u ≤ w.The quantale V is constructively completely distributive iff for all v ∈ V it holds that v = {u ∈ V | u ≪ v}.In Appendix B.3.5 we prove a more general statement in which the lifting of T is not assumed to be the canonical one, that is useful to guarantee the result for interesting liftings, such as the one in Example 18.
Proposition 29.Assume that T preserves weak pullbacks and that V is constructively completely distributive.Then Combining Theorem 27 and Propositions 26, 28 and 29 we conclude: When α is the free algebra for a signature µ X : T Σ T Σ X → T Σ X (as in Example 24), the above theorem guarantees that up-to contextual closure is compatible with respect to b.By (7), the following holds.
For V = 2, since the canonical quantitative lifting coincides with the canonical relational one, then νb is exactly the standard coalgebraic notion of behavioural equivalence [20].Therefore the above corollary just means that behavioural equivalence is a congruence.
For V = [0, ∞] instead, this property boils down to non-expansiveness of contexts with respect to the behavioural metric.It is worth to mention that this property often fails in probabilistic process algebras when taking the standard Wasserstein lifting which, as shown in Example 18, is not the canonical one.We leave as future work to explore the implications of this insight.

7
Example: distance between regular languages We will now work out the quantitative version of the up-to congruence technique for nondeterministic automata.We consider the shortest-distinguishing-word-distance d sdw , proposed in Section 2. As explained, we will assume an on-the-fly determinization of the nondeterministic automaton, i.e., formally we will work with a coalgebra that corresponds to a deterministic automaton on which we have a join-semilattice structure.
We explain next the various ingredients of the example: Coalgebra and algebra.As outlined in Section 2 and Example 3 the determinization of an NFA with state space Q is a bialgebra (X, α, ξ) for the distributive law ζ X : P(2 × X A ) → 2 × (PX) A , where X = PQ, α : PX → X is given by union and ξ : X → 2 × X A specifies the DFA structure of the determinization.Hence, we instantiate the generic results in the previous section with T X = PX, F X = 2 × X A and ζ as defined in Example 3.

Lifting the functors.
We take the quantale V = [0, 1] (Example 6) and consider the Wasserstein liftings of the endofunctors F and T to V-Rel corresponding to the following evaluation maps: where X 1 , X 2 ⊆ X and d H denotes the Hausdorff metric based on d.On the other hand, the Wasserstein lifting of F corresponding to ev F associates to a metric d : Fixpoint equation.The map b for the fixpoint equation was defined in Section 6 as the composite ξ * • F .Using the above lifting F , this computation yields exactly the map b defined in (2), whose largest fixpoint (smallest with respect to the natural order on the reals) is the shortest-distinguishing-word-distance introduced in Section 2. Up-to technique.The next step is to determine the map f introduced in Section 6 for the up-to technique and defined as the composite Σ α • T on V-Rel.Combining the definition of the direct image functors on V-Rel with the lifting T , we obtain for a given a map and a constant r we use the following rules: Lifting of distributive law.In order to prove that the distributive law lifts to V-Rel and hence that the up-to technique is sound by virtue of Proposition 26, we can prove that the two conditions of Theorem 27 are met by the V-Pred liftings of F and T corresponding to the evaluation maps ev F and ev T , see Lemma 55 in Appendix B.4.
Everything combined, we obtain a sound up-to technique, which implies that the reasoning in Section 2 is valid.Furthermore, as the example shows, the up-to technique can significantly simplify behavioural distance arguments and speed up computations.

Related and future work
Up-to techniques for behavioural metrics in a probabilistic setting have been considered in [14] using a generalization of the Kantorovich lifting [13].In Section 6, we have shown that the basic techniques introduced in [14] (e.g., metric closure, convex closure and contextual closure) as well as the ways to combine them (composition, join and chaining) naturally fit within our framework.The main difference with our approach-beyond the fact that we consider arbitrary coalgebras while the results in [14] just cover coalgebras for a fixed functor-is that the definition of up-to techniques and the criteria to prove their soundness do not fit within the standard framework of [35].Nevertheless, as illustrated by a detailed comparison in Appendix A, the techniques of [14] can be reformulated within the standard theory and thus proved sound by means of our framework.An important observation brought to light by compositional methodology inherent to the fibrational approach, is that for probabilistic automata a bisimulation metric up-to convexity in the sense of [14] is just a bisimulation metric, see Lemma 33.Nevertheless, the up-to convex closure technique can find meaningful applications in linear, trace-based behavioural metrics (see [5]).The Wasserstein (respectively Kantorovich) lifting of the distribution functor involving couplings was first used for defining behavioural pseudometrics using final coalgebras in [42].Our work is based instead on liftings for arbitrary functors, a problem that has been considered in several works (see e.g.[21, 3, 6, 26]), despite with different shades.The closest to our approach are [21] and [6] that we discuss next.
In [21] Hofmann introduces a generalization of the Barr extension (of Set-functors to Rel), namely he defines extensions of Set-monads to the bicategory of V-matrices, in which 0-cells are sets and the V-relations are 1-cells.Some of the definitions and techniques do overlap between the developments in [21] and the results we presented in Section 5.However, there are also some (subtle) differences which would not allow us to use off the shelf his results.
First, in order to reuse the results in [10], we need to recast the theory in a fibrational setting, rather than the bicategorical setting of [21].The definition of topological theory [21, Definition 3.1] comprises what we call an evaluation map, but which additionally has to satisfy various conditions.An important difference with what we do is that the condition (Q ) in the aforementioned definition entails that the predicate lifting one would obtain from such an evaluation map would be an opfibred lifting, rather than a fibred lifting as in our setting.Indeed, the condition (Q ) can be equivalently expressed in terms of a natural transformation involving the covariant functor P V , as opposed to the contravariant one V − that we used in Section 5.1.Lastly, in our framework we need to work with arbitrary functors, not necessarily carrying a monad structure.
In [6] we provided a generic construction for the Wasserstein lifting of a functor to the category of pseudo-metric spaces, rather than on arbitrary quantale-valued relations.The realisation that this construction is an instance as a change-of-base situation between V-Rel and V-Pred allows us to exploit the theory in [10] for up-to techniques and, as a side result, provides simpler (and cleaner) conditions for the restriction V-Cat (Theorem 21).
We leave for future work several open problems.What is a universal property for the canonical Wasserstein lifting?Secondly, can the Wasserstein liftings presented here be captured in the framework of [3] or [26]?We also leave for future work the development of up-to techniques for other quantales than 2 and [0, 1].We are particularly interested in weighted automata [18] over quantales and in conditional transition systems, a variant of featured transition systems.

A A detailed comparison with [14]
In this appendix we discuss in details the relationship between our work and [14] where a general framework of up-to techniques for behavioural metric is introduced.The systems of interest in [14] are probabilistic automata which are known [7] to be coalgebras for the functor P(A × D(−)).The behavioural metrics under consideration are defined as the greatest fixed points of b where ξ : X → P(A × D(X)) is a probabilistic automaton, P(A × −) is the canonical lifting of P(A × −) (based on the Hausdorff distance, Example 19) and K is some lifting of D.
Please note that the quantale V in [14] is [0, ∞] (Example 6) so the ordering used in this paper and the one in [14] are always inverted.
Observe that the definition of b as in ( 11) is an instance of (8) by taking F = K •P(A × −).It is worth to mention that K in [14] is not arbitrary, but it is supposed to be an instance of a parametric construction called generalized Kantorovic metric.For a certain value of the parameter, this coincides (via the well known duality) with the Wasserstein metric from transportation theory (Example 18).
The authors of [14] introduced several basic techniques -which can be easily defined in our framework, e.g., metric closure (Section 6), convex closure (Example 25) or contextual closure (Example 24)-and combine them via composition (•), supremum ( ) and chaining ( • ).In Proposition 23, we have provided sufficient conditions ensuring that • preserves compatibility.The same result for • and follows immediately from the standard theory of compatible up-to techniques [35].This is not the case for [14], where these results need novel proofs since the basic notions of up-to techniques and compatibility (or respectfullness) do not fit within the standard lattice-theoretic framework.
Indeed in [14], an up-to technique is defined to be some map f of type V-Rel D(X) → V-Rel D(X) and a bisimulation up-to f to be some d ∈ V-Rel X such that d ≤ (ξ * •P)•f •Kd. 3oundness is defined in the expected way.The notion to prove soundness (Definition 5 in [14]) amounts to the following, modulo the usual difference between compatibility and respectfullness (that is well-known and deeply discussed in several papers [11,34]) Observe that whenever f is well-behaved, a bisimulation up-to f in the sense of [14], can be transformed into a bisimulation up-to f in our sense by mean of the first item: Moreover, thanks to the second item, f is compatible w.r.t.b.This observation shows that the techniques in [14] can be reformulated within the standard theory of [35] and thus proved compatible by means of our framework.

Lemma 33. Consider a probabilistic automaton and let K denote a convex (in the sense of [14]) lifting of the probability distribution functor. Then a bisimulation metric up-to convex closure in the sense of [14] is just a bisimulation metric, i.e., a post-fixpoint of b in (11).
Proof.As above, let ξ : X → P(A × D(X)) denote the coalgebra structure corresponding to the probabilistic automaton.The up-to convex closure is defined as in Example 25.Recall that a bisimulation metric up-to convex closure in the sense of [14] is a bisimulation metric d such that d progresses to cvx • K(d), written using the notation in [14, Definition 2] as Spelling out that definition, we obtain that, in the quantale order (i.e., the reversed of the order on the reals used [14]) we have On the other hand, the respectfulness of cvx-established via [14, Theorem 11]-uses the fact that for all d ∈ V-Rel X we have that K(d) is convex, hence the f used above is simply the identity function on V-Rel DX .In other words we have Combining ( 13) and ( 14) we obtain that or equivalently, that d is simply a bisimulation metric.

B Proofs and additional material B.1 Proofs and additional material for Section 4
We will use the the Beck-Chevalley condition for fibrations p : E → B, which will be needed in some of the proofs.Assume we have a commuting square: Since the fibration is split we have a commuting diagram Using the adjunctions Σ f f * and Σ g g * we obtain the so-called mate of the above square obtained using the unit and the counit of the above adjunctions, as the composite Definition 34.We say that the square (15) has the Beck-Chevalley condition if the mate (16) is an isomorphism.

Example 35.
The bifibration V-Pred → Set has the Beck-Chevalley condition for weak pullback squares in Set.Essentially we have to show that if (15) is a weak pullback, then for every p ∈ V-Pred C and b ∈ B we have Proving ≤ is easy (we just use that the square commutes), but for ≥ we need that (15) is a weak pullback.

B.2 Proofs and additional material for Section 5 B.2.1 V-predicate liftings
In order to state the following proposition we first have to spell out what it means for an evaluation map to be monotone.For this, we first define an (order) relation on F V.

Up-To Techniques for Behavioural Metrics via Fibrations
Definition 36 (Relation on F V). We define a relation on The relation will also be denoted by ≤ F (order ≤ lifted under F via the standard relation lifting).
According to [2] relation lifting transforms preorders into preorders whenever F preserves weak pullbacks (but not necessarily orders into orders).
Proposition 12.There is a one-to-one correspondence between Proof.The equivalence of the first two bullets is well-known in coalgebraic modal logic for V = 2.For the sake of completeness we include here full details.
F is a lifting of F to V-Pred if and only if the following two conditions are met for all sets X and functions f : X → Y : These two conditions alone are equivalent to the laxness of the following square However, F is a fibred lifting of F if and only if item 1 holds and the inequality in item 2 above is in fact an equality.Hence F is a fibred lifting if and only if the above square is actually commutative, which ammounts to the existence of a natural transformation γ : V − → V F − with each component γ X being monotone.
We have thus proved the equivalence of the two first bullets.Now, let us turn to the third one.By Yoneda lemma we know that natural transformations V − → V F − are in one-to-one correspondence with evaluation maps ev : F (V) → V.It remains to characterize the monotonicity condition.We show that this is equivalent to requiring that ev F : F V → V is monotone for the order on F V and ≤ on V. "⇐" Assume that ev F is monotone and take If we apply F to the diagram above and post-compose with F π 1 , F π 2 , ev F , we obtain the following diagram.
Using the monotonicity of ev F we can conclude that "⇒" Assume that F is monotone.In order to show monotonicity of ev Hence ev ), i.e., we have shown that ev F is monotone.
Lemma 37. Assume that T is a monad and V = T Ω a quantale as detailed above.Assume that there is a partial order on Ω such that the lattice order ≤ of the quantale is obtained by lifting under T , i.e., ≤ = T (as in Definition 36).Then ev = µ Ω : (T V, ≤ T ) → (V, ≤) is monotone, and consequently corresponds to a fibred lifting T of T .
Since ≤ is obtained by lifting under T we can infer that there exists a witness function w : ≤ → T ( ) that assigns to every pair of elements → Ω and π i : ≤ → V are the usual projections.
Since t 1 ≤ T t 2 , there exists a witness t ∈ T (≤) with where the first equality holds since µ is a natural transformation.This implies

B.2.2 From predicates to relations via Wasserstein
Proposition 17.The functor F defined above is a well defined lifting of F to V-Rel.Furthermore, when F preserves weak pullbacks and F is a fibred lifting of F to V-Pred, then F is a fibred lifting of F to V-Rel.
Proof.To prove that F is a well defined functor on V-Rel it remains to show that F p ≤ (F f ) * (F q) whenever p ≤ f * q (for f : X → Y ).From the definition of F as given in (5), we know that on each fibre F is monotone, hence F p ≤ F (f * (q)).Hence it suffices to show that This follows from the sequence of (in)equalities ( 18)-( 23), where on each line we underlined the sub-expression that was rewritten and which we will explain in turn.
We obtained (18) and (23) using the definition of F .To derive the equalities in ( 19) and ( 22) we used the fact that ι is a fibred lifting of ∆.The inequality (20) follows from the fact that F is a lifting of F and hence we have the inequality Finally the inequality (21) follows from the commutativity of the naturality squares of λ and the Beck-Chevalley condition (see Appendix B.1): Now let us focus on the second part of the proof.Since F is a fibred lifting by assumption, then the inequality (24) becomes an equality.When the functor F preserves weak pullbacks, then by Lemma 42 we know that the naturality squares of λ are weak pullbacks.Hence, since the fibration V-Rel has the Beck-Chevalley property for weak pullback squares, it follows that (25) is also an equality.We obtain that all the inequalities (18)-( 23) are in fact equalities.This amounts to the fact that F is a fibred lifting.
We now prove Lemma 20: Lemma 20.If there exists a lifting ζ : F ⇒ G of a natural transformation ζ : F ⇒ G, then there exists a lifting ζ : F ⇒ G between the corresponding Wasserstein liftings.Furthermore, when F and G correspond to monotone evaluation maps ev F and ev G , then the lifting ζ exists and is unique if and only if ev Proof.The existence (and in this case uniqueness) of the lifting ζ is equivalent to the fact that F X ≤ (ζ X ) * • G X for all X.This is fairly standard, but we include here an explanation for the sake of completeness.If ζ exists, then for all p ∈ V-Pred X we have the next diagram, where the dashed arrow exists and is unique by the universal property in Definition 4.
Since the fibres in V-Pred are posets, this means that We have to show that Proof.It is easy to verify that the square below is a pullback.
By applying F to the diagram we obtain the diagram below where the square is a weak pullback (since F preserves weak pullbacks).
Using this diagram we can show that the square below is a pullback as well.Assume that . That is, t 1 , t 2 live on the middle level and s 3 , s 2 , s 1 on the lower level (in that order) in the diagram above.Since the square is a weak pullback, there exists t ∈ F (X 3 ) such that F π 2 , π 3 (t) = t 1 and F π 1 , π 2 (t) = t 2 .It remains to verify that ν X (t) = (s 1 , s 2 , s 3 ): Since the Beck-Chevalley condition holds we obtain Then we will apply this to a predicate of the form ⊗ • (u × v) and using the facts

Up-To Techniques for Behavioural Metrics via Fibrations
Whenever f : X → Y , p, p : X → V, y, y ∈ Y , we have (using distributivity): Lemma 41.The lifting preserves symmetric V-valued relations.
Proof.We first observe that the square below commutes.
and that sym X = π 2 , π X 1 , where π X i : X × X → X, we can easily show that the square commutes: We cannot perform a reindexing along sym Y in the fibration V-Rel, since sym Y is not a morphims on Y , but on Y ×Y .Instead, we have that p is symmetric if and only if in V-Pred.Hence, we want to show that for any r ∈ V-Rel X the implication holds We have the following inequalities: F. Bonchi, B. König, D. Petrişan 17:27 However, using the idempotency of sym F X and the monotonicity of (sym F X ) * from the inequality ι F X F r ≤ (sym F X ) * (ι F X F r) that we have just proved above we can infer that the equality also holds.
Lemma 42 (Corollary 2.7 in [21]).If F : Set → Set is weak pullback-preserving, then the naturality squares of the binatural transformation F π 1 d, , F π 2 : F (X × Y ) → F X × F Y are weak pullbacks, where π 1 : X × Y → X and π 2 : X × Y → X denote the projections.In particular, the naturality squares of the natural transformation λ are weak pullbacks.
Proof.Consider morphisms f : X → X and g : Y → Y .We want to prove that the square is a weak pullback.To this end we will consider the following diagram: The three squares above are obtained by applying the functor F to weak pullbacks, hence, by the assumption on F , they are also weak pullbacks.
Assume s ∈ F (X ) and t ∈ F (Y ) are such that there exist s ∈ F (X), t ∈ F (Y ) and From the fact that the lower left square in ( 43) is a weak pullback we infer the existence of u Analoguosly, using that the lower right square in ( 43) is a weak pullback we obtain the existence of u Since the upper square is also a weak pullback, we deduce the existence of we conclude that v is the element we were looking for in F (X × Y ).

17:28
Up-To Techniques for Behavioural Metrics via Fibrations Lemma 43.Assume the functor F preserves weak pullbacks.The map ev can : F V → V is a monotone evaluation map, that is, it is monotone with respect to the order on F V defined in 36 and the order ≤ on V.
Proof.It is suffient to show that ev can : (F V, ) → (V, ≤) is monotone.
Hence, let u 1 , u 2 ∈ F V such that u 1 u 2 , which implies that there exists u ∈ F (V × V) with F π i (u ) = u i , where π i : ≤ → V are the projections.
We have to show that ev can (u 1 ) ≤ ev can (u 2 ).It is sufficient to show that u 1 ∈ F (↑ r) implies u 2 ∈ F (↑ r).Assume r ∈ V is such that u 1 ∈ F (↑ r).Then there exists u 1 ∈ ↑ r such that F true r (u 1 ) = u 1 .Now consider the diagram on the left in (44), where e r : ≤ ↑r → ≤ embeds ≤ restricted to ↑ r into the full relation.Furthermore the functions π i are the projections for ≤ ↑r .This diagram commutes for i = 1, 2 and is a weak pullback for i = 1.
Hence the diagram on the right in ( 44) is also a weak pullback.
We have u 1 ∈ F (↑ r) and u ∈ F (≤) with F true r (u 1 ) = u 1 = F π 1 (u ).Hence there must be an element u ∈ F (≤ ↑r ) with F π 1 (u) = u 1 and F e r (u) = u .We set This means that u 2 ∈ F (↑ r) as required.
Proposition 44.Assume ev : F V → V is monotone evaluation map and let F be the corresponding fibred lifting of F .Then we have: 1. F (p ⊗ q) ≥ F (p) ⊗ F (q) holds whenever the map ⊗ : V × V → V is a lax F -algebra morphism, in the sense that we have a lax diagram: F (κ X ) ≥ κ X holds whenever the map κ 1 : 1 → V is a lax algebra morphism, i.e., we have the lax diagram Proof. 1.We start with the observation that the predicate p⊗q is computed as the composite Upon recalling that F (p) = ev • F (p), we notice that the leftmost path from F X to V in the next diagram evaluates to F (p ⊗ q).Similarly, the rightmost path from F X to V evaluates to F (p) ⊗ F (q). Now, the desired inequality F (p ⊗ q) ≥ F (p) ⊗ F (q) follows using the fact that the upper triangle commutes, the naturality of λ and the lax diagram from the hypothesis.
2. We consider the following diagram or, equivalently, We show how one of the conditions for well-behavedness that we required for the Wasserstein lifting in [6, Definition 5.14] for the quantale V = [0, ∞] is related to the conditions in Proposition 21.Our original condition was d e • (ev ] (which evaluates to d e (r, s) = |r − s| on the reals).This clearly implies the non-symmetric variant stated in the lemma below.Using this, we now aim to show that (48) ⇐⇒ (33).
Using this, the monotonicity of F and (33) (by taking u = [π 1 , π 2 ] : X → V and v = π 1 : X → V) we obtain inequality (48) as follows: The implication (48) =⇒ ( 33) can be shown by rewriting u ⊗ v = π 2 • v, u ⊗ v and then using (48) as follows where the last inequality follows again from monotonicity of F and the definitions of ⊗ and Next we will prove Proposition 22, which captures the properties of the canonical lifting F can .
Proposition 22. Whenever F preserves weak pullbacks the canonical lifting F can satisfies the conditions in Theorem 21: Proof. 1.Given t ∈ F X, we have on one hand that and on the other, that Hence, in order to show the desired inequality it is sufficient to show that Let r, s ∈ V so that F p(t) ∈ F (↑ r) and F q(t) ∈ F (↑ s).Note that p ⊗ q : X → V is the composite: is the composite of the arrows on the top line of the diagram below: Note that the triangle and the square above are commutative.Using the abbreviation θ = F ((p × q) • δ X )(t) we have that: From Lemma 42 we know that the square in the diagram below is a weak pullback.
By hypothesis we know that there exists u ∈ F (↑ r) and v ∈ F (↑ s) such that F p(t) = F true r (u) and F q(t) = F true s (v).Hence Using the fact that the square (51) is a weak pullback, there exists w ∈ F ((↑ r) × (↑ s)) such that F (true r × true s )(w) = θ, F π 1 (w) = u and F π 2 (w) = v.Thus far we have shown that for some w ∈ F ((↑ r) × (↑ s)).To finish the proof of the first item, we will prove that To this end, notice that due to monotonicity of the tensor product, we know that (↑ r) ⊗ (↑ s) ⊆ ↑ (r ⊗ s).Hence, ⊗ : V × V → V restricts to a function ⊗ |↑r,↑s on ↑ r × ↑ s so that the square below commutes.
Now we put z := F (⊗ |↑r,↑s )(w) and observe that The latter inequality, which we have to prove, is in turn equivalent to the inequality obtained by using the isomorphism ι.
The left hand side of the above inequality rewrites using the definitions of the Wasserstein liftings as the composite of the outermost right-then-down path V-Pred ∆X to V-Pred ∆T F X in the next diagram.The right hand side similarly evaluates to the outermost down-then-right path in the diagram.So it suffices to establish the inequality between these two paths.We do this by decomposing the diagram into smaller pieces (see Figure 2) and explaining each inequality in turn.The two inequalities in the top pentagon and top-right square follow from the hypothesis.The two triangles at the bottom are equalities that follow from the fact that The inequality in the left-down square holds since F is a lifting and is obtained via adjoint transposes from (3).Using the naturality of ζ one can show that the next square commutes and hence, the inequality in the bottom rhombus can be derived as an instance of a generic result for bifibrations, see (16).
We now turn to proving Proposition 28.
We will consider the inclusion maps true r : ↑ r → V and write t ∈ F (↑ r) for t ∈ (F ↑ r).
We first consider the diagram below.We will show that the dotted arrow exists and that the resulting square is a weak pullback.
can restricts to ev F can | ↑r .In order to show that the square is a weak pullback take t ∈ F V such that ev F can (t ) = {s | t ∈ F (↑ s)} = s ≥ r.We have to show that t ∈ F (↑ r), i.e., that r is contained in the set, which we will do by showing that {s | t ∈ F (↑ s)} is downward-closed and contains its supremum.The set {s | t ∈ F (↑ s)} is downward-closed since F as a Setfunctor preserves injections with non-empty domains and hence s ≤ s implies ↑ s ⊆ ↑ s and thus t ∈ F (↑ s) ⊆ F (↑ s ).If F preserves intersections, it also contains its supremum: Similarly one obtains such a commuting square (not necessarily a weak pullback) for T and ev T can .This results in the following diagram where the right-hand square and the upper "square" commute and the left-hand square is a weak pullback (using pullback preservation of T ).
In order to prove that So let T ev F can (t) ∈ T (↑ r) and the fact that the left-hand square is a weak pullback implies that there exists t ∈ T F (↑ r) with T F true r (t ) = t.
Then, using naturality of ζ, we obtain

B.3.5 Details on constructively completely distributive quantales
In this appendix, we provide a result (Proposition 51 below) for proving T • Σ f ≤ Σ T f • T that is more general than Proposition 29.This is useful, for instance to prove such property for liftings different than the canonical one.
We assume that the quantale V is constructively completely distributive and we start with two examples of such quantales, in order to give some more intuition.
Example 49.In the reals the order ≪ coincides with > R , whereas in a powerset lattice PM we have that M 1 ≪ M 2 for M 1 , M 2 ⊆ M whenever M 1 ⊆ M 2 and M 1 contains at most one element.Both lattices are constructively completely distributive.
For this more general result, we need some additional properties, in particular the lifting T must preserve a special type of supremum of predicates (even stronger than uniform convergence).
Definition 50.Let (p i : X → V) i∈I be a family of predicates.We call its sup constructivelyconvergent if for every predicate q : X → V with q ≪ i∈I p i (pointwise), there exists i ∈ I with q ≤ p i .Proposition 51.Assume V is a constructively completely distributive quantale and assume T is a lifting a Set-functor T .Then we have that T • Σ f ≤ Σ T f • T whenever either of the conditions below is met f is surjective and T preserves constructively-convergent sups.f is injective, T preserves weak pullbacks, T is a fibred lifting corresonding to an evaluation map ev such that for every t ∈ T V, ev(t) = ⊥ implies t ∈ T (V\{⊥}).(In other words: ev −1 (V\{⊥}) ⊆ T (V\{⊥}).)f is an arbitrary function and all the above properties are satisfied.
Proof.Let f = m • e be the epi-mono factorization of f , i.e., e : X → Z is surjective and m : Z → Y is injective.We will show the inequality separately for m, e, from which we can straightforwardly derive the inequality for f .So Σ e (p) = g∈G p • g = g∈G g * (p) and we show that this sup is constructivelyconvergent.Let q : Z → V with q ≪ Σ e (p).Now for a z ∈ Z we observe that q(z) ≪ e(x)=z p(x) and hence, since we are working in a cccd-lattice, there exists an x z ∈ X with e(x z ) = z and p(x z ) ≥ q(z).On z we define the choice function g as g(z) = x z .
We have e • g = id Z and furthermore for all z ∈ Z we have q(z) ≤ p(x z ) = (p • g)(z), hence q ≤ p • g as desired.
According to our assumption T preserves such suprema and we get: Proof.Recall that on the quantale [0, 1] the quantale order is the reversed order on the reals, so in order to avoid confusion we use ≤, ∨, ∧ in the quantale and ≥ R , inf, sup in the reals.1.To prove the first item, we can rely on Proposition 29, since T can is the canonical lifting and we are working in the quantale V = [0, 1], which is constructively completely distributive.
2. Recall that T • F is a lifting of T • F which corresponds to the evaluation map ev T F = ev T • T (ev F ). Similarly, F • T corresponds to the evaluation map ev F T = ev F • F (ev T ).
The existence of ζ is then equivalent to the inequality Here we are almost in the setting of canonical liftings treated in Proposition 28, apart from the fact that ev F = g • ev F can , where the function g is given by g(r) = c • r.Recall ev T = ev T can .Furthermore T preserves weak pullbacks and F preserves intersections, hence by (the proof of) Proposition 28, we know that In order to obtain the desired lifting of natural transformations, we first notice that ev T can •T g = g • ev T can .Indeed, for all R ⊆ [0, 1] we have To conclude, we use the above equalities and the monotonicity of g:

Figure 1
Figure 1 Example automaton

F
Given fibrations p : E → B and p : E → B and a functor on the base categories F : B → B , we call F : E → E a lifting of F when p F = F p.

Lemma 20 .
If there exists a lifting ζ : F ⇒ G of a natural transformation ζ : F ⇒ G, then there exists a lifting ζ : F ⇒ G between the corresponding Wasserstein liftings.Furthermore, when F and G correspond to monotone evaluation maps ev F and ev G , then the lifting ζ exists and is unique if and only if ev by a topological theory in the sense of [21,Definition 3.1].Since these two are satisfied by the canonical evaluation map ev can , 2 we immediately obtain2 The same observation is present in [21,Theorem 3.3(b)] but in a slightly different setting.

F
Whenever F preserves weak pullbacks the canonical lifting F can satisfies the conditions in Theorem 21: 9)where bhv(p)(x, y) = {p(x , y ) | !(x) = !(x ) and !(y) = !(y)}.For V = 2, behavioural closure corresponds to the usual up-to behavioural equivalence (bisimilarity).Other immediate generalisations are the up-to reflexivity (ref ), up-to transitivity (trn) and up-to symmetry (sym) techniques.Whenever F is obtained through the Wasserstein construction of some F satisfying the conditions of Theorem 21, these techniques are compatible (see Appendix B.3.1 for more details).As usual, compatible techniques can be combined together either by function composition (•) or by arbitrary joins ( ).For instance compatibility of up-to metric closure, defined as the composite mtr = trn • sym • ref follows immediately from compatibility of trn, sym and ref .In V-Rel there is yet another useful way to combine up-to techniques -called chaining in [14] -and defined as the composition ( • ) of relations.
When b and f are as in (8), respectively (10), we use [10, Theorem 2] to obtain Proposition 26.If there exists a lifting ζ : T • F ⇒ F • T of ζ, then f is b-compatible.The next theorem establishes sufficient conditions for the existence of a lifting of ζ.Theorem 27.Assume the natural transformation ζ : T • F ⇒ F • T lifts to a natural transformation ζ : T • F ⇒ F • T and that we have T • Σ λ F X ≤ Σ T λ F X • T .Then ζ lifts to a distributive law ζ : T • F ⇒ F • T .Proof Sketch.Notice that T • F := T • F and F • T := F • T are liftings of the composite functors T • F , respectively F • T .We will denote by T • F and F • T the corresponding Wasserstein liftings obtained from T • F , respectively F • T as in Section 5. We split the proof obligation into three parts:

2 )
is obtained by applying Lemma 20 to ζ.Such liftings have already been studied in[5].(3) lifts the identity natural transformation on F •T .It exists by Lemma 48 in Appendix B.3.4.The first requirement of the previous theorem holds for the canonical V-Pred-liftings under mild assumptions on F and T .Proposition 28.Assume that ζ : T • F ⇒ F • T is a natural transformation and that, furthermore, T preserves weak pullbacks and F preserves intersections.Then ζ lifts to a natural transformation ζ : ev F (b, f ) := c • max a∈A f (a), where b ∈ {0, 1}, f : A → [0, 1] and c is the constant used in d sdw , and, ev T := ev P can = sup, the canonical evaluation map as in Example 15.These are monotone evaluation maps that satisfy the hypothesis of Theorem 21 (see Lemma 54 in Appendix B.4). Hence the corresponding Wasserstein liftings restrict to V-Cat.We computed the Wasserstein lifting of T = P in Example 19: applying the lifted functor T to a map d : X × X → [0, 1], gives us the Hausdorff distance, i.e., T ( since there is a unique morphism in the fibre from F (p) to G(p).For the same reason any two liftings of ζ must coincide.Conversely, if the inequality 48) using For the equivalences (45) ⇐⇒ (46) ⇐⇒ (47) just simple rewriting along with F = ev F • F .For the equivalence (47) ⇐⇒ (48) the tensor property x ⊗ y ≤ z ⇐⇒ x ≤ [y, z].

Figure 2
Figure 2 Existence of the lifting ζ ev T can (T ev F can (t)) = {r | T ev F can (t) ∈ T (↑ r)} and ev F can (F ev T can (ζ V (t))) = {r | F ev T can (ζ V (t)) ∈ F (↑ r)} it suffices to show that T ev F can (t) ∈ T (↑ r) implies F ev T can (ζ V (t)) ∈ F (↑ r) .

F
ev T can (ζ V (t)) = F ev T can (ζ V (T F true r (t ))) = F ev T can (F T true r (ζ ↑r (t ))) = F true r (F (ev T can | ↑r )(ζ ↑r (t ))) ∈ F (↑ r)Proposition 29.Assume that T preserves weak pullbacks and that V is constructively completely distributive.ThenT can • Σ f ≤ Σ T f • T can .Proof.In Appendix B.3.5, we prove a more general result (Proposition 51).Proposition 29 follows thus from Proposition 51, whose conditions are shown to be satisfied by the canonical lifting in Lemmas 52 and 53.

T
• Σ e ≤ Σ T e • T :17:38Up-To Techniques for Behavioural Metrics via FibrationsLet p : X → V, z ∈ Z. Observe that Σ e (p)(z) = {p(x) | e(x) = z} = {(p • g)(z) | g ∈ G} where G = {g : Z → X | e • g = id Z }is the set of all choice functions.Note that the last equality in the displayed equation above requires surjectivity of e, because otherwise no choice functions exist.

T 2 .
(Σ e (p)) = T ( g∈G g * (p)) = g∈G T (g * (p)) ≤ g∈G (T g) * ( T p)We will now show (T g) * ≤ Σ T e as an intermediate result: Let p : T X → V and t ∈ T Z.Then (T g) * (p)(t) = (p • T g)(t) = p(T g(t)) ≤ T e(s)=t p(s) = Σ T e (p)(t) since s = T g(t) satisfies T e(s) = T e(T g(t)) = T id Z (t) = t.This implies g∈G (T g) * ( T p) ≤ g∈G Σ T e ( T p) = (Σ T e • T )(p)By combining everything we obtain the desired result.T • Σ m ≤ Σ T m • T : Let p : Z → V, t ∈ F Y , we have to show that T (Σ m (p))(t) ≤ Σ T m ( T p)(t).We consider the following two cases: t is in the image of T m: in this case there exists s ∈ T X with T m(s) = t.Since m is injective we have that for any y ∈ Y in the image of m Σ m (p)(y) = p(z), where z ∈ Z is the unique preimage of y.Hence Σ m (p) • m = p.Using the fact that we have a fibred lifting (Proposition 12), this means thatT (Σ m (p))(t) = T (Σ m (p))(T m(s)) = T (Σ m (p) • m)(s) = T p(s) ≤ T m(s)=t T p(s) = Σ T m ( T p))(t) t isnot in the image of T m: we show that in this case T (Σ m (p))(t) = ⊥.(The right-hand side of the inequality is also ⊥, due to the empty supremum.)Note that Σ m (p)(y) = ⊥ for all y ∈ Y which are not in the image of m.Now assume that T (Σ m (p))(t) = ⊥.Take the pullback on the left below and observe that Y = {y ∈ Y | Σ m (p)(y) = ⊥} ⊆ m[X].ζ : T • F ⇒ F • T lifts to a natural transformation ζ : T • F ⇒ F • T

Up-To Techniques for Behavioural Metrics via Fibrations
Proposition 28.Assume that ζ : T • F ⇒ F • T is a natural transformation and that, furthermore, T preserves weak pullbacks and F preserves intersections.Then ζ lifts to a natural transformation ζ :T can • F can ⇒ F can • T can .Notice that ev T F and ev F T are exactly the evluation maps corresponding to the liftings T can • F can , respectively F can • T can .Using the second part of Lemma 20, it suffices to show ev