arXiv:2610.26187cs.AIOct 2026

Manuscript Offprint

arXiv:2610.26187

On Counting Graphs for Modal Logic with Counting

Avijeet Ghosh, François Schwarzentruber

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

In this paper, we study the theoretical computational complexity of counting trees and graphs that are classified positively by a graph neural networks, or said equivalently that satisfy a given formula of modal logic with counting. We also study convergence.

2012 ACM Subject Classification

Keywords and phrases graph neural networks, counting problem, modal logic with counting

On Counting Graphs for Modal Logic with Counting

1 Introduction

Validity problems in modal logic is relevant in many reasoning tasks: verification of systems, epistemic planning. However, validity problem is rigid in this sense: a formula is valid if it holds in all models. In this paper, we relax the validity problem to model counting and we study the probabilistic validity problem: Is a formula true in a large proportion of models? Is a formula asymptotically true for large models? What is the proportion of models in which a formula holds? First, let us give motivation from a verification problem of graph neural networks (GNNs).

Recently, an exact correspondence between modal logic with counting verifying GNNs has been settled and applied for verifying properties on GNNs ([19], [18], [5]). In this paper, the only thing the reader must know is that each GNN from a large class of GNNs, namely with an eventually constant activation function or let say with truncated ReLU, is equivalent to a formula φGNN\varphi_{GNN} from a logic called K#K^{\#}, which is a natural extension of graded modal logic with linear arithmetic inequations (see [19], [18], [5]). The notion of equivalence is: a pointed graph GG, uu is classified positively by the GNN iff φGNN\varphi_{GNN} holds in GG, uu.

An example of K#K^{\#}-formula is #p≥#q+2\#p \geq \#q + 2 which means that there are more p-successors than q-successors plus two. For instance, the formula #p≥#q+2\#p \geq \#q + 2 is true in the pointed

graph p←p←p←q←◯◯◯p \leftarrow p \leftarrow p \leftarrow q \leftarrow \bigcirc \bigcirc \bigcirc since 3≥1+23 \geq 1 + 2.

Verifying GNNs is important in order to understand how they classify data. For instance, we could verify that a GNN recommends a person whenever that person has at least 3 violinist friends, meaning that for all pointed graphs (G,u)(G, u), if the current vertex has at least 3 violinist successors then the GNN classifies (G,u)(G, u) positively. This kind of verification tasks were addressed in [18], and on quantized GNNs in [21] and [8].

However, it is unlikely that a property holds for all GNNs. For instance, it is unlikely that a GNN recommends a person whenever that person has at least 3 violinist friends. The reason is because the concept of recommended persons is a vague concept that is difficult to explain and does not completely match a property as precise as "having at least 3 violinist friends" (written #violinist≥3\#violinist \geq 3). The second reason is that there are approximations due to learning process itself, making unlikely that the obtained GNN exactly corresponds to a given property.

However, it is possible that a property like "having at least 3 violinist friends" is a probable explanation of the classification of the GNN. That is why, instead of checking that φ→φGNN\varphi \to \varphi_{\mathrm{GNN}} is valid, we want to compute the probability that φ→φGNN\varphi \to \varphi_{\mathrm{GNN}} holds where φGNN\varphi_{\mathrm{GNN}} is a formula that is true when the GNN recommends the current model, and φ\varphi is a property, e.g. "the person has at least 3 violinist friends", #violinist≥3\#violinist \geq 3. We may then conclude that the probability that φ→φGNN\varphi \to \varphi_{\mathrm{GNN}} holds in graph of size 42 is more than 0.8.

Our paper is related to 0-1 law that first-order logic has: any FO-sentence φ\varphi is asymptotically true in large models or false in large models. While specific classes of GNNs have 0-1 law ([2], [1]), this is clearly false for logic K#K^{\#}. Indeed, the limit of the truth of #p≥#q\#p \geq \#q is 1/2. This justify the study of computing the probability of a formula φ\varphi given the size of the graph, or counting the number of φ\varphi-models of size nn. As many modal logics have the tree-model property, we also focus on trees and counting the number of trees satisfying φ\varphi given a branching factor.

Counting models. We study the complexity of counting φ\varphi-trees/graphs, given formula φ\varphi from logic K#K^{\#} (see Figure 1).

nn unarynn binary
Trees#PSPACE\PSPACE-complete
Graphs#P-complete#EXPTIME\PSPACE-hard

Figure 1 Complexity results about counting trees (nn is the branching factor) or graphs (nn is then the number of vertices).

■ Convergence. We show that the proportion of φ\varphi-trees does not converge for some φ\varphi. We propose an artificial trick to make it converge.

Outline. In Section 2 we discuss the related work. In Section 3, we recall the formal definition of logic K#K^{\#}. In Section 4, we define the counting problems we are studying. In Section 5, we provide our complexity results. We also have an implementation using Monte-carlo method that samples arbitrary large graphs and trees and gives out the proportion of satisfiability1^{1}. In Section 6, we exemplify non-convergence in trees and provide a patch for having convergence. In Section 7, we conclude.

Some parts of the proof of Theorem 28 were obtained by AI, although the authors have come up with the general approach by themselves.

References (23)