Splitting a Hybrid ASP Program
Abstract
Hybrid Answer Set Programming (Hybrid ASP) is an extension of Answer Set Programming (ASP) that allows ASP-like rules to interact with outside sources. The Splitting Set Theorem is an important and extensively used result for ASP. The paper introduces the Splitting Set Theorem for Hybrid ASP, which is for Hybrid ASP the equivalent of the Splitting Set Theorem, and shows how it can be applied to simplify computing answer sets for Hybrid ASP programs most relevant for practical applications.
An important result for logic programs is the Splitting Set Theorem [13], which shows how computing an answer set for a program can be broken into several tasks of the same kind for smaller programs. The theorem and its more general variant the Splitting Sequence Theorem are extensively used for proving other theorems, for instance in [2], [10] or [4] among many others. Hybrid Answer Set Programming (Hybrid ASP) [5] is an extension of ASP that allows ASP-like rules to interact with outside sources, which makes Hybrid ASP well suited for practical applications. For instance, recently Hybrid ASP has been used in a system for diagnosing failures of data processing pipelines at Google Inc [9]. The theory of Hybrid ASP, however is not extensively developed. This paper introduces the Splitting Set Theorem for Hybrid ASP and the Splitting Sequence Theorem for Hybrid ASP, which are the equivalents for Hybrid ASP of the similarly named results for ASP, thus making a small step towards developing the theory of Hybrid ASP. The author hopes that the new theorems will have many future applications, in the way analogous to the original Splitting Set Theorem and Splitting Sequence Theorem. The potential of the new theorems to be useful in the future, and the significance of the new results is demonstrated by using them to simplify computation of answer sets for the types of Hybrid ASP programs most relevant for practical applications, i.e. those applications that have answer sets with states having times of the form , such as the programs that result from translating descriptions in action languages Hybrid AL [8] and Hybrid ALE [3], or such as the programs used in other applications of Hybrid ASP [7], [6].
The paper is structured as follows. The first section reviews ASP, The Splitting Set Theorem and Hybrid ASP. The paper then presents The Splitting Set Theorem for Hybrid ASP and The Splitting Sequence Theorem for Hybrid ASP. The following section presents an algorithm that simplifies computing answer sets for Hybrid ASP. Finally a short conclusion follows.
1 Review of the Splitting Set Theorem and Hybrid ASP
We will begin with a brief review of ASP. Let be a nonempty set of symbols called atoms. A block is an expression of the form
(1) |
where are atoms. For a block as above, let the set of atoms of be defined as . is called the positive part of , and is called the negative part of . A set operation applied to a block will indicate the same set operation applied to with the block being reconstructed from the result of the set operation. For instance will indicate a block .
A normal propositional logic programming rule is an expression of the form
(2) |
where is an atom and is a block. We define the head of as , and we define the body of as . We define .
Given any set and a block , we say that satisfies , written , if and . For a rule , we say that satisfies , written , if whenever satisfies the body of , then satisfies the head of . A normal logic program is a set of rules. We say that is a model of , written , if satisfies every rule of .
A Horn rule is the rule with the empty negative part. A Horn program is a set of Horn rules. Each Horn program has a least model under inclusion, , which can be defined using the one-step provability operator as follows. For any set , let denote the set of all subsets of . The one-step provability operator associated with the Horn program [11] is defined by setting
for any . We define by induction by setting , and . Then the least model can be computed as
If is a normal logic program and , then the Gelfond-Lifschitz (GL) reduct of with respect to [12] is the Horn program which results by eliminating those rules such that and replacing other rules by . We then say that is a stable model for if equals the least model of .
An answer set programming rule is an expression of the form (2) where are classical literals, i.e., either positive atoms or atoms preceded by the classical negation sign . The set of literals of will be denoted . Answer sets are defined in analogy to stable models, but taking into account that atoms may be preceded by classical negation and that atoms and classically negated atoms are mutually exclusive in answer sets.
We will now follow [13] in review of the Splitting Set Theorem and the Splitting Sequence Theorem. A splitting set for a program is any set such that for every rule if then . The set of rules such that is called the bottom of relative to the splitting set and is denoted by . The set is the top of relative to .
Consider . For each rule such that and take the rule defined by
The program consisting of all rules obtained in this way will be denoted by .
A solution to with respect to is a pair of sets of literals such that
-
•
is an answer set for
-
•
is an answer set for
-
•
is consistent (a set is consistent if for any atom it does not contain both and classically negated atom )
Splitting Set Theorem. Let be a splitting set for a program . A set of literals is a consistent answer set for if and only if for some solution to with respect to .
We will now review extending the definition of a splitting set to a splitting sequence. A sequence is a family whose index set is an initial segment of ordinals, . The ordinal is the length of the sequence. A sequence of sets is monotone if whenever , and continuous if, for each limit ordinal , .
A splitting sequence for a program is a monotone, continuous sequence of splitting sets for such that . The definition of a solution with respect to a splitting set is extended to splitting sequence as follows. A solution to with respect to is a sequence of sets of literals such that
-
•
is an answer set for ,
-
•
for any such that , is an answer set for ,
-
•
for any limit ordinal , ,
-
•
is consistent.
Splitting Sequence Theorem. Let be a splitting sequence for a program . A set of literals is a consistent answer set for if and only if for some solution to with respect to .
We will now proceed with the review of Hybrid ASP. A Hybrid ASP program has an underlying parameter space . Elements of are of the form where is time and are arbitrary parameter values. We shall let denote and denote for . We refer to the elements of as generalized positions. Let be a set of atoms of . Then the universe of is . Let be a block. We will define
If , we let . Given an initial condition, defined as a subset let . Given and , we say that and initial condition satisfy a block of the form (1) at the generalized position , written , if the following holds:
-
•
if then and
-
•
if then and .
We say that satisfies a n-tuple of blocks written as with the initial condition at the n-tuple of generalized positions , written , if for .
There are two types of rules in Hybrid ASP. Advancing rules are of the form
(3) |
where is a function returning a set of generalized positions, are blocks, is a literal, and is a subset of such that if , then and ( applied to ) is a subset of such that for all , . Here and in the next rule, we allow blocks to be empty for any . is called the constraint set of the rule and will be denoted by . is called the advancing algorithm of the rule and is denoted by . The arity of rule , , is equal to .
The idea is that if and for each , is satisfied at the generalized position , then the function can be applied to to produce a set of generalized positions such that if , then and holds. Thus advancing rules are like input-output devices in that the function allows the user to derive possible successor generalized positions as well as certain atoms which are to hold at such positions. The advancing algorithm can access outside sources quite arbitrarily in that it may involve functions for solving differential or integral equations, solving a set of linear equations or linear programming equations, solving an optimization problem, etc. (as for example in [6]).
Stationary rules are of the form
(4) |
where are blocks, is a literal, is called a boolean algorithm of the rule and will be denoted by , and is the constraint set of the rule denoted . A boolean algorithm is a function returning either true or false. We will sometimes treat a boolean algorithm of the rule as a set. For instance will indicate all the n-tuples of generalized positions such that is true and . The arity of rule , , is equal to .
Stationary rules are much like normal logic programming rules in that they
allow us to derive new atoms at a given generalized position .
The idea is that if and
for each , is satisfied at the generalized position , then holds. The difference is that a derivation
with our stationary rules can depend on what happens in the multiple past time
points and the boolean algorithm can be any sort of a function which
returns either true or false.
For an advancing rule or a stationary rule as above we define the positive part of the body of , denoted and we define the negative part of the body of , denoted . For the rest of the paper, we denote by the arity of a hybrid ASP rule when the rule is clear from the context.
A Hybrid ASP program is a collection of Hybrid ASP advancing and stationary rules. To define the notion of a stable model of , we first must define the notion of a Hybrid ASP Horn program and the one-step provability operator for Hybrid ASP Horn programs.
A Hybrid ASP Horn program is a Hybrid ASP program which does not contain any negated atoms. Let be a Horn Hybrid ASP program and be an initial condition. Then the one-step provability operator is defined so that given , consists of together with the set of all such that
-
1.
there exists a stationary rule and such that and or
-
2.
there exists an advancing rule and such that and and .
The stable model semantics for Hybrid ASP programs is defined as follows. Let and be an initial condition in . An Hybrid ASP rule is inapplicable for if for all , either (i) there is an such that , (ii) if is an advancing algorithm, or (iii) if is a boolean algorithm.
If is not inapplicable for then we define the GL reduct of over and , denoted by as follows:
-
1.
If is an advancing rule then where is equal to the set of in such that and , and .
-
2.
If is a stationary rule then where is equal to the set of all in such that and is true.
One note to make about the definition above is that GL reduct cannot derive generalized positions that are not in . This is because the range of in the definition is restricted to .
We form a GL reduct of over and , as follows.
-
1.
Eliminate all rules which are inapplicable for .
-
2.
If a rule is not eliminated in step 1, then replace it by the rule .
We then say that is a stable model of with initial condition if
Answer sets are defined in analogy to stable models, but taking into account that atoms may be preceded by classical negation and that and are mutually exclusive in answer sets.
2 The Splitting Set Theorem for Hybrid ASP
We will now introduce additional notation that will be used throughout the rest of the paper.
Without loss of generality assume that all advancing rules are of the form
and all of stationary rules are of the form
where is a literal, , …, are blocks, is a constraint set, is an advancing algorithm, and is a boolean algorithm.
Let be a set of literals and generalized position pairs, and let be a generalized position. Define
Let . We say that is a splitting set of with initial condition (w.i.c.) if for all
-
1.
if is advancing and and and then both for , and .
-
2.
if is stationary and and then both for , and .
As in the case of the original splitting set theorem [13] the splitting set acts to split Hybrid ASP program into the part that can derive or one of its subsets, and the remaining part of , which can derive or one of its subsets. The difference, however, is that for a given rule the conclusion of the rule may be in for some n-tuples of generalized positions () and not for others. So, the splitting set splits not only the program, but the rules themselves. This will be elaborated below.
As in the case of the original splitting set theorem we identify by a set of new rules that capture the rules and generalized positions that may contribute to generating .
Define as
In other words, is the set of all rules of that could contribute to for some tuple of generalized positions.
For an advancing rule let
For a stationary rule let
That is are all the generalized position tuples for which could contribute to .
For an advancing rule define by
is an advancing algorithm that for any tuple of generalized positions will only generate those that contribute to .
For an advancing rule let
For a stationary rule let
Define the bottom of with respect to , as
The idea is that just like in [13], forms only those rules that could contribute to , and so will be an answer set of w.i.c. iff for some answer set of w.i.c. .
We will now proceed to define with the understanding that the same rule may contribute to for some generalized position tuples and contribute to for others.
First, we need to identify remainder of not captured by . That is we need to identify the parts contributing to the complement of of those rules that have other parts contributing to . This is due to an important difference between Hybrid ASP and ASP. In ASP a rule contributes a single conclusion. Thus if ASP rule contributes to the splitting set then it must be in the bottom of the program. In Hybrid ASP, however, a rule acts more like a collection of rules contributing different conclusions for different generalized position tuples. Consequently, the parts of the rules that contribute to the complement of the splitting set need to be separated from those that contribute to the splitting set itself. We will now proceed with the definition.
For an advancing rule define
For a stationary define
That is, contains those generalized position tuples such that for them the rule contributes to the complement of .
For an advancing rule and define
That is is a restriction of to those generalized positions such that for them contributes to the complement of .
When define
In other words, is the part of that contributes to the complement of .
Define
That is contain those parts of the rules in that contribute to the complement of .
Let . For a rule define
That is is the set of those generalized position tuples such that for them the ”projection” of onto is satisfied by .
Finally
In other words, for every rule such that and for every where the ”projection” of onto is satisfied by at , we add to a rule , which is a part of rule that will be active only for that with the ”projection” part removed.
Theorem 1. (The Splitting Set Theorem for Hybrid ASP). Let be a Hybrid ASP program over . Let be a splitting set of w.i.c. . A set is a answer set of w.i.c. iff is a answer set of w.i.c. and is a answer set of w.i.c. .
Sketch of a proof. We first prove that if is an answer set of w.i.c. then is an answer set of w.i.c. . That is, we want to show that . In direction we show by induction on in one-step provability operator that if a rule in derives in , then the rule must derive in for some . In direction we show by induction on in that if derives in where , then derives in for some .
We then proceed to prove that if is an answer set of w.i.c. , and then is an answer set of w.i.c. . That is, we want to show that . In direction we prove by induction that if derives in then there is a corresponding rule in that derives in for some . In direction we prove by induction on in that if derives in where then there is a corresponding in that derives in for some .
To finish the proof we need to show that if is an answer set of w.i.c. and is an answer set of w.i.c. then is an answer set of w.i.c. . That is we want to show that . We do so by induction in both directions in a manner similar to the previous part of the proof.
Similar to the Splitting Sequence Theorem of [13] we also prove the Splitting Sequence Theorem for Hybrid ASP.
Theorem 2. (The Splitting Sequence Theorem for Hybrid ASP). Let be a monotone continuous sequence of splitting sets for a Hybrid ASP program over w.i.c. , and . is an answer set of w.i.c. iff for a sequence s.t.
-
•
is an answer set of w.i.c.
-
•
for any such that is an answer set for
w.i.c. and and is an answer set of w.i.c. .
The proof proceeds by the induction on and is a direct application of The Splitting Set Theorem for Hybrid ASP.
In the Splitting Sequence Theorem for Hybrid ASP, is a program that derives as its answer set w.i.c. . Now, . So, to derive (i.e. the subset of that is in ) we need to remove from the rules that derive . That is accomplished by subtracting from the rules . Nevertheless, this subtracts too much as some of the rules in contribute to for some generalized position tuples. The parts of those rules that contribute to are , which we then add back. Applying operator to the resulting program (i.e. ) then removes the ”useless” part of the rules with respect to .
3 An Application: Computing Answer Sets of Hybrid ASP Programs
One of the applications of the Splitting Sequence Theorem for Hybrid ASP is proving the correctness of a certain algorithm for computing answer sets of certain types of Hybrid ASP programs. We will consider only the programs where the set of generalized positions is such that if then where , and for any advancing rule of any arity , for any we have that for all , . That is, these are the programs with generalized positions with discrete times of the form , and whenever an advancing algorithm produces a new generalized position, that generalized position has time larger by than the largest time in the input arguments. All applications of Hybrid ASP known to the author are restricted to such programs. This is the case for using Hybrid ASP to diagnose failure of data processing pipelines, as described in [3] and [9]. It is the case for the Hybrid ASP programs that are the result of translation from action languages Hybrid AL [8] and Hybrid ALE [3]. It is also the case for using Hybrid ASP to compute optimal finite horizon policies in dynamic domains [6].
The algorithm.
We will first describe the algorithm informally. We will use some of the new notation which will be defined further below. The algorithm is based on the observation that in Hybrid ASP the facts in the ”future” cannot affect the facts in the ”past”. That is for any two generalized position and , if then the state at cannot be used to derive the state at (but the state at can be used to derive the state at ). Consequently, it should be possible to first derive the states at some minimal time , then derive the states at the time , then derive the states at time and so on.
Without the loss of generality, we will assume that for any initial condition , there exists such that . Let be a Hybrid ASP program over . Let be an initial condition. The algorithm will be defined inductively. Suppose the set of all the (literal, generalized position) pairs for the generalized positions with time up to is derived by the algorithm for some . The algorithm will first identify all the advancing rules that could derive generalized positions with time . These are the advancing rules such that satisfies their body for some , where and the time of is . The set of the ”next” generalized positions (i.e. the set of generalized positions with time ) is derived by choosing a subset of the set of all the generalized positions derived by these rules. To formally define such a choice of a subset we introduce a concept of an advancing selector , which is a function s.t. for and , is a subset of . We will denote the set of ”next” generalized positions derived in this manner by .
Now, for every ”next” generalized position in derived by an advancing rule , it must be that is derived. So, for every there is a set of literals that will be derived at by the advancing rules in . This set of literals will be denoted by .
Next we turn our attention to the role of the stationary rules in deriving hybrid state at a ”next” generalized position . There is a set of stationary rules that can contribute to the hybrid state at . If such a stationary rule has blocks, then the first blocks are satisfied by (at some generalized positions ) and are in . Thus, only the last block, which we will denote by needs to be evaluated at . Thus, the relevant part of such a stationary rule is a regular ASP rule of the form . All such regular ASP rules applicable at will be denoted by . A state at is then an answer set of a regular ASP program . To formally define such a choice we will use a concept of a stationary selector , which we will define further below.
We will now define the algorithm formally.
For a set and generalized positions and , let
Let . We define the set of advancing rules active at relative to as
That is, is the set of the advancing rules whose body is satisfied by at and .
We define the set of ”next” generalized positions at relative to as
That is is the set of ”next” generalized positions generated by any advancing rule active at relative to .
For a time , we define the set of all the ”next” generalized positions relative to , and an advancing selector as
The set of all heads at relative to is then
Let . We define the set of stationary rules active at relative to as
That is is the set of stationary rules with blocks satisfied by at respectively, and .
We define a stationary selector to be a function such that for for for an ASP program , is an answer set of . That is, a stationary selector chooses one of answer sets of a regular ASP programs .
For a stationary rule of the form , we define an applicable reduct of
For we define the active reduct of at relative to as
Finally, for and let . Similarly for , .
We are now ready to formally specify our algorithm. We define a sequence of sets , as follows:
That is, the state at any generalized position with time equal to is determined by taking all the stationary rules with one block (i.e. rules of the form ) such that , composing a regular ASP program from the reducts of the form derived from those rules, and then finding an answer set of that program.
Now, suppose are defined for and . Let
That is is the set of generalized positions with time derived by the advancing rules .
Let
if and otherwise.
That is, is a collection of hybrid states where , and where
is an answer set of a regular ASP program composed of
the active reducts of the stationary rules that can contribute to
and the heads of the advancing rules that derive .
Theorem 3. is an answer set of w.i.c. iff there is advancing selector and a stationary selector such that with and .
Sketch of a proof. We begin by specifying a sequence of splitting sets defined as
We then first show that is an answer set of w.i.c. . The rules that can contribute to are stationary-1 rules such as . These rules will contribute regular ASP rules to for every . We then show that is an answer set of iff is an answer set of w.i.c. .
The rest is proven by induction using The Splitting Sequence Theorem. That is is an answer set of w.i.c. , where iff there exists an advancing selector and a stationary selector such that is equal to as defined by the algorithm.
For the forward direction of the inductive step we define . We define
We then show . We then use the induction on one-step provability operator to show that if is an answer set of w.i.c. then . That is we show that if is an answer set of w.i.c. then the algorithm derives it as .
For the reverse direction we first show . That is we show that the literals of are also derived by at . We then use induction on one step provability , where to show that for all it is the case that , for some . That is, we show that the literals derived by the regular ASP program are also derived by at . But this merely shows that . We also need to show that .
We do that by using induction on one step provability operator to show that for all it is the case that is a subset of .
This completes the proof of the theorem.
The algorithm computes an answer set of the Hybrid ASP program w.i.c. inductively, by computing a subset of the answer set at time , then at time , and so on through time . Moreover, the aglorithm reduces the process of computing an answer set of a Hybrid ASP program to the repeated application of two processes: the process of computing the set of ”next” generalized positions, and the process of computing an answer set of a regular ASP program derived from advancing and stationary Hybrid ASP rules applicable at these ”next” generalized positions.
4 Conclusion
The paper presents The Splitting Set Theorem for Hybrid ASP, which is the
equivalent for Hybrid ASP of the Splitting Set Theorem
[13], and the Splitting Sequence Theorem for
Hybrid ASP (which is the equivalent for Hybrid ASP of The Splitting Sequence
Theorem). The original Splitting Set Theorem proved to be a widely used
result. It is the author’s hope that the new theorem will likewise prove to
have many applications. The paper discusses one of the applications of the
theorems to computing answer sets of Hybrid ASP programs.
Acknowledgements. The author would like to thank Jori
Bomanson for insightful comments that helped to enhance the paper.
References
- [1]
- [2] Marcello Balduccini & Michael Gelfond (2003): Diagnostic reasoning with A-Prolog. TPLP 3(4-5), pp. 425–461. Available at http://dx.doi.org/10.1017/S1471068403001807.
- [3] Jori Bomanson & Alex Brik (2019): Diagnosing Data Pipeline Failures Using Action Languages. In Marcello Balduccini, Yuliya Lierler & Stefan Woltran, editors: Logic Programming and Nonmonotonic Reasoning - 15th International Conference, LPNMR 2019, Philadelphia, PA, USA, June 3-7, 2019, Proceedings, Lecture Notes in Computer Science 11481, Springer, pp. 181–194, 10.1007/978-3-030-20528-7_14.
- [4] Piero A. Bonatti (2008): Erratum to: Reasoning with infinite stable models [Artificial Intelligence 156 (1) (2004) 75-111]. Artif. Intell. 172(15), pp. 1833–1835, 10.1016/j.artint.2008.07.002.
- [5] Alex Brik & Jeffrey B. Remmel (2011): Hybrid ASP. In John P. Gallagher & Michael Gelfond, editors: ICLP (Technical Communications), LIPIcs 11, Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, pp. 40–50. Available at http://dx.doi.org/10.4230/LIPIcs.ICLP.2011.40.
- [6] Alex Brik & Jeffrey B. Remmel (2012): Computing a Finite Horizon Optimal Strategy Using Hybrid ASP. In: 14th International Workshop on Non-Monotonic Reasoning, NMR 2012, Rome, Italy, June 8-10, 2012. Procedings.
- [7] Alex Brik & Jeffrey B. Remmel (2015): Diagnosing Automatic Whitelisting for Dynamic Remarketing Ads Using Hybrid ASP. In Francesco Calimeri, Giovambattista Ianni & Miroslaw Truszczynski, editors: Logic Programming and Nonmonotonic Reasoning - 13th International Conference, LPNMR 2015, Lexington, KY, USA, September 27-30, 2015. Proceedings, Lecture Notes in Computer Science 9345, Springer, pp. 173–185, 10.1007/978-3-319-23264-5.
- [8] Alex Brik & Jeffrey B. Remmel (2017): Action Language Hybrid AL. In Marcello Balduccini & Tomi Janhunen, editors: Logic Programming and Nonmonotonic Reasoning - 14th International Conference, LPNMR 2017, Espoo, Finland, July 3-6, 2017, Proceedings, Lecture Notes in Computer Science 10377, Springer, pp. 322–335, 10.1007/978-3-319-61660-5_29.
- [9] Alex Brik & Jeffrey Xu (2020): Diagnosing Data Pipeline Failures Using Action Languages: A Progress Report. In Ekaterina Komendantskaya & Yanhong Annie Liu, editors: Practical Aspects of Declarative Languages - 22nd International Symposium, PADL 2020, New Orleans, LA, USA, January 20-21, 2020, Proceedings, Lecture Notes in Computer Science 12007, Springer, pp. 73–81, 10.1007/978-3-030-39197-3_5.
- [10] Steve Dworschak, Susanne Grell, Victoria J. Nikiforova, Torsten Schaub & Joachim Selbig (2008): Modeling Biological Networks by Action Languages via Answer Set Programming. Constraints 13(1-2), pp. 21–65, 10.1007/s10601-007-9031-y.
- [11] Maarten H. van Emden & Robert A. Kowalski (1976): The Semantics of Predicate Logic as a Programming Language. J. ACM 23(4), pp. 733–742. Available at http://doi.acm.org/10.1145/321978.321991.
- [12] Michael Gelfond & Vladimir Lifschitz (1988): The Stable Model Semantics for Logic Programming. In: ICLP/SLP, pp. 1070–1080.
- [13] Vladimir Lifschitz & Hudson Turner (1994): Splitting a Logic Program. In Pascal Van Hentenryck, editor: Logic Programming, Proceedings of the Eleventh International Conference on Logic Programming, Santa Marherita Ligure, Italy, June 13-18, 1994, MIT Press, pp. 23–37.