A Formal Comparison between Datalog-based Languages for Stream Reasoning
(extended version)

Nicola Leone 1Department of Mathematics and Computer Science, University of Calabria, Rende, Italy
, 1name.surname@unical.it
   Marco Manna 1Department of Mathematics and Computer Science, University of Calabria, Rende, Italy
, 1name.surname@unical.it
   Maria Concetta Morelli 2Department of Mathematics and Computer Science, University of Calabria, Rende, Italy
2maria.morelli@unical.it
   Simona Perri 1Department of Mathematics and Computer Science, University of Calabria, Rende, Italy
, 1name.surname@unical.it
Abstract

The paper investigates the relative expressiveness of two logic-based languages for reasoning over streams, namely LARS Programs — the language of the Logic-based framework for Analytic Reasoning over Streams called LARS — and LDSR — the language of the recent extension of the -DLV system for stream reasoning called I-DLV-sr. Although these two languages build over Datalog, they do differ both in syntax and semantics. To reconcile their expressive capabilities for stream reasoning, we define a comparison framework that allows us to show that, without any restrictions, the two languages are incomparable and to identify fragments of each language that can be expressed via the other one.

Keywords:
Stream Reasoning, Datalog, Knowledge Representation and Reasoning, Relative Expressiveness
\tocauthor

Nicola Leone, Marco Manna, Maria Concetta Morelli, Simona Perri

1 Introduction

Stream Reasoning (SR) DBLP:journals/datasci/DellAglioVHB17 is a recently emerged research area that consists in the application of inference techniques to heterogeneous and highly dynamic streaming data. Stream reasoning capabilities are nowadays a key requirement for deploying effective applications in several real-world domains, such as IoT, Smart Cities, Emergency Management. Different SR approaches have been proposed in contexts such as Complex Event Processing, Semantic Web and Knowledge Representation and Reasoning (KRR) DBLP:journals/ijsc/BarbieriBCVG10; hoeksema2011high; DBLP:conf/lpnmr/PhamAM19; DBLP:conf/semweb/PhuocDPH11. In the KRR research field, the Answer Set Programming (ASP) declarative formalism DBLP:journals/cacm/BrewkaET11; DBLP:conf/ijcai/GebserLMPRS18 has been acknowledged as a particularly attractive basis for SR DBLP:journals/datasci/DellAglioVHB17 and a number of SR solutions relying on ASP have been recently proposed  beck2018lars; bazoobandi2017expressive; beck2018ticker; eiter2019distributed; DBLP:conf/bigdataconf/RenCNX18; DBLP:conf/rr/MileoAPH13; DBLP:conf/lpnmr/PhamAM19; DBLP:conf/ai/DoLL11; DBLP:conf/lpnmr/GebserGKS11; DBLP:journals/tplp/CalimeriMMMPZ21. Among these, I-DLV-sr DBLP:journals/tplp/CalimeriMMMPZ21 is a SR system that efficiently scale over real-world application domains thanks to a proper integration of the well-established stream processor Apache Flink carbone2015apache and the incremental ASP reasoner -DLV DBLP:journals/tplp/IanniPZ20. Its input language, called LDSR (the Language of -DLV for Stream Reasoning) inherits the highly declarative nature and ease of use from ASP, while being extended with new constructs that are relevant for practical SR scenarios.

Although LDSR enjoys valuable knowledge modelling capabilities together with an efficient and effective reasoner, it would be desirable to formally investigate its expressive power. This is exactly the mission of the present paper. To this aim, the prime objective is to compare LDSR with one of the most famous and well-studied formalisms for reasoning over streams that goes under the name of LARS Programs (the language of LARS), where LARS is the Logic-based framework for Analytic Reasoning over Streams beck2018lars. More precisely, the paper investigates the relative expressiveness of LDSR and LARS Programs. Despite the fact that these languages build over Datalog and represent the information via sets of ASP ground predicate atoms associated with different time points, unfortunately they overall differ both in syntax and semantics. In particular, LDSR associates information that is true at every time point with standard ASP facts, whereas LARS Programs involve background atoms whose truth is not directly associated with all the time points. Moreover, given an input stream, LDSR returns a single set of information related to the most recent time point (streaming model), whereas LARS Programs associate, for each different time point of the stream, another stream called answer stream at that time point.

To reconcile the expressive capabilities for stream reasoning of LDSR and LARS Programs, we first define a comparison framework that allows to understand in which cases, starting from the same input stream, both languages may produce the same output. Inside this framework, we identify three output profiles —called atomic, bound, and full— that fix the form of the output stream. Without any restriction on the two languages, the paper shows that they are incomparable under all the output profiles. Eventually, for each output profile, the paper isolates large fragments of each of the two languages that can be expressed via the other one.

2 Preliminaries

We assume to have finite sets , , and consisting of variables, constants, predicate names and respectively; we constrain and to be disjoint. A term is either a variable in or a constant in . A predicate atom has the form , where is a predicate name, are terms and is the arity of the predicate atom; a predicate atom of arity can be also denoted by . A predicate atom is ground if none of its terms is a variable. We denote by the set of all ground predicate atoms constructible from predicate names in and constants in . We divide the set of predicates into two disjoint subsets, namely the extensional predicates and the intensional predicates . Extensional predicates are further partitioned into for background data and for data streams. The mentioned partitions are analogously defined for ground atoms , and . In what follows we will introduce different types of constructs peculiar to the two languages considered in this paper. In both, given a set of constructs , we will denote by the set of predicates appearing in .

A stream is a sequence of sets of ground predicate atoms such that for , . Each natural number is called time point. A ground predicate atom is true at the -th time point. Given a value s.t. , we define the restriction of to the stream denoted with . Moreover, let we indicate with the stream with for each . A subset of a stream is a stream such that for each where is a subset of consecutive numbers of the set and for each . For a stream , a backward observation identifies ground predicate atoms that are true at some time points preceding the -th time point. More formally, given a stream and a set of numbers , we define the backward observation of w.r.t. as the family of sets , and we denote it as . Given , a backward observation of w.r.t. is called window.

2.1 Lars syntax and semantics

A window function is a function that returns, given a stream and a time point , a substream of . We consider only time-based window functions, which select all the atoms appearing in the last time points, to which a window is trivially associated according to the definition above. Given a predicate atom , a term and a window function , formulas are defined by the following grammar:

A LARS program P is a set of rules of the form , where are formulas. Given a rule , we call the head of , denoted with , and we call the conjunction the body of , denoted with . A ground formula can be satisfied at a time point in a that is a triple where is a stream, is a set of window functions and . Let , we start defining the entailment relation between and formulas:

  • iff or

  • iff

  • iff and

  • iff or

  • iff or

  • iff for some

  • iff for all ,

  • iff and ,

  • , iff where

  • iff .

The structure satisfies at time ( if . Given a ground LARS program , a stream and a structure we say that: is a model of rule for at time , denoted , if ; is a model of for at time , denoted , if for all rules ; is a minimal model, if no model of for at time exists such that and ; and The reduct of a program with respect to at time is defined by . Fixed an input stream , contains only atoms belong to , we call any stream such that all atoms that occur in but not in have intensional predicates. An interpretation stream for a stream is an of a program , if is a -minimal model of the reduct for at time . The semantics of the non-ground programs is given by the answer streams of according groundings, obtained by replacing variables with constants from , respectively time points from , in all possible ways. We consider LARS programs with a single answer stream for each time point, denoted with , and we indicate the single answer stream of for at with .

2.2 Ldsr syntax and semantics

Given a predicate atom , a term , a counting term , and a finite non-empty set , we define three types of streaming atoms:

In particular, if is of the form , then this set can be alternatively written as inside streaming atoms; also we may write in place of . A streaming atom (resp., ) is said to be a positive streaming literal (resp., negative streaming literal), where denotes negation as failure. A streaming literal is said to be harmless if it has form or ; otherwise, it is said to be non-harmless. A streaming literal is said to be ground if none of its terms is a variable.

A rule is a formula of form    or , where is a predicate atom, and represent a conjunction of literals (streaming literals or other literals defined in the ASP-Core-2 standard DBLP:journals/tplp/CalimeriFGIKKLM20).

For a rule , we say that the head of is the set , whereas the set is referred to as the body of . A rule is safe if all variables in or in a negative streaming literal of also appear in a positive streaming literal of .

A program is a finite set of safe rules. We denote with the set of rules of of form (1) and with the set of rules of of form (2).

A program is stratified if there is a partition of disjoint sets of rules (called strata) such that for both these conditions hold: () for each harmless literal in the body of a rule in with predicate , ; () for each non-harmless literal in the body of a rule in with predicate , . We call a stratification for and is stratified by . An LDSR program is a program being also stratified.

A backward observation allows to define the truth of a ground streaming literal at a given time point. Given a stream , , and the backward observation , Table 1 reports when entails a ground streaming atom (denoted ) or its negation (). If ( ) we say that is true (false) at time point .

Table 1: Entailment of ground streaming literals.

To make a comparison between and LDSR, we defined also for LDSR a model-theoretic semantics that can be shown to be equivalent to the operational semantics originally defined. Moreover, besides the concept of streaming model for LDSR, we defined the concept of answer stream.

Consider an LDSR program . Given a rule , the ground instantiation of denotes the set of rules obtained by applying all possible substitutions from the variables in to elements of . In particular, to the counting terms are applied only constants belong to . Similarly, the ground instantiation of is the set . Given a ground rule , a stream and a stream such that , we say that is a model of for , denoted , if when . We say that is a model of for , denoted , if for all rules . Moreover, is a minimal model, if no model of exists such that and . Let be a model of for , an atom is temporary in if and there exists no rule such that and . Accordingly, let be the set of all temporary atoms in , the stream is called the permanent part of . Eventually, the reduct of w.r.t. , denoted by , consists of the rules such that .

Definition 1

Given an LDSR program , a stream and a stream such that , is called answer stream and streaming model of for if: if , is the permanent part of the minimal model of the reduct for the stream ; if , for all , is the permanent part of the minimal model of the reduct for the stream ; and is a minimal model of the reduct for the stream .

Note that, differently from LARS, for which the information associated with each time point is entirely derived at the time point of evaluation, for LDSR, each time point in the answer stream is associated with the information derived when the time point has been evaluated. In other words, the answer stream for LDSR is obtained by collecting the results of the previous time points and integrating them with the result of the time point of evaluation.

3 Framework

In this section, we present the framework that has been designed for comparing the languages and LDSR. The comparison focuses on different parts of the answer stream. In particular, given an input stream , when referring to an evaluation time point , one could compare the answer streams only at , or in all the time points up to or also in all time points up to . To this aim, we define three types of streams. Given and , we say that a stream is of if for each ; if for each ; and if may be nonempty for each .

Consider a language , an input stream , a set of ground predicate atoms and a program , we call an tuple. According to the three types of streams, for a tuple and for each time point , we now define three types of output streams for each language .

Given a and a time point , we define:

  • where for and is the streaming model of on .

  • , where is the answer stream of for and for .

  • where is the answer stream of for and for .

Analogously, given a and a time point , and the answer stream , we define:

  • where for and .

  • , where for and for .

  • where for .

We now define when a fragment of a language can be expressed in the other one in our framework. In particular, we differentiate expressible fragments from strictly expressible fragments. Given a stream form ,and , with , a fragment is via if there exists a mapping such that, for each -tuple and for each time point of evaluation , it holds that ; moreover, is via if . Basically, for the non strict expressiveness, a translation into the other language is possible but it can involve the addition of auxiliary predicates, while for the strict one, there is a translation that does not require auxiliary predicates and thus for which the outputs coincide without the need of any filtering.

We are now ready to compare the two languages. The first result of the comparison is that, without any restrictions, the two languages are incomparable. The following two propositions describe the results. The ideas behind the formal demonstrations, which are instead reported in appendix 0.B, are also introduced.

Proposition 1

is not via LDSR.

To see this, consider the simple program =. This program, that expresses that the presence of an atom in a time point infers the presence of an atom in the previous time point, is not expressible in LDSR since in its semantic the information associated at every time point are relative only to the information received and inferred up to it.

Proposition 2

LDSR is not via .

To prove this result, consider the following LDSR program where the predicate belongs to the input predicates . The program is not expressible in since its semantics avoids to infer ground atoms over input predicates.

Since implies holds for , Proposition 1 and 2 imply the following result.

Theorem 3.1

and LDSR are incomparable under each of the three stream forms.

Given the incomparability of the languages, we introduced some restrictions to identify fragments of a language expressible in the other. Up to now, we identified seven fragments that are described in detail in sections 3.1 and 3.2. Here, we briefly discuss their relations and expressiveness (see Fig. 3 and Tables 3 and 3). In particular, Table 3 presents the fragments of , and . All of them are strictly expressible via LDSR. is the largest identified fragment and it is atomic-expressible; is obtained from by imposing some restriction and it is bound-expressible, while is obtained by further restricting , and allows for achieving full-expressivity.

Table 2: to LDSR
strictly not strictly
Table 3: LDSR to
strictly not strictly
 fragments
(a) LARS fragments
 fragments
(b) LDSR fragments
Figure 3: Fragments and their relations

As for LDSR, Table 3 summarizes its identified fragments ,, and . The largest fragment is , which is bound-expressible via ; the fragment , that restricts , allows full expressiveness; the other two fragments allows for strictly expressiveness: further restricts , and it is full-expressible, while is obtained by imposing restrictions on and is bound-expressible.

3.1 to Ldsr

Here we present the identified fragments of . We consider two types of rules:

where is an intensional predicate atom and is a predicate atom, and for . For a rule of type , we denote as the consequent of the implication, and with the set of formulas in the premise; moreover, for a rule of type , we denote with the atom and with the set of formulas . Let be a program, we denote with the set of rules of of type and with the set of rules of of type .
We say that a predicate is if there are two rules and with , and . The set of marked predicates of a program is denoted with .

Consider a program containing rules of type and only. Let and . We define the graph , where: ; + if there exists a rule with and occurring in a formula without negation or if there exists a rule with and occurring in a formula without negation; and - if there exists a rule with and occurs in a formula with negation or if there exists a rule with and occurring in a formula with negation.

Definition 2

Fragment of collects all the programs that meet the next conditions: ; ; ; no cycle in contains an arc labeled with “-”.

Roughly, contains only programs that are stratified w.r.t negation, featuring only rules of types (I) and (II), where no marked predicate appears in premises and in bodies.

Proposition 3

is strictly atomic-expressible via LDSR.

Indeed, it can be shown that there is a mapping such that for each and for each time point of evaluation , it holds that . In particular, given a program , the LDSR program is obtained by replacing:

  • each rule ) of type with the LDSR rule of form

  • each rule of type with the LDSR rule of form

where associates each formula in the fragment with a LDSR streaming atom as reported below:

  • .

  • .

  • .

  • .

  • where is a formula.

Intuitively, the idea of the mapping is that rules of type that must be evaluated at each time point are associated with rules of form (1) and rules of type that infer information only at the evaluation time point are associate with LDSR rules of form (2) which are evaluated at each time point but the derivations of the time points preceding have been forgotten via the operator. Moreover, we impose the restrictions and for defining in order to achieve atomic-expressiveness; indeed, they ensure that, if in LDSR a permanent information is derived relying on a temporary information, this is not used to derive other information.

Now, we define the fragment that imposes an additional restriction w.r.t to , and the fragment that further restricts .

Definition 3

The fragment of is the subset of the programs of that meet the condition .

Proposition 4

is strictly bound-expressible via LDSR.

It can be shown that for the mapping , it holds that for each and for each time point of evaluation , . Basically, the additional condition for fragment avoids that a temporary information associated to a time point can generate a permanent information.

We now show an example of a program belonging to fragment and its image with respect to the function . The example is taken from one of the tasks of the “model and solve” Stream Reasoning Hackathon 2021 DBLP:conf/esws/SchneiderALDP22. The task concerns urban traffic management. Traffic is observed from a top-down, third-person perspective, and vehicle movement flows in a given road network coded as Datalog facts are considered. We want to identify the vehicles that appear or disappear in the network. It is then necessary to note vehicles that were absent at the previous time point and are now present and vice versa. A rule of type is used to evaluate the presence of vehicles at the current and previous time points; then the obtained information is used in a rule of type that detects the appearance or disappearance of a vehicle at the evaluation time point. This task can be modelled via the following program in :

The corresponding LDSR program, image of the function, is:

Definition 4

The fragment of is the subset of the programs of that meet the condition .

Proposition 5

is strictly full-expressible via LDSR.

Similarly to , it can be shown that, considering the mapping , it holds that that for each and for each time point of evaluation , . Intuitively, since in LDSR the evaluation of a program with respect to a time point can not add information in the output stream at time points that are subsequent to , to achieve full expressiveness, we impose the restriction to rules of type type in as these are evaluated only at and do not change the output in the subsequent time points.

3.2 Ldsr to

Here we present the identified fragments of LDSR along with their expressiveness. While, for the fragments of we obtained strict expressiveness and each rule in has been translated into exactly one rule in LDSR, for the fragments of LDSR, the translation, in general, needs auxiliary atoms and additional rules to simulate the behavior of rules of the form (2) and of some streaming and aggregates atoms.

The largest identified fragment is that is defined as follows.

Definition 5

The fragment is the subset of the LDSR programs that meet the condition .

Basically, is obtained from LDSR by simply imposing that no extensional predicate appears in the head of a rule.

Proposition 6

is bound-expressible via .

It can be shown that there is a mapping such that for each and for each , . First, we note that, in general, each streaming atom in has to properly translated into a formula; moreover a special rewriting, requiring additional rules, has to be performed for streaming atoms of the form , where is a variable in and for all the aggregate atoms. Thus, without going into details, the mapping relies on a function that associates each streaming atom (but those of form ) with a formula that expresses the condition that must be satisfied in the stream for the streaming atom to be true; moreover, if is an aggregate atom or a streaming atom of the form , associates it with a formula containing auxiliary atoms defined via an additional set of rules that are needed to simulate its semantics. For the sake of the presentation, the function and the set of additional rules are reported in appendix 0.A.1

Furthermore, given a program , the mapping has to replace each rule in with one or more rules. In sum, the program is obtained by:

  • replacing each rule of form (1) with the rule
    .

  • for each rule of form (2),

    • replacing it with the rule

    • adding the rule .

  • adding for each streaming atom of the form , where is a variable in or aggregates atom, a set of rules .

Basically, the mapping manages the interaction between the two forms of rules, simulating, at an evaluation time point , the temporary derivations obtained in the previous time points and evaluating their effect on the permanent derivations that will be part of the output. This is mainly obtained by creating and handling a copy of each rule of the form (2) where the suffix “temp” is added to the head predicate. Moreover, since the streaming atoms in LDSR are evaluated according to the backward observation, we need to identify the reference time point in which the formulas representing the conditions expressed by the streaming atoms have to checked. To do this, we use the formula that evaluates the tautology within a window of size 0 and thus, it holds in the rule instance where the variable corresponds to the reference time point.

We are now ready to define the fragment that is obtained from by avoiding rules of form (1).

Definition 6

The fragment of LDSR is the subset of the programs of that meet the condition .

Proposition 7

is via .

To see this, consider, the mapping such that, for each program , is obtained by:

  • replacing each rule of form (2) , with the rule
    .

  • adding for each streaming atom of the form , where is a variable in or aggregates atom, a set of rules .

It can be shown that is such that for each and for each , . Roughly, similarly to , relies on a function for rewriting body atoms and adds auxiliary rules for handling aggregate atoms or a streaming atoms of the form (more details on this are reported in Appendix in0.A.2); however the translation for the fragment is simpler than the one for , as it is sufficient to associate each rule of form (2) with a rule of type (II). Indeed, since rules of form (1) are not allowed, there is no need to consider the information that can be derived in a permanent way through them. The condition defining the fragment ensures the full expressiveness: since a program in this fragment features only rules of form (2), and its translation only rules of type (II), their evaluation at each time point can derive information only at , while leaving unchanged the output in the other time points.

The fragment restrict to reach strict full expressiveness.

Definition 7

The fragment of LDSR is the subset of the programs of in which streaming atoms of the form where and aggregate atoms are not allowed in rule bodies.

Proposition 8

is strictly full-expressible via .

It can be shown that for the mapping , it holds that for each and for each , . Since no atoms involving the addition of auxiliary predicates are considered, is strictly expressible.

The last considered fragment still features strict expressiveness, but of bound type, as, differently from , it allows also rules of form (1) to some extent.

Definition 8

The fragment of LDSR is the subset of the programs of that meet the following conditions: streaming atoms of the form where and aggregate atoms are not allowed in rule bodies.

Proposition 9

is strictly bound-expressible via .

It can be shown that there is a mapping such that for each and for each , . To see this, consider, the mapping such that, for each program , is obtained by:

  • replacing each rule of form (2) with the rule
    .

  • replacing each rule of form (1) with the rule
    .

The mapping relies on the same function as for the rules of form (2). In addition, for the rule of form (1), a different function is used to associate the body streaming atoms with formulas based on the following definition.

Definition 9

Given an atom and a LDSR rule with we call definition of in , denoted with , the conjunction . Given an LDSR program the definition of in is .

This definition identifies, for each predicate in the head of a rule of form (2), a formula relying only on permanent information that can be used in the translation in place of . Further details on the translation and the functions are reported in Appendix 0.A.3. We note here that the strict expressiveness of this fragment is obtained since the translation of the allowed streaming atoms does not require the use of additional atoms, and condition simplifies the rewriting of the rules of form w.r.t what fragment . Indeed, in this case, it is not necessary to add the rules used by such as that required additional auxiliary atoms.

Consider, for example, the LDSR program that could be used for monitoring irregularity in a subway station monitoring system. Three minutes are expected to elapse between the arrival of one train and the next, so the program records an irregularity when one train passes and another has already passed in one of the previous two minutes:

The program belongs to the fragment, and the corresponding program with respect to the function is as follows:

4 Conclusion

This work presents a formal comparison about the relative expressiveness of the two languages LDSR and LARS. The main contribution of the work is twofold: we propose a suitable framework to compare the two languages, which exhibit different syntax and semantics. and for each language, we identify a number of fragments that can be expressed by the other one, showing possible rewritings. In order to compare the semantics of the two languages, we first provided an alternative equivalent model-theoretic definition of the semantics of LDSR, instead of the operational one originally provided. Moreover, we defined the concept of answer stream also for LDSR, as an extension of the streaming model. The framework allowed us for focusing the comparison on different forms of the output stream (atomic, bound, full) and on the nature of the rewriting that could forbid or admit the addition of auxiliary predicates (strict or not strict expressiveness, respectively). For each given form of output and type of rewriting, we studied how to build fragments of a language that could meet the desired expressiveness. To do this, we considered the semantics behind each construct or combination of constructs that can occur in the rules and the effect of interactions between the different rules. The fragments are the largest we identified so far, but, of course, these could be further enlarged and new ones could be possibly found; this will be the subject of future works.

5 Acknowledgments

This work has been partially supported by the project “MAP4ID - Multipurpose Analytics Platform 4 Industrial Data”, N. F/190138/01-03/X44 and by the Italian MIUR Ministry and the Presidency of the Council of Ministers under the project “Declarative Reasoning over Streams” under the “PRIN” 2017 call (CUP , project 2017M9C25L_001).

References

Appendix 0.A Details on the translation from Ldsr to

We introduce a function that associates any streaming atoms with a formula. Function will be used to present , and and works as follows:

  • By applying over we obtain:

    where , and are fresh variables.

  • By applying over we obtain:

    where and are fresh variables.

  • By applying over with we obtain:

    where , and are fresh variables.

  • By applying over with we obtain the predicate atom .

Basically, the function returns a LARS formula that is true when the corresponding LDSR streaming atom is true. The formula identifies the time points related to the backward observation of a stream w.r.t the set for which the condition defined by the streaming atom holds.

0.a.1 The function

We present the function , used by . In particular, associates each streaming atom (but those of form ) with a formula that expresses the condition that must be satisfied in the stream for the streaming atom to be true; it has to consider also the temporary information possibly present in the previous time point when the streaming atom was evaluated. The presence of these information in the stream is simulated with the auxiliary atoms with suffix “temp”.

  • Let ,

  • Let ,

Moreover, if is a streaming atom of the form or an aggregate atom, associates it with a formula containing auxiliary atoms defined via an additional set of rules that are needed to simulate its semantics. Let ,

The set of rules defining where are the following rules:

  • for

  • .

First, rules are needed, where each one verifies if atoms of type occur or times. Eventually, a rule is needed to verify the exact number of occurrences. Similar approaches are used for the translation of the aggregate atoms.
Eventually, for each positive literal .

0.a.2 The function

We present the function , used by . In particular, associates each streaming atom (but those of form ) with a formula that expresses the condition that must be satisfied in the stream for the streaming atom to be true.

  • .

  • .

  • if .

Moreover, if is a streaming atom of the form or an aggregate atom, associates it with a formula containing auxiliary atoms defined via an additional set of rules that are needed to simulate its semantics. Let , . The set of rules defining for where are the following rules:

  • for

  • .

First, rules are needed, where each one verifies if atoms of type occur or times. Eventually, a rule is needed to verify the exact number of occurrences. Similar approaches are used for the translation of the aggregate atoms.

Eventually, for each positive literal .

0.a.3 The function

We present the function , used by . In particular, associates each streaming atom (but those of form ) with a formula that expresses the condition that must be satisfied in the stream for the streaming atom to be true; it has to consider the temporary information possibly present in a time point when was the evaluation time point and thus the streaming atom was evaluated. It is possible to verify the presence of an atom at the time of a previous evaluation also if was derived by a rule of form (2): since in the body of any rule of form (2) are only present atoms deriving from the input stream o from rules of form (1), we can know if an atom was derived considering its derivation . We assume that the program rules do not share variables.

  • .

  • .

  • Let ,

  • Let ,

Eventually, for each positive literal .

Appendix 0.B Proofs

0.b.1 Statement and Proof of Lemma 1

Lemma 1

Let be a LDSR program, an input stream and , for all set of ground predicate atoms and for all with for , we have that .

Let and , for definition of answer stream:

  • is the permanent part of a minimal model of the reduct for the stream and is the permanent part of a minimal model of the reduct for the stream . Since we have that ;

  • for all , is the permanent part of a minimal model of the reduct for the stream . Since , we have that .

  • is a minimal model of the reduct for the stream . Since , we have that .

Finally, for definition for .

0.b.2 Proof of Proposition 1

Let be the LARS program .

Let and . Let any subset of T such that and . Let . Let a stream such that:

Let . Observe that:

  • if

  • if

  • if

Assume, by contradiction, that there exists a mapping such that, for each and and for each time point of evaluation , it holds that . Let and a stream such that:

Let and , we have that and .
Since for the Lemma 1 , we have that
.

0.b.3 Proof of Proposition 2

Let be the LDSR program Let and . Let a stream with for . Assume, by contradiction, that there exists a mapping such that, for each and and for each time point of evaluation , it holds that .

Let , and , we have that .
For definition, let , we have that , but is an interpretation stream for , so all atoms that occur in but not in must have intensional predicates but the atom has predicate with .