The CTMC-Dist Mathematica package

On-the-fly computation of bisimilarity distances for Continuous-Time Markov Chains

Authors: Giorgio Bacci, Giovanni Bacci, Kim G. Larsen, and Radu Mardare

The following tutorial aims at presenting the main features of the CTMCDist package. This Mathematica package implements three different methods for computing the bisimilarity distance between continuous-time Markov Chains (CTMCs):

iterative method;

linear programming method;

on-the-fly method.

Further details about their implementations can be found in a related technical-report paper Tutorial_CTMCDist_1.gif.

The current package extends the BisimDist Mathematica library Tutorial_CTMCDist_2.gif to continuous-time Markov chains, and is inspired from prevoius work on bisimilarity distances on Markov chains Tutorial_CTMCDist_3.gif Tutorial_CTMCDist_4.gif.

Preliminaries

Continuous-Time Markov Chains and Stochastic Bisimilarity

Definition (Continuous-time Markov chain). An L-labelled continuous-time Markov chain (CTMC) is a tuple M = (S, A, τ, ρ, ℓ) consisting of a nonempty finite set S of states, a set A ⊆ S of absorbing states, a transition probability function τ : S\A → D(S) (where D(S) is the set of probability distributions over S), an exit-rate function ρ : S\A → Tutorial_CTMCDist_5.gif, and a labelling function ℓ : S → L.

The labels L represent properties of interest that hold in a partucular state according to the labelling function ℓ. If s ∈ S is the current state of the system and E ⊆ S is a subset of states, τ(s)(E) ∈ [0,1] corresponds to the probability that a transition from s to arbitrary s’∈ E is taken, and ρ(s) ∈ Tutorial_CTMCDist_6.gif represents the rate of an exponentially distributed random variable that characterizes the residence time in the state s before any transition is taken. Therefore, the probability to make a transition from stete s to s’∈ E within time unit t∈ Tutorial_CTMCDist_7.gifis given by τ(s)(E) ·Tutorial_CTMCDist_8.gif  for any Borel subset E ⊆ Tutorial_CTMCDist_9.gif.

Definition (Stochastic Bisimulation). Let M = (S, A, τ, ρ, ℓ) be an CTMC. An equivalence relation R ⊆ S × S is a stochastic bisimulation on M if whenever (s,t) ∈ R, then the following hold

ℓ(s) = ℓ(t);

s ∈ A  iff  t ∈ A;

if s,t ∉ A then ρ(s) = ρ(t) and, for all R-equivalence class C, τ(s)(C) = τ(t)(C).

Intuitively, two states are bisimilar if they have the same labels, they agree on being absorbing or not, and, in the case they are non-absorbing, their residence-time distributions and probability of moving by a single transition to any given class of bisimilar states is always the same.

Two states s,t ∈ S are bisimilar with respect to M, written s ∼ t, if they are related by some stochastic bisimulation on M.

Bisimilarity Pseudometric

Following the approach of Tutorial_CTMCDist_10.gif , given a CTMC M = (S, A, τ, ρ, ℓ) we define 1-bounded pseudometric on S as the least fixed point of an operator on the set S × S → [0,1]. This pseudometric is then shown to be adequate with respect to stochastic bisimilarity: it has been proved that two states are stochastic bisimilar if and only if they have distance zero.

The operator uses three key ingredients. The first one is a 1-bounded metric on the set of labels

Tutorial_CTMCDist_11.gif

a distance between residence-time distributions, and a distance beween transition ditributions. The first is meant to measure the static differences with respect to the labels associated with the states, the last two are meant to capture the differences in the dynamics, respectively, with respect to the continuous and discrete probabilistic choices.
To this end, we consider two distances over probability distributions. The first one is the so called total variation metric, defined for arbitrary distributions, μ,ν ∈ D(Tutorial_CTMCDist_12.gif) as

Tutorial_CTMCDist_13.gif

where the supremum is taken over the Borel measurable sets of Tutorial_CTMCDist_14.gif. The second one is the Kantorovich distance, that for arbitrary distributions μ,ν ∈ D(S) is defined as

Tutorial_CTMCDist_15.gif

Intuitively, Tutorial_CTMCDist_16.gif lifts a (1-bounded) distance over S to a (1-bounded) distance over probability distributions. One can show that Tutorial_CTMCDist_17.gifis a (pseudo)metric if d is a (pseudo)metric.
Now, we consider the following functional operator from which we will induce the bisimilarity distance

Definition. Let M = (S, A, τ, ρ, ℓ) be an CTMC and λ ∈ (0,1) a discount factor. The λ-discounted bisimilarity pseudometric for M, written Tutorial_CTMCDist_18.gif, is the least fixed point of the function Tutorial_CTMCDist_19.gif : (S × S → [0,1]) → (S × S → [0,1]), defined, for d : S × S → [0,1] and s,t ∈ S, as

Tutorial_CTMCDist_20.gif

where T : (S × S → [0,1]) → (S × S → [0,1]) and L, E : S × S → [0,1] are respectively defined as

Tutorial_CTMCDist_21.gif

Tutorial_CTMCDist_22.gif

Tutorial_CTMCDist_23.gif

The functional Tutorial_CTMCDist_24.gif measures the differences of two states with respect to: their labels (by means of the pseudometric L), their residence-time distributions (by means of the pseudometric E), and their discrete probabilities to move to the next state (by means of the Kantorovich distance). If two states disagree on been absorbing (or not) they are considered incompatible, and their distance is set to 1. If both states are absorbing, they express no dynamic behavior, hence they are compared statically, and their distance corresponds to that occurring between their respective labels. Finally, if the states are non-absorbing, then they are compared with respect to both their static and dynamic features, namely, taking the maximum among their respective associated distances.

It has been shown that Tutorial_CTMCDist_25.gif for arbitrary discount factors, is adequate with respect to stochastic bisimilarity, that is Tutorial_CTMCDist_26.gif(s,t) = 0 if and only if s and t are stochastic bisimilar, s ∼ t.

Loading the package

The package can be loaded by setting the current directory to that of the CTMCDist package and then using the commad << (Get) as follows. Here we use the directory of the current Mathematica notebook, referred by NotebookDirectory.

Tutorial_CTMCDist_27.gif

Encoding Continuous-Time Markov Chains

A CTMC M = (S, A, τ, ρ, ℓ) with Tutorial_CTMCDist_28.gif is represented by a term of the form CTMC[τ,ℓ,ρ,absQ]

Tutorial_CTMCDist_29.gif

Tutorial_CTMCDist_30.gif

The set of states Tutorial_CTMCDist_31.gif can be represented symbolically; a probability distribution D(S) is encoded as a list of rules Tutorial_CTMCDist_32.gif, where Tutorial_CTMCDist_33.gif is the probability associated with Tutorial_CTMCDist_34.gif; and absQ represent the characteristic function such that absQ[Tutorial_CTMCDist_35.gif] iff Tutorial_CTMCDist_36.gif A.

For example we can encode a CTMC m by defining τ,ρ,ℓ, and absQ, as follows:

Tutorial_CTMCDist_37.gif

The CTMC m can is displayed by means of its undelying graph. Different labels are associated with different colors.

Tutorial_CTMCDist_38.gif

Tutorial_CTMCDist_39.gif

Tutorial_CTMCDist_40.gif

Tutorial_CTMCDist_41.gif

Computing the behavioral distance Tutorial_CTMCDist_42.gif

On-the-fly method

Given a CTMC m, a discount factor λ ∈ (0,1), and a list of pairs of states Q, one can compute the bisimilarity distance between the pairs listed in Q by calling the function BDistCTMC as follows

Tutorial_CTMCDist_43.gif

Tutorial_CTMCDist_44.gif

The Verbose option may be used to trace the computation steps

Tutorial_CTMCDist_45.gif

Tutorial_CTMCDist_46.gif

Tutorial_CTMCDist_47.gif

Tutorial_CTMCDist_48.gif

Tutorial_CTMCDist_49.gif

Tutorial_CTMCDist_50.gif

Tutorial_CTMCDist_51.gif

Tutorial_CTMCDist_52.gif

Tutorial_CTMCDist_53.gif

Tutorial_CTMCDist_54.gif

Tutorial_CTMCDist_55.gif

Tutorial_CTMCDist_56.gif

Tutorial_CTMCDist_57.gif

Tutorial_CTMCDist_58.gif

Tutorial_CTMCDist_59.gif

Tutorial_CTMCDist_60.gif

Tutorial_CTMCDist_61.gif

Tutorial_CTMCDist_62.gif

Tutorial_CTMCDist_63.gif

Tutorial_CTMCDist_64.gif

Tutorial_CTMCDist_65.gif

For computing the distance between all pair of states one can use as query list AllPairs[S]

Tutorial_CTMCDist_66.gif

Tutorial_CTMCDist_67.gif

Iterative method

A second approach to compute the bisimilarity distance is given by computing an under-approximation by iterating the operator Tutorial_CTMCDist_68.gif a number of times. To this end, the CTMCDist package provides the function IterativeAlg

Tutorial_CTMCDist_69.gif

Tutorial_CTMCDist_70.gif

for example, we can compute the 10th iterate of Tutorial_CTMCDist_71.gif by executing the following expression. One can set the number of performed iterations using the option IterationLimit

Tutorial_CTMCDist_72.gif

Tutorial_CTMCDist_73.gif

Linear Programming method

The third approach for computing the bisimilarity distance consists in solving the linear program that characterizes the distance.

The CTMCDist package provides the function LPMethod that generates the LP program and uses the built-in funtion LinearProgramming

Tutorial_CTMCDist_74.gif

Tutorial_CTMCDist_75.gif

Tutorial_CTMCDist_76.gif

Tutorial_CTMCDist_77.gif

Tutorial_CTMCDist_78.gif

Tutorial_CTMCDist_79.gif

Bisimilarity Distance and Bisimilarity Quotient

Due to the fact that Tutorial_CTMCDist_80.gif(s,t) equals zero if and only if the states s and t are bisimilar, Tutorial_CTMCDist_81.gif can be used to compute the bisimilarity classes and the bisimilarity quotient for a given CTMC.

The CTMCDist package provides the functions BisimClassesCTMC and BisimQuotientCTMC that respectively computes the bisimilarity classes and the bisimilarity quotient of a given CTMC.

Tutorial_CTMCDist_82.gif

Tutorial_CTMCDist_83.gif

Tutorial_CTMCDist_84.gif

Tutorial_CTMCDist_85.gif

For example, using the function BisimClassesCTMC one can compute the bisimilarity classes of the CTMC m.

Tutorial_CTMCDist_86.gif

Tutorial_CTMCDist_87.gif

here we can see that Tutorial_CTMCDist_88.gifTutorial_CTMCDist_89.gif and Tutorial_CTMCDist_90.gifTutorial_CTMCDist_91.gif. Therefore we can lump together bisimilar states obtaining a minimized version of the CTMC that is behaviorally equivalent to m. This can be done using the function BisimQuotientCTMC as follows.

Tutorial_CTMCDist_92.gif

Tutorial_CTMCDist_93.gif

Examples

Example 1

Here we repropose Example 5.1 formTutorial_CTMCDist_94.gif.

Tutorial_CTMCDist_95.gif

Tutorial_CTMCDist_96.gif

Let us compute the undiscouted distance between the state Tutorial_CTMCDist_97.gif and Tutorial_CTMCDist_98.gif, namely Tutorial_CTMCDist_99.gif

Tutorial_CTMCDist_100.gif

Tutorial_CTMCDist_101.gif

Tutorial_CTMCDist_102.gif

Tutorial_CTMCDist_103.gif

Tutorial_CTMCDist_104.gif

Tutorial_CTMCDist_105.gif

Tutorial_CTMCDist_106.gif

Tutorial_CTMCDist_107.gif

Tutorial_CTMCDist_108.gif

Tutorial_CTMCDist_109.gif

Tutorial_CTMCDist_110.gif

Tutorial_CTMCDist_111.gif

Tutorial_CTMCDist_112.gif

Tutorial_CTMCDist_113.gif

Tutorial_CTMCDist_114.gif

Tutorial_CTMCDist_115.gif

Tutorial_CTMCDist_116.gif

Tutorial_CTMCDist_117.gif

Tutorial_CTMCDist_118.gif

Tutorial_CTMCDist_119.gif

Tutorial_CTMCDist_120.gif

Looking at the execution trace we see that during the computation of d(s1,s4) an over-approximation for the distance beween the pairs {(s1,s2),(s1,s4),(s2,s3),(s2,s4)} is demanded. Since, the λ-discrepancy for (s2, s3), (s2, s4), and (s1, s2) equals the distance L between their labels, it coincides with the bisimilarity distance, hence it cannot be further decreased. Consequently, those values will be stored and successively used to cut further the searching space.
This can be seen in the second coupling structure, where only the input pair is demanded for computing the associated λ-discrepancy.

The following execution trace shows that the exact computation of Tutorial_CTMCDist_121.gif demands for the pairs {(s1,s2),(s1,s4),(s2,s3),(s2,s4)} as in the previous example. Here insted we immediately note that the λ-discrepancy for (s2, s4) equals the distance L between their labels, therefore, we can terminate the computation even before checking for some other coupling structures.

Tutorial_CTMCDist_122.gif

Tutorial_CTMCDist_123.gif

Tutorial_CTMCDist_124.gif

Tutorial_CTMCDist_125.gif

Tutorial_CTMCDist_126.gif

Tutorial_CTMCDist_127.gif

Tutorial_CTMCDist_128.gif

Tutorial_CTMCDist_129.gif

Tutorial_CTMCDist_130.gif

Tutorial_CTMCDist_131.gif

Tutorial_CTMCDist_132.gif

Tutorial_CTMCDist_133.gif

Tutorial_CTMCDist_134.gif

Tutorial_CTMCDist_135.gif

Tutorial_CTMCDist_136.gif

Bibliography

    1    Giorgio Bacci, Giovanni Bacci, Kim G. Larsen, and Radu Mardare. On-the-fly computation of Bisimilarity Distances. Submitted to LMCS for the special issue of TACAS 2013.

    2    Giorgio Bacci, Giovanni Bacci, Kim G. Larsen, and Radu Mardare. The BisimDist Library: Efficient Computation of Bisimilarity Distances for Markovian Models.
In QEST 2013, volume 8054 of LNCS, pages 278-281, Springer Berlin Heidelberg, 2013.

    3    Di Chen, Franck van Breugel, and James Worrell. On the Complexity of Computing Probabilistic Bisimilarity. In FoSSaCS 2012, volume 7213 of LNCS, pages 437–451. Springer, 2012.

    4    Giorgio Bacci, Giovanni Bacci, Kim G. Larsen, and Radu Mardare. On-the-Fly Exact Computation of Bisimilarity Distances. In TACAS, volume 7795 of Lecture Notes in Computer Science, pages 1–15, 2013.

    5    Franck van Breugel, Claudio Hermida, Michael Makkai, and James Worrell. Recursively defined metric spaces without contraction. Theoretical Computer Science, 380(1-2):143–163, 2007

    6    Giorgio Bacci, Giovanni Bacci, Kim G. Larsen, and Radu Mardare. On-the-fly computation of Bisimilarity Distances. Submitted to LMCS for the special issue of TACAS 2013.

Spikey Created with Wolfram Mathematica 9.0