Hostname: page-component-586b7cd67f-tf8b9 Total loading time: 0 Render date: 2024-12-04T23:11:55.797Z Has data issue: false hasContentIssue false

INTERLEAVING LOGIC AND COUNTING

Published online by Cambridge University Press:  26 July 2023

JOHAN VAN BENTHEM
Affiliation:
INSTITUTE FOR LOGIC, LANGUAGE, AND COMPUTATION UNIVERSITEIT VAN AMSTERDAM SCIENCE PARK 107, 1098 XG AMSTERDAM NETHERLANDS E-mail: johan@stanford.edu
THOMAS ICARD
Affiliation:
DEPARTMENT OF PHILOSOPHY, STANFORD UNIVERSITY 450 JANE STANFORD WAY, MAIN QUAD, BUILDING 90 STANFORD, CA 94305, USA E-mail: icard@stanford.edu
Rights & Permissions [Opens in a new window]

Abstract

Reasoning with quantifier expressions in natural language combines logical and arithmetical features, transcending strict divides between qualitative and quantitative. Our topic is this cooperation of styles as it occurs in common linguistic usage and its extension into the broader practice of natural language plus ‘grassroots mathematics’.

We begin with a brief review of $\mathsf {FO}(\#)$, first-order logic with counting operators and cardinality comparisons. This system is known to be of very high complexity, and drowns out finer aspects of the combination of logic and counting. We therefore move to a small fragment that can represent numerical syllogisms and basic reasoning about comparative size: monadic first-order logic with counting, $\mathsf {MFO}(\#)$. We provide normal forms that allow for axiomatization, determine which arithmetical notions can be defined on finite and on infinite models, and conversely, we discuss which logical notions can be defined out of purely arithmetical ones, and what sort of (non-)classical logics can be induced.

Next, we investigate a series of strengthenings of $\mathsf {MFO}(\#)$, again using normal form methods. The monadic second-order version is close, in a precise sense, to additive Presburger Arithmetic, while versions with the natural device of tuple counting take us to Diophantine equations, making the logic undecidable. We also define a system $\mathsf {ML}(\#)$ that combines basic modal logic over binary accessibility relations with counting, needed to formulate ubiquitous reasoning patterns such as the Pigeonhole Principle. We prove decidability of $\mathsf {ML}(\#)$, and provide a new kind of bisimulation matching the expressive power of the language.

As a complement to the fragment approach pursued here, we also discuss two other ways of lowering the complexity of $\mathsf {FO}(\#)$ by changing the semantics of counting in natural ways. A first approach replaces cardinalities by abstract but well-motivated values of ‘mass’ or other mereological aggregating notions. A second approach keeps the cardinalities but generalizes the meaning of counting to work in models that allow dependencies between variables.

Finally, we return to our starting point in natural language, confronting the architecture of our formal systems with linguistic quantifier vocabulary and syntax, as well as with natural reasoning modules such as the monotonicity calculus. In addition to these encounters with formal semantics, we discuss the role of counting in semantic evaluation procedures for quantifier expressions and determine, for instance, which binary quantifiers are computable by finite ‘semantic automata’. We conclude with some general thoughts on yet further entanglements of logic and counting in formal systems, on rethinking the qualitative/quantitative divide, and on connecting our analysis to empirical findings in cognitive science.

Type
Articles
Copyright
© The Author(s), 2023. Published by Cambridge University Press on behalf of The Association for Symbolic Logic

1 Introduction: inference and computing

Here is the archetypal logical inference with a basic quantifier:

From ‘All A are B’ and ‘All B are C’, conclude that ‘All A are C’.

Next, here are two slightly modified premises in natural language.

‘All A except one are B and all B except two are C’.

This time, one may need to think just a little bit more to conclude that

‘All A except at most three are C’.

That extra bit of thought involves considering possible exceptions, or more generally: counting. In fact, the very term quantifier suggests quantities, and the semantics of quantifier expressions in logic and linguistics involves numbers by its emphasis on permutation invariance, which abstracts away from every feature of predicates except their size. This mix of logic and counting is not just about absolute numbers, it also extends to size comparisons. From

‘Most A are B’ and ‘All B are C’,

we may safely draw the conclusion that

‘Most A are C

and similar simple inference patterns govern explicitly comparative expressions such as ‘More A than B are C’. But valid reasoning patterns with comparatives can also be more challenging, as in the following inference, which may require drawing a Venn diagram:

‘More A than B are C’, ‘More B than C are A’,

Therefore: ‘More A than C are B’.

This has echoes of the mathematical Triangle Inequality underlying metric geometry.

Numerical comparisons in natural language can even occur between proportions, as happens in the relative sense of ‘Many A are B’, comparing the numbers of Bs among the As with the number of Bs overall, defined more precisely in Section 3, and a running example later on.

Qualitative logical analyses are sometimes seen as replacing quantitative theories by ‘more basic’ qualitative ones, for instance, in the foundations of probability or in measurement theory. This can be illuminating, and success can be measured by representation theorems. And yet, historically, logic and quantitative reasoning, for instance, with probability, went together in the pioneering work of Bolzano and Boole. It is hard to say whether Boole’s propositional logic is a qualitative basic form of binary arithmetic, or a way of making logical inference a form of counting. In a sense, it is both. A divide arose only in the time of Frege, when logicism insisted that logical notions come first, and arithmetical ones are constructed out of these. To be sure, this reductionist program has yielded many fundamental notions and results, and we owe a lot of modern logic to its arrival. But in this paper, we will follow the linguistic practice that we started with, and treat logic and counting, taken as the realm of numerical comparisons and basic arithmetic, on a par.

In what follows we will take this linguistic practice in a broad sense, including ubiquitous forms of reasoning that might be called ‘grassroots mathematics’ rather than pure natural language inference. A typical example underlies the following pattern:

  • ‘Twenty farmers own at most 15 cows each’. Therefore:

  • ‘At least two farmers own the same number of cows’.

The reader may find it difficult to see how this would follow as a straightforward matter of overt logical or linguistic form. Instead, what is needed is the following:

  • Pigeonhole Principle If one puts n objects into k boxes, with $n> k$ , then at least one box must contain at least two objects.

Here k is the number of cows owned, which runs from 0 to 15, n the number of farmers. The Pigeonhole Principle occurs in elementary mathematics where it can have non-trivial consequences when applied imaginatively, but it is also of interest in cognitive science as a benchmark in reasoning ability including finding the right representation of problems [Reference Mercier, Politzer and Sperber87]. In this paper, the principle will occur at various places as we determine its position in combined systems of logic and counting.

Where should we start with our investigation of logic and counting? It is well-known that combining a standard system like first-order logic with counting syntax and cardinality comparisons leads to a system $\mathsf {FO}(\#)$ of very high complexity. Therefore, for our purpose, this ‘view from above’ is not that illuminating, and after just a quick look at $\mathsf {FO}(\#)$ and its properties, we will start work ‘from below’, exploring very simple combinations of logic and counting, and only then move to more complex systems.

Our presentation follows mainstream practice in offering a sequence of formal systems of increasing expressive strength. We will prove many results about these systems that demonstrate their precise mixture of logic and counting. Toward the end of the paper, we return to the naturally occurring practice of mixed qualitative and quantitative reasoning that we started with here, linking up with Generalized Quantifier Theory for natural language, and touching on empirical issues in cognitive science. Finally, in a sequence of appendices, we broaden the context, and point out yet further entanglements of logic and counting that show the ubiquity of the phenomenon we are after. True understanding of how logical systems work involves numbers and counting from manipulating syntax to proofs by formula induction, but also semantically, e.g., in the use of numerical invariants in Ehrenfeucht games.

There are several ways of looking at the topics and results presented in this paper. Simple combinations of logic and counting can often be seen as fragments of richer logics of generalized quantifiers [Reference Barwise and Feferman9, Reference Peters and Westerståhl100]. In this sense, we are looking at fine-structure of fragments of well-known systems from mathematical logic. Moreover, the interplay of logic and counting has long been studied in computational logic [Reference Otto98, Reference Schweikardt116]. Accordingly, themes and results from the literature in theoretical computer science will appear at many places in this paper. We have added an appendix with references to a wide, and hopefully representative, swath of the preceding literature, though a full overview is beyond our capacity.

Against this background, the technical main novelty of this paper is the series of simple combined systems that we define and study. However, a further contribution may be the more empirical perspective we are adding of connections with natural language and cognition. In addition to our technical results about logic and counting, we see this stance in between logic, computation, and cognition, as fruitful and worth pursuing.

In the next section, we first present a higher-end combination of logic and counting, as a first pass through our main themes. After that, we give more detail on the lower-end systems that will be the focus of our analysis in the core of the paper.

2 First-order logic with counting

Perhaps the obvious starting point is to consider a counting operator $\#$ on top of standard first-order logic, allowing us to count the number of objects satisfying a given formula. Where x is a first-order variable and $\varphi $ a first-order formula, in a first-order model $\mathcal {M}$ with variable assignment s, the term $\#_x\varphi $ denotes the cardinality of the set of x’s satisfying $\varphi $ :

$$ \begin{align*} {[\![ {\#_x\varphi} ]\!]}^{\mathcal{M},s} & = |\{d \in D: \mathcal{M},s^x_d \models \varphi\}|. \end{align*} $$

Count terms thus denote cardinal numbers. What kinds of assertions would we want to make about cardinal numbers to formalize interesting reasoning about counting? Here we start with a basic and fundamental capacity, namely comparison. We inductively define count comparison formulas $\#_x\varphi \succsim \#_y\psi $ , with the obvious interpretation according to which:

$$ \begin{align*} \mathcal{M},s \vDash \#_x\varphi \succsim \#_y\psi \quad \mbox{iff}\quad {[\![{ {\#_x\varphi} }]\!]}^{\mathcal{M},s} \geq {[\![{ {\#_y\psi} }]\!]}^{\mathcal{M},s}. \end{align*} $$

Call this language $\mathcal {L}_\#$ and call the logical system $\mathsf {FO}(\#)$ .

This system has been studied thoroughly. It is natural to construe $\mathsf {FO}(\#)$ as first-order logic with a generalized quantifier, sometimes known in the literature as the Rescher quantifier [Reference Herre, Krynicki, Pinus and Väänänen56, Reference Otto98] after a related extension considered in [Reference Rescher109]; in the philosophical literature it has sometimes been called the Frege quantifier [Reference Antonelli2]. Other well-known quantifiers, such as the so-called Härtig quantifier and the Chang quantifier, are easily definable in $\mathsf {FO}(\#)$ (see, e.g., [Reference Peters and Westerståhl100]). It will be convenient to abbreviate the Härtig quantifier $(\#_x\varphi \succsim \#_y\psi ) \wedge (\#_y\psi \succsim \#_x\varphi )$ by $\#_x\varphi \approx \#_y \psi $ ; likewise, we abbreviate $(\#_x\varphi \succsim \#_y\psi ) \wedge \neg (\#_y\psi \succsim \#_x\varphi )$ by $\#_x\varphi \succ \#_y \psi $ .

Typical of extensions of first-order logic, we have the following:

Proposition 2.1. $\mathsf {FO}(\#)$ fails to be compact and it lacks the Löwenheim–Skølem property down to any cardinality below $\aleph _{\omega }$ .

Proof First, note that the infinity quantifier is easily definable in $\mathsf {FO}(\#)$ :

(2.1)

where the substitution is defined as usual. Then we can force the domain to have size at least $\aleph _k$ simply by stating, for instance, $\exists ^\infty x. P_0(x) \wedge \bigwedge _{i \leq k}\big (\#_x P_{i+1}(x) \succ \#_x P_i(x)\big )$ , for $k+1$ predicate symbols $P_0,\dots ,P_k$ .

Compactness also fails easily: abbreviating $\bigwedge _{i,j \leq n} x_i\neq x_j$ by $\mathsf {diff}(\mathbf {x})$ , and using $\exists ^{\geq n}x.P(x)$ to abbreviate $\exists x_1\dots x_{n}.\big (\mathsf {diff}(\mathbf {x}) \wedge \bigwedge _{i \leq n} P(x_i) \big )$ , the set

(2.2) $$ \begin{align} \{\neg \exists^\infty x. P(x)\} \cup \{ \exists^{\geq n}x.P(x): n < \omega \} \end{align} $$

is unsatisfiable, but finitely satisfiable.

To see just how much stronger $\mathsf {FO}(\#)$ is than ordinary $\mathsf {FO}$ , note the following:

Fact 2.2. We can enforce in $\mathsf {FO}(\#)$ that a binary relation R is a well-order of order type $\omega $ .

Proof Let $\sigma $ be the statement that R is a serial, strict total order (i.e., serial, irreflexive, transitive, total), and conjoin $\sigma $ with the statement $\forall x. \neg \exists ^{\infty } y. R(y,x)$ , saying that each element has only finitely many R-predecessors.

It follows that the validity problem for $\mathsf {FO}(\#)$ is not arithmetical; in fact it is $\Pi ^1_1$ -hard. If we do not allow embedding $\#$ comparisons, then we can also show that the satisfiability problem is in $\Sigma ^1_1$ : every comparison amounts to the existence of an injective function.

Fact 2.3. The set of validities of $\mathsf {FO}(\#)$ without embedded $\#$ terms is $\Pi ^1_1$ -complete.

However, for the general case the situation is much worse. Herre et al. [Reference Herre, Krynicki, Pinus and Väänänen56] showed the following result for first-order logic with the Härtig quantifier:Footnote 1

Theorem 2.4 [Reference Herre, Krynicki, Pinus and Väänänen56].

The set of validities of $\mathsf {FO}(\#)$ is neither in $\Pi ^1_2$ nor in $\Sigma ^1_2$ .

$\mathsf {FO}(\#)$ clearly brings a potent combination of logical expressive power and explicit count comparison. To what degree can we tease apart the separate contributions of logic and counting in this rich setting? Specifically, how much do $\#$ comparisons add to the counting repertoire native to first-order logic; and vice versa, how much logic could we already extract from counting alone? We begin with the second question.

2.1 From counting to logic

Let us restrict attention to a very small fragment of the language $\mathcal {L}_\#$ described above. Given some variables $\mathsf {Var}$ and predicate symbols $\mathsf {Pred}$ , we only allow two types of atomic formulas and one operation for building complex formulas. Let $\mathcal {L}_\#^-$ be generated by the grammar:

$$ \begin{align*} \varphi ::= P(x_1,\dots,x_n) \quad\mid\quad x\neq y \quad\mid\quad \#_x\varphi \succsim \#_y\varphi. \end{align*} $$

Aside from predication and variable inequality, we can only compare cardinalities.

A first observation is that Boolean implication can already be defined in $\mathcal {L}_\#^-$ . Where x occurs free in neither $\varphi $ nor $\psi $ , we can take

(2.3) $$ \begin{align} \psi \rightarrow \varphi \equiv \#_x\varphi \succsim \#_x\psi. \end{align} $$

Boolean negation can also be defined. Where $\mathsf {0}$ is an abbreviation for the formula $\#_x (x \neq x)$ (cf. Frege), and again x is a variable that does not occur free in $\varphi $ , we can define

(2.4) $$ \begin{align} \neg \varphi \equiv \mathsf{0} \succsim \#_x\varphi. \end{align} $$

With these we recover any other Boolean connective, as well as variable equality. In some respect, count comparison already incorporates Boolean structure, and familiar Boolean laws emerge as principles of count comparisons. For instance, the pattern $\varphi \rightarrow (\psi \rightarrow \varphi )$ is encoded simply as $\#_x(\#_x\varphi \succsim \#_x\psi ) \succsim \#_x\varphi $ .

Going further, first-order quantification is expressible in $\mathcal {L}_\#^-$ :

(2.5) $$ \begin{align} \exists x. \varphi \equiv \#_x\varphi \succ \mathsf{0}. \end{align} $$

This thus brings us back to full $\mathsf {FO}(\#)$ , in which we can again define the infinity quantifier $\exists ^\infty $ in (2.1), its dual $\forall ^\infty $ , and so on. From rather austere (atomic) primitives, count comparisons already encode a significant amount of logic, provided of course that we allow iteration of comparisons within comparisons.

Remark 2.5 (Extended logical vocabulary).

Counting can also define non-first-order quantifiers that are often considered logical in an extended sense. An example is the binary quantifier ‘Most $\varphi $ are $\psi $ ’, which is definable as $\#_x(\varphi \land \psi ) \succ \#_x(\varphi \land \neg \psi )$ . But even closer to first-order logic, counting suggests different kinds of universal quantifiers, depending on how we extend the standard meaning on finite sets to infinite ones. One option is $\neg \exists x. \neg \varphi $ , the dual of the existential quantifier defined in (2.5), which expresses exceptionless universal quantification. But there are also interesting weaker variants, such as $\#_x\varphi \approx \#_x\top \wedge \#_x\varphi \succ \#_x\neg \varphi $ . This says that the set of objects satisfying $\varphi $ has the size of the universe, while the possible exceptions have a smaller size. This is a version of the quantifier ‘almost all’ which has elegant mathematical properties and interesting measure-theoretic applications [Reference Steinhorn, Harrington, Morley, Svêdrov and Simpson122].

Remark 2.6 (Non-classical logics).

In addition to options qua expressive power, counting also offers options for deductive power. The definitions (2.3)–(2.5) show that we can reconstruct classical logic from $\#$ comparisons. Is $\mathsf {FO}(\#)$ in some way inherently classical, or could we instead naturally extract non-classical connectives?

One route would be to keep the same implication in (2.3), but to redefine negation in terms of an arbitrary predicate, say, $G(x)$ . If we then let $\neg \varphi $ stand for the sentence $\#_xG(x) \succsim \#_x\varphi $ , where again x is not free in $\varphi $ , we lose one direction of the law of double negation, namely, $\neg \neg \varphi \rightarrow \varphi $ , while the other direction remains valid. We retain the converse of contraposition, $(\varphi \rightarrow \psi ) \rightarrow (\neg \psi \rightarrow \neg \varphi )$ , while losing the contraposition formula, $(\neg \psi \rightarrow \neg \varphi ) \rightarrow (\varphi \rightarrow \psi )$ . The resulting logic has some intuitionistic flavor, which would be worth determining exactly.

A more dramatic route to non-classical logics would be to change the semantics of $\#$ terms altogether. We explore this route further in Section 8.

2.2 From logic to counting

While pure $\mathsf {FO}$ is also capable of encoding facts about counting and arithmetic, it is far less extensive. As already mentioned, first-order logic can define the simple counting quantifiers like $\exists ^{\geq n}x$ ; however, first-order logic does so by means of counting in the syntax. That is, the formula expressing that there are at least n objects satisfying a given condition achieves this by concatenating n existential quantifiers and adding n conjuncts. Basic arithmetic principles like $\exists ^{\geq m}x.\varphi \rightarrow \exists ^{\geq n}x.\varphi $ for $m\geq n$ , thus follow from elementary logical patterns like distribution of existential quantification over conjunction, applied the requisite number of times (e.g., $m-n$ times). This style of counting in the syntax also produces a case-by-case formulation of the Pigeonhole Principle:Footnote 2

Example 2.7. Suppose we have k monadic predicate symbols $P_1,\dots ,P_k$ and let $n>k$ . Then,

(2.6) $$ \begin{align} \big( \exists^{= n}x. \bigvee_{i \leq k} P_i(x) \wedge \forall x. \bigwedge_{i \neq j} \neg (P_i(x) \wedge P_j(x)) \big)\rightarrow \bigvee_{i \leq k} \exists^{\geq 2}x. P_i(x) \end{align} $$

says that if these k predicates together include n objects, then at least one must include at least two objects. This schema is of course valid for every choice of k and $n>k$ .

We will see more examples of counting in the syntax with subsequent sections (see especially Remark 9.15 and Appendix E).

Remark 2.8. The fact that $\mathsf {FO}$ can only count in the syntax reverberates in interesting ways when we consider finite variable fragments of $\mathsf {FO}$ . While the two-variable fragment is known to have the (bounded) finite-model property [Reference Mortimer89], which in turn establishes its decidability, this fragment with counting quantifiers $\exists ^{\geq n}$ can easily enforce infinite models:

$$ \begin{align*}\forall x. \exists^{=1}y. R(x,y) \wedge \forall y .\exists^{\leq 1} x. R(x,y) \wedge \exists y. \forall x. \neg R(x,y) .\end{align*} $$

Such a language is in fact decidable [Reference Grädel, Otto and Rosen45]: like the two-variable fragment without counting, its satisfiability problem is NExpTime-complete [Reference Pratt-Hartmann103]. However, the complexity analysis of this system and its extensions [Reference Kieroński, Pratt-Hartmann and Tendera69] reveals arithmetical content that does not appear in analyses of the plain two-variable fragment, witness connections to integer programming (Section 3.2.1) and to semi-linear sets (Section 4.1).

2.3 Finite models

It is natural to consider a related system in the same language, but with interpretations restricted to finite models. Call such a system $\mathsf {FO}^\phi (\#)$ . As $\mathcal {L}_\#$ extends the language of first-order logic, Trakhtenbrot’s theorem tells us that the validities of $\mathsf {FO}^\phi (\#)$ are still not computably enumerable. Nonetheless, $\mathsf {FO}^\phi (\#)$ and variations on it have also been intensely studied in the literature on finite model theory. See, e.g., [Reference Otto98] or [Reference Schweikardt116] for summaries of relevant work.

As an example of distinctive issues that come up in the finitary setting, one might ask about the asymptotic probabilities of formulas in $\mathsf {FO}^\phi (\#)$ over finite structures. It was shown in [Reference Grumbach and Tollu48] that $\mathsf {FO}$ with the Härtig quantifier in fact possesses a zero–one law, just as pure $\mathsf {FO}$ does. As possession of a zero–one law is commonly interpreted as evidence that a logic cannot formalize any non-trivial counting, this can be taken as justification for our choice of comparison rather than equality as a primitive. Indeed, $\mathsf {FO}^\phi (\#)$ lacks a zero–one law; e.g., $\#_x P(x) \succsim \#_x \neg P(x)$ has asymptotic probability $1/2$ . It is conjectured in [Reference Grumbach and Tollu48] that (an extension of) $\mathsf {FO}^\phi (\#)$ nonetheless possesses a limit law, and that the limits are all rational numbers between $0$ and $1$ .

For many purposes in finite model theory (e.g., descriptive complexity) authors have been motivated to consider proper extensions of our language $\mathcal {L}_\#$ , a notable example being fixed point logic with counting [Reference Cai, Fürer and Immerman22]. Our purpose here is different: we aim to isolate weaker fragments of this language that might further reveal the subtle interplay between logic and counting, also pinpointing differences and commonalities between finitary and infinitary patterns in counting.

2.4 Fragments of $\mathcal {L}_\#$

While full first-order logic with counting may be a natural starting point for exploring our subject, the above observations invite the search for natural fragments and weaker variants of $\mathsf {FO}(\#)$ . It may be desirable, for example, to identify decidable fragments of $\mathcal {L}_\#$ . From this perspective it is noteworthy that some familiar ways of taming complexity are less effective here. For example, finite-variable fragments do not result in decidability: as shown by Grädel et al. [Reference Grädel, Otto and Rosen46], the two-variable fragment of $\mathsf {FO}(\#)$ is still undecidable ( $\Pi ^1_1$ -complete, so we do observe a reduction in complexity, compared to Theorem 2.4). The two-variable fragment of $\mathsf {FO}^\phi (\#)$ is also undecidable. Evidently, a significant source of the complexity is the potent combination of counting and arbitrary quantificational-relational reasoning, witness Lemma 2.2. The undecidability proof in [Reference Grädel, Otto and Rosen46] for the two-variable fragment crucially involves counting successors along binary relations.

A more dramatic route would be to move to a much tamer syllogistic or propositional fragment [Reference Ding, Harrison-Trainor and Holliday32, Reference Moss and Bimbó91]. For instance, if we let $\mathcal {L}_\#^0$ be the language of propositional logic with count comparisons, the resulting system $\mathsf {PL}(\#)$ is easily shown to be decidable (e.g., it will follow immediately from our results below). This route at once eliminates relational reasoning and first-order quantification.

An alternative route is to put relational reasoning to the side, but still retain first-order quantification. The monadic fragment of $\mathcal {L}_\#$ , which we will call $\mathcal {L}_\#^1$ , does not allow counting along relations, but it otherwise preserves the counting content of $\mathsf {FO}(\#)$ . Observe, for example, that our definition of the infinity quantifier in (2.1) and our reconstruction of logical connectives from count comparisons (Section 2.1) depend in no way on the arity of available predicates. We will thus use $\mathsf {MFO}(\#)$ , monadic first-order logic with counting, as a base system to explore richer combinations (Section 3). In this context we will consider adding second-order quantification (system $\mathsf {MSO}(\#)$ in Section 4), as well as the ability to count not just individuals but sequences of individuals (systems $\mathsf {MFO}(\sharp )$ and $\mathsf {MSO}(\sharp )$ in Section 5).

Of course, counting along relations is also common and natural. We therefore explore a tractable modal fragment of $\mathcal {L}_\#$ , which we call $\mathcal {L}_\#^{\mathsf {ml}}$ , as a way of taming the interaction among counting, quantification, and relational reasoning. A summary appears in Table 1.

Table 1 A hierarchy of counting languages and logics, covered in Sections 2-7. For each logical system $\mathsf {L}(\#)$ we also have a version $\mathsf {L}^\phi (\#)$ , where we restrict to finite models. In these systems terms can only denote natural numbers

Following this work we consider a different route altogether, namely changing the semantics of $\mathcal {L}_\#$ . Relaxing either the logical interpretation (relativizing to sets of ‘admissible’ variable assignments; cf. [Reference Németi, Marx, Masuch and Pólos96]) or the numerical content of the $\#$ terms again results in systems that retain much of the character of $\mathsf {FO}(\#)$ , while gaining in tractability.

3 Monadic first-order counting logic

The system $\mathsf {MFO}(\#)$ of monadic first-order logic with identity and cardinality comparisons, though restricted in its expressive power, still captures a good deal of the natural reasoning mentioned in our Introduction. It is easy to see that numerical syllogisms can be represented, and so can simple comparative reasoning with quantifiers like ‘most’. But $\mathsf {MFO}(\#)$ can also represent the earlier more complex inference

$$ \begin{align*}\begin{array}{@{}lll@{}} \mbox{from } & \mbox{`More }A\mbox{ than }B\mbox{ are }C\mbox{'} \quad & (\#_x\big(A(x) \wedge C(x)\big) \succ \#_x \big(B(x) \wedge C(x)\big))\\ \mbox{and} & \mbox{`More }B\mbox{ than }C\mbox{ are }A\mbox{'} \quad & (\#_x\big(B(x) \wedge A(x)\big) \succ \#_x \big(C(x) \wedge A(x)\big))\\ \mbox{to } & \mbox{`More }A\mbox{ than }C\mbox{ are }B\mbox{'} \quad & (\#_x\big(A(x) \wedge B(x)\big) \succ \#_x \big(C(x) \wedge B(x)\big)). \end{array}\end{align*} $$

The underlying Venn diagram-style reasoning will be analyzed more generally below.

Beyond the basic linguistic inference repertoire, $\mathsf {MFO}(\#)$ can also represent some of what we called ‘grassroots mathematics’. Note, for instance, that Example 2.7 encoding the Pigeonhole Principle only involved monadic predicates (and in fact did not even need $\#$ -terms). In $\mathsf {MFO}(\#)$ we can also express a natural infinitary generalization:

(3.1) $$ \begin{align} \left( \exists^{\infty}x. \bigvee_{i \leq k} P_i(x) \wedge \forall x. \bigwedge_{i \neq j} \neg (P_i(x) \wedge P_j(x)) \right)\rightarrow \bigvee_{i \leq k} \exists^{\infty}x. P_i(x), \end{align} $$

stating that infinitely many objects in finitely many disjoint boxes (‘pigeonholes’) must result in at least one box having infinitely many objects.

We will now look more systematically at what this monadic counting logic can express. Suppose $\mathsf {Pred} = \{P_1,\dots ,P_n\}$ is finite, and list the $2^n$ possible state-descriptions over $\mathsf {Pred}$ as $S_1,\dots ,S_{2^n}$ , so that each $S_i(x)$ is of the form $\bigwedge _{j \in J} P_j(x) \wedge \bigwedge _{j \notin J} \neg P_j(x)$ . Call the extension of a state-description $S_i$ in a model a region. In $\mathcal {L}_\#^1$ we can easily state count comparisons between regions. A count comparison, such as a statement $\#_x S_i(x) \succsim \#_xS_j(x)$ , can be succinctly written with numerical variables replacing cardinalities: $\mathsf {s}_i \geq \mathsf {s}_j$ . As the $S_i$ are pairwise disjoint we can more generally encode constraints involving sums of (cardinalities of) regions by disjunctions of state-descriptions. For instance, a sentence like $\#_x \bigvee _{i} S_i(x) \succsim \#_x \bigvee _j S_j(x)$ encodes a typical linear inequality between sums of variables $\mathsf {s}_1,\dots ,\mathsf {s}_{2^n}$ :

(3.2) $$ \begin{align} \sum_{i} \mathsf{s}_i \geq \sum_j \mathsf{s}_j. \end{align} $$

By closing under Booleans we can of course express equality and strict inequality versions of (3.2). When restricting to finite models call the resulting logical system $\mathsf {MFO}^\phi (\#)$ . In this case ‘solutions’ to such (in)equations will always be natural numbers. However, if we allow models of arbitrary cardinality, then solutions may involve infinite cardinal numbers. This is the system that we call $\mathsf {MFO}(\#)$ .

How much more can we express in $\mathsf {MFO}^\phi (\#)$ or $\mathsf {MFO}(\#)$ than the simple linear inequalities in (3.2)? We have already seen an instructive example in the formula (2.1) defining the infinity quantifier. The encoding of $\exists ^\infty x. S(x)$ for a state description S is essentially an inequality statement $\mathsf {s} \geq \mathsf {s}+1$ . The use of individual variables here is an instance of a more general pattern, also relevant in the finite case. Indeed, everything we say in the present section will apply equally to $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ .

As above, consider two non-overlapping sets $T_1=\{S_i\}_i$ , $T_2=\{S_j\}_j$ of state-descriptions, whose respective cardinalities we will label $\{\mathsf {s}_i\}_{i}$ and $\{\mathsf {s}_j\}_j$ . Then we can encode not only inequalities like those in (3.2), but also those such as

(3.3) $$ \begin{align} \sum_{i} \mathsf{s}_i = \sum_j \mathsf{s}_j + k, \end{align} $$
(3.4) $$ \begin{align} \sum_{i} \mathsf{s}_i> & \sum_j \mathsf{s}_j + k. \end{align} $$

For instance, to express (3.3) we can assert the existence of k distinct objects $\mathbf {y}$ all of which satisfy one of the $T_1$ , such that ‘removing’ these elements from the regions spanned by $T_1$ results in the same cardinality as the regions spanned by $T_2$ :

$$ \begin{align*} \exists \mathbf{y}.\Big( \mathsf{diff}(\mathbf{y}) \wedge \bigwedge_{y \in \mathbf{y}} T_1(y) \wedge \#_x\big(\bigwedge_{y \in \mathbf{y}} x \neq y \wedge T_1(x)\big) \approx \#_xT_2(x)\Big). \end{align*} $$

Here $T_1(y)$ is shorthand for $\bigvee _i S_i(y)$ , and similarly for $T_2(x)$ .

Meanwhile (3.4) is expressed by replacing the equality with a strict inequality. In fact, with k variables $\mathbf {y}$ (in addition to the variable x used in the count comparisons) we can already encode (3.3) and (3.4) with a constant $2k$ , simply by taking these variables $\mathbf {y}$ and ‘adding’ them to the regions spanned by the $T_2$ (see Figure 1 for visualization):

(3.5) $$ \begin{align} \exists \mathbf{y}.\Big( \mathsf{diff}(\mathbf{y}) \!\wedge\! \bigwedge_{y \in \mathbf{y}} T_1(y) \!\wedge\! \#_x\big(\bigwedge_{y \in \mathbf{y}} x \neq y \!\wedge\! T_1(x)\big) \approx \#_x\big( \bigvee_{y \in \mathbf{y}} x = y \vee T_2(x)\big)\Big). \end{align} $$

We are effectively stating that $|T_1| \geq k$ , and that $|T_1|-k = |T_2|+k$ ; in other words, $|T_1| = |T_2|+2k$ . Again, the same argument extends to inequality statements.

Figure 1 A visualization of the formula expressing that the number of P points (darkly shaded) is exactly $2k$ greater than the numbers non-P points (lightly shaded), where k is the size of the ‘extracted’ set of P points (i.e., the size of $\mathbf {y}$ ).

3.1 Some core principles

Both systems, $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ , are evidently invariant under automorphisms. In the monadic setting automorphisms are precisely the maps that permute elements within a region: all the points that satisfy a given state-description are indistinguishable. This means that if a property holds for one point in a region, it holds for every point in that region. This theme of permutation invariance is characteristic of counting, and it will return when we discuss generalized quantifiers in Section 9.

As demonstrated above, use of individual variables essentially allows manipulating regions—removing or adding points. We can correspondingly state a more general invariance principle. Fix some variables $\mathbf {y}$ and a fixed (finite) set $\mathbf {P}$ of predicate letters, and let $\alpha ^{\mathbf {y}}(x)$ specify a state-description for x as well as which of the variables $\mathbf {y}$ are (un)equal to x. Then, for any formula $\varphi $ (in predicates $\mathbf {P}$ ), if there is at least one x satisfying $\alpha ^{\mathbf {y}}$ and $\varphi $ , then every x satisfying $\alpha ^{\mathbf {y}}$ also satisfies $\varphi $ . Codified in a general invariance principle:

(INV) $$\begin{align} \exists x.\big(\alpha^{\mathbf{y}}(x) \wedge \varphi(x)\big) \rightarrow \#_x\big(\alpha^{\mathbf{y}}(x) \wedge \varphi(x)\big) \approx \#_x\big(\alpha^{\mathbf{y}}(x)\big). \end{align} $$

Since either none of the $\alpha $ ’s satisfy $\varphi $ or all of them do, once we have specified $\alpha $ in a count formula, reference to $\varphi $ becomes redundant. In fact, ( INV ) follows from an even stronger statement (that is, stronger provided we admit infinite models):

(INV2) $$\begin{align} \#_x\big(\alpha^{\mathbf{y}}(x) \wedge \varphi(x)\big) \succ \mathsf{0} \rightarrow \#_x\big(\alpha^{\mathbf{y}}(x) \wedge \neg \varphi(x) \big) \approx \mathsf{0}. \end{align}$$

A related observation about terms $\#_x\varphi $ is that subformulas of $\varphi $ that do not involve x do not contribute any fine-grained information to the term’s denotation. If the free variables of $\psi $ are not among the bound variables of $\#_x\varphi $ , then the following is valid:

(SUB)

Here is the result of substituting $\beta $ for every occurrence of $\gamma $ in $\alpha $ .

3.2 Normal forms

The principles recorded in ( INV ) and ( SUB ), together with basic propositional reasoning and a few other elementary principles (see Section 3.4 for the others), allow the derivation of a normal form result, which works uniformly for $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ . As a first step, we can show that any formula is equivalent to one with no embedded $\#$ -terms or quantifiers within $\#$ -terms, as these terms can always be replaced by unembedded existential quantifiers. This is already a dramatic departure from full relational $\mathsf {FO}(\#)$ , where embedding is non-trivial. (Recall that $\mathsf {FO}(\#)$ with no embedded count comparisons was $\Pi ^1_1$ -complete, in stark contrast to Theorem 2.4.)

Define depth $\mathsf {d}(\varphi )$ by recursion, with $\mathsf {d}(\alpha ) = 0$ for $\alpha $ atomic, $\mathsf {d}(\varphi \wedge \psi ) = \mbox {max}(\mathsf {d}(\varphi ),\mathsf {d}(\psi ))$ , $\mathsf {d}(\neg \varphi ) = \mathsf {d}(\varphi )$ , while $\mathsf {d}(\#_x\varphi \succsim \#_y\psi ) = \mbox {max}(\mathsf {d}(\varphi ),\mathsf {d}(\psi ))+1$ and $\mathsf {d}(\exists x. \varphi ) =\mathsf {d}(\varphi )+1$ .

Generically, a monadic formula with free variables $\mathbf {y},x$ can be written in disjunctive normal form $\bigvee _i \big (\alpha _i(\mathbf {y}) \wedge \alpha ^{\mathbf {y}}_i(x) \wedge \varphi _i(\mathbf {y},x)\big )$ , where $\alpha _i(\mathbf {y})$ specifies state-descriptions for $\mathbf {y}$ and which of these variables are (un)equal, $\alpha ^{\mathbf {y}}_i(x)$ is as in the previous subsection, and $\varphi _i(\mathbf {y},x)$ is some other formula that may in general have positive depth. We want to show that any formula

$$ \begin{align*} \#_x\bigvee_{i\in I} \big(\alpha_i(\mathbf{y}) \wedge \alpha^{\mathbf{y}}_i(x) \wedge \varphi_i(\mathbf{y},x)\big)\succsim \#_x\bigvee_{j\in J} \big(\alpha_j(\mathbf{y}) \wedge \alpha^{\mathbf{y}}_j(x) \wedge \varphi_j(\mathbf{y},x)\big)\end{align*} $$

is equivalent to one with no embedded count comparisons or quantifiers. In other words this formula is equivalent to one of depth $1$ . First, by ( SUB ) we can take the subformulas $\alpha _i(\mathbf {y}),\alpha _j(\mathbf {y})$ outside the count comparisons, which leaves

$$ \begin{align*} \#_x\bigvee_{i\in I} \big(\alpha^{\mathbf{y}}_i(x) \wedge \varphi_i(\mathbf{y},x)\big) \succsim \#_x\bigvee_{j\in J} \big( \alpha_j^{\mathbf{y}}(x) \wedge \varphi_j(\mathbf{y},x)\big) \end{align*} $$

to analyze. Let $\kappa _k$ range over formulas $\exists x.\big (\alpha _k^{\mathbf {y}}(x) \wedge \varphi _k(\mathbf {y},x)\big )$ for $k \in I \cup J$ . Then by appeal to ( INV ), we have the equivalent formula:

$$ \begin{align*} \bigvee_{K \subseteq I \cup J}\big(\bigwedge_{k \in K}\kappa_k \wedge \bigwedge_{k \notin K} \neg \kappa_k \wedge \#_x\bigvee_{i\in I\cap K} \alpha^{\mathbf{y}}_i(x) \succsim \#_x\bigvee_{j\in J \cap K} \alpha_j^{\mathbf{y}}(x) \big) \end{align*} $$

Note that we have traded one level of $\#$ embedding for one existential quantifier. Since $\alpha _i^{\mathbf {y}},\alpha _j^{\mathbf {y}}$ are of depth $0$ , this concludes the argument for:

Lemma 3.1. Every $\mathcal {L}_\#^1$ formula is equivalent to one in which every count comparison subformula has depth exactly $1$ .

Using Lemma 3.1, the main result of this section is:

Theorem 3.2. Every depth $k+1$ sentence is equivalent, in $\mathsf {MFO}^\phi (\#)$ as well as in $\mathsf {MFO}(\#)$ , to a disjunction of conjunctions of sentences specifying $T_1 = T_2 +m$ or $T_1> T_2+m$ , for $T_1,T_2$ sums of $($ cardinalities of $)$ state-descriptions, and $m\leq 2k$ .

Proof We show more generally that a formula of depth $k+1$ over predicates $\mathbf {P}$ with free variables $\mathbf {y} = y_1,\dots ,y_n$ is equivalent to a disjunction

(3.6) $$ \begin{align} \bigvee\big(\alpha(\mathbf{y})\wedge(\sigma)_{\alpha(\mathbf{y})}\big), \end{align} $$

where $\alpha (\mathbf {y})$ ranges over possible descriptions of $\mathbf {y}$ , and $\sigma $ is a complete description of the regions over $\mathbf {P}$ , i.e., specifying $T_1 {\kern-1pt}={\kern-1pt} T_2 {\kern-1pt}+{\kern-1pt}m$ or $T_1{\kern-1pt}>{\kern-1pt} T_2+m$ for all $m\leq 2(n+k)$ . The notation $(\sigma )_{\alpha (\mathbf {y})}$ denotes a formula that specifies the description $\sigma $ on the assumption of $\alpha (\mathbf {y})$ . In other words, we claim that for each disjunct of (3.6), for all variable assignments s,

(3.7) $$ \begin{align} \mathcal{M},s \vDash \alpha(\mathbf{y}) \wedge (\sigma)_{\alpha(\mathbf{y})} \Rightarrow \mathcal{M}\mbox{ satisfies the }2(n+k)\mbox{ description }\sigma. \end{align} $$

The statement in the theorem will be the special case of (3.6) with no free variables ( $n=0$ ).

Example 3.3. For an example of such a disjunct over one predicate letter P, see the formula inside the existential quantifier in Figure 1. This formula has k free variables and depth $1$ . Here $\alpha (\mathbf {y})$ is the formula $\mathsf {diff}(\mathbf {y}) \wedge \bigwedge _{i \leq k} P(y_i)$ , while $(\sigma )_{\alpha (\mathbf {y})}$ is the count comparison. Note that $(\sigma )_{\alpha (\mathbf {y})}$ has free variables and it ‘means’ that $|P| = |\neg P| + 2k$ provided $\alpha (\mathbf {y})$ holds.

To show that depth $k+1$ formulas are always equivalent to formulas (3.6) satisfying (3.7), we proceed by inducting on k, starting with the case of depth $1$ formulas ( $k=0$ ) in free variables $\mathbf {y}=y_1,\dots , y_n$ . The critical case is a count comparison:

$$ \begin{align*}\#_x \bigvee \alpha(\mathbf{y},x) \succsim \#_x \bigvee \beta(\mathbf{y},x). \end{align*} $$

As before, by ( SUB ) we can separate out the descriptions of $\mathbf {y}$ to obtain a formula

(3.8) $$ \begin{align}\bigvee \big(\gamma(\mathbf{y}) \wedge \#_x\bigvee \alpha^{\mathbf{y}}(x) \succsim \#_x\bigvee\beta^{\mathbf{y}}(x) \big), \end{align} $$

where we have a $\gamma (\mathbf {y})$ disjunct exactly when $\gamma (\mathbf {y}) = \alpha (\mathbf {y}) = \beta (\mathbf {y})$ ; that is, all disjuncts inside the $\#$ terms must agree on the characterization of variables  $\mathbf {y}$ . It is then straightforward to check, by considering all cases, that the count comparison in each disjunct of (3.8), in context $\gamma (\mathbf {y})$ , asserts $T_1 = T_2 +m$ or $T_1> T_2+m$ for $m\leq 2n$ (or a disjunction of such comparisons). So this fits the form in (3.6), and (3.7) is satisfied.

In general, the normal forms (3.6) for a fixed k and n are closed under Boolean combinations, so we only need to consider the case of depth $k+1$ and n variables. By Lemma 3.1 we can assume all count comparison subformulas have depth $1$ , so it suffices to consider an existential quantification, which by induction we assume is

$$ \begin{align*} \exists z. \bigvee \big( \alpha(\mathbf{y},z) \wedge (\sigma)_{\alpha(\mathbf{y},z)}\big). \end{align*} $$

Such a formula will be equivalent to

$$ \begin{align*}\bigvee \exists z. \big(\alpha(\mathbf{y},z) \wedge (\sigma)_{\alpha(\mathbf{y},z)}\big)\end{align*} $$

and indeed to

(3.9) $$ \begin{align} \bigvee \Big(\alpha(\mathbf{y}) \wedge \exists z. \big(\alpha^{\mathbf{y}}(z) \wedge (\sigma)_{\alpha(\mathbf{y},z)}\big)\Big). \end{align} $$

It remains to be seen that (3.9) is of the form (3.6) with each disjunct satisfying (3.7). By the inductive assumption we know that for any s, if $\mathcal {M},s \vDash \alpha (\mathbf {y},z) \wedge (\sigma )_{\alpha (\mathbf {y},z)}$ , then $\mathcal {M}$ satisfies the $2(n+k)$ description $\sigma $ . But if $\mathcal {M},s \vDash \alpha (\mathbf {y}) \wedge \exists z. \big (\alpha ^{\mathbf {y}}(z) \wedge (\sigma )_{\alpha (\mathbf {y},z)}\big )$ , then there is a z-variant $s'$ of s such that $\mathcal {M},s' \vDash \alpha (\mathbf {y},z) \wedge (\sigma )_{\alpha (\mathbf {y},z)}$ , which establishes the result.

3.2.1 Connection to integer programming

As with ordinary monadic first-order logic, putting a sentence into normal form may result in a significantly longer formula. The satisfiability problem for monadic first-order logic (as for the two-variable fragment) is NExpTime-complete [Reference Lewis80], even though checking satisfiability of normal forms is in NP. As with monadic logic, checking satisfiability of a normal form in $\mathsf {MFO}^\phi (\#)$ is of relatively low complexity. In fact, it is of the same complexity. A set of (in)equalities of types (3.3) and (3.4) give us an integer program, whose solvability is known to be decidable in NP-time [Reference Borosh and Treybig18]. Meanwhile, the special case of integer programming in which all coefficients are $1$ or $0$ —in other words, the special case of inequalities like those in (3.2)—was already included in Karp’s [Reference Karp, Miller, Thatcher and Bohlinger67] original list of NP-complete problems. With this lower bound we can conclude that the satisfiability problem for normal forms in $\mathsf {MFO}^\phi (\#)$ is NP-complete.

3.3 Questions of definability

Theorem 3.2 affords a refined understanding of the numerical relations that can be defined in $\mathsf {MFO}^\phi (\#)$ , as well as $\mathsf {MFO}(\#)$ . Where T is a set of state-descriptions, let $|T|_{\mathcal {M}}$ denote the sum of cardinalities of extensions in $\mathcal {M}$ of state-descriptions in T. We will say that $\mathcal {M} \sim _k \mathcal {M}'$ if for all $T_1,T_2$ and all $m \leq k$ ,

$$ \begin{align*} |T_1|_{\mathcal{M}} \geq |T_2|_{\mathcal{M}} + m \quad \mbox{iff}\quad |T_1|_{\mathcal{M}'} \geq |T_2|_{\mathcal{M}'} + m \end{align*} $$

Then, where $\mathcal {M} \equiv _k \mathcal {M}'$ signifies that $\mathcal {M}$ and $\mathcal {M}'$ agree on all sentences up to depth k, Theorem 3.2 immediately gives:

Corollary 3.4. $\mathcal {M} \sim _{2k} \mathcal {M'}$ iff $\mathcal {M} \equiv _{k+1} \mathcal {M}'$ .

As an initial example, we can characterize precisely the binary logical quantifiers definable in $\mathsf {MFO}^\phi (\#)$ (see Section 9 for a proof, and for further discussion of generalized quantifiers):

Theorem 3.5. The binary quantifiers definable in $\mathsf {MFO}^\phi (\#)$ correspond exactly to those expressible in the first-order theory of $\langle \mathbb {N};>\rangle $ .

This includes many of the standard logical quantifiers: ‘most’, ‘all’, ‘some’, ‘all but one’, ‘at least two’, etc. The following gives an example of a statement that cannot be expressed.

Fact 3.6. ‘There are twice as many Ps as Qs’ cannot be expressed in $\mathsf {MFO}^\phi (\#)$ .

Proof Supposing it could, such a sentence would have some depth $k+1$ . In light of Corollary 3.4, it suffices to show that, for any k, we can find $\mathcal {M},\mathcal {M}'$ that disagree on the statement and yet $\mathcal {M} \sim _{2k} \mathcal {M}'$ . Define a first model $\mathcal {M}$ with $9k$ elements, such that $|P^{\mathcal {M}}| = 6k$ while $|Q^{\mathcal {M}}| = 3k$ . The statement clearly holds of $\mathcal {M}$ . But now define $\mathcal {M'}$ with $9k+1$ elements, such that $|P^{\mathcal {M}'}| = 6k+1$ and again $|Q^{\mathcal {M}'}| = 3k$ . The statement fails in $\mathcal {M}'$ , yet $\mathcal {M} \sim _{2k} \mathcal {M}'$ .

For a second example, consider a natural rendering of the natural language expression ‘many’, often taken to refer to a number above some contextual threshold. On a more sophisticated, but not uncommon, reading (cf. [Reference Rett111, Reference Westerståhl128]), ‘Many Qs are P’ amounts to a comparison between the proportion of Ps among the Qs and the proportion of Ps overall, which we might symbolize as

(3.10) $$ \begin{align} \frac{\#_x\big(P(x) \wedge Q(x)\big)}{\#_x Q(x)} \succ \frac{\#_x P(x)}{\#_x \top}. \end{align} $$

Fact 3.7.Many Qs are P’ cannot be expressed in $\mathsf {MFO}^\phi (\#)$ .

Proof Again, for any k, we must find two models $\mathcal {M},\mathcal {M}'$ that disagree on the statement and yet $\mathcal {M} \sim _{2k} \mathcal {M}'$ . It suffices to specify the cardinalities of four regions within the model: $p = |P \cap \overline {Q}|$ , $q = |Q \cap \overline {P}|$ , $r = |P \cap Q|$ , $s = |\overline {P \cup Q}|$ .

In both models let $r=k$ , $q=3k$ , and $p=4k$ . In $\mathcal {M}$ let $s = 15k$ , while in $\mathcal {M}'$ let $s=11k$ . In both cases $s> p+q+r+2k$ , and this is the crucial case to establish that $\mathcal {M} \sim _{2k} \mathcal {M}'$ , and $\mathcal {M} \equiv _{k+1} \mathcal {M}'$ . However, in $\mathcal {M}$ we have $\frac {r}{r+q}> \frac {p+r}{p+q+r+s}$ , while in $\mathcal {M}'$ the inequality fails.

We will return to more analysis of natural language constructions in Section 9. Note that Corollary 3.4 can be used to derive undefinability results in $\mathsf {MFO}(\#)$ as well:

Fact 3.8. The successor function on infinite cardinals is not expressible in $\mathsf {MFO}(\#)$ .

Proof Every two models that agree on the order of cardinalities for infinite definable sets will stand in the relation $\sim _k$ for all k.

3.3.1 Interpolation failure

Another consequence of Theorem 3.2 is a particularly simple normal form result for the ‘letterless’ fragment of $\mathcal {L}_\#^1$ , that is, the fragment with no predicate symbols, built up from atomic formulas $\top $ and $\bot $ . In fact, the normal forms are identical to those for monadic first-order logic with the infinity quantifier [Reference Carreiro, Facchini, Venema and Zanasi24]:

Lemma 3.9. Every letterless sentence is equivalent in $\mathsf {MFO}(\#)$ to a disjunction of formulas having one of the following forms $\exists ^\infty x. \top $ , $\forall ^\infty x. \bot \wedge \exists ^{\geq k} \top $ , or $\exists ^{=k} x. \top $ .

For the restriction $\mathsf {MFO}^\phi (\#)$ to finite models, this simplifies even further to include only statements of the form $\exists ^{>k}.\top $ and $\exists ^{=k} x. \top $ . As a consequence we can show:

Proposition 3.10. Neither $\mathsf {MFO}^\phi (\#)$ nor $\mathsf {MFO}(\#)$ enjoys the interpolation property.

Proof Let $\varphi (P)$ be the formula:

$$ \begin{align*}\forall^\infty x. \bot \wedge \#_x(P(x)) \approx \#_x(\neg P(x)),\end{align*} $$

which is only true in finite models of even sizes. Let $\psi (Q)$ be the formula:

$$ \begin{align*}\exists x.\#_y( y \neq x \wedge Q(y) ) \approx \#_y( y \neq x \wedge \neg Q(y) ),\end{align*} $$

which in finite models requires the domain to be odd. Evidently $\varphi (P) \vDash \neg \psi (Q)$ . Let $\chi $ be a purported interpolant: $\varphi (P) \vDash \chi \vDash \neg \psi (Q)$ . As $\chi $ must be letterless, Lemma 3.9 implies that it must be a disjunction of sentences with one of the three specified forms. Furthermore, as it is entailed by $\varphi (P)$ we can assume that $\exists ^\infty x. \top $ is not a disjunct. A straightforward case analysis shows that $\chi $ must either be true only in models up to some fixed size—in which case it cannot be entailed by $\varphi (P)$ —or it is true in all finite models from some finite size onward—in which case it cannot entail $\neg \psi (Q)$ .

A familiar way of extending a language to guarantee interpolation is to allow second-order quantification. We will turn to such an extension below in Section 4. But first, we analyze the reasoning content of our normal form analysis a bit further.

3.4 Questions of axiomatization

What is the calculus of valid reasoning suggested by our current systems? For both of our basic monadic systems, $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ , we can locate a kind of separation between two components: (a) the general, more ‘logical’ principles that allow our normal form result (Theorem 3.2) and (b) more specific numerical reasoning for solving systems of inequalities. We discuss each component in turn for the system $\mathsf {MFO}^\phi (\#)$ which allows only finite domains. The general system $\mathsf {MFO}(\#)$ involves one more component for dealing with infinite sets that we will remark on at the end.

3.4.1 Step I

The normal form principles underlying our normal form result are as follows:

  1. (a) general validities of propositional and first-order predicate logic,

  2. (b) the two general principles ( INV ) and ( SUB ) highlighted earlier,

  3. (c) the linear order properties of the relation $\succsim $ .

Here the linearity in Principle (c), used in our case distinctions, is worth high-lighting:

(COMP) $$\begin{align} \#_x\varphi \succsim \#_x\psi \vee \#_x\psi \succsim \#_x\varphi. \end{align}$$

The soundness of ( COMP ) in $\mathsf {MFO}(\#)$ depends on the axiom of choice. Indeed, ( COMP ) is equivalent to the axiom of choice [Reference Hartogs55]. Significantly, in the generalized semantics discussed in Section 8, Principles (a) and (b) will remain valid, while the strong reasoning principle (c) is naturally replaced by just the pre-order properties for $\succsim $ .

3.4.2 Step II

As a result of the normal form analysis, we are left with a satisfiability problem for inequalities all of whose variables denote natural numbers. This system can be solved effectively, e.g., using the well-known FourierMotzkin algorithm [Reference Schrijver115, Section 12.2].

At this stage, we might say that we have solved the reasoning problem in the spirit of this paper, having used a simple combination of logic and counting. The above calculus uses logic to reduce a reasoning problem to a numerical one that is most elegantly solved on its own terms. This is precisely the sort of combination that we find natural and insightful.

Remark 3.11. Even so, we could go further in Step III, and determine the exact arithmetical principles that drive the Fourier–Motzkin algorithm. Here is a sketch.

The algorithm works as follows. One picks a variable $\mathsf {s}$ as long as still possible, and then considers one of three cases.

  1. (i) The variable $\mathsf {s}$ occurs only to the right in $\geq$ -inequalities of the system. Then $\mathsf {s}$ can be dropped from all inequalities: setting its value to 0 will always suffice.

  2. (ii) The variable $\mathsf {s}$ occurs only to the left in $\geq$ -inequalities. Then all inequalities where $\mathsf {s}$ occurs can be dropped, since they can be made true at the end by choosing some suitably large value for $\mathsf {s}$ .

  3. (iii) In case $\mathsf {s}$ occurs both to the left and to the right in inequalities, one groups the inequalities of the form $\mathsf {u} \geq \mathsf {s} + \mathsf {v}, \mathsf {w}> \mathsf {s} + \mathsf {z}$ and those of the forms $\mathsf {y} + \mathsf {s}\geq \mathsf {t}$ , $\mathsf {r} + \mathsf {s}>\mathsf {x}$ , and forms all sums as follows: $\mathsf {u}\geq \mathsf {s} + \mathsf {v}$ with $\mathsf {y} + \mathsf {s}\geq \mathsf {t}$ gives $\mathsf {u}+\mathsf {y} \geq \mathsf {v} + \mathsf {t}$ ; $\mathsf {u} \geq \mathsf {s} + \mathsf {v}$ with $\mathsf {r} + \mathsf {s}> \mathsf {x}$ gives $\mathsf {u}+\mathsf {r}> \mathsf {v} + \mathsf {x}$ , and so on.

In the end, a set of variable-free statements about concrete natural numbers remains, which can be inspected immediately for truth or falsity.

Now each step of this algorithm can be checked for the principles that guarantee its soundness. Here are a few representative illustrations. All steps involve evident principles for inequalities, such as symmetry and associativity of addition, and monotonicity inferences such as the implication from $\mathsf {u} \geq \mathsf {v}$ to $\mathsf {u} + \mathsf {z} \geq \mathsf {v}$ . Step (i) also involves the equality $\mathsf {v} = \mathsf {v} + 0$ , while step (ii) involves $\mathsf {u} + \mathsf {v} \geq \mathsf {v}$ . The key step (iii) involves principles like the equivalence of $\mathsf {z} + \mathsf {u} \geq \mathsf {v} + \mathsf {u}$ and $\mathsf {z} \geq \mathsf {v}$ and addition principles such as the implication from $\mathsf {u} \geq \mathsf {v}$ and $\mathsf {w} \geq \mathsf {z}$ to $\mathsf {u}+\mathsf {w} \geq \mathsf {v} + \mathsf {z}$ . The final inspection step involves some simple principles for the successor function, if we think of numbers as encoded in a unary format.

The preceding observations amount to what one might call a ‘mixed’ axiomatization of the system $\mathsf {MFO}^\phi (\#)$ , letting the logic do what it is good at: reducing assertions to normal form, and then letting the arithmetical component do what it is good at: solving equational problems involving numbers. By itself, a two-stage analysis with reductions to syntactic normal forms plus a separate combinatorial analysis of the latter is a common practice in logic, e.g., in quantifier elimination arguments. However, the above specific division of labor between logic and counting is a perfect fit with the methodological spirit of this paper, and with the general empirical reasoning practices that we started with. We will return to such combinations of logic and (explicit) arithmetic a bit more systematically in Section 6.

Even so, it is also natural to explore the road of greater purity, and ask for a purely logical axiomatization, or a purely numerical one. We consider each of these roads in turn.

Can the arithmetical steps in the Fourier–Motzkin algorithm be replaced by an illuminating purely logical proof system that goes beyond routine transcription? There is an interesting conceptual issue here. The variable-elimination step in the algorithm typically forms sums of single variables in its step (iii), and these sums have no direct interpretation in our logical systems: in particular, $|P| + |P|$ has no defining expression in our logical languages (Fact 3.6). There are ways of dealing with this problem, for instance, by adding special inference rules as is done in [Reference Ding, Harrison-Trainor and Holliday32], which essentially axiomatizes the slightly smaller system $\mathsf {PL}(\#)$ (cf. the discussion in Appendix A). Such inference rules can be seen as expressing the admissibility of certain model constructions for the logic, such as taking disjoint unions. This makes sense in our case, since, while $|P| + |P|$ may not be definable in a given model $\mathcal {M}$ , it does denote the extension of P in the disjoint union of $\mathcal {M}$ with itself. Even so, we are not aware of obvious model constructions matching the invariants needed for $\mathsf {MFO}(\#)$ , and therefore leave this issue as an open problem.

Equally well, in terms of purity, one could go to the opposite side and ask for a purely numerical calculus for our systems. We could restrict ourselves to (the monadic fragment of) the small sublanguage $\mathcal {L}_\#^-$ consisting only of predication, variable inequality, and count comparison (Section 2.1). As all logical operators are definable there, such an axiomatization would be possible in principle. For example, the following numerical claims (suppressing individual variables as all are chosen fresh) capture the basic principles of propositional logic:

  1. (1) $\#(\#\varphi \succsim \#\psi ) \succsim \#\varphi $ ,

  2. (2) $\#\big ( \#(\#\chi \succsim \#\varphi ) \succsim \#(\#\psi \succ \#\varphi ) \big ) \succsim \#\big ( \#(\#\chi \succsim \#\psi ) \succsim \#\varphi \big )$ ,

  3. (3) $\#(\#\varphi \succsim \#\psi ) \succsim \#\big ( \#(\mathsf {0} \succsim \#\psi ) \succsim \#(\mathsf {0} \succsim \varphi ) \big )$ .

However, what one wants is not transcription, but an independently motivated numerical system that generates the logic. As with the purely logical axiomatization, we leave providing an illuminating purely numerical axiomatization of our systems as an open problem.

3.4.3 Infinite cardinalities

In the general system $\mathsf {MFO}(\#)$ , we must also deal with infinite cardinalities. This makes no difference to the principles producing our normal forms, but it changes the subsequent phase of solving equations. The key observation is that there is a simple expression distinguishing the infinite from the finite extensions, namely $\mathsf {s} \geq \mathsf {s} + 1$ . We can thus completely separate reasoning about inequalities among finite variables from reasoning about the variables denoting infinite sets (cf. [Reference Ding, Harrison-Trainor and Holliday32]). This is done systematically in 4.2 for the second-order version of $\mathsf {MFO}(\#)$ , to which we now turn.

4 Monadic second-order counting logic

From a logical point of view, a natural extension of $\mathcal {L}_\#^1$ is to allow quantification over predicates. Call the resulting language $\mathcal {L}_\#^2$ , and the finitary and general systems $\mathsf {MSO}^\phi (\#)$ and $\mathsf {MSO}(\#)$ , respectively. One immediate observation is that, while in $\mathsf {MFO}$ count comparisons $\#_x \varphi \succsim \#_x \psi $ are not definable from the Härtig quantifier $\#_x\varphi \approx \#_x\psi $ alone (see, e.g., [Reference Peters and Westerståhl100, p. 470]), with second-order quantification this is straightforward:

$$ \begin{align*} \exists X. \big(\#_x\varphi \approx \#_x(\psi \vee X(x))\big). \end{align*} $$

How much more powerful will $\mathsf {MSO}^\phi (\#)$ and $\mathsf {MSO}(\#)$ be in comparison to $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ ? The question is of some interest, since it is known (at least since [Reference Ackermann1]) that adding second-order quantification to monadic first-order logic does not increase expressive power. At the same time, if we add quantification over finite sets to $\mathsf {MFO}$ this becomes equivalent to monadic logic with the infinity quantifier (see [Reference Väänänen126] for the case without equality, or Appendix B including equality).

The failure of interpolation (Proposition 3.10) shows that we could not expect a similar collapse when adding monadic second-order quantification to our counting extensions of $\mathsf {MFO}$ . We saw that $\mathsf {MFO}(\#)$ can already distinguish between finite and infinite, so in effect we automatically gain access to quantification over finite sets. In fact we gain much more.

Example 4.1. As a preview, within the finite setting, in contrast to $\mathsf {MFO}^\phi (\#)$ (Fact 3.6), in $\mathsf {MSO}^\phi (\#)$ the statement ‘There are twice as many Ps as Qs’ now becomes expressible:

$$ \begin{align*} \exists X. \big(\#_y (X(y) \wedge \neg Q(y)) \approx \#_y Q(y) \wedge \#_y P(y) \approx \#_y (X(y)\vee Q(y)) \big). \end{align*} $$

This essentially asserts the existence of a set whose extension outside of Q is the same size as Q, and that P is the same size as the union of these two.

It turns out that Example 4.1 is just the tip of the iceberg. In addition to obviously guaranteeing interpolants, there is another sense in which these second-order systems, $\mathsf {MSO}^\phi (\#)$ and $\mathsf {MSO}(\#)$ , ‘fill in the gaps’ of $\mathsf {MFO}^\phi (\#)$ and $\mathsf {MFO}(\#)$ . While the latter systems could enforce a certain type of inequality between sums, namely those in Equations (3.3) and (3.4), the second-order versions are capable of enforcing arbitrary linear constraints over cardinalities. We now proceed to make this more precise, first in the finitary case, then infinitary.

4.1 Finitary case

We saw above that normal forms in $\mathsf {MFO}^\phi (\#)$ correspond to (disjunctions of) sets of inequality constraints, a class whose solvability problem is already NP-complete. In the general setting of integer programming, there is a close correspondence between sets of linear inequalities and quantifier-free formulas of Presburger Arithmetic, that is, first-order logic with addition over the natural numbers (see, e.g., [Reference Oppen97]). The sets of solutions to such inequalities (or equivalently, assignments satisfying Presburger formulas with free variables) are exactly the semi-linear sets [Reference Ginsburg and Spanier44], a generalization of the ‘ultimately periodic’ sets of numbers:

Definition 4.2. A set $\mathcal {V}\subseteq \mathbb {N}^n$ of n-ary vectors is called linear if there is a system of equations over variables $\mathsf {v}_1,\dots ,\mathsf {v}_n,\mathsf {u}_1,\dots ,\mathsf {u}_m$ and constants $b_1,\dots ,b_n,a_{1,1},\dots ,a_{n,m}$ ,

(4.1) $$ \begin{align} \begin{pmatrix} \;\mathsf{v}_1\; \\ \vdots \\ \mathsf{v}_n \end{pmatrix} = \begin{pmatrix} b_1 + a_{1,1}\mathsf{u}_1 + & \dots & + a_{1,m}\mathsf{u}_m \\ \vdots & & \vdots \\ b_n + a_{n,1}\mathsf{u}_1 + & \dots & + a_{n,m}\mathsf{u}_m \end{pmatrix} \end{align} $$

such that $\mathbf {x} \in \mathcal {V}$ if and only if there exist values of $\mathsf {u}_1,\dots ,\mathsf {u}_m$ for which $\mathbf {v}=\mathbf {x}$ is a solution to (4.1). We say $\mathcal {V} \subseteq \mathbb {N}^n$ is semi-linear if it is a finite union of linear sets.

Definition 4.3. Suppose $S_1,\dots ,S_n$ are some state-descriptions over predicates $\mathbf {P}$ , and that $\varphi $ is an $\mathcal {L}_\#^2$ sentence in these same predicates $\mathbf {P}$ . We say that $\varphi $ defines a set $\mathcal {V} \subseteq \mathbb {N}^n$ just in case, for any model $\mathcal {M}$ , we have

(4.2) $$ \begin{align} \mathcal{M} \vDash \varphi \quad \mbox{iff}\quad [|S_1|_{\mathcal{M}},\dots,|S_n|_{\mathcal{M}}] \in \mathcal{V}. \end{align} $$

Lemma 4.4. Every semi-linear set is definable in $\mathsf {MSO}^\phi (\#)$ .

Proof As $\mathcal {L}_\#^2$ closes under disjunction, it suffices to show that every linear set is definable. So we describe how to encode any linear set of the form in (4.1) by an $\mathcal {L}_\#^2$ sentence. In words:

  1. (i) For all $i\leq n$ , assert the existence of:

    • Sets $Z_{i,j,1} \dots , Z_{i,j,a_{i,j}}$ (none if $a_{i,j}=0$ ) for all $j \leq m$ ,

    • Individuals $z_{i,1}, \dots , z_{i,b_i}$ (none if $b_i=0$ ).

  2. (ii) Add conjuncts for:

    • $\#_x\big (Z_{i,j,p}(x) \wedge Z_{i,j',p'}(x)\big ) \approx \mathsf {0}$ , whenever $j\neq j'$ or $p \neq p'$ ,

    • $\neg Z_{i,j,p}(z_{i,l})$ , for all $i,j,p,l$ ,

    • $\#_xZ_{i,j,p}(x) \approx \#_xZ_{i',j,p'}(x)$ , for all j and all $i,i',p,p'$ ,

  3. (iii) Finally, conjoin these together with the claim that each state-description $S_i$ has the same cardinality as the union of all $Z_{i,j,p}$ , together with $z_{i,1},\dots ,z_{i,b_i}$ :

    $$ \begin{align*} \#_xS_i(x) \approx \#_x \big( \bigvee_{j\leq m \atop p \leq a_{i,j}} Z_{i,j,p}(x) \vee \bigvee_{l \leq b_i} x = z_{i,l} \big). \end{align*} $$

For a given $i\leq n$ and $j \leq m$ , the sets $Z_{i,j,p}$ correspond to $a_{i,j}$ -many copies of the variable $\mathsf {u}_j$ in (4.1). The individual variables $z_{i,l}$ count the constant ‘base’ number $b_i$ . The numerical equalities stated in (iii) guarantee that each ‘variable’ $|S_i|_{\mathcal {M}}$ has the right cardinality according to (4.1), under the conditions specified by (ii). By existentially quantifying all variables (i) the resulting formula defines the linear set in (4.1) in the sense of (4.2).

We now want to show the other direction, that all $\mathcal {L}_\#^2$ sentences in fact define semi-linear sets. Toward this result we first note that $\mathsf {MSO}(\#)$ possesses a prenex normal form.

Lemma 4.5. Every $\mathcal {L}_\#^2$ sentence in predicates $\mathbf {P}$ is equivalent—in $\mathsf {MSO}(\#)$ as well as in $\mathsf {MSO}^\phi (\#)$ —to one in prenex form, that is, of the form $Q_1X_1,\dots ,Q_nX_n. \varphi (\mathbf {P},X_1,\dots ,X_n)$ , where $\varphi (\mathbf {P},X_1,\dots ,X_n)$ is a first-order $\mathcal {L}_\#^1$ sentence $($ treating $X_1,\dots ,X_n$ as additional predicates $)$ and $Q_1,\dots ,Q_n$ are second-order quantifiers.

Proof Sketch

The argument is as usual for prenex normal forms in first-order logic. As in case of $\mathsf {MFO}(\#)$ , the soundness of ( INV ) allows us to extract any first-order or second-order quantifier from the scope of a $\#$ -term. The only case we need to consider is a first-order (universal) quantifier scoping directly over a second-order quantifier. The point is to convert the first-order universal quantifier into a universal second-order quantifier restricted to singleton sets. That is, a formula $\forall x. QY. \varphi $ , with Q a second-order quantifier, will be equivalent to $\forall X. QY. \forall x. \big (\forall z(X(z) \leftrightarrow z=x) \rightarrow \varphi \big )$ .

By Theorem 3.2 we know that $\varphi (\mathbf {P},X_1,\dots ,X_n)$ has a normal form involving expressions $T_1=T_2+m$ and $T_1> T_2+m$ , where $T_1,T_2$ are cardinalities of state-descriptions over $\mathbf {P}$ and additional predicates $X_1,\dots ,X_n$ . Such formulas are thus easily seen to be semi-linear, indeed linear. As semi-linear sets are closed under Boolean combinations, and second-order quantifiers distribute over disjunction, the main goal is to show:

Lemma 4.6. Let X be a predicate variable, and let $O_1,\dots ,O_n$ be either predicate letters or predicate variables. Suppose that $\varphi (O_1,\dots ,O_n,X)$ defines a linear set in state-descriptions $S_1,\dots ,S_{2^{n+1}}$ over $O_1,\dots ,O_n,X$ . Then $\exists X. \varphi (O_1,\dots ,O_n,X)$ defines a linear set in state-descriptions $S_1',\dots ,S_{2^n}'$ over just $O_1,\dots ,O_n$ .

Proof As $\varphi (O_1,\dots ,O_n,X)$ is linear, we can assume it defines the solutions to

(4.3) $$ \begin{align} \begin{pmatrix} \;|S_1|\; \\ \vdots \\ |S_{2^{n+1}}| \end{pmatrix} = \begin{pmatrix} b_1 + a_{1,1}\mathsf{u}_1 + & \cdots & + a_{1,m}\mathsf{u}_m \\ \vdots & & \vdots \\ b_{2^{n+1}} + a_{2^{n+1},1}\mathsf{u}_1 + & \cdots & + a_{2^{n+1},m}\mathsf{u}_m \end{pmatrix}. \end{align} $$

To show that $\exists X. \varphi (O_1,\dots ,O_n,X)$ , too, is linear, we define another linear set of equations by ‘projecting out’ the variable X.

Specifically, note for each state-description $S_k'$ , both $S_k' \wedge X$ and $S_k' \wedge \neg X$ are (equivalent to) some state-descriptions, $S_i$ and $S_j$ , and in fact $S_k'$ is equivalent to $S_i \vee S_j$ . The new linear system in $2^n$ variables is then as follows for each $k\leq 2^n$ :

(4.4) $$ \begin{align} |S^{\prime}_k| = b_i + b_j + (a_{i,1}+a_{j,1})\mathsf{u}_1+ \dots + (a_{i,m} + a_{j,m})\mathsf{u}_m. \end{align} $$

It remains only to show that:

$$ \begin{align*} \mathcal {M} & \vDash \exists X. \varphi (O_1,\dots ,O_n,X)\\ &\Leftrightarrow [|S_1'|_{\mathcal {M}},\dots ,|S_{2^n}'|_{\mathcal {M}}] \mbox{ is a solution to Equation (20)}.\end{align*} $$

$(\Rightarrow )$ : If $\mathcal {M} \vDash \exists X. \varphi (O_1,\dots ,O_n,X)$ then for some subset A of the domain, we have $\mathcal {M},s^X_A \vDash \varphi (O_1,\dots ,O_n,X)$ . Treating X now as a predicate constant, we have a model $\mathcal {M}'$ for which $X^{\mathcal {M}'}=A$ , and by assumption this gives a solution $[|S_1|_{\mathcal {M}'},\dots ,|S_{2^{n+1}}|_{\mathcal {M}'}]$ to (4.3). But each state-description $S_k'$ is equivalent to a disjunction $S_i \vee S_j$ , whose cardinality is the sum $|S_i|+|S_j|$ . Therefore $\mathcal {M}'$ will satisfy each of the constraints in (4.4). As the state-descriptions $S_1',\dots ,S_{2^n}'$ are independent of X, this means $[|S_1'|_{\mathcal {M}},\dots ,|S_{2^n}'|_{\mathcal {M}}]$ also gives a solution to (4.4).

$(\Leftarrow )$ : Suppose $[|S_1'|_{\mathcal {M}},\dots ,|S_{2^n}'|_{\mathcal {M}}]$ gives a solution to (4.4) for some particular choices $\mathsf {u}_1,\dots ,\mathsf {u}_m$ . We need to find a set A such that $\mathcal {M},s^X_A \vDash \varphi (O_1,\dots ,O_n,X)$ . Since the extensions of $S_1',\dots ,S_{2^n}'$ are all disjoint, to define A it suffices to identify subsets of each ${[\![{ {S_k'} }]\!]}_{\mathcal {M}}$ . As above, suppose $S^{\prime }_k$ is equivalent to $S_i \vee S_j$ , so that $S_i$ is equivalent to $S^{\prime }_k \wedge X$ and $S_j$ is equivalent to $S_k' \wedge \neg X$ . Then let $B_k$ be any subset of ${[\![{ {S_k'} }]\!]}_{\mathcal {M}}$ of size $b_i + a_{i,1}\mathsf {u}_1 + \dots + a_{i,m}\mathsf {u}_m$ , such that the complement ${[\![{ {S^{\prime }_k} }]\!]}_{\mathcal {M}} - B_k$ has size $b_j + a_{j,1}\mathsf {u}_1 + \dots + a_{j,m}\mathsf {u}_m$ . This is always possible since $|S^{\prime }_k|$ is simply the sum of these two numbers. Finally let $A = \bigcup _{k\leq 2^n} B_k$ . Once again absorbing X into the language and defining $\mathcal {M}'$ to be just like $\mathcal {M}$ but with $X^{\mathcal {M}'} = A$ , the tuple $[|S_1|_{\mathcal {M}'},\dots ,|S_{2^{n+1}}|_{\mathcal {M}'}]$ gives a solution to (4.3) with the same choices $\mathsf {u}_1,\dots ,\mathsf {u}_m$ . Hence, $\mathcal {M}'\vDash \varphi (O_1,\dots ,O_n,X)$ , from which it easily follows that $\mathcal {M},s^X_A \vDash \varphi (O_1,\dots ,O_n,X)$ and finally $\mathcal {M} \vDash \exists X. \varphi (O_1,\dots ,O_n,X)$ .

The foregoing thus establishes:

Theorem 4.7. The numerical relations definable in $\mathsf {MSO}^\phi (\#)$ are the semi-linear sets. In other words, $\mathsf {MSO}^\phi (\#)$ expresses the same numerical relations as Presburger Arithmetic.

Remark 4.8. In $\mathcal {L}_\#^2$ we allow arbitrary second-order quantification. However, we saw in Lemma 4.4 that we only needed an initial block of existential second-order quantifiers to encode any (semi-)linear set. The fact that every sentence in $\mathsf {MSO}^\phi (\#)$ defines a semi-linear set demonstrates a collapse of $\mathsf {MSO}^\phi (\#)$ into its purely existential fragment.

As in the first-order case, numerous undefinable results again follow. For example:

Corollary 4.9. The expression ‘many’ is still not definable in $\mathsf {MSO}^\phi (\#)$ .

Proof Adopting the notation from the proof of Fact 3.7, the constraint on state-descriptions, $\frac {r}{r+q}> \frac {p+r}{p+q+r+s}$ , is not semi-linear.

Indeed, the theory of definability for Presburger Arithmetic carries over exactly to $\mathsf {MSO}^\phi (\#)$ , thanks to Theorem 4.7. Moreover, since there is an algorithmic means of putting a formula of $\mathsf {MSO}^\phi (\#)$ into normal form and finding a suitable semi-linear form, decidability follows from the decidability of Presburger Arithmetic.

Corollary 4.10. $\mathsf {MSO}^\phi (\#)$ is decidable.

4.2 Infinitary case

Allowing second-order quantification does increase the expressive power of our initial system $\mathsf {MFO}^\phi (\#)$ . While the latter essentially amounts to a proper fragment of Presburger Arithmetic, $\mathsf {MSO}^\phi (\#)$ gave us precisely Presburger Arithmetic. How does this look for the system $\mathsf {MSO}(\#)$ over models of arbitrary cardinality? One immediate difference is that, in contrast to $\mathsf {MFO}(\#)$ (Fact 3.8), the successor function on cardinal numbers can now be easily expressed:

$$ \begin{align*}\forall X.\big( \#_yP(y) \succ \#_y X(y) \rightarrow \#_y Q(y) \succsim \#_yX(y)\big).\end{align*} $$

This formula states that there is no cardinality strictly in between that of P and that of Q. How much more cardinal arithmetic does $\mathsf {MSO}(\#)$ encode?

As in the case of $\mathsf {MSO}^\phi (\#)$ , we can calibrate this by appeal to additive first-order (now cardinal) arithmetic. Consider the elementary theory of the structure $\langle C_{\aleph _\omega };+ \rangle $ , addition over the cardinals numbers less than $\aleph _\omega $ . This is the theory of cardinal numbers in a first-order language with one binary function symbol, namely addition. We show in Appendix C that this theory admits quantifier elimination provided we augment the language with constants for the (definable in $\mathsf {MSO}(\#)$ ) functions and relations:

  • $\{0\}$ and $\{\aleph _0\}$ ,

  • s — the successor function,

  • $>$ — the ‘greater than’ relation,

  • $\equiv _k$ — equivalence modulo k for each $k>1$ .

Furthermore, we can derive a normal form result for this language:

Proposition 4.11. Every first-order sentence is equivalent over the structure $\langle C_{\aleph _\omega };+ \rangle $ to a disjunction of conjunctions $\delta \wedge \iota \wedge \phi $ each specifying $:$

  • which (ordinary first-order) variables in the disjunct are finite or infinite ( $\delta $ ),

  • a description of a linear set for the finite variables ( $\phi $ ),

  • a description of a set of infinite cardinals using $0$ , s, and $>$ over $\aleph $ -number indices, for the infinite variables ( $\iota $ ).

This can be understood as a kind of separation result. The finitary part, Presburger Arithmetic, simply describes ordinary addition. As for the infinitary part, observe that there is an isomorphism from $\langle \mathbb {N};0,s,>\rangle $ onto $\langle \{\aleph _k\}_{k\in \mathbb {N}}; \aleph _0,s,> \rangle $ , sending k to $\aleph _k$ . In other words, the additive structure of cardinals less than $\aleph _\omega $ amounts to a ‘product’ of $\langle \mathbb {N};+ \rangle $ and $\langle \mathbb {N};> \rangle $ .Footnote 3

Our aim is to show that $\mathsf {MSO}(\#)$ possesses the same normal forms as in Proposition 4.11. To see that any statement of the form $\delta \wedge \iota \wedge \phi $ can be expressed, note that $\delta $ merely requires distinguishing finite and infinite sets (recall Equation (2.1)), while definability of any linear set (specified by $\phi $ ) was shown already in Lemma 4.4. Meanwhile, $\iota $ is a conjunction of formulas of types $\mathsf {v}=s^k(\mathsf {u})$ , $\mathsf {v}>s^k(\mathsf {u})$ , $\mathsf {v} = \aleph _k$ , and $\mathsf {v}>\aleph _k$ . We noted above that successor is expressible, and, for instance, we can assert that P has cardinality $\aleph _0$ simply by stating that P is infinite and there is no infinite set with smaller cardinality. Thus, any such statement is expressible.

To show that this exhausts what is definable in $\mathsf {MSO}(\#)$ , given Lemma 4.5, it remains to observe that the $\mathcal {L}_\#^2$ -definable sets are closed under ‘projection’ by existentially quantifying one of the variables. Thus, suppose we have an $\mathcal {L}_\#^2$ formula $\varphi (\mathbf {O},Y)$ with Y a predicate variable and $\mathbf {O}=O_1,\dots ,O_n$ all either predicate variables or letters. We will assume $\varphi (\mathbf {O},Y)$ has the form $\delta (\mathbf {O},Y) \wedge \iota (\mathbf {O},Y) \wedge \phi (\mathbf {O},Y)$ , analogously to the additive language: $\delta (\mathbf {O},Y)$ describes which state descriptions over variables $O_1,\dots ,O_n,Y$ are (in)finite, $\iota (\mathbf {O},Y)$ characterizes the infinite state descriptions, while $\phi (\mathbf {O},Y)$ describes a linear set. We need to analyze $\exists Y.\big (\delta (\mathbf {O},Y) \wedge \iota (\mathbf {O},Y) \wedge \phi (\mathbf {O},Y)\big )$ .

We can replace $\delta (\mathbf {O},Y)$ with a formula $\delta '(\mathbf {O})$ specifying that a state description S over $O_1,\dots ,O_n$ is finite iff $S \wedge Y$ and $S \wedge \neg Y$ were both finite according to $\delta (\mathbf {O},Y)$ . List the finite state descriptions according to $\delta (\mathbf {O},Y)$ as $S_1,\dots ,S_k$ . The subformula $\phi (\mathbf {O},Y)$ defines a linear set over the possible (finite) cardinalities:

(4.5) $$ \begin{align} \begin{pmatrix} \;|S_1|\; \\ \vdots \\ |S_{k}| \end{pmatrix} = \begin{pmatrix} b_1 + a_{1,1}\mathsf{u}_1 + & \cdots & + a_{1,m}\mathsf{u}_m \\ \vdots & & \vdots \\ b_{k} + a_{k,1}\mathsf{u}_1 + & \cdots & + a_{k,m}\mathsf{u}_m \end{pmatrix}. \end{align} $$

Suppose $S_i = S \wedge Y$ is finite but $S \wedge \neg Y$ is infinite. Then the constraint in (4.5) on $|S_i|$ is no constraint at all: since $|S|$ must be infinite, carving out a finite portion $S \wedge Y$ of any size will always be possible. So in this case we can simply drop the equation for $S_i$ . Otherwise, if $S_i = S\wedge Y$ and $S_j=S \wedge \neg Y$ are both finite, then we can repeat the argument from Section 4.1, again combining these two equations into a single equation for $|S|$ . The result is a set of equations in (cardinalities of) state descriptions over $\mathbf {O}$ , all asserted finite in $\delta '(\mathbf {O})$ .

The subformula $\iota (\mathbf {O},Y)$ represents constraints of the form $\mathsf {v}=\mathsf {w}$ and $\mathsf {v}>\mathsf {w}$ , where $\mathsf {v}$ and $\mathsf {w}$ are either ‘infinite’ state descriptions over $\mathbf {O},Y$ , k-fold successors of such state descriptions, or aleph-numbers. In view of the isomorphism between $\langle \mathbb {N};0,s,> \rangle $ and $\langle \{\aleph _k\}_{k \in \mathbb {N}};\aleph _0,s,>\rangle $ , we can construe these conjuncts as describing relations on natural numbers. As these relations are a special case of linear sets and can thus be encoded as in (4.5), we once again run the argument to ‘merge’ the equations for $S \wedge Y$ and $S \wedge \neg Y$ into a single equation for S, provided all of these are infinite. (If only one of $S \wedge Y$ and $S \wedge \neg Y$ is infinite, then that equation remains as before since S will have the same cardinality.) The resulting formula will in general involve addition. But as discussed further in Appendix C, since all variables are infinite we can eliminate all explicit sums, using equivalences such as $\mathsf {t} = \mathsf {v}+\mathsf {w} \Leftrightarrow (\mathsf {t}=\mathsf {v} \wedge \mathsf {v} \geq \mathsf {w})\vee (\mathsf {t}=\mathsf {w} \wedge \mathsf {w} \geq \mathsf {v}) $ .

Theorem 4.12. The definable relations on cardinal numbers in $\mathsf {MSO}(\#)$ are exactly the same as those definable in additive first-order logic.

In effect, we have shown how to reduce a sentence $\varphi (\mathbf {P})$ in $\mathcal {L}_\#^2$ to an additive first-order formula $\alpha (\mathbf {x})$ , with a variable $x_i$ in $\mathbf {x}$ corresponding to each state-description over $\mathbf {P}$ . Moreover, $\varphi (\mathbf {P})$ is satisfiable if and only if $\exists \mathbf {x}.\alpha (\mathbf {x})$ is true in $\langle C_{\aleph _\omega };+ \rangle $ . Thus, from decidability of the elementary theory of $\langle C_{\aleph _\omega };+ \rangle $ (see Theorem C.3 in Appendix C) we obtain:

Corollary 4.13. $\mathsf {MSO}(\#)$ is decidable.

5 Counting sequences

We have so far considered a base monadic system, $\mathsf {MFO}^\phi (\#)$ , and a second-order extension, $\mathsf {MSO}^\phi (\#)$ , both of which are essentially restricted to reasoning about sums of numbers. The latter theme carries over to the setting of infinite models, with $\mathsf {MFO}(\#)$ and $\mathsf {MSO}(\#)$ . These previous systems involve unary variable binding operators, which count sets of objects. But it is also very natural from a logical point of view to count sequences of objects. Indeed, polyadic quantifiers are ubiquitous across natural language; cf. Section 9. We now consider such an extension, essentially moving from sets to products of sets. We would like to understand what additional arithmetical capacity this affords.

Let $\mathcal {L}^1_{\sharp }$ be the first-order monadic language with polyadic counting terms $\sharp _{\mathbf {x}}\varphi $ , where $\mathbf {x} = x_1,\dots ,x_k$ is a sequence of variables, which may appear in $\varphi $ . Then:

$$ \begin{align*} \mathcal{M},s \vDash \sharp_{\mathbf{x}}\varphi \succsim \sharp_{\mathbf{y}}\psi & \mbox{ iff } |\{\mathbf{d} \in D^n: \mathcal{M},s^{\mathbf{x}}_{\mathbf{d}} \models \varphi\}| \geq |\{\mathbf{d} \in D^m: \mathcal{M},s^{\mathbf{y}}_{\mathbf{d}} \models \psi\}|. \end{align*} $$

Over finite models let us call the resulting system $\mathsf {MFO}^{\phi }(\sharp )$ , and $\mathsf {MFO}(\sharp )$ for the general case.

It is known that polyadic counting over full first-order logic is more expressive than unary counting (i.e., our $\mathsf {FO}^\phi (\#)$ ; see, e.g., [Reference Otto98, Example 4.13]). In our monadic fragment this is particularly dramatic, as shown by the following example.

Example 5.1. Consider the earlier ‘Many Qs are P’, defined in (3.10) and repeated here:

$$ \begin{align*} \#_x\big(P(x) \wedge Q(x)\big) \times \#_x \top & \succ \#_x P(x) \times \#_x Q(x). \end{align*} $$

We can express this as follows:

$$ \begin{align*}\sharp_{x,y} \big(P(x) \wedge Q(x)\big) \succ \sharp_{x,y} \big(P(x) \wedge Q(y)\big).\end{align*} $$

In a finite model, the term $\sharp _{x,y} \big (P(x) \wedge Q(x)\big )$ gives us the product of the model’s total cardinality and the region in which P and Q both hold, while the term on the right gives us the product of cardinalities for P and Q.

Evidently $\mathsf {MFO}^{\phi }(\sharp )$ incorporates some reasoning about multiplication. Another example:

Example 5.2. We can encode Pythagorean triples of cardinalities for state-descriptions $S_1,S_2,S_3$ , i.e., the statement that $|S_1|^2 + |S_2|^2 = |S_3|^2$ :

$$ \begin{align*}\sharp_{x,y}\big((S_1(x) \wedge S_1(y)) \vee (S_2(x) \wedge S_2(y))\big) \approx \sharp_{x,y}(S_3(x) \wedge S_3(y)).\end{align*} $$

The multiplication again comes from taking products, while the addition in this example arises from disjunction, just as in our initial system $\mathsf {MFO}^\phi (\#)$ .

The next examples involves a different combination of multiplication and addition:

Example 5.3. This sentence expresses the constraint that $|P|\times 2 = |Q|^3 + 2$ .

$$ \begin{gather*} \exists x,y.\Big(\neg (Q(x) \vee Q(y)) \wedge x \neq y \wedge \sharp_{u,v}\big( P(u) \wedge (v=x \vee v=y) \big)\approx \\ \sharp_{z,u,v} \big((Q(z) \wedge Q(u) \wedge Q(v)) \vee z=u=v=x \vee z=u=v=y \big) \Big). \end{gather*} $$

Note the use of variables $x,y$ for both $\sharp $ terms. In the first term, $\sharp _{u,v}\big ( P(u) \wedge (v=x \vee v=y) \big )$ , we simply want to multiply the cardinality of P by $2$ —the fact that Q holds of neither x nor y does not matter here. In the second $\sharp $ term we consider all triples of points satisfying Q, i.e., $|Q|\times |Q|\times |Q|$ -many points, and we add two points $x,y$ —here it is important that Q holds of neither, since this guarantees that we indeed add $2$ to the product $|Q|^3$ in the second $\sharp $ term.

For a visualization, see Figure 2. All of these examples certainly go beyond what can be expressed in $\mathsf {MFO}^\phi (\#)$ , and even $\mathsf {MSO}^\phi (\#)$ . What is the full scope of $\mathsf {MFO}^{\phi }(\sharp )$ ?

Figure 2 A visualization of the formula expressing that $2$ times the number of P points is exactly the number of Q points squared, i.e., $ |P|+|P| = |Q|^2$ . The formula asserts that the number of lines on the left is equal to the number of lines on the right. This is a simplified version of Example 5.3 and of the more general construction in Lemma 5.4. In the case pictured, $|P|=8$ and $|Q|=4$ .

5.1 Diophantine inequalities

To start our discussion, consider any polynomial inequality

(5.1) $$ \begin{align} m_1(\mathbf{v}) + \dots + m_k(\mathbf{v}) \geq m_1'(\mathbf{v}) + \dots + m_j'(\mathbf{v}), \end{align} $$

where $m_1,\dots ,m_k,m^{\prime }_1,\dots ,m^{\prime }_j$ are all monomials in variables $\mathbf {v} = \mathsf {v}_1,\dots ,\mathsf {v}_n$ . Each monomial $m(\mathbf {v})$ is of the form $a \mathsf {v}_1^{e_1}\dots \mathsf {v}_n^{e_n}$ , with