Hostname: page-component-68c7f8b79f-s5tvr Total loading time: 0 Render date: 2026-01-09T12:21:06.423Z Has data issue: false hasContentIssue false

Deductive Systems for Logic Programs with Counting

Published online by Cambridge University Press:  02 January 2026

JORGE FANDINNO
Affiliation:
University of Nebraska Omaha, Omaha, NE, USA (e-mail: jfandinno@unomaha.edu)
VLADIMIR LIFSCHITZ
Affiliation:
University of Texas at Austin, Austin, TX, USA (e-mail: lifschitzv@gmail.com)
Rights & Permissions [Opens in a new window]

Abstract

In answer set programming, two groups of rules are considered strongly equivalent if they have the same meaning in any context. Strong equivalence of two programs can be sometimes established by deriving rules of each program from rules of the other in an appropriate deductive system. This paper shows how to extend this method of proving strong equivalence to programs containing the counting aggregate.

Information

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 (https://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), 2026. Published by Cambridge University Press

1 Introduction

In answer set programming (ASP), two groups of rules are considered strongly equivalent if, informally speaking, they have the same meaning in any context (Lifschitz et al. Reference Lifschitz, Pearce and Vvalverde2001).

If programs $\Pi _1$ and $\Pi _2$ are strongly equivalent then, for any program $\Pi$ , programs $\Pi _1\cup \Pi$ and $\Pi _2\cup \Pi$ have the same stable models. Properties of this equivalence relation are important because they can help us simplify parts of an ASP program without examining its other parts. More generally, they can guide us in the process of developing correct and efficient code.

Strong equivalence of two programs can be sometimes established by deriving rules of each program from rules of the other in an appropriate deductive system. Deriving rules involves rewriting them in the syntax of first-order logic. The possibility of such proofs has been demonstrated for the ASP language mini-gringo (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019; Lifschitz Reference Lifschitz2021; Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a), and it was used in the design of a proof assistant for verifying strong equivalence (Heuer Reference Heuer2020; Fandinno and Lifschitz Reference Fandinno and Lifschitz2023b).

We are interested in extending this method of proving strong equivalence to ASP programs with aggregates, such as counting and summation (Gebser et al. Reference Gebser, Kaminski, Kaufmann, Lindauer, Ostrowski, Romero, Schaub and Thiele2019, Section 3.1.12). Procedures for representing rules with aggregates in the syntax of first-order logic have been proposed in several recent publications (Lifschitz Reference Lifschitz2022; Fandinno et al. Reference Fandinno, Hansen and Lieler2022; Fandinno and Hansen Reference Fandinno and Hansen2025). The first of these papers describes a deductive system that can be used for proving strong equivalence of programs in the language called mini-gringo with counting (mgc). But that system is too weak for reasoning about mgc rules that contain variables in the right-hand side of an aggregate atom. For instance, let $A$ be the pair of rules

\begin{equation*}\begin{array} l p(a),\\[5pt] q(Y) \leftarrow {{\mathit{count}}}\{ X : p(X) \land X \neq a \} = Y, \end{array}\end{equation*}

and let $B$ stand for

\begin{equation*}\begin{array} l p(a),\\[5pt] q(Y-1) \leftarrow {{\mathit{count}}}\{ X : p(X)\} = Y. \end{array}\end{equation*}

These pairs of rules are strongly equivalent to each other, but the deductive system mentioned above would not allow us to justify this claim.

We propose here an alternative set of axioms for proving strong equivalence of programs with counting. After reviewing in Section 2 the language mgc and the translation $\tau ^*$ that transforms mgc rules into first-order sentences, we define in Section 3 a deductive system of here-and-there with counting $({\mathit{HT}_{\!\!\#}})$ . Any two mgc programs $\Pi _1$ and $\Pi _2$ such that $\tau ^*\Pi _1$ and $\tau ^*\Pi _2$ can be derived from each other in this deductive system are strongly equivalent. Furthermore, the sentences $\tau ^*A$ and $\tau ^*B$ , corresponding to the programs $A$ and $B$ above, are equivalent in $\mathit{HT}_{\!\!\#}$ , as well as any two sentences that are equivalent in the deductive system from the previous publication on mgc (Sections 4 and 5).

The system $\mathit{HT}_{\!\!\#}$ is not a first-order theory in the sense of classical logic, because some instances of the law of excluded middle $F\lor \neg F$ are not provable in it. This fact makes it difficult to automate reasoning in $\mathit{HT}_{\!\!\#}$ , because existing work on automated reasoning deals for the most part with classical logic and its extensions. (Pearce et al. Reference Pearce, Tompits and Woltran2001) and (Lin Reference Lin2002) showed how to modify the straightforward representation of propositional rules by formulas in such a way that strong equivalence will correspond to equivalence of formulas in classical logic. Their method was used in the design of a system for verifying strong equivalence of propositional programs (Chen et al. Reference Chen, Lin and Li2005). It was also generalized to strong equivalence of propositional formulas (Pearce et al. Reference Pearce, Tompits and Woltran2009), first-order formulas (Ferraris et al. Reference Ferraris, Lee and Lifschitz2011), and mini-gringo programs (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023b), and it was used in the design of a system for verifying strong equivalence in mini-gringo (Heuer Reference Heuer2020). In Section 6 we show that this method is applicable to programs with counting as well. To this end, we define a classical first-order theory ${\mathit{HT}'_{\!\!\#}}$ and an additional syntactic transformation $\gamma$ such that two sentences $F_1$ , $F_2$ are equivalent in $\mathit{HT}_{\!\!\#}$ if and only if $\gamma F_1$ is equivalent to $\gamma F_2$ in ${\mathit{HT}'_{\!\!\#}}$ . It follows that if the formula $\gamma \tau ^*\Pi _1\leftrightarrow \gamma \tau ^*\Pi _2$ can be derived from the axioms of ${\mathit{HT}'_{\!\!\#}}$ in classical first-order logic then $\Pi _1$ is strongly equivalent to $\Pi _2$ .

Section 7 describes a modificaton ${\mathit{HT}^{\omega}_{\!\!\#}}$ of the deductive system $\mathit{HT}_{\!\!\#}$ that is not only sound for proving strong equivalence, but also complete: any two mgc programs $\Pi _1$ , $\Pi _2$ are strongly equivalent if and only if the formulas $\tau ^*\Pi _1$ and $\tau ^*\Pi _2$ are equivalent in the modified system. This is achieved by including rules with infinitely many premises, similar to the $\omega$ -rule in arithmetic investigated by Leon Henkin (Reference Henkin1954):

\begin{equation*}\frac {F(0)\quad F(1)\quad \ldots }{\forall n F(n)}.\end{equation*}

Deductive systems of this kind are useful as theoretical tools. But derivations in such systems are infinite trees, and they cannot be represented in a finite computational device.

Some additional details of the semantics of mgc are reviewed in Appendix A, and proofs are presented in Appendix B. Some of the proofs refer to the concept of an HT-interpretation, which is reviewed in Appendix B.3. In Appendix B.5, we define a class of standard HT-interpretations, for which the deductive system ${\mathit{HT}^{\omega}_{\!\!\#}}$ is sound and complete.

A preliminary report on this work was presented at the Seventeenth International Conference on Logic Programming and Non-monotonic Reasoning (LPNMR 2024).

2 Background

In this section, we recall the basic definitions about logic programs (Section 2.1), stable models and strong equivalence (Section 2.2), representation of logic programs by first-order formulas (Sections 2.3 and 2.4) and the logic of here-and-there (Section 2.5).

2.1 Programs

The syntax of mini-gringo with counting is defined as follows.Footnote 1 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 of programs, we sometimes drop overlines in numerals.)

The set of precomputed terms is assumed to be a totally ordered set containing numerals, symbolic constants, and possibly other symbols, such that numerals are contiguous (every precomputed term between two numerals is a numeral) and are ordered in the standard way. mgc terms are formed from precomputed terms and variables using the unary operation symbol $|\ |$ and the binary operation symbols:

\begin{equation*}+\quad -\quad \times \quad /\quad \backslash \quad ..\end{equation*}

An mgc atom is a symbolic constant optionally followed by a tuple of terms in parentheses. A literal is a mgc atom possibly preceded by one or two occurrences of not. A comparison is an expression of the form $t_1\prec t_2$ , where $t_1$ , $t_2$ are mini-gringo terms, and $\prec$ is $=$ or one of the comparison symbols:

(1) \begin{equation} \neq \quad \lt \quad \gt \quad \leq \quad \geq \end{equation}

An aggregate element is a pair $\textbf {X}:{\textbf {L}},$ where $\textbf {X}$ is a tuple of distinct variables, and $\textbf {L}$ is a conjunction of literals and comparisons such that every member of $\textbf {X}$ occurs in $\textbf {L}$ . An aggregate atom is an expression of one of the forms

(2) \begin{equation} {{\mathit{count}}} \{E\} \geq t,\ {{\mathit{count}}} \{E\} \leq t,\ \end{equation}

where $E$ is an aggregate element and $t$ is a term that does not contain the interval symbol ( $..$ ). The conjunction of aggregate atoms (2) can be written as ${{\mathit{count}}}\{E\}=t$ .

A rule is an expression of the form

(3) \begin{equation} {\mathit{Head}}\leftarrow {\mathit{Body}}, \end{equation}

where

  • $\mathit{Body}$ is a conjunction (possibly empty) of literals, comparisons, and aggregate atoms, and

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

A variable that occurs in a rule $R$ is local in $R$ if each of its occurrences is within an aggregate element, and global otherwise. A rule is pure if, for every aggregate element $\textbf {X}:\textbf {L}$ in its body, all variables in the tuple $\textbf {X}$ are local. For example, the rule

\begin{equation*} q(Y) \leftarrow {{\mathit{count}}}\{X:p(X)\} = Y \land X\gt 0 \end{equation*}

is not pure, because $X$ is global.

In mini-gringo with counting, a program is a finite set of pure rules.

2.2 Stable models and strong equivalence

An atom $p(\textbf {t})$ is precomputed if all members of the tuple $\textbf {t}$ are precomputed terms. The semantics of mgc is based on an operator, called $\tau$ , which transforms pure rules into infinitary propositional formulas formed from precomputed atoms (Lifschitz Reference Lifschitz2022, Section 5). For example, the rule

\begin{equation*}q \leftarrow {{\mathit{count}}}\{X:p(X)\} \leq 5\end{equation*}

is transformed by $\tau$ into the formula

\begin{equation*}\left ( \bigwedge _{\Delta \,:\,|\Delta | \gt 5}\neg \bigwedge _{x\in \Delta }\;p(x) \right )\to q,\end{equation*}

where $\Delta$ ranges over finite sets of precomputed terms and $|\Delta |$ stands for the cardinality of $\Delta$ . The antecedent of this implication expresses that a set of more than 5 elements cannot be a subset of $\{X:p(X)\}$ . The result of applying $\tau$ to a program $\Pi$ is defined as the conjunction of formulas $\tau R$ for all rules $R$ of $\Pi$ .

Stable models of an mgc program $\Pi$ are defined as stable models of $\tau \Pi$ in the sense of the work by (Truszczynski Reference Truszczynski2012). Thus stable models of programs are sets of precomputed atoms.

About programs $\Pi _1$ and $\Pi _2$ we say that they are strongly equivalent to each other if $\tau \Pi _1$ is strongly equivalent to $\tau \Pi _2$ ; in other words, if for every set $\Phi$ of infinitary propositional formulas formed from precomputed atoms, $\{\tau \Pi _1\}\cup \Phi$ and $\{\tau \Pi _2\}\cup \Phi$ have the same stable models. It is clear that if $\Pi _1$ is strongly equivalent to $\Pi _2$ then, for any program $\Pi$ , $\Pi _1\cup \Pi$ has the same stable models as $\Pi _2\cup \Pi$ (take $\Phi$ to be $\{\tau \Pi \}$ ).

2.3 Representing MGC terms and atoms by formulas

In first-order formulas used to represent programs, we distinguish between terms of two sorts: the sort general and its subsort integer. General variables are meant to range over arbitrary precomputed terms, and we assume them to be the same as variables used in mgc programs. Integer variables are meant to range over numerals (or, equivalently, integers). In this paper, integer variables are represented by letters from the middle of the alphabet ( $I,\ldots ,N$ ).

The two-sorted signature $\sigma _0$ includes

  • all numerals as object constants of the sort integer;

  • other precomputed terms as object constants of the sort general;

  • 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;

  • pairs $p/n$ , where $p$ is a symbolic constant and $n$ is a nonnegative integer, as $n$ -ary predicate constants; their arguments have the sort general;

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

Note that the definition of $\sigma _0$ does not allow terms that contain a general variable in the scope of an arithmetic operation. For example, the mgc term $Y-\overline 1$ is not a term over $\sigma _0$ .

A formula of the form $(p/n)(\textbf {t})$ , where $\textbf {t}$ is a tuple of terms, can be written also as $p(\textbf {t})$ . Thus precomputed atoms can be viewed as sentences over $\sigma _0$ .

The set of values of an mgc termFootnote 2 $t$ can be described by a formula over the signature $\sigma _0$ that contains a variable $Z$ that does not occur in $t$ (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019; Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a). This formula, “ $Z$ is a value of $t$ ,” is denoted by $\textit {val}_{t}(Z)$ . Its definition is recursive, and we reproduce here two of its clauses:

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

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

    \begin{equation*}\exists I J (\textit {val}_{t_1}(I) \land \textit {val}_{t_2}(J) \land Z=I\;\textit {op}\;J),\end{equation*}
    where $I$ and $J$ are integer variables that do not occur in $t$ .

For example, $\textit {val}_{Y-\overline 1}(Z)$ is

\begin{equation*}\exists I J(I=Y \land J=\overline 1\land Z=I-J).\end{equation*}

The translation $\tau ^B$ transforms mgc atoms, literals, and comparisons into formulas over the signature $\sigma _0$ . (The superscript $B$ conveys the idea that this translation expresses the meaning of expressions in bodies of rules). For example, $\tau ^B$ transforms $p(t)$ into the formula $\exists Z(\textit {val}_{t}(Z) \land p(Z))$ . The complete definition of $\tau ^B$ can be found in earlier publications (Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019; Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a) and is reproduced in Appendix A for convenience.

2.4 Representing aggregate expressions and rules

To represent aggregate expressions by first-order formulas, we need to extend the signature $\sigma _0$ (Lifschitz Reference Lifschitz2022, Section 7). The signature $\sigma _1$ is obtained from $\sigma _0$ by adding all predicate constants of the forms

(4) \begin{equation} {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F\hbox{ and }{\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F \end{equation}

where $\textbf {X}$ and $\textbf {V}$ are disjoint lists of distinct general variables, and $F$ is a formula over $\sigma _0$ such that each of its free variables belongs to $\textbf {X}$ or to $\textbf {V}$ . The number of arguments of each constant (4) is the length of $\textbf {V}$ plus 1; all arguments are of the sort general. If $n$ is a positive integer then the formula ${\mathit{Atleast}}^{\textbf {X},\textbf {V}}_F(\textbf {V},\overline n)$ is meant to express that $F$ holds for at least $n$ values of $\textbf {X}$ . The intuitive meaning of ${\mathit{Atmost}}^{\textbf {X},\textbf {V}}_F(\textbf {V},\overline n)$ is similar: $F$ holds for at most $n$ values of $\textbf {X}$ .

For an aggregate atom of the form ${{\mathit{count}}}\{\textbf {X}:\textbf {L}\}\geq t$ in the body of a rule, the corresponding formula over $\sigma _1$ is

\begin{equation*} \exists Z\left (\textit {val}_{t}(Z) \land {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_{\exists \textbf {W}\tau ^B(\textbf {L})}(\textbf {V},Z)\right ), \end{equation*}

where

  • $\textbf {V}$ is the list of global variables that occur in $\textbf {L}$ , and

  • $\textbf {W}$ is the list of local variables that occur in $\textbf {L}$ and are different from the members of $\textbf {X}$ .

For example, the aggregate atom ${{\mathit{count}}}\{ X : p(X)\} \geq Y$ is represented by the formula

\begin{equation*} \exists Z\left (Z=Y\land {\mathit{Atleast}}^{X;}_{\exists Z(Z=X\land p(Z))}(Z)\right ) \end{equation*}

( $\textbf {V}$ and $\textbf {W}$ are empty).

The formula representing ${{\mathit{count}}}\{\textbf {X}:\textbf {L}\}\leq t$ is formed in a similar way, with $\mathit{Atmost}$ in place of $\mathit{Atleast}$ .

Now we are ready to define the translation $\tau ^*$ , which transforms pure rules into sentences over $\sigma _1$ . It converts a basic rule

\begin{equation*}p(t) \leftarrow B_1\land \cdots \land B_n\end{equation*}

into the universal closure of the formula

\begin{equation*}B^*_1\land \cdots \land B^*_n\land \textit {val}_{t}(Z)\to p(Z),\end{equation*}

where $B^*_i$ is

  • $\tau ^B(B_i)$ , if $B_i$ is a literal or comparison, and

  • the formula representation of $B_i$ formed as described above, if $B_i$ is an aggregate atom.

The definition of $\tau ^*$ for pure rules of other forms can be found in the previous paper on mini-gringo with counting (Lifschitz Reference Lifschitz2022, Sections 6 and 8). For any program $\Pi$ , $\tau ^*\Pi$ stands for the conjunction of the sentences $\tau ^*R$ for all rules $R$ of $\Pi$ .

2.5 Logic of here-and-there and standard interpretations

We are interested in deductive systems $S$ with the following property:

(5) \begin{equation} \begin{array} c {for\;any\;programs}\,\Pi _1\; {and}\, \Pi _2,\\[5pt] {if} \; \tau ^*\Pi _1\; {and} \, \tau ^*\Pi _2 \, {can\;be\;derived\;from\;each\;other\;in}\, S\\[5pt] {then} \,\Pi _1\, {is\;strongly\;equivalent\;to}\,\Pi _2. \end{array} \end{equation}

Systems with property (5) cannot possibly sanction unlimited use of classical propositional logic. Consider, for instance, the one-rule programs

\begin{equation*}p \leftarrow {\mathit{not}} q\quad \hbox{and}\quad q \leftarrow {\mathit{not}} p.\end{equation*}

They have different stable models, although the corresponding formulas

\begin{equation*}\neg q\to p\quad \hbox{and}\quad \neg p\to q\end{equation*}

have the same truth table.

This observation suggests that the study of subsystems of classical logic may be relevant. One such subsystem is first-order intuitionistic logic (with equality) adapted to the two-sorted signature $\sigma _1$ . Intuitionistic logic does have property (5). Furthermore, this property is preserved if we extend it by the axiom schema

(6) \begin{equation} F\lor (F\to G) \lor \neg G, \end{equation}

introduced by Hosoi (Reference Hosoi1966) as part of his formalization of the propositional logic known as the logic of here-and-there.

The axiom schema

(7) \begin{equation} \exists X(F\to \forall X\,F) \end{equation}

(for a variable $X$ of either sort) can be included without losing property (5) as well. It was introduced to extend the logic of here-and-there to a language with variables and quantifiers (Lifschitz et al. Reference Lifschitz, Pearce and Valverde2007). Both (6) and (7) are provable classically, but not intuitionistically.

The axioms and inference rules discussed so far are abstract, in the sense that they are not related to any properties of the domains of variables (except that one is a subset of the other). To describe more specific axioms, we need the following definition. An interpretation of the signature $\sigma _0$ is standard if

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

  • its domain of the sort integer is the set of numerals;

  • every object constant represents itself;

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

  • predicate constants (1) are interpreted in accordance with the total order on precomputed terms chosen in the definition of mgc (Section 2.1).

Two standard interpretations of $\sigma _0$ can differ only by how they interpret the predicate symbols $p/n$ . If a sentence over $\sigma _0$ does not contain these symbols then it is either satisfied by all standard interpretations or is not satisfied by any of them.

Let $\mathit{Std}$ be the set of sentences over $\sigma _0$ that do not contain predicate symbols of the form $p/n$ and are satisfied by standard interpretations. Property (5) will be preserved if we add any members of $\mathit{Std}$ to the set of axioms. The set $\mathit{Std}$ includes, for instance, the law of excluded middle $F\lor \neg F$ for every formula $F$ over $\sigma _0$ that does not contain symbols $p/n$ . Other examples of formulas from $\mathit{Std}$ are

\begin{equation*}\overline 2\times \overline 2 = \overline 4,\quad \forall N (N*N\geq \overline 0),\quad t_1\neq t_2, \end{equation*}

where $t_1$ , $t_2$ are distinct precomputed terms.

To reason about mgc programs, we need also axioms for $\mathit{Atleast}$ and $\mathit{Atmost}$ . A possible choice of such additional axioms is described in the next section.

3 Deductive system $\mathit{HT}_{\!\!\#}$

The deductive system $\mathit{HT}_{\!\!\#}$ (“here-and-there with counting”) operates with formulas of the signature $\sigma _2$ , which is obtained from $\sigma _1$ (Section 2.4) by adding the predicate constants ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F$ , where $\textbf {X}$ and $\textbf {V}$ are disjoint lists of distinct general variables, and $F$ is a formula over $\sigma _0$ such that each of its free variables belongs to $\textbf {X}$ or to $\textbf {V}$ . The number of arguments of each of these constants is the combined length of $\textbf {X}$ and $\textbf {V}$ plus 1. The last argument is of the sort integer, and the other arguments are of the sort general.

For any integer $n$ , the formula ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline n)$ is meant to express that if $n\gt 0$ then there exists a lexicographically increasing sequence $\textbf {X}_1,\ldots \textbf {X}_n$ of values satisfying $F$ such that the first of them is $\textbf {X}$ . Two features of the $\mathit{Start}$ predicate make it useful. On the one hand, it can be described by a recursive definition. On the other hand, the predicates $\mathit{Atleast}$ and $\mathit{Atmost}$ can be defined in terms of $\mathit{Start}$ as illustrated by formulas (8) and (9).

3.1 Axioms of $\mathit{HT}_{\!\!\#}$

The axioms for $\mathit{Start}$ define these predicates recursively:

\begin{equation*} \begin{array} l \forall \textbf {X}\textbf {V} N(N\leq \overline 0 \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)),\\[5pt] \forall \textbf {X}\textbf {V} ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 1)\leftrightarrow F),\\[5pt] \forall \textbf {X}\textbf {V} N(N\gt \overline 0 \to ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1) \leftrightarrow \\[5pt] \hskip 4cm F\land \exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N)))). \end{array}\end{equation*}

Here $N$ is an integer variable, and $\textbf {U}$ is a list of distinct general variables of the same length as $\textbf {X}$ , which is disjoint from both $\textbf {X}$ and $\textbf {V}$ . The symbol $\lt$ in the last line denotes lexicographic order: $(X_1,\ldots ,X_m)\lt (U_1,\ldots ,U_m)$ stands for

\begin{equation*} \bigvee _{l=1}^m\left ((X_l\lt U_l) \land \bigwedge _{k=1}^{l-1}(X_k=U_k)\right ). \end{equation*}

This set of axioms for $\mathit{Start}$ will be denoted by $D_0$ .

The set of axioms for $\mathit{Atleast}$ and $\mathit{Atmost}$ , denoted by $D_1$ , defines these predicates in terms of $\mathit{Start}$ :

(8) \begin{align} \forall \textbf {V} Y({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y) &\leftrightarrow \exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\land N\geq Y)), \end{align}
(9) \begin{align} \forall \textbf {V} Y({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y) &\leftrightarrow \forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq Y)). \end{align}

In addition to the axioms listed above, we need the induction schemaFootnote 3

\begin{equation*} F^N_{\overline 0}\land \forall N\left (N\geq \overline 0 \land F \to F^N_{N+\overline 1}\right ) \to \forall N (N\geq \overline 0 \to F) \end{equation*}

for all formulas $F$ over $\sigma _2$ . The set of the universal closures of its instances will be denoted by $\mathit{Ind}$ .

The deductive system $\mathit{HT}_{\!\!\#}$ is defined as first-order intuitionistic logic for the signature $\sigma _2$ extended by

  • axiom schemas (6) and (7) for all formulas $F$ , $G$ , $H$ over $\sigma _2$ , and

  • axioms $\mathit{Std}$ , $\mathit{Ind}$ , $D_0$ , and $D_1$ .

This deductive system has property (5):

Theorem 1. For any programs $\Pi _1$ and $\Pi _2$ , if the formula $\tau ^*\Pi _1\leftrightarrow \tau ^*\Pi _2$ is provable in $\mathit{HT}_{\!\!\#}$ then $\Pi _1$ and $\Pi _2$ are strongly equivalent.

The proof of this theorem can be found in Appendix B.8 (page 57). As discussed in Section 7, $\mathit{HT}_{\!\!\#}$ is an extension of the system with property (5) introduced by Lifschitz (Reference Lifschitz2022). Furthermore, in Section 4 we show that $\mathit{HT}_{\!\!\#}$ is sufficiently strong for proving the equivalence between $\tau ^*A$ and $\tau ^*B$ for the programs $A$ and $B$ from the introduction.

3.2 Some theorems of $\mathit{HT}_{\!\!\#}$

The characterization of $\mathit{Atleast}$ and $\mathit{Atmost}$ given by the axioms $D_1$ can be simplified, if we replace the variable $Y$ by an integer variable:

Proposition 1. The formulas

(10) \begin{equation} \forall \textbf {V} N({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \leftrightarrow \exists \textbf {X}\,{\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)) \end{equation}

and

(11) \begin{equation} \forall \textbf {V} N({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \leftrightarrow \neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N+\overline 1)) \end{equation}

are provable in $\mathit{HT}_{\!\!\#}$ .

A few other theorems of $\mathit{HT}_{\!\!\#}$ :

Proposition 2. The formulas

(12) \begin{align} &\forall \textbf {V} N(N\leq \overline 0\to {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N)), \end{align}
(13) \begin{align} &\forall \textbf {V} ({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline 1) \leftrightarrow \exists \textbf {X}\,F), \end{align}

(14) \begin{align} \forall \textbf {X}(F\to G)\to \forall \textbf {X}\textbf {V} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N)), \end{align}
(15) \begin{align} \forall \textbf {Z}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {Z},\textbf {V},N)\land N\gt \overline 0 \to F^{\textbf {X}}_{\textbf {Z}}) \end{align}

are provable in $\mathit{HT}_{\!\!\#}$ .

An expression of the form ${\mathit{Exactly}}^{\textbf {X};\textbf {V}}_F(\textbf {t},t)$ is shorthand for the conjunction

\begin{equation*}{\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {t},t)\land {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {t},t)\end{equation*}

( $\textbf {t}$ is a tuple of terms, and $t$ is a term). By (11), ${\mathit{Exactly}}^{\textbf {X};\textbf {V}}_F(\textbf {X},N)$ is equivalent in $\mathit{HT}_{\!\!\#}$ to

\begin{equation*}{\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {X},N)\land \neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {X},N+\overline 1).\end{equation*}

Proposition 3. The formulas

(16) \begin{equation} \forall \textbf {X} Y({\mathit{Exactly}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y) \to \exists N(Y=N\land N\geq \overline 0)) \end{equation}

and

(17) \begin{equation} \forall \textbf {X}(F\leftrightarrow G)\to \forall \textbf {X} Y({\mathit{Exactly}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)\leftrightarrow {\mathit{Exactly}}^{\textbf {X};\textbf {V}}_G(\textbf {X},Y)) \end{equation}

are provable in $\mathit{HT}_{\!\!\#}$ .

The proof of these results can be found in Appendix B.1 (page 28).

4 An example of reasoning about programs

In this section, we show that $\tau ^*A$ is equivalent to $\tau ^*B$ , for the programs $A$ and $B$ from the introduction, in the logic of here-and-there with counting, defined in the previous section. The proof consists of three parts.

4.1 Part 1: Simplification

The translation $\tau ^*$ transforms program $A$ into the conjunction of the formulas

(18) \begin{equation} \forall Z(Z=a\to p(Z)) \end{equation}

and

(19) \begin{align} \!\!\!\forall Y\!Z\big (\exists Z_1(Z_1 = Y\! \land {\mathit{Atleast}}^{X;}_F(Z_1)) \land \exists Z_2(Z_2 = Y\! \land {\mathit{Atmost}}^{X;}_F(Z_2)) \land Z = Y \to q(Z)\big ), \end{align}

where $F$ stands for $\tau ^B(p(a)\land X\neq a)$ . Formula (18) is equivalent to $p(a)$ , and (19) is equivalent to

(20) \begin{equation} \forall Y({\mathit{Atleast}}^{X;}_F(Y)\land {\mathit{Atmost}}^{X;}_F(Y)\to q(Y)). \end{equation}

The antecedent of this implication can be written as ${\mathit{Exactly}}^{X;}_F(Y)$ . By (16), it follows that the variable $Y$ can be replaced by the integer variable $N$ . Furthermore, by (17), formula (20) can be further rewritten as

(21) \begin{equation} \forall N({\mathit{Exactly}}^{X;}_{p(a)\land X\neq a}(N)\to q(N)), \end{equation}

because $F$ is equivalent to $p(a)\land X\neq a$ .

The result of applying $\tau ^*$ to $B$ is the conjunction of (18) and

\begin{gather*} \begin{aligned} \forall YZ\big ( &\exists Z_1(Z_1=Y\land {\mathit{Atleast}}^{X;}_G(Z_1))\,\land \qquad \qquad \\ &\exists Z_2(Z_2=Y\land {\mathit{Atmost}}^{X;}_G(Z_2))\,\land \qquad \;\;\\ &\exists IJ(I=Y\land J=\overline 1\land Z=I+J) \to q(Z)\big ), \end{aligned} \end{gather*}

where $G$ stands for $\tau ^B(p(X))$ . This formula can be equivalently rewritten as:

\begin{equation*}\forall I({\mathit{Exactly}}^{X;}_G(I+\overline 1)\to q(I))\end{equation*}

and further as

(22) \begin{equation} \forall I({\mathit{Exactly}}^{X;}_{p(X)}(I+\overline 1)\to q(I)), \end{equation}

because $G$ is equivalent to $p(X)$ .

Thus the claim that $\tau ^*A$ is equivalent to $\tau ^*B$ will be proved if we prove the formula

\begin{equation*} p(a) \to \forall N({\mathit{Exactly}}^{X;}_{p(X)\land X\neq a}(N)\leftrightarrow {\mathit{Exactly}}^{X;}_{p(X)}(N+\overline 1)). \end{equation*}

It is clearly a consequence of the formula

(23) \begin{equation} p(a) \to \forall N({\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)\leftrightarrow {\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1)), \end{equation}

which is proven below.

4.2 Part 2: Three lemmas

Three lemmas will be proved in the next section:

(24) \begin{align} &\forall XN(N\gt \overline 0\land X \gt a\land {\mathit{Start}}^{X;}_{p(X)}(X,N) \to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)), \end{align}
(25) \begin{align} &\forall XN(N\gt \overline 0\land X\neq a\land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)\to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)), \end{align}

and

(26) \begin{equation} \begin{array} r \forall XN(N\gt \overline 0\land X\lt a\land p(a)\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)\to {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)). \end{array} \end{equation}

Using these lemmas, we will now prove (23). Assume $p(a)$ ; our goal is to show that

\begin{equation*} {\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)\leftrightarrow {\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1). \end{equation*}

We consider three cases, according to the axiom

\begin{equation*}\forall N(N\lt \overline 0 \lor N=\overline 0 \lor N\gt \overline 0)\end{equation*}

from $\mathit{Std}$ .

If $N\lt \overline 0$ then both sides of the equivalence are true by (12). If $N=\overline 0$ then the left-hand side is true by (12), and the right-hand side follows from $p(a)$ by (13). Hence, assume that $N\gt \overline 0$ .

Right-to-left: assume ${\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1)$ . By (10), there exists $X$ such that

(27) \begin{equation} {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1). \end{equation}

Case 1: $X=a$ , so that ${\mathit{Start}}^{X;}_{p(X)}(a,N+\overline 1)$ . By $D_0$ ,

\begin{equation*}p(a)\land \exists U(a\lt U\land {\mathit{Start}}^{X;}_{p(X)}(U,N)).\end{equation*}

Take $U$ such that $a\lt U$ and ${\mathit{Start}}^{X;}_{p(X)}(U,N)$ . By (24), it follows that

\begin{equation*}{\mathit{Start}}^{X;}_{p(X)\land X\neq a}(U,N).\end{equation*}

Then ${\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)$ by (10).

Case 2: $X\neq a$ . By (27) and (25),

\begin{equation*}{\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N).\end{equation*}

By (10), it follows that ${\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)$ .

Left-to-right: assume ${\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)$ . Then, for some $X$ ,

(28) \begin{equation} {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N) \end{equation}

by (10), and consequently ${\mathit{Start}}^{X;}_{p(X)}(X,N)$ by (14).

Case 1: $X\gt a$ . Then

\begin{equation*}p(a)\land \exists U(a\lt U\land {\mathit{Start}}^{X;}_{p(X)}(U,N))\end{equation*}

(take $U$ to be $X$ ). By $D_0$ , we can conclude that ${\mathit{Start}}^{X;}_{p(X)}(a,N+\overline 1)$ . Then ${\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1)$ follows by (10).

Case 2: $X\leq a$ . From (28) and (15), $X\neq a$ , so that $X\lt a$ . From (28) and (26), ${\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)$ ; ${\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1)$ follows by (10).

4.3 Part 3: Proofs of the lemmas

Proofs of all three lemmas use induction in the form

(29) \begin{equation} F^N_{\,\overline 1}\land \forall N\left (N\geq \overline 1 \land F \to F^N_{N+\overline 1}\right ) \to \forall N (N\geq \overline 1 \to F), \end{equation}

which follows from $\mathit{Ind}$ and $\mathit{Std}$ .

Proof of (24). We need to show that for all positive $N$ ,

(30) \begin{equation} \forall X(X\gt a \land {\mathit{Start}}^{X;}_{p(X)}(X,N)\to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)). \end{equation}

If $N$ is $\overline 1$ then (30) is equivalent to

\begin{equation*}\forall X(X\gt a \land p(X) \to p(X)\land X\neq a)\end{equation*}

by $D_0$ ; this formula follows from $\mathit{Std}$ . Assume (30) for a positive $N$ ; we need to prove

\begin{equation*}\forall X(X\gt a \land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)\to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N+\overline 1)).\end{equation*}

Assume $X\gt a \land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)$ . From the second conjunctive term,

\begin{equation*} p(X)\land \exists U(X\lt U\land {\mathit{Start}}^{X;}_{p(X)}(U,N)) \end{equation*}

by $D_0$ . Take $U$ such that $X\lt U$ and ${\mathit{Start}}^{X;}_{p(X)}(U,N)$ . Then $U\gt a$ , so that by the induction hypothesis, ${\mathit{Start}}^{X;}_{p(X)\land X\neq a}(U,N)$ . Since $p(X)$ , $X\neq a$ , and $X\lt U$ ,

\begin{equation*}{\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N+\overline 1))\end{equation*}

follows by $D_0$ .

Proof of (25). We need to show that for all positive $N$ ,

(31) \begin{equation} \forall X(X\neq a\land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)\to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)). \end{equation}

To prove this formula for $N$ equal to $\overline 1$ , assume that $X\neq a\land {\mathit{Start}}^{X;}_{p(X)}(X,\overline 2)$ . By (15), the second conjunctive term implies $p(X)$ ; ${\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,\overline 1)$ follows by $D_0$ . Now assume (31) for a positive $N$ ; we need to prove

(32) \begin{equation} \forall X(X\neq a\land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 2)\to {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N+\overline 1)). \end{equation}

Assume $X\neq a\land {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 2)$ . From the second conjunctive term we conclude by $D_0$ that $p(X)$ and, for some $U$ ,

(33) \begin{equation} U\gt X\land {\mathit{Start}}^{X;}_{p(X)}(U,N+\overline 1). \end{equation}

We proceed by cases.

Case 1: $U=a$ , so that ${\mathit{Start}}^{X;}_{p(X)}(a,N+\overline 1)$ . By $D_0$ , it follows that for some $V$ , $V\gt a\land {\mathit{Start}}^{X;}_{p(X)}(V,N)$ . Then, by (24), ${\mathit{Start}}^{X;}_{p(X)\land X\neq a}(V,N)$ . On the other hand, $p(X)\land X\neq a$ and $V\gt a=U\gt X$ ; the consequent of (32) follows by $D_0$ .

Case 2: $U\neq a$ . By the induction hypothesis, from the second conjunctive term of (33) we conclude that ${\mathit{Start}}^{X;}_{p(X)\land X\neq a}(U,N)$ . Since $U\gt X$ and $p(X)\land X\neq a$ , the consequent of (32) follows by $D_0$ .

Proof of (26). We need to show that for all positive $N$ ,

(34) \begin{equation} \forall X(X\lt a \land p(a)\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N)\to {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 1)). \end{equation}

To prove this formula for $N$ equal to $\overline 1$ , assume that

\begin{equation*}X\lt a\land p(a)\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,\overline 1).\end{equation*}

By $D_0$ , the second conjunctive term implies ${\mathit{Start}}^{X;}_{p(X)}(a,\overline 1)$ , and the third term implies $p(X)$ . Hence,

\begin{equation*}p(X)\land \exists U(X\lt U \land {\mathit{Start}}^{X;}_{p(X)}(U,\overline 1))\end{equation*}

(take $U$ to be $a$ ). By $D_0$ , it follows that ${\mathit{Start}}^{X;}_{p(X)}(X,\overline 2)$ . Now assume (34) for a positive $N$ ; we need to prove

\begin{equation*}\forall X(X\lt a\land p(a)\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N+\overline 1)\to {\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 2)).\end{equation*}

Assume $X\lt a\land p(a)\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(X,N+\overline 1)$ . From the last conjunctive term, we conclude by $D_0$ that $p(X)$ , and there exists $U$ such that

(35) \begin{equation} X\lt U\land {\mathit{Start}}^{X;}_{p(X)\land X\neq a}(U,N). \end{equation}

From the second conjunctive term of (35), by (15), $p(U)$ and $U\neq a$ . We proceed by cases.

Case 1: $U\lt a$ . By the induction hypothesis, ${\mathit{Start}}^{X;}_{p(X)}(U,N+\overline 1)$ . Since $p(X)$ and $X\lt U$ , we can conclude by $D_0$ that ${\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 2)$ .

Case 2: $U\gt a$ . By (14), the second conjunctive term of (35) implies ${\mathit{Start}}^{X;}_{p(X)}(U,N)$ . Since $p(a)$ and $a\lt U$ , ${\mathit{Start}}^{X;}_{p(X)}(a,N+\overline 1)$ follows by $D_0$ . Then, since $p(X)$ and $X\lt a$ , ${\mathit{Start}}^{X;}_{p(X)}(X,N+\overline 2)$ follows in a similar way.

5 Comparison with the original formalization

The deductive system from the previous paper on mgc programs (Lifschitz Reference Lifschitz2022) operates with formulas over the signature $\sigma _1$ (that is, $\sigma _2$ without $\mathit{Start}$ predicates). Its definition uses the following notation. If $r$ is a precomputed term, $\textbf {X}$ is a tuple of distinct general variables, and $F$ is a formula over $\sigma _0$ , then the expression $\exists _{\geq r}\textbf {X} F$ stands for

Here $\textbf {X}_1,\ldots ,\textbf {X}_n$ are disjoint tuples of distinct general variables that do not occur in $F$ . The symbols $\top$ and $\bot$ denote the logical constants true, false. The equality between tuples $X_1,X_2,\ldots$ and $Y_1,Y_2,\ldots$ is understood as the conjunction $X_1=Y_1\land X_2=Y_2\land \cdots$ . The three cases in this definition cover all precomputed terms $r$ , because the set of numerals is contiguous (Section 2.1). Similarly, $\exists _{\leq r}\textbf {X} F$ stands for

By $\mathit{Defs}$ we denote the set of all sentences of the forms

(36) \begin{equation} \forall \textbf {V} \left ({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \exists _{\geq r} \textbf {X} F\right ) \end{equation}

and

(37) \begin{equation} \forall \textbf {V} \left ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \exists _{\leq r}\textbf {X} F\right ). \end{equation}

These formulas are similar to the axioms $D_1$ of $\mathit{HT}_{\!\!\#}$ (Section 3.1) in the sense that both $\mathit{Defs}$ and $D_1$ can be viewed as definitions of $\mathit{Atleast}$ and $\mathit{Atmost}$ . But each formula in $\mathit{Defs}$ refers to a specific value $r$ of the last argument of $\mathit{Atleast}$ , $\mathit{Atmost}$ , whereas the last argument of $\mathit{Atleast}$ , $\mathit{Atmost}$ in $D_1$ is a variable. This difference explains why $\mathit{HT}_{\!\!\#}$ may be a better tool for proving strong equivalence than deductive systems with the axioms $\mathit{Defs}$ .

Theorem 2. The formulas $\mathit{Defs}$ are provable in $\mathit{HT}_{\!\!\#}$ .

The proof of this theorem can be found in Appendix B.2 (page 37). The formulas $\mathit{Defs}$ are the only axioms of the deductive system from the previous publication (Lifschitz Reference Lifschitz2022) that are not included in $\mathit{HT}_{\!\!\#}$ . So the theorem above shows that all formulas provable in that system are provable in $\mathit{HT}_{\!\!\#}$ as well.

6 Deductive system ${\mathit{HT}'_{\!\!\#}}$

In this section, we show that combining $\tau ^*$ with an additional syntactic transformation $\gamma$ allows us to replace $\mathit{HT}_{\!\!\#}$ by a classical first-order theory.

The signature $\sigma '_2$ is obtained from the signature $\sigma _2$ (Section 3.1) by adding, for every predicate symbol $p$ other than comparison symbols (1), a new predicate symbol $p'$ of the same arity. The formula $\forall \textbf {X}(p(\textbf {X})\to p'(\textbf {X}))$ , where $\textbf {X}$ is a tuple of distinct general variables, is denoted by ${{\mathcal{A}}}(p)$ . The set of all formulas ${{\mathcal{A}}}(p)$ is denoted by ${\mathcal{A}}$ .

For any formula $F$ over the signature $\sigma _2$ , by $F'$ we denote the formula over $\sigma '_2$ obtained from $F$ by replacing every occurrence of every predicate symbol $p$ other than comparison symbols by $p'$ . The translation $\gamma$ , which relates the logic of here-and-there to classical logic, maps formulas over $\sigma _2$ to formulas over $\sigma '_2$ . It is defined recursively:

  • $\gamma F=F$ if $F$ is atomic,

  • $\gamma (\neg F)=\neg F'$ ,

  • $\gamma (F\land G)=\gamma F \land \gamma G$ ,

  • $\gamma (F\lor G)=\gamma F \lor \gamma G$ ,

  • $\gamma (F\to G)=(\gamma F \to \gamma G)\land (F'\to G')$ ,

  • $\gamma (\forall X\,F)=\forall X\,\gamma F$ ,

  • $\gamma (\exists X\,F)=\exists X\,\gamma F$ .

To apply $\gamma$ to a set of formulas means to apply $\gamma$ to each of its members.

By ${\mathit{HT}'_{\!\!\#}}$ , we denote the classical first-order theory over the signature $\sigma _2'$ with the axioms ${\mathcal{A}}$ , $\gamma ({\mathit{Ind}})$ , $\mathit{Std}$ , $\gamma D_0$ , and $\gamma D_1$ .

Theorem 3. A sentence $F\leftrightarrow G$ over signature $\sigma _2$ is provable in $\mathit{HT}_{\!\!\#}$ iff $\gamma F \leftrightarrow \gamma G$ is provable in ${\mathit{HT}'_{\!\!\#}}$ .

The proof of this theorem can be found in Appendix B.4 (page 47).

Corollary 1. A sentence $F$ over the signature $\sigma _2$ is provable in $\mathit{HT}_{\!\!\#}$ iff $\gamma F$ is provable in ${\mathit{HT}'_{\!\!\#}}$ .

Proof. In Theorem 3, take $G$ to be $\top$ .

From Theorems 1 and 3, we conclude that mgc programs $\Pi _1$ and $\Pi _2$ are strongly equivalent if the formula $\gamma \tau ^*\Pi _1\leftrightarrow \gamma \tau ^*\Pi _2$ is provable in ${\mathit{HT}'_{\!\!\#}}$ .

7 Deductive system ${\mathit{HT}^{\omega}_{\!\!\#}}$

In case of the language mini-gringo, using inference rules with infinitely many premises allows us to define a deductive system that satisfies not only condition (5) but also its converse: programs $\Pi _1$ , $\Pi _2$ are strongly equivalent if and only if $\tau ^*\Pi _1$ and $\tau ^*\Pi _2$ can be derived from each other (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Theorem 6). In this section we define a deductive system with the same property for the language mgc. This system, like the deductive system from the previous publication on mgc (Lifschitz Reference Lifschitz2022), does not require extending the signature $\sigma _1$ .

The system ${\mathit{HT}^{\omega}_{\!\!\#}}$ is an extension of first-order intuitionistic logic formalized as the natural deduction system Int (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Section 5.1) for the signature $\sigma _1$ . Its derivable objects are sequents – expressions $\Gamma \Rightarrow F$ , where $\Gamma$ is a finite set of formulas over $\sigma _1$ (“assumptions”), and $F$ is a formula over $\sigma _1$ . A sequent of the form $\Rightarrow F$ is identified with the formula $F$ . The system ${\mathit{HT}^{\omega}_{\!\!\#}}$ is obtained from Int by adding

  • axiom schemas (6) and (7) for all formulas $F$ , $G$ , $H$ over $\sigma _1$ ,

  • axioms $\mathit{Std}$ and $\mathit{Defs}$ , and

  • the $\omega$ -rules

    (38) \begin{gather} \frac {\Gamma \Rightarrow F^X_t \hbox{ for all precomputed terms}\,t} {\Gamma \Rightarrow \forall X\,F}, \end{gather}
    where $X$ is a general variable, and
    (39) \begin{gather} \frac {\Gamma \Rightarrow F^N_{\overline n} \hbox{ for all integers}\,n} {\Gamma \Rightarrow \forall N\,F}, \end{gather}
    where $N$ is an integer variable.

Induction axioms are not on this list, but the instances of the induction schema $\mathit{Ind}$ for all formulas $F$ over $\sigma _1$ are provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ . Indeed, we can prove in ${\mathit{HT}^{\omega}_{\!\!\#}}$ the sequents

\begin{equation*} F^N_{\overline 0}\land \forall N\left (N\geq \overline 0 \land F \to F^N_{N+\overline 1}\right ) \Rightarrow \overline n\geq \overline 0 \to F \end{equation*}

for all integers $n$ ; then $\mathit{Ind}$ can be derived by the second $\omega$ -rule followed by implication introduction.

Theorem 4. For any mgc programs $\Pi _1$ and $\Pi _2$ , the formula $\tau ^*\Pi _1\leftrightarrow \tau ^*\Pi _2$ is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ iff $\Pi _1$ and $\Pi _2$ are strongly equivalent.

The proof of this theorem can be found in Appendix B.7 (page 55). The system ${\mathit{HT}^{\omega}_{\!\!\#}}$ is not an extension of $\mathit{HT}_{\!\!\#}$ , because its axioms say nothing about the predicate symbols ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F$ . But all theorems of $\mathit{HT}_{\!\!\#}$ that do not contain these symbols are provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ :

Theorem 5. Every sentence over the signature $\sigma _1$ provable in $\mathit{HT}_{\!\!\#}$ is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ .

The proof of this theorem can be found in Appendix B.8 (page 57).

In order to illustrate how ${\mathit{HT}^{\omega}_{\!\!\#}}$ can be used to prove strong equivalence without using the $\mathit{Start}$ predicates, consider the two programs from the introduction. As discussed in Section 4, the strong equivalence of these two programs will be verified if we can prove formula (23), which is equivalent to the conjunction of formulas

(40) \begin{align} \forall N( p(a) \wedge {\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N)\to {\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1)),\end{align}
(41) \begin{align} \forall N( p(a) \wedge {\mathit{Atleast}}^{X;}_{p(X)}(N+\overline 1) \to {\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(N))\end{align}

We can prove (40) using the $\omega$ -rule (39) with infinitely many premises of the form

(42) \begin{gather} p(a) \wedge {\mathit{Atleast}}^{X;}_{p(X)\land X\neq a}(\overline n)\to {\mathit{Atleast}}^{X;}_{p(X)}(\overline n +\overline 1), \end{gather}

one for each integer $n$ . Each of these formulas can be proved in ${\mathit{HT}^{\omega}_{\!\!\#}}$ , without using the $\omega$ -rule. Note that, by (36), the antecedent of (42) entails

\begin{align*} p(a) \wedge \exists X_1\cdots X_n\left (\, p(X_1) \wedge X_1 \neq a \land \dotsc \land p(X_n) \wedge X_n \neq a \land \bigwedge _{i\lt j}\neg (X_i=X_j) \right ) \end{align*}

which entails the consequent of (42). The proof uses the introduction of the existential quantifier rule, introducing the variable $X_{n+1}$ in place of the object constant $a$ , and equivalence (36) again, now with $n+1$ variables $X_1,\dotsc ,X_{n+1}$ . We can similarly prove (41) using the $\omega$ -rule (39) with infinitely many premises obtained by replacing in (41) variable $N$ by numeral $\overline n$ for each integer $n$ .

8 Conclusion

In this paper, we argue that strong equivalence of two programs with counting can be established, in many cases, by proving the equivalence of the corresponding first-order sentences in the deductive system $\mathit{HT}_{\!\!\#}$ . We do not know whether $\mathit{HT}_{\!\!\#}$ is complete for strong equivalence, that is to say, if $\tau ^*\Pi _1\leftrightarrow \tau ^*\Pi _2$ is provable in $\mathit{HT}_{\!\!\#}$ for all pairs $\Pi _1$ , $\Pi _2$ of strongly equivalent mgc programs. But the deductive system ${\mathit{HT}^{\omega}_{\!\!\#}}$ , which contains infinitary rules, is complete in this sense.

Sentences $F_1$ and $F_2$ are equivalent in $\mathit{HT}_{\!\!\#}$ if and only if the sentences $\gamma F_1$ and $\gamma F_2$ are equivalent in the classical first-order theory ${\mathit{HT}'_{\!\!\#}}$ . This fact suggests that it may be possible to use theorem provers for classical theories, such as vampire (Kovaćs and Voronkov Reference Kovaćs and Voronkov2013), to verify strong equivalence of mgc programs. Extending the proof assistant anthem (Fandinno et al. Reference Fandinno, Lifschitz, Lühne and Schaub2020; Heuer Reference Heuer2020) in this direction is a topic for future work.

A translation similar to $\tau ^*$ is used in anthem to verify another kind of equivalence of mini-gringo programs – equivalence with respect to a user guide (Fandinno et al. Reference Fandinno, Hansen, Lieler, Lifschitz and Temple2023; Hansen Reference Hansen2023). We plan to extend work on user guides to programs with counting.

Finally, we would like to investigate the possibility of extending the deductive systems described in this paper to counting aggregates with comparison symbols other that $\geq$ and $\leq$ and to aggregates other than counting (Fandinno and Hansen Reference Fandinno and Hansen2025).

Acknowledgments

We would like to thank the anonymous reviewers for their comments that have helped us to improve the paper. This research is partially supported by NSF CAREER award 2338635. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.

Competing interests

The authors declare none.

Appendix A — Review of the $\tau ^*$ translation

The target language of the translation $\tau ^*$ is a first-order language with signature $\sigma _1$ described in Sections 2.3 and 2.4.

Lifschitz et al. (Reference Lifschitz, Lühne and Schaub2019) defined, for every mini-gringo term $t$ , a formula $\textit {val}_{t}(Z)$ that expresses, informally speaking, that $Z$ is one of the values of $t$ . (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a) further refined this definition by introducing the absolute value and providing an alternative definition for the case of division.Footnote 4 We reproduce here this last definition.

For every mini-gringo term $t$ , a formula $\textit {val}_{t}(Z)$ over the signature $\sigma _0$ is defined, where $Z$ is a general variable that does not occur in $t$ . The definition is recursive:

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

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

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

    \begin{equation*}\exists I J (\textit {val}_{t_1}(I) \land \textit {val}_{t_2}(J) \land Z=I\;\textit {op}\;J),\end{equation*}
  • if $t$ is $t_1\,/\,t_2$ then $\textit {val}_{t}(Z)$ is

    \begin{equation*}\begin{array} l \exists I J K (\textit {val}_{t_1}(I) \land \textit {val}_{t_2}(J) \\[5pt] \hskip 1cm \land \; K\times |J|\leq |I|\lt (K+\overline 1)\times |J|\\[5pt] \hskip 1cm \land \; ((I\times J \geq \overline 0 \land Z=K)\\[5pt] \hskip 1cm \lor \;(I\times J \lt \overline 0 \land Z=-K))), \end{array}\end{equation*}
  • if $t$ is $t_1\backslash t_2$ then $\textit {val}_{t}(Z)$ is

    \begin{equation*}\begin{array} l \exists I J K (\textit {val}_{t_1}(I) \land \textit {val}_{t_2}(J) \\[5pt] \hskip 1cm \land \; K\times |J|\leq |I|\lt (K+\overline 1)\times |J|\\[5pt] \hskip 1cm \land \; ((I\times J \geq \overline 0 \land Z=I-K\times J)\\[5pt] \hskip 1cm \lor \;(I\times J \lt \overline 0 \land Z=I+K\times J))), \end{array}\end{equation*}
  • if $t$ is $t_1\,..\,t_2$ then $\textit {val}_{t}(Z)$ is

    \begin{equation*}\exists I J K (\textit {val}_{t_1}(I) \land \textit {val}_{t_2}(J) \land I\leq K \leq J \land Z=K),\end{equation*}
    where $I$ , $J$ , $K$ are fresh integer variables.

If $\textbf {t}$ is a tuple $t_1,\ldots ,t_n$ of mini-gringo terms, and $\textbf {Z}$ is a tuple $Z_1,\ldots ,Z_n$ of distinct general variables, then $\textit {val}_{\textbf {t}}(\textbf {Z})$ stands for the conjunction $\textit {val}_{t_1}(Z_1) \land \cdots \land \textit {val}_{t_n}(Z_n)$ .

The translation $\tau ^B$ , which transforms literals and comparisons into formulas over the signature $\sigma _0$ , is defined in that paper as follows:Footnote 5

  • $\tau ^B(p(\textbf {t}))= \exists \textbf {Z}(\textit {val}_{\textbf {t}}(\textbf {Z}) \land p(\textbf {Z}))$ ;

  • $\tau ^B({\mathit{not}} p(\textbf {t})) = \exists \textbf {Z}(\textit {val}_{\textbf {t}}(\textbf {Z}) \land \neg p(\textbf {Z}))$ ;

  • $\tau ^B({\mathit{not}} {\mathit{not}}\ p(\textbf {t})) = \exists \textbf {Z}(\textit {val}_{\textbf {t}}(\textbf {Z}) \land \neg \neg p(\textbf {Z}))$ ;

  • $\tau ^B(t_1\prec t_2) = \exists Z_1 Z_2 (\textit {val}_{t_1}(Z_1) \land \textit {val}_{t_2}(Z_2) \land Z_1\prec Z_2)$ ;

Here, $Z_1$ , $Z_2$ , and members of the tuple Z are fresh general variables.

The result of applying $\tau ^*$ to a mini-gringo rule $H \leftarrow B_1\land \cdots \land B_n$ can be defined as the universal closure of the formula:

(A1) \begin{equation} \begin{array}{ll} B^*_1\land \cdots \land B^*_n\land \textit {val}_{\textbf {t}}(\textbf {Z})\to p(\textbf {Z}) &\hbox{ if }H\hbox{ is }p(\textbf {t}),\\[5pt] B^*_1\land \cdots \land B^*_n\land \textit {val}_{\textbf {t}}(\textbf {Z}) \to p(\textbf {Z}) \lor \neg p(\textbf {Z}) &\hbox{ if }H\hbox{ is }p\{(\textbf {t})\},\\[5pt] \neg (B^*_1\land \cdots \land B^*_n) &\hbox{ if $H$ is empty}, \end{array} \end{equation}

where $\textbf {Z}$ is a tuple of fresh general variables, and $B^*_i$ stands for $\tau ^B(B_i)$ if $B_i$ does not include and aggregate element, and for

\begin{equation*} \exists C\left (\textit {val}_{t}(C) \land {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_{\exists \textbf {W}\tau ^B(\textbf {L})}(\textbf {V},C)\right ) \end{equation*}

if $B_i$ is ${{\mathit{count}}}\{\textbf {X}:\textbf {L}\} \geq t$ , and as

\begin{equation*} \exists C\left (\textit {val}_{t}(C) \land {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_{\exists \textbf {W}\tau ^B(\textbf {L})}(\textbf {V},C)\right ) \end{equation*}

if $B_i$ is ${{\mathit{count}}}\{\textbf {X}:\textbf {L}\} \leq t$ , where $C$ is a fresh general variable. Here, $\textbf {V}$ is the list of global variables that occur in $\textbf {L}$ , and $\textbf {W}$ is the list of local variables that occur in $\textbf {L}$ but are not included in $\textbf {X}$ .

Appendix B — Proofs

In this section, we provide the proofs of the results stated in the main body of the paper.

B.1 Proofs of Propositions 1 3

B.1.1 A few more theorems of $\mathit{HT}_{\!\!\#}$

The symbols $\leq$ and $\lt$ between tuples refer to lexicographic order, as in Section 3.1.

Claim: If $\textbf {X}$ , $\textbf {W}$ are disjoint tuples of distinct general variables of the same length, and the variables $\textbf {W}$ are not free in $F$ , then the formula

(B1) \begin{equation} \forall \textbf {X}\textbf {W}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N) \land \textbf {W}\leq \textbf {X} \land F^{\textbf {X}}_{\textbf {W}} \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},N)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. By $D_0$ , if $N\leq \overline 0$ then ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},N)$ ; also, if $N=\overline 1$ then

\begin{equation*}F^{\textbf {X}}_{\textbf {W}} \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},N).\end{equation*}

It remains to prove

(B2) \begin{equation} N\gt \overline 0\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1) \land \textbf {W}\leq \textbf {X} \land F^{\textbf {X}}_{\textbf {W}} \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},N+\overline 1). \end{equation}

(This assertion is justified by the formula

\begin{equation*}\forall N (N\leq \overline 0 \lor N=\overline 1 \lor \exists M(N=M+\overline 1 \land M\gt \overline 0)), \end{equation*}

which belongs to $\mathit{Std}$ .) Assume the antecedent of (B2). From the first two conjunctive terms, by $D_0$ , we can conclude that there exists $\textbf {U}$ such that

\begin{equation*}\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N).\end{equation*}

In combination with the last two conjunctive terms, we get

\begin{equation*}F^{\textbf {X}}_{\textbf {W}} \land \textbf {W}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N).\end{equation*}

Now the consequent of (B2) follows by $D_0$ .

Claim: The formula

(B3) \begin{equation} \forall \textbf {X}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1)\to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. If $N\leq \overline 0$ then the consequent of (B3) follows from $D_0$ . If $N\gt \overline 0$ then, by $D_0$ , the antecedent of (B3) implies

\begin{equation*} F\land \exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N)). \end{equation*}

Thus there exists $\textbf {U}$ such that ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N)\land \textbf {X}\lt \textbf {U}\land F$ . The consequent of (B3) follows by (B1).

Claim: The formula

(B4) \begin{equation} \forall \textbf {X}\textbf {V} MN ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\geq N \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Since $M\geq N$ is equivalent to $\exists K(K\geq \overline 0\land M=N+K)$ , formula (B4) can be rewritten as

\begin{equation*}\forall K(K\geq \overline 0\to \forall \textbf {X}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+K) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N))). \end{equation*}

The proof is by induction $\mathit{Ind}$ . The basis

\begin{equation*}\forall \textbf {X}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 0) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)) \end{equation*}

follows from the $\mathit{Std}$ axiom $\forall N(N+\overline 0=N)$ . The induction hypothesis is

\begin{equation*} K\geq \overline 0\land \forall \textbf {X}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+K) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)); \end{equation*}

we need to derive

\begin{equation*}\forall \textbf {X}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+K+\overline 1) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)). \end{equation*}

Assume ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+K+\overline 1)$ . Then, by (B3), ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+K)$ , and ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)$ follows by the induction hypothesis.

B.1.2 Proof of Proposition 1

Proof of (10). By $D_1$ , the left-hand side of (10) is equivalent to

\begin{equation*}\exists \textbf {X} M({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\geq N).\end{equation*}

From (B4) we can conclude that

\begin{equation*}\exists M ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\geq N)\end{equation*}

is equivalent to ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)$ .

Claim: The formula

(B5) \begin{equation} \forall \textbf {V} N({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \leftrightarrow \neg \exists \textbf {X}\,{\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. By $D_1$ , the left-hand side of (B5) is equivalent to

\begin{equation*}\forall \textbf {X} M({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\to M\leq N)\end{equation*}

and consequently to

\begin{equation*}\neg \exists \textbf {X} M({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\gt N).\end{equation*}

The formula

\begin{equation*}\exists M ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\gt N)\end{equation*}

is equivalent to

\begin{equation*}\exists M ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},M)\land M\geq N+\overline 1)\end{equation*}

and, by (B4), to ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1)$ .

Formula (11) follows from (10) and (B5).

B.1.3 Proof of Proposition 2

Formulas (12) and (13) follow from (10) and $D_0$ .

Claim: Formula (14) is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Assume $\forall \textbf {X}(F\to G)$ . If $N\leq 0$ then ${\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N)$ by $D_0$ . For positive $N$ , the proof is by induction (29). The basis

\begin{equation*} {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 1) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},\overline 1) \end{equation*}

is equivalent to $F\to G$ by $D_0$ . Take a positive $N$ and assume

\begin{equation*}\forall \textbf {X}\textbf {V} ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N)); \end{equation*}

we want to show that

(B6) \begin{equation} \forall \textbf {X}\textbf {V} ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1) \to {\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N+\overline 1)). \end{equation}

Assume ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1)$ . By $D_0$ ,

\begin{equation*}F\land \exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},N)).\end{equation*}

Then $G$ and, by the induction hypothesis,

\begin{equation*}\exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {U},\textbf {V},N)).\end{equation*}

The consequent of (B6) follows by $D_0$ .

Claim: Formula (15) is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Since

\begin{equation*} \forall N( N\gt \overline 0 \to N=\overline 1 \lor \exists M(N=M+\overline 1 \land M\gt \overline 0)) \end{equation*}

(Group $\mathit{Std}$ axiom), it is sufficient to show that

\begin{equation*} \forall \textbf {Z}({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {Z},\textbf {V},\overline 1) \to F^{\textbf {X}}_{\textbf {Z}}) \end{equation*}

and

\begin{equation*}\forall \textbf {Z}\textbf {V} N ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {Z},\textbf {V},N+\overline 1)\land N\gt \overline 0 \to F^{\textbf {X}}_{\textbf {Z}}). \end{equation*}

Both formulas follow from axioms $D_0$ .

B.1.4 Proof of Proposition 3

Proof of (16). Assume ${\mathit{Exactly}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)$ . Then ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)$ . From $D_0$ and $D_1$ , we can conclude that

\begin{equation*}\forall \textbf {V} Y({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y)\to \overline 0\leq Y).\end{equation*}

Hence $\overline 0 \leq Y$ . On the other hand, ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)$ , so that $\exists N(N\geq Y)$ by $D_1$ . Thus, $\exists N(\overline 0\leq Y\leq N)$ . It remains to observe that the formula:

\begin{equation*} \forall Y(\exists N(\overline 0\leq Y\leq N)\leq \exists N(Y=N\land N\geq \overline 0)) \end{equation*}

is a group $\mathit{Std}$ axiom, because the set of numerals is contiguous.

Claim: The formula

(B7) \begin{equation} \forall \textbf {X}(F\to G)\to \forall \textbf {X} Y({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)\to {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_G(\textbf {X},Y)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Assume $\forall \textbf {X}(F\to G)$ and ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)$ . By $D_1$ ,

\begin{equation*}\exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\land N\geq Y).\end{equation*}

Then $\exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N)\land N\geq Y)$ by (14), and ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_G(\textbf {X},Y)$ follows by $D_1$ .

Claim: The formula

(B8) \begin{equation} \forall \textbf {X}(F\to G)\to \forall \textbf {X} Y({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_G(\textbf {X},Y)\to {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Assume $\forall \textbf {X}(F\to G)$ and ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_G(\textbf {X},Y)$ . By $D_1$ ,

\begin{equation*}\forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_G(\textbf {X},\textbf {V},N)\to N\leq Y)).\end{equation*}

Then $\forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq Y))$ by (14), and ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {X},Y)$ follows by $D_1$ .

Formula (17) follows from (B7) and (B8).

B.2 Proof of Theorem 2

B.2.1 A few more theorems of $\mathit{HT}_{\!\!\#}$ , continued

Claim: Let $F$ be a formula over $\sigma _0$ , let $\textbf {U}$ , $\textbf {W}$ are disjoint tuples of distinct general variables of the same length such that the variables $\textbf {W}$ are not free in $F$ , and let $n$ is a positive integer. The formula

(B9) \begin{equation} \exists _{\geq \overline {n+1}}\textbf {U}\,F \leftrightarrow \exists \textbf {U}(F\land \exists _{\geq \overline n}\textbf {W}(\textbf {U}\lt \textbf {W} \land F^{\textbf {U}}_{\textbf {W}})) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. Left-to-right: take $\textbf {U}_1,\ldots ,\textbf {U}_{n+1}$ such that

(B10) \begin{equation} \bigwedge _{i=1}^{n+1} F^{\textbf {U}}_{\,\textbf {U}_i} \land \bigwedge _{i\lt j}\neg (\textbf {U}_i=\textbf {U}_j). \end{equation}

We reason by cases, using the axiom

\begin{equation*}\bigvee _{k=1}^{n+1}\bigwedge _{i=1}^{n+1}\textbf {U}_k\leq \textbf {U}_i\end{equation*}

from $\mathit{Std}$ (“for some $k$ , $\textbf {U}_k$ is lexicographically first among $\textbf {U}_1,\ldots ,\textbf {U}_{n+1}$ ”). Consider the $k$ -th case $\bigwedge _{i=1}^{n+1}\textbf {U}_k\leq \textbf {U}_i$ . From (B10),

\begin{equation*}\textbf {U}_k\lt \textbf {U}_i\hbox{ and }F^{\textbf {U}}_{\textbf {U}_i} \qquad (i=1,\ldots ,n+1;\ i\neq k)\end{equation*}

and

\begin{equation*}\neg (\textbf {U}_i=\textbf {U}_j)\qquad (1\leq i\lt j\leq n+1;\ i,j\neq k).\end{equation*}

Hence, $\exists _{\geq \overline n} \textbf {W}(\textbf {U}_k\lt \textbf {W}\land F^{\textbf {U}}_{\,\textbf {W}})$ . Since $F^{\textbf {U}}_{\,\textbf {U}_k}$ , it follows that

\begin{equation*}\exists \textbf {U}(F\land \exists _{\geq \overline n}\textbf {W}(\textbf {U}\lt \textbf {W} \land F^{\textbf {U}}_{\textbf {W}})).\end{equation*}

Right-to-left: assume

\begin{equation*} \exists \textbf {U}\left (F\land \exists \textbf {W}_1\cdots \textbf {W}_n\left (\,\bigwedge _{i=1}^n (\textbf {U}\lt \textbf {W}_i\land F^{\textbf {U}}_{\,\textbf {W}_i}) \land \bigwedge _{i\lt j}\neg (\textbf {W}_i=\textbf {W}_j) \right )\right ). \end{equation*}

This formula is equivalent to

\begin{equation*} \exists \textbf {U}\textbf {W}_1\cdots \textbf {W}_n\left (F\land \bigwedge _{i=1}^n (\textbf {U}\lt \textbf {W}_i\land F^{\textbf {U}}_{\,\textbf {W}_i}) \land \bigwedge _{i\lt j}\neg (\textbf {W}_i=\textbf {W}_j) \right ) \end{equation*}

and can be rewritten as:

\begin{equation*} \exists \textbf {W}_0\textbf {W}_1\cdots \textbf {W}_n\left (F^{\textbf {U}}_{\,\textbf {W}_0}\land \bigwedge _{i=1}^n (\textbf {W}_0\lt \textbf {W}_i\land F^{\textbf {U}}_{\,\textbf {W}_i}) \land \bigwedge _{1\leq i\lt j\leq n}\neg (\textbf {W}_i=\textbf {W}_j) \right ). \end{equation*}

It implies

\begin{equation*} \exists \textbf {W}_0\textbf {W}_1\cdots \textbf {W}_n\left (\bigwedge _{i=0}^n F^{\textbf {U}}_{\,\textbf {W}_i} \land \bigwedge _{0\leq i\lt j\leq n}\neg (\textbf {W}_i=\textbf {W}_j) \right ), \end{equation*}

which is equivalent to $\exists _{\geq \overline {n+1}}\textbf {U}\,F$ .

Claim: If $\textbf {X}$ , $\textbf {U}$ are disjoint tuples of distinct general variables of the same length, the variables $\textbf {U}$ are not free in $F$ , and $n\gt 0$ , then the sentence

(B11) \begin{equation} \forall \textbf {X}\textbf {V}( \exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},\overline n)) \leftrightarrow \exists _{\geq \overline n}\textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}})) \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. By induction on $n$ . If $n=1$ then ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},\overline n)$ in the left-hand side of (B11) is equivalent to $F^{\textbf {X}}_{\textbf {U}}$ by $D_0$ , and the right-hand side of (B11) is equivalent to $\exists \textbf {U}(\textbf {X}\lt \textbf {U}\land F^{\textbf {X}}_{\textbf {U}})$ . Induction step: we will show that the formula

(B12) \begin{equation} \forall \textbf {X}\textbf {V} (\exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},\overline {n+1})) \leftrightarrow \exists _{\geq \overline {n+1}}\textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}})) \end{equation}

is derivable from (B11) in $\mathit{HT}_{\!\!\#}$ . By (B9), the right-hand side of (B12) is equivalent to

(B13) \begin{equation} \exists \textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}}\land \exists _{\geq \overline n}\textbf {W}(\textbf {U}\lt \textbf {W} \land \textbf {X}\lt \textbf {W}\land F^{\textbf {X}}_{\textbf {W}})). \end{equation}

In the presence of $\textbf {X}\lt \textbf {U}$ , the subformula $\textbf {U}\lt \textbf {W} \land \textbf {X}\lt \textbf {W}$ is equivalent to $\textbf {U}\lt \textbf {W}$ . Hence (B13) is equivalent to

(B14) \begin{equation} \exists \textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}}\land \exists _{\geq \overline n}\textbf {W}(\textbf {U}\lt \textbf {W} \land F^{\textbf {X}}_{\textbf {W}})). \end{equation}

On the other hand, (B11) can be rewritten as:

\begin{equation*} \forall \textbf {X}\textbf {V}( \exists \textbf {W}(\textbf {X}\lt \textbf {W}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},\overline n)) \leftrightarrow \exists _{\geq \overline n}\textbf {W}(\textbf {X}\lt \textbf {W} \land F^{\textbf {X}}_{\textbf {W}})), \end{equation*}

and it implies

\begin{equation*} \exists \textbf {W}(\textbf {U}\lt \textbf {W}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},\overline n)) \leftrightarrow \exists _{\geq \overline n}\textbf {W}(\textbf {U}\lt \textbf {W} \land F^{\textbf {X}}_{\textbf {W}}). \end{equation*}

It follows that (B14) is equivalent to

\begin{equation*} \exists \textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}}\land \exists \textbf {W}(\textbf {U}\lt \textbf {W}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {W},\textbf {V},\overline n))). \end{equation*}

By $D_0$ , this formula is equivalent to the left-hand side of (B12).

Claim: If $\textbf {U}$ is a tuple of distinct general variables of the same length as $\textbf {X}$ such that its members do not belong to $\textbf {X}$ and are not free in $F$ then the sentence

(B15) \begin{gather} \forall \textbf {V}( \exists \textbf {U} {\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {U},\textbf {V}, \overline n) \leftrightarrow \exists _{\geq \overline n} \textbf {U} \, F^{\textbf {X}}_{\textbf {U}}) \end{gather}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof. The following is one of the axioms of $\mathit{Std}$ :

\begin{equation*} \overline n \leq \overline 0 \,\vee \, \overline n = \overline 1 \,\vee \, \overline n \gt \overline 1. \end{equation*}

Case 1: $\overline n \leq \overline 0$ . The right-hand side of (B15) is $\top$ and its left-hand side follows from $D_0$ . Case 2: $\overline n = \overline 1$ . The right-hand side of (B15) is $\exists \textbf {X}_1 F^{\textbf {X}}_{\textbf {X}_1}$ and (B15) is immediate from $D_0$ . Case 3: $\overline n\gt \overline 1$ . The left-hand side of (B15) is equivalent to

\begin{equation*} \exists \textbf {X}(F\land \exists \textbf {U}(\textbf {X}\lt \textbf {U}\land {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {U},\textbf {V},\overline {n-1}))) \end{equation*}

by $D_0$ , and the right-hand side is equivalent to

\begin{equation*}\exists \textbf {X}(F\land \exists _{\geq \overline {n-1}}\textbf {U}(\textbf {X}\lt \textbf {U} \land F^{\textbf {X}}_{\textbf {U}}))\end{equation*}

by (B9). These two formulas are equivalent to each other by (B11).

Claim: For any formula $F$ over $\sigma _0$ and any nonnegative integer $n$ , the formula

(B16) \begin{equation} \exists _{\leq \overline n}\textbf {X}\,F\leftrightarrow \neg \exists _{\geq \overline {n+1}}\textbf {X}\,F. \end{equation}

is provable in $\mathit{HT}_{\!\!\#}$ .

Proof.

\begin{equation*}\begin{array}{rcl} \neg \exists _{\geq \overline {n+1}}\textbf {X}\,&F &=\neg \exists \textbf {X}_1\cdots \textbf {X}_{n+1}\left (\bigwedge _{i=1}^{n+1} F^{\textbf {X}}_{\,\textbf {X}_i}\land \,\bigwedge _{i\lt j}\neg (\textbf {X}_i=\textbf {X}_j)\right )\\[5pt] & \leftrightarrow &\forall \textbf {X}_1\cdots \textbf {X}_{n+1}\neg \left (\bigwedge _{i=1}^{n+1} F^{\textbf {X}}_{\,\textbf {X}_i}\land \,\bigwedge _{i\lt j}\neg (\textbf {X}_i=\textbf {X}_j)\right )\\[5pt] &\leftrightarrow &\forall \textbf {X}_1\cdots \textbf {X}_{n+1}\left (\bigwedge _{i=1}^{n+1} F^{\textbf {X}}_{\,\textbf {X}_i}\to \neg \,\bigwedge _{i\lt j}\neg (\textbf {X}_i=\textbf {X}_j)\right ) \\ &\leftrightarrow &\forall \textbf {X}_1\cdots \textbf {X}_{n+1}\left (\bigwedge _{i=1}^{n+1} F^{\textbf {X}}_{\,\textbf {X}_i}\to \,\bigvee _{i\lt j}\textbf {X}_i=\textbf {X}_j\right )\\[5pt] &=&\exists _{\leq \overline n}\textbf {X}\,F. \end{array}\end{equation*}

B.2.2 Proof of Theorem 2, part 1

We will show now that for every precomputed term $r$ , sentence (36) is provable in $\mathit{HT}_{\!\!\#}$ .

Case 1: $r\leq \overline 0$ ; (36) is

(B17) \begin{equation} \forall \textbf {V} \left ({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \top \right ). \end{equation}

From $D_1$ ,

\begin{equation*} \forall \textbf {V} \textbf {X} ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 0) \land \overline 0\geq r \to {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)). \end{equation*}

The conjunctive term ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 0)$ follows from $D_0$ , and second conjunctive term $\overline 0\geq r$ is an axiom of $\mathit{Std}$ . Consequently ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)$ , which is equivalent to (B17).

Case 2: for all $n$ , $r\gt \overline n$ ; (36) is

(B18) \begin{equation} \forall \textbf {V} \left ({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \bot \right ). \end{equation}

Assume ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)$ . From $D_1$ ,

\begin{equation*} \forall \textbf {V} ({\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r) \to \exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\land N\geq r)). \end{equation*}

Consequently $\exists N(N\geq r)$ , which contradicts the $\mathit{Std}$ axiom $\forall N\neg (N\geq r)$ .

Case 3: for some $n$ , $\overline 0 \lt r \leq \overline n$ . Since the set of numerals is contiguous, $r$ is a numeral $\overline m$ ( $m\gt 0$ ). By (10), formula (36) can be rewritten as

\begin{equation*} \forall \textbf {V} \left (\exists \textbf {X}\,{\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline m)\leftrightarrow \exists _{\geq \overline m} \textbf {X} F\right ), \end{equation*}

which is the universal closure of (B15).

B.2.3 Proof of Theorem 2, part 2

We will show now that for every precomputed term $r$ , sentence (37) is provable in $\mathit{HT}_{\!\!\#}$ .

Case 1: $r\lt \overline 0$ ; (37) is

(B19) \begin{equation} \forall \textbf {V} \left ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \bot \right ). \end{equation}

From $D_1$ ,

\begin{equation*} {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r) \to \forall \textbf {X} ({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 0)\to \overline 0\leq r). \end{equation*}

By $D_0$ , ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},\overline 0)$ , so that

\begin{equation*} {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r) \to \overline 0\leq r. \end{equation*}

From the $\mathit{Std}$ axiom $\neg (\overline 0\leq r)$ we conclude that $\neg {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)$ , which is equivalent to (B19).

Case 2: for all $n$ , $r\gt \overline n$ ; (37) is

(B20) \begin{equation} \forall \textbf {V} \left ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\leftrightarrow \top \right ). \end{equation}

From $D_1$ ,

\begin{equation*} \forall \textbf {V} (\forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq r) \to {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)). \end{equation*}

The antecedent $\forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq r)$ follows from the $\mathit{Std}$ axiom $\forall N(N\leq r)$ . Hence ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)$ , which is equivalent to (B20).

Case 3: for some $n$ , $\overline 0 \leq r \leq \overline n$ . Since the set of numerals is contiguous $r$ is a numeral $\overline m$ ( $m\geq 0$ ), so that (37) is

\begin{equation*}\forall \textbf {V} \left ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline m)\leftrightarrow \exists _{\leq \overline m}\textbf {X} F\right ).\end{equation*}

By (11) and (B16), this formula is equivalent to

\begin{equation*}\forall \textbf {V} \left (\neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline {m+1})\leftrightarrow \neg \exists _{\geq \overline {m+1}}\textbf {X} F\right ),\end{equation*}

which follows from (36).

B.3 Review: HT-interpretations

A propositional HT-interpretation is a pair ${\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }$ , where $\mathcal{Y}$ is a set of propositional atoms, and $\mathcal{X}$ is a subset of $\mathcal{Y}$ . In terms of Kripke models with two worlds, $\mathcal{X}$ is the here-world and $\mathcal{Y}$ is the there-world. The recursive definition of the satisfaction relation between HT-interpretations and propositional formulas can be extended to infinitary propositional formulas (Truszczynski Reference Truszczynski2012, Definition 2). Equilibrium models of a set of formulas (Pearce Reference Pearce1997, Reference Pearce1999) are defined as its HT-models satisfying a certain minimality condition. A set $\mathcal{X}$ of atoms is a stable model of a set of infinitary propositional formulas iff ${\left \langle {\mathcal{X}},{\mathcal{X}}\right \rangle }$ is an equlibrium model of that set (Truszczynski Reference Truszczynski2012, Theorem 3). Thus stable models of an mgc program $\Pi$ can be characterized as sets $\mathcal{X}$ such that ${\left \langle {\mathcal{X}},{\mathcal{X}}\right \rangle }$ is an equilibrium model of $\tau \Pi$ .

The definition of a many-sorted HT-interpretation (Fandinno et al. Reference Fandinno, Lifschitz and Temple2024, Appendices A and B) extends this construction to many-sorted first-order languages. In classical semantics of first-order formulas, the recursive definition of the satisfaction relation between an interpretation $I$ of a signature $\sigma$ and a sentence $F$ over $\sigma$ involves extending $\sigma$ by new object constants $d^*$ , which represent elements $d$ of the domain of $I$ (Lifschitz et al. Reference Lifschitz, Morgenstern and Plaisted2008, Section 1.2.2). The extended signature is denoted by $\sigma ^I$ . In the definition of a many-sorted HT-interpretation, the predicate symbols of $\sigma$ are assumed to be partitioned into extensional and intensional. For any interpretation $I$ of such a signature $\sigma$ , $I^\downarrow$ stands for the set of all atomic sentences over $\sigma ^I$ that have the form $p(\mathbf{d}^*)$ , where $p$ is intensional, $\mathbf{d}$ is a tuple of elements of appropriate domains of $\sigma$ , and $I\models p(\mathbf{d}^*)$ . An HT-interpretation of a many-sorted signature $\sigma$ is a pair ${\left \langle {\mathcal{H}},I\right \rangle }$ , where $I$ is an interpretation of $\sigma$ , and $\mathcal{H}$ is a subset of $I^\downarrow$ . In terms of Kripke models, $I$ is the there-world, and $\mathcal{H}$ describes the intensional predicates in the here-world.

The satisfaction relation between HT-interpretations and sentences is denoted by $\models _{ht}$ , to distinguish it from classical satisfaction. According to the persistence property of this relation, ${{\left \langle {\mathcal{H}},I\right \rangle }}\models _{ht} F$ implies $I\models F$ for every sentence $F$ over $\sigma$ (Fandinno et al. Reference Fandinno, Lifschitz and Temple2024, Proposition 3a).

The soundness and completeness theorem for the many-sorted logic of here-and-there (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Theorem 2) can be stated as follows:

For any set $\Gamma$ of sentences over a many-sorted signature $\sigma$ and any sentence $F$ over $\sigma$ , the following two conditions are equivalent:

  1. (i) every HT-interpretation of $\sigma$ satisfying $\Gamma$ satisfies $F$ ;

  2. (ii) $F$ can be derived from $\Gamma$ in first-order intuitionistic logic extended by

    1. axiom schemas (6) and (7) for all formulas $F$ and $G$ over $\sigma$ ;

    2. the axioms

      (B21) \begin{equation} X=Y\lor X\neq Y, \end{equation}
      where $X$ and $Y$ are variables of the same sort;
    3. the axioms

      (B22) \begin{equation} p(\textbf {X})\lor \neg p(\textbf {X}), \end{equation}
      where $p$ is an extensional predicate symbol and $\textbf {X}$ is a tuple of distinct variables of appropriate sorts.

The deductive system described in clause (ii) is denoted by ${\mathit{SQHT}}^=$ (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Section 5.1).

B.4 Proof of Theorem 3

In the special case of the signature $\sigma _2$ (Section 3.1), we designate comparison symbols (1) as extensional, and all other predicate symbols (i.e.,, $p/n$ , ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F$ , ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F$ , and ${\mathit{Start}}^{\textbf {X};\textbf {V}}_F$ ) as intensional. This convention allows us to generalize some of the definitions from Section 6 to arbitrary many-sorted signatures with predicate constants classified into extensional and intensional. For any such signature $\sigma$ , by $\sigma '$ we denote the signature obtained from it by adding, for every intensional constant $p$ , a new predicate constant $p'$ of the same arity. The formula

(B23) \begin{equation} \forall \textbf {X}(p(\textbf {X})\to p'(\textbf {X})), \end{equation}

where $p$ is intensional and $\textbf {X}$ is a tuple of distinct variables of appropriate sorts, is denoted by ${{\mathcal{A}}}(p)$ , and ${\mathcal{A}}$ stands for the set of these formulas for all intensional predicate constants $p$ . For any formula $F$ over the signature $\sigma$ , by $F'$ we denote the formula over $\sigma '$ obtained from $F$ by replacing every occurrence of every intensional predicate symbol $p$ by $p'$ . Then the transformation $\gamma$ is defined as in Section 6.

For any HT-interpretation $\langle {\mathcal{H}},I\rangle$ of $\sigma$ , $I^{\mathcal{H}}$ stands for the interpretation of $\sigma '$ that has the same domains as $I$ , interprets function constants and extensional predicate constants of $\sigma$ in the same way as $I$ , and interprets the other predicate constants $p$ , $p'$ as follows:

(B24) \begin{equation} \begin{array} l I^{\mathcal{H}}\models p(\textbf {d}^*)\hbox{ iff }p(\textbf {d}^*)\in {\mathcal{H}};\\[5pt] I^{\mathcal{H}}\models p'(\textbf {d}^*)\hbox{ iff }I\models p(\textbf {d}^*). \end{array} \end{equation}

From the second line of (B24) we can derive a more general assertion:

(B25) \begin{equation} I^{\mathcal{H}}\models p'(\mathbf{t})\hbox{ iff }I\models p(\mathbf{t}) \end{equation}

for every tuple $\mathbf{t}$ of ground terms over the signature $\sigma ^I$ . Indeed, the value assigned to $\mathbf{t}$ by the interpretation $I^{\mathcal{H}}$ (symbolically, $\mathbf{t}^{I^{\mathcal{H}}}$ ) is the same as the value $\mathbf{t}^I$ , assigned to $\mathbf{t}$ by $I$ , because $I^{\mathcal{H}}$ and $I$ interpret all symbols occurring in $\mathbf{t}$ in the same way. In the second line of (B24), take $\mathbf{d}$ to be the common value of $\mathbf{t}^{I^{\mathcal{H}}}$ and $\mathbf{t}^I$ . Then

\begin{equation*}I^{\mathcal{H}}\models p'\left (\left (\mathbf{t}^{I^{\mathcal{H}}}\right )^*\right ) \hbox{ iff }I\models p\left (\left ({\mathbf{t}^I}\right )^*\right ),\end{equation*}

which is equivalent to (B25).

Lemma 1. An interpretation of the signature $\sigma '$ satisfies ${\mathcal{A}}$ iff it can be represented in the form $I^{\mathcal{H}}$ for some HT-interpretation $\langle {\mathcal{H}},I\rangle$ .

Proof. For the if-part, take any formula (B23) from ${\mathcal{A}}$ . We need to show that $I^{\mathcal{H}}$ satisfies all sentences of the form $p(\mathbf{d}^*)\to p'(\mathbf{d}^*)$ . Assume that $I^{\mathcal{H}}\models p(\mathbf{d}^*)$ . Then $p(\mathbf{d}^*)\in {\mathcal{H}}\subseteq I^\downarrow$ , and consequently $I\models p(\mathbf{d}^*)$ , which is equivalent to $I^{\mathcal{H}}\models p'(\mathbf{d}^*)$ .

For the only-if part, take any interpretation $J$ of $\sigma '$ that satisfies ${\mathcal{A}}$ . Let $I$ be the interpretation of $\sigma$ that has the same domains as $J$ , interprets function constants and extensional predicate constants in the same way as $J$ , and interprets every intensional $p$ in accordance with the condition

(B26) \begin{equation} I\models p(\textbf {d}^*)\hbox{ iff }J\models p'(\textbf {d}^*). \end{equation}

Take $\mathcal{H}$ to be the set of all atoms of the form $p(\mathbf{d}^*)$ with intensional $p$ that are satisfied by $J$ . Since $J$ satisfies ${\mathcal{A}}$ , $J$ satisfies $p'(\mathbf{d}^*)$ for every atom $p(\mathbf{d}^*)$ from $\mathcal{H}$ . By (B26), it follows that all atoms from $\mathcal{H}$ are satisfied by $I$ , so that $\mathcal{H}$ is a subset of $I^\downarrow$ . It follows that $\langle {\mathcal{H}},I\rangle$ is an HT-interpretation. Let us show that $I^{\mathcal{H}}=J$ . Each of the interpretations $I^{\mathcal{H}}$ and $J$ has the same domains as $I$ and interprets all function constants and extensional predicate constants in the same way as $I$ . For every intensional $p$ and any tuple $\mathbf{d}$ of elements of appropriate domains, each of the conditions $I^{\mathcal{H}}\models p(\mathbf{d}^*)$ , $J\models p(\mathbf{d}^*)$ is equivalent to $p(\mathbf{d}^*)\in {\mathcal{H}}$ , and each of the conditions $I^{\mathcal{H}}\models p'(\mathbf{d}^*)$ , $J\models p'(\mathbf{d}^*)$ is equivalent to $I\models p(\mathbf{d}^*)$ .

Lemma 2. For every HT-interpretation $\langle {\mathcal{H}},I\rangle$ of $\sigma$ and every sentence $F$ over the signature $\sigma ^I$ , $I^{\mathcal{H}}\models F'$ iff $I\models F$ .

Proof. We will consider the case when $F$ is a ground atom $p(\mathbf{t})$ ; extension to arbitrary sentences by induction is straightforward. If $p$ is intensional then $F'$ is $p'(\mathbf{t})$ , so that the assertion of the lemma turns into property (B25). If $p$ is extensional then $F'$ is $p(\mathbf{t})$ ; $I^{\mathcal{H}}\models p(\mathbf{t})$ iff $I\models p(\mathbf{t})$ because $I^{\mathcal{H}}$ interprets all symbols occurring in $F$ in the same way as $I$ .

Lemma 3. For every HT-interpretation $\langle {\mathcal{H}},I\rangle$ of $\sigma$ and every sentence $F$ over the signature $\sigma ^I$ , $I^{\mathcal{H}}\models \gamma F$ iff ${\langle {\mathcal{H}},I\rangle }\models _{ht} F$ .

Proof. The proof is by induction on the number of propositional connectives and quantifiers in $F$ . We consider below the more difficult cases when $F$ is an atomic formula, a negation, or an implication.

Case 1: $F$ is an atomic formula $p(\mathbf{t})$ . Then $\gamma F$ is $p(\mathbf{t})$ too; we need to check that

(B27) \begin{equation} I^{\mathcal{H}}\models p(\mathbf{t})\hbox{ iff }{\langle {\mathcal{H}},I\rangle }\models _{ht} p(\mathbf{t}). \end{equation}

Case 1.1: $p$ is intensional. Let $\mathbf{d}$ be the common value of $\mathbf{t}^{I^{\mathcal{H}}}$ and $\mathbf{t}^I$ . The left-hand side of (B27) is equivalent to $I^{\mathcal{H}}\models p(\mathbf{d}^*)$ and consequently to $p(\mathbf{d}^*)\in {\mathcal{H}}$ . The right-hand side of (B27) is equivalent to $p\left (\left (\mathbf{t}^I\right )^*\right )\in {\mathcal{H}}$ , which is equivalent to $p(\mathbf{d}^*)\in {\mathcal{H}}$ as well.

Case 1.2: $p$ is extensional. Each of the conditions $I^{\mathcal{H}}\models p(\mathbf{t})$ , ${\langle {\mathcal{H}},I\rangle }\models _{ht} p(\mathbf{t})$ is equivalent to $I\models p(\mathbf{t})$ .

Case 2: $F$ is $\neg G$ . Then $\gamma F$ is $\neg G'$ ; we need to check that

\begin{equation*} I^{\mathcal{H}}\not \models G\hbox{ iff }{\langle {\mathcal{H}},I\rangle }\models _{ht}\neg G'. \end{equation*}

By Lemma 2, the left-hand side is equivalent to $I\not \models G'$ . By the definition of $\models _{ht}$ , the right-hand side is equivalent to $I\not \models G'$ as well.

Case 3: $F$ is $G \to H$ . Then $\gamma F$ is $(\gamma G \to \gamma H) \land (G' \to H')$ , so that the condition $I^{\mathcal{H}}\models \gamma F$ holds iff

(B28) \begin{equation} I^{\mathcal{H}}\not \models \gamma G\hbox{ or }I^{\mathcal{H}}\models \gamma H \end{equation}

and

(B29) \begin{equation} I^{\mathcal{H}}\models G'\to H'. \end{equation}

By the induction hypothesis, (B28) is equivalent to

(B30) \begin{equation} {\langle {\mathcal{H}},I\rangle }\not \models _{ht} G\hbox{ or }{\langle {\mathcal{H}},I\rangle }\models _{ht} H. \end{equation}

By Lemma 2, (B29) is equivalent to

(B31) \begin{equation} I\models G\to H. \end{equation}

The conjunction of (B30) and (B31) is equivalent to ${\langle {\mathcal{H}},I\rangle }\models _{ht} G\to H$ .

Proof of Theorem 3 . To prove a formula in $\mathit{HT}_{\!\!\#}$ means to derive it in first-order intuitionistic logic from (6), (7), $\mathit{Std}$ , $\mathit{Ind}$ , $D_0$ , and $D_1$ . Since the universal closures of (B21) and (B22) belong to $\mathit{Std}$ , it follows that a formula is provable in $\mathit{HT}_{\!\!\#}$ iff it can be derived from $\mathit{Std}$ , $\mathit{Ind}$ , $D_0$ , and $D_1$ in ${\mathit{SQHT}}^=$ . Consequently $F\leftrightarrow G$ is provable in $\mathit{HT}_{\!\!\#}$ iff

(B32) \begin{equation} G\,\text{can be derived in} \, {\mathit{SQHT}}^=\, \text{from} {\mathit{Std}}, {\mathit{Ind}}, \,D_0, D_1\, \text{and}\,F \end{equation}

and

(B33) \begin{equation} F \,\text{can be derived in} \,{\mathit{SQHT}}^= \text{from}\, {\mathit{Std}}, {\mathit{Ind}}, D_0, D_1\, \text{and}\,G. \end{equation}

By the soundness and completeness theorem quoted in Appendix B.3, (B32) is equivalent to the condition

\begin{equation*}\begin{array} c G \,\text{is satisfied by every HT-interpretation of} \,\sigma _2\\[5pt] \text{that satisfies}\, {\mathit{Std}}, {\mathit{Ind}}, \,D_0, D_1\, and\,F. \end{array}\end{equation*}

By Lemma 3, this condition can be further reformulated as follows:

\begin{equation*}\begin{array} c {for every HT-interpretation\,{\langle {\mathcal{H}},I\rangle } \,of\,\sigma _2, I^{\mathcal{H}}\, satisfies \,\gamma G}\\[5pt] {if\,I^{\mathcal{H}}\, satisfies\,\gamma ({\mathit{Ind}}), \gamma ({\mathit{Std}}), \gamma D_0,\,\gamma D_1 \,\textrm{and}\,\gamma F.} \end{array}\end{equation*}

Then, by Lemma 1, (B32) is equivalent to the condition

\begin{equation*}\begin{array} c {\gamma G\, \text{is satisfied by every interpretation of}\,\sigma _2'}\\[5pt] \text{that satisfies} \,{{\mathcal{A}}}, \,\gamma ({\mathit{Ind}}), \gamma ({\mathit{Std}}), \gamma D_0, \gamma D_1\, \text{and}\; \gamma F. \end{array}\end{equation*}

Similarly, (B33) is equivalent to the condition

\begin{equation*}\begin{array} c {\gamma F\, \text{is satisfied by every interpretation of}\,\sigma _2'}\\[5pt] \text{that satisfies} {{\mathcal{A}}}, \gamma ({\mathit{Ind}}), \gamma ({\mathit{Std}}), \gamma D_0, \,\gamma D_1 \;\text{and}\; \gamma G. \end{array}\end{equation*}

Consequently $F\leftrightarrow G$ is provable in $\mathit{HT}_{\!\!\#}$ iff

\begin{equation*}\begin{array} c {\gamma F\leftrightarrow \gamma G\, \text{is satisfied by every interpretation of}\,\sigma _2'}\\[5pt] \text{that satisfies} \,{{\mathcal{A}}}, \gamma ({\mathit{Ind}}), \gamma ({\mathit{Std}}), \gamma D_0, \text{and}\,\gamma D_1. \end{array}\end{equation*}

Since all predicate constants occurring in $\mathit{Std}$ are comparisons, $\gamma ({\mathit{Std}})$ is equivalent to $\mathit{Std}$ , so that $\gamma ({\mathit{Std}})$ here can be replaced by $\mathit{Std}$ . It remains to observe that ${\mathcal{A}}$ , $\gamma ({\mathit{Ind}})$ , $\mathit{Std}$ , $\gamma D_0$ , and $\gamma D_1$ is the list of all axioms of ${\mathit{HT}'_{\!\!\#}}$ .

B.5 Standard HT-interpretations

In preparation for the proof of Theorem 4, we describe here the class of standard HT-interpretations of the signature $\sigma _1$ and prove the soundness and completeness of ${\mathit{HT}^{\omega}_{\!\!\#}}$ with respect to standard HT-interpretations.

An interpretation of $\sigma _1$ is standard if its restriction to $\sigma _0$ is standard (see Section 2.5) and it satisfies $\mathit{Defs}$ . For every set $\mathcal{X}$ of precomputed atoms, ${\mathcal{X}}^\uparrow$ stands for the standard interpretation of $\sigma _1$ defined by the following conditions:

  1. (a) a precomputed atom is satisfied by ${\mathcal{X}}^\uparrow$ iff it belongs to $\mathcal{X}$ ;

  2. (b) an extended precomputed atom ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ is satisfied by ${\mathcal{X}}^\uparrow$ iff

    \begin{equation*}{\mathcal{X}}^\uparrow \models \left (\exists _{\geq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}};\end{equation*}
  3. (c) an extended precomputed atom ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ is satisfied by ${\mathcal{X}}^\uparrow$ iff

    \begin{equation*}{\mathcal{X}}^\uparrow \models \left (\exists _{\leq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}.\end{equation*}

The operation ${\mathcal{X}}\mapsto {\mathcal{X}}^\uparrow$ is opposite to the operation $I\mapsto I^\downarrow$ defined in Appendix B.3, in the sense that

  • for any standard interpretation $I$ of $\sigma _1$ , $(I^\downarrow )^\uparrow =I$ , and

  • for any set $\mathcal{X}$ of precomputed atoms, the set of precomputed atoms in $({\mathcal{X}}^\uparrow )^\downarrow$ is $\mathcal{X}$ .

This construction is extended to HT-interpretations as follows. An HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ of $\sigma _1$ is standard if the restriction of $I$ to $\sigma _0$ is standard and ${\left \langle {\mathcal{H}},I\right \rangle }$ satisfies $\mathit{Defs}$ . For any standard HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ , $I$ satisfies $\mathit{Defs}$ by the persistence property of HT-interpretations (Appendix B.3), so that $I$ is standard as well. For any pair $\mathcal{X}$ , $\mathcal{Y}$ of sets of precomputed atoms such that ${\mathcal{X}}\subseteq \mathcal{Y}$ , the pair ${\left \langle {\mathcal{X}},\mathcal{Y}^\uparrow \right \rangle }$ is an HT-interpretation of $\sigma _1$ , because ${\mathcal{X}}\subseteq \mathcal{Y} \subseteq (\mathcal{Y}^\uparrow )^\downarrow$ . We define extended precomputed atoms as atomic formulas $p(\textbf {t})$ over the signature $\sigma _1$ such that $p$ is intensional, and $\textbf {t}$ is a tuple of precomputed terms. Let $\mathcal{H}$ be the superset of $\mathcal{X}$ obtained from it by adding all extended precomputed atoms ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ such that

\begin{equation*}{{\left \langle {\mathcal{X}},\mathcal{Y}^\uparrow \right \rangle }}\models _{ht} \left (\exists _{\geq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}\end{equation*}

and all extended precomputed atoms ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ such that

\begin{equation*}{{\left \langle {\mathcal{X}},\mathcal{Y}^\uparrow \right \rangle }}\models _{ht} \left (\exists _{\leq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}.\end{equation*}

For every atom ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ in $\mathcal{H}$ ,

\begin{equation*}\mathcal{Y}^\uparrow \models \left (\exists _{\geq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}\end{equation*}

by persistence. Consequently every such atom belongs to $(\mathcal{Y}^\uparrow )^\downarrow$ . Similarly, every atom ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ in $\mathcal{H}$ belongs to $(\mathcal{Y}^\uparrow )^\downarrow$ as well. It follows that ${\left \langle {\mathcal{H}},\mathcal{Y}^\uparrow \right \rangle }$ is an HT-interpretation of $\sigma _1$ . We denote this HT-interpretation by ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ .

This HT-interpretation is standard. Indeed, a precomputed atom of the form ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ belongs to $\mathcal{H}$ iff the formula $\left (\exists _{\geq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}$ is satisfied by ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ , because this HT-interpretation interprets sentences over the signature $\sigma _0$ in the same way as ${\left \langle {\mathcal{X}},\mathcal{Y}^\uparrow \right \rangle }$ . Similarly, ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {v},r)$ belongs to $\mathcal{H}$ iff the formula $\left (\exists _{\leq r} \textbf {X} F\right )^{\textbf {V}}_{\textbf {v}}$ is satisfied by ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ . It follows that ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ satisfies $\mathit{Defs}$ .

Conversely, every standard HT-interpretation of $\sigma _1$ can be represented in the form ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ . Indeed, for any standard HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ of $\sigma _1$ , take $\mathcal{X}$ to be the set of precomputed atoms in $\mathcal{H}$ , and take $\mathcal{Y}$ to be $I^\downarrow$ . Then

\begin{equation*}{\mathcal{X}}\subseteq {\mathcal{H}}\subseteq I^\downarrow =\mathcal{Y}\end{equation*}

and

\begin{equation*}{{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow ={{\left \langle {\mathcal{H}},\mathcal{Y}^\uparrow \right \rangle }}= {{\left \langle {\mathcal{H}},(I^\downarrow )^\uparrow \right \rangle }}={{\left \langle {\mathcal{H}},I\right \rangle }}.\end{equation*}

Soundness and completeness theorem. For any set $\Gamma$ of sentences over $\sigma _1$ and any sentence $F$ over $\sigma _1$ , $F$ can be derived from $\Gamma$ in ${\mathit{HT}^{\omega}_{\!\!\#}}$ iff every standard HT-interpretation satisfying $\Gamma$ satisfies $F$ .

The proof of the theorem refers to $\omega$ -interpretations of many-sorted signatures (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Section 5.2). In case of the signatures $\sigma _0$ , $\sigma _1$ , and $\sigma _2$ , $\omega$ -interpretations are characterized by two conditions:

  • every element of the domain of general variables is represented by a precomputed term;

  • every element of the domain of integer variables is represented by a numeral.

An $\omega$ -model of a set $\Gamma$ of sentences is an HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ satisfying $\Gamma$ such that $I$ is an $\omega$ -interpretation.

Lemma 4. An HT-interpretation of $\sigma _1$ is isomorphic to a standard HT-interpretation iff it is an $\omega$ -model of $\mathit{Std}$ and $\mathit{Defs}$ .

Proof. The only-if part is obvious. If ${\left \langle {\mathcal{H}},I\right \rangle }$ is an $\omega$ -model of $\mathit{Std}$ and $\mathit{Defs}$ then the function that maps every precomputed term to the corresponding element of the domain of general variables in $I$ is an isomorphism between a standard HT-interpretation and ${\left \langle {\mathcal{H}},I\right \rangle }$ .

Proof of the soundness and completeness theorem. The deductive system $\mathit{SQHT}^\omega$ (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Section 5.3) for the signature $\sigma _1$ can be described as ${\mathit{SQHT}}^=$ (see Appendix B.3) extended by the two $\omega$ -rules from Section 7. According to Theorem 4 from that paper, for any set $\Gamma$ of sentences over $\sigma _1$ and any sentence $F$ over $\sigma _1$ , $F$ can be derived from $\Gamma$ in $\mathit{SQHT}^\omega$ iff every $\omega$ -model of $\Gamma$ satisfies $F$ . On the other hand, ${\mathit{HT}^{\omega}_{\!\!\#}}$ can be described as $\mathit{SQHT}^\omega$ extended by the axioms $\mathit{Std}$ and $\mathit{Defs}$ . It follows that for any set $\Gamma$ of sentences over $\sigma _1$ and any sentence $F$ over $\sigma _1$ , $F$ can be derived from $\Gamma$ in ${\mathit{HT}^{\omega}_{\!\!\#}}$ iff every $\omega$ -model of $\mathit{Std}$ , $\mathit{Defs}$ , and $\Gamma$ satisfies $F$ . The assertion of the theorem follows by Lemma 4.

B.6 Grounding

Recall that in Appendix B.4, we subdivided the predicate symbols of the signature $\sigma _2$ into extensional and intensional. This classification applies, in particular, to the predicate symbols of $\sigma _1$ : comparison symbols (1) are extensional, and the symbols $p/n$ , ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F$ , and ${\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F$ are intensional.

The proof of Theorem 4 refers to the grounding transformation $F\mapsto F^{\textrm {prop}}$ , which converts sentences over $\sigma _0$ into infinitary propositional combinations of precomputed atoms, and sentences over $\sigma _1$ into infinitary propositional combinations of extended precomputed atoms (Truszczynski Reference Truszczynski2012, Section 3; Lifschitz et al. Reference Lifschitz, Lühne and Schaub2019, Section 5; Lifschitz Reference Lifschitz2022, Section 10; Fandinno et al. Reference Fandinno, Lifschitz and Temple2024, Section 8).Footnote 6 This transformation is defined as follows:

  • if $F$ is $p(\textbf {t})$ , where $p$ is intensional, then $F^{\textrm {prop}}$ is obtained from $F$ by replacing each member of $\textbf {t}$ by the precomputed term obtained from it by evaluating arithmetic functions;

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

  • $(\neg F)^{\textrm {prop}}$ is $\neg F^{\textrm {prop}}$ ;

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

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

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

For any set $\Gamma$ of sentences over $\sigma _1$ , $\Gamma ^{\textrm {prop}}$ stands for $\{F^{\textrm {prop}}\,:\,F\in \Gamma \}$ .

The lemma below relates the meaning of a sentence over $\sigma _1$ to the meaning of its grounding. It is similar to Proposition 4 from Truszczynski’s article (Reference Truszczynski2012) and can be proved by induction in a similar way.

Lemma 5. For any HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ of $\sigma _1$ such that the restriction of $I$ to $\sigma _0$ is standard, and any sentence $F$ over $\sigma _1$ ,

\begin{equation*}{{\left \langle {\mathcal{H}},I\right \rangle }}\models _{ht} F\hbox{ iff } {{\left \langle {\mathcal{H}},I^\downarrow \right \rangle }}\models _{ht} F^{\textrm {prop}}.\end{equation*}

The next lemma relates $(\tau ^*\Pi )^{\textrm {prop}}$ to $\tau \Pi$ .

Lemma 6. For any mgc program $\Pi$ , every propositional HT-interpretation satisfying ${\mathit{Defs}}^{\textrm {prop}}$ satisfies also the formula $(\tau ^*\Pi )^{\textrm {prop}}\leftrightarrow \tau \Pi$ .

Proof. It is sufficient to consider the case when $\Pi$ is a single pure rule $R$ . The equivalence $(\tau ^*R)^{\textrm {prop}}\leftrightarrow \tau R$ is provable in the deductive system $HT^{\infty }+{\mathit{Defs}}^{\textrm {prop}}$ (Lifschitz Reference Lifschitz2022, Theorem 1). The assertion of the lemma follows from this theorem, because every HT-interpretation satisfies all axioms of $HT^{\infty }$ , and satisfaction is preserved by the inference rules of $HT^{\infty }$ .

B.7 Proof of Theorem 4

Lemma 7. For any mgc program $\Pi$ and any sets $\mathcal{X}$ , $\mathcal{Y}$ of precomputed atoms such that ${\mathcal{X}}\subseteq \mathcal{Y}$ ,

(B34) \begin{equation} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow \models _{ht}\tau ^*\Pi \end{equation}

iff ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi$ .

Proof. Condition (B34) can be rewritten as ${{\left \langle {\mathcal{H}},\mathcal{Y}^\uparrow \right \rangle }}\models _{ht}\tau ^*\Pi$ , and, by Lemma 5, it is equivalent to

(B35) \begin{equation} {{\left \langle {\mathcal{H}},(\mathcal{Y}^\uparrow )^\downarrow \right \rangle }}\models _{ht}(\tau ^*\Pi )^{\textrm {prop}}. \end{equation}

On the other hand,

\begin{equation*}{{\left \langle {\mathcal{H}},\mathcal{Y}^\uparrow \right \rangle }}={{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow \models _{ht}{\mathit{Defs}}.\end{equation*}

By Lemma 5, it follows that ${\left \langle {\mathcal{H}},(\mathcal{Y}^\uparrow )^\downarrow \right \rangle }$ satisfies ${\mathit{Defs}}^{\textrm {prop}}$ . By Lemma 6, we can conclude that (B35) is equivalent to

\begin{equation*}{{\left \langle {\mathcal{H}},(\mathcal{Y}^\uparrow )^\downarrow \right \rangle }}\models _{ht}\tau \Pi .\end{equation*}

This condition is equivalent to ${{\left \langle {\mathcal{H}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi$ , because the formula $\tau \Pi$ is formed from precomputed atoms.

Proof of the theorem. We need to show that the formula $\tau ^*\Pi _1\leftrightarrow \tau ^*\Pi _2$ is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ iff $\tau \Pi _1$ is strongly equivalent to $\tau \Pi _2$ . This formula is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ iff

(B36) \begin{equation} \tau ^*\Pi _2\hbox{ is derivable in ${{\mathit{HT}^{\omega}_{\!\!\#}} }$ from }\tau ^*\Pi _1 \end{equation}

and

(B37) \begin{equation} \tau ^*\Pi _1\hbox{ is derivable in ${{\mathit{HT}^{\omega}_{\!\!\#}} }$ from }\tau ^*\Pi _2. \end{equation}

On the other hand, the characterization of strong equivalence of infinitary propositional formulas in terms of propositional HT-interpretations (Harrison et al. Reference Harrison, Lifschitz, Pearce and Valverde2017, Theorem 3) shows that $\tau \Pi _1$ is strongly equivalent to $\tau \Pi _2$ iff

(B38) \begin{equation} \begin{array} c \text{for every propositional HT-interpretation} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }},\\[5pt] \text{if} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _1 \text{then} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _2 \end{array} \end{equation}

and

(B39) \begin{equation} \begin{array} c \text{for every propositional HT-interpretation} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }},\\[5pt] \text{if} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _2 \text{then} {{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _1 \end{array} \end{equation}

We will show that conditions (B36) and (B38) are equivalent to each other; the equivalence between (B37) and (B39) is proved in a similar way.

Assume that condition (B36) is satisfied but condition (B38) is not, so that ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _1$ and ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\not \models _{ht}\tau \Pi _2$ for some propositional HT-interpretation ${\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }$ . By Lemma 7, ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow \models _{ht}\tau ^*\Pi _1$ and ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow \not \models _{ht}\tau ^*\Pi _2$ . Thus, there exists a standard HT-interpretation of $\sigma _1$ that satisfies $\tau ^*\Pi _1$ but does not satisfy $\tau ^*\Pi _2$ . This is in contradiction with the fact that ${\mathit{HT}^{\omega}_{\!\!\#}}$ is sound with respect to standard interpretations (Appendix B.5).

Assume now that (B36) is not satisfied. Since ${\mathit{HT}^{\omega}_{\!\!\#}}$ is complete with respect to standard interpretations (Appendix B.5), there exists a standard interpretation that satisfies $\tau ^*\Pi _1$ but does not satisfy $\tau ^*\Pi _2$ . Consider a representation of this interpretation in the form ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}^\uparrow$ . By Lemma 7, ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\models _{ht}\tau \Pi _1$ and ${{\left \langle {\mathcal{X}},\mathcal{Y}\right \rangle }}\not \models _{ht}\tau \Pi _2$ , so that condition (B38) is not satisfied either.

B.8 Proofs of Theorems 1 and 5

B.8.1 Deductive system $\mathit{HT}_{\!\!\#2}^\omega$

Proofs of Theorems 1 and 5 refer to the deductive system $\mathit{HT}_{\!\!\#2}^\omega$ , which is a straightforward extension of ${\mathit{HT}^{\omega}_{\!\!\#}}$ to the signature $\sigma _2$ . Its derivable objects are sequents over $\sigma _2$ . Its axioms and inference rules are those of intuitionistic logic for the signature $\sigma _2$ extended by

  • axiom schemas (6) and (7) for all formulas $F$ , $G$ , $H$ over $\sigma _2$ ,

  • axioms $\mathit{Std}$ and $\mathit{Defs}$ , and

  • the $\omega$ -rules from Section 7 extended to sequents over $\sigma _2$ .

Any sentence provable in $\mathit{HT}_{\!\!\#}$ can be derived in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ and $D_1$ . Indeed, the only axioms of $\mathit{HT}_{\!\!\#}$ that are not included in $\mathit{HT}_{\!\!\#2}^\omega$ are $\mathit{Ind}$ , $D_0$ , and $D_1$ , and all instances of $\mathit{Ind}$ can be proved using the second $\omega$ -rule, as discussed in Section 7. We will prove a stronger assertion:

Lemma 8. Any sentence provable in $\mathit{HT}_{\!\!\#}$ can be derived in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ .

We will prove also the following conservative extension property:

Lemma 9. Every sentence over the signature $\sigma _1$ derivable in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ .

The assertion of Theorem 5 follows from these two lemmas.

The assertion of Theorem 1 follows from Theorems 4 and 5.

B.8.2 Some formulas derivable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ and $\mathit{HT}_{\!\!\#2}^\omega$

In Appendix B.2.1, we showed that formula (B9) is provable in $\mathit{HT}_{\!\!\#}$ . All axioms of $\mathit{HT}_{\!\!\#}$ used in that proof are among the axioms of ${\mathit{HT}^{\omega}_{\!\!\#}}$ , so that this formula is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ as well.

Claim: For any formula $F$ over $\sigma _0$ and any integers $m$ , $n$ such that $m\geq n$ , the formula

(B40) \begin{gather} \exists _{\geq \overline m} \textbf {U} \, F \to \exists _{\geq \overline n} \textbf {U} \, F \end{gather}

is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ .

Proof. It is sufficient to consider the case when $m=n+1$ ; then the general case will follow by induction. We can also assume that $n$ is positive, because otherwise the consequent of (B40) is $\top$ . From (B9),

\begin{gather*} \exists _{\geq \overline {n+1}}\textbf {U}\,F \to \exists \textbf {W}(\exists _{\geq \overline n}\textbf {U}(\textbf {W}\lt \textbf {U} \land F)). \end{gather*}

We can rewrite the consequent of this implication as

\begin{gather*} \exists \textbf {W} \textbf {U}_1 \dotsm \textbf {U}_n \left ( \bigwedge _{i=1}^n \left (\textbf {W} \lt \textbf {U}_i \land F^{\textbf {U}}_{\textbf {U}_1} \right ) \land \bigwedge _{i\lt j} \neg (\textbf {U}_i = \textbf {U}_j) \right ). \end{gather*}

It implies

\begin{gather*} \exists \textbf {U}_1 \dotsm \textbf {U}_n \left ( \bigwedge _{i=1}^n F^{\textbf {U}}_{\textbf {U}_1} \land \bigwedge _{i\lt j} \neg (\textbf {U}_i = \textbf {U}_j) \right ), \end{gather*}

which is the consequent of (B40).

Claim: For any formula $F$ over $\sigma _0$ , any integer $n$ , and any precomputed term $r$ , the formula

(B41) \begin{align} \overline n \geq r \wedge \exists _{\geq \overline n} \textbf {U} \, F \to \exists _{\geq r} \textbf {U} \, F \end{align}

is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ .

Proof. If $\overline n \lt r$ then the antecedent of (B41) is equivalent to $\bot$ . If $r \leq \overline 0$ then the consequent of (B41) is $\top$ . If $\overline n\geq r\gt 0$ then $r$ is a numeral $\overline m$ , because the set of numerals is contiguous, so that (B41) follows from (B40).

In Appendix B.2.1, we showed that formula (B16) is provable in $\mathit{HT}_{\!\!\#}$ . All axioms of $\mathit{HT}_{\!\!\#}$ used in that proof are among the axioms of ${\mathit{HT}^{\omega}_{\!\!\#}}$ , so that this formula is provable in ${\mathit{HT}^{\omega}_{\!\!\#}}$ as well.

Claim: The formula

(B42) \begin{equation} \forall \textbf {V} N(N\geq \overline 0 \to ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \leftrightarrow \neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N+\overline 1))) \end{equation}

is provable in $\mathit{HT}_{\!\!\#2}^\omega$ .

Proof: By Defs and (B16), for every nonnegative $n$ ,

\begin{equation*} {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n) \leftrightarrow \exists _{\leq \overline n} \textbf {U} \, F \leftrightarrow \neg \exists _{\geq \overline {n+1}} \textbf {U} \, F \leftrightarrow \neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n+\overline 1). \end{equation*}

It follows that for every integer $n$ ,

\begin{equation*}\forall \textbf {V} (\overline n\geq \overline 0 \to ({\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n) \leftrightarrow \neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n+\overline 1))).\end{equation*}

Formula (B42) follows by the second $\omega$ -rule.

Claim: The formula

(B43) \begin{gather} \forall \textbf {V} Y \left ( \exists N \left ( N \geq Y \wedge {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \right ) \leftrightarrow {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y) \right ) \end{gather}

is provable in $\mathit{HT}_{\!\!\#2}^\omega$ .

Proof. Left-to-right: take any integer $n$ and precomputed term $r$ . By (36), the universal closure of (B41) can be rewritten as

\begin{equation*} \forall \textbf {V} \left ( \overline n \geq r \wedge {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n) \to {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r) \right ).\end{equation*}

By the $\omega$ -rules, it follows that

\begin{equation*} \forall N Y \textbf {V} \left ( N \geq Y \wedge {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \to {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y) \right ),\end{equation*}

which is equivalent to the implication to be proved.

Right-to-left: We will show that

(B44) \begin{equation} \forall \textbf {V} \left ( {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)\to \exists N \left ( N \geq r \wedge {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \right ) \right ) \end{equation}

for every precomputed term $r$ ; then the implication to be proved will follow by the second $\omega$ -rule. Since the set of numerals is contiguous, three cases are possible: (1) $r\lt \overline n$ for all integers $n$ ; (2) $r$ is a numeral; (3) $r\gt \overline n$ for all integers $n$ . In the last case, the antecedent of (B44) is equivalent to $\bot$ by (36). Otherwise, assume ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},r)$ ; we need to find $N$ such that $N \geq r$ and ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N)$ . If $r\lt \overline n$ for all $n$ then take $N=\overline 0$ ; ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline 0)$ follows from (36). If $r$ is a numeral then take $N=r$ .

In Appendix B.2.1 we showed that formula (B15) is provable in $\mathit{HT}_{\!\!\#}$ . The axioms $D_1$ are not used in that proof. It follows that formula (B15) is derivable in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ .

Claim: The sentence

(B45) \begin{gather} \forall \textbf {V} N \left ( \exists \textbf {X} {\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {X},\textbf {V}, N) \leftrightarrow {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N) \right ) \end{gather}

is derivable in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ .

Proof. For every integer $n$ , the sentence

\begin{gather*} \forall \textbf {V}( \exists \textbf {X} {\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {X},\textbf {V}, \overline n) \leftrightarrow {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},\overline n)) \end{gather*}

is derivable in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ , because it follows from (36) and (B15). Then (B45) follows by the second $\omega$ -rule.

B.8.3 Proof of Lemma 8

To prove Lemma 8, we need to show that all instances of $D_1$ can be derived in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ .

Proof of (8). By (B43), ${\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y)$ is equivalent to

\begin{equation*} \exists N(N \geq Y \land {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},N)). \end{equation*}

By (B45), this formula is equivalent to

\begin{equation*}\exists N( N \geq Y \land \exists \textbf {X} {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)),\end{equation*}

which can be further rewritten as

\begin{equation*}\exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\land N\geq Y).\end{equation*}

Proof of (9). We will prove the equivalence

(B46) \begin{gather} {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},Y) \leftrightarrow \forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq Y) \end{gather}

by cases, using the $\mathit{Std}$ axiom

\begin{gather*} Y \lt \overline 0\,\vee \,\forall M (M \lt Y)\,\vee \, \exists M (M = Y \wedge M \geq \overline 0). \end{gather*}

Case 1: $Y \lt \overline 0$ . By Defs, the left-hand side of (B46) is equivalent to $\bot$ . Furthermore, by $D_0$ , ${\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {U},\textbf {V}, 0)$ and thus the right-hand side of (B46) is equivalent to $\bot$ as well.

Case 2: $\forall M (M \lt Y)$ . By Defs, the left-hand side of (B46) is equivalent to $\top$ . The right-hand side is equivalent to $\top$ as well.

Case 3: $M = Y$ and $M \geq 0$ . Formula (B46) can be rewritten as:

(B47) \begin{equation} {\mathit{Atmost}}^{\textbf {X};\textbf {V}}_F(\textbf {V},M) \leftrightarrow \forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N)\to N\leq M). \end{equation}

By (B42), the left-hand side is equivalent to $\neg {\mathit{Atleast}}^{\textbf {X};\textbf {V}}_F(\textbf {V},M+\overline 1)$ . Hence, by (8), it is equivalent to

\begin{equation*} \neg \exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N+\overline 1) \land N+\overline 1\geq M+\overline 1) \end{equation*}

and furthermore to

\begin{equation*} \neg \exists \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N) \land N\geq M+\overline 1). \end{equation*}

This formula can be further rewritten as

\begin{equation*} \forall \textbf {X} N({\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {X},\textbf {V},N) \to \neg (N\geq M+\overline 1)), \end{equation*}

which is equivalent to the right-hand side of (B47).

B.8.4 Proof of Lemma 9

Ley $F$ be a sentence over the signature $\sigma _1$ that is derivable in $\mathit{HT}_{\!\!\#2}^\omega$ from $D_0$ . We will show that every standard HT-interpretation of $\sigma _1$ satisfies $F$ ; then the provability of $F$ in ${\mathit{HT}^{\omega}_{\!\!\#}}$ will follow from the completeness of ${\mathit{HT}^{\omega}_{\!\!\#}}$ (Appendix B.5).

Consider a standard HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ of $\sigma _1$ . Let $I'$ be the extension of $I$ to the signature $\sigma _2$ defined by the condition: an extended precomputed atom ${\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {x},\textbf {v},\overline n)$ is satisfied by $I'$ iff $n\leq 0$ or

  • $n\gt 0$ ,

  • $I \models F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}}$ , and

  • there exist at least $n$ tuples $\textbf {y}$ of precomputed terms such that $\textbf {y}\geq \textbf {x}$ and $I \models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}$ .

Since ${\left \langle {\mathcal{H}},I\right \rangle }$ is standard, $I'$ is an $\omega$ -iterpretation. Furthermore, let ${\mathcal{H}}'$ be the set of extended precomputed atoms obtained from $\mathcal{H}$ by adding the atoms ${\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {x},\textbf {v},\overline n)$ such that $n\leq 0$ or

  • $n\gt 0$ ,

  • ${{\left \langle {\mathcal{H}},I\right \rangle }} \models _{ht} F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}}$ , and

  • there exist at least $n$ tuples $\textbf {y}$ of precomputed terms such that $\textbf {y}\geq \textbf {x}$ and ${{\left \langle {\mathcal{H}},I\right \rangle }} \models _{ht} F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}$ .

From the persistence property of HT-interpretations (Appendix B.3) we can conclude that each of the atoms added to $\mathcal{H}$ is satisfied by $I'$ . Hence ${\left \langle {\mathcal{H}}',I'\right \rangle }$ is an HT-interpretation of $\sigma _2$ .

We will show that

(B48) \begin{equation} {{\left \langle {\mathcal{H}}',I'\right \rangle }}\,\text{satisfies}\,\, {\mathit{Std}},\,{\mathit{Defs}},\, \text{and}\,\, D_0. \end{equation}

Then the assertion of the lemma will follow. Indeed, the deductive system $\mathit{HT}_{\!\!\#2}^\omega$ can be described as $\mathit{SQHT}^\omega$ (see Appendix B.5) over $\sigma _2$ extended by the axioms $\mathit{Std}$ and $\mathit{Defs}$ . Hence, $F$ is derivable in $\mathit{SQHT}^\omega$ over $\sigma _2$ from $\mathit{Std}$ , $\mathit{Defs}$ and $D_0$ . By (B48), ${\left \langle {\mathcal{H}}',I'\right \rangle }$ is an $\omega$ -model of these sentences. By the soundness of $\mathit{SQHT}^\omega$ (Fandinno and Lifschitz Reference Fandinno and Lifschitz2023a, Theorem 4), it follows that $F$ is satisfied by ${\left \langle {\mathcal{H}}',I'\right \rangle }$ . Since $F$ is a sentence over $\sigma _1$ , we conclude that $F$ is satisfied by ${\left \langle {\mathcal{H}},I\right \rangle }$ .

Proof of (B48):

For $\mathit{Defs}$ and $\mathit{Std}$ , this assertion follows from the fact that ${\left \langle {\mathcal{H}}',I'\right \rangle }$ extends the interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ of $\sigma _1$ , which satisfies $\mathit{Defs}$ and $\mathit{Std}$ because it is standard.

For $D_0$ , consider the more difficult axiom schema in this group, the last one. We need to check that for any tuples $\textbf {x}$ and $\textbf {v}$ of precomputed terms and any positive $n$ , ${\left \langle {\mathcal{H}}',I'\right \rangle }$ satisfies

(B49) \begin{equation} {\mathit{Start}}^{\textbf {X};\textbf {V}}_F(\textbf {x},\textbf {v},\overline {n+1}) \leftrightarrow F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}} \land \exists \textbf {U}(\textbf {x} \lt \textbf {U} \land {\mathit{Start}}^{\textbf {X},\textbf {V}}_F(\textbf {U},\textbf {v},\overline n)). \end{equation}

We need to check, in other words, that $I'$ satisfies the left-hand side of (B49) iff $I'$ satisfies the right-hand side, and similarly for ${\left \langle {\mathcal{H}}',I'\right \rangle }$ .

Assume that $I'$ satisfies the left-hand side. Then $I \models F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}}$ , and

\begin{align*} \text{there exist at least}\,n+1\, tuples\,\textbf {y}\, \text{such that}\, \textbf {y}\geq \textbf {x} \,\text{and}\, I\models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}. \end{align*}

It follows that

\begin{align*} \text{there exist at least}\,n \,tuples\,\textbf {y}\, \text{such that}\, \textbf {y}\gt \textbf {x} \,\text{and}\, I\models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}. \end{align*}

Pick such a group of n tuples, and let u be the least among them. Then u>x, and

\begin{align*} \text{there exist at least}\,n\, tuples\,\textbf {y}\, \text{such that}\, \textbf {y}\geq \textbf {u}\, \text{and}\, I\models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}. \end{align*}

It follows that $I$ satisfies $\textbf {x} \lt \textbf {u}\; \land$ $\mathit{Start}$ $^{\textbf {X},\textbf {V}}_F(\textbf {u},\textbf {v},\overline n)$ and consequently satisfies the right-hand side of (B49).

Assume now that $I'$ satisfies the right-hand side of (B49). Then $I'\models F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}}$ , and there exists a tuple $\textbf {u}$ such that $\textbf {x}\lt \textbf {u}$ and $I'\models {\mathit{Start}}$ $^{\textbf {X},\textbf {V}}_F(\textbf {u},\textbf {v},\overline n)$ . Hence, $I\models F^{\textbf {X},\textbf {V}}_{\textbf {x},\textbf {v}}$ , and

\begin{align*} \text{there exist at least}\,n \,tuples\,\textbf {y}\, \text{such that}\, \textbf {y}\geq \textbf {u} \, \text{and}\, I\models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}. \end{align*}

It follows that

\begin{align*} \text{there exist at least}\,n+1\, tuples\,\textbf {y}\, \text{such that}\, \textbf {y}\geq \textbf {x} \,\text{and}\, I\models F^{\textbf {X},\textbf {V}}_{\textbf {y},\textbf {v}}, \end{align*}

so that $I'$ satisfies the left-hand side of (B49).

For the HT-interpretation ${\left \langle {\mathcal{H}},I\right \rangle }$ the reasoning is similar.

Footnotes

1 The description below differs slightly from the original publication (Lifschitz Reference Lifschitz2022): the absolute value symbol $|\ |$ is allowed in the definition of a term, and the symbols inf and sup are not required.

2 We talk about a set of values because an mgc term may contain the interval symbol. For instance, the values of the mgc term $\overline{1}..\overline{3}$ are $\overline{1}$ , $\overline{2}$ , and $\overline{3}$ . On the other hand, the set of values of the term a- $\overline{1}$ , where a is a symbolic constant, is empty.

3 If F is a formula, by $F^{X}_{t}$ we denote the result of replacing all free occurrences of a variable X in F by a term t.

4 Grounder gringo (Gebser et al. Reference Gebser, Kaminski, Kaufmann, Lindauer, Ostrowski, Romero, Schaub and Thiele2019) truncates the quotient toward zero, instead of applying the floor function. 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).

5 The superscript B indicates that this translation is intended for bodies of rules.

6 In some of these papers, the transformation $F \mapsto F^{prop}$ is denoted by gr. We take the liberty to identify precomputed terms t with their names $t^{\ast}$ .

References

Chen, Y., Lin, F. and Li, L. 2005. SELP – a system for studying strong equivalence between logic programs. In Proceedings of International Conference on Logic Programming and Nonmonotonic Reasoning, 442446. URL: CEUR-WS.org.10.1007/11546207_43CrossRefGoogle Scholar
Fandinno, J. and Hansen, Z. 2025. Recursive aggregates as intensional functions in answer set programming: semantics and strong equivalence. In AAAI, AAAI Press, 1489314901.Google Scholar
Fandinno, J., Hansen, Z. and Lieler, Y. 2022. Axiomatization of aggregates in answer set programming. In Proceedings of the AAAI Conference on Artificial Intelligence, AAAI Press.Google Scholar
Fandinno, J., Hansen, Z., Lieler, Y., Lifschitz, V. and Temple, N. 2023. External behavior of a logic program and verification of refactoring. In Theory and Practice of Logic Programming, Cambridge University Press, 933947.Google Scholar
Fandinno, J. and Hansen, Z. 2025. Recursive aggregates as intensional functions in answer set programming: Semantics and strong equivalence. In Proceedings of the Thirty-eighth National Conference on Artificial Intelligence (AAAI’25), T. Walsh, J. Shah and Z. Kolter, Eds. AAAI Press. (to appear).10.1609/aaai.v39i14.33633CrossRefGoogle Scholar
Fandinno, J. and Lifschitz, V. 2023a. 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, IJCAI Organization.Google Scholar
Fandinno, J. and Lifschitz, V. 2023b. On Heuer’s procedure for verifying strong equivalence. In Proceedings of European Conference on Logics in Artificial Intelligence, Springer.Google 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, 5, 735750.10.1017/S1471068420000344CrossRefGoogle Scholar
Fandinno, J., Lifschitz, V. and Temple, N. 2024. Locally tight programs. In Theory and Practice of Logic Programming, Cambridge University Press, 131.Google Scholar
Ferraris, P., Lee, J. and Lifschitz, V. 2011. Stable models and circumscription. Artificial Intelligence 175, 236263.10.1016/j.artint.2010.04.011CrossRefGoogle Scholar
Gebser, M., Harrison, A., Kaminski, R., Lifschitz, V. and Schaub, T. 2015. Abstract gringo. Theory and Practice of Logic Programming 15, 449463.10.1017/S1471068415000150CrossRefGoogle 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
Hansen, Z. 2023. Anthem-p2p: Automatically verifying the equivalent external behavior of ASP programs. In Electronic Proceedings in Theoretical Computer Science, vol. 385, Open Publishing Association.Google Scholar
Harrison, A., Lifschitz, V., Pearce, D. and Valverde, A. 2017. Infinitary equilibrium logic and strongly equivalent logic programs. Artificial Intelligence 246, 2233.10.1016/j.artint.2017.02.002CrossRefGoogle Scholar
Henkin, L. 1954. A generalization of the concept of $\omega$ -consistency. The Journal of Symbolic Logic 19, 183196.10.2307/2268617CrossRefGoogle Scholar
Heuer, J. 2020. Automated Verification of Equivalence Properties in Advanced Logic Programs. Bachelor Thesis, University of Potsdam.Google Scholar
Hosoi, T. 1966. The axiomatization of the intermediate propositional systems ${S}_n$ of Gödel. Journal of the Faculty of Science of the University of Tokyo 13, 183187.Google Scholar
Kovaćs, L. and Voronkov, A. 2013. First-order theorem proving and Vampire. In International Conference on Computer Aided Verification, Springer, 135.Google Scholar
Lifschitz, V. 2021. Here and there with arithmetic. In Theory and Practice of Logic Programming, Cambridge University Press, 735749.Google Scholar
Lifschitz, V. 2022. Strong equivalence of logic programs with counting. Theory and Practice of Logic Programming 22, 4, 573588.10.1017/S1471068422000278CrossRefGoogle 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, Springer.Google Scholar
Lifschitz, V., Morgenstern, L. and Plaisted, D. 2008. Knowledge representation and classical logic. In Handbook of Knowledge Representation, F. Van Harmelen, V. Lifschitz and B. Porter, Eds. Elsevier, 388.Google Scholar
Lifschitz, V., Pearce, D. and Vvalverde, A. 2001. Strongly equivalent logic programs. ACM Transactions on Computational Logic 2, 4, 526541.10.1145/383779.383783CrossRefGoogle Scholar
Lifschitz, V., Pearce, D. and Valverde, A. 2007. A characterization of strong equivalence for logic programs with variables. In Procedings of International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR), Springer, 188200.10.1007/978-3-540-72200-7_17CrossRefGoogle Scholar
Lin, F. 2002. Reducing strong equivalence of logic programs to entailment in classical propositional logic. In Proceedings of International Conference on Principles of Knowledge Representation and Reasoning (KR), IJCAI Organization, 170176.Google Scholar
Pearce, D. 1997. A new logical characterization of stable models and answer sets. In Non-Monotonic Extensions of Logic Programming (Lecture Notes in Artificial Intelligence 1216), J. Dix, L. Pereira and T. Przymusinski, Eds. Springer, 5770.10.1007/BFb0023801CrossRefGoogle Scholar
Pearce, D. 1999. From here to there: Stable negation in logic programming. In What Is Negation?, D. Gabbay and H. Wansing, Eds. Kluwer.Google Scholar
Pearce, D., Tompits, H. and Woltran, S. 2001. Encodings for equilibrium logic and logic programs with nested expressions. In Proceedings of the Tenth Portuguese Conference on Artificial Intelligence (EPIA’01), P. Brazdil and A. Jorge, Eds. vol. 2258 of Lecture Notes in Computer Science, Springer-Verlag, 306320.Google Scholar
Pearce, D., Tompits, H. and Woltran, S. 2009. Characterising equilibrium logic and nested logic programs: Reductions and complexity. Theory and Practice of Logic Programming 9, 565616.10.1017/S147106840999010XCrossRefGoogle 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, E. Erdem, J. Lee, Y. Lierler and D. Pearce, Eds. Springer, 543559.10.1007/978-3-642-30743-0_37CrossRefGoogle Scholar