**3. Duration Calculus**

In this section, we present the basic features of duration calculus (DC). We present the basic idea behind temporal specification relative to time intervals. We also list and explain the temporal modalities it provides and explain how they can be used.

#### *3.1. Using Duration Calculus*

In this subsection, we show the basic properties of duration calculus (DC) in its original form. DC allows to specify Boolean-valued functions, which play the role of timedependent formulas, and to use the DC integral operator to measure the time, or equivalently the duration, when they hold. We also consider an operator for splitting intervals.

DC allows to treat durations of processes. More precisely, it expresses integrals of Boolean-valued functions with values 1 and 0 representing true and false, respectively. Such functions are called state functions since they indicate whether the system is in a given state or not. It should be noted that the properties are defined not in respect to specific points in time but in respect to intervals and in terms of durations.

We start with a simple example of system with states modeled by the *sin*(*t*) function and lasting for the time interval [0, 2 *π*] (see Figure 1). This function is first positive on [0, *π*] subinterval and then it is negative on subinterval [*<sup>π</sup>*, 2 *<sup>π</sup>*]. The fact that the function is first positive may be characterized in DC using the Boolean-valued function *sp*(*t*) = *<sup>1</sup>*{*x* ∣ *<sup>0</sup>*⩽*sin*(*x*)}(*t*), which returns 1 if *t* ∈ {*x* ∣ *0* ⩽ *sin*(*x*)} and 0 otherwise. In the first case, the value is 1, and in the second case, it equals 0; we identify *true* with 1 and *false* with 0. *sp*(*t*) is called the characteristic function of the set {*x* ∣ *0* ⩽ *sin*(*x*)}. To describe that the value of *sin* is negative, we can use the characteristic function *sn*(*t*) = *<sup>1</sup>*{*x* ∣*sin*(*x*)<*0*}. This function may be obtained from the first one using logical negation *sn* = <sup>¬</sup>*sp*, which swaps 1 and 0. It should be noted that DC does not allow direct access to *sin* and its integral, but only via Boolean-valued functions characterizing its values.

**Figure 1.** *sin*-function and the corresponding state function 1{ *x* ∣ 0 ⩽ *sin*(*x*)}.

Duration calculus enables one to express such properties as the duration of states— for example, the period of time over which *sin* remains positive, with the help of state function *sp*. DC formulas are evaluated always in respect to an underlying time interval. Length function - returns the length of the underlying interval. It is defined using the integration operator ∫ of DC: - = ∫ 1. The semantics of this operator is defined relatively to an underlying interval [*a*, *b*]—in this case, ∫ 1 = ∫ *b a*1 *dt*.

For a Boolean-valued function, the integral operator measures the time when the function is true. For intervals of length 2 *π*, the length of subinterval where *sin*(*t*) is positive is equal to the length of the subinterval in which it is negative. This fact may be expressed using the length function -:

$$\ell = 2\,\pi \quad \Rightarrow \quad \int \, sp = \int \, sn \tag{1}$$

In this formula, we use the integral ∫ *sp*, which, for a given interval [*a*, *b*], returns the value ∫ *ba sp dt*, i.e., the value of the integral for the interval, and similarly for *sn*. The formula states that if the length of an interval equals to 2*π*, then the time when the *sp* is true equals to the time, the duration, when *sn* is true. We do not have to consider the fact that the function is equal 0 at the end of intervals, since the functions are characterized in terms of integrals and for subintervals of length 0, the integral value has no influence on the entire integral.

For interval [0, <sup>2</sup>*π*], it holds that ∫ *sp* = *π*, since the duration of *sp* being true is *π*. In fact, this expression is true for every interval of the form [0, *<sup>x</sup>*], where *π* ⩽ *x* ⩽ 2*π*, but it is false for intervals of the form [*<sup>x</sup>*, <sup>2</sup>*π*]. Similarly, we can express the fact that the duration of *sin* being negative is *π*: ∫ *sn* = *π*. This expression is true on every interval of the form [*y*, <sup>2</sup>*π*] where 0 ⩽ *y* ⩽ *π*. In both cases, we have to use the auxiliary functions *sp*,*sn* to characterize *sin* in terms of being positive or negative, respectively.
