arXiv:2608.30580cs.LOAug 2026

Manuscript Offprint

arXiv:2608.30580

Unary Functions, Automorphisms, and Unlabeled First-Order Model Counting

Ondřej Kuželka

Abstract

Every fixed first-order sentence φ\varphi determines an enumerative sequence n↦FOMC(φ,n)n \mapsto \text{FOMC}(\varphi, n), counting its models on the labeled domain [n][n]. We study the complexity of these sequences when logical specifications may use genuine unary function symbols and hence nested terms x,f(x),f2(x),…x, f(x), f^2(x), \ldots.

We first prove that, for every fixed sentence φ∈C=1[f]\varphi \in \mathrm{C}_{=}^1[f], with one unary function and an arbitrary finite relational vocabulary, FOMC(φ,n)\mathrm{FOMC}(\varphi, n) is computable in time polynomial in nn. By contrast, permitting either a second variable or a second unary function already yields hardness. Without counting quantifiers, there is a fixed sentence in FO=2[f]\mathrm{FO}_{=}^2[f] whose model-counting function is #P1\#P_1-complete. With one variable and two unary functions, there is a fixed constant-free universal sentence in FO=1[f,g]\mathrm{FO}_{=}^1[f, g], using only unary predicates besides ff and gg, whose model-counting function is again #P1\#P_1-complete.

We also relate labeled and unlabeled enumeration exactly. For every relational sentence φ\varphi, we construct an extension φaut\varphi_{aut} in which a unary function records an automorphism and

FOMC(φaut,n)=n!UFOMC(φ,n),\mathrm{FOMC}(\varphi_{\mathrm{aut}},n)=n!\mathrm{UFOMC}(\varphi,n),

where UFOMC( φ,n\varphi, n) denotes the number of n-element models of φ\varphi up to isomorphism. Thus automorphism marking gives a one-query exact reduction from unlabeled to labeled model counting at the same domain size. Over relational vocabularies of maximum arity at most kk, where k≥2k \geq 2, eliminating the auxiliary function yields single-query reductions from unlabeled FO=kFO_{=}^k and CkC^k model counting to labeled FO=k+1FO_{=}^{k+1} and Ck+1C^{k+1} model counting, respectively.

1 Introduction

What constitutes a satisfactory solution to an enumeration problem? Suppose that an enumeration problem gives an integer sequence (an)n≥0(a_n)_{n \geq 0}, where ana_n is the number of objects of size nn. A closed formula is one possibility, but from an algorithmic point of view a recurrence, generating function, or other representation is useful only as long as it permits the desired numbers to be computed efficiently. Wilf (1982) proposed judging solutions to enumeration problems partly by their computational complexity. In particular, one of his criteria asks whether ana_n can be computed in time polynomial in nn; Pak (2018) refers to algorithms of this kind as Wilfian formulas of type (W1). This viewpoint belongs to a broader complexity-theoretic study of enumerative combinatorics, in which the complexity of exact computation is treated as an intrinsic aspect of an enumeration problem (Pak, 2018, 2024; see also Klazar, 2018).

First-order model counting provides a uniform way to ask such questions for logically specified classes of finite structures. A fixed first-order sentence φ\varphi describes a family of structures independently of the domain size, and

FOMC(φ,n)\mathrm{FOMC}(\varphi,n)

is the number of its models on the labeled domain

[n]={1,…,n}.[n]=\{1,\dots,n\}.

Thus every fixed sentence determines an enumerative sequence. In the model-counting literature, a sentence or fragment is called domain-liftable when this count, or more generally its symmetric weighted version, can be computed in time polynomial in n. For ordinary model counting, domain liftability therefore says that every fixed specification in the fragment gives an enumerative sequence computable in time polynomial in n.

A tractability theorem for a logical fragment therefore gives a single sufficient condition for polynomial-time exact enumeration across all fixed specifications expressible in that fragment. A standard illustration is supplied by regular graphs. For fixed k, the sentence

∀x¬E(x,x)∧∀x∀y(E(x,y)⇒E(y,x))∧∀x∃=kyE(x,y)\forall x\neg E(x,x)\land\forall x\forall y\left(E(x,y)\Rightarrow E(y,x)\right)\land\forall x\exists^{=k}y E(x,y)

has as its models precisely the labeled simple k-regular graphs. It belongs to the two-variable logic with counting quantifiers C2C^{2}, whose weighted model-counting problem is polynomial-time in the domain size for every fixed sentence (Kučelka, 2021). Adding a fixed number l of unary color predicates, requiring every vertex to receive exactly one color, and forbidding monochromatic edges similarly counts pairs consisting of a labeled k-regular graph and a proper l-coloring. For every fixed k, the counting sequence for labeled k-regular graphs was already known to be P-recursive (Goulden and Jackson, 1986; Gessel, 1990), and hence computable in time polynomial in n; see also (Pak, 2018, Section 1.3). The regular-graph example illustrates the role of the logical result rather than its scope: the C2C^{2} tractability theorem applies to every fixed C2C^{2} specification, including structurally quite different relational classes and combinations of constraints expressible in the fragment.

This perspective has increasingly brought first-order model counting into contact with enumerative combinatorics. The original tractability results established polynomial-time symmetric weighted model counting for every fixed sentence of the two-variable fragment FO2FO^{2} (Van den Broeck, 2011; Van den Broeck et al., 2014; Beame et al., 2015), and Kuželka (2021) extended this to C2C^{2}. Subsequent work showed that polynomial-time counting survives the addition of structural requirements such as tree, forest, connectedness, directed acyclicity, and linear order axioms (van Bremen and Kuželka, 2021; Tóth and Kuželka, 2023; Malhotra et al., 2025). Some of these arguments import classical enumerative tools directly: the tree result, for example, uses the matrix-tree theorem, while connectedness and acyclicity are handled through adaptations of familiar combinatorial recurrences.

More recently, Kuang et al. (2026) developed model-counting analogues of graph polynomials whose coefficients encode structural information about the models of a sentence. Their weak- and strong-connectedness polynomials provide a common framework for several previously studied structural axioms and yield further tractable counting problems. Classical graph polynomials also arise within this framework: the Tutte polynomial is obtained as a special case of the weak-connectedness polynomial, while directed chromatic polynomials arise from the strong-connectedness construction.

The present paper asks what happens when this framework is extended from relational structures to structures with genuine unary function symbols. There is an important distinction here. Functionality itself is not new to relational model counting: a binary relation F can be required to be the graph of a total function by the C2C^{2} sentence

∀x∃=1yF(x,y),\forall x\exists^{=1}y F(x,y),

and functionality constraints already occur in earlier tractability results (Kuusisto and Lutz, 2018; Kuželka, 2021). A unary function symbol, however, changes the term language. From a single variable x one may form

x, f(x), f2(x),…,x,\ f(x),\ f^{2}(x),\ldots,

compare different iterates for equality, and place several points of one forward orbit into the same relation atom, as in

R(x,f(x),f2(x)).R(x,f(x),f^{2}(x)).

This information is not available in the same syntactic fragment merely by representing f through a functional binary relation. In particular, equality atoms can compare nonadjacent points of a single forward orbit while using only one variable. Nested function terms therefore give the one-variable language genuine, though bounded, access to orbit structure.

For every fixed sentence

φ∈C=1[f],\varphi\in\mathrm{C}_{=}^{1}[f],

over one unary function symbol and an arbitrary finite relational vocabulary, we prove that

n⟼FOMC(φ,n)n\longmapsto\mathrm{FOMC}(\varphi,n)

is computable in time polynomial in n. Thus every fixed specification in C=[f]C_=[f] admits a polynomial-time exact enumeration algorithm in the domain size. The fragment is nevertheless quite small: the formula has only one variable and one unary function, and each fixed sentence can inspect only a bounded portion of any forward orbit.

The main complexity message is that tractability for one-variable counting logic with a single unary function does not extend much further. If a second variable is allowed, hardness already occurs without counting quantifiers: we construct a fixed sentence in FO=2[f]\mathrm{FO}_{=}^{2}[f] whose model-counting function is #P1\#P_{1}-complete. Keeping one variable but allowing a second unary function is equally powerful: there is a fixed constant-free universal sentence in FO=1[f,g]\mathrm{FO}_{=}^{1}[f,g], using only unary predicates besides ff and gg, whose model-counting function is again #P1\#P_{1}-complete. Here #P1\#P_{1} is the unary-input version of #P\#P. Giving the domain size as 1n1^{n} is precisely the complexity-theoretic formalization of asking for computation in time polynomial in the enumerative parameter nn, rather than polynomial in the binary length of nn. Thus, unless FP=#P1\mathrm{FP} = \#P_{1}, no analogue of our polynomial-time theorem can hold throughout either of these richer languages.

The two hardness proofs encode the same fixed linear-time nondeterministic computation by different means; see Section 5. Taken together, the results leave a narrow tractable region:

C=1[f]−FOMCispolynomial−timecomputable,\mathrm{C}_{=}^{1}[f]-\mathrm{FOMC}is polynomial-time computable,

whereas FO=2[f]\mathrm{FO}_{=}^{2}[f] and FO=1[f,g]\mathrm{FO}_{=}^{1}[f,g] already contain fixed sentences with #P1\#P_{1}-complete model-counting functions.

Our second theme concerns the distinction between labeled and unlabeled enumeration. First-order model counting is inherently labeled: the domain is the fixed set [n][n]. Many classical enumeration problems instead ask for isomorphism classes. The relation between the two counts is obstructed by automorphisms. If A is an n-element structure, then its isomorphism class has

n!∣Aut(A)∣\frac{n!}{\left|\mathrm{Aut}(A)\right|}

labeled copies, so simply dividing a labeled count by n!n! is valid only when every model is rigid.

We show that this varying automorphism factor can itself be absorbed into a logical specification. Given a relational sentence φ\varphi, introduce a unary function ff and require it to be a permutation preserving every relation. The models of the resulting sentence φaut\varphi_{aut} are precisely the pairs

(A,π)(A,\pi)

where AA is a labeled model of φ\varphi and π∈Aut(A)\pi \in \text{Aut}(A). Consequently each isomorphism class contributes

n!∣Aut(A)∣∣Aut(A)∣=n!\frac{n!}{\left|\mathrm{Aut}(A)\right|}\left|\mathrm{Aut}(A)\right|=n!

expanded labeled structures, independently of the size of its automorphism group. Hence

FOMC(φaut,n)=n!UFOMC(φ,n).\mathrm{FOMC}(\varphi_{\mathrm{aut}},n)=n!\mathrm{UFOMC}(\varphi,n).

At the numerical level this is the familiar Burnside/orbit-stabilizer cancellation. The point of the construction is that the permutation is made part of the structure, turning the Burnside fixed-point sum into an ordinary labeled model count for one fixed sentence.

The auxiliary function can also be eliminated. Over a relational vocabulary of maximum arity at most kk, where k≥2k \geq 2, its graph can be represented by a binary relation and its action on an rr-ary relation can be enforced one argument at a time. This yields a purely relational fixed sentence using only one additional variable. We therefore obtain single-query polynomial-time reductions from unlabeled FO=k\mathrm{FO}_{=}^{k} model counting to labeled FO=k+1\mathrm{FO}_{=}^{k+1} model counting, and from unlabeled Ck\mathrm{C}^{k} model counting to labeled Ck+1\mathrm{C}^{k+1} model counting. The oracle is queried once, at the same domain size, and the answer is followed only by exact division by n!n!. For unary relational vocabularies the construction stays inside C2\mathrm{C}^{2}; together with the polynomial-time C2\mathrm{C}^{2} model-counting theorem, this gives polynomial-time unlabeled model counting for every fixed C1\mathrm{C}^{1} sentence.

This reduction should not be confused with a canonical-form or symmetry-breaking construction. That distinction is important from the complexity-theoretic viewpoint emphasized by Pak (2018, 2024). Wilf (1982) conjectured that the number unu_n of unlabeled graphs on nn vertices cannot be computed in time polynomial in nn. Pak (2024) asks the different, and still open, question whether the sequence (un)(u_n) even has a combinatorial interpretation in the complexity-theoretic sense, equivalently, whether it belongs to #P\#P when nn is given in unary. The obstacle is precisely that an unlabeled count is an orbit count: there is no evident polynomially checkable procedure that selects one representative from each orbit. For some special classes, such as plane triangulations, polynomially bounded and effectively computable automorphism groups permit explicit symmetry breaking and hence #P\#P-membership (Pak, 2024).

Our automorphism-marking construction addresses a different question. It does not select representatives and therefore does not resolve the accepting-path complexity of unlabeled graphs. Instead, it gives a one-query exact reduction from the unlabeled count to an ordinary labeled model count. The oracle is queried at the same domain size, and the answer is divided by the known factor n!n!. The reduction works by changing the objects being counted: each labeled representative is paired with one of its automorphisms, so the varying stabilizer factor cancels.

The paper is organized as follows. Section 2 fixes the logical, counting, and reduction conventions. Section 3 gives the polynomial-time model-counting algorithm for C=1[f]C_{=}^{1}[f]. Section 4 develops automorphism marking and its purely relational form. Section 5 proves the two hardness results obtained by allowing, respectively, a second variable and a second unary function. Section 6 summarizes the resulting narrow tractability boundary and its enumerative consequences, and Section 7 places the results in the surrounding literature. The longer proofs are collected in Section 8.

We work throughout with ordinary, unweighted model counting in order to keep the presentation close to the enumerative setting. The constructions also admit symmetric weighted variants; the required modifications are discussed in Section 6.

References (28)