Hostname: page-component-586b7cd67f-2plfb Total loading time: 0 Render date: 2024-11-27T12:21:39.608Z Has data issue: false hasContentIssue false

Locally Tight Programs

Published online by Cambridge University Press:  19 January 2024

JORGE FANDINNO
Affiliation:
University of Nebraska Omaha, USA (e-mail: [email protected])
VLADIMIR LIFSCHITZ
Affiliation:
University of Texas at Austin, USA (e-mails: [email protected], [email protected])
NATHAN TEMPLE
Affiliation:
University of Texas at Austin, USA (e-mails: [email protected], [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Program completion is a translation from the language of logic programs into the language of first-order theories. Its original definition has been extended to programs that include integer arithmetic, accept input, and distinguish between output predicates and auxiliary predicates. For tight programs, that generalization of completion is known to match the stable model semantics, which is the basis of answer set programming. We show that the tightness condition in this theorem can be replaced by a less restrictive “local tightness” requirement. From this fact we conclude that the proof assistant anthem-p2p can be used to verify equivalence between locally tight programs.

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press

1 Introduction

Program completion (Clark Reference Clark1978) is a translation from the language of logic programs into the language of first-order theories. If, for example, a program defines the predicate $q/1$ by the rules

(1) \begin{equation}\begin{array} lq(a),\\q(X) \leftarrow p(X),\end{array}\end{equation}

then the completed definition of $q/1$ is

(2) \begin{equation}\forall X(q(X)\leftrightarrow X=a \lor p(X)).\end{equation}

Program (1) and formula (2) express, in different languages, the same idea: the set q consists of a and all elements of p.

Fages (Reference Fages1994) identified a class of programs for which the completion semantics is equivalent to the stable model semantics. Programs in this class are now called tight. This relationship between completion and stable models plays an important role in the theory of answer set programming (ASP). It is used in the design of the answer set solvers cmodels (Lierler and Maratea Reference Lierler and Maratea2004), assat (Lin and Zhao Reference Lin and Zhao2004) and clasp (Gebser et al. Reference Gebser, Schaub and Thiele2007); and in the design of the proof assistants anthem (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020) and anthem-p2p (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023).

Some constructs that are common in ASP programs are not covered by Clark’s definition of program completion, and that definition had to be generalized. First, the original definition does not cover programs that involve integer arithmetic. To extend it to such programs, we distinguish, in the corresponding first-order formula, between “general” variables on the one hand, and variables for integers on the other (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019, Section 5). This is useful because function symbols in a first-order language are supposed to represent total functions, and arithmetical operations are not defined on symbolic constants.

Second, in ASP programs we often find auxiliary predicate symbols, which are not considered part of its output. Consider, for instance, the program

(3) \begin{align} \textit{in}(P,R,0) &\leftarrow \textit{in}_0(P,R),\end{align}

(4) \begin{align}\textit{in}(P,R,T+ 1) &\leftarrow \textit{goto}(P,R,T),\end{align}
(5) \begin{align}\{\,\textit{in}(P,R,T+ 1)\,\} &\leftarrow \textit{in}(P,R,T) \land T = 0\,..\,h- 1,\end{align}
(6) \begin{align}&\leftarrow \textit{in}(P,R_1,T)\land \textit{in}(P,R_2,T)\land R_1 \neq R_2,\end{align}
(7) \begin{align}\textit{in_building}(P,T) &\leftarrow \textit{in}(P,R,T),\end{align}
(8) \begin{align}&\leftarrow \textit{not}\ \textit{in_building}(P,T)\land \textit{person}(P) \land T = 0\,..\,h,\end{align}

which will be used as a running example. It describes the effect of an action – walking from one room to another – on the location of a person. We can read $\textit{in}(P,R,T)$ as “person P is in room R at time T,” and $\textit{goto}(P,R,T)$ as “person P goes to room R between times T and $T+1$ .” The placeholder h represents the horizon – the length of scenarios under consideration. Choice rule (5) encodes the commonsense law of inertia for this dynamic system: in the absence of information to the contrary, the location of a person at time $T+1$ is presumed to be the same as at time T. To run this program, we need to specify the value of h and the input predicates person/1, $\textit{in}_0/2$ and goto/3. The output is represented by the atoms in the stable model that contain in/3. The predicate symbol in_building/2 is auxiliary; a file containing program (3)–(8) may contain a directive that causes the solver not to display the atoms containing that symbol.

For this program and other programs containing auxiliary symbols, we would like the completion to describe the “essential parts” of its stable models, with all auxiliary atoms removed. This can be accomplished by replacing the auxiliary symbols in Clark’s completion by existentially quantified predicate variables (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020, Section 6.2). The version of completion defined in that paper covers both integer arithmetic and the distinction between the entire stable model and its essential part. Standard models of the completion, in the sense of that paper, correspond to the essential parts of the program’s stable models if the program is tight (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020, Theorem 2, reproduced in Section 3.3 below).

That theorem is not applicable, however, to program (3)–(8), because this program is not tight. Tightness is defined as the absence of certain cyclical dependencies between predicate symbols (see Section 3.3 for details). The two occurrences of the predicate in/3 in rule (5) create a dependency that is not allowed in a tight program.

In this article we propose the definition of a “locally tight” program and show that the above-mentioned theorem by Fandinno et al. can be extended to programs satisfying this less restrictive condition. Local tightness is defined in terms of dependencies between ground atoms. The last argument of in/3 in the head of rule (3)–(8) is $T+1$ , and the last argument of in/3 in the body is T; for this reason, the dependencies between ground atoms corresponding to this rule are not cyclic. ASP encodings of dynamic systems (Lifschitz Reference Lifschitz2019, Chapter 8) provide many examples of this kind. The tightness condition prohibits pretty much all uses of recursion in a program; local tightness, on the other hand, expresses the absence of “nonterminating” recursion.

The result of this article shows, for example, that the completion of program (3)–(8) correctly describes the essential parts of its stable models.

Section 2 is a review of definitions and notation related to ASP programs with arithmetic. After defining program completion in Section 3, we introduce locally tight programs and state a theorem describing the relationship between stable models and completion under a local tightness assumption (Section 4). In Section 5, that theorem is used to justify the usability of the proof assistant anthem-p2p for verifying equivalence between programs in some cases that are not allowed in the original publication (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023). Proofs of the theorems stated in these sections are based on a lemma of more general nature, which relates stable models to completion for a class of many-sorted first-order theories. This Main Lemma is stated in Section 6 and proved in Section 7. Proofs of the theorems are given in Sections 810. In two appendices, we review terminology and notation related to many-sorted formulas and their stable models.

2 Background

This review follows previous publications on ASP programs with arithmetic (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019; Fandinno et al. 2020; Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023).

2.1 Programs

The programming language mini-gringo, defined in this section, is a subset of the input language of the grounder gringo (Gebser et al. Reference Gebser, Schaub and Thiele2007). Most constructs included in this language are available also in the input language of the solver dlv (Leone et al. Reference Leone, Pfeifer, Faber, Eiter, Gottlob, Perri and Scarcello2006). The description of mini-gringo programs below uses “abstract syntax,” which disregards some details related to representing programs by strings of ASCII characters (Gebser et al. Reference Gebser, Harrison, Kaminski, Lifschitz and Schaub2015).

2.1.1 Syntax

We assume that three countably infinite sets of symbols are selected: numerals, symbolic constants, and variables. We assume that a 1-1 correspondence between numerals and integers is chosen; the numeral corresponding to an integer n is denoted by $\overline{n}$ . In examples, we take the liberty to drop the overline in numerals. This convention is used, for instance, in rule (5), which should be written, strictly speaking, as

Precomputed terms are numerals and symbolic constants. We assume that a total order on precomputed terms is chosen such that for all integers m and n, $\overline{m} < \overline{n}$ iff $m<n$ .

Terms allowed in a mini-gringo program are formed from precomputed terms and variables using the absolute value symbol $|\,|$ and six binary operation names

$$+\quad-\quad\times\quad/\quad\backslash \quad.$$

An atom is a symbolic constant optionally followed by a tuple of terms in parentheses. A literal is an atom possibly preceded by one or two occurrences of not. A comparison is an expression of the form $t_1\;\mathit{rel}\; t_2$ , where $t_1$ , $t_2$ are terms and $\mathit{rel}$ is $=$ or one of the comparison symbols

(9) \begin{equation}\neq\quad<\quad>\quad\leq\quad\geq.\end{equation}

A rule is an expression of the form $\mathit{Head}\leftarrow\mathit{Body}$ , where

  1. $\mathit{Body}$ is a conjunction (possibly empty) of literals and comparisons, and

  2. $\mathit{Head}$ is either an atom (then this is a basic rule), or an atom in braces (then this is a choice rule), or empty (then this is a constraint).

A rule is ground if it does not contain variables. A ground rule of the form $\mathit{Head}\leftarrow$ , where $\mathit{Head}$ is an atom, will be identified with the atom $\mathit{Head}$ and called a fact.

A program is a finite set of rules.

A predicate symbol is a pair $p/n$ , where p is a symbolic constant, and n is a nonnegative integer. We say that $p/n$ occurs in a literal l if l contains an atom of the form $p(t_1,\dots,t_n)$ , and similarly for occurrences in rules and in other syntactic expressions.

An atom $p(t_1,\dots,t_n)$ is precomputed if the terms $t_1,\dots,t_n$ are precomputed.

2.1.2 Semantics

The semantics of ground terms is defined by assigning to every ground term t a finite set [t] of precomputed terms called its values. It is recursively defined as follows:

  • if t is a numeral or a symbolic constant, then [t] is the singleton set $\{t\}$ ;

  • if t is $|t_1|$ , then [t] is the set of numerals $\overline{|n|}$ for all integers n such that $\overline{n} \in [t_1]$ ;

  • if t is $(t_1 + t_2)$ , then [t] is the set of numerals $\overline{n_1 + n_2}$ for all integers $n_1$ , $n_2$ such that $\overline{n_1} \in [t_1]$ and $\overline{n_2} \in [t_2]$ ; similarly when t is $(t_1 - t_2)$ or $(t_1 \times t_2)$ ;

  • if t is $(t_1/t_2)$ , then [t] is the set of numerals $\overline{\mathit{round}(n_1/n_2)}$ for all integers $n_1$ , $n_2$ such that $n_1 \in [t_1]$ , $n_2 \in [t_2]$ , and $n_2 \neq 0$ ;

  • if t is $(t_1 \backslash t_2)$ , then [t] is the set of numerals $\overline{n_1 - n_2 \cdot \mathit{round}(n_1/n_2)}$ for all integers $n_1$ , $n_2$ such that $n_1 \in [t_1]$ , $n_2 \in [t_2]$ , and $n_2 \neq 0$ ;

  • if t is $(t_1..t_2)$ , then [t] is the set of numerals $\overline{m}$ for all integers m such that, for some integers $n_1$ , $n_2$ , $n_1 \in [t_1]$ , $n_2 \in [t_2]$ , $n_1 \leq m \leq n_2$ ;

where the function $\mathit{round}$ is defined as follows:

\begin{gather*} \mathit{round}(n) = \begin{cases} \lfloor n \rfloor & \text{if $n \geq 0$}, \\ \lceil n \rceil & \text{if $n < 0$}. \end{cases}\end{gather*}

The use of this function reflects the fact that the grounder gringo (Gebser et al. Reference Gebser, Kaminski, Kaufmann, Lindauer, Ostrowski, Romero, Schaub and Thiele2019) truncates non-integer quotients toward zero. This feature of gringo was not taken into account in earlier publications (Gebser et al. Reference Gebser, Harrison, Kaminski, Lifschitz and Schaub2015, Section 4.2; Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019, Section 6; Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020, Section 3), where the floor function was used.

For instance,

$$[\overline{7}/\overline{2}]=\{\overline{3}\},\;[\overline{0}\,..\,\overline{2}]=\{\overline{0}, \overline{1}, \overline{2}\},\;[\overline{2}/\overline{0}] = [\overline{2}\,..\,\overline{0}] = \emptyset;$$

$[\overline{2}+c] = [\overline{2}\,..\,c] = \emptyset$ if c is a symbolic constant.

For any ground terms $t_1, \dots, t_n$ , by $[t_1, \dots, t_n]$ we denote the set of tuples $r_1, \dots, r_n$ for all $r_1 \in [t_1], \dots, r_n \in[t_n]$ .

The semantics of programs is defined by rewriting rules in the syntax of propositional logic and referring to the definition of a stable model (answer set) of a propositional theory (Ferraris Reference Ferraris2005). The transformation $\tau$ is defined as follows. For any ground atom $p(\mathbf{t})$ , where $\mathbf{t}$ is a tuple of terms,

  • $\tau (p(\mathbf{t}))$ stands for $\bigvee_{\mathbf{r} \in [\mathbf{t}]} p(\mathbf{r})$ ,

  • $\tau (\mathit{not} p(\mathbf{t}))$ stands for $\bigvee_{\mathbf{r} \in [\mathbf{t}]} \neg p(\mathbf{r})$ , and

  • $\tau (\mathit{not} \mathit{not} p(\mathbf{t}))$ stands for $\bigvee_{\mathbf{r} \in [\mathbf{t}]} \neg\neg p(\mathbf{r})$ .

For any ground comparison $t_1 \mathit{rel} t_2$ , we define $\tau(t_1 \mathit{rel} t_2)$ as

  • $\top$ if the relation $\mathit{rel}$ holds between some $r_1$ from $[t_1]$ and some $r_2$ from $[t_2]$ ;

  • $\bot$ otherwise.

If each of $C_1,\dots, C_k$ is a ground literal or a ground comparison, then $\tau(C_1\land \cdots \land C_k)$ stands for $\tau C_1\land \cdots \land \tau C_k$ .

If R is a ground basic rule $p(\mathbf{t}) \leftarrow \mathit{Body}$ , then $\tau R$ is the propositional formula

\[\textstyle\tau(\mathit{Body}) \rightarrow\bigwedge_{\mathbf{r}\in [\mathbf{t}]} p(\mathbf{r}).\]

If R is a ground choice rule $\{p(\mathbf{t})\} \leftarrow \mathit{Body}$ , then $\tau R$ is the propositional formula

\[\textstyle\tau(\mathit{Body}) \rightarrow \bigwedge_{\mathbf{r} \in [\mathbf{t}]}(p(\mathbf{r})\lor\neg p(\mathbf{r})).\]

If R is a ground constraint $\leftarrow\mathit{Body}$ , then $\tau R$ is $\neg\tau(\mathit{Body})$ .

An instance of a rule is a ground rule obtained from it by substituting precomputed terms for variables. For any program $\Pi$ , $\tau\Pi$ is the set of the formulas $\tau R$ for all instances R of the rules of $\Pi$ . Thus $\tau\Pi$ is a set of propositional combinations of precomputed atoms.

For example, $\tau$ transforms $\{q(X)\} \leftarrow p(X)$ into the set of formulas

$$p(t)\to (q(t)\lor\neg q(t)),$$

for all precomputed terms t. The rule $q(\overline{0}\,..\,\overline{2}) \leftarrow \textit{not}\ p$ is transformed into

$$\neg p\to(q(\overline{0})\land q(\overline{1})\land q(\overline{2})).$$

Stable models of a program are defined as stable models of the set of formulas obtained from it by applying the transformation $\tau$ . Thus stable models of programs are sets of precomputed atoms. This definition is a special case of the definition proposed by Lifschitz et al. (Reference Lifschitz, Lühne and Schaub2019, Section 3) for Abstract Gringo, except for the changes in the treatment of the division and modulo operations mentioned above.

2.2 Programs with input and output

A program with input and output, or an io-program, is a quadruple

(10) \begin{equation}(\Pi,\textit{PH},\textit{In},\textit{Out}),\end{equation}

where

  • PH is a finite set of symbolic constants;

  • In is a finite set of predicate symbols,

  • Out is a finite set of predicate symbols that is disjoint from In,

and $\Pi$ is a mini-gringo program such that the symbols from In do not occur in the heads of its rules. Members of PH are the placeholders of (10); members of In are the input symbols of (10); members of Out are the output symbols of (10). The input symbols and output symbols of an io-program are collectively called its public symbols. The other predicate symbols occurring in the rules are private. An input atom is an atom $p(t_1,\dots,t_n)$ such that $p/n$ is an input symbol. Output atoms, public atoms and private atoms are defined in a similar way.

For any set $\mathcal{P}$ of public atoms, $\mathcal{P}^{in}$ stands for the set of input atoms in $\mathcal{P}$ .

The example discussed in the introduction corresponds to program (3)–(8) as $\Pi$ , and

(11) \begin{equation}\textit{PH}=\{h\},\;\textit{In}= \{\textit{person}/1, \textit{in}_0/2, \textit{goto}/3\},\;\textit{Out}= \{\textit{in}/3\}.\end{equation}

This io-program will be denoted by $\Omega_1$ . The only private symbol of $\Omega_1$ is $\textit{in_building}/2$ .

A valuation on a set PH of symbolic constants is a function that maps elements of PH to precomputed terms that do not belong to PH. An input for an io-program (10) is a pair $(v,\mathcal{I})$ , where

  • v is a valuation on the set PH of its placeholdlers, and

  • $\mathcal{I}$ is a set of precomputed input atoms such that its members do not contain placeholders.

An input $(v,\mathcal{I})$ represents a way to choose the values of placeholders and the extents of input predicates: for every placeholder c, specify v(c) as its value, and add the atoms $\mathcal{I}$ to the rules of the program as facts. If $\Pi$ is a mini-gringo program then $v(\Pi)$ stands for the program obtained from $\Pi$ by replacing every occurrence of every constant c in the domain of v by v(c). Using this notation, we can say that choosing $(v,\mathcal{I})$ as input for $\Pi$ amounts to replacing $\Pi$ by the program $v(\Pi)\cup\mathcal{I}$ .

About a set of precomputed atoms we say that it is an io-model of an io-program (10) for an input $(v,\mathcal{I})$ if it is the set of all public atoms of some stable model of the program $v(\Pi)\cup\mathcal{I}$ . If $\mathcal{P}$ is an io-model of an io-program for an input $(v,\mathcal{I})$ then $\mathcal{P}^{in}=\mathcal{I}$ , because the only rules of $v(\Pi)\cup\mathcal{I}$ containing input symbols in the head are the facts $\mathcal{I}$ .

For example, an input $(v,\mathcal{I})$ for the io-program $\Omega_1$ can be defined by the conditions

(12) \begin{equation}\begin{array} lv(h)=\overline{2},\\\mathcal{I}= \{\textit{person}(\textit{alice}),\textit{person}(\textit{bob}),\\\hskip 9mm\textit{in}_0(\textit{alice},\textit{hall}),\textit{in}_0(\textit{bob},\textit{hall}),\\\hskip 9mm\textit{goto}(\textit{alice},\textit{classroom},\overline{0}),\textit{goto}(\textit{bob},\textit{classroom},\overline{1})\}.\end{array}\end{equation}

The program $v(\Pi)\cup\mathcal{I}$ has a unique stable model, which consists of the members of $\mathcal{I}$ , the atoms

(13) \begin{equation}\begin{array} l\{\textit{in}(\textit{alice},hall,\overline{0}),\textit{in}(\textit{bob},hall,\overline{0}),\\\hskip 2mm\textit{in}(\textit{alice},classroom,\overline{1}),\textit{in}(\textit{bob},hall,\overline{1}),\\\hskip 2mm\textit{in}(\textit{alice},classroom,\overline{2}),\textit{in}(\textit{bob},classroom,\overline{2})\},\end{array}\end{equation}

and the private atoms $\textit{in_building}(p,\overline{i})$ for all p in $\{\textit{alice},\textit{bob}\}$ and all i in $\{0,1,2\}$ . The io-model of $\Omega_1$ for $(v,\mathcal{I})$ consists of the members of $\mathcal{I}$ and atoms (13).

2.3 Two-sorted formulas and standard interpretations

The two-sorted signature $\sigma_0$ includes

  • the sort general and its subsort integer;

  • all precomputed terms of mini-gringo as object constants; an object constant is assigned the sort integer iff it is a numeral;

  • the symbol $|\,|$ as a unary function constant; its argument and value have the sort integer;

  • the symbols $+$ , $-$ and $\times$ as binary function constants; their arguments and values have the sort integer;

  • predicate symbols $p/n$ as n-ary predicate constants; their arguments have the sort general;

  • symbols (9) as binary predicate constants; their arguments have the sort general.Footnote 1

A formula of the form $(p/n)({\bf t})$ can be written also as $p({\bf t})$ . This convention allows us to view precomputed atoms (Section 2.1.1) as sentences over $\sigma_0$ . Conjunctions of equalities and inequalities can be abbreviated as usual in algebra; for instance, $X=Y<Z$ stands for $X=Y\land Y<Z$ .

An interpretation of the signature $\sigma_0$ is standard if

  • (a) its domain of the sort general is the set of precomputed terms;

  • (b) its domain of the sort integer is the set of numerals;

  • (c) every object constant represents itself;

  • (d) the absolute value symbol and the binary function constants are interpreted as usual in arithmetic;

  • (e) predicate constants (9) are interpreted in accordance with the total order on precomputed terms chosen in the definition of mini-gringo (Section 2.1.1).

A standard interpretation will be uniquely determined if we specify the set $\mathcal{J}$ of precomputed atoms to which it assigns the value true. This interpretation will be denoted by $\mathcal{J}^\uparrow$ .

When formulas over $\sigma_0$ are used in reasoning about io-programs with placeholders, we may need interpretations satisfying a condition different from (c). An interpretation is standard for a set PH of symbolic constants if it satisfies conditions (a), (b), (d), (e) above and the conditions

(cʹ) every object constant that belongs to PH represents a precomputed term that does not belong to PH;

(cʹʹ) every object constant that does not belong to PH represents itself.

An interpretation that is standard for PH will be uniquely determined if we specify (i) the valuation v that maps every element of PH to the precomputed term that it represents, and (ii) the set $\mathcal{J}$ of precomputed atoms to which it assigns the value true. This interpretation will be denoted by $\mathcal{J}^v$ .

2.4 Representing rules by formulas

From now on, we assume that every symbol designated as a variable in mini-gringo is among general variables of the signature $\sigma_0$ . The transformation $\tau^*$ , described in this section, converts mini-gringo rules into formulas over $\sigma_0$ .

First we define, for every mini-gringo term t, a formula $\mathit{val}_{t}(V)$ over the signature $\sigma_0$ , where V is a general variable that does not occur in t. That formula expresses, informally speaking, that V is one of the values of t. The definition is recursive:Footnote 2

  • if t is a precomputed term or a variable then $\mathit{val}_{t}(V)$ is $V=t$ ,

  • if t is $|t_1|$ then $\mathit{val}_{t}(V)$ is $\exists I(\mathit{val}_{t_1}(I)\land V =|I|)$ ,

  • if t is $t_1\;\textit{op}\;t_2$ , where op is $+$ , $-$ , or $\times$ then $\mathit{val}_{t}(V)$ is

    $$\exists I J (\mathit{val}_{t_1}(I) \land \mathit{val}_{t_2}(J) \land V=I\;\textit{op}\;J),$$
  • if t is $t_1\,/\,t_2$ then $\mathit{val}_{t}(V)$ is

    $$\begin{array} l\exists I J K (\mathit{val}_{t_1}(I) \land \mathit{val}_{t_2}(J)\land K\times |J|\leq |I|<(K+\overline{1})\times |J|\\\hskip 1.2cm \land\; ((I\times J \geq \overline{0} \land V=K)\lor(I\times J < \overline{0} \land V=-K))),\end{array}$$
  • if t is $t_1\backslash t_2$ then $\mathit{val}_{t}(V)$ is

    $$\begin{array} l\exists I J K (\mathit{val}_{t_1}(I) \land \mathit{val}_{t_2}(J)\land K\times |J|\leq |I|<(K+\overline{1})\times |J|\\\hskip 1.2cm \land\; ((I\times J \geq \overline{0} \land V=I-K\times J)\lor(I\times J < \overline{0} \land V=I+K\times J))),\end{array}$$
  • if t is $t_1\,..\,t_2$ then $\mathit{val}_{t}(V)$ is

    $$\exists I J K (\mathit{val}_{t_1}(I) \land \mathit{val}_{t_2}(J) \land I\leq K \leq J \land V=K),$$
    where I, J, K are fresh integer variables.

If $\bf t$ is a tuple $t_1,\dots,t_n$ of mini-gringo terms, and $\bf V$ is a tuple $V_1,\dots,V_n$ of distinct general variables, then $\mathit{val}_{\bf t}(\bf V)$ stands for the conjunction $\mathit{val}_{t_1}(V_1) \land \cdots \land \mathit{val}_{t_n}(V_n)$ .

The next step is to define the transformation $\tau^B$ , which converts literals and comparisons into formulas over $\sigma_0$ . (The superscript B reflects the fact that this translation is close to the meaning of expressions in bodies of rules.) It transforms

  • $p({\bf t})$ into $\exists {\bf V}({\mathit{val}_{\bf t}(\bf V)} \land p({\bf V}))$ ;

  • $\textit{not}\ p({\bf t})$ into $\exists {\bf V}({\mathit{val}_{\bf t}(\bf V)} \land \neg p({\bf V}))$ ;

  • $\textit{not}\ \textit{not}\ p({\bf t})$ into $\exists {\bf V}({\mathit{val}_{\bf t}(\bf V)} \land \neg\neg p({\bf V}))$ ;

  • $t_1 \;\mathit{rel}\; t_2$ into $\exists V_1 V_2 (\mathit{val}_{t_1}(V_1) \land \mathit{val}_{t_2}(V_2) \land V_1\;\mathit{rel}\; V_2)$ .

If Body is a conjunction $B_1\land B_2\land\cdots$ of literals and comparisons then $\tau^B(\textit{Body})$ stands for the conjunction $\tau^B(B_1)\land\tau^B(B_2)\land\cdots$ .

Now we are ready to define the transformation $\tau^*$ . It converts a basic rule

(14) \begin{gather} p({\bf t}) \leftarrow \mathit{Body,} \end{gather}

of a program $\Pi$ into the formula

$$\widetilde{\forall}({\mathit{val}_{\bf t}(\bf V)} \land \tau^B(\mathit{Body}) \rightarrow p({\bf V})),$$

where $\bf V$ is the list of alphabetically first general variables that do not occur in $\Pi$ , and $\widetilde{\forall}$ denotes universal closure (see Appendix A). A choice rule

(15) \begin{equation}\{p({\bf t})\} \leftarrow \mathit{Body,}\end{equation}

is converted intoFootnote 3

(16) \begin{equation} \widetilde{\forall}({\mathit{val}_{\bf t}(\bf V)} \land \tau^B(\mathit{Body}) \land \neg\neg p({\bf V}) \rightarrow p({\bf V})), \end{equation}

and a constraint $\leftarrow\mathit{Body}$ becomes $\widetilde{\forall}(\tau^B(\mathit{Body})\to\bot)$ .

By $\tau^*\Pi$ we denote the set of sentences $\tau^* R$ for all rules R of $\Pi$ .

The transformation $\tau^*$ can be used in place of the transformation $\tau$ (Section 2.1.2) to describe the stable models of a mini-gringo program, as shown by the theorem below. Its statement refers to stable models of many-sorted theories (Appendix B) for the case when the underlying signature is $\sigma_0$ , and all comparison symbols are classified as extensional. Its proof is given in Section 8.

Theorem 1 A set $\mathcal{J}$ of precomputed atoms is a stable model of a mini-gringo program $\Pi$ iff $\mathcal{J}^\uparrow$ is a stable model of $\tau^*\Pi$ .

3 Completion

This section describes the process of constructing the completion of an io-program. This construction involves the formulas $\tau^*R$ for the rules R of the program, and it exploits the special syntactic form of these formulas, as discussed below.

3.1 Completable sets

Consider a many-sorted signature $\sigma$ (see Appendix A) with its predicate constants partitioned into intensional symbols and extensional symbols, so that the set of intensional symbols is finite. A sentence over $\sigma$ is completable if it has the form

(17) \begin{equation}\widetilde{\forall} (F\to G),\end{equation}

where G either contains no intensional symbols or has the form $p({\bf V})$ , where p is an intensional symbol with argument sorts $s_1,\dots,s_n$ , and $\bf V$ is a tuple of pairwise distinct variables of these sorts. A finite set $\Gamma$ of sentences is completable if

  • every sentence in $\Gamma$ is completable, and

  • for any two sentences $\widetilde{\forall} (F_1\to G_1)$ , $\widetilde{\forall} (F_2\to G_2)$ in $\Gamma$ such that $G_1$ and $G_2$ contain the same intensional symbol, $G_1=G_2$ .

It is easy to see that for any mini-gringo program $\Pi$ , the set $\tau^*\Pi$ is completable.

The definition of an intensional symbol p in a completable set $\Gamma$ is the set of members (17) of $\Gamma$ such that p occurs in G. A first-order constraint is a completable sentence (17) such that G does not contain intensional symbols. Thus $\Gamma$ is the union of the definitions of intensional symbols and a set of first-order constraints.

If the definition of p in $\Gamma$ consists of the sentences $\widetilde{\forall}(F_i({\bf V})\to p({\bf V}))$ then the completed definition of p in $\Gamma$ is the sentence

$$\forall {\bf V} \left (p({\bf V}) \leftrightarrow \bigvee_i \exists {\bf U}_i\,F_i({\bf V}) \right ),$$

where ${\bf U}_i$ is the list of free variables of $F_i({\bf V})$ that do not belong to $\bf V$ .

The completion $\mathrm{COMP}[\Gamma]$ of a completable set $\Gamma$ is the conjunction of the completed definitions of all intensional symbols of $\sigma$ in $\Gamma$ and the constraints of $\Gamma$ .

3.2 Completion of a program with input and output

The completion of an io-program (10) is the second-order sentenceFootnote 4 $\exists P_1 \cdots P_l\,C$ , where C is obtained from the sentence $\mathrm{COMP}[\tau^*\Pi]$ by replacing all private symbols $p_1/n_1,\dots,p_l/n_l$ with distinct predicate variables $P_1,\dots,P_l$ . The completion of $\Omega$ will be denoted by $\mathrm{COMP}[\Omega]$ .Footnote 5 In building $\mathrm{COMP}[\Omega]$ , we classify as extensional all comparison and input symbols. All output and private symbols are intensional.

Consider, for example, the io-program with the rules

(18) \begin{equation}\begin{array} lp(a),\\p(b),\\q(X,Y) \leftarrow p(X) \land p(Y),\end{array}\end{equation}

without input symbols and with the output symbol $q/2$ . The translation $\tau^*$ transforms these rules into the formulas

(19) \begin{gather} \newcommand{\shorteq}{\hspace{-2pt}=\hspace{-2pt}} \begin{aligned}[c] &\forall V_1(V_1=a \to p(V_1)),\\ &\forall V_1(V_1=b \to p(V_1)),\\ &\forall XYV_1V_2(V_1 \shorteq X \land V_2 \shorteq Y \land \exists V(V \shorteq X \land p(V)) \land\exists V(V \shorteq Y \land p(V))\to q(V_1,V_2)). \end{aligned} \end{gather}

The completed definition of $p/1$ in (19) is

$$\forall V_1 (p(V_1) \leftrightarrow V_1=a \lor V_1=b),$$

and the completed definition of $q/2$ is

$$\begin{array} l\forall V_1V_2(q(V_1,V_2)\, \leftrightarrow\\\qquad\quad\qquad\exists XY(V_1=X \land V_2=Y \land \exists V(V=X \land p(V)) \land\exists V(V=Y\land p(V)))).\end{array}$$

The completion of the program is

(20) \begin{equation}\begin{array} l\!\!\!\exists P(\forall V_1(P(V_1) \leftrightarrow V_1=a \lor V_1=b)\,\land\\\quad\;\forall V_1V_2(q(V_1,V_2)\, \leftrightarrow\\\qquad\;\;\;\exists XY(V_1=X \land V_2=Y \land \exists V(V=X \land P(V)) \land\exists V(V=Y\land P(V))))).\end{array}\end{equation}

Formula (20) can be equivalently rewritten as

$$\exists P(\forall V_1(P(V_1) \leftrightarrow V_1=a \lor V_1=b)\land\forall V_1V_2(q(V_1,V_2) \leftrightarrow P(V_1) \land P(V_2))).$$

Second-order quantifiers in completion formulas can often be eliminated. For instance, formula (20) is equivalent to the first-order formula

$$\forall V_1V_2(q(V_1,V_2) \leftrightarrow (V_1=a \lor V_1=b)\land(V_2=a \lor V_2=b)).$$

3.3 Review: Tight programs

We are interested in cases when the sentence $\mathrm{COMP}[\Omega]$ can be viewed as a description of the io-models of $\Omega$ . This is a review of one result of this kind.

The positive predicate dependency graph of a mini-gringo program $\Pi$ is the directed graph defined as follows. Its vertices are the predicate symbols $p/n$ that occur in $\Pi$ . It has an edge from $p/n$ to $p'/n'$ iff $p/n$ occurs in the head of a rule R of $\Pi$ such that $p'/n'$ occurs in an atom that is a conjunctive term of the body of R.

A mini-gringo program is tight if its positive predicate dependency graph is acyclic. For example, the positive predicate dependency graph of program (18) has a single edge, from $q/2$ to $p/1$ ; this program is tight. The positive predicate dependency graph of program (3)–(8) includes a self-loop at $\textit{in}/3$ ; this program is not tight.

Let $\Omega$ be an io-program $(\Pi,\textit{PH},\textit{In},\textit{Out})$ , and let $\mathcal{P}$ be a set of precomputed public atoms that do not contain placeholders of $\Omega$ . Under the assumption that $\Pi$ is tight, $\mathcal{P}$ is an io-model of $\Omega$ for an input $(v,\mathcal{I})$ iff $\mathcal{P}^v$ satisfies $\mathrm{COMP}[\Omega]$ and $\mathcal{P}^{in} = \mathcal{I}$ (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020, Theorem 2).

4 Locally tight programs

For any tuple $t_1,\dots,t_n$ of ground terms, $[t_1,\dots,t_n]$ stands for the set of tuples $r_1,\dots,r_n$ of precomputed terms such that $r_1\in[t_1],\dots,r_n\in[t_n]$ .

The positive dependency graph of an io-program $\Omega$ for an input $(v,\mathcal{I})$ is the directed graph defined as follows. Its vertices are the ground atoms $p(r_1,\dots,r_n)$ such that $p/n$ is an output symbol or a private symbol of $\Omega$ , and each $r_i$ is a precomputed term different from the placeholders of $\Omega$ . It has an edge from $p({\bf r})$ to $p'({\bf r}')$ iff there exists a ground instance R of one of the rules of $v(\Pi)$ such that

  • (a) the head of R has the form $p({\bf t})$ or $\{p({\bf t})\}$ , where t is a tuple of terms such that ${\bf r}\in[{\bf t}]$ ;

  • (b) the body of R has a conjunctive term of the form $p'({\bf t})$ , where t is a tuple of terms such that ${\bf r}'\in[{\bf t}]$ ;

  • (c) for every conjunctive term of the body of R that contains an input symbol of $\Omega$ and has the form $q({\bf t})$ or $\textit{not}\ \textit{not}\ q({\bf t})$ , the set $[{\bf t}]$ contains a tuple $\bf r$ such that $q({\bf r})\in\mathcal{I}$ ;

  • (d) for every conjunctive term of the body of R that contains an input symbol of $\Omega$ and has the form $\textit{not}\ q({\bf t})$ , the set $[{\bf t}]$ contains a tuple $\bf r$ such that $q({\bf r})\not\in\mathcal{I}$ ;

  • (e) for every comparison ${t_1 \prec t_2}$ in the body of R, there exist terms $r_1$ , $r_2$ such that $r_1\in[t_1]$ , $r_2\in[t_2]$ , and the relation $\prec$ holds for the pair ${(r_1,r_2)}$ .

Recall that an infinite walk in a directed graph is an infinite sequence of edges which joins a sequence of vertices. If the positive dependency graph of $\Omega$ for an input $(v,\mathcal{I})$ has no infinite walks, then we say that $\Omega$ is locally tight on that input.

Consider, for example, the positive dependency graph of the io-program $\Omega_1$ (Section 2.2). Its vertices for an input $(v,\mathcal{I})$ are atoms $\textit{in}(p,r,t)$ and $\textit{in_building}(p,t)$ , where p, r, t are precomputed terms different from h. The only rules of $\Omega_1$ that contribute edges to the graph are (5) and (7), because all predicate symbols in the bodies of (3) and (4) are input symbols, and rules (6) and (8) are constraints. If R is (5) then v(R) is the rule

An instance

$$\{\textit{in}(p,r,t+\overline{1})\} \leftarrow \textit{in}(p,r,t) \land t = \overline{0}\,..\,v(h)\!-\!\overline{1},$$

of this rule contributes an edge if and only if v(h) is a numeral $\overline{n}$ , t is a numeral $\overline{i}$ , and $0\leq i<n$ . If R is (7) then $v(R)=R$ , and an instance

$$\textit{in_building}(p,t) \leftarrow \textit{in}(p,r,t),$$

of v(R) contributes the edge

(21) \begin{equation}\textit{in_building}(p,t) \longrightarrow \textit{in}(p,r,t).\end{equation}

Consequently the edges of the positive dependency graph of $\Omega_1$ are (21) and

$$\textit{in}(p,r,\overline{i+1}) \longrightarrow \textit{in}(p,r,\overline{i}),$$

if $v(h)=\overline{n}$ and $0\leq i <n$ . It is clear that this graph has no infinite walks. Consequently $\Omega_1$ is locally tight on all inputs.

Proposition 1 If a mini-gringo program $\Pi$ is tight then any io-program of the form $(\Pi,\textit{PH},\textit{In},\textit{Out})$ is locally tight for all inputs.

Proof Assume that $\Pi$ is tight, but the positive dependency graph of $(\Pi,\textit{PH},\textit{In},\textit{Out})$ for some input has an infinite walk. If that graph has an edge from $p(r_1,\dots,r_n)$ to $p'(r'_1,\dots,r'_{n'})$ then the positive predicate dependency graph of $\Pi$ has an edge from $p/n$ to $p'/n'$ . Consequently this graph has an infinite walk as well. But that is impossible, because this graph is finite and acyclic.

The example of program $\Omega_1$ shows that the converse of Proposition 1 does not hold.

The theorem below generalizes the property of tight programs reviewed at the end of Section 3.3. For any formula F over $\sigma_0$ and any valuation v, v(F) stands for the formula obtained from F by replacing every occurrence of every constant c in the domain of v by v(c). The proof of the following theorem is given in Section 9.

Theorem 2 For any io-program $\Omega$ , any set $\mathcal{P}$ of precomputed public atoms that do not contain placeholders of $\Omega$ , and any input $(v,\mathcal{I})$ for which $\Omega$ is locally tight, the following conditions are equivalent:

  • (a) $\mathcal{P}$ is an io-model of $\Omega$ for $(v,\mathcal{I})$ ,

  • (b) $\mathcal{P}^\uparrow$ satisfies $v(\mathrm{COMP}[\Omega])$ and $\mathcal{P}^{in} = \mathcal{I}$ ,

  • (c) $\mathcal{P}^v$ satisfies $\mathrm{COMP}[\Omega]$ and $\mathcal{P}^{in} = \mathcal{I}$ .

Take, for instance, the io-program $\Omega_1$ and the input $(v,\mathcal{I})$ defined by conditions (12). We observed in Section 2.2 that the set $\mathcal{P}$ obtained from $\mathcal{I}$ by adding atoms (13) is an io-model of $\Omega_1$ for $(v,\mathcal{I})$ . According to Theorem 2, this observation is equivalent to the claim that the corresponding interpretation $\mathcal{P}^\uparrow$ satisfies the sentence obtained from $\mathrm{COMP}[\Omega_1]$ by substituting $\overline{2}$ for the placeholder h.

5 Equivalence of io-programs

We begin with an example. Consider the io-program $\Omega_2$ , obtained from $\Omega_1$ by replacing inertia rule (5) with the pair of rules

(22) \begin{equation}\textit{go}(P,T) \leftarrow \textit{goto}(P,R,T),\end{equation}

(23) \begin{equation}\textit{in}(P,R,T+1) \leftarrow \textit{in}(P,R,T) \land \textit{not}\ \textit{go}(P,T) \land T = 0\,..\,h- 1. \end{equation}

Here $\textit{go}/2$ is a new private symbol. These rules express commonsense inertia in a different way, using the fact that goto actions are the only possible causes of change in the location of a person. Programs $\Omega_1$ and $\Omega_2$ describe the same dynamic system using two different approaches to encoding inertia.

Are these programs equivalent, in some sense? The idea of equivalence with respect to a user guide (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023) allows us to make this question precise. We present the details below.

About two io-programs we say that they are comparable to each other if they have the same placeholders, the same input symbols, and the same output symbols. For example, $\Omega_1$ and $\Omega_2$ are comparable. Any two comparable programs have the same inputs, because the definition of an input for $\Omega$ (Section 2.2) refers to only two components of $\Omega$ – to its placeholders and its input symbols.

We will define when comparable io-programs $\Omega$ , $\Omega'$ are equivalent to each other on a subset Dom of their inputs. Sets of inputs will be called domains. We need domains to express the idea that two io-programs can be equivalent even if they exhibit different behaviors on some inputs that we consider irrelevant. In an input for $\Omega_1$ or $\Omega_2$ , for example, the first argument of each of the predicate symbols $\textit{in}_0/2$ , $\textit{goto}/3$ is expected to be a person; we are not interested in inputs that contain $\textit{in}_0(\textit{alice},\textit{hall})$ but do not contain $\textit{person}(\textit{alice})$ .

Domains are infinite sets, but there is a natural way to represent some domains by finite expressions. An assumption for an io-program $\Omega$ is a sentence over $\sigma_0$ such that every predicate symbol $p/n$ occurring in it is an input symbol of $\Omega$ . The domain defined by an assumption A is the set of all inputs $(v,\mathcal{I})$ such that the interpretation $\mathcal{I}^v$ satisfies A. For example, the assumption

(24) \begin{equation}\forall P R (\textit{in}_0(P,R) \to \textit{person}(P)),\end{equation}

where P and R are general variables, defines the set $\mathcal{I}$ of all inputs for $\Omega_1$ such that $\textit{person}(p)\in\mathcal{I}$ whenever $\textit{in}_0(p,r)\in\mathcal{I}$ .

About comparable io-programs $\Omega$ , $\Omega'$ we say that they are equivalent on a domain Dom if, for every input $(v,\mathcal{I})$ from Dom, $\Omega$ and $\Omega'$ have the same io-models for that input.

anthem-p2p (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023) is a proof assistant designed for verifying equivalence of io-programs in the sense of this definition. It uses the following terminology. A user guide is a quadruple

(25) \begin{equation}(\textit{PH},\textit{In},\textit{Out},\textit{Dom}),\end{equation}

where PH, In and Out are as in the definition of an io-program (Section 2.2), and Dom is a domain. The assertion that io-programs $(\Pi,\textit{PH},\textit{In},\textit{Out})$ and $(\Pi',\textit{PH},\textit{In},\textit{Out})$ are equivalent on a domain Dom can be expressed by saying that $\Pi$ and $\Pi'$ are equivalent with respect to user guide (25).Footnote 6

We can say, for example, that replacing rule (5) in mini-gringo program (3)–(8) with rules (22) is an equivalent transformation for the user guide (25) with PH, In and Out defined by formulas (11), and with Dom defined by the conjunction of assumption (24) and the assumption

(26) \begin{equation}\forall P R\, T(\textit{goto}(P,R,T) \to \textit{person}(P)).\end{equation}

Theorem 3 below shows that using the anthem-p2p algorithm for verifying equivalence of io-programs can be justified under a local tightness condition. If an io-program is locally tight for all inputs satisfying an assumption A then we say that it is locally tight under the assumption A. If two comparable io-programs are equivalent on the domain defined by an assumption A then we say that they are equivalent under the assumption A. The proof of the following theorem is given in Section 10.

Theorem 3 Let $\Omega$ , $\Omega'$ be comparable io-programs with placeholders PH that are locally tight under an assumption A. Programs $\Omega$ , $\Omega'$ are equivalent to each other under the assumption A iff the sentence

(27) \begin{equation}A\to(\mathrm{COMP}[\Omega] \leftrightarrow\mathrm{COMP}[\Omega']),\end{equation}

is satisfied by all interpretations that are standard for PH.

From Theorem 3 we can conclude that equivalence between $\Omega$ and $\Omega'$ will be established if formula (27) is derived from a set of axioms that are satisfied by all interpretations that are standard for PH. This is how anthem-p2p operates (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023, Sections 7).

The claim that $\Omega_1$ is equivalent to $\Omega_2$ assuming (24) and (26) has been verified by anthem-p2p, with the resolution theorem prover vampire (Kovaćs and Voronkov Reference Kovaćs and Voronkov2013) used as the proof engine. We saw in Section 4 that $\Omega_1$ is locally tight for all inputs. The positive dependency graph of $\Omega_2$ has additional edges, from $\textit{go}(p,t)$ to $\textit{goto}(p,r,t)$ . It is clear that this graph has no infinite walks either, so that $\Omega_2$ is locally tight for all inputs as well.

The process of verifying equivalence in this case was interactive – we helped vampire find a proof by suggesting useful lemmas and an induction axiom, as usual in such experiments (Fandinno et al. Reference Fandinno, Hansen, Lierler, Lifschitz and Temple2023, Section 6; Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020, Figure 5). Induction was needed to prove the lemma

$$\forall P R\, T(\textit{in}(P,R,T) \to \textit{person}(P)),$$

with (24) used to justify the base case.

6 Main Lemma

The Main Lemma, stated below, relates the completion of a completable set of sentences (Section 3.1) to its stable models (Appendix B).

As in Section 3.1, $\sigma$ stands here for a many-sorted signature with its predicate constants partitioned into intensional and extensional. The symbols $\sigma^I$ , $\mathbf{d}^*$ , used in this section, are introduced in Appendix A; $I^\downarrow$ is defined in Appendix B.

We define, for an interpretation I of $\sigma$ and a sentence F over $\sigma^I$ , the set $\mathit{Pos}({F},I)$ of (strictly) positive atoms of F with respect to I. Elements of this set are formulas of the form $p(\mathbf{d}^*)$ . This set is defined recursively, as follows. If F does not contain intensional symbols or is not satisfied by I then $\mathit{Pos}({F},I) = \emptyset$ . Otherwise,

  • (i) $\mathit{Pos}({p(\mathbf{t})},I) = \{p((\mathbf{t}^I)^*)\}$ ;

  • (ii) $\mathit{Pos}({F_1 \wedge F_2},I) = \mathit{Pos}({F_1 \vee F_2},I) = \mathit{Pos}({F_1},I) \cup \mathit{Pos}({F_2},I)$ ;

  • (iii) $\mathit{Pos}({F_1 \to F_2},I) = \mathit{Pos}({F_2},I)$ ;

  • (iv) $\mathit{Pos}({\forall X F(X)},I) = \mathit{Pos}({\exists X F(X)},I) = \bigcup_{d\in|I|^s} \mathit{Pos}({F(d^*)},I)$ if X is a variable of sort s.

It is easy to check by induction on F that $\mathit{Pos}({F},I)$ is a subset of the set $I^\downarrow$ .

An instance of a completable sentence $\widetilde{\forall}(F \to G)$ over $\sigma^I$ is a sentence obtained from $F\to G$ by substituting names $d^*$ for its free variables. For any completable set $\Gamma$ of sentences over $\sigma^I$ , the positive dependency graph $G^{sp}_{I}(\Gamma)$ is the directed graph defined as follows. Its vertices are elements of $I^\downarrow$ . It has an edge from A to B iff, for some instance $F\to G$ of a member of $\Gamma$ , $A\in\mathit{Pos}({G},I)$ and $B\in\mathit{Pos}({F},I)$ .

Main Lemma

For any interpretation I of $\sigma$ and any completable set $\Gamma$ of sentences over $\sigma^I$ such that the graph $G^{sp}_I(\Gamma)$ has no infinite walks, I is a stable model of $\Gamma$ iff $I\models\mathrm{COMP}[\Gamma]$ .

Consider, for example, the signature consisting of a single sort, the object constants a, b, and the intensional unary predicate constant p. Let $\Gamma$ be

$$\{\forall V(V=a\to p(V)),\ \forall V(V=b \land p(V) \to p(V))\},$$

and let the interpretations I, J be defined by the conditions

$$\begin{array} c |I|=|J|=\{0,1,\dots\};\ a^I=a^J=0;\ b^I=b^J=1;\\p^I(n)=\textit{true}\hbox{ iff }n=0;\ p^J(n)=\textit{true}\hbox{ iff }n\in\{0,1\}.\end{array}$$

Instances of the members of $\Gamma$ are implications of the forms

$$n^*=a\to p(n^*)\quad\hbox{and}\quad n^*=b \land p(n^*) \to p(n^*),$$

( $n=0,1,\dots$ ). The set $I^\downarrow$ of vertices of the graph $G^{sp}_I(\Gamma)$ is $\{p(0^*)\}$ . This graph has no edges, because, for every n,

$$\mathit{Pos}({n^*=a},I)=\mathit{Pos}({n^*=b \land p(n^*)},I)=\emptyset.$$

The set $J^\downarrow$ of vertices of $G^{sp}_J(\Gamma)$ is $\{p(0^*),p(1^*)\}$ . This graph has one edge – the self-loop at $p(1^*)$ , because

$$\mathit{Pos}({1^*=b \land p(1^*)},J)=\mathit{Pos}({p(1^*)},J) =\{p(1^*)\}.$$

Consequently the Main Lemma is applicable to I, but not to J. It asserts that I is a stable model of $\Gamma$ (which is true) iff I satisfies the completion

$$\forall V(p(V)\leftrightarrow V=a\lor(V=b\land p(b)),$$

of $\Gamma$ (which is true as well). The interpretation J, on the other hand, satisfies the completion of $\Gamma$ , but it is not a stable model.

The Main Lemma is similar to two results published earlier (Ferraris et al. Reference Ferraris, Lee and Lifschitz2011, Theorem 11; Lee and Meng Reference Lee and Meng2011, Corollary 4). The former refers to dependencies between predicate constants, rather than ground atoms. The latter is applicable to formulas of different syntactic form.

About an interpretation I of $\sigma$ we say that it is semi-Herbrand if

  • all elements of its domains are object constants of $\sigma$ , and

  • $d^I=d$ for every such element d.Footnote 7

For example, every interpretation of $\sigma_0$ that is standard, or standard for some set PH (Section 2.3), is semi-Herbrand.

If I is semi-Herbrand then the graph $G^{sp}_I(\Gamma)$ can be modified by replacing each vertex $p({\bf d}^*)$ by the atom $p({\bf d})$ over the signature $\sigma$ . This modified positive dependency graph is isomorphic to $G^{sp}_I(\Gamma)$ as defined above. It can be defined independently, by replacing clauses (i) and (iv) in the definition of $\mathit{Pos}({ },I)F$ above by

(i)ʹ $\mathit{Pos}({p(\mathbf{t})},I) = \{p(\mathbf{t}^I)\}$ ;

(iv)ʹ $\mathit{Pos}({\forall X F(X)},I) = \mathit{Pos}({\exists X F(X)},I) = \bigcup_{d\in|I|^s} \mathit{Pos}({F(d)},I)$ if X is a variable of sort s.

7 Proof of the Main Lemma

The Main Lemma expresses a property of the completion operator, and its proof below consists of two parts. We first prove a similar property of pointwise stable models, defined in Appendix B (Lemma 3); then we relate pointwise stable models to completion.

As in Section 6, $\sigma$ stands for a many-sorted signature with its predicate constants subdivided into intensional and extensional.

Lemma 1 For any HT-interpretation $\langle\mathcal{H},I \rangle$ and any sentence F over $\sigma^I$ , if $I \models F$ and $\mathit{Pos}({F},I)\subseteq \mathcal{H}$ then $\langle\mathcal{H},I \rangle\models_{ht} F.$

Proof By induction on the size of F. Case 1: F does not contain intensional symbols. The assertion of the lemma follows from Proposition 3(b) in Appendix B. Case 2: F contains an intensional symbol. Since ${I\models F}$ , the set $\mathit{Pos}({F},I)$ is determined by the recursive clauses in the definition of $\mathit{Pos}$ . Case 2.1: F is $p(\mathbf{t})$ , where p is intensional. Then, the assumption $\mathit{Pos}({F},I)\subseteq \mathcal{H}$ and the claim $\langle\mathcal{H},I\rangle\models_{ht} F$ turn into the condition $p((\mathbf{t}^I)^*)\in \mathcal{H}$ . Case 2.2: F is $F_1\land F_2$ . Then, from the assumption ${I\models F}$ we conclude that ${I\models F_i}$ for $i=1,2$ . On the other hand,

$$\mathit{Pos}({F_i},I)\subseteq\mathit{Pos}({F},I)\subseteq \mathcal{H}.$$

By the induction hypothesis, it follows that $\langle\mathcal{H},I\rangle\models_{ht} F_i$ , and consequently ${\langle\mathcal{H},I\rangle\models_{ht} F}$ . Case 2.3: F is $F_1\lor F_2$ . Similar to Case 2.2. Case 2.4: F is $F_1\to F_2$ . Since ${I\models F_1\to F_2}$ , we only need to check that ${\langle\mathcal{H},I\rangle \not\models_{ht} F_1}$ or ${\langle\mathcal{H},I\rangle\models_{ht} F_2}$ . Case 2.4.1: $I\models F_1$ . Since $I\models F_1\to F_2$ , it follows that $I\models F_2$ . On the other hand,

$$\mathit{Pos}({F_2},I)=\mathit{Pos}({F},I)\subseteq \mathcal{H}.$$

By the induction hypothesis, it follows that $\langle\mathcal{H},I\rangle\models_{ht} F_2$ . Case 2.4.2: $I\not\models F_1$ . By Proposition 3(a) in Appendix B, it follows that $\langle\mathcal{H},I\rangle\not\models_{ht} F_1$ . Case 2.5: F is $\forall X\,G(X)$ , where X is a variable of sort s. Then, for every element d of $|I|^s$ , $I\models G(d^*)$ and

$$\mathit{Pos}({G(d^*)},I)\subseteq \mathit{Pos}({F},I)\subseteq \mathcal{H}.$$

By the induction hypothesis, it follows that $\langle\mathcal{H},I\rangle\models_{ht} G(d^*)$ . We can conclude that $\langle\mathcal{H},I\rangle\models_{ht} \forall X\,G(X)$ . Case 2.6: F is $\exists X\,G(X)$ . Similar to Case 2.5.

The definition of $G^{sp}_{I}(\Gamma)$ in Section 6 is restricted to the case when $\Gamma$ is a completable set of sentences over $\sigma^I$ . It can be generalized to arbitrary sets of sentences as follows. A rule subformula of a formula F is an occurrence of an implication in F that does not belong to the antecedent of any implication (Ferraris et al. Reference Ferraris, Lee and Lifschitz2011, Section 7.3; Lee and Meng Reference Lee and Meng2011, Section 3.3). Let I be an interpretation of an arbitrary signature $\sigma$ , and let $\Gamma$ be a set of sentences over $\sigma^I$ . All vertices of $G^{sp}_{I}(\Gamma)$ are elements of $I^\downarrow$ . The graph has an edge from A to B iff, for some sentence $F_1\to F_2$ obtained from a rule subformula of a member of $\Gamma$ by substituting names $d^*$ for its free variables, $A\in\mathit{Pos}({F_2},I)$ and $B\in\mathit{Pos}({F_1},I)$ .

For any sentence F, $G^{sp}_{I}(F)$ stands for $G^{sp}_{I}(\{F\})$ .

Lemma 2 For any HT-interpretation $\langle\mathcal{H},I \rangle$ , any atom M in $I^\downarrow \setminus \mathcal{H}$ , and any sentence F over $\sigma^I$ , if

  • (i) for every edge (M,B) of $G^{sp}_{I}(F)$ , $B\in \mathcal{H}$ ,

  • (ii) $M\in\mathit{Pos}({F},I)$ , and

  • (iii) $\langle\mathcal{H},I \rangle\models_{ht} F$ , then $\langle I^\downarrow \setminus\{M\},I\rangle\models_{ht} F$ .

Proof By induction on the size of F. Sentence F is neither atomic nor $\bot$ . Indeed, in that case F would be an atomic sentence of the form $p(\mathbf{t})$ , where p is intensional, because, by (ii), $\mathit{Pos}({F},I)$ is non-empty. Then, from (iii), $p((\mathbf{t}^I)^*)\in \mathcal{H}$ . On the other hand, $\mathit{Pos}({F},I)$ is $\{p((\mathbf{t}^I)^*)\}$ , and from (ii) we conclude that $M=p((\mathbf{t}^I)^*)$ . This contradicts the assumption that $M\in I^\downarrow \setminus \mathcal{H} $ . Thus five cases are possible.

Case 1: F is $F_1\land F_2$ . From (iii) we can conclude that $\langle\mathcal{H},I \rangle\models_{ht} F_i$ for $i=1,2$ . It is sufficient to show that $\langle I^\downarrow \setminus\{M\}, I\rangle\models_{ht} F_i$ ; then the conclusion that $\langle I^\downarrow \setminus\{M\}, I\rangle\models_{ht} F$ will follow. Case 1.1: $M\in\mathit{Pos}({F_i},I)$ , so that formula $F_i$ satisfies condition (ii). That formula satisfies condition (i) as well, because $G^{sp}_{I}(F_i)$ is a subgraph of $G^{sp}_{I}(F)$ , and it satisfies condition (iii). So the conclusion $\langle I^\downarrow \setminus\{M\}, I\rangle\models_{ht} F_i$ follows by the induction hypothesis. Case 1.2: $M\not\in\mathit{Pos}({F_i},I)$ . Since $\mathit{Pos}({F_i},I)$ is a subset of $I^\downarrow$ , $\mathit{Pos}({F_i},I)\subseteq I^\downarrow \setminus\{M\}$ . On the other hand, from the fact that $\langle\mathcal{H},I \rangle\models_{ht} F_i$ we conclude, by Proposition 3(a), that $I\models F_i$ . By Lemma 1, it follows that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F_i$ .

Case 2: F is $F_1\lor F_2$ . From (iii) we can conclude that $\langle\mathcal{H},I \rangle\models_{ht} F_i$ for $i=1$ or $i=2$ . It is sufficient to show that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F_i$ ; then the conclusion that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ will follow. The reasoning is the same as in Case 1.

Case 3: F is $F_1\to F_2$ . Then, $ \mathit{Pos}({F},I)=\mathit{Pos}({F_2},I)$ . By (ii), it follows that

(28) \begin{equation}M\in\mathit{Pos}({F_2},I).\end{equation}

On the other hand, F is a rule subformula of itself, so that for every atom B in $\mathit{Pos}({F_1},I)$ , (M,B) is an edge of the graph $G^{sp}_{I}(F)$ . By (i), it follows that every such atom B belongs to $\mathcal{H}$ . Consequently

(29) \begin{equation}\mathit{Pos}({F_1},I)\subseteq \mathcal{H}.\end{equation}

Case 3.1: $\langle\mathcal{H},I \rangle\models_{ht} F_2$ , so that $F_2$ satisfies condition (iii). Since $G^{sp}_{I}(F_2)$ is a subgraph of $G^{sp}_{I}(F)$ , $F_2$ satisfies condition (i) as well. By (28), $F_2$ satisfies condition (ii). Then, by the induction hypothesis, $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F_2$ . Consequently $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ . Case 3.2: $\langle\mathcal{H},I \rangle\not\models_{ht} F_2$ . Then, in view of (iii), $\langle\mathcal{H},I \rangle\not\models_{ht} F_1$ . From this fact and formula (29) we can conclude, by Lemma 1, that $I \not\models F_1$ . By Proposition 3(a), it follows that $\langle I^\downarrow\setminus\{M\},I\rangle\not\models_{ht} F_1$ , which implies $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ .

Case 4: F is $\forall X\,G(X)$ . From (iii) we can conclude that for every d in the domain $|I|^s$ , where s is the sort of X, $\langle\mathcal{H},I \rangle\models_{ht} G(d^*)$ . It is sufficient to show that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} G(d^*)$ ; then the conclusion that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ will follow. Case 4.1: $M\in\mathit{Pos}({G(d^*)},I)$ , so that formula $G(d^*)$ satisfies condition (ii). That formula satisfies condition (i) as well, because $G^{sp}_{I}(G(d^*))$ is a subgraph of $G^{sp}_{I}(F)$ , and it satisfies condition (iii). So the conclusion ${\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} G(d^*)}$ follows by the induction hypothesis. Case 4.2: $M\not\in\mathit{Pos}({G(d^*)},I)$ . Since $\mathit{Pos}({G(d^*)},I)$ is a subset of $I^\downarrow$ , we can conclude that $\mathit{Pos}({G(d^*)},I)\subseteq I^\downarrow \setminus\{M\}$ . On the other hand, from the fact that $\langle\mathcal{H},I \rangle\models_{ht} G(d^*)$ we conclude, by Proposition 3(a), that $I\models G(d^*)$ . By Lemma 1, it follows that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} G(d^*)$ .

Case 5: F is $\exists X\,G(X)$ . From (iii) we can conclude that for some d in the domain $|I|^s$ , where s is the sort of X, $\langle\mathcal{H} ,I\rangle\models_{ht} G(d^*)$ . It is sufficient to show that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} G(d^*)$ ; then the conclusion that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ will follow. The reasoning is the same as in Case 4.

Lemma 3 For any interpretation I of $\sigma$ and any set $\Gamma$ of sentences over $\sigma^I$ such that the graph $G^{sp}_I(\Gamma)$ has no infinite walks, I is a stable model of $\Gamma$ iff I is pointwise stable.

Proof We need to show that if I is a model of $\Gamma$ such that the graph $G^{sp}_{I}(\Gamma)$ has no infinite walks, and there exists a proper subset $\mathcal{H}$ of $I^\downarrow$ such that $\langle\mathcal{H},I\rangle$ satisfies $\Gamma$ , then a subset with this property can be obtained from $I^\downarrow$ by removing a single element.

The set $I^\downarrow \setminus \mathcal{H}$ contains an atom M such that for every edge (M,B) of the graph $G^{sp}_{I}(\Gamma)$ , $B\not\in I^\downarrow \setminus \mathcal{H}$ . Indeed, otherwise this graph would have an infinite walk consisting of elements of $I^\downarrow \setminus \mathcal{H}$ . On the other hand, for every such edge, $B\in I^\downarrow$ . Indeed, from the definition of the graph $G^{sp}_I(\Gamma)$ we see that for every edge (M,B) of that graph, B belongs to the set $\mathit{Pos}({F},I)$ for some sentence F, and that set is contained in $I^\downarrow$ . Consequently for every edge (M,B) of $G^{sp}_{I}(\Gamma)$ , $B\in \mathcal{H}$ .

We will show that $\langle I^\downarrow\setminus\{M\},I\rangle$ satisfies $\Gamma$ . Take a sentence F from $\Gamma$ . Case 1: $M\in\mathit{Pos}({F},I)$ . Then, condition (ii) of Lemma 2 is satisfied for the HT-interpretation $\langle\mathcal{H},I\rangle$ . Condition (i) is satisfied for this HT-interpretation as well, because $G^{sp}_{I}(F)$ is a subgraph of $G^{sp}_{I}(\Gamma)$ ; furthermore, condition (iii) is satisfied because $\langle\mathcal{H},I\rangle$ satisfies $\Gamma$ . Consequently $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ by Lemma 2. Case 2: $M\not\in\mathit{Pos}({F},I)$ . Then, $\mathit{Pos}({F},I)\subseteq I^\downarrow\setminus\{M\}$ . Since $I \models F$ , we can conclude that $\langle I^\downarrow\setminus\{M\},I\rangle\models_{ht} F$ by Lemma 1.

A model I of a set $\Gamma$ of completable sentences over $\sigma$ is supported if for every atom $p(\mathbf{d}^*)$ in $I^\downarrow$ there exists an instance $F\to p(\mathbf{d}^*)$ of a member of $\Gamma$ such that $I \models F$ .

Lemma 4 Every pointwise stable model of a completable set of sentences is supported.

Proof. Let I be a pointwise stable model of a completable set $\Gamma$ of sentences. Take an atom $p(\mathbf{d}^*)$ from $I^\downarrow$ . We need to find an instance $F\to p(\mathbf{d}^*)$ of a completable sentence from $\Gamma$ such that $I\models F$ .

By the definition of a pointwise stable model, $\langle I^\downarrow\setminus\{p(\mathbf{d}^*)\},I\rangle$ does not satisfy $\Gamma$ . Then, one of the completable sentences from $\Gamma$ has an instance $F\to G$ such that

(30) \begin{equation}\hbox{$\langle I^\downarrow\setminus\{p(\mathbf{d}^*)\},I\rangle\not\models_{ht} F\to G$}.\end{equation}

We will show that this instance has the required properties. Since I is a model of $\Gamma$ ,

(31) \begin{equation}I\models F\to G.\end{equation}

From (30) and (31) we conclude that

(32) \begin{equation}\hbox{$\langle I^\downarrow\setminus\{p(\mathbf{d}^*)\},I\rangle\models_{ht} F,$}\end{equation}

and

(33) \begin{equation}\hbox{$\langle I^\downarrow\setminus\{p(\mathbf{d}^*)\},I\rangle\not\models_{ht} G$}.\end{equation}

From (32) and Proposition 3(a), $I\models F$ . Then, in view of (31),

(34) \begin{equation}I\models G.\end{equation}

From (33), (34) and Proposition 3(c) we can conclude that formula Gd contains p, so that it has the form $p(\mathbf{e}^*)$ for some tuple of domain elements $\mathbf{e}$ . Then, from (34), $p(\mathbf{e}^*)\in I^\downarrow$ , and from (33), $p(\mathbf{e}^*)\not\in I^\downarrow \setminus\{p(\mathbf{d}^*)\}$ . Consequently $p(\mathbf{e}^*)$ is $p(\mathbf{d}^*)$ , so that $\mathbf{e}=\mathbf{d}$ .

Lemma 5 For any interpretation I of $\sigma$ and any completable set $\Gamma$ of sentences over $\sigma$ such that the graph $G^{sp}_I(\Gamma)$ has no infinite walks, I is a supported model of $\Gamma$ iff I is stable.

Proof The if part follows from Lemmas 3 and 4. For the only if part, consider a supported model I of a completable set $\Gamma$ of sentences such that the graph $G^{sp}_{I}(\Gamma)$ has no infinite walks; we need to prove that I is stable. According to Lemma 3, it is sufficient to check that I is pointwise stable.

Take any atom M in $I^\downarrow$ ; we will show that $\langle I^\downarrow\setminus\{M\}, I\rangle$ is not an HT-model of $\Gamma$ . Since I is supported, one of the completable sentences in $\Gamma$ has an instance ${F\to M}$ such that ${I\models F}$ . Atom M does not belong to $\mathit{Pos}({F},I)$ , because otherwise $M,M,\dots$ would be an infinite walk in $G^{sp}_{I}(\Gamma)$ . Since the set $\mathit{Pos}({F},I)$ is a subset of $I^\downarrow$ , we can conclude that it is a subset of $I^\downarrow\setminus\{M\}$ . By Lemma 1, it follows that $\langle I^\downarrow\setminus\{M\}, I\rangle\models_{ht} F$ . Therefore $\langle I^\downarrow\setminus\{M\}, I\rangle\not\models_{ht} F\to M$ .

Lemma 6 For any interpretation I of $\sigma$ and any completable set $\Gamma$ sentences over $\sigma$ , I is a supported model of $\Gamma$ iff $I\models\mathrm{COMP}[\Gamma]$ .

Proof Let the sentences defining an intensional predicate symbol p in $\Gamma$ be

(35) \begin{equation}\forall \mathbf{U}_i\mathbf{V}(F_i(\mathbf{U}_i,\mathbf{V})\to p(\mathbf{V}))\qquad ( i=1,\dots,k).\end{equation}

The completed definition of p is

$$\forall {\mathbf{V}}\left(p({\mathbf{V}}) \leftrightarrow \bigvee_{i = 1}^k \exists \mathbf{U}_i \, F_i(\mathbf{U}_i,\mathbf{V})\right).$$

Hence, an interpretation I of $\sigma$ satisfies $\mathrm{COMP}[\Gamma]$ iff the following three conditions hold:

  • (a) for every intensional p, I satisfies the sentence

    $$\forall {\mathbf{V}}\left(p({\mathbf{V}}) \to \bigvee_{i = 1}^k \exists \mathbf{U}_i \, F_i(\mathbf{U}_i,\mathbf{V})\right);$$
  • (b) for every intensional p and for every i, I satisfies the sentence

    (36) \begin{equation}\forall {\mathbf{V}}( \exists \mathbf{U}_i \, F_i(\mathbf{U}_i,\mathbf{V})\to p({\mathbf{V}}));\end{equation}
  • (c) I satisfies all constraints of $\Gamma$ .

Since (36) is equivalent to (35), I is a model of $\Gamma$ if and only if conditions (b) and (c) hold. It remains to check that condition (a) holds if and only if the model I is supported.

Condition (a) can be expressed by saying that

  • for every atom $p(\mathbf{d}^*)$ in $I^\downarrow$ there exists i such that $I\models\exists \mathbf{U}_i \, F_i(\mathbf{U}_i,\mathbf{d}^*),$

or, equivalently, that

  • for every atom $p(\mathbf{d}^*)$ in $I^\downarrow$ there exist i and a tuple $\mathbf{d}_i$ of domain elements

such that $I\models F_i(\mathbf{d}_i^*,\mathbf{d}^*)$ .

Since the members of $\Gamma$ defining p are sentences of form (35), the last condition expresses that I is a supported model of $\Gamma$ .

The assertion of the Main Lemma follows from Lemmas 5 and 6.

8 Proof of Theorem 1

The proof of Theorem 1 refers to infinitary propositional formulas and the strong equivalence relation between them (Harrison et al. Reference Harrison, Lifschitz, Pearce and Valverde2017).

Translations $\tau$ and $\tau^*$ are related by a third translation $F\mapsto F^\mathrm{prop}$ (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019, Section 5), which transforms sentences over $\sigma_0$ into infinitary propositional combinations of precomputed atoms. This translation is defined as follows:

  • if F is $p(t_1,\dotsc,t_n)$ , then $F^\mathrm{prop}$ is obtained from F by replacing each $t_i$ by the value obtained after evaluating all arithmetic functions in $t_i$ ;

  • if F is $t_1 \,\mathit{rel}\, t_2$ , then $F^\mathrm{prop}$ is $\top$ if the values of $t_1$ and $t_2$ are in the relation $\mathit{rel}$ , and $\bot$ otherwise;

  • $\bot^\mathrm{prop}$ is $\bot$ ;

  • $(F \odot G)^\mathrm{prop}$ is $F^\mathrm{prop} \odot G^\mathrm{prop}$ for every binary connective $\odot$ ;

  • $(\forall X\, F(X))^\mathrm{prop}$ is the conjunction of the formulas $F(r)^\mathrm{prop}$ over all precomputed terms r if X is a general variable, and over all numerals r if X is an integer variable;

  • $(\exists X\, F(X))^\mathrm{prop}$ is the disjunction of the formulas $F(r)^\mathrm{prop}$ over all precomputed terms r if X is a general variable, and over all numerals r if X is an integer variable.

This translation is similar to the grounding operation defined by Truszczynski (Reference Truszczynski, Erdem, Lee, Lierler and Pearce2012, Section 2). The following proposition, analogous to Proposition 2 from Truszczynski’s paper and to Proposition 3 by Lifschitz et al. (Reference Lifschitz, Lühne and Schaub2019), relates the meaning of a sentence to the meaning of its propositional translation. It differs from the last result in view of the fact that the division and modulo operations are treated here in a different way (see Section 2.1.2 and Footnote 2), but can be proved in a similar way.

Proposition 2 For any rule R, $(\tau^*R)^\mathrm{prop}$ is strongly equivalent to $\tau R$ .

Since standard interpretations of $\sigma_0$ are semi-Herbrand (Section 6), the correspondence between tuples d of elements of domains of a standard interpretation and tuples ${\bf d}^*$ of their names is one-to-one, and we take the liberty to identify them. Therefore, for a standard interpretation I of $\sigma_0$ , $I^\downarrow$ is identified with the set of precomputed atoms that are satisfied by I. In view of this convention, the transformation $I\mapsto I^\downarrow$ is the inverse of the transformation $\mathcal{J}\mapsto \mathcal{J}^\uparrow$ , defined in Section 2.3: for any set $\mathcal{J}$ of precomputed atoms over $\sigma_0$ ,

(37) \begin{equation}(\mathcal{J}^\uparrow)^\downarrow=\mathcal{J}.\end{equation}

Lemma 7 (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023, Lemma 2(i)) A standard interpretation I of $\sigma_0$ satisfies a sentence F over $\sigma_0$ iff $I^\downarrow$ satisfies $F^\mathrm{prop}$ .

The lemma below relates the meaning of a sentence in the logic of here-and-there to the meaning of its grounding in the infinitary version of that logic (Truszczynski Reference Truszczynski, Erdem, Lee, Lierler and Pearce2012, Section 2). It is similar to Proposition 4 from that paper and can be proved by induction in a similar way.

Lemma 8 A standard HT-interpretation $\langle \mathcal{H},I\rangle$ of $\sigma_0$ satisfies a sentence F over $\sigma_0$ iff $\langle \mathcal{H},I^\downarrow\rangle$ satisfies $F^\mathrm{prop}$ .

The following lemma relates stable models of first-order formulas (as defined in Appendix B) to stable models of infinitary propositional formulas (Truszczynski Reference Truszczynski, Erdem, Lee, Lierler and Pearce2012, Section 2). It is a generalization of Theorem 5 from that paper.

Lemma 9 A standard interpretation I of $\sigma_0$ is a stable model of a set $\Gamma$ of sentences over $\sigma_0$ iff $I^\downarrow$ is a stable model of $\{F^\mathrm{prop}\,:\,F\in\Gamma\}$ .

Proof By Lemma 7, an interpretation I is a model of $\Gamma$ iff $I^\downarrow$ is a model of $\{F^\mathrm{prop}\,:\,F\in\Gamma\}$ . By Lemma 8, for any proper subset $\mathcal{H}$ of $I^\downarrow$ , $\langle\mathcal{H},I\rangle$ satisfies $\Gamma$ iff $\langle\mathcal{H},I^\downarrow\rangle$ satisfies $\{F^\mathrm{prop}\,:\,F\in\Gamma\}$ .

Proof of Theorem 1 For any set $\mathcal{J}$ of precomputed atoms and any mini-gringo program $\Pi$ ,

  • $\mathcal{J}^{\uparrow}$ is a stable model of $\tau^*\Pi$

    iff

  • $(\mathcal{J}^{\uparrow})^{\downarrow}$ is a stable model of $\{ F^\mathrm{ prop} : F \in \tau^*\Pi\}$ (Lemma 9)

    iff

  • $\mathcal{J}$ is a stable model of $\{ F^\mathrm{prop} : F \in \tau^*\Pi\}$ (formula (37))

    iff

  • $\mathcal{J}$ is a stable model of $\{ (\tau^*R)^\mathrm{prop} : R \in\Pi\}$ (definition of $\tau^*\Pi$ )

    iff

  • $\mathcal{J}$ is a stable model of $\{ \tau R : R \in\Pi\}$ (Proposition 2)

    iff

  • $\mathcal{J}$ is a stable model of $\Pi$ (semantics of mini-gringo).

9 Proof of Theorem 2

The equivalence between conditions (b) and (c) in the statement of Theorem 2 follows from the fact that for every sentence F over $\sigma_0$ (first-order or second-order), $\mathcal{P}^\uparrow$ satisfies v(F) iff $\mathcal{P}^v$ satisfies F. The equivalence between conditions (a) and (b) will be derived from the Main Lemma. To this end, we need to relate the positive dependency graph of an io-program to the positive dependency graph of the corresponding completable set of sentences with respect to a standard interpretation of $\sigma_0$ . Such a relationship is described by Lemma 14 below.

Lemma 10 For any tuple $\bf t$ of ground terms in the language of mini-gringo and for any tuple $\bf r$ of precomputed terms of the same length, the formula $\mathit{val}_{{\bf t}}({\bf r})$ is equivalent to $\top$ if ${\bf r} \in [{\bf t}]$ , and to $\bot$ otherwise.

Proof The special case when $\bf t$ is a single term is Lemma 1 by Lifschitz et al. (Reference Lifschitz, Lühne and Schaub2020). The general case easily follows.

The following lemma describes properties of the transformation $\tau^B$ , defined in Section 2.4.

Lemma 11 For any set $\mathcal{J}$ of precomputed atoms and any ground literal L such that $\mathcal{J}^\uparrow \models \tau^B(L)$ ,

  • (a) If L is $p({\bf t})$ or $\textit{not}\ \textit{not}\ p({\bf t})$ then, for some tuple $\bf r$ in $[{\bf t}]$ , $p({\bf r})\in\mathcal{J}$ .

  • (b) If L is $\textit{not}\ p({\bf t})$ then, for some tuple $\bf r$ in $[{\bf t}]$ , $p({\bf r})\not\in\mathcal{J}$ .

Proof Consider the case when L is $p({\bf t})$ . Then, $\tau^B(L)$ is $\exists {\bf V}(\mathit{val}_{{\bf t}}({\bf V}) \land p({\bf V}))$ . Since $\mathcal{J}^\uparrow$ satisfies this formula, there exists a tuple $\bf r$ of precomputed terms such that $\mathcal{J}^\uparrow$ satisfies $\mathit{val}_{{\bf t}}({\bf r})$ and $p({\bf r})$ . Since $\mathit{val}_{{\bf t}}({\bf r})$ is satisfiable, we can conclude by Lemma 10 that ${\bf r}\in[{\bf t}]$ . The other two cases are analogous.

Lemma 12 If $\bf U$ is a tuple of general variables, and $\bf u$ is a tuple of precomputed terms of the same length, then

  • (a) for any term $t({\bf U})$ and any precomputed term r, the result of substituting $\bf u$ for $\bf U$ in $\mathit{val}_{t({\bf U})}(r)$ is $\mathit{val}_{t({\bf u})}(r)$ ;

  • (b) for any conjunction $\mathit{Body}({\bf U})$ of literals and comparisons, the result of substituting $\bf u$ for $\bf U$ in $\tau^B(\mathit{Body}({\bf U}))$ is $\tau^B(\mathit{Body}({\bf u}))$ .

Proof Part (i) is easy to prove by induction. Part (ii) immediately follows.

In the rest of this section, v is a valuation on the set of placeholders of an io-program $\Omega$ , and $\mathcal{J}$ is a set of precomputed atoms that do not contain placeholders of $\Omega$ . Standard interpretations of $\sigma_0$ are semi-Herbrand, and the references to Pos and $G^{sp}$ below refer to the definitions modified as described at the end of Section 6.

Lemma 13 Let $\bf U$ be a list of distinct general variables, and let $p({\bf t}({\bf U})) \leftarrow \mathit{Body}({\bf U})$ be a basic rule of $\Omega$ with all variables explicitly shown. For any tuple $\bf u$ of precomputed terms of the same length as $\bf U$ , any tuple $\bf r$ from $[v({\bf t}({\bf u}))]$ , and any precomputed atom A from $\mathit{Pos}({\tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow)$ , the positive dependency graph of $\Omega$ for the input $(v,\mathcal{J}^{in})$ has an edge from $p({\bf r})$ to A.

Proof We will show that the instance

$$p(v({\bf t}({\bf u}))) \leftarrow v(\mathit{Body}({\bf u})),$$

of the rule

$$p(v({\bf t}({\bf U}))) \leftarrow v(\mathit{Body}({\bf U})),$$

satisfies conditions (a)–(e) imposed on R in the definition of the positive dependency graph of an io-program (see Section 4).

Verification of condition (a): the argument of p in the head of R is $v({\bf t}({\bf u}))$ , and ${\bf r} \in [v({\bf t}({\bf u}))]$ .

Verification of condition (b): since $A\in\mathit{Pos}({\tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow)$ , the body $v(\mathit{Body}({\bf u}))$ of R has a conjunctive term $p'({\bf r}')$ such that

$$A\in\mathit{Pos}({\tau^B(p'({\bf r}'))},\mathcal{J}^\uparrow) =\mathit{Pos}({\exists {\bf V}({\bf r}'={\bf V} \land p'({\bf V}))},\mathcal{J}^\uparrow) =\mathit{Pos}({p'({\bf r}'))},\mathcal{J}^\uparrow)\subseteq\{p'({\bf r}')\}.$$

It follows that $A=p'({\bf r}')$ , so that A is a conjunctive term of the body required by condition (b).

Verification of conditions (c)–(e): let L be a conjunctive term of the body $v(\mathit{Body}({\bf u}))$ of R that contains an input symbol of $\Omega$ or is a comparison. Since $\mathit{Pos}({\tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow)$ is non-empty, $\tau^B(v(\mathit{Body}({\bf u})))$ is satisfied by $\mathcal{J}^\uparrow$ . Therefore, the conjunctive term $\tau^B(L)$ of that formula is satisfied by $\mathcal{J}^\uparrow$ as well. If L has the form $q({\bf t})$ or $\textit{not}\ \textit{not}\ q({\bf t})$ then, by Lemma 11(a), there exists a tuple ${\bf r}'$ in $[{\bf t}]$ such that $q({\bf r}')\in\mathcal{J}$ , and consequently $q({\bf r}')\in\mathcal{J}^{in}$ . If L has the form $\textit{not}\ q({\bf t})$ then, by Lemma 11(b), there exists a tuple ${\bf r}'$ in $[{\bf t}]$ such that $q({\bf r}')\not\in\mathcal{J}$ , and consequently $q({\bf r}')\notin\mathcal{J}^{in}$ . If L is a comparison $t_1\prec t_2$ then $\tau^B(L)$ is

$$\exists V_1 V_2 (\mathit{val}_{t_1}(V_1) \land \mathit{val}_{t_2}(V_2) \land V_1\prec V_2).$$

Since this formula is satisfied by $\mathcal{J}^\uparrow$ , the relation $\prec$ holds for a pair $(r_1,r_2)$ of precomputed terms such that $\mathit{val}_{t_1}(r_1)$ and $\mathit{val}_{t_2}(r_2)$ are satisfied by $\mathcal{J}^\uparrow$ . By Lemma 10, $r_1\in[t_1]$ and $r_2\in[t_2]$ .

Lemma 14 Let $\Pi$ be the set of rules of $\Omega$ .

  • (i) The positive dependency graph of $\Omega$ for the input $(v,\mathcal{J}^{in})$ is a supergraph of the positive dependency graph of $\tau^*(v(\Pi))$ .

  • (ii) If $\Omega$ is locally tight for the input $(v,\mathcal{J}^{in})$ then the graph $G^{sp}_{\mathcal{J}^\uparrow}(\tau^*(v(\Pi)))$ has no infinite walks.

Proof (i) Replacing a choice rule $\{p({\bf t})\}\leftarrow\mathit{Body}$ in $\Omega$ by the basic rule $p({\bf t})\leftarrow\mathit{Body}$ affects neither the positive dependency graph of $\Omega$ nor the positive dependency graph of $\tau^*(v(\Pi))$ . Consequently we can assume, without loss of generality, that $\Omega$ is an io-program without choice rules.

Pick any edge $(p({\bf r}),A)$ of the (modified) graph $G^{sp}_{\mathcal{J}^\uparrow}(\tau^*(v(\Pi)))$ . Then, there is an instance $F\to G$ of the completed sentence obtained by applying $\tau^*$ to a basic rule of $v(\Pi)$ such that $p({\bf r})\in\mathit{Pos}({G},\mathcal{J}^\uparrow)$ and $A\in\mathit{Pos}({F},\mathcal{J}^\uparrow)$ . That rule of $v(\Pi)$ can be written as

(38) \begin{equation} p(v({\bf t}({\bf U})))\leftarrow v(\mathit{Body}({\bf U})), \end{equation}

where

$$ p({\bf t}({\bf U}))\leftarrow \mathit{Body}({\bf U}),$$

is a rule of $\Pi$ , and $\bf U$ is the list of its variables. The result of applying $\tau^*$ to (38) is

$$\forall {\bf U}{\bf V} (\mathit{val}_{v({\bf t}({\bf U}))}({\bf V}) \land \tau^B(v(\mathit{Body}({\bf U}))) \rightarrow p({\bf V})),$$

where $\bf V$ is a tuple of general variables. Let $\bf u$ , $\bf z$ be tuples of precomputed terms that are substituted for $\bf U$ , $\bf V$ in the process of forming the instance $F\to G$ . By Lemma 12, that instance can be written as

$$\mathit{val}_{v({\bf t}({\bf u}))}(\mathbf{v}) \land \tau^B(v(\mathit{Body}({\bf u}))) \rightarrow p(\mathbf{v}).$$

Consequently $p({\bf r})\in\mathit{Pos}({p(\mathbf{v})},\mathcal{J}^\uparrow)$ and

$$A\in\mathit{Pos}({\mathit{val}_{v({\bf t}({\bf u}))}(\mathbf{v}) \land \tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow).$$

The first of these conditions implies $\mathbf{v}={\bf r}$ , so that the second can be rewritten as

(39) \begin{equation} A\in\mathit{Pos}({\mathit{val}_{v({\bf t}({\bf u}))}({\bf r}) \land \tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow).\end{equation}

It follows that $\mathcal{J}^{\uparrow}$ satisfies $\mathit{val}_{v({\bf t}({\bf u}))}({\bf r})$ . By Lemma 10, we can conclude that ${\bf r}\in v({\bf t}({\bf u}))$ . On the other hand, the set $\mathit{Pos}({\mathit{val}_{v({\bf t}({\bf u}))}(\bf r)},\mathcal{J}^\uparrow)$ is empty, because the formula $\mathit{val}_{v({\bf t}({\bf u}))}({\bf r})$ does not contain intensional symbols. Consequently (39) implies that

$$A\in\mathit{Pos}({\tau^B(v(\mathit{Body}({\bf u})))},\mathcal{J}^\uparrow).$$

By Lemma 13, it follows that $(p({\bf r}),A)$ is an edge of the positive dependency graph of $\Omega$ for the input $(v,\mathcal{J}^{in})$ .

(ii) Immediate from part (i).

Now we are ready to prove that condition (a) in the statement of Theorem 2 is equivalent to condition (b). The assumption that $\mathcal{P}$ is an io-model of $\Omega$ for an input $(v,\mathcal{I})$ implies that $\mathcal{P}^{in}=\mathcal{I}$ . Indeed, that assumption means that $\mathcal{P}$ is the set of public atoms of some stable model $\mathcal{J}$ of the program $v(\Pi)\cup\mathcal{I}$ , where $\Pi$ is the set of rules of $\Omega$ . In that program, the facts $\mathcal{I}$ are the only rules containing input symbols in the head, so that $\mathcal{J}^{in}=\mathcal{I}$ . Since all input symbols are public, it follows that $\mathcal{P}^{in}=\mathcal{I}$ . It remains to show that

(40) \begin{equation}\hbox{$\mathcal{P}$ is an io-model of~$\Omega$ for~$(v,\mathcal{P}^{in})$ iff $\mathcal{P}^\uparrow$ satisfies $v(\mathrm{COMP}[\Omega]),$}\end{equation}

under the assumption that $\Omega$ is locally tight for $(v,\mathcal{P}^{in})$ .

Recall that $\mathrm{COMP}[\Omega]$ is the second-order sentence $\exists P_1 \cdots P_l\,C$ , where C is obtained from the sentence $\mathrm{COMP}[\tau^*\Pi]$ by replacing the private symbols $p_1/n_1,\dots,p_l/n_l$ of $\Omega$ with distinct predicate variables $P_1,\dots,P_l$ . Then $v(\mathrm{COMP}[\Omega])$ is $\exists P_1 \cdots P_l\,v(C)$ . Hence, the condition in the right-hand side of (40) means that

$$\begin{array} l\hbox{for some set~$\mathcal{J}$ obtained from~$\mathcal{P}$ by adding private precomputed atoms,}\\\mathcal{J}^\uparrow \hbox{ satisfies } v(\mathrm{COMP}[\tau^*\Pi]).\end{array}$$

Note also that $v(\mathrm{COMP}[\tau^*\Pi]) = \mathrm{COMP}[\tau^*(v(\Pi)]$ . Thus the right-hand side of (40) is equivalent to the condition

(41) \begin{gather} \begin{aligned} &\hbox{for some set~$\mathcal{J}$ obtained from~$\mathcal{P}$ by adding private precomputed atoms,}\\ &\mathcal{J}^\uparrow \hbox{ satisfies } \mathrm{COMP}[\tau^*(v(\Pi))]. \end{aligned} \end{gather}

The condition in the left-hand side of (40) means that $\mathcal{P}$ is the set of public atoms of some stable model of $v(\Pi) \cup \mathcal{P}^{in}$ . By Theorem 1, this condition can be equivalently reformulated as follows:

(42) \begin{gather} \begin{aligned} &\hbox{for some set~$\mathcal{J}$ obtained from~$\mathcal{P}$ by adding private precomputed atoms,}\\ &\hbox{$\mathcal{J}^\uparrow$ is a stable model of $\tau^*(v(\Pi) \cup \mathcal{P}^{in})$.} \end{aligned} \end{gather}

We can further reformulate this condition using the Main Lemma (Section 6) with

  • the signature $\sigma_0$ as $\sigma$ ,

  • all comparison symbols viewed as extensional,

  • $\mathcal{J}^\uparrow$ as I, and

  • $\tau^*(v(\Pi) \cup \mathcal{P}^{in})$ as $\Gamma$ .

The graph $G^{sp}_{\mathcal{J}^\uparrow}(\tau^*(v(\Pi)\cup \mathcal{P}^{in}))$ has no infinite walks, because it is identical to the graph $G^{sp}_{\mathcal{J}^\uparrow}(\tau^*(v(\Pi)))$ , which has no infinite walks by Lemma 14(ii). Consequently (42) – and so the left-hand side of (40) – is equivalent to the condition:

(43) \begin{gather} \begin{aligned} &\hbox{for some set~$\mathcal{J}$ obtained from~$\mathcal{P}$ by adding private precomputed atoms,}\\ &\hbox{$\mathcal{J}^\uparrow$ satisfies $\mathrm{COMP}[\tau^*(v(\Pi)) \cup \mathcal{P}^{in}]$}. \end{aligned} \end{gather}

Therefore, condition (40) is equivalent to the assertion that conditions (41) and (43) are equivalent to each other. So to prove (40), it is enough to show that

(44) \begin{gather} \begin{aligned} &\hbox{for every set~$\mathcal{J}$ obtained from~$\mathcal{P}$ by adding private precomputed atoms,}\\ &\hbox{$\mathcal{J}^\uparrow$ satisfies $\mathrm{COMP}[\tau^*(v(\Pi))]$ iff $\mathcal{J}^\uparrow$ satisfies $\mathrm{COMP}[\tau^*(v(\Pi)) \cup \mathcal{P}^{in}]$}. \end{aligned} \end{gather}

Formula $\mathrm{COMP}[\tau^*(v(\Pi)) \cup \mathcal{P}^{in}]$ is a conjunction that includes the completed definitions of all input symbols among its conjunctive terms. The interpretation $\mathcal{J}^\uparrow$ satisfies these completed definitions, because $\mathcal{J}^{in}=\mathcal{P}^{in}$ . On the other hand, the remaining conjunctive terms of $\mathrm{COMP}[\tau^*(v(\Pi)) \cup \mathcal{P}^{in}]$ form the completion $\mathrm{COMP}[\tau^*(v(\Pi))]$ under the assumption that both comparison symbols and the input symbols are considered extensional. Hence, (44) holds.

10 Proof of Theorem 3

IO-programs $\Omega$ and $\Omega'$ are equivalent to each other under an assumption A iff, for every input $(v,\mathcal{I})$ from the domain defined by A and every set $\mathcal{P}$ of precomputed public atoms,

\begin{gather*} \text{$\mathcal{P}$ is an io-model of~$\Omega$ for~$(v,\mathcal{I})$ iff $\mathcal{P}$ is an io-model of~$\Omega'$ for~$(v,\mathcal{I})$. }\end{gather*}

Since $\Omega$ and $\Omega'$ are locally tight under assumption A, they both are locally tight for input $(v,\mathcal{I})$ . Hence, by Theorem 2, the above condition is equivalent to:

\begin{gather*} \text{ $\mathcal{P}^v$ satisfies~$\mathrm{COMP}[\Omega]$ and~$\mathcal{P}^{\mathit{in}} = \mathcal{I}$ iff $\mathcal{P}^v$ satisfies~$\mathrm{COMP}[\Omega']$ and~$\mathcal{P}^{\mathit{in}} = \mathcal{I}$. }\end{gather*}

We can further rewrite this condition as

\begin{gather*} \text{ $\mathcal{P}^{\mathit{in}} = \mathcal{I}$ implies that $\mathcal{P}^v$ satisfies~$\mathrm{COMP}[\Omega] \leftrightarrow \mathrm{COMP}[\Omega']$. }\end{gather*}

Hence, programs $\Omega$ and $\Omega'$ are equivalent to each other under assumption A iff the condition

(45) \begin{gather} \text{ $\mathcal{P}^v$ satisfies~$\mathrm{COMP}[\Omega] \leftrightarrow \mathrm{COMP}[\Omega'],$ } \end{gather}

holds for every input $(v,\mathcal{I})$ from the domain defined by A and every set $\mathcal{P}$ of precomputed public atoms such that $\mathcal{P}^{\mathit{in}} = \mathcal{I}$ ; equivalently, iff

  • (45) holds for every input $(v,\mathcal{I})$ such that $\mathcal{I}^v$ satisfies A and every set $\mathcal{P}$ of precomputed public atoms such that $\mathcal{P}^{\mathit{in}} = \mathcal{I}$ ;

equivalently, iff

  • (45) holds for every input $(v,\mathcal{I})$ and every set $\mathcal{P}$ of precomputed public atoms such that $\mathcal{P}^{\mathit{in}} = \mathcal{I}$ and $\mathcal{P}^v$ satisfies A;

equivalently, iff

  • (45) holds for every valuation v of PH and every set $\mathcal{P}$ of precomputed public atoms such that $\mathcal{P}^v$ satisfies A;

equivalently, iff for every valuation v of PH and every set $\mathcal{P}$ of precomputed public atoms, $\mathcal{P}^v$ satisfies the sentence

\begin{gather*}A \to (\mathrm{COMP}[\Omega] \leftrightarrow \mathrm{COMP}[\Omega']).\end{gather*}

It remains to observe that an interpretation of $\sigma_0$ is standard for PH iff it can be represented in the form $\mathcal{P}^v$ for some $\mathcal{P}$ and v.

11 Conclusion

In this paper, we defined when an io-program is considered locally tight for an input, and proved two properties of locally tight programs: io-models can be characterized in terms of completion (Theorem 2), and the anthem-p2p algorithm can be used to verify equivalence (Theorem 3). The local tightness condition is satisfied for many nontight programs that describe dynamic domains.

Theorem 2 can be used also to justify using the anthem algorithm (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020) for verifying a locally tight program with respect to a specification expressed by first-order sentences.

Future work will include extending the anthem-p2p algorithm and Theorem 3 to ASP programs that involve aggregate expressions, using the ideas of Fandinno et al. (Reference Fandinno, Hansen and Lierler2022) and Lifschitz (Reference Lifschitz2022).

Appendix A Many-sorted formulas

A many-sorted signature consists of symbols of three kinds – sorts, function constants, and predicate constants. A reflexive and transitive subsort relation is defined on the set of sorts. A tuple $s_1,\dots,s_n$ ( $n\geq 0$ ) of argument sorts is assigned to every function constant and to every predicate constant; in addition, a value sort is assigned to every function constant. Function constants with $n=0$ are called object constants.

We assume that for every sort, an infinite sequence of object variables of that sort is chosen. Terms over a many-sorted signature $\sigma$ are defined recursively:

  • object constants and object variables of a sort s are terms of sort s;

  • if f is a function constant with argument sorts $s_1,\dots,s_n$ ( $n>0$ ) and value sort s, and $t_1,\dots,t_n$ are terms such that the sort of $t_i$ is a subsort of $s_i$ ( $i=1,\dots,n$ ), then $f(t_1,\dots,t_n)$ is a term of sort s.

Atomic formulas over $\sigma$ are

  • expressions of the form $p(t_1,\dots,t_n)$ , where p is a predicate constant and $t_1,\dots,t_n$ are terms such that their sorts are subsorts of the argument sorts $s_1,\dots,s_n$ of p, and

  • expressions of the form $t_1=t_2$ , where $t_1$ and $t_2$ are terms such that their sorts have a common supersort.

First-order formulas over $\sigma$ are formed from atomic formulas and the 0-place connective $\bot$ (falsity) using the binary connectives $\land$ , $\lor$ , $\to$ and the quantifiers $\forall$ , $\exists$ . The other connectives are treated as abbreviations: $\neg F$ stands for $F\to\bot$ and $F\leftrightarrow G$ stands for $(F\to G)\land (G\to F)$ . First-order sentences are first-order formulas without free variables. The universal closure $\widetilde{\forall} F$ of a formula F is the sentence $\forall{\bf X}\,F$ , where $\bf X$ is the list of free variables of F.

An interpretation I of a signature $\sigma$ assigns

  • a non-empty domain $|I|^s$ to every sort s of I, so that $|I|^{s_1}\subseteq |I|^{s_2}$ whenever $s_1$ is a subsort of $s_2$ ,

  • a function $f^I$ from $|I|^{s_1}\times\cdots\times|I|^{s_n}$ to $|I|^s$ to every function constant f with argument sorts $s_1,\dots,s_n$ and value sort s, and

  • a Boolean-valued function $p^I$ on $|I|^{s_1}\times\cdots\times|I|^{s_n}$ to every predicate constant p with argument sorts $s_1,\dots,s_n$ .

If I is an interpretation of a signature $\sigma$ then by $\sigma^I$ we denote the signature obtained from $\sigma$ by adding, for every element d of a domain $|I|^s$ , its name $d^*$ as an object constant of sort s. The interpretation I is extended to $\sigma^I$ by defining $(d^*)^I=d$ . The value $t^I$ assigned by an interpretation I of $\sigma$ to a ground term t over $\sigma^I$ and the satisfaction relation between an interpretation of $\sigma$ and a sentence over $\sigma^I$ are defined recursively, in the usual way. A model of a set $\Gamma$ of sentences is an interpretation that satisfies all members of $\Gamma$ .

If $\mathbf{d}$ is a tuple $d_1,\dots,d_n$ of elements of domains of I then $\mathbf{d}^*$ stands for the tuple $d_1^*,\dots,d_n^*$ of their names. If $\mathbf{t}$ is a tuple $t_1,\dots,t_n$ of ground terms then $\mathbf{t}^I$ stands for the tuple $t_1^I,\dots,t_n^I$ of values assigned to them by I.

Appendix B Stable models of many-sorted theories

The definition of a stable model given below is based on the first-order logic of here-and-there, which was introduced by Pearce and Valverde (Reference Pearce and Valverde2004) and Ferraris et al. (Reference Ferraris, Lee and Lifschitz2011), and then extended to many-sorted formulas (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023).

Consider a many-sorted signature $\sigma$ with its predicate constants partitioned into intensional and extensional. For any interpretation I of $\sigma$ , $I^\downarrow$ stands for the set of atoms of the form $p(\mathbf{d}^*)$ with intensional p that are satisfied by this interpretation.Footnote 8

An HT-interpretation of $\sigma$ is a pair $\langle \mathcal{H},I\rangle$ , where I is an interpretation of $\sigma$ , and $\mathcal{H}$ is a subset of $I^\downarrow$ . (In terms of Kripke models with two sorts, I is the there-world, and $\mathcal{H}$ describes the intensional predicates in the here-world). The satisfaction relation $\models_{ht}$ between HT-interpretation $\langle \mathcal{H}, I\rangle$ of $\sigma$ and a sentence F over $\sigma^I$ is defined recursively as follows:

  • $\langle \mathcal{H}, I\rangle \models_{ht} p(\mathbf{t})$ , where p is intensional, if $p((\mathbf{t}^I)^*)\in \mathcal{H}$ ;

  • $\langle \mathcal{H}, I\rangle \models_{ht} p(\mathbf{t})$ , where p is extensional, if $I \models p(\mathbf{t})$ ;

  • $\langle \mathcal{H}, I\rangle \models_{ht} t_1=t_2$ if $t_1^I=t_2^I$ ;

  • $\langle \mathcal{H}, I\rangle \not\models_{ht}\bot$ ;

  • $\langle \mathcal{H}, I\rangle \models_{ht} F\land G$ if $\langle \mathcal{H}, I\rangle \models_{ht} F$ and $\langle \mathcal{H}, I\rangle \models_{ht} G$ ;

  • $\langle \mathcal{H}, I\rangle \models_{ht} F\lor G$ if $\langle \mathcal{H}, I\rangle \models_{ht} F$ or $\langle \mathcal{H}, I\rangle \models_{ht} G$ ;

  • $\langle \mathcal{H}, I\rangle \models_{ht} F\to G$ if

    1. (i) $\langle \mathcal{H}, I\rangle \not\models_{ht} F$ or $\langle \mathcal{H}, I\rangle \models_{ht} G$ , and

    2. (ii) $I \models F\to G$ ;

  • $\langle \mathcal{H}, I\rangle\models_{ht}\forall X\,F(X)$ if $\langle \mathcal{H}, I\rangle\models_{ht} F(d^*)$ for each $d\in|I|^s$ , where s is the sort of X;

  • $\langle \mathcal{H}, I\rangle\models_{ht}\exists X\,F(X)$ if $\langle \mathcal{H}, I\rangle\models_{ht} F(d^*)$ for some $d\in|I|^s$ , where s is the sort of X.

If $\langle \mathcal{H}, I\rangle \models_{ht} F$ holds, we say that $\langle \mathcal{H}, I\rangle$ satisfies F and that $\langle \mathcal{H}, I\rangle$ is an HT-model of F. If two formulas have the same HT-models then we say that they are HT-equivalent.

In the following proposition, we collected some properties of this satisfaction relation that can be proved by induction.

Proposition 3

  • (a) If $\langle\mathcal{H},I \rangle\models_{ht} F$ then $I \models F$ .

  • (b) For any sentence F that does not contain intensional symbols, $\langle\mathcal{H},I \rangle\models_{ht} F$ iff ${I\models F}$ .

  • (c) For any subset $\mathcal{S}$ of $\mathcal{H}$ such that the predicate symbols of its members do not occur in F, $\langle\mathcal{H} \setminus \mathcal{S}, I\rangle\models_{ht} F$ iff $\langle\mathcal{H}, I\rangle\models_{ht} F$ .

About a model I of a set $\Gamma$ of sentences over $\sigma^I$ we say it is stable if, for every proper subset $\mathcal{H}$ of $I^\downarrow$ , HT-interpretation $\langle \mathcal{H},I \rangle$ does not satisfy $\Gamma$ . In application to finite sets of formulas with a single sort, this definition of a stable model is equivalent to the definition in terms of the operator SM (Ferraris et al. Reference Ferraris, Lee and Lifschitz2011).

We say that I is pointwise stable if, for every element M of $I^\downarrow$ , $\langle I^\downarrow \setminus\{M\},I\rangle$ does not satisfy $\Gamma$ .

Footnotes

*

Many thanks to Yuliya Lierler and to the anonymous referees for their valuable comments.

1 The symbols $/$ and $\backslash$ are not included in this signature because division is not a total function on integers. The symbol $..$ is not included either, because intervals are not meant to be among values of variables of this first-order language.

2 The treatment of division here follows the paper (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023) that corrects a mistake found in previous publications; see Section 2.1.2.

3 In some publications, the result of applying $\tau^*$ to a choice rule (15) is defined as

$$\widetilde{\forall}({\mathit{val}_{\bf t}(\bf V)} \land \tau^B(\mathit{Body}) \rightarrow\neg p({\bf V})\lor\neg p({\bf V})).$$

The difference between this formula and formula (16) is not essential, because the two formulas are satisfied by the same HT-interpretations (see Appendix B).

4 Recall that second-order formulas may contain predicate variables, which can be used to form atomic formulas in the same way as predicate constants, and can be bound by quantifiers in the same way as object variables (Lifschitz et al. Reference Lifschitz, Morgenstern, Plaisted, van Harmelen, Lifschitz and Porter2008, Section 1.2.3). In many-sorted setting, each predicate variable is assigned argument sorts, like a predicate constant (see Appendix A).

5 The definitions of $\mathrm{COMP}[\Omega]$ in other publications do not refer to the translation $\tau^*$ . But they describe formulas that are almost identical to the sentence $\mathrm{COMP}[\Omega]$ defined here, and are equivalent to it in classical second-order logic.

6 The definition in the anthem-p2p paper looks different from the one given here, but the two definitions are equivalent. Instead of the condition “ $\Omega$ and $\Omega'$ have the same io-models” Fandinno et al. require that $\Pi$ and $\Pi'$ have the same external behavior. The external behavior of a mini-gringo program $\Pi$ for a user guide (25) and an input $(v,\mathcal{I})$ can be described as the collection of all sets that can be obtained from io-models of $(\Pi,\textit{PH},\textit{In},\textit{Out})$ by removing the input atoms $\mathcal{I}$ .

7 This is weaker than the condition defining Herbrand interpretations; some ground terms over $\sigma$ may be different from elements of the domains $|I|^s$ .

8 In earlier publications, this set of atoms was denoted by $I^{int}$ . The symbol $I^\downarrow$ is more appropriate, because this operation is opposite to the operation $\mathcal{J}^\uparrow$ , as discussed in Section 8.

References

Clark, K. 1978. Negation as failure. In Logic and Data Bases, H. Gallaire and J. Minker, Eds. Plenum Press, New York, 293–322.Google Scholar
Fages, F. 1994. Consistency of Clark’s completion and existence of stable models. Journal of Methods of Logic in Computer Science 1, 5160.Google Scholar
Fandinno, J., Hansen, Z. and Lierler, Y. 2022. Axiomatization of aggregates in answer set programming. In Proceedings of the AAAI Conference on Artificial Intelligence.CrossRefGoogle Scholar
Fandinno, J., Hansen, Z., Lierler, Y., Lifschitz, V. and Temple, N. 2023. External behavior of a logic program and verification of refactoring. Theory and Practice of Logic Programming.CrossRefGoogle Scholar
Fandinno, J. and Lifschitz, V. 2023. Omega-completeness of the logic of here-and-there and strong equivalence of logic programs. In Proceedings of International Conference on Principles of Knowledge Representation and Reasoning. To appear, URL: https://www.cs.utexas.edu/users/vl/papers/omega.pdf.CrossRefGoogle Scholar
Fandinno, J., Lifschitz, V., Lühne, P. and Schaub, T. 2020. Verifying tight logic programs with Anthem and Vampire. Theory and Practice of Logic Programming 20.CrossRefGoogle Scholar
Ferraris, P. 2005. Answer sets for propositional theories. In Proceedings of International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR), 119–131.Google Scholar
Ferraris, P., Lee, J. and Lifschitz, V. 2011. Stable models and circumscription. Artificial Intelligence 175, 236263.CrossRefGoogle Scholar
Gebser, M., Harrison, A., Kaminski, R., Lifschitz, V. and Schaub, T. 2015. Abstract Gringo. Theory and Practice of Logic Programming 15, 449463.CrossRefGoogle Scholar
Gebser, M., Kaminski, R., Kaufmann, B., Lindauer, M., Ostrowski, M., Romero, J., Schaub, T. and Thiele, S. 2019. Potassco user guide. URL: https://github.com/potassco/guide/releases/.Google Scholar
Gebser, M., Kaufmann, B., Neumann, A. and Schaub, T. 2007. clasp: A conflict-driven answer set solver. In Proceedings of the Ninth International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR’07).Google Scholar
Gebser, M., Schaub, T. and Thiele, S. 2007. Gringo: A new grounder for answer set programming. In Proceedings of the Ninth International Conference on Logic Programming and Nonmonotonic Reasoning, 266–271.Google Scholar
Harrison, A., Lifschitz, V., Pearce, D. and Valverde, A. 2017. Infinitary equilibrium logic and strongly equivalent logic programs. Artificial Intelligence 246, 2233.CrossRefGoogle Scholar
Kovaćs, L. and Voronkov, A. 2013. First-order theorem proving and Vampire. In International Conference on Computer Aided Verification, 1–35.Google Scholar
Lee, J. and Meng, Y. 2011. First-order stable model semantics and first-order loop formulas. Journal of Artificial Inteligence Research (JAIR) 42, 125180.Google Scholar
Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S. and Scarcello, F. 2006. The DLV system for knowledge representation and reasoning. ACM Transactions on Computational Logic 7, 3, 499562.CrossRefGoogle Scholar
Lierler, Y. and Maratea, M. 2004. Cmodels-2: SAT-based answer set solver enhanced to non-tight programs. In Procedings of International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR). 346–350.CrossRefGoogle Scholar
Lifschitz, V. 2019. Answer Set Programming. Springer.CrossRefGoogle Scholar
Lifschitz, V. 2022. Strong equivalence of logic programs with counting. Theory and Practice of Logic Programming 22.CrossRefGoogle Scholar
Lifschitz, V., Lühne, P. and Schaub, T. 2019. Verifying strong equivalence of programs in the input language of gringo. In Proceedings of the 15th International Conference on Logic Programming and Non-monotonic Reasoning.CrossRefGoogle Scholar
Lifschitz, V., Lühne, P. and Schaub, T. 2020. Towards verifying logic programs in the input language of clingo. In Fields of Logic and Computation III, Essays Dedicated to Yuri Gurevich on the Occasion of His 80th Birthday. Springer, 190–209.Google Scholar
Lifschitz, V., Morgenstern, L. and Plaisted, D. 2008. Knowledge representation and classical logic. In Handbook of Knowledge Representation, van Harmelen, F., Lifschitz, V., and Porter, B., Eds. Elsevier, 388.CrossRefGoogle Scholar
Lin, F. and Zhao, Y. 2004. ASSAT: Computing answer sets of a logic program by SAT solvers. Artificial Intelligence 157, 115137.CrossRefGoogle Scholar
Pearce, D. and Valverde, A. 2004. Towards a first order equilibrium logic for nonmonotonic reasoning. In Proceedings of European Conference on Logics in Artificial Intelligence (JELIA), 147–160.Google Scholar
Truszczynski, M. 2012. Connecting first-order ASP and the logic FO(ID) through reducts. In Correct Reasoning: Essays on Logic-Based AI in Honor of Vladimir Lifschitz, Erdem, E., Lee, J., Lierler, Y., and Pearce, D., Eds. Springer, 543559.CrossRefGoogle Scholar