---
abstract: |
    The problem of inclusion of the language accepted by timed automaton $A$ (e.g., the implementation) in the language accepted by $B$ (e.g., the specification) is, in general, undecidable in the class of non-deterministic timed automata. In order to tackle this disturbing problem we show how to effectively construct deterministic timed automata ${{A}_d}$ and ${{B}_d}$ that are discretizations (digitizations) of the non-deterministic timed automata $A$ and $B$ and differ from the original automata by at most $\frac{1}{6}$ time units on each occurrence of an event. Language inclusion in the discretized timed automata is decidable and it is also decidable when instead of ${\mathfrak{L}}(B)$ we consider $\overline{{\mathfrak{L}}(B)}$, the closure of ${{\mathfrak{L}}(B)}$ in the Euclidean topology: if ${\mathfrak{L}}({{A}_d}) \nsubseteq {\mathfrak{L}}({{B}_d})$ then ${\mathfrak{L}}(A) \nsubseteq {\mathfrak{L}}(B)$ and if ${\mathfrak{L}}({{A}_d}) \subseteq {\mathfrak{L}}({{B}_d})$ then ${\mathfrak{L}}(A) \subseteq \overline{{\mathfrak{L}}(B)}$.

    Moreover, if ${\mathfrak{L}}({{A}_d}) \nsubseteq {\mathfrak{L}}({{B}_d})$ we would like to know how far away is ${\mathfrak{L}}({{A}_d})$ from being included in ${\mathfrak{L}}({{B}_d})$. For that matter we define the distance between the languages of timed automata as the limit on how far away a timed trace of one timed automaton can be from the closest timed trace of the other timed automaton. We then show how one can decide under some restriction whether the distance between two timed automata is finite or infinite.
address: 'Graz University of Technology, Steyrergasse 30, A-8010 Graz, Austria'
author:
- Amnon Rosenmann
bibliography:
- 'ta.bib'
title: On the Distance between Timed Automata
---

Introduction {#sec:intro}
============

Timed automaton (TA) was introduced by Alur and Dill [@ta] as an abstract model for real-time systems by extending finite automaton with continuous clocks. When the ${\mathrm{TA}}$s are non-deterministic then a fundamental problem of language inclusion is, in general, undecidable, for example, whether the set of timed traces of the ${\mathrm{TA}}$ representing the implementation is included in that of the specification. This lead to imposing restrictions on and modifications to non-deterministic TAs in order to achieve decidability (see [@bbbb; @ta-eps; @era; @updatable-ta; @Ouak_one_clk; @Ouak_time_bound; @bounded-time; @Dec_TA_Survey; @bound-det] for a partial list). Another approach was to allow robustness in the language [@GHJ97] or perturbations in the clocks [@purturbed-ta] (see also [@BMS15]). The problem is that by allowing a fixed imprecision, undecidability problems due to working over continuous time do not vanish.

Digitization of timed systems, where basic decision problems like language inclusion are decidable, was considered, for example, in [@HMP92; @O02; @OW03]. But, as stated in [@OW03], the implementation should be ’closed under digitization’ and the specification should be ’closed under inverse digitization’ in order to be able to reduce the language inclusion problem from the continuous world to the discretized one. In [@irta] the authors construct TAs with reset only on integral time and demonstrate the decidability of the language inclusion problem ${\mathfrak{L}}(A) \subseteq {\mathfrak{L}}(B)$ in case $B$ is an integer reset TA. In this paper we go further with this approach. The idea is to work in the setting of discretized time, but without restricting or modifying the definition of a TA. The discretization is over intervals which are smaller than 1 time unit so that although we work in the discretized setting we are able to check for exact occurrence of events also outside integral time. For this matter we construct discretized TAs that enable effective comparison of the languages of the original TAs. The discretized TA stays within a distance of $\frac{1}{6}$ time units from the original TA (the distance can, in fact, be as small as we like, in the cost of complexity, but that won’t improve our knowledge about the inclusion of the languages of the original automata), a goal that is achieved through the introduction of an additional clock, $t$, that measures absolute time. Now, instead of comparing directly the language of two TAs, a problem which is in general undecidable, we can compare their discretized TAs and have the following (see Theorem \[th:inclusion\_gap\]): if ${\mathfrak{L}}({{A}_d})$, the language of the discretized TA of $A$, is not included in ${\mathfrak{L}}({{B}_d})$, the language of the discretized TA of $B$, then the same holds for ${\mathfrak{L}}(A)$ with respect to ${\mathfrak{L}}(B)$. If, however, ${\mathfrak{L}}({{A}_d}) \subseteq {\mathfrak{L}}({{B}_d})$ then ${\mathfrak{L}}(A)$ is included in the topological closure of ${\mathfrak{L}}(B)$.

The next natural question, in case ${\mathfrak{L}}(A) \nsubseteq {\mathfrak{L}}(B)$, is how far away is a timed trace of ${\mathfrak{L}}(A)$ from all timed traces of ${\mathfrak{L}}(B)$, that is, what is the conformance distance $c({\mathfrak{L}}(A), {\mathfrak{L}}(B))$, the distance of ${\mathfrak{L}}(A)$ from being conformed with ${\mathfrak{L}}(B))$. When an untimed word of ${\mathfrak{L}}(A)$ is not in ${\mathfrak{L}}(B)$ or when a transition in $A$ which is not bound in time is not met with a similar transition in ${\mathfrak{L}}(B)$ of the same action label then $c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) = \infty$ and the existence of these cases is decidable. A more challenging question is whether there is a sequence of timed traces of ${\mathfrak{L}}(A)$ which tend to diverge from ${\mathfrak{L}}(B)$, causing $c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) = \infty$. For example, it may happen that due to imprecisions or delays in a real system, a TA model is changed to allow wider time intervals around actions compared to the more idealistic previous model. It is then necessary to check whether or not this extended freedom is controlled and the distance between the two TAs stays within a reasonable bound (see [@BMS15] regarding an ideal model versus a realistic model). Moreover, an algorithm based on the approach suggested here may find the timed traces that deviate from the allowed distance between two timed languages. Further applications for computing the distance may be when safety properties include time restrictions for specific set of timed traces, given as timed automata, and we want to check these timed traces with respect to the implementation model. In general, in a design of a computerized system, e.g. a network, that contains timing changes, a relaxed equivalence verification may allow bounded perturbations in time that needed to be checked.

Computing the distance between TAs (or their languages), even between discretized TAs, may be quite complex. Here we concentrate on the problem of deciding whether the distance is infinite. It is not clear to us whether this problem is decidable in general, but for a (perhaps) restricted version of it we construct an algorithm that solves it.

Timed Automaton {#sec:ta}
===============

A timed automaton is an abstract model of temporal behavior of real-time systems. It is a finite automaton with *locations* and *transitions* between them, extended with a finite set of (continuous) clocks defined over ${\mathbb{R}_{\geq 0}}$. A transition at time $t$ can occur only if the condition expressed as a *transition guard* is satisfied at $t$. A transition guard is a conjunction of constraints of the form ${c}\sim n$, where ${c}$ is a clock, $\sim \ \in \{<,\leq, =,\geq, >\}$ and $n \in {\mathbb{N}_0}= {\mathbb{N}}\cup \{0\}$. Each transition is labeled by some *action* $a \in {\Sigma}$ and some of the clocks may be reset to zero. In ${\mathrm{NTA}}$, the class of non-deterministic timed automata, and unlike deterministic TAs, it may occur that two transitions from the same location $q$ can be taken at the same time and with the same action but to two different locations $q'$ and $q''$.

\[def:ntaeps\] A *non-deterministic timed automaton* $A \in {\mathrm{NTA}}$ is a tuple $({\mathcal{Q}}, q_0, {\mathcal{F}}, {\Sigma}, {\mathcal{C}},
{\mathcal{T}})$, where:

1.  ${\mathcal{Q}}$ is a finite set of locations and $q_0 \in {\mathcal{Q}}$ is the initial location;

2.  ${\mathcal{F}}\subseteq {\mathcal{Q}}$ is the set of accepting locations;

3.  ${\Sigma}$ is a finite set of transition labels, called actions;

4.  ${\mathcal{C}}$ is a finite set of clock variables;

5.  ${\mathcal{T}}\subseteq {\mathcal{Q}}\times {\Sigma}\times {\mathcal{G}}\times {\mathcal P \left({{\mathcal{C}}}\right) } \times {\mathcal{Q}}$ is a finite set of transitions of the form $(q, a, g, {\mathcal{C}_{rst}}, q')$, where:

    1.  $q,q' \in {\mathcal{Q}}$ are the source and the target locations respectively;

    2.  $a \in {\Sigma}$ is the transition action;

    3.  $g \in  {\mathcal{G}}$ is the *transition guard*;

    4.  ${\mathcal{C}_{rst}}\subseteq {\mathcal{C}}$ is the subset of clocks to be reset.

A clock *valuation* $v ({c})$ is a function $v:{\mathcal{C}}\to {\mathbb{R}_{\geq 0}}$. We denote by ${\mathcal{V}}$ the set of all clock valuations and by $\textbf{d}$ the valuation which assigns the value $d$ to every clock. Given a valuation $v$ and $d \in {\mathbb{R}_{\geq 0}}$, we define $v+d$ to be the valuation $(v+d)({c}) := v({c})+d$ for every $ {c}\in {\mathcal{C}}$. The valuation $v[{\mathcal{C}_{rst}}]$, ${\mathcal{C}_{rst}}\subseteq {\mathcal{C}}$, is defined to be $v[{\mathcal{C}_{rst}}](c) = 0$ for $c \in {\mathcal{C}_{rst}}$ and $v[{\mathcal{C}_{rst}}](c) = v(c)$ for $c \notin {\mathcal{C}_{rst}}$.

The *semantics* of $A \in {\mathrm{NTA}}$ is given by the *timed transition system* $[[A]] = (S, s_0, {\mathbb{R}_{\geq 0}}, {\Sigma}, T)$, where:

1.  $S = \{(q,v) \in {\mathcal{Q}}\times {\mathcal{V}}\}$ is the set of states, with $s_0 = (q_0, {\textbf{0}})$ the initial state;

2.  $T \subseteq S \times ({\Sigma}\cup {\mathbb{R}_{\geq 0}}) \times S$ is the transition relation. The set $T$ consists of

    1.  *Timed transitions (delays):* $(q,v) \xrightarrow{d} (q, v+d)$, where $d \in {\mathbb{R}_{\geq 0}}$;

    2.  *Discrete transitions (jumps):* $(q,v) \xrightarrow{a} (q',v')$, where $a \in {\Sigma}$ and there exists a transition $(q, a, g, {\mathcal{C}_{rst}}, q')$ in ${\mathcal{T}}$, such that the valuation $v$ satisfies the guard $g$ and $v' = v[{\mathcal{C}_{rst}}]$.

A (finite) *run* $\varrho$ on $A \in {\mathrm{eNTA}}$ is a sequence of alternating timed and discrete transitions of the form $$(q_{0}, {\textbf{0}}) \xrightarrow{d_{1}} (q_{0}, \textbf{d}_1) \xrightarrow{a_{1}} (q_{1}, v_{1}) \xrightarrow{d_{2}} \cdots 
\xrightarrow{d_{k}} (q_{k-1}, v_{k-1} + d_{k}) \xrightarrow{a_{k}} (q_{k}, v_{k}).$$ The run $\varrho$ on $A$ induces the *timed trace* (*timed word*) $$\tau = (t_{1}, a_{1}), (t_{2}, a_{2}), \ldots, (t_{k}, a_{k}),$$ with $a_i \in {\Sigma}$ and $t_{i} = \Sigma_{j=1}^{i} d_i$. The language ${\mathfrak{L}}(A)$ consists of the set of timed traces that are obtained from the runs that end in accepting locations. We remark that for simplification of presentation we did not include the location invariants in the definition of timed automata since they are more of a ’syntactic sugar’: the invariants of location $q$ are composed of upper bounds to the values of the clocks while being in $q$, but these constraints can be incorporated in the transition guards to $q$ (for the clocks that are not reset at the transitions) and in those transitions that emerge from $q$, thus not affecting ${\mathfrak{L}}(A)$.

Augmented Region Automaton {#sec:ARA}
==========================

Given a (finite) timed automaton $A$, the region automaton ${\mathfrak{R}}(A)$ [@ta] is a finite *discretized* version of $A$, such that time is abstracted and both automata define the same untimed language. Instead of looking at the clocks-space as a continuous space it is partitioned into regions. Suppose that the maximal integer appearing in the transition guards of $A$ is $M$, then we denote by $\top$ a value of a clock which is greater than $M$. The regions partition the space of clock valuations into equivalent classes, where two valuations belong to the same equivalent class if and only if they agree on the clocks with $\top$ value and on the integral parts and the order among the fractional parts of the other clocks. The edges of ${\mathfrak{R}}(A)$ are labeled by the transition actions and they correspond to the actual transitions that occur in the runs on $A$.

The *augmented region automaton*, denoted ${\mathfrak{R}^t}(A)$, is defined as in [@R19]. First, we add to $A$ a clock $t$ that measures absolute time, is never reset to $0$ and does not affect the runs and timed traced of $A$. Secondly, we want to construct ${\mathfrak{R}^t}(A)$ in a way that keeps track of absolute time and regain much of the information that is lost when passing from the timed automaton $A$ to the regular region automaton ${\mathfrak{R}}(A)$. But since $t$ does not appear in the transition guards of $A$, we need not know the exact value of the integral part of $t$ but just how much time passes between two consecutive transitions. Thus, we assign $t$ in ${\mathfrak{R}^t}(A)$ only two time-regions: $\{0\}$ and $(0,1)$. However, in order to keep track of the absolute time that passes, each edge is assigned a ’weight’, the time difference in the integral part of $t$ between the target and the source regions. The ordering among the fractional part of the clocks does, however, take that of $t$ into account. Overall, the number of regions of ${\mathfrak{R}^t}(A)$ is clearly finite (although potentially exponentially large).

\[def:aug\_region\_automaton\] Given a non-deterministic timed automaton $A$ with clocks $x_1, \ldots, x_s$ extended with absolute-time clock $t$, a corresponding augmented region automaton ${\mathfrak{R}^t}(A)$ is a tuple $({\mathcal{V}}, v_0, {\mathcal{E}}, {\Sigma}, {\mathcal{W}}^*)$, where:

1.  ${\mathcal{V}}$ is the set of vertices. Each vertex is a triple $(q, {\bf n}, \Delta)$, where $q$ is a location of $A$ and $r=({\bf n}, \Delta)$ is a region, with ${\bf n} = (n_1, \ldots, n_s) \in \{0, 1, \ldots, M, \top \}^{s}$ consisting of the integral parts of the clocks $x_1, \ldots, x_s$ and $\Delta$ is the simplex (hyper-triangle) with vertices in the lattice ${\mathbb{N}_0}^{s+1}$ of all points that satisfy a fixed ordering of the fractional parts of the clocks $t=x_0, x_1, \ldots, x_s$: $$\label{eq:simplex}
            0 \preceq_0 {\left\{{x_{i_0}}\right\}} \preceq_1 {\left\{{x_{i_1}}\right\}} \preceq_2 \cdots \preceq_s {\left\{{x_{i_s}}\right\}} < 1,$$ where $\preceq_i \, \in \{=, < \}$.

2.  $v_0 = (q_0, {\bf 0}, {\bf 0})$ is the initial vertex, where $q_0$ is the initial location of $A$ and $({\bf 0}, {\bf 0})$ indicates that all clocks have value $0$.

3.  ${\mathcal{E}}$ is the set of edges. There is an edge $(q, r) \xrightarrow{a} (q',r')$ if and only if there is a run on $A$ containing $(q, v) \xrightarrow{d} (q, v + d) \xrightarrow{a} (q', v')$, such that, the clock valuation $v$ is in the region $r$ and $v'$ is in $r'$.

4.  ${\Sigma}$ is the finite set of actions.

5.  ${\mathcal{W}}^*$ is the set of weights $m$ on the edges calculated as $m = \lfloor t_1 \rfloor - \lfloor t_0 \rfloor \in [0..M]$, where $\lfloor t_1 \rfloor$ ($\lfloor t_0 \rfloor$) is the integral part of $t$ in the target (source) location in a corresponding run on $A$. There may be more than one edge between two vertices of ${\mathfrak{R}^t}(A)$, each one with a distinguished weight. A weight $m$ may be marked as $m^*$, representing infinitely-many consecutive values $m$, $m+1$, $m+2, \ldots$ as weights between the same two vertices, for example when the regular clocks passed the maximal value $M$.

An augmented region automaton can be seen in Fig. \[fig:disc\_ta\](b) (the example is taken from [@ta]).

Discretized Timed Automaton {#sec:Approx}
===========================

After constructing the augmented region automaton ${\mathfrak{R}^t}(A)$, we turn it into a deterministic timed automaton ${{A}_d}$ which discretizes (digitizes) $A$.

\[def:appta\] A *discretized timed automaton* ${{A}_d}$ is a timed automaton constructed from the augmented region automaton ${\mathfrak{R}^t}(A)$ in the following way.

1.  The directed graph structure of locations and edges of ${{A}_d}$ is the same as that of ${\mathfrak{R}^t}(A)$.

2.  The transition labels (actions) are also as in ${\mathfrak{R}^t}(A)$.

3.  There is a single clock in ${{A}_d}$, namely $t$, which is reset on each transition.

4.  The transition guards of ${{A}_d}$ are of the following form. Let $e = v_0 \to v_1$ be an edge of ${\mathfrak{R}^t}(A)$, let $w(e)$ be its weight and let $\{t_0\}, \{t_1\} \in [0,1)$ be any fractional parts of $t$ in the source and target regions. Let $$\delta = \frac{1}{2}(\lceil \{t_1\} \rceil - \lceil \{t_0\} \rceil) \in \{-\frac{1}{2},0,\frac{1}{2}\},$$ where $\lceil \{t_i\} \rceil \in \{0,1\}$ is the ceiling function applied to $t_i$. Then, we set the transition guard of the corresponding edge of ${{A}_d}$ to be $$t =  w(e) + \delta.$$ In case of a weight $w(e) = m^*$ then the transition guard is $$t \geq m+\delta.$$

A discretized timed automaton can be seen in Fig. \[fig:disc\_ta\](c).

We remark that the fact that the transition guards of ${{A}_d}$ are over $\frac{1}{2} {\mathbb{N}_0}$ and not over ${\mathbb{N}_0}$ need not bother us since the standard definition of timed automata holds also over the rational numbers. Indeed, by letting all clocks run twice as fast and multiplying by 2 all values in the constraints of the transition guards, we end up in an automaton over the integers.

The Conformance Distance {#sec:inc_gap}
========================

We want to define a metric on the set of timed traces in order to define (conformance) distance between timed languages.

Given a set $T$ of timed traces over the same alphabet $\Sigma$, we define the $\infty$-metric or max-metric $d$ on $T$ in the following way. Given two timed traces $$\begin{aligned}
        \tau_1 &=(t_1^{\tau_1}, a_1^{\tau_1}), (t_2^{\tau_1}, a_{2}^{\tau_1}),\ldots,(t_m^{\tau_1}, a_m^{\tau_1}), \\
        \tau_2 &=(t_1^{\tau_2}, a_1^{\tau_2}), (t_2^{\tau_2}, a_{2}^{\tau_2}),\ldots,(t_n^{\tau_2}, a_n^{\tau_2}),
    \end{aligned}$$ the distance between $\tau_1$ and $\tau_2$ is $$d(\tau_1, \tau_2) = \begin{cases}
    \infty, &\quad \mathrm{if} \; m \neq n \; \mathrm{or} \; a_i^{\tau_1} \neq a_i^{\tau_2} \; \mathrm{for} \; \mathrm{some} \; i,\\
    \max_i{| t_i^{\tau_1}-t_i^{\tau_2} |}, &\quad \mathrm{otherwise.}
    \end{cases}$$

The above metric over the set of traces induces inclusion relation on timed languages (languages of timed automata).

Given two timed languages ${\mathfrak{L}}_1$ and ${\mathfrak{L}}_2$, ${\mathfrak{L}}_1$ is $\varepsilon$-included in ${\mathfrak{L}}_2$, denoted ${\mathfrak{L}}_1 \subseteq_{\varepsilon} {\mathfrak{L}}_2$, if for every timed trace $\tau_1 \in {\mathfrak{L}}_1$ there exists a timed trace $\tau_2 \in {\mathfrak{L}}_2$ such that $d(\tau_1, \tau_2) \leq \varepsilon$.\
The *conformance distance* $c({\mathfrak{L}}_1, {\mathfrak{L}}_2)$ between ${\mathfrak{L}}_1$ and ${\mathfrak{L}}_2$ is $$c({\mathfrak{L}}_1, {\mathfrak{L}}_2) = \inf\{\varepsilon \, : \,  {\mathfrak{L}}_1 \subseteq_{\varepsilon} {\mathfrak{L}}_2\},$$ that is, $$c({\mathfrak{L}}_1, {\mathfrak{L}}_2) = \sup_{\tau_1 \in {\mathfrak{L}}_1} \inf_{\tau_2 \in {\mathfrak{L}}_2} d(\tau_1, \tau_2) = \sup_{\tau_1 \in {\mathfrak{L}}_1} d(\tau_1, {\mathfrak{L}}_2).$$ The distance $d({\mathfrak{L}}_1,{\mathfrak{L}}_2)$ between ${\mathfrak{L}}_1$ and ${\mathfrak{L}}_2$ is $$\label{qe:lang_dist}
    d({\mathfrak{L}}_1,{\mathfrak{L}}_2) = \max\{c({\mathfrak{L}}_1, {\mathfrak{L}}_2), c({\mathfrak{L}}_2, {\mathfrak{L}}_1)\}.$$

In case of a finite conformance distance $n$ that is reached as a limit of a sequence of distances, we can denote it as $n^{+}$ (for a limit from above) or as $n^{-}$ (for a limit from below). Thus, ${\mathfrak{L}}_1 \subseteq {\mathfrak{L}}_2$ if and only if $c({\mathfrak{L}}_1,{\mathfrak{L}}_2) = 0$. But when $c({\mathfrak{L}}_1,{\mathfrak{L}}_2) = 0^{+}$ then ${\mathfrak{L}}_1 \nsubseteq {\mathfrak{L}}_2$ but ${\mathfrak{L}}_1 \subseteq \overline{{\mathfrak{L}}_2}$, where $\overline{{\mathfrak{L}}_2}$ is the closure of ${\mathfrak{L}}_2$ in the Euclidean topology, defined as follows. Fixing an untimed word $w \in \Sigma^*$ of length $n$, let ${\mathfrak{L}}_2(w)$ be the timed traces in ${\mathfrak{L}}_2$ whose untimed word is $w$ and let ${\mathbb{R}}^n_w$ be a copy of ${\mathbb{R}}^n$ indexed by $w$. There is a natural embedding $\iota: {\mathfrak{L}}_2(w) \to {\mathbb{R}}^n_w$. Then, $c({\mathfrak{L}}_1, {\mathfrak{L}}_2)=0^{+}$ implies that $\iota({\mathfrak{L}}_1) \subseteq \overline{\iota({\mathfrak{L}}_2)}$, where $\iota({\mathfrak{L}}_j) = \bigcup_{w \in \Sigma^*}\iota({\mathfrak{L}}_j(w))$, $j=1,2$, and $\overline{S}$ is the closure of $S$ in the Euclidean topology.

Subadditivity (triangle inequality) holds for the conformance distance: $$c({\mathfrak{L}}_1, {\mathfrak{L}}_3) \leq c({\mathfrak{L}}_1, {\mathfrak{L}}_2) + c(L_2, L_3).$$

\[th:integer\_gap\] Let $A,B \in {\mathrm{NTA}}$. Then $c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) \in \frac{1}{2}{\mathbb{N}_0}\cup \{\infty\}$.

Clearly, the conformance distance $c({\mathfrak{L}}(A), {\mathfrak{L}}(B))$ can be $\infty$, for example, when the untimed language of $A$ contains a word that is not in the untimed language of $B$. Suppose now that $\delta = c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) < \infty$. It suffices to show the following. Given a path $\gamma^A$ in $A$ and another path $\gamma^B$ in $B$, where both define the same untimed trace (identical sequence of actions), let $T^A$ ($T^B$) be the set of all timed traces along $\gamma^A$ ($\gamma^B$). We need to show that $$\label{eq:dist_path}
     \sup_{\tau^A \in T^A} \inf_{\tau^B \in T^B} d(\tau^A, \tau^B) \in \frac{1}{2}{\mathbb{N}_0}.$$ By [@R19], the timestamp of each of the events along $\gamma^A$ and $\gamma^B$ is an interval of the form $(m,n)$, $(m,n]$, $[m,n)$ or $[m,n]$, where $m \leq n$ and $m \in {\mathbb{N}_0}$, $n \in {\mathbb{N}_0}\cup \{\infty\}$. This can be shown by writing equalities and inequalities over the integers and variables $z_i$, where $z_i$ represents the time of the $i$-th event along the path. Then becomes an optimization problem over the integers and variables for the events along $\gamma^A$ as well as for those along $\gamma^B$. The solution lies in $\frac{1}{2}{\mathbb{N}_0}$ because it can be shown that for any other solution the timed traces can be shifted so that we are nearer $\frac{1}{2}{\mathbb{N}_0}$. In fact, it is quite clear that the solution should be looked for when considering the integral end-points of the event intervals. The solution is, in general, in $\frac{1}{2}{\mathbb{N}_0}$ and not in ${\mathbb{N}_0}$ as can be seen from the following example. Suppose that an event of $\tau^A$ occurs at time $0 < t < 1$ where the corresponding event in $B$ can occur at time $0$ or at time $1$. Then, the maximal time difference, namely $\frac{1}{2}$, occurs when we choose the event of $\tau^A$ to be at time $t=\frac{1}{2}$.

By the way they are defined, the untimed runs on the augmented region automaton ${\mathfrak{R}^t}(A)$, as well as those on the discretized timed automaton ${{A}_d}$, are identical to the untimed runs on $A$. The runs differ in the exact time on which each event occurs. When the absolute time of occurrence of an event is $t_0 \in {\mathbb{N}_0}$ then ${{A}_d}$ agrees with $A$. When $t_0 = n+\varepsilon$, $n \in {\mathbb{N}_0}$, $0 < \varepsilon <1$ then the time of the event on ${{A}_d}$ is set to be $n + \frac{1}{2}$, thus, the time difference is less than $\frac{1}{2}$ time units. The fact that the clock $t$ of ${{A}_d}$ is synchronized with the clock $t$ that was added to $A$ to measures absolute time guarantees that the cumulative error does not increase over time but remains bounded by $\frac{1}{2}$. That is, ${{A}_d}$ is a $\frac{1}{2}$-time-unit approximation of $A$: there exits a surjective mapping $$\label{eq:proj}
    \pi : {\mathfrak{L}}(A) \twoheadrightarrow {\mathfrak{L}}({{A}_d}),$$ such that if $\pi(\tau) = \tilde{\tau}$ then $d(\tau, \tilde{\tau}) < \frac{1}{2}$. We showed that the following holds.

\[th:approx\_ta\] $d({\mathfrak{L}}(A), {\mathfrak{L}}({{A}_d})) \leq \frac{1}{2}$.

Since $t$ is reset only on values in $\frac{1}{2}{\mathbb{N}_0}$ then ${{A}_d}$ is determinizable (see [@irta], [@bbbb]). In fact, since $t$ is reset at each transition, we can remove it altogether to obtain an action-labeled, weighted directed graph. The determinization algorithm is then straightforward by searching the graph in a breadth-first manner, unifying edges of the same source location that agree on their labels: $(a,t)$, $a$ - action, $t$ -time, followed by unifying the target locations. The number of vertices, however, may grow exponentially.

Computing the Conformance Distance
==================================

Since ${{A}_d}$ is determinizable, we can gain information about the relation between the languages of two timed automata by comparing their discretized languages.

Note that by the way the distance between languages is defined, it is clear that it refers to languages which are supposed to be (almost) identical or that one language is assumed to be (almost) included in the other, but this is normally the case in equivalence verification or when comparing the implication language with its specification. Note that even if the untimed languages of two TAs are identical, it is enough that there exists a cycle, in which the timed languages do not agree, then by repeatedly taking this cycle the distance between the timed traces of the two TAs may grow indefinitely, resulting in a distance of $\infty$, and it is of interest to be able to recognize when this phenomenon occurs. Thus, it seems that since the distance between $A$ and its discretized timed automaton ${{A}_d}$ is only $\frac{1}{2}$ time units, we may not lose much by comparing ${{A}_d}$ instead of $A$ with another TA. In fact, in order to be more precise in the computation of the distance between two languages we need to make the basic discretization interval, denoted $\Delta$, shorter than $\frac{1}{2}$ time units. By setting $\Delta = \frac{1}{n}$ we get that $d({\mathfrak{L}}(A), {\mathfrak{L}}({{A}_d})) < \frac{1}{n}$, thus we can make ${\mathfrak{L}}(A)$ and ${\mathfrak{L}}({{A}_d})$ as close to one another as we like (of course, in the expense of complexity). However, it turns out that it suffices to choose $\Delta = \frac{1}{6}$ in order to get the maximal precision about $d({\mathfrak{L}}(A), {\mathfrak{L}}(B))$.

For our convenience, since we prefer not to work with small fractions we accelerate the clocks to run at triple speed. That is, from now on, given the timed automata $A$ and $B$ under test, we first multiply by $3$ all the numbers that appear in the transition guards, so they all belong to $3{\mathbb{N}_0}$. Then we proceed as before: we construct the region automata with respect to basic regions of size 1 time unit and the discretized automata with respect to $\Delta = \frac{1}{2}$. Now we have, $$\label{eq:gap_set}
c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) \in \frac{3}{2}{\mathbb{N}_0}\cup \{\infty\}$$ and $$d({\mathfrak{L}}(A), {\mathfrak{L}}({{A}_d})) \leq \frac{1}{2}, \quad d({\mathfrak{L}}(B), {\mathfrak{L}}({{B}_d})) \leq \frac{1}{2}.$$

\[th:inclusion\_gap\] Let $A,B \in {\mathrm{NTA}}$ with clocks running at triple speed and let ${{A}_d}, {{B}_d}$ be their discretized timed automata with respect to $\Delta = \frac{1}{2}$. Then $$|\, c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) - c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d})) \, | \leq \frac{1}{2}$$ and $c({\mathfrak{L}}(A), {\mathfrak{L}}(B))$ is known in case $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d}))$ is known. In particular: $${\mathfrak{L}}({{A}_d}) \nsubseteq {\mathfrak{L}}({{B}_d}) \; \Rightarrow \; {\mathfrak{L}}(A) \nsubseteq {\mathfrak{L}}(B)$$ and $${\mathfrak{L}}({{A}_d}) \subseteq {\mathfrak{L}}({{B}_d}) \; \Rightarrow \; {\mathfrak{L}}(A) \subseteq \overline{{\mathfrak{L}}(B)},$$ so that the language inclusion problem between ${\mathfrak{L}}(A)$ and the topological closure of ${\mathfrak{L}}(B)$ is decidable.

$A$ and ${{A}_d}$ have the same untimed language. The timed languages ${\mathfrak{L}}(A)$ (with clocks running at triple speed) and ${\mathfrak{L}}({{A}_d})$ differ from one another in that every event of a run on $A$ that occurs at time $t$, with $t = n + \varepsilon$ and $0 < \varepsilon < 1$, occurs at the ‘rounded‘ time $n+\frac{1}{2}$ in the corresponding run on ${{A}_d}$. Similarly for $B$ with respect to ${{B}_d}$. It follows that $\delta = c({\mathfrak{L}}(A), {\mathfrak{L}}(B)) = \infty$ if and only if $\delta_d = c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d})) = \infty$.

Suppose now that $\delta < \infty$. We know that $\delta \in \frac{3}{2}{\mathbb{N}_0}$. Since the timed traces of ${\mathfrak{L}}({{A}_d})$ and ${\mathfrak{L}}({{B}_d})$ are discretized to the set $\frac{1}{2}{\mathbb{N}_0}$ then, when computing $\delta_d$ instead of $\delta$, we may have a difference of $\frac{1}{2}$ time units between the two. It follows that $$\label{eq:delta}
    \delta = \begin{cases}
    3k, &\quad \mathrm{if} \; \delta_d \in \{3k-\frac{1}{2}, 3k, 3k+\frac{1}{2}\}, \\
    3k+\frac{3}{2}, &\quad \mathrm{if} \; \delta_d \in \{3k+1, 3k+\frac{3}{2}, 3k+2 \}.
    \end{cases}$$

Let us elaborate on that. When $\delta$ is exactly $k$ and not $3k^{+}$ or $3k^{-}$ then it means that it is achieved on specific timed traces and not as a limit. That is, it refers to an even occurring at time $t^A$ on a run on $A$ and and event occurring at time $t^B$ on a run on $B$, with $| t^A - t^B | = 3k$. Since the fractional parts of $t^A$ and $t^B$ are identical, the discretization in the corresponding runs on ${{A}_d}$ and ${{B}_d}$ are identical so that they occur at times $t^{{{A}_d}}$ and $t^{{{B}_d}}$ with $| t^{{{A}_d}} - t^{{{B}_d}} | = 3k$. The same applies when $\delta$ is exactly $3k+\frac{3}{2}$ since we are working with a resolution of $\frac{1}{2}$.

When $\delta = 3k^{+}$ or $\delta = 3k^{-}$ then it is achieved as a limit of timed traces. If $\delta = 3k^{+}$ then $\delta_d$ can be $3k + \frac{1}{2}$, for example, when $t^A=3$ and $t^B = 3 + \varepsilon$, $\varepsilon>0$. Then the discretized traces will occur at times $t^{{{A}_d}}=3$ and $t^{{{B}_d}}=3\frac{1}{2}$. Then by choosing a sequence of timed traces of ${\mathfrak{L}}(B)$ the time difference can tend to $0$ while in the discretized automata it will remain $\frac{1}{2}$.

The other cases of an conformance distance $\delta$ that is a limit of converging distances are analogous, but we do not go here into detail.

Let us look at the last claims of the theorem. Suppose that ${\mathfrak{L}}(A) \subseteq {\mathfrak{L}}(B)$. Then for each timed trace of ${\mathfrak{L}}(A)$ there is an identical timed trace of ${\mathfrak{L}}(B)$. The projection to the discretized timed trace will also be identical, thus, $${\mathfrak{L}}(A) \subseteq {\mathfrak{L}}(B) \; \Rightarrow \; {\mathfrak{L}}({{A}_d}) \subseteq {\mathfrak{L}}({{B}_d}).$$ If ${\mathfrak{L}}(A) \nsubseteq \overline{{\mathfrak{L}}(B)}$ then $\delta > 0$. By , we have that $\delta_d > 0$. It follows that $${\mathfrak{L}}(A) \nsubseteq \overline{{\mathfrak{L}}(B)} \; \Rightarrow \; {\mathfrak{L}}({{A}_d}) \nsubseteq {\mathfrak{L}}({{B}_d}).$$

By $\eqref{qe:lang_dist}$, a similar result to Theorem \[th:inclusion\_gap\] holds with respect to distances between languages.

By Theorem \[th:inclusion\_gap\], in order to compute the conformance distance $c({\mathfrak{L}}(A), {\mathfrak{L}}(B))$, we can compute $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d}))$, and know that we lie within an error of at most $\frac{1}{2}$ time unit. We may assume that ${{A}_d}$ is deterministic, as this is feasible. It is not necessary to determinize ${{B}_d}$.

The general goal in computing $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d}))$ is to find the timed trace of ${\mathfrak{L}}({{A}_d})$ that is farthest from ${\mathfrak{L}}({{B}_d})$ (or a sequence of such timed traces if the distance is $\infty$). A heuristic approach is to play a timed game in which the player in white moves along ${{A}_d}$ and tries to maximize her wins, while the player in black moves along ${{B}_d}$ and tries to minimize his losses. The players start from the initial vertex of each graph. Then white makes a move by jumping to a vertex in ${{A}_d}$ with transition label $a$, followed by a move of black on an edge in ${{B}_d}$ with the same label $a$. Next, white moves on an edge with label $a'$, followed by a move of black with the same label $a'$ and so on. At each move we record the time difference between the absolute time duration of the paths along ${{A}_d}$ and along ${{B}_d}$. The problem is that we may return to the same pair of locations $(q,q') \in {\mathcal{Q}}^{{{A}_d}} \times {\mathcal{Q}}^{{{B}_d}}$ but with a different time difference between the path along ${{A}_d}$ and that along ${{B}_d}$. In addition, there are moves to locations where the time is not a single value but of the form $t \geq m$. Thus, the game may not be of finite type. One strategy to cope with the complexity of the game is a greedy max-min algorithm: each move of white is one that maximizes the new difference in times after the following move of black that tries to minimizes the time difference. A better, but more expensive, strategy on the part of white is to look-ahead more than one step.

So, let us then consider a seemingly easier question: is $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d}))$ finite or infinite? For this question we do not need to speed-up the clocks. An infinite conformal distance occurs in one of the following three situations.

1.  The untimed language of ${{A}_d}$ is not included in that of ${{B}_d}$: there exists a path $q_0 \xrightarrow{a_1} q_1 \xrightarrow{a_2} \cdots \xrightarrow{a_n} q_n$ in ${{A}_d}$, with $q_n$ an accepting location, which either cannot be realized in ${{B}_d}$ with the same sequence of actions, or all such paths in ${{B}_d}$ do not terminate in an accepting location.

2.  There exists a path in ${{A}_d}$ of the form $q_0 \xrightarrow{a_1} q_1 \xrightarrow{a_2} \cdots \xrightarrow{a_n} q_n$, where the transition $q_{n-1} \xrightarrow{a_n} q_n$ has guard $t \geq m$, whereas for any path in ${{B}_d}$ of the form $q'_0 \xrightarrow{a_1} q'_1 \xrightarrow{a_2} \cdots \xrightarrow{a_n} q'_n$ the guard of the last transition $q'_{n-1} \xrightarrow{a_n} q'_n$ bounds $t$ from above.

3.  For each $N \in {\mathbb{N}}$ there exists a timed trace $\tau \in {\mathfrak{L}}({{A}_d})$, such that for each $\sigma \in {\mathfrak{L}}({{B}_d})$, $d(\tau, \sigma) > N$ and not because of S2.

In order to find out whether the conformance distance between ${\mathfrak{L}}({{A}_d})$ and ${\mathfrak{L}}({{B}_d})$ is infinite as a result of **S1** or **S2** we extend ${{A}_d}$ and ${{B}_d}$ as follows.

First, we add to the set ${\Sigma}$ of actions a copy of it $\bar{{\Sigma}} = \{ \bar{a} \, : \, a \in {\Sigma}\}$. Then, for each transition $q \xrightarrow{a} q'$ of ${{A}_d}$ or of ${{B}_d}$ with time constraint of type $t \geq m$, we add a transition $q \xrightarrow{\bar{a}} q'$ with guard $t = \infty$. Next, we complete ${{B}_d}$ by adding a location $s$ which is a ’sink’: whenever there is no transition with action $b \in {\Sigma}\cup \bar{{\Sigma}}$ from location $q$ of ${{B}_d}$, we add the transition $q \xrightarrow{b} s$. The sink location is supplemented by self-loops of all actions. We retain the names ${{A}_d}$ and ${{B}_d}$ for the resulting automata.

In the next step we form the untimed automaton $U({{A}_d})$ which is a determinization of ${{A}_d}$ with respect to actions while ignoring the temporal part. Similarly, we construct $U({{B}_d})$.

\[def:uappta\_a\] The automaton $U({{A}_d})$ is a tuple $({\mathcal{Q}}, Q_0, {\mathcal{F}}, {\Sigma}\cup \bar{{\Sigma}}, {\mathcal{E}})$, where:

1.  ${\mathcal{Q}}\subseteq \mathcal{P}({\mathcal{Q}}^{{{A}_d}})$ is a subset of the power set of the locations of ${{A}_d}$, where $Q_0 = \{q^{{{A}_d}}_0\}$ is the initial location;

2.  ${\mathcal{F}}\subseteq {\mathcal{Q}}$ is the set of accepting locations, where $Q = \{q^{{{A}_d}}_1, \ldots, q^{{{A}_d}}_m\}$ is accepting if at least one of the $q^{{{A}_d}}_i$ is an accepting location of ${{A}_d}$;

3.  ${\Sigma}\cup \bar{{\Sigma}}$ is the set of actions;

4.  ${\mathcal{E}}\subseteq {\mathcal{Q}}\times ({\Sigma}\cup \bar{{\Sigma}}) \times {\mathcal{Q}}$ is a finite set of edges of the form $(Q, a, Q')$, where $Q' = \{ q'^{{{A}_d}} : \exists q^{{{A}_d}} \in Q. \, (q^{{{A}_d}}, a, q'^{{{A}_d}} )\in {\mathcal{T}}^{{{A}_d}} \}$.

Finally, we construct a version of the untimed product automaton $U({{A}_d}) \times U({{B}_d})$ in which the accepting locations are those pairs of locations $(Q,Q')$ for which $Q$ is an accepting location of $U({{A}_d})$ but $Q'$ is not an accepting location of $U({{B}_d})$.

\[def:prod\] The product automaton $U({{A}_d}) \times U({{B}_d})$ is a tuple $({\mathcal{Q}}, Q_0, {\mathcal{F}}, {{\Sigma}\cup \bar{{\Sigma}}}, {\mathcal{E}})$, where:

1.  ${\mathcal{Q}}\subseteq {\mathcal{Q}}^{U({{A}_d})} \times {\mathcal{Q}}^{U({{B}_d})}$, where $Q_0 = (q^{U({{A}_d})}_0, q^{U({{B}_d})}_0)$ is the initial location;

2.  ${\mathcal{F}}\subseteq {\mathcal{Q}}$ is the set of accepting locations $(Q,Q')$, where $Q \in {\mathcal{F}}^{U({{A}_d})}$ and $Q' \notin {\mathcal{F}}^{U({{B}_d})}$;

3.  ${\Sigma}\cup \bar{{\Sigma}}$ is the set of actions;

4.  ${\mathcal{E}}\subseteq {\mathcal{Q}}\times ({\Sigma}\cup \bar{{\Sigma}}) \times {\mathcal{Q}}$ is the set of edges, where for each $(Q_1, a, Q'_1) \in {\mathcal{E}}^{U({{A}_d})}$ and $(Q_2, a, Q'_2) \in {\mathcal{E}}^{U({{B}_d})}$ we have that $((Q_1,Q_2), a, (Q'_1,Q'_2)) \in {\mathcal{E}}$,

and $U({{A}_d}) \times U({{B}_d})$ is the connected component of the initial location.

$c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d})) = \infty$ as a result of **S1** or **S2** if and only if the set of accepting locations of $U({{A}_d}) \times U({{B}_d})$ is not empty.

By completing ${{B}_d}$ we made sure that the set of untimed traces of $U({{B}_d})$ consists of all possible traces. But if a path in $U({{A}_d}) \times U({{B}_d})$ terminates in an accepting location, then there exists a path in ${{A}_d}$ that ends in an accepting location, while all paths in ${{B}_d}$ of the same sequence of actions either terminate in a non-sink location which is non-accepting, or enter the sink either on an edge with action $a \in {\Sigma}$ due to missing such an edge on the uncompleted ${{B}_d}$ or on an edge labeled $\bar{a} \in \bar{{\Sigma}}$ due to reaching a transition that is bounded in time in (the uncompleted) ${{B}_d}$, but not bounded in ${{A}_d}$.

Assume now that by constructing the automaton $U({{A}_d}) \times U({{B}_d})$ it turns out that no possible infinite conformance distance exists when checking **S1** and **S2** and it remains to check **S3**. Hence, the goal is to find a sequence of traces in ${{A}_d}$ which ’run-away’ from ${{B}_d}$, and now we are interested in the exact delays between consecutive transitions. This problem may be of very high complexity and even it is not clear whether it is decidable. We will show that a (perhaps) restricted version is decidable.

First, we extend ${{A}_d}$ and ${{B}_d}$ with actions $\bar{{\Sigma}}$ as before, referring to transitions that are unbounded by time. Let $M$ be the maximal integer that appears in a transition guard of ${{A}_d}$ or ${{B}_d}$. Then, each transition $q \xrightarrow{a} q'$ of ${{A}_d}$ or ${{B}_d}$ with time constraint $t \geq m$, $m \leq M+\frac{1}{2}$, is replaced by the transitions $q \xrightarrow{a} q'$ with delays $t = m$, $t=m+\frac{1}{2}$,..., $t=M+\frac{1}{2}$ and another transition $q \xrightarrow{\bar{a}} q'$ with delay $t = (M+1)^*$. The set of delays of ${{A}_d}$ (${{B}_d}$) is denoted by ${\mathcal{D}}$.

In the next step we determinize ${{B}_d}$ into $D({{B}_d})$. The idea is to be able to compare each timed trace of ${{A}_d}$ simultaneously with all equivalent (having the same untimed trace) time traces of ${{B}_d}$.

\[def:detappta\_b\] The automaton $D({{B}_d})$ is a tuple $({\mathcal{Q}}, Q_0, {\mathcal{F}}, {\Sigma}\cup \bar{{\Sigma}}, {\mathcal{T}})$, where:

1.  ${\mathcal{Q}}\subseteq \mathcal{P}({\mathcal{Q}}^{{{B}_d}})$ is a subset of the power set of the locations of ${{B}_d}$, where $Q_0 = \{q^{{{B}_d}}_0\}$ is the initial location;

2.  ${\mathcal{F}}\subseteq {\mathcal{Q}}$ is the set of accepting locations, where location $Q = \{q^{{{B}_d}}_1, \ldots, q^{{{B}_d}}_m\}$ is accepting if at least one of the $q^{{{B}_d}}_i$ is an accepting location of ${{B}_d}$;

3.  ${\Sigma}\cup \bar{{\Sigma}}$ is the set of actions;

4.  ${\mathcal{T}}\subseteq {\mathcal{Q}}\times ({\Sigma}\cup \bar{{\Sigma}}) \times {\mathcal{E}}\times {\mathcal{Q}}$ is a finite set of transitions of the form $(Q, a, E, Q')$, where $$E = \{(q^{{{B}_d}}, a, d, q'^{{{B}_d}}) \in {\mathcal{T}}^{{{B}_d}} \, : \,  q^{{{B}_d}} \in Q, q'^{{{B}_d}} \in Q', a \in {\Sigma}\cup \bar{{\Sigma}}, d \in {\mathcal{D}}\}.$$ and $Q'$ contains exactly the set of these target locations $q'^{{{A}_d}}$.

Note that the transitions of $D({{B}_d})$ retain the set of transitions of ${{B}_d}$ including source and target locations.

In the next step we make the standard construction of the product automaton ${{A}_d} \times D({{B}_d})$. It has at most $L = | {\mathcal{Q}}^{{{A}_d}} | \cdot 2^{|{\mathcal{Q}}^{{{B}_d}}|}$ locations, where each location is of the form $$Q^{{{A}_d} \times D({{B}_d})} = (q^{{{A}_d}}, \{q^{{{B}_d}}_1, \ldots, q^{{{B}_d}}_m\}).$$ Since the difference between a transition delay on ${{A}_d}$ and a corresponding transition on ${{B}_d}$ in parallel runs on ${{A}_d}$ and ${{B}_d}$ is at most $M$ time units (actually, it is $M+\frac{1}{2}$, but it makes no difference for our argument), then a run on ${{A}_d} \times D({{B}_d})$ that does not visit the same location twice may result in a delay of at most $LM$ time units between its projection to ${{A}_d}$ and each of its projections to ${{B}_d}$.

At each transition of a run on ${{A}_d} \times D({{B}_d})$ we can subtract the delay of the edge of ${{A}_d}$ from each of the delays of the corresponding edges of ${{B}_d}$ and record at each location $q^{{{B}_d}}_i$ of $Q^{{{A}_d} \times D({{B}_d})}$ the set of *accumulated time differences* (ATDs), that is, the differences in absolute time between the runs on ${{A}_d}$ and all possible runs on ${{B}_d}$ of the same untimed trace when reaching $Q^{{{A}_d} \times D({{B}_d})}$. The ATD of the least absolute value gives the least difference in time at that location between the run on ${{A}_d}$ and a corresponding run on ${{B}_d}$. When a delay is $(M+1)^*$ (and then it is the same delay for both ${{A}_d}$ and ${{B}_d}$) then we denote the difference $0^+$, and this $+$ sign carries on to the next differences by defining $i^+ + j = (i+j)^+$, $i^+ + j^+ = (i+j)^{++}$, and so on. It means that $i^+$ is actually any value of $\frac{1}{2}{\mathbb{N}_0}$ which is greater than or equals $i$. The reason for that is that for a delay $k$ in ${{A}_d}$ we can choose any delay $l \geq k$ in ${{B}_d}$. In order to exclude the possibility of choosing also a delay in ${{B}_d}$ which is smaller than $k$ (and maybe reduce the distance between the corresponding paths in ${{A}_d}$ and ${{B}_d}$), each transition of ${{A}_d}$ that is unbounded in time is considered as a delay of $M+1$ time units. Once a value of the form $i^+$ is realized as a concrete value $i+j$, for some $j \geq 0$, then in all the difference values that appear in the following locations the relevant $+$ sign is removed and the value $j$ is added.

Every run $\rho$ on ${{A}_d} \times D({{B}_d})$ can be uniquely written in the form $$\rho = \rho_0 \sigma_1^{i_1} \rho_1 \sigma_2^{i_2} \rho_2 \cdots \sigma_r^{i_r} \rho_r,$$ for some $r \in {\mathbb{N}_0}$, $i_j \in {\mathbb{N}}$ and where each $\sigma_j$ is a simple cycle of positive length and each $\rho_j$ is without cycles and of length $0 \leq l < L$. We say that the number of *power cycles* of $\rho$ is $r$, written $pc(\rho)=r$.

It is decidable whether there exists a fixed $K \in {\mathbb{N}}$, such that for every $N \in {\mathbb{N}}$ there exists a timed trace $\tau \in {\mathfrak{L}}({{A}_d})$, such that $d(\tau, {\mathfrak{L}}({{B}_d})) > N$ and the corresponding run $\rho$ on ${{A}_d} \times D({{B}_d})$ satisfies $pc(\rho) \leq K$.

The conformance distance $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d}))$ is $\infty$ if for every $N \in {\mathbb{N}}$ we can reach a location $Q^{{{A}_d} \times D({{B}_d})}$ with all ATDs of absolute value at least $N$. Since $pc(\rho) \leq K$, $K$ fixed, it is clear that the unbounded increase in the ATDs can come only from the powers of simple cycles $\sigma^{i_j}$. Since the number of locations of ${{A}_d} \times D({{B}_d})$ is finite, all locations can be reached in a bounded number of steps. Then, for each location $Q^{{{A}_d} \times D({{B}_d})}$ and each simple cycle $\sigma$ starting at $Q^{{{A}_d} \times D({{B}_d})}$, it can be checked for which locations $q^{{{B}_d}}_i$ of $Q^{{{A}_d} \times D({{B}_d})}$ the minimal (in absolute value) ATD increases indefinitely when repeating the cycle $\sigma$. Let $P$ be the set of these locations $Q^{{{A}_d} \times D({{B}_d})}$ with at least one unbounded ATD.

Next we look at all the simple paths from each $Q^{{{A}_d} \times D({{B}_d})} \in P$ to the other locations of ${{A}_d} \times D({{B}_d})$ and update their sub-locations $q^{{{B}_d}}_i$ of having an unbounded ATD. Moreover, when reaching a location $Q'^{{{A}_d} \times D({{B}_d})} \in P$ from another location $Q^{{{A}_d} \times D({{B}_d})} \in P$ then it can be checked whether new sub-locations $q^{{{B}_d}}_i$ of $Q'^{{{A}_d} \times D({{B}_d})}$ become with unbounded ATD when repeating a cycle $\sigma$ (even when its minimal ATD decreases by a bounded finite number at each round of $\sigma$, if we started with an unbounded value, we can end at an unbounded value). This process is repeated until no improvement in the maximum number of sub-locations of unbounded ATD can be achieved. Since the graph is finite, the whole algorithm is finite. Finally, $c({\mathfrak{L}}({{A}_d}), {\mathfrak{L}}({{B}_d})) = \infty$ when at some step of the algorithm a location $Q^{{{A}_d} \times D({{B}_d})}$ becomes with all its sub-locations $q^{{{B}_d}}_i$ of unbounded ATD.

Conclusion and Suggested Future Research
========================================

In this paper we introduced a natural definition of the distance between the languages of non-deterministic timed automata in terms of the times at which events in one automaton occur compared to the times of corresponding events in the other automaton. We showed how one can effectively construct discretized deterministic timed automata and obtain the distance between the original timed automata from the distance between the discretized versions. Consequently, the problem of language inclusion for timed automata, which is undecidable in general, is decidable if we consider the closure of the languages with respect to the Euclidean topology.

Computing the distance between timed automata may not be an easy task. We even do not know whether the finiteness of the distance is a decidable problem. We showed, however, that under some restriction on the timed traces, this problem is decidable.

There is more than one reasonable way to define the distance between timed automata and the one we chose refers to the accumulated time difference that may occur between timed automata that are supposed to be (almost) the same or conformance distance between the language of an implementation and that of the specification. Other possible definitions of distances like a maximal time difference on a single transition or time difference mean on simple cycles are easier to compute on the discretized automata. For another notion of distance between implementation and specification we refer to [@CHR12]. Another interesting problem is to compute the distance between timed automata equipped with probabilities on transitions, where the distances are computed as expected values with respect to these probabilities.

Acknowledgements. {#acknowledgements. .unnumbered}
-----------------

This research was partly supported by the Austrian Science Fund (FWF) Project P29355-N35.
