arXiv Science⌕ Search

arXiv subjects

Ondřej Kuželka

Publications and source records attributed to Ondřej Kuželka.

At least 19 recordsLinked to original sources

Exact Counting and Sampling of Labeled Graphs of Bounded Treewidth with MSO Properties

How many graphs on $n$ labeled vertices have treewidth at most $k$, and how can we sample such graphs uniformly at random? We devise algorithms for both tasks that run in polynomial time for every fixed $k$. Efficient counting and sampling for this class had been listed as fully open. More generally, our algorithms count and sample graphs of treewidth at most $k$ satisfying any property expressible in monadic second-order logic with quantification over vertex and edge sets ($\mathrm{MSO}_2$). This provides an algorithmic counterpart to Courcelle's theorem for counting and generating graphs subject to logical constraints. The algorithms also support vertex colors and nonnegative rational vertex and edge weights determined by colors. They compute the exact total weight of all admissible colored graphs and sample each graph with probability proportional to its weight. Let $θ$ comprise the treewidth bound, color set, and logical sentence, and let $L$ denote the encoding length of the weights. Counting uses $f(θ)O(n^2)$ arithmetic operations and $f(θ)\operatorname{poly}(n,L)$ bit operations, where $f$ is a computable function. Generating each sample requires $f(θ)\operatorname{poly}(n,L)$ bit operations in expectation.

cs.DS↗

Solving Combinatorial Counting Problems with Weighted First-Order Model Counting

Combinatorial counting asks how many structures satisfy a specification of dependent choices and constraints, underpinning tasks from assignment counting to probabilistic inference. Manual derivations are fragile when specifications change, and large language models offer no guarantee of correctness, motivating declarative methods that compute exact counts automatically. Weighted first-order model counting (WFOMC), originally developed for statistical relational inference, provides a natural foundation by expressing relational constraints uniformly in first-order logic. Its lifted algorithms exploit exchangeable domain elements to count without full grounding, running in polynomial time in the domain size for fixed sentences in tractable fragments. Bridging high-level specifications to these reusable WFOMC algorithms, however, requires a count-preserving translation handling multiplicities, redundant representations, and dependent choices. We introduce Cofola, a declarative language for combinatorial counting over sets, bags, tuples, sequences, partitions, and compositions, with backend-independent joint counting semantics. We compile Cofola into symbolic WFOMC via relational encodings, polynomial weights, and decoding rules, proving exact count preservation on a supported fragment under exact symbolic computation. For multiset scalability, we introduce an optional exchangeable bag factorization that shares multiplicity symbols across interchangeable entities while provably preserving counts. Across 695 real, synthetic, and growing-domain instances, our WFOMC pipeline solves 675 within a 100-second limit per run, outperforming four alternative counting pipelines. In a controlled ablation, bag factorization raises coverage from 13 to all 32 expanded multi-type bag instances.

cs.AI↗

Removing the floor from Hoeffding and Bernstein inequalities for finite-population U-statistics

Let $C$ be a uniformly sampled $n$-element subset of a finite population $D$ of size $N$, and let $U_C$ be the complete U-statistic of order $k$ built from a bounded kernel on the $k$-subsets of $D$. We prove a product inequality for the uniform distribution on $\binom{D}{n}$ and deduce from it the comparison $ \log \mathbb{E}\left[e^{θ(U_C-\mathbb{E}U_C)}\right] \le \frac{n}{k}\log \mathbb{E}\left[e^{\frac{kθ}{n}(Y-\mathbb{E}Y)}\right]$, where $Y$ is a single kernel value taken at a uniformly sampled $k$-subset of $D$. This yields Hoeffding, Bennett and Bernstein inequalities for $U_C$ with effective sample size $n/k$ in place of the $\lfloor n/k\rfloor$ available so far. The gain is negligible when $n$ is much larger than $k$, but it approaches a factor of two in the exponent when $k$ is close to $n$.

math.ST↗

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

Every fixed first-order sentence $φ$ determines an enumerative sequence $n\mapsto \mathrm{FOMC}(φ,n)$, counting its models on the labeled domain $[n]$. We study the complexity of these sequences when logical specifications may use genuine unary function symbols and hence nested terms such as $x,f(x),f^2(x),\ldots$. We prove that, for every fixed sentence $φ\in \mathrm{C}^1_{=}[f]$ with one unary function and an arbitrary finite relational vocabulary, $\mathrm{FOMC}(φ,n)$ is computable in time polynomial in $n$. By contrast, either a second variable or a second unary function yields hardness: there is a fixed sentence in $\mathrm{FO}^2_{=}[f]$ whose model-counting function is $\#\mathrm{P}_1$-complete, and there is a fixed constant-free universal sentence in $\mathrm{FO}^1_{=}[f,g]$, using only unary predicates besides $f$ and $g$, with the same property. We also relate labeled and unlabeled enumeration exactly. For every relational sentence $φ$, we construct an extension $φ_{\mathrm{aut}}$ in which a unary function records an automorphism and $\mathrm{FOMC}(φ_{\mathrm{aut}},n)=n! \cdot \mathrm{UFOMC}(φ,n)$, where $\mathrm{UFOMC}(φ,n)$ counts the $n$-element models of $φ$ up to isomorphism. This gives a one-query exact reduction from unlabeled to labeled model counting at the same domain size. If $φ$ belongs to $\mathrm{FO}^k_{=}$, respectively $\mathrm{C}^k$, and its relational vocabulary has maximum arity $r$, eliminating the auxiliary function yields a single-query reduction to labeled model counting in $\mathrm{FO}^{\max\{k,r+1\}}_{=}$, respectively $\mathrm{C}^{\max\{k,r+1\}}$.

cs.LO↗

On the probability that a discrete IFR random variable exceeds its mean

Let $X$ be an integer-valued random variable with $\mathbb{E}(|X|)<\infty$ whose survival probabilities $S_j=\mathbb{P}(X\ge j), j\in\mathbb{Z}$, form a log-concave sequence. Suppose that for some integer $m$ and some $γ\in (0, 1/2]$ it holds $\mathbb{E}(X)\ge m$ and $\mathbb{P}(X=m+1)\geγ\cdot\mathbb{P}(X=m)> 0$. It is shown that \[ \mathbb{P}(X \ge m+1) \,\ge\, \fracγ{1+2γ} \, , \] with the bound being best possible. As a consequence, it is shown that if $H \sim \text{Hyp}(n, i, k)$ is a hypergeometric random variable for which both $ik/n$ and $(n-i)(n-k)/n$ are at least $\log(4/3)$, then it holds $\mathbb{P}(H >\mathbb{E}(H)) \ge 1/4$ when $\mathbb{E}(H)$ is not an integer, and $\mathbb{P}(H >\mathbb{E}(H)) \ge 1/6$ when $\mathbb{E}(H)$ is an integer, both bounds being best possible.

math.PR↗

CombEval: A Framework for Evaluating Combinatorial Counting in Large Language Models

We present CombEval, a dynamic benchmark for evaluating combinatorial counting in large language models. CombEval represents each problem as a typed Cofola specification over entities, combinatorial objects, object dependencies, and constraints, enabling controlled generation of natural-language counting problems with exact solver-verified answers. Unlike static collections, CombEval supports systematic variation of object type, entity scale, constraint count, and reasoning depth. We evaluate 11 LLMs under direct and code-augmented settings and find that models remain brittle on ordered objects, indistinguishable elements, relatively positional constraints, and nested object dependencies. Error analysis further identifies failures in constraint interpretation and counting principles. CombEval provides a diagnostic testbed for studying when and why LLMs fail at combinatorial reasoning. The code and generated benchmark suites are publicly available at https://github.com/YuxuZhou-CN/combination-problem-generation.

cs.AI↗

Accepting-Path Counting at the One-Tape $n\log n$ Threshold

We observe that the classical $n\log n$ time threshold for one-tape Turing machines is also a threshold for their accepting-path counts. Below it, every nondeterministic one-tape machine running in strong $o(n\log n)$ time has a rational ordinary generating function of accepting-path counts. At strong $O(n\log n)$ time, the situation changes completely: there is a fixed one-tape machine whose accepting-path function is complete for $\#\mathsf P_1$, the tally analogue of $\#\mathsf P$, under parsimonious polynomial-time tally reductions. A second construction within the same time bound gives positive accepting-path counts with a noncomputable exponential growth rate. The rationality result combines the one-tape time gap with the linear-time counting theorem of Tadaki, Yamakami and Lin. The completeness proof adapts the linear-time universal counting machine of Beame et al. to the one-tape setting.

cs.CC↗

Weighted First-Order Model Counting over Ordered Domains

The Weighted First-Order Model Counting Problem (WFOMC) asks for the weighted sum of models of a first-order logical sentence over a domain. It is a fundamental problem in statistical relational learning, with applications extending to enumerative combinatorics and graph polynomials. Computing WFOMC for the three-variable fragment is $\mathsf{\#P}_1$-hard, whereas polynomial-time algorithms exist for the two-variable fragment and its extensions by cardinality constraints and counting quantifiers. In this work, we explore computing WFOMC in polynomial time over linearly ordered domains, enabling tractable reasoning across inference scenarios and combinatorial problems involving sequences. Because encoding a linear order in standard first-order logic requires three variables, negating our polynomial-time aspirations, we add a linear order axiom directly to the language. This forces one predicate to impose a total ordering on domain elements. We first prove that WFOMC with the linear order axiom can be solved in time polynomial in the domain size. We then extend this result to ordered domains with access to successor relations. While this holds when successors are explicitly defined via the linear order, we demonstrate an alternative implicit approach where successor relations are part of the axiom. This implicit method exhibits significantly better performance on all tested instances, sometimes providing exponential runtime improvements. Finally, we analyze scenarios with two distinct linear orders. We show that WFOMC over the two-variable fragment with two linear orders is $\mathsf{\#P}_1$-hard. However, we develop a polynomial-time algorithm for WFOMC with one linear order and a successor relation of another, pushing the intractability barrier further, yet still leaving the question of how close to a second full linear order one can get.

cs.LO↗

An entropic analogue of the MMS conjecture

Let $P=\{x_1,\ldots,x_n\}$ be a multiset consisting of $n\ge 2$ real numbers such that $\sum_{i=1}^{n}x_i=0$ and $\sum_{i=1}^{n}|x_i|>0$, and let $k <n$ be a positive integer. We sample $k$ elements from $P$ without replacement and set $X_P$ be the sum of the elements in our sample. It is shown that the Shannon entropy of $X_P$ satisfies \[ \mathbf{H}(X_P) \ge \mathbf{H}(\text{Ber}(k/n)) \, , \] where $\text{Ber}(k/n)$ is a Bernoulli random variable of mean $k/n$. The result is sharp, and may be seen as an entropic analogue of the Manickam-Miklós-Singhi (MMS) conjecture.

math.CO↗

On Knowledge Compilation For Two-Variable First-Order Logic

Knowledge compilation transforms logical theories into circuit representations that support efficient reasoning. We study this problem for propositional groundings of FO2, the two-variable fragment of first-order logic over finite domains. Given an FO2 sentence and a domain of size n, its grounding yields a propositional theory over ground atoms. We ask whether such theories admit compact representations in DNNF-based and related knowledge compilation languages, and whether these can be constructed efficiently, both with respect to the domain size n for a fixed sentence. We show first that compact compilation is impossible in general: there exists an FO2 sentence whose grounding over a domain of size n requires DNNF size $2^{Ω(n)}$. On the positive side, we develop a two-stage compiler that exploits the symmetries inherent in the propositional groundings of FO2 sentences. It branches on unary and binary types rather than individual ground atoms, in a similar spirit to lifted inferences for probabilistic relational models. Moreover, it optimizes the compilation process by efficiently identifying and caching residual subproblems that are equivalent with respect to future extensions. Experiments show the practical efficiency of our approach, which often produces smaller circuits and compiles faster than straightforward grounding-based baselines.

cs.LO↗

A Fast Model Counting Algorithm for Two-Variable Logic with Counting and Modulo Counting Quantifiers

Weighted first-order model counting (WFOMC) is a central task in lifted probabilistic inference: It asks for the weighted sum of all models of a first-order sentence over a finite domain. A long line of work has identified domain-liftable fragments of first-order logic, that is, syntactic classes for which WFOMC can be solved in time polynomial in the domain size. Among them, the two-variable fragment with counting quantifiers, $\mathbf{C}^2$, is one of the most expressive known liftable fragments. Existing algorithms for $\mathbf{C}^2$, however, establish tractability through multi-stage reductions that eliminate counting quantifiers via cardinality constraints, which introduces substantial practical overhead as the domain size grows. In this paper, we introduce IncrementalWFOMC3, a lifted algorithm for WFOMC on $\mathbf{C}^2$ and its modulo counting extension, $\mathbf{C}^2_{\text{mod}}$. Instead of relying on reduction techniques, IncrementalWFOMC3 operates directly on a Scott normal form that retains counting quantifiers throughout inference. This direct treatment yields two main results. First, we derive a tighter data-complexity bound for WFOMC in $\mathbf{C}^2$, reducing the degree of the polynomial from quadratic to linear in the counting parameters. Second, we prove that $\mathbf{C}^2_{\text{mod}}$ is domain-liftable, extending tractability from $\mathbf{C}^2$ to a richer fragment with native modulo counting support. Finally, our empirical evaluation shows that IncrementalWFOMC3 delivers orders-of-magnitude runtime improvements and better scalability than both existing WFOMC algorithms and state-of-the-art propositional model counters.

cs.LO↗

Bridging Weighted First Order Model Counting and Graph Polynomials

The Weighted First-Order Model Counting Problem (WFOMC) asks to compute the weighted sum of models of a given first-order logic sentence over a given domain. It can be solved in time polynomial in the domain size for sentences from the two-variable fragment with counting quantifiers, known as $C^2$. This polynomial-time complexity is known to be retained when extending $C^2$ by one of the following axioms: linear order axiom, tree axiom, forest axiom, directed acyclic graph axiom or connectedness axiom. An interesting question remains as to which other axioms can be added to the first-order sentences in this way. We provide a new perspective on this problem by associating WFOMC with graph polynomials. Using WFOMC, we define Weak Connectedness Polynomial and Strong Connectedness Polynomials for first-order logic sentences. It turns out that these polynomials have the following interesting properties. First, they can be computed in polynomial time in the domain size for sentences from $C^2$. Second, we can use them to solve WFOMC with all of the existing axioms known to be tractable as well as with new ones such as bipartiteness, strong connectedness, having $k$ connected components, etc. Third, the well-known Tutte polynomial can be recovered as a special case of the Weak Connectedness Polynomial, and the Strict and Non-Strict Directed Chromatic Polynomials can be recovered from the Strong Connectedness Polynomials.

cs.LO↗

Tractable Weighted First-Order Model Counting with Bounded Treewidth Binary Evidence

The Weighted First-Order Model Counting Problem (WFOMC) asks to compute the weighted sum of models of a given first-order logic sentence over a given domain. Conditioning WFOMC on evidence -- fixing the truth values of a set of ground literals -- has been shown impossible in time polynomial in the domain size (unless $\mathsf{\#P \subseteq FP}$) even for fragments of logic that are otherwise tractable for WFOMC without evidence. In this work, we address the barrier by restricting the binary evidence to the case where the underlying Gaifman graph has bounded treewidth. We present a polynomial-time algorithm in the domain size for computing WFOMC for the two-variable fragments $\text{FO}^2$ and $\text{C}^2$ conditioned on such binary evidence. Furthermore, we show the applicability of our algorithm in combinatorial problems by solving the stable seating arrangement problem on bounded-treewidth graphs of bounded degree, which was an open problem. We also conducted experiments to show the scalability of our algorithm compared to the existing model counting solvers.

cs.LO↗

Weighted First Order Model Counting for Two-variable Logic with Axioms on Two Relations

The Weighted First-Order Model Counting Problem (WFOMC) asks to compute the weighted sum of models of a given first-order logic sentence over a given domain. The boundary between fragments for which WFOMC can be computed in polynomial time relative to the domain size lies between the two-variable fragment ($\text{FO}^2$) and the three-variable fragment ($\text{FO}^3$). It is known that WFOMC for \FOthree{} is $\mathsf{\#P_1}$-hard while polynomial-time algorithms exist for computing WFOMC for $\text{FO}^2$ and $\text{C}^2$, possibly extended by certain axioms such as the linear order axiom, the acyclicity axiom, and the connectedness axiom. All existing research has concentrated on extending the fragment with axioms on a single distinguished relation, leaving a gap in understanding the complexity boundary of axioms on multiple relations. In this study, we explore the extension of the two-variable fragment by axioms on two relations, presenting both negative and positive results. We show that WFOMC for $\text{FO}^2$ with two linear order relations and $\text{FO}^2$ with two acyclic relations are $\mathsf{\#P_1}$-hard. Conversely, we provide an algorithm in time polynomial in the domain size for WFOMC of $\text{C}^2$ with a linear order relation, its successor relation and another successor relation.

cs.LO↗

Faster Lifting for Ordered Domains with Predecessor Relations

We investigate lifted inference on ordered domains with predecessor relations, where the elements of the domain respect a total (cyclic) order, and every element has a distinct (clockwise) predecessor. Previous work has explored this problem through weighted first-order model counting (WFOMC), which computes the weighted sum of models for a given first-order logic sentence over a finite domain. In WFOMC, the order constraint is typically encoded by the linear order axiom introducing a binary predicate in the sentence to impose a linear ordering on the domain elements. The immediate and second predecessor relations are then encoded by the linear order predicate. Although WFOMC with the linear order axiom is theoretically tractable, existing algorithms struggle with practical applications, particularly when the predecessor relations are involved. In this paper, we treat predecessor relations as a native part of the axiom and devise a novel algorithm that inherently supports these relations. The proposed algorithm not only provides an exponential speedup for the immediate and second predecessor relations, which are known to be tractable, but also handles the general k-th predecessor relations. The extensive experiments on lifted inference tasks and combinatorics math problems demonstrate the efficiency of our algorithm, achieving speedups of a full order of magnitude.

cs.AI↗

Model Enumeration of Two-Variable Logic with Quadratic Delay Complexity

We study the model enumeration problem of the function-free, finite domain fragment of first-order logic with two variables ($FO^2$). Specifically, given an $FO^2$ sentence $Γ$ and a positive integer $n$, how can one enumerate all the models of $Γ$ over a domain of size $n$? In this paper, we devise a novel algorithm to address this problem. The delay complexity, the time required between producing two consecutive models, of our algorithm is quadratic in the given domain size $n$ (up to logarithmic factors) when the sentence is fixed. This complexity is almost optimal since the interpretation of binary predicates in any model requires at least $Ω(n^2)$ bits to represent.

cs.LO↗

Concentration inequalities for the sum in sampling without replacement: an approach via majorization

Let $P=(x_1,\ldots,x_n)$ be a population consisting of $n\ge 2$ real numbers whose sum is zero, and let $k <n$ be a positive integer. We sample $k$ elements from $P$ without replacement and denote by $X_P$ the sum of the elements in our sample. In this article, using ideas from the theory of majorization, we deduce non-asymptotic lower and upper bounds on the probability that $X_P$ exceeds its expected value.

math.PR↗

Complexity of Weighted First-Order Model Counting in the Two-Variable Fragment with Counting Quantifiers: A Bound to Beat

We study the time complexity of the weighted first-order model counting (WFOMC) over the logical language with two variables and counting quantifiers. The problem is known to be solvable in time polynomial in the domain size. However, the degree of the polynomial, which turns out to be relatively high for most practical applications, has never been properly addressed. First, we formulate a time complexity bound for the existing techniques for solving WFOMC with counting quantifiers. The bound is already known to be a polynomial with its degree depending on the number of cells of the input formula. We observe that the number of cells depends, in turn, exponentially on the parameter of the counting quantifiers appearing in the formula. Second, we propose a new approach to dealing with counting quantifiers, reducing the exponential dependency to a quadratic one, therefore obtaining a tighter upper bound. It remains an open question whether the dependency of the polynomial degree on the counting quantifiers can be reduced further, thus making our new bound a bound to beat.

cs.LO↗