Reformulating the Situation Calculus and the Event Calculus in the General Theory of Stable Models and in Answer Set Programming

Circumscription and logic programs under the stable model semantics are two well-known nonmonotonic formalisms. The former has served as a basis of classical logic based action formalisms, such as the situation calculus, the event calculus and temporal action logics; the latter has served as a basis of a family of action languages, such as language A and several of its descendants. Based on the discovery that circumscription and the stable model semantics coincide on a class of canonical formulas, we reformulate the situation calculus and the event calculus in the general theory of stable models. We also present a translation that turns the reformulations further into answer set programs, so that efficient answer set solvers can be applied to compute the situation calculus and the event calculus.

While the two nonmonotonic formalisms have been applied to overlapping classes of problems, minimal model reasoning ensured by circumscription does not coincide with stable model reasoning.Moreover, these formalisms have different roots.While circumscription is defined in terms of translation into classical (second-order) logic, stable models proposed by Gelfond and Lifschitz (1988) are defined in terms of grounding and fixpoints in the style of Reiter's default logic (Reiter, 1980).These differences in part account for the fact that the two formalisms have formed rather disparate traditions in knowledge representation research.In particular, in the area of temporal reasoning, the former has served as a basis of classical logic based action calculi, such as the situation calculus (McCarthy & Hayes, 1969;Reiter, 2001), the event calculus (Shanahan, 1995) and temporal action logics (Doherty, Gustafsson, Karlsson, & Kvarnström, 1998), whereas the latter has served as a basis of a family of action languages, such as language A (Gelfond & Lifschitz, 1998) and several of its descendants which can be translated into logic programs under the stable model semantics.
However, a recent generalization of the stable model semantics shed new light on the relationship between circumscription and stable models.The first-order stable model semantics defined by Ferraris, Lee andLifschitz (2007, 2011) characterizes the stable models of a first-order sentence as the models (in the sense of first-order logic) of the sentence that satisfy the "stability" condition, expressed by a second-order formula that is similar to the one used to define circumscription.Since logic programs are viewed as a special class of first-order sentences under the stable model semantics, this definition extends the stable model semantics by Gelfond and Lifschitz (1988) to the full first-order level without limiting attention to Herbrand models.Essentially the same characterization was independently given by Lin and Zhou (2011), via logic of knowledge and justified assumption (Lin & Shoham, 1992).These definitions are also equivalent to the definition of Quantified Equilibrium Logic given by Pearce and Valverde (2005), which is defined in terms of the logic of Here-and-There (Heyting, 1930).
The new definition of a stable model motivates us to investigate the relationship between stable model reasoning and minimal model reasoning.In particular, we focus on their relationship in the area of temporal reasoning.We show how the situation calculus and the event calculus can be reformulated in the first-order stable model semantics, and further in ASP.This is not only theoretically interesting, but also practically useful as it allows us to leverage efficient answer set solvers for computing circumscriptive action theories.
For this, we develop two technical results.First, we show that circumscription and the first-order stable model semantics coincide on the class of canonical formulas.This is the largest syntactic class identified so far on which the two semantics coincide, and is general enough to cover several circumscriptive action formalisms, such as the situation calculus, the event calculus, and temporal action logics.The result allows us to reformulate those action formalisms in the first-order stable model semantics.While minimal model reasoning sometimes leads to unintuitive results, those circumscriptive action formalisms are carefully designed to avoid such cases, and our result implies that minimal model reasoning in those action formalisms can also be viewed as stable model reasoning.
Second, we identify a class of almost universal formulas, which can be turned into the syntax of a logic program while preserving stable models.It turns out that the reformulations of the situation calculus and the event calculus in the first-order stable model semantics fall into this class of formulas.We introduce system f2lp that turns formulas in this class to logic programs, and, in conjunction with the result on canonical formulas, use the combination of f2lp and answer set solvers to compute the situation calculus and the event calculus.
Our work makes explicit the relationship between classical logic and logic program traditions in temporal reasoning.Interestingly, the development of the event calculus has spanned over both traditions.The original version of the event calculus (Kowalski & Sergot, 1986) was formulated in logic programs, but not under the stable model semantics (that was the time before the invention of the stable model semantics).More extensive developments have been later carried out on the classical logic foundation via circumscription (e.g., Shanahan, 1995Shanahan, , 1997Shanahan, , 1999;;Miller & Shanahan, 1999;Mueller, 2004), but the relation to the logic program formulation remained implicit.Based on the reduction of circumscription to completion, SAT-based event calculus systems were implemented, one by Shanahan and Witkowski (2004) and another by Mueller (2004).The latter system is called the dec reasoner, 1 which outperforms the former thanks to a more efficient and general compilation method into propositional logic.While the system handles a large fragment of the event calculus, it still cannot handle recursive and disjunctive axioms since completion cannot be applied to such axioms.Our ASP-based approach on the other hand can handle the full version of the event calculus under the assumption that the domain is given and finite.Thanks to the efficiency of ASP solvers, our experiments indicate that the ASP-based event calculus reasoner is significantly faster than the dec reasoner (Appendix B).
Similar to the logic programming tradition of the event calculus, the situation calculus (McCarthy & Hayes, 1969;Reiter, 2001) can be implemented in Prolog, based on the fact that Clark's completion semantics accounts for definitional axioms.But unlike the event calculus, to the best of our knowledge, efficient propositional solvers have not been applied to directly compute the models of situation calculus theories.In this paper, we reformulate Lin's causal action theories (1995) and Reiter's basic action theories (2001) in the first-order stable model semantics and in ASP.For basic action theories, we also provide an ASP-based encoding method that obtains Reiter's successor state axioms from the effect axioms and the generic inertia axioms adopted in ASP, the idea of which is close to Reiter's frame default (1980).
The paper is organized as follows.The next section reviews the definitions of circumscription and the first-order stable model semantics, and presents the definition of a canonical formula.Based on this, Sections 3 and 4 reformulate the event calculus and the situation calculus in the first-order stable model semantics.Section 5 shows a translation that turns almost universal formulas into logic programs that can be accepted by ASP solvers.Sections 6 and 7 use this result to turn the reformulations of the event calculus and the situation calculus given in Sections 3 and 4 into the input language of ASP solvers.Complete proofs are given in Appendix C.

Circumscription and First-Order Stable Model Semantics
We assume the following set of primitive propositional connectives and quantifiers: We understand ¬F as an abbreviation of F → ⊥; symbol stands for ⊥ → ⊥, and

Review: Circumscription
Let p be a list of distinct predicate constants p 1 , . . ., p n , and let u be a list of distinct predicate variables u 1 , . . ., u n .By u ≤ p we denote the conjunction of the formulas ∀x(u i (x) → p i (x)) for all i = 1, . . .n, where x is a list of distinct object variables whose length is the same as the arity of p i .Expression u < p stands for (u ≤ p) ∧ ¬(p ≤ u).For Lee & Palla instance, if p and q are unary predicate constants then (u, v) Circumscription is defined in terms of the CIRC operator with minimized predicates.For any first-order formula F , expression CIRC[F ; p] stands for the second-order formula where F (u) is the formula obtained from F by substituting u i for p i .When F is a sentence (i.e., a formula with no free variables), intuitively, the models of CIRC[F ; p] are the models of F that are "minimal" on p.
The definition is straightforwardly extended to the case when F is a many-sorted firstorder formula (Lifschitz, 1994, Section 2.4), which is the language that the event calculus and the situation calculus are based on.

Review: First-Order Stable Model Semantics
This review follows the definition by Ferraris et al. (2011).There, the stable models are defined in terms of the SM operator, whose definition is similar to the CIRC operator in the previous section.For any first-order formula F and any finite list of predicate constants p = (p 1 , . . ., p n ), formula SM[F ; p] is defined as where u is defined the same as in CIRC[F ; p], and F * (u) is defined recursively as follows: • p i (t) * = u i (t) for any list t of terms; • F * = F for any atomic formula F (including ⊥ and equality) that does not contain members of p; The predicates in p are called intensional: these are the predicates that we "intend to characterize" by F in terms of non-intensional predicates.2When F is a sentence, the models of the second-order sentence SM[F ; p] are called the p-stable models of F : they are the models of F that are "stable" on p.We will often simply write SM[F ] in place of SM[F ; p] when p is the list of all predicate constants occurring in F .According to Lee, Lifschitz, and Palla (2008), answer sets are defined as a special class of stable models as follows.By σ(F ) we denote the signature consisting of the object, function and predicate constants occurring in F .If F contains at least one object constant, an Herbrand interpretation of σ(F ) that satisfies SM [F ] is called an answer set of F .The answer sets of a logic program Π are defined as the answer sets of the FOL-representation of Π (i.e., the conjunction of the universal closures of implications corresponding to the rules).For example, the FOL-representation of the program and SM[F ] is which is equivalent to the first-order sentence (Ferraris et al., 2007, Example 3).The stable models of F are any first-order models of (2).The only answer set of F is the Herbrand model {p(a), q(b), r(a)}.
According to Ferraris et al. (2011), this definition of an answer set, when applied to the syntax of logic programs, is equivalent to the traditional definition of an answer set that is based on grounding and fixpoints (Gelfond & Lifschitz, 1988).
Note that the definition of a stable model is more general than the definition of an answer set in the following ways: stable models are not restricted to Herbrand models, the underlying signature can be arbitrary, and the intensional predicates are not fixed to the list of predicate constants occurring in the formula.The last fact is not essential in view of the following proposition.By pr (F ) we denote the list of all predicate constants occurring in F ; by Choice(p) we denote the conjunction of "choice formulas" ∀x(p(x) ∨ ¬p(x)) for all predicate constants p in p, where x is a list of distinct object variables; by False(p) we denote the conjunction of ∀x¬p(x) for all predicate constants p in p.We sometimes identify a list with the corresponding set when there is no confusion.
Notice that the (implicit) intensional predicates on the right-hand side of (3) are those in (pr (F ) ∪ p).The Choice formula makes the predicates in (pr (F ) \ p) to be exempt from the stability checking.On the other hand, the False formula makes the predicates in (p \ pr (F )) to be stabilized (i.e., to have empty extents), though they do not occur in F .Ferraris et al. (2011) incorporate strong negation into the stable model semantics by distinguishing between intensional predicates of two kinds, positive and negative.Each negative intensional predicate has the form ∼p, where p is a positive intensional predicate and '∼' is a symbol for strong negation.Syntactically ∼ is not a logical connective, as it can appear only as a part of a predicate constant.An interpretation of the underlying signature is coherent if it satisfies the formula where x is a list of distinct object variables, for each negative predicate ∼p.We usually consider coherent interpretations only.Like the extension of circumscription to many-sorted first-order sentences, the definition of a stable model is straightforwardly extended to many-sorted first-order sentences.

Equivalence of the Stable Model Semantics and Circumscription on Canonical Formulas
Neither the stable model semantics nor circumscription is stronger than the other.For example, CIRC[∀x(p(x) ∨ ¬p(x)); p] (5) is equivalent to ∀x¬p(x), and is equivalent to , so that (5) is stronger than (6).On the other hand, is equivalent to ∀x(¬p(x) ↔ q(x)), and is equivalent to ∀x(¬p(x) ∧ q(x)), so that ( 8) is stronger than (7).
In this section, we show that the two semantics coincide on a class of formulas called canonical formulas, which we define below.We first review the notions of positive, negative, and strictly positive occurrences.
Definition 1 We say that an occurrence of a predicate constant, or any other subexpression, in a formula F is positive if the number of implications containing that occurrence in the antecedent is even, and negative otherwise.(Recall that we treat ¬G as shorthand for G → ⊥.)We say that the occurrence is strictly positive if the number of implications in F containing that occurrence in the antecedent is 0.
For example, in (1), both occurrences of q are positive, but only the first one is strictly positive.
Definition 2 We say that a formula F is canonical relative to a list p of predicate constants if • no occurrence of a predicate constant from p is in the antecedents of more than one implication in F , and • every occurrence of a predicate constant from p that is in the scope of a strictly positive occurrence of ∃ or ∨ in F is strictly positive in F .
Example 1 The formula ∀x(¬p(x) → q(x)) that is shown above is not canonical relative to {p, q} since it does not satisfy the first clause of the definition (p occurs in the antecedents of two implications as ¬p(x) is shorthand for p(x) → ⊥).On the other hand, the formula is canonical relative to {q}.The formula is not canonical relative to {p} since it does not satisfy the second clause (the second occurrence of p is in the scope of a strictly positive occurrence of ∨, but is not strictly positive in (10)); the formula p(a) ∧ (∃x p(x) → ∃x q(x)) is canonical relative to {p, q}, while p(a, a) ∧ ∃x(p(x, a) → p(b, x)) (12) is not canonical relative to {p, q} since it does not satisfy the second clause (the second occurrence of p is in the scope of a strictly positive occurrence of ∃, but is not strictly positive in formula ( 12)).
The following theorem states that, for any canonical formula, circumscription coincides with the stable model semantics.
Theorem 1 For any canonical formula F relative to p, is logically valid.
For instance, for formula (11), which is canonical relative to {p, q}, formulas CIRC[(11); p, q] and SM [(11); p, q] are equivalent to each other.Also, any sentence F is clearly canonical relative to ∅, so that CIRC[F ; ∅] is equivalent to SM[F ; ∅], which in turn is equivalent to F .On the other hand, such equivalence may not necessarily hold for non-canonical formulas.For instance, we observed that, for formula (10) that is not canonical relative to {p}, formulas ( 5) and ( 6) are not equivalent to each other.For formula (9) that is not canonical relative to {p, q}, formulas (7) and ( 8) are not equivalent to each other.We also observe that formula (12) that is not canonical relative to {p, q}, CIRC[(12); p, q] is not equivalent to SM[(12); p, q]: the Herbrand interpretation {p(a, a), p(b, a)} satisfies SM[(12); p, q], but does not satisfy CIRC [(12); p, q].
Note that non-canonical formulas can often be equivalently rewritten as canonical formulas.Since any equivalent transformation preserves the models of circumscription, Theorem 1 can be applied to such non-canonical formulas, by first rewriting them as canonical formulas.For example, formula (9) is equivalent to which is canonical relative to {p, q}, so that CIRC[(9); p, q] is equivalent to SM[(14); p, q].For another example, formula (10) is equivalent to which is canonical relative to {p}, so that CIRC[(10); p] is equivalent to SM[(15); p].It is clear that this treatment can be applied to any quantifier-free formula (including any propositional formula) because a quantifier-free formula can be equivalently rewritten as a canonical formula by first rewriting it into a clausal normal form and then turning each clause into the form C → D, where C is a conjunction of atoms and D is a disjunction of atoms.3Sections 3 and 4 use Theorem 1 to reformulate the event calculus and the situation calculus in the first-order stable model semantics.

Reformulating the Event Calculus in the General Theory of Stable Models
In this section, we review the syntax of circumscriptive event calculus described in Chapter 2 of the book by Mueller (2006).Based on the observation that the syntax conforms to the condition of canonicality, we present a few reformulations of the event calculus in the general theory of stable models.

Review: Circumscriptive Event Calculus
We assume a many-sorted first-order language, which contains an event sort, a fluent sort, and a timepoint sort.A fluent term is a term whose sort is a fluent; an event term and a timepoint term are defined similarly.
Definition 3 A condition is defined recursively as follows: • If τ 1 and τ 2 are terms, then comparisons • If f is a fluent term and t is a timepoint term, then HoldsAt(f, t) and ¬HoldsAt(f, t) are conditions; • If γ 1 and γ 2 are conditions, then γ 1 ∧ γ 2 and γ 1 ∨ γ 2 are conditions; • If v is a variable and γ is a condition, then ∃vγ is a condition.
We will use e and e i to denote event terms, f and f i to denote fluent terms, t and t i to denote timepoint terms, and γ and γ i to denote conditions.
In the event calculus, we circumscribe Initiates, Terminates, and Releases to minimize unexpected effects of events, circumscribe Happens to minimize unexpected events, and circumscribe Ab i (abnormality predicates) to minimize abnormalities.Formally, an event calculus description is a circumscriptive theory defined as where • Σ is a conjunction of universal closures of axioms of the form Happens(e n , t) → Terminates(e, f, t), where each of π 1 and π 2 is either Initiates or Terminates ('[¬]' means that '¬' is optional); • ∆ is a conjunction of universal closures of temporal ordering formulas (comparisons between timepoint terms) and axioms of the form where σ is Started or Stopped and each π j (1 ≤ j ≤ n) is either Initiated or Terminated ; • Θ is a conjunction of universal closures of cancellation axioms of the form γ → Ab i (..., t) ; • Ξ is a conjunction of first-order sentences (outside the scope of CIRC) including unique name axioms, state constraints, event occurrence constraints, and the set of domainindependent axioms in the event calculus, such as EC (for the continuous event calculus) and DEC (for the discrete event calculus) (Mueller, 2006, Chapter 2).It also includes the following definitions of the predicates used in the causal constraints in ∆:
These facts are used in the next section to reformulate the event calculus in the general theory of stable models.

Reformulating the Event Calculus in the General Theory of Stable Models
Following Ferraris, Lee, Lifschitz, and Palla (2009), about a formula F we say that it is negative on a list p of predicate constants if members of p have no strictly positive occurrences in F . 4 For example, formula ( 9) is negative on {p}, but is not negative on {p, q}.A formula of the form ¬F (shorthand for F → ⊥) is negative on any list of predicates.
We assume that Ξ was already equivalently rewritten so that Ξ is negative on {Initiates, Terminates, Releases, Happens, Ab 1 , . . ., Ab n }.This can be easily done by prepending ¬¬ to strictly positive occurrences of those predicates.The following theorem shows a few equivalent reformulations of circumscriptive event calculus in the general theory of stable models.
Theorem 2 For any event calculus description (16), the following theories are equivalent to each other: The equivalence between (a) and (b) is immediate from Theorem 1.The equivalence between (b) and (c) can be shown using the splitting theorem by Ferraris et al. (2009).
The assumption that Ξ is negative on the intensional predicates is essential in showing that equivalence (For more details, see the proof in Appendix C.4.).The equivalence between (c) and (d) follows from Proposition 1 since is the empty set. 6

Reformulating the Situation Calculus in the General Theory of Stable Models
In this section, we review and reformulate two versions of the situation calculus-Lin's causal action theories (1995) and Reiter's basic action theories (2001).

Review: Lin's Causal Action Theories
We assume a many-sorted first-order language which contains a situation sort, an action sort, a fluent sort, a truth value sort and an object sort.We understand expression P (x, s), where P is a fluent name, as shorthand for Holds(P (x), s).We do not consider functional fluents here for simplicity.
According to Lin (1995), a formula φ(s) is called a simple state formula about s if φ(s) does not mention Poss, Caused or any situation term other than possibly the variable s.
We assume that a causal action theory D consists of a finite number of the following sets of axioms.We often identify D with the conjunction of the universal closures of all axioms in D. In the following, F , F i are fluent names, A is an action name, V , V i are truth values, s, s are situation variables, φ(s) is a simple state formula about s, symbols a, a are action variables, f is a variable of sort fluent, v is a variable of sort truth value, and x, x i , y, y i are lists of variables.
• D caused is a conjunction of axioms of the form (direct effect axioms), and • D rest is a conjunction of the following axioms: -The basic axioms: 6. I, T , R, H occur in the domain independent axioms as part of Ξ.

Lee & Palla
-The unique name assumptions for fluent names: Similarly for action names.
-The foundational axioms for the discrete situation calculus: -The frame axiom: -Axioms for other domain knowledge: φ(s).
A causal action theory is defined as Remark 2 It is easy to check that D caused is canonical relative to Caused .
This fact is used in the next section to reformulate causal action theories in the general theory of stable models.

Reformulating Causal Action Theories in the General Theory of Stable Models
Let D poss → be the conjunction of axioms φ(s) → Poss(A(x), s) for each axiom (17) in D poss .Instead of the second-order axiom ( 22), we consider the following first-order formula D sit , which introduces a new intensional predicate constant Sit whose argument sort is situation. 8 Sit(S 0 ) ∧ ∀a, s(Sit(s) → Sit(do(a, s))) ∧ ¬∃s¬Sit(s).
In the following, D − rest is the theory obtained from D rest by dropping ( 22).
Theorem 3 Given a causal action theory (23), the following theories are equivalent to each other when we disregard the auxiliary predicate Sit: 7. For simplicity we omit two other axioms regarding the partial-order among situations.8. Suggested by Vladimir Lifschitz (personal communication).

Review: Reiter's Basic Action Theories
As in causal action theories, we understand P (x, s), where P is a fluent name, as shorthand for Holds(P (x), s), and do not consider functional fluents.
A basic action theory (BAT) is of the form where • Σ is the conjunction of the foundational axioms (Section 4.1); • D ss is a conjunction of successor state axioms of the form where Φ F (x, a, s) is a formula that is uniform in s 9 and whose free variables are among x, a, s; • D ap is a conjunction of action precondition axioms of the form where Π A (x, s) is a formula that is uniform in s and whose free variables are among x, s; • D una is the conjunction of unique name axioms for fluents and actions; • D S 0 is a conjunction of first-order formulas that are uniform in S 0 .

Reformulating Basic Action Theories in the General Theory of Stable Models
Note that a BAT is a theory in first-order logic. 10In view of the fact that any first-order logic sentence F is equivalent to SM[F ; ∅], it is trivial to view a BAT as a first-order theory under the stable model semantics with the list of intensional predicates being empty.
In the rest of this section, we consider an alternative encoding of BAT in ASP, in which we do not need to provide explicit successor state axioms D ss .Instead, the successor state axioms are entailed by the effect axioms and the generic inertia axioms adopted in ASP by making intensional both the positive predicate Holds and the negative predicate ∼Holds (Recall the definitions of positive and negative predicates in Section 2.2).In the following we assume that the underlying signature contains both these predicates.
An ASP-style BAT is of the form where • Σ, D una and D S 0 are defined as before; 9. We refer the reader to the book by Reiter (2001) for the definition of a uniform formula.10.For simplicity we disregard the second-order axiom (22).
• D effect is a conjunction of axioms of the form where γ + R (x, a, s) and γ − R (x, a, s) are formulas that are uniform in s and whose free variables are among x, a and s; • D precond is a conjunction of axioms of the form where π A (x, s) is a formula that is uniform in s and whose free variables are among x, s; • D inertia is the conjunction of the axioms for all fluent names R; • D exogenous 0 is the conjunction of for all fluent names R.
Note that axioms in D inertia are typically used in answer set programming to represent the common sense law of inertia (Lifschitz & Turner, 1999).Similarly, D exogenous 0 is used to represent that the initial value of a fluent is arbitrary. 11e will show how this ASP-style BAT is related to Reiter's BAT.First, since we use strong negation, it is convenient to define the following notions.Given the signature σ of a BAT, σ Holds is the signature obtained from σ by adding ∼Holds to σ.We say that an interpretation I of σ Holds is complete on Holds if it satisfies ∀y(Holds(y)∨ ∼Holds(y)), where y is a list of distinct variables.Given an interpretation I of σ Holds , expression I| σ denotes the projection of I on σ.
Let D ss be the conjunction of successor state axioms where Γ + R (x, a, s) is the disjunction of γ + R (x, a, s) for all axioms (27) in D effect , and Γ − R (x, a, s) is the disjunction of γ − R (x, a, s) for all axioms (28) in D effect .By D ap we denote the conjunction of axioms Poss(A(x), s) ↔ Π A (x, s), where Π A (x, s) is the disjunction of π A (x, s) for all axioms (29) in D precond .
Theorem 4 Let T be a theory (26) of signature σ Holds , and I a coherent interpretation of σ Holds that is complete on Holds.If I satisfies for every fluent name R, then I satisfies

Translating Almost Universal Sentences into Logic Programs
Theorems 2-4 present reformulations of the situation calculus and the event calculus in the general theory of stable models, which may contain nested quantifiers and connectives.On the other hand, the input languages of ASP solvers are limited to simple rule forms, which are analogous to clausal normal form in classical logic.Although any first-order formula can be rewritten in clausal normal form while preserving satisfiability, such transformations do not necessarily preserve stable models.This is due to the fact that the notion of equivalence is "stronger" under the stable model semantics (Lifschitz, Pearce, & Valverde, 2001).In other words, replacing a subformula with another strongly equivalent subformula does not change the stable models of the whole formula.While strongly equivalent theories are classically equivalent (i.e., equivalent under classical logic), the converse does not hold.Consequently, classically equivalent transformations do not necessarily preserve stable models.For instance, consider p and ¬¬p.When p is intensional, the former has stable models and the latter does not.
It is known that every propositional formula can be rewritten as a logic program (Cabalar & Ferraris, 2007;Cabalar, Pearce, & Valverde, 2005;Lee & Palla, 2007), and such translations can be extended to quantifier-free formulas in a straightforward way (Section 5.1).However, the method does not work in the presence of arbitrary quantifiers, because in the target formalism (logic programs), all variables are implicitly universally quantified.
In this section, we present a translation that turns a certain class of sentences called "almost universal" sentences into logic programs while preserving stable models.It turns out that the reformulations of the situation calculus and the event calculus in Sections 3 and 4 belong to the class of almost universal sentences, so that we can use ASP solvers for computing them.
5.1 Translating Quantifier-Free Formulas into Logic Programs Cabalar et al. (2005) define the following transformation that turns any propositional formula under the stable model semantics into a logic program.
• Left side rules: • Right side rules: Before applying this transformation to each formula on the lefthand side, we assume that the formula is already written in negation normal form, in which negation is applied to literals only, by using the following transformation: • Negation normal form conversion: According to Cabalar et al. (2005), successive application of the rewriting rules above turn any propositional formula into a disjunctive logic program.This result can be simply extended to turn any quantifier-free formula into a logic program.
As noted by Cabalar et al. (2005), this translation may involve an exponential blowup in size, and Theorem 1 from their paper shows that indeed there is no vocabulary-preserving polynomial time algorithm to convert general propositional theories under the stable model semantics into disjunctive logic programs.Alternatively, one can use another translation from the same paper, which is linear in size but involves auxiliary atoms and is more complex.

Quantifier Elimination
We introduce a quantifier elimination method that distinguishes between two kinds of occurrences of quantifiers: "singular" and "non-singular."Any "non-singular" occurrence of a quantifier is easy to eliminate, while a "singular" occurrence is eliminated under a certain syntactic condition.
Definition 5 We say that an occurrence of QxG in F is singular if • Q is ∀, and the occurrence of QxG is negative in F .
For example, the occurrence of ∃x q(x) is singular in ( 11), but the occurrence of ∃x p(x) is not.
Non-singular occurrences of quantifiers can be eliminated in view of the fact that every first-order sentence can be rewritten in prenex form.The prenex form conversion rules given in Section 6.3.1 of Pearce and Valverde (2005) preserve strong equivalence, which leads to the following theorem.12Theorem 5 (Lee & Palla, 2007, Proposition 5) Every first-order formula is strongly equivalent to a formula in prenex form.
The prenex form conversion turns a non-singular occurrence of a quantifier into an outermost ∀ while preserving strong equivalence.Consequently, if a sentence contains no singular occurrence of a quantifier, then the above results can be used to turn the sentence into a universal sentence and then into a set of ASP rules.However, in the presence of a singular occurrence of a quantifier, the prenex form conversion turns the occurrence into an outermost ∃, which is not allowed in logic programs.Below we consider how to handle such occurrences.
Obviously, if the Herbrand universe is finite, and if we are interested in Herbrand stable models (i.e., answer sets) only, quantified formulas can be rewritten as multiple disjunctions and conjunctions.We do not even need to consider turning the formula into prenex form.For example, for a formula occurring in a theory whose signature contains {1, . . ., n} as the only object constants (and no other function constants), if we replace ∃x(p(x) ∧ q(x)) with multiple disjunctions and then turn the resulting program with nested expressions into a usual disjunctive program (Lifschitz, Tang, & Turner, 1999), 2 n rules are generated.For instance, if n = 3, the Lee & Palla resulting logic program is s ← r, not p(1), not p(2), not p(3) s ← r, not p(1), not p(2), not q(3) s ← r, not p(1), not q(2), not p(3) s ← r, not p(1), not q(2), not q(3) s ← r, not q(1), not p(2), not p(3) s ← r, not q(1), not p(2), not q(3) s ← r, not q(1), not q(2), not p(3) s ← r, not q(1), not q(2), not q(3).
Also, the translation is not modular as it depends on the underlying domain; the multiple disjunctions or conjunctions need to be updated when the domain changes.More importantly, this method is not applicable if the theory contains function constants of positive arity, as its Herbrand universe is infinite.
One may also consider introducing Skolem constants as in first-order logic, presuming that, for any sentence F and its "Skolem form" F , SM[F ; p] is satisfiable iff SM[F ; p] is satisfiable.However, this idea does not work. 13xample 2 For formula F = (∀x p(x) → q) ∧ ¬¬∃x(q ∧ ¬p(x)), SM[F ; q] is equivalent to the first-order sentence (q ↔ ∀x p(x)) ∧ ∃x(q ∧ ¬p(x)), which is unsatisfiable (the equivalence can be established using Theorems 3 and 11 from Ferraris et al., 2011).Formula F is strongly equivalent to its prenex form However, if we introduce new object constants a and b to replace the existentially quantified variables as in which is satisfiable.
Here we present a method of eliminating singular occurrences of quantifiers by introducing auxiliary predicates.Our idea is a generalization of the practice in logic programming that simulates negated existential quantification in the body of a rule by introducing auxiliary predicates.For instance, in order to eliminate ∃ in (30), we will introduce a new predicate constant p , and turn (30) into which corresponds to the logic program The models of SM[(30); p, q, r, s] are the same as the stable models of (33) if we disregard p .This method does not involve grounding, so that the translation does not depend on the domain and is not restricted to Herbrand models.The method is formally justified by the following proposition.
Recall that a formula H is negative on p if members of p have no strictly positive occurrences in H.Given a formula F , we say that an occurrence of a subformula G is p-negated in F if it is contained in a subformula H of F that is negative on p.
Proposition 2 Let F be a sentence, let p be a finite list of distinct predicate constants, and let q be a new predicate constant that does not occur in F .Consider any non-strictly positive, p-negated occurrence of ∃yG(y, x) in F , where x is the list of all free variables of ∃yG(y, x).Let F be the formula obtained from F by replacing that occurrence of ∃yG(y, x) with q(x).Then SM[F ; p] ∧ ∀x(q(x) ↔ ∃yG(y, x)) Proposition 2 tells us that SM[F ; p] and SM[F ∧ ∀xy(G(y, x) → q(x); p, q] have the same models if we disregard the new predicate constant q.Notice that F does not retain the occurrence of ∃y.
Example 3 In formula (30), ∃x(p(x) ∧ q(x)) is contained in a negative formula (relative to any set of intensional predicates).In accordance with Proposition 2, SM[(30); p, q, r, s] has the same models as SM[(32); p, q, r, s, p ] if we disregard p .
Any singular, p-negated occurrence of a subformula ∀yG(y, x) can also be eliminated using Proposition 2 by first rewriting ∀yG(y, x) as ¬∃y¬G(y, x).Note that ∀yG(y, x) is not strongly equivalent to ¬∃y¬G(y, x), and in general such a classically equivalent transformation may not necessarily preserve stable models.However, the Theorem on Double Negations (Ferraris et al., 2009, also reviewed in Appendix C) tells us that such a transformation is ensured to preserve p-stable models if the replaced occurrence is p-negated in the given formula.Now we are ready to present our quantifier elimination method, which applies to the class of almost universal formulas.
Definition 6 We say that a formula F is almost universal relative to p if every singular occurrence of QxG in F is p-negated in F .
For example, formula (30) is almost universal relative to any set of predicates because the only singular occurrence of ∃x(p(x) ∧ q(x)) in ( 30) is contained in ¬∃x(p(x) ∧ q(x)), which is negative on any list of predicates.Formula F in Example 2 is almost universal relative to {q} because the singular occurrence of ∀x p(x) is contained in the formula itself, which is negative on {q}, and the singular occurrence of ∃x(q ∧¬p(x)) is contained in ¬∃x(q ∧¬p(x)), which is also negative on {q}.
The following procedure can be used to eliminate all (possibly nested) quantifiers in any almost universal sentence.
Definition 7 (Translation elim-quantifiers) Given a formula F , first prepend ¬¬ to every maximal strictly positive occurrence of a formula of the form ∃yH(y, x),14 and then repeat the following process until there are no occurrences of quantifiers remaining: Select a maximal occurrence of a formula of the form QyG(y, x) in F , where Q is ∀ or ∃, and x is the list of all free variables in QyG(y, x).
(a) If the occurrence of QyG(y, x) in F is non-singular in F , then set F to be the formula obtained from F by replacing the occurrence of QyG(y, x) with G(z, x), where z is a new variable.
where p G is a new predicate constant and F is the formula obtained from F by replacing the occurrence of QyG(y, x) with p G (x).
(c) Otherwise, if Q is ∀ and the occurrence of QyG(y, x) in F is negative, then set F to be the formula obtained from F by replacing the occurrence of QyG(y, x) with ¬∃y¬G(y, x).
We assume that the new predicate constants introduced by the translation do not belong to the signature of the input formula F .It is clear that this process terminates, and yields a formula that is quantifier-free.Since the number of times step (b) is applied is no more than the number of quantifiers in the input formula, and the new formulas added have the size polynomial to the input formula, it follows that the size of the resulting quantifier-free formula is polynomial in the size of the input formula.
The following theorem tells us that any almost universal sentence F can be turned into the form ∀xG, where G is a quantifier-free formula.For any (second-order) sentences F and G of some signature and any subset σ of that signature, we say that F is σ-equivalent to G, denoted by F ⇔ σ G, if the class of models of F restricted to σ is identical to the class of models of G restricted to σ.
Theorem 6 Let F be a sentence of a signature σ, let F be the universal closure of the formula obtained from F by applying translation elim-quantifiers, and let q be the list of new predicate constants introduced by the translation.If F is almost universal relative to p, then SM[F ; p] is σ-equivalent to SM[F ; p, q].The statement of the theorem becomes incorrect if we do not require F to be almost universal relative to p.For instance, if elim-quantifiers is applied to ∃x p(x), it results in ¬¬q ∧ (p(x) → q).However, SM[∃x p(x); p] is not {p}-equivalent to SM[∀x(¬¬q ∧ (p(x) → q)); p, q].The former is equivalent to saying that p is a singleton.The latter is equivalent to q ∧ ∀x¬p(x) ∧ (q ↔ ∃xp(x)), which is inconsistent.

f2lp: Computing Answer Sets of First-Order Formulas
Using translation elim-quantifiers defined in the previous section, we introduce translation f2lp that turns an almost universal formula into a logic program.We assume that the underlying signature contains finitely many predicate constants.

Definition 8 (Translation f2lp)
1. Given a formula F and a list of intensional predicates p, apply translation elim-quantifiers (Definition 7) to F ; 2. Add choice formulas (q(x) ∨ ¬q(x)) for all non-intensional predicates q.
3. Turn the resulting quantifier-free formula into a logic program by applying the translation from Section 3 of the paper by Cabalar et al. (2005), which was also reviewed in Section 5.1.
As explained in Section 5.1, due to the third step, this transformation may involve an exponential blowup in size.One can obtain a polynomial translation by replacing Step 3 with an alternative translation given in Section 4 of the paper by Cabalar et al.
The following theorem asserts the correctness of the translation.
Turning the program obtained by applying translation f2lp into the input languages of lparse 15 and gringo 16 requires minor rewriting, such as moving equality and negated atoms in the head to the body 17 and adding domain predicates in the body for all variables occurring in the rule in order to reduce the many-sorted signature into the non-sorted one. 18 System f2lp is an implementation of translation f2lp, which turns a first-order formula into the languages of lparse and gringo.The system can be downloaded from its home page http://reasoning.eas.asu.edu/f2lp .First-order formulas can be encoded in f2lp using the extended rule form F ← G, where F and G are first-order formulas that do not contain →.The ASCII representation of the quantifiers and connectives are shown in the following table.
For example, formula (34) can be encoded in the input language of f2lp as The usual lparse and gringo rules (which have the rule arrow ':-') are also allowed in f2lp.Such rules are simply copied to the output.The program returned by f2lp can be passed to ASP grounders and solvers that accept lparse and gringo languages.

Computing the Event Calculus Using ASP Solvers
Using translation f2lp, we further turn the event calculus reformulation in Section 3.2 into answer set programs.The following procedure describes the process.

Definition 9 (Translation ec2asp)
1. Given an event calculus description ( 16), rewrite all the definitional axioms of the form , where G ¬¬ is obtained from G by prepending ¬¬ to all occurrences of intensional predicates Initiates, Terminates, Releases, Happens, Ab 1 , . . ., Ab n .Also prepend ¬¬ to the strictly positive occurrences of the intensional predicates in the remaining axioms of Ξ.Let Ξ be the resulting formula obtained from Ξ.
The following theorem states the correctness of the translation.
Theorem 8 Let T be an event calculus description ( 16) of signature σ that contains finitely many predicate constants, let F be the FOL representation of the program obtained from T by applying translation ec2asp.
In view of the theorem, system f2lp can be used to compute event calculus descriptions by a simple rewriting as stated in translation ec2asp. 19The system can be used in place of the dec reasoner in many existing applications of the event calculus, such as in robotics, security, video games, and web service composition, as listed in http://decreasoner.sourceforge.net/csr/decapps.html .
The computational mechanism of the dec reasoner is similar to our method as it is based on the reduction of event calculus reasoning to propositional satisfiability and uses efficient SAT solvers for computation.However, our method has some advantages.
First, it is significantly faster due to the efficient grounding mechanisms implemented in ASP systems.This is evidenced in some experiments reported in Appendix B.
Second, f2lp allows us to compute the full version of the event calculus, assuming that the domain is given and finite.On the other hand, the reduction implemented in the dec reasoner is based on completion, which is weaker than circumscription.This makes the system unable to handle recursive axioms and disjunctive axioms, such as effect constraints and disjunctive event axioms (Section 3.1).For example, the dec reasoner does not allow the following effect constraints which describe the indirect effects of an agent's walking on the objects that he is holding: HoldsAt(Holding(a, o), t) ∧ Initiates(e, InRoom(a, r), t) → Initiates(e, InRoom(o, r), t) HoldsAt(Holding(a, o), t) ∧ Terminates(e, InRoom(a, r), t) → Terminates(e, InRoom(o, r), t). (36) Third, we can enhance the event calculus reasoning by combining ASP rules with the event calculus description.In other words, the event calculus can be viewed as a high level action formalism on top of ASP.We illustrate this using the example from the work of Dogandag, Ferraris, and Lifschitz (2004).There are 9 rooms and 12 doors as shown in Figure 1.Initially the robot "Robby" is in the middle room and all the doors are closed.The goal of the robot is to make all rooms accessible from each other.Figure 2 (File robby) shows an encoding of the problem in the language of f2lp.Atom door(x, y) denotes that there is a door between rooms x and y; open(x, y) denotes the event "Robby opening the door Figure 1: Robby's apartment in a 3 × 3 grid between rooms x and y"; goto(x) denotes the event "Robby going to room x"; opened(x, y) denotes that the door between x and y has been opened; inRoom(x) denotes that Robby is in room x; accessible(x, y) denotes that y is accessible from x.Note that the rules defining the relation accessible are not part of event calculus axioms (Section 3.1).This example illustrates an advantage of allowing ASP rules in event calculus descriptions.
The minimal number of steps to solve the given problem is 11.We can find such a plan using the combination of f2lp, gringo (grounder) and claspD (solver for disjunctive programs) in the following way. 20

$ f2lp dec robby | gringo -c maxstep=11 | claspD
File dec is an f2lp encoding of the domain independent axioms in the Discrete Event Calculus (The file is listed in Appendix A). 21The following is one of the plans found:

Computing the Situation Calculus Using ASP Solvers
Using translation f2lp, we further turn the situation calculus reformulations in Sections 4.2 and 4.4 into answer set programs.

Representing Causal Action Theories by Answer Set Programs
The following theorem shows how to turn causal action theories into answer set programs.
Theorem 9 Let D be a finite causal action theory (23) of signature σ that contains finitely many predicate constants, and let F be the FOL representation of the program obtained by applying translation f2lp on  Similar to the computation of the event calculus in Section 6, the Herbrand stable models of (37) can be computed using f2lp and answer set solvers.The input to f2lp can be simplified as we limit attention to Herbrand models.We can drop axioms ( 18)-( 21) as they are ensured by Herbrand models.Also, in order to ensure finite grounding, instead of D sit , we include the following set of rules Π situation in the input to f2lp.nesting(0,s0).nesting(L+1,do(A,S)) <-nesting(L,S) & action(A) & L < maxdepth.situation(S) <-nesting(L,S).final(S) <-nesting(maxdepth,S).
Π situation is used to generate finitely many situation terms whose depth is up to maxdepth, the value that can be given as an option in invoking gringo.Using the splitting theorem (Section C.1), it is not difficult to check that if a program Π containing these rules has no occurrence of predicate nesting in any other rules and has no occurrence of predicate situation in the head of any other rules, then every answer set of Π contains atoms situation(do(a m , do(a m−1 , do(. . ., do(a 1 , s0))))) for all possible sequences of actions a 1 , . . ., a m for m = 0, . . ., maxdepth.Though this program does not satisfy syntactic conditions, such as λ-restricted (Gebser, Schaub, & Thiele, 2007), ω-restricted (Syrjänen, 2004), or finite domain programs (Calimeri, Cozza, Ianni, & Leone, 2008), that answer set solvers usually impose in order to ensure finite grounding, the rules can still be finitely grounded % File: suitcase value(t).value(f).lock(l1).lock(l2).
% defining the situation domain nesting(0,s0).nesting(L+1,do(A,S)) <-nesting(L,S) & L < maxdepth.situation(S) <-nesting(L,S).final(S) <-nesting(maxdepth,S).(open, do(flip(l1), do(flip(l2), s0))), each of which encodes a plan.In other words, the single answer set encodes multiple plans in different branches of the situation tree, which allows us to combine information about the different branches in one model.This is an instance of hypothetical reasoning that is elegantly handled in the situation calculus due to its branching time structure.Belleghem, Denecker, and Schreye (1997) note that the linear time structure of the event calculus is limited to handle such hypothetical reasoning allowed in the situation calculus.

Representing Basic Action Theories by Answer Set Programs
Since a BAT T (not including the second-order axiom ( 22)) can be viewed as a first-order theory under the stable model semantics with the list of intensional predicates being empty, it follows that f2lp can be used to turn T into a logic program.As before, we focus on ASP-style BAT.
Theorem 10 Let T be a ASP-style BAT (26) of signature σ that contains finitely many predicate constants, and let F be the FOL representation of the program obtained by applying translation f2lp on T with intensional predicates {Holds, ∼ Holds, Poss}.Then Figure 4 shows an encoding of the "broken object" example discussed by Reiter (1991).Consider the simple projection problem of determining if an object o, which is next to bomb b, is broken after the bomb explodes.We add Π executable and the following rules to the theory in Figure 4.

Related Work
Identifying a syntactic class of theories on which different semantics coincide is important in understanding the relationship between them.It is known that, for tight logic programs and tight first-order formulas, the stable model semantics coincides with the completion semantics (Fages, 1994;Erdem & Lifschitz, 2003;Ferraris et al., 2011).This fact helps us understand the relationship between the two semantics, and led to the design of the answer set solver cmodels-123 that computes answer sets using completion.Likewise the class of canonical formulas introduced here helps us understand the relationship between the stable model semantics and circumscription.The class of canonical formulas is the largest  syntactic class of first-order formulas identified so far on which the stable models coincide with the models of circumscription.In other words, minimal model reasoning and stable model reasoning are indistinguishable on canonical formulas.Proposition 8 from the work of Lee and Lin (2006) shows an embedding of propositional circumscription in logic programs under the stable model semantics.Our theorem on canonical formulas is a generalization of this result to the first-order case.Janhunen and Oikarinen (2004) showed another embedding of propositional circumscription in logic programs, and implemented the system circ2dlp,24 but their translation appears quite different from the one by Lee and Lin.
Zhang, Zhang, Ying, and Zhou (2011) show an embedding of first-order circumscription in first-order stable model semantics.Theorem 3 from that paper is reproduced as follows. 25heorem 11 (Zhang et al., 2011, Thm. 3) Let F be a formula in negation normal form and let p be a finite list of predicate constants.Let F ¬¬ be the formula obtained from F by replacing every p(t) by ¬¬p(t), and let F c be the formula obtained from F by replacing every ¬p(t) by p(t) → Choice(p), where p is in p and t is a list of terms.Then CIRC In comparison with Theorem 1, this theorem can be applied to characterize circumscription of arbitrary formulas in terms of stable models by first rewriting the formulas into negation normal form.While Theorem 1 is applicable to canonical formulas only, it does not require any transformation, and the characterization is bidirectional in the sense that it can be also viewed as a characterization of stable models in terms of circumscription.Zhang et al. (2011) also introduce a translation that turns arbitrary first-order formulas into logic programs, but this work is limited to finite structures only.On the other hand, our translation f2lp (Definition 8) works for almost universal formulas only, but is not limited to finite structures.
Prolog provides a natural implementation for basic action theories since definitional axioms can be represented by Prolog rules according to the Clark's theorem (Reiter, 2001, Chapter 5).The Lloyd-Topor transformation that is used to turn formulas into Prolog rules is similar to translation f2lp, but the difference is that the former preserves the completion semantics and the latter preserves the stable model semantics.
Lin and Wang (1999) describe a language that can be used to represent a syntactically restricted form of Lin's causal situation calculus, called "clausal causal theories," which does not allow quantifiers.They show how to translate that language into answer set programs with strong negation, the answer sets of which are then used to obtain fully instantiated successor state axioms and action precondition axioms.This is quite different from our approach, which computes the propositional models of the full situation calculus theories directly.Kautz and Selman (1992) introduce linear encodings that are similar to a propositionalized version of the situation calculus (McCarthy & Hayes, 1969).Lin (2003) introduces an action description language and describes a procedure to compile an action domain in that language into a complete set of successor state axioms, from which a STRIPS-like description can be extracted.The soundness of the procedure is shown with respect to a translation from action domain descriptions into Lin's causal action theories.However, that procedure is based on completion and as such cannot handle recursive axioms unlike our approach.Denecker and Ternovska (2007) present an inductive variant of the situation calculus represented in ID-logic (Denecker & Ternovska, 2008)-classical logic extended with inductive definitions.ID-logic and the first-order stable model semantics appear to be closely related, but the precise relationship between them has yet to be shown.

Conclusion
The first-order stable model semantics is defined similar to circumscription.This paper takes advantage of that definition to identify a class of formulas on which minimal model reasoning and stable model reasoning coincide, and uses this idea to reformulate the situation calculus and the event calculus in the first-order stable model semantics.Together with the translation that turns an almost universal sentence into a logic program, we show that reasoning in the situation calculus and the event calculus can be reduced to computing answer sets.We implemented system f2lp, a front-end to ASP solvers that allows us to compute these circumscriptive action theories.The mathematical tool sets and the system presented in this paper may also be useful in relating other circumscriptive theories to logic programs.Also, the advances in ASP solvers may improve the computation of circumscriptive theories.We compared the performance of the dec reasoner (v 1.0) running relsat (v 2.2) and minisat (v 2.2) with the following: • f2lp (v 1.11) with lparse (v 1.0.17)+cmodels(v 3.79) running minisat (v 2.0 beta), • f2lp (v 1.11) with gringo (v 3.0.3)+cmodels(v 3.79) running minisat (v 2.0 beta), • f2lp (v 1.11) with gringo (v 3.0.3)+clasp (v 2.0.2) (claspD (v 1.1.2)used instead for disjunctive programs), and f2lp turns an input theory into the languages of lparse and gringo, and lparse and gringo turn the result into a ground ASP program.cmodels turns this ground program into a set of clauses and then invokes a SAT solver to compute answer sets, while clasp computes answer sets using the techniques similar to those used in SAT solvers.clingo is a system that combines gringo and clasp in a monolithic way.
The first five examples in Figure 5 are part of the benchmark problems from the work of Shanahan (1997Shanahan ( , 1999)).The next four are by Mueller (2006)  to see more notable differences.)More examples can be found from the f2lp homepage.All experiments were done on a Pentium machine 3.06 GHz CPU and 4GB RAM running 64 bit Linux.The reported run times are in seconds and were obtained using the Linux time command ("user time + sys time"), except for the dec reasoner for which we recorded the times reported by the system.This was for fair comparisons in order to avoid including the time spent by the dec reasoner in producing output in a neat format, which sometimes takes non-negligible time.For the dec reasoner, the times in parentheses are "(SAT encoding time + SAT solving time)."For the others, they are the times spent by each of the grounder and the solver.cmodels time includes the time spent in converting the ground program generated by lparse/gringo into a set of clauses, and calling the SAT solver.The time spent by f2lp in translating an event calculus description into an answer set program (retaining variables) is negligible for these problems.'-' denotes that the system cannot solve the example due to the limited expressivity.For instance, BusRide includes disjunctive event axioms, which results in a disjunctive program that cannot be handled by clingo.Similarly, the dec reasoner cannot handle BusRide (disjunctive event axioms), Commuter (compound events) and Walking Turkey (effect constraints).As is evident from the experiments, the main reason for the efficiency of the ASP-based approach is the efficient grounding mechanisms implemented in the ASP grounders.Though the dec reasoner and cmodels call the same SAT solver minisat, the number of atoms processed by the dec reasoner is in general much smaller.This is because the dec reasoner adopts an optimized encoding method (that is based on predicate completion) which avoids a large number of ground instances of atoms such as Initiates(e, f, t), Terminates(e, f, t), and Releases(e, f, t) (Mueller, 2004, Section 4.4).On the other hand, in several examples, the number of clauses generated by cmodels is 0, which means that the answer sets were found without calling the SAT solver.This is because for these examples the unique answer set coincides with the well-founded model, which is efficiently computed by cmodels in a preprocessing step before calling SAT solvers.Out of the 14 benchmark examples by Shanahan (1997Shanahan ( , 1999)), 10 of them belong to this case when lparse is used for grounding.
In the experiments in Figure 5, the solving times are negligible for most of the problems.We also experimented with some computationally hard problems, where solving takes more time than grounding.Figure 6 shows runs of a medium-size action domain, the Zoo World (Akman, Erdogan, Lee, Lifschitz, & Turner, 2004).All the tests shown in the table are planning problems where max.step is the length of a minimal plan.The cut-off time was 2 hours and the dec reasoner did not terminate within that time for any of the problems.In fact, the entire time was spent on SAT encoding and the SAT solver was never called.On the other hand, the ASP grounder gringo took only a few seconds to ground the domain and, unlike in Figure 5, the solvers took much more time than the grounder.As we can see, cmodels with minisat performed better than clasp on two of the problems.
To check the time taken by minisat on the encoding generated by the dec reasoner, we ran ZooTest1 to completion.The dec reasoner terminated after 116578.1 seconds (32.38 hours).

C.1 Review of Some Useful Theorems
We review some theorems by Ferraris et al. (2011) andFerraris et al. (2009) which will be used to prove our main results.In fact, we will provide a version of the splitting theorem which is slightly more general than the one given by Ferraris et al. (2009), in order to facilitate our proof efforts.
Theorem 12 (Ferraris et al., 2011, Thm. 2) For any first-order formula F and any disjoint lists p, q of distinct predicate constants, is logically valid.
Let F be a first-order formula.A rule of F is an implication that occurs strictly positively in F .The predicate dependency graph of F (relative to p) is the directed graph that • has all members of p as its vertices, and • has an edge from p to q if, for some rule G → H of F , p has a strictly positive occurrence in H, and q has a positive occurrence in G that does not belong to any subformula of G that is negative on p.
Theorem 13 (Ferraris et al., 2009, Splitting Thm.)Let F , G be first-order sentences, and let p, q be finite disjoint lists of distinct predicate constants.If (a) each strongly connected component of the predicate dependency graph of F ∧ G relative to p, q is either a subset of p or a subset of q, (b) F is negative on q, and (c) G is negative on is logically valid.
The theorem is slightly more general than the one by Ferraris et al. (2009) in that the notion of a dependency graph above yields less edges than the one given by Ferraris et al.Instead of q has a positive occurrence in G that does not belong to any subformula of G that is negative on p,

Ferraris et al.'s definition has
q has a positive occurrence in G that does not belong to any subformula of the form ¬K.
For instance, according to Ferraris et al., the dependency graph of relative to p has two edges (from p to r, and from p to p), while the dependency graph according to our definition has no edges.On the other hand, the generalization is not essential in view of the following theorem.
Theorem 14 (Ferraris et al., 2009, Thm. on one for each intensional predicate p, where x is a list of distinct object variables, and G has no free variables other than those in x.The completion (relative to p) of a formula F in Clark normal form is obtained by replacing each conjunctive term (39) with ∀x(p(x) ↔ G).
The following theorem relates SM to completion.We say that F is tight on p if the predicate dependency graph of F relative to p is acyclic.
Theorem 15 (Ferraris et al., 2011) For any formula F in Clark normal form that is tight on p, formula SM[F ; p] is equivalent to the completion of F relative to p.

C.2 Proof of Proposition 1
Using Theorem 12 and Theorem 13,

C.3 Proof of Theorem 1
In the following, F is a formula, p is a list of distinct predicate constants p 1 , . . ., p n , and u is a list of distinct predicate variables u 1 , . . ., u n of the same length as p.
Lemma 2 (Ferraris et al., 2011, Lemma 5) Lemma 3 If every occurrence of every predicate constant from p is strictly positive in F , is logically valid.
Proof.By induction.We will show only the case when F is G → H.The other cases are straightforward.Consider Since every occurrence of predicate constants from p in F is strictly positive, G contains no predicate constants from p, so that G * (u) is equivalent to G(u), which is the same as G. Also, by I.H., H * (u) ↔ H(u) is logically valid.Therefore it is sufficient to prove that under the assumption u ≤ p, is logically valid.From left to right is clear.Assume (u ≤ p), G → H(u), and G.We get H(u), which is equivalent to H * (u) by I.H.By Lemma 2, we conclude H.
The proof of Theorem 1 is immediate from the following lemma, which can be proved by induction.
Lemma 4 If F is canonical relative to p, then formula is logically valid.

Proof.
• F is an atomic formula.Trivial.
every occurrence of every predicate constant from p is strictly positive in G or in H, so that, by Lemma 3, G * (u) is equivalent to G(u), and H * (u) is equivalent to H(u).
Since G → H is canonical relative to p, every occurrence of every predicate constant from p in G is strictly positive in G, so that, by Lemma 3, G * (u) is equivalent to G(u).
-Case 2: H.By I.H.H * (u) is equivalent to H(u).The claim follows since G * (u) is equivalent to G(u).
• F = ∃xG.Since every occurrence of every predicate constant from p in G is strictly positive in G, the claim follows from Lemma 3. Similarly, applying Theorem 13 repeatedly, we can show that the above formula is equivalent to (c).(43) Since P oss does not occur in and since D precond is negative on {Holds, ∼Holds}, by Theorem 13, ( 43) is equivalent to which is equivalent to Therefore the statement of the theorem can be proven by showing the following: if for every fluent R, and iff I| σ satisfies D S 0 ∧ D ss .
From D exogenous 0 , it follows that (47) is equivalent to where D ¬¬ S 0 is the formula obtained from D S 0 by prepending ¬¬ to all occurrences of Holds.Under the assumption (46), In the following we will use the following facts.
• if F is a ground formula that does not contain ∼, then Left to Right: Assume I |= (49) ∧ (50).

C.7 Proof of Proposition 2
Lemma 5 Let F be a formula, let p be a list of distinct predicate constants, let G be a subformula of F and let G be any formula that is classically equivalent to G. Let F be the formula obtained from F by substituting G for G.If the occurrence of G is in a subformula of F that is negative on p and the occurrence of G is in a subformula of F that is negative on p, then SM[F ; p] ↔ SM[F ; p] is logically valid.
Proof.Let F ¬¬ be the formula obtained from F by prepending ¬¬ to G, and let (F ) ¬¬ be the formula obtained from Proof of Proposition 2. In formula SM[F ∧ ∀xy(G(y, x) → q(x)); p, q], (52) clearly, F is negative on q and ∀xy(G(y, x) → q(x)) is negative on p.Let H be any subformula of F that is negative on p and contains the occurrence of ∃yG(y, x).Consider two cases.
• Case 1: the occurrence of ∃yG(y, x) in H is not strictly positive.Thus the dependency graph of F ∧ ∀xy(G(y, x) → q(x)) relative to {p, q} has no incoming edges into q.
• Case 2: the occurrence of ∃yG(y, x) in H is strictly positive.Since H is negative on p, ∃yG(y, x) is negative on p as well, so that the dependency graph of F ∧ ∀xy(G(y, x) → q(x)) relative to {p, q} has no outgoing edges from q.
Consequently, the claim follows.

C.8 Proof of Theorem 6
It is clear that the algorithm terminates and yields a quantifier-free formula K.We will prove that SM[F ; p] ⇔ σ SM[∀xK; p ∪ q], where x is the list of all (free) variables of K. Let F ¬¬ be the formula obtained from the initial formula F by prepending double negations in front of every maximal strictly positive occurrence of formulas of the form ∃yG(x, y).Since F is almost universal relative to p, such an occurrence is in a subformula of F that is negative on p. Thus by the Theorem on Double Negations (Theorem 14), SM[F ; p] is equivalent to SM[F ¬¬ ; p].Note that F ¬¬ contains no strictly positive occurrence of formulas of the form ∃yG(x, y).
For each iteration, let us assume that the formula before the iteration is where H 0 is transformed from F ¬¬ by the previous iterations, and each H i (i > 0) is a formula of the form G(x, y) → p G (x) that is introduced by Step (b).Initially H 0 is F ¬¬ and n = 0. Let r 0 be p, and let r i be each p G for H i (i > 0).By induction we can prove that (i) every positive occurrence of formulas of the form ∃yG(x, y) in H i is not strictly positive, and is in a subformula of H i that is negative on r i ; (ii) every negative occurrence of formulas of the form ∀yG(x, y) in H i is in a subformula of H i that is negative on r i . We where H j = H j for all j different from k, and x i (i ≥ 0) is the list of all free variables of H i , and x i (i ≥ 0) is the list of all free variables of H i .and σ pred ∪ r 1 ∪ • • • ∪ r m is the same as p ∪ pr (F ), so that (62) can be written as According to the syntax of the event calculus reviewed in Section 3.1, • every positive occurrence of a formula of the form ∃yG(y) in ( 65) is contained in a subformula that is negative on {Initiates, Terminates, Releases, Happens, Ab 1 , . . ., Ab n , p}, and • there are no negative occurrences of any formula of the form ∀yG(y) in (65).
Consequently, the statement of the theorem follows from Theorem 7.

C.11 Proof of Theorem 9
Since (37) is almost universal relative to {Caused , Poss, Sit}, the result follows from Theorems 7 and 3.
C.12 Proof of Theorem 10 From D exogenous 0 , it follows that SM[T ; Holds, ∼Holds, Poss] is equivalent to SM[T ¬¬ ; Holds, ∼ Holds, Poss], where T ¬¬ is obtained from T by prepending ¬¬ to all occurrences of Holds in D S 0 .From the definition of a uniform formula (Reiter, 2001), it follows that T ¬¬ is almost universal relative to {Holds, ∼Holds, Poss}.The result follows from Theorem 7.

Figure 4 :
Figure 4: Broken object example in the language of f2lp

Figure 5 :
Figure 5: Comparing the dec reasoner and f2lp with answer set solvers

Figure 6 :
Figure 6: Zoo World in dec reasoner and ASP
Intuitively, ∼p(t)represents that p(t) is false.This is different from ¬p(t) which represents that it is not known that p(t) is true.Similarly, ¬ ∼p(t) represents that it is not known that p(t) is false, and ¬¬p(t) represents that it is not known that p(t) is not known to be true.Note that, unlike in first-order logic, ¬¬p(t) is different from p(t).For instance, formula p(a) has only one answer set {p(a)} but ¬¬p(a) has no answer sets.
. (We increased timepoints The dependency graph of ¬¬((p → q) → r) → p relative to p according to the definition by Ferraris et al. is identical to the dependency graph of (38) relative to p according to our definition.Next, we say that a formula F is in Clark normal form (relative to the list p of intensional predicates) if it is a conjunction of sentences of the form ∀x Double Negations) Let H be a sentence, F a subformula of H, and H ¬¬ the sentence obtained from H by inserting ¬¬ in front of F .If the occurrence of F is p-negated in H, then SM[H; p] is equivalent to SM[H ¬¬ ; p].For instance, SM[(38); p] is equivalent to SM[¬¬((p → q) → r) → p; p].
(Lee & Meng, 2011)by the relationship between completion and SM that is stated in Corollary 11 of(Lee & Meng, 2011), we have that I |= (48) iff I satisfies D S 0 , and, for each fluent R, Lee and Meng (2011)rom the work ofLee and Meng (2011)for the definition.