Reasoning over streams of input data is an essential part of human intelligence. During the last decade stream reasoning has emerged as a research area within the AI-community with many potential applications, e.g., web of things, smart cities, and social media analysis (cf. Valle et al. (2009); Mileo et al. (2017); Aglio et al. (2017)). In fact, the increased availability of streaming data via services like Google and Facebook has raised the need for reasoning engines coping with data that changes at high rate.
Logic programs are rule-based systems with the rules and facts being written in a sublanguage of predicate logic extended by a unary operator “” denoting negation-as-failure (or default negation) (Clark, 1978). While each monotone (i.e., negation-free) logic program has a unique least Herbrand model (with the least model semantics (van Emden and Kowalksi, 1976) being the accepted semantics for this class of programs), for general logic programs a large number of different purely declarative semantics exist. Many of it have been introduced some 20 years ago, among them the answer set semantics (Gelfond and Lifschitz, 1991) and the well-founded semantics (van Gelder et al., 1991). The well-founded semantics, because of its nice computational properties (computing the unique well-founded model is tractable), plays an important role in database theory. However, with the emergence of efficient solvers such as DLV (Leone et al., 2006), Smodels (Simons et al., 2002), Cmodels (Giunchiglia et al., 2006), and Clasp (Gebser et al., 2012), programming under answer set semantics led to a predominant declarative problem solving paradigm, called answer set programming (or ASP) (Marek and Truszczyński, 1999; Lifschitz, 2002). Answer set programming has a wide range of applications and has been successfully applied to various AI-related subfields such as planning and diagnosis (for a survey see Brewka et al. (2011); Eiter et al. (2009); Baral (2003)). Driven by this practical needs, a large number of extensions of classical answer set programs have been proposed, e.g. aggregates (cf. Faber et al. (2004, 2011); Pelov (2004)), choice rules (Niemelä et al., 1999), dl-atoms (Eiter et al., 2008), and general external atoms (Eiter et al., 2005). For excellent introductions to the field of answer set programming we refer the reader to Brewka et al. (2011); Baral (2003); Eiter et al. (2009).
Beck et al. (2018) introduced LARS, a Logic-based framework for Analytic Reasoning over Streams, where the semantics of LARS has been defined in terms of FLP-style answer sets (Faber et al., 2011). Syntactically, LARS programs are logic programs with negation as failure incorporating operators for temporal reasoning, most notably window operators for selecting relevant time points. Unfortunately, by preselecting fixed intervals for the semantic evaluation of programs, the rigid semantics of LARS programs is not flexible enough to constructively cope with rapidly changing data dependencies. For example, sentences of the form “ holds at time point if holds at every relevant time point” are not expressible within LARS (cf. exa:Box_b), as the interval of ‘relevant’ time points changes dynamically, whereas LARS preselects a static interval. Our first step therefore is to refine and simplify Beck et al. (2018)’s semantics in sec:Refined by employing dynamic time intervals.
Extensions of the answer set semantics adhere to minimal models or, even more restricting, to models free of unfoundedness. However, FLP-answer sets of stream logic programs may permit undesirable circular justifications similar to other ASP extensions (cf. Shen et al. (2014); Antić et al. (2013)). Fixed point semantics of logic programs (cf. Fitting (2002)), on the other hand, are constructive by nature, which suggests to define a fixed point semantics for stream logic programs targeted for foundedness, by recasting suitable operators in such a way that the FLP semantics can be reconstructed or refined, in the sense that a subset of the respective answer sets are selected (sound “approximation”). The benefit is twofold: by coinciding semantics, we get operable fixed point constructions, and by refined semantics, we obtain a sound approximation that is constructive. For this we recast two well-known fixed point operators from ordinary to stream logic programs, namely the van Emden-Kowalski operator (van Emden and Kowalksi, 1976) and the Fitting operator (Fitting, 2002). This task turns out to be non-trivial due to the intricate properties of windows (Arasu et al., 2006; Beck et al., 2018) and other modal operators occurring in rule heads. We show that the so obtained operators inherit the following characteristic properties: models of a program are characterized by the prefixed points of its associated van Emden-Kowalski operator, and the Fitting operator is monotone with respect to a suitable ordering which guarantees the existence of certain least fixed points, namely the so obtained constructive answer sets. We then show the constructiveness of our fixed point semantics in terms of level mappings (Shen et al., 2014). Specifically, we prove that our semantics captures those answer sets which possess a level mapping or, equivalently, which are free of circular justifications, which is regarded as a positive feature.
The rest of the paper is structured as follows. In sec:LARS we define the syntax and semantics of stream logic programs first in the vein of Beck et al. (2018) (sec:Beck18) followed by our refined semantics in sec:Refined. sec:operators and 4 constitute the main part of the paper. More precisely, in sec:MMt we define a novel (partial) model operator for the evaluation of rule heads, and in sec:Tp and 3.3 we recast the well-known van Emden-Kowalski operator and the Fitting operator from ordinary to stream logic programs and prove some non-trivial properties. In sec:semantics we then define a fixed point semantics for stream logic programs in terms of the (extended) Fitting operator and prove in our Main thm:main the soundness of our approach. Afterwards, in sec:level we characterize our semantics in terms of level mappings and conclude that our semantics is sound, constructive, and free of circular justifications.
2 Stream Logic Programs
We denote the set by . A partially ordered set (or poset) is a pair where is a set and is a reflexive, antisymmetric, and transitive binary relation on . A lattice is a poset where every pair of elements has a unique greatest lower bound and least upper bound in . We call complete if every subset has a greatest lower bound and a least upper bound. For any two elements , we define the interval . Given a mapping , we call a prefixed point of if , and we call a fixed point of if . Moreover, we call monotone if implies , for all . In case has a least fixed point, we denote it by . Moreover, for a mapping we denote by the function mapping every to .
2.1 Streams and Windows
In the rest of the paper, will denote a finite nonempty set of propositional atoms containing the special symbol .
A formula (over ) is defined by the grammar
where , , and , . We call (i) -free if it does not contain ; (ii) monotone if it does not contain ; and (iii) normal if it does not contain .
A stream (over ) is an infinite sequence of subsets of , i.e., for all time points . We call a stream a substream of , in symbols , if for all . In the sequel, we omit empty sets in a sequence and write, e.g., instead of , and we denote the empty sequence simply by . We define the support of , in symbols , to be the tightest interval containing ; formally, and in case , and .
A window111Beck et al. (2018) employed more sophisticated windows and called them window functions; for simplicity, we consider here only the windows defined above and note that our results are independent of the particular choice of windows. is a function mapping every stream to the substream of , where , . Note that and are monotone functions, that is, implies and , for all and .
A (stream logic) program is a finite nonempty set of rules of the form
where is a normal -formula, are formulas, and denotes negation-as-failure (Clark, 1978). We will often write in expressions of the form equ:rule to make the name of the rule explicit. For convenience, we define for a rule of the form equ:rule, , and . As is customary in logic programming, we will interpret every finite set of formulas as the conjunction over all formulas in . We call a rule a fact if , and we call ordinary if . Moreover, we define to be the conjunction of all rule heads occurring in , that is, .
2.3 Semantics of Beck et al. (2018)
Let be a closed interval in and let be a finite set, called the background data. We define the entailment relation , with respect to , for all streams , , formulas , and all time points :
if and ;
if or ;
if or ;
if , for some ;
if , for all ;
if , and ;
In case , we call a -model of .
We wish to evaluate with respect to some fixed stream , called the data stream. We call a stream an interpretation stream for if , and we say that such an interpretation stream is a -model of if , for all rules . The reduct of with respect to and at time point is given by
[Beck et al. (2018)] Let be a closed interval in and let . An interpretation stream for is a -answer stream of (for ) if is a -model of and there is no -model of (for ) with .
Note that the minimality condition in def:Beck18 is given with respect to the same interval , which is crucial. In fact, the following example shows that as a consequence of def:Beck18, trivial programs may have infinitely many answer streams which is counter-intuitive from an answer set programming perspective.
The ordinary program consisting of a single fact has the single answer set . Given some arbitrary time point for the evaluation of within the LARS context defined above, we therefore expect to have the single answer stream . Unfortunately, under Beck et al. (2018)’s semantics, has infinitely many answer streams: the -answer stream , the -answer stream , the -answer stream and so on.
The reason for the existence of the infinitely many answer streams for the trivial program in exa:a is the preselection of the fixed interval in def:Beck18 for the semantic evaluation of programs. As a negative consequence of this choice, which appears to be an artificial simplification of the semantics of programs, is that some specifications which occur in practice cannot be expressed within the LARS language as is demonstrated by the following example.
Let be some interval and let be some time point. According to def:Beck18, the statement “ holds at if holds at every time point in ” is formalized by the single rule evaluated at time point . Now consider the slighly different statement “ holds at if holds at every relevant time point in the support222Recall from sec:Syntax that the support of a stream is given by the tightest intervall containing all non-empty (i.e., relevant) time points. of the input data.” As natural as this statement seems, it is not expressible within the LARS language. The intuitive reason is that the support function is flexible and depends on the data, whereas the preselected interval is fixed by the programmer and therefore does not depend on the data. In a sense, preselecting fixed intervals for the semantic evaluation of programs contradicts the very idea of stream reasoning which aims at coping with data that changes at a high rate by incorporating window operators on a syntactic level for selecting relevant time points. Arguably, it is therefore more natural to formalize the first statement by the rule thus syntactically encoding the restricted interval , and interpreting as a formalization of the second statement (cf. exa:Box_b_2).
2.4 Refined Semantics
We refine the FLP-style semantics of Beck et al. (2018) (cf. def:Beck18) by employing dynamic intervals. For this we first refine the entailment relation by using the support function in the definition of and for dynamically computing intervals instead of the fixed interval used by Beck et al. (2018):
if , for some ;
if , for all ;
if , for .
In case , we call a -model of , and we call -consistent (resp., -inconsistent) if has at least one (resp., no) -model. For convenience, we call a -formula if is -consistent.
The formula is 1-inconsistent since is a reference to time point 2 which is outside the scope of the window evaluated at time point 1. More precisely, let be an arbitrary stream and compute which implies —so is not a 1-model of .
Note that -inconsistency of normal formulas can be easily verified by a syntactic check as in the example above and in the rest of the paper we assume that (normal) formulas occurring in rule heads are -consistent, for all relevant .
We can now refine and simplify the definition of answer streams by omitting the reference to interval which gives a more natural minimality condition.
An interpretation stream for is a -answer stream of (for ) if is a substream minimal -model of .
The ordinary program of exa:a consisting of the single fact has the single -answer stream as expected.
The two statements in exa:Box_b are formalized according to def:answer by the two rules and , respectively, as desired.
We now illustrate the above concepts in more detail with the following running example.
Consider the program consisting of the following rules:
Let the background data consist of the single proposition , and let the data stream be given by
That is, the propositions and hold at time point 5 and so on. Then, the 5-answer streams of (for ) are given by:
For instance, we verify that is indeed a 5-answer stream of . First of all, note that is a 5-model of (for ): (i) as holds in at time points 5 and 7, we have and which implies and ; (ii) as holds at every time point in the interval , we have which implies ; and (iii) as and hold at every time point in , we have which implies .
Now we argue that is a minimal 5-model of . To this end, suppose is a 5-model of for with . Then, since and , for to be a 5-model of we must have and ; but this is equivalent to , for all , and , for all where and , respectively. That is, we have , for all , and , for all —but this, together with , immediately implies which shows that is indeed a minimal 5-model of and therefore a 5-answer stream of .
It is important to emphasize that we can capture Beck et al. (2018)’s semantics as follows.
Let be an interval and let be some time point. An interpretation stream for is a -answer stream of if, and only if, is a -answer stream of
where is a special symbol not occurring in and consists of all rules of the form
At this point, we have successfully extended the FLP-style answer set semantics from ordinary to stream logic programs by refining Beck et al. (2018)’s semantics. Unfortunately, as for other program extensions (cf. Shen et al. (2014); Antić et al. (2013)), our FLP-style semantics may permit circular justifications as is demonstrated by the following example.
Consider the program consisting of the following two rules:
We argue that the -model of is a -answer stream of , for every (and ): (i) The empty stream is not a -model of since both rules fire in ; (ii) the stream is not a -model of since fires; (iii) the stream is not a -model of since fires. This shows that is indeed a subset minimal -model of and, hence, a -answer stream of .
In the next two sections, we will develop the tools for formalizing the reasoning in exa:running in an operational setting (cf. exa:Fp) while avoiding circular justifications.
3 Fixed Point Operators
In this section, we recast the following well-known fixed point operators from ordinary to stream logic programs: (i) the van Emden-Kowalski operator (van Emden and Kowalksi, 1976), and (ii) the Fitting operator (Fitting, 2002). This task turns out to be non-trivial due to the intricate properties of windows and other modal operators occurring in rule heads.
In the rest of the paper, let be a stream, let be some data stream, let be some background data, and let be some fixed time point.
3.1 The Model Operator
In this subsection, we define an operator for the evaluation of rule heads. Specifically, given a normal -formula , we wish to construct a -model of which is in some sense minimal with respect to a given stream (cf. thm:MMt).
For normal -formulas and , and for , we define the partial model operator at time point and with respect to , inductively as follows:
Finally, define the model operator to be the twofold application of , that is,
One can easily derive the following computation rules for the model operator:
In case is -free, we will often write instead of to indicate that the evaluation of does not depend on .
Let be the -free normal 1-formula , and compute
which is a 1-model of . On the other hand, for the normal 1-formula containing , we obtain
which is not a 1-model of ; however, by applying twice, we do obtain a 1-model of :
Intuitively, to obtain a 1-model of , we have to apply twice as the subformula induces an expansion of the support of the generated stream which has to be taken into account for the generation of a 1-model for (note that conjunctions are treated separately by the partial model operator).
exa:MMt indicates that requires a special treatment. In fact, if is -free then does not depend on and, consequently, in this case and coincide which simplifies the matters significantly.
For every -free normal -formula , holds for all streams and ; consequently, .
By definition of the partial model operator, depends on only if contains . The second assertion follows from the first with and .
In the next two propositions, we show some monotonicity properties of the (partial) model operator.
For every normal -formula and all streams and , implies and . Moreover, implies and , for all finite sets and of normal -formulas.
The first inclusion can be shown by a straightforward structural induction on , so we prove here only the case , for some normal -formula :
The second inclusion, , is a direct consequence of the first. Finally, the second part of the proposition is an immediate consequence of the first part and the definition of the (partial) model operator.
For every normal -formula , and
The first identity can be proved by a straightforward structural induction on .
We prove the inclusion by structural induction on . The only non-trivial case is , for some normal -formula :
where the second and third inclusion follows from prop:MMt-mon together with
and the last equality holds since:
To prove equ:box, first note that, by definition, holds for all ; consequently:
It will often be convenient to separate a proof into a -free and a general case. Therefore we define the translation of with respect to at time point to be the homomorphic extension to all normal -formulas of:
where we interpret the empty conjunction in as . Intuitively, eliminates every occurring in while preserving the meaning of in the following sense.
For every normal -formula , and for all streams and with , we have if, and only if, .
A straightforward structural induction on .
Interestingly, the next proposition shows that we can simulate the model operator by the partial model operator applied to an appropriate translation of the input formula.
For every normal -formula , and, consequently, with .
The first identity can be proved by a straightforward structural induction on , and the second identity follows from the first, i.e., .
Monotone formulas inherit their name from the following property.
For every monotone formula , implies , for all streams .
We are now ready to prove our first theorem which shows that is a -model of which is in some sense “minimal” (with respect to ).
For every normal -formula , is a -model of , that is,
In case is -free, a single application of suffices, that is, . Moreover, if is a -model of , then .
We start with the second assertion and prove by structural induction on that in case is -free, . The induction hypothesis , and the case are straightforward. In what follows, let and denote normal -formulas. For , we have and, by induction hypothesis, and . Since and are -free, we have as a consequence of prop:mon (recall that -free normal formulas are monotone). Finally, for we have and, by induction hypothesis, . Since is -consistent by assumption, (cf. rem:incon and 3.1) and, hence, which is equivalent to .
We now turn to the general case and prove that holds for any normal -formula , by first translating into a -free formula, and then referring to the first part of the proof. Let . Since is -free, we know from the first part of the proof that
From equ:MMt-1 and equ:MMt-2 we infer
Now since (cf. prop:seq), prop:ibt proves our claim.
Finally, a straightforward structural induction on shows .
We want to emphasize that the requirement in thm:MMt of being -consistent is essential. For instance, reconsider the 1-inconsistent normal formula of rem:incon, and compute which is not a 1-model of .
3.2 The van Emden-Kowalski Operator
We are now ready to extend the well-known van Emden-Kowalski operator to the class of stream logic programs.
We define the van Emden-Kowalski operator of (for at time point ), for every stream , by
As for ordinary logic programs (van Emden and Kowalksi, 1976), prefixed points of the van Emden-Kowalski operator characterize the models of (for at time point ).
A stream is a -model of if, and only if, is a prefixed point of .
Suppose is a -model of and note that this is equivalent to
Moreover, note that we can rewrite the van Emden-Kowalski operator more compactly as
So we have to show (recall that holds by assumption), but this follows directly from equ:Tp-1 together with the last part of thm:MMt.
For the other direction, we show that implies . Let . By prop:seq,
On the other hand, and prop:MMt-mon imply
Consequently, from equ:Tp-2 and equ:Tp-3 we infer
Intuitively, equ:Tp-4 means that in case , one application of suffices (cf. thm:MMt and exa:MMt). Moreover, prop:mbt implies
Since is a -model of (cf. thm:MMt), holds by equ:Tp-5, and is monotone, prop:mon and equ:Tp-5 imply