• Keine Ergebnisse gefunden

5.3 Discrete Temporal Interval Sequences

5.3.2 Intersection Operators

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.

Figure 5.6: Intersection between intervals.

Figure 5.6 shows three different cases for an intersection between two in-tervals. The other possible arrangements of I1 and I2 are symmetric and are therefore covered by the maximum and minimum operators in Definition 5.6.

When an interval intersection is used to update the evaluation schedule, it is almost always also important to process the remainder of the intersection, i.e.

the parts of the original intervals that are not included in the intersection. For the purpose of the algorithms of this chapter, it makes sense to view one of the two intervals in an intersection as thequery interval and one as themanipulated interval. In many cases, only the remaining part of the manipulated interval has to be processed further. This remainder of an interval intersection is defined as therelative complement of the intervals in the set theoretic sense.

Definition 5.7 (Relative complement of two intervals). Let I1 = [t1,s, t1,e] andIq= [t2,s, t2,e]be two discrete temporal intervals. Then the relative com-plement ofI2 inI1, written as I1\I2 yields a temporal interval sequence that is defined as follows:

I1\I2 =





























(Ii0)0i=0 withI00 =I1 if t1,e < t2,s∨t2,e < t1,s (Ii0)0i=0 withI00 = [t1,s, t2,s−1] if t1,s < t2,s ≤t1,e∧t2,e ≥t1,e

(Ii0)0i=0 withI00 = [t2,e+ 1, t1,e] if t2,s ≤t1s ∧t1,s ≤t2,e< t1,e

∅ if t2,s ≤t1,s∧t2,e ≥t1,e ([t1,s, t2,s−1],[t2,e+ 1, t1,e]) if t1,s < t2,s∧t1,e > t2,e

Figure 5.7: Relative complement of two intervals.

The calculation of the relative complement is visualized in Figure 5.7, where all cases from Definition 5.7 are shown. It is easy to see that the required properties for interval sequences are fulfilled by the complement sequence.

This is stated as a simple theorem for later reference.

Theorem 5.4. Let I1 = [t1,s, t1,e]and Iq= [t2,s, t2,e] be two discrete temporal intervals. Then I1 \I2 yields a temporal interval sequence that fulfills the invariants stated in Definition 5.2.

Proof. The first two invariants from Definition 5.2, namely that all interval bounds have to be in N0 and that each interval has to contain at least one time point (i.e. ts ≤ te), directly follow from the conditions of the cases in Definition 5.7. More precisely, it is easy to check that for all cases except the fourth one, the conditions, together with the fact that both I1 andI2 are defined as non-empty intervals over N0, imply 0 ≤ t0s ≤ t0e. The fourth case produces an empty sequence, so all invariants apply trivially.

For the third and fourth invariant, only the last case of Definition 5.7 is relevant since the other cases produce sequences with at most one element.

Therefore, it remains to show that([t1,s, t2,s−1],[t2,e+ 1, t1,e])fulfills the third and fourth invariants. This again follows directly from the fact that I2 is an admissible discrete temporal interval, which implies t2,s ≤ t2,e and hence t2,s −1 < t2,e + 1. Since the sequence contains exactly two intervals, this satisfies both invariant3 and 4.

Based on the definitions above, it is now possible to specify the most im-portant operator, namely the intersection between an interval sequence and an interval.

Definition 5.8 (Intersection of an interval sequence with an interval). Let T = (Ii)Ni=0 be a temporal interval sequence with (Ii)li=k representing its sub-sequence fromk to l. Additionally, let I = [ts, te] be a closed temporal inter-val. Then the intersection between T and I creates a new temporal interval sequence that is defined as follows:

(Ii)li=k ∩ I :=

((Ii)li=k+1∩I)⊕(Ik∩I) if k < l (Ii0)0i=0 withI00 =Ik∩I otherwise

Similar to the union operator from Definition 5.5, the intersection defined above recursively processes each interval in the sequence and adds its intersec-tion with the query intervalI to the result sequence. As in Definition 5.5, the interval addition operator ⊕ guarantees that the resulting interval sequence satisfies the invariants of Definition 5.2. Therefore, it is also easy to show that temporal interval sequences are closed under intersection with an inter-val, which is stated in the next theorem.

Theorem 5.5. LetT = (Ii)Ni=0 be a temporal interval sequence andI = [ts, te] be a closed temporal interval. Then T ∩I yields a new admissible temporal interval sequence that fulfills the invariants from Definition 5.2.

Proof. The proof works by induction over the cardinality ofT and is structured very similar to the proof of Theorem 5.3. Since the intersection with an empty sequence is trivially empty, let the induction start withN = 0, which means thatT contains exactly one interval. In this case, Definition 5.8 directly yields T ∩I = I0∩. For the induction step, consider a cardinality of N + 1 for T. Then, according to Definition 5.8, it holds that

T ∩I = (Ii)N+1i=0 ∩ I = ((Ii)N+1i=1 ∩I)⊕(I0∩I)

The right side of the ⊕ above is a single interval by definition and, given the induction hypothesis, the left side is a valid temporal interval sequence.

Therefore, due to Theorem 5.2, T ∩I must also be an admissible temporal interval sequence.

As in the case of two intervals, the property evaluation algorithms also need to process the remainder of intersections between an interval sequence and a query interval. Hence, the relative complement operator has to be extended similarly to the extension of the intersection.

Definition 5.9 (Relative complement of an interval in an interval sequence). Let T = (Ii)Ni=0 be a temporal interval sequence with (Ii)li=k representing its subsequence from k to l. Additionally, let I = [ts, te] be a closed temporal interval. Then the relative complement ofI inT, written asT\I yields a new temporal interval sequence that is defined as follows:

(Ii)li=k\I :=

((Ii)li=k+1\I)⊕(Ik\I) if k < l (Ii0)0i=0 withI00 =Ik\I otherwise

For the sake of completeness, it is obviously necessary to show also in this case that the properties of Definition 5.2 are maintained.

Theorem 5.6. LetT = (Ii)Ni=0 be a temporal interval sequence andI = [ts, te] be a closed temporal interval. Then the relative complement T\I is an ad-missible temporal interval sequence according that fulfills the requirements of Definition 5.2.

Proof. The proof works by induction over the cardinality of T and uses Theo-rem 5.4. Otherwise, it works exactly as the one in TheoTheo-rem 5.5 and is therefore not repeated in detail.

Figure 5.8 visualizes the application of the intersection and relative com-plement operators between an interval sequence and a query interval. As mentioned before, these two operations are essential for the evaluation of tem-poral operators in SALMA’s property evaluation algorithm and will therefore appear often during the next sections.

Finally, by a similar recursion scheme as before, it is also straightforward to define the relative complements of an interval sequence in another.

Definition 5.10 (Relative complement of an interval sequence in another interval sequence). Let T1 = (I1,i)Ni=0 and T2 be temporal interval sequences.

Then the relative complement of T1 in T2, written as T2\T1 yields a new temporal interval sequence that is defined as follows:

T2\(I1,i)Ni=k:=

((T2\I1,k)\(I1,i)Ni=k+1 if k < N

T2\I1,k otherwise

Figure 5.8: Intersection and complement of sequence and interval.

Again, the validity of the construction above is stated separately in the theorem below, which follows directly from the theorem above.

Theorem 5.7. LetT1 = (I1,i)Ni=0 andT2 be temporal interval sequences. Then the relative complement T2\T1 is an admissible temporal interval sequence according that fulfills the requirements of Definition 5.2.

Proof. The proof works by induction over the cardinality ofT1 and uses The-orem 5.6. Since it is structured exactly as the one in TheThe-orem 5.5, it is not repeated in detail.

The definitions above together form a solid basis that allow the creation, access, and manipulation of temporal interval sequences. Additionally, at sev-eral points of the algorithms, a function is needed to calculate the latest time point in an interval sequence.

Definition 5.11 (Latest time point in interval sequence). Let T = (Ii)Ni=0 be a temporal interval sequence. Then the latest time point in T, written as maxt(T) is defined as follows:

maxt(T) =maxt((Ii)Ni=0) := max{t∈N0| ∃i. t∈Ii}