• Keine Ergebnisse gefunden

5.3 Discrete Temporal Interval Sequences

5.3.1 Unlabeled Temporal Interval Sequences

First, since a discrete time base is assumed, a temporal interval is merely a closed interval on natural numbers.

Definition 5.1 (Discrete temporal interval). A temporal interval is a closed interval [ts, te]with ts ∈N0 and te ∈N0. Furthermore, the set of all possible temporal intervals is denoted byIT.

In the further discussion within this chapter, temporal intervals will be used to reflect the evaluation state of a given property with respect to the time, i.e. at which time points the property was evaluated to true or false, and for which points a concise result has not been found yet. Since the state of a property will change in the course of events, it is necessary to represent time trajectories that contain gaps. This is achieved by aggregating intervals in sorted sequences.

Definition 5.2 (Discrete Temporal Interval Sequence). A discrete temporal interval sequence, written like T, is a sorted sequence of disjunctive closed intervals of natural numbers. Formally, T : N0 → IT = ([ti,s, ti,e])Ni=0 where the following invariants hold:

1. ∀0≤i≤N. ti,s∈N0 andti,e∈N0. 2. ∀0≤i≤N. ti,s≤ti,e.

3. ∀1≤i≤N. ti,s> ti−1,e. 4. ∀0≤i≤N−1. ti,e< ti+1,s.

For some of the following definitions and theorems, it is useful to introduce some additional terminology and notation that facilitate referring to certain properties of temporal interval sequences.

Definition 5.3. LetT be a temporal interval sequence. Then the cardinality of T, written as|T|is defined as the number of temporal intervals inT. This means that forT = (Ii)Ni=0 = (I0, . . . , IN), the cardinality is|T|=N+ 1.

Furthermore, when T = (Ii)Ni=0, then the set of temporal intervals in T, written asIT(T), is defined as

IT(T)⊂ IT :={Ii|0≤i≤ |T| −1}

In the definition of temporal interval sequences, properties1and 2simply state that the elements of the sequence are valid discrete temporal intervals, i.e.

intervals on natural numbers. More importantly, properties 3 and 4 together establish that the intervals are sorted in ascending order and are disjunct, i.e. they don’t overlap. Since these invariants are crucial for the evaluation algorithms, it will be necessary below to show that they are maintained by all used operations on temporal interval sequences.

Figure 5.4 shows an example for a temporal interval sequence. Later in this chapter, it will be described how sequences like that are used to represent time intervals that share a common category. For instance, the intervals in Figure 5.4 could reflect the times when a given property holds.

Figure 5.4: Example discrete temporal interval sequence.

Without going into details about how the evaluation algorithm actually creates such interval-based property state representations, it is clear that first

of all, a constructor is required to build temporal interval sequences. More precisely, an operator is needed that adds a temporal interval to an interval sequence while maintaining the invariants of Definition 5.2.

Definition 5.4(Addition of an interval to a temporal interval sequence). Let T = ([ti,s, ti,e])Ni=0 be a temporal interval sequence and I = [ts, te] a single closed temporal interval. Then the addition of T and I, written as T⊕I is defined as follows:

T⊕I = Ii0N0 i=0

where

Ii0 =













[ti,s, ti,e] if i≤i<

[t0s, t0e] if i=i<+ 1 [tr(i),s, tr(i),e] if i<+ 2≤i≤N0 with

i<=

(max{i|ti,e< ts} if ∃i. ti,e< ts

−1 otherwise

i> =

(min{i|ti,s> te} if ∃i. ti,s> te

N + 1 otherwise

r :N0 →N0, r(i) =i+i>−i<−2 N0 =i<+ 2 +N −i>

t0s=

min (ts, tk,s) if ∃k. k= min{i|ts≤ti,e≤te}

ts otherwise

t0e =

max (te, tl,e) if ∃l. l = max{i|ts≤ti,s≤te}

te otherwise

A schematic overview of the calculations in Definition 5.4 is shown in Fig-ure 5.5. Unlike a regular insertion of an element into a list, the operator ⊕ not only has to maintain the order of the sequence but also potentially merge overlapping intervals to guarantee that the resulting sequence reflects the in-tuitive addition semantics and fulfills the conditions stated in Definition 5.2.

This is established in the following theorem.

Figure 5.5: Addition of an interval to an interval sequence.

Theorem 5.2. LetT = ([ti,s, ti,e])Ni=0be a temporal interval sequence for which the properties 1. to 4. of Definition 5.2 hold. Furthermore, let I = [ts, te] be a single closed temporal interval and T0=T⊕I the sequence that results from the addition of I to T. Then, the intervals in T0 cover all intervals from T and I and satisfy properties 1. to 4. of Definition 5.2.

Proof. The proof works by case analysis of all possible constellations regarding the temporal relation between the interval I and the sequenceT:

i) I is strictly before T, i.e. te < t0,s. The ordering constraints of Defi-nition 5.2 imply ∀i.ti,e > ti,s > te > ts. This yields i< = −1, i> = 0, t0s = ts and t0e = te. Therefore, r(i) = i−1 and N0 = N + 1. Al-together, this results in the intended temporal interval sequence T0 = ([ts, te],[t0,s, t0,e], . . . ,[tN,s, tN,e]). This means that all previous intervals as well asI are contained inT0 and the order of the original elements ofT is not modified. Withts< te< t0,s, all properties of Definition 5.2 hold.

ii) I starts before or within the first interval and ends before the start of the last interval. Then, as above,i< =−1. Let c be the number of intervals that are fully covered byI. This means thati>=c,N0 =−1+2+N−c= N−c+1, andr(i) =i+c−1. Thus,T0 = ([t0s, t0e],[tc,s, tc,e], . . . ,[tN,s, tN,e]). This immediately shows that properties 1. to 4. of Definition 5.2 are satisfied. Sincet0s andt0e are defined so that[t0s, t0e]is the smallest interval that containsIand all intervals that are partially or completely overlapped byI, it holds thatT0 covers all intervals as intended.

iii) Iis strictly between two intermediate intervals. In this case, there is a left part and a right part of the old sequence that are not altered internally and simply arranged before and after I. For the index transformation defined above, this means that i> = i<+ 1, which implies r(i) = i−1 andN0 =N + 1. This corresponds to a valid construction of an interval sequence and therefore all required properties hold.

iv) I overlaps one or several intermediate intervals. This means that basically the same considerations apply as in case ii. Additionally, like before, the left and right surrounding sequence parts are not altered and therefore the required properties hold.

v) I overlaps or is adjacent to the last interval ofT. Again, it is easy to see that this case is symmetrical to ii so the same arguments apply.

vi) I is strictly after the last interval of T, i.e. te < t0,s. This means that i< = N, i> = N + 1, t0s = ts and t0e = te. Therefore, r(i) = i−1 and N0=N+ 1. As before, the construction corresponds to the requirements in Definition 5.2.

Based upon the interval addition operator from above, it is possible to inductively define the union of two temporal interval sequences.

Definition 5.5 (Union of temporal interval sequences). Let T = (Ii)Ni=0 and T0 = (Ii0)Ni=00 be two temporal interval sequences. Furthermore, let (Ii0)li=k denote the subsequence of(Ii0)Ni=00 from indexktol. Then the union ofT and (Ii0)Ni=00 is recursively defined as follows:

T∪ Ii0l i=k:=

(T⊕Ik0)∪(Ii0)li=k+1 if k < l

T⊕Ik0 otherwise

The union operator simply works by successively adding all intervals from one sequence to another sequence. Since this is recursively based on the interval addition operation from Definition 5.4, it is easy to show that temporal interval sequences are closed under union, i.e. the union of two temporal interval sequences also maintains the invariants from Definition 5.2. However, the proof necessarily relies on the fact that subsequences of temporal interval sequences maintain these invariants, which is shown in the following lemma.

Lemma 5.2. Let T = (Ii)Ni=0 be a temporal interval sequence and let (Ii)li=k with 0 ≤ k ≤ l ≤ N denote the subsequence of T from index k to l. Then (Ii)li=k fulfills the invariants from Definition 5.2.

Proof. Since no interval bounds are changed, properties 1 and 2 cannot be violated in any way. Furthermore, the subsequence (Ii)li=k can be seen as a sequence(Ii0)l−ki=0 whereIi0 =Ii+k, i.e. Ii =Ii−k0 . From Definition 5.2 we know that∀1≤i≤N. ti,s> ti−1,e and ∀0≤i≤N −1. ti,e< ti+1,s. In particular, this implies∀k+ 1≤i≤l. ti,s> ti−1,e and ∀k≤i≤l−1. ti,e< ti+1,s. With

the equivalence from above, this can be rewritten to ∀k+ 1≤i≤l. t0i−k,s >

t0i−k−1,e and ∀k ≤ i ≤ l−1. t0i−k,e < t0i−k+1,s. Simple index transformation finally leads to∀1≤i≤l−k. t0i,s> t0i−1,e and∀0≤i≤l−k−1. t0i,e< t0i+1,s, respectively. These two expressions correspond to the instantiation of property 3and4of Definition 5.2 for the sequence(Ii0)l−ki=0, which proves the lemma.

Using Lemma 5.2, it can be shown that the temporal interval sequence invariants are maintained by the union operator.

Theorem 5.3. Let T = (Ii)Ni=0 and T0 = (Ii0)Ni=00 be two temporal interval sequences and let T00=T ∪ T0 be the union of T andT0. Then the invariants defined in Definition 5.2 hold for T00.

Proof. The proof works by induction over the length of T0, i.e. N0+ 1. If T0 is empty, T00=T, which fulfills the invariants by definition. Therefore, let the induction start with a length of 1, i.e. T0= (Ii0)0i=0. In this case, T00=T⊕I00, which fulfills the invariants due to Theorem 5.2.

For the induction step, letT0 = (Ii0)Ni=00 be a sequence with a length greater than1, i.e. N0 >0. Then,T00= (T⊕I00)∪(Ii0)Ni=10 . Due to Theorem 5.2, the left part of this union is an admissible interval sequence that fulfills the invariants.

Additionally, Lemma 5.2 shows that right part also fulfills the invariants. By a simple index transformation, the subsequence (Ii0)Ni=10 can be rewritten to (Ii0)Ni=00−1, whose length is one less than the length of(Ii0)Ni=00 . Therefore, by the induction hypothesis, a union with (Ii0)Ni=00−1 maintains the invariants, which concludes the proof.