WorksComputer Science
Two Primes Suffice for Definable Graph Canonisation
Abstract
We study inflationary fixed-point logic on finite simple graphs with unordered vertices and an ordered number sort. For a prime , the quantifier tests whether the number of relations satisfying a formula is nonzero modulo . For any distinct primes and , the logic with and defines the adjacency matrix of a canonical copy on the number sort. On labelled inputs this matrix is computable in deterministic polynomial time with an oracle that tests whether the number of satisfying assignments of a Boolean circuit is nonzero modulo . For each prime , the logic with alone cannot define a canonical copy on all graphs. The primes also differ on Boolean queries. There is a single first-order formula on vertex sets such that is undefinable with alone whenever . For a positive integer-valued function , consider the class of all graphs with at most automorphisms. For each fixed prime , the logic with canonises this class exactly when is bounded.
Introduction
The two endpoints of a single edge are indistinguishable. Neither can be chosen first by a formula, yet either ordering gives the same adjacency matrix. For a graph on vertices, a canonisation specifies an isomorphic graph on whose adjacency matrix depends only on the isomorphism type of the input.
On ordered structures, fixed-point logic captures polynomial time (PTIME) [17, 22]. A definable canonisation lets us apply this theorem to an unordered graph by evaluating a sentence on its ordered copy. This is how Grohe [14] obtains a logic for PTIME on graph classes with an excluded minor. On arbitrary graphs, the question is whether there is a logic with effective syntax that expresses every PTIME graph property and effectively assigns a polynomial-time evaluation algorithm to each sentence [15]. For a logic that evaluates ordered fixed-point sentences on a canonical copy, it would suffice to compute that copy in polynomial time.
The input has an unordered vertex sort and the ordered number sort . For a prime , the formula holds when the number of relations satisfying is nonzero modulo . Each relation variable has a fixed arity and specified argument sorts. For example, it may count vertex sets or binary relations that encode maps from vertices to numbers. Let be first-order logic with inflationary fixed points and , and let allow both modular quantifiers. Our first theorem separates these languages using only a set of vertices as the counted relation.
Theorem (Boolean separation). There is a first-order graph formula with one unary relation parameter such that, for every pair of distinct primes , the graph property is undefinable in . Consequently the single-prime languages are pairwise incomparable on graphs, and adjoining any second prime strictly increases expressive power.
To construct , take a connected network over the field with a prescribed net outflow at each vertex. If the prescribed values sum to zero, any assignment to the edges outside a spanning tree extends to a unique flow. There are then flows. If the total is nonzero, there are none. Counting modulo any other prime distinguishes these cases. The graph encodes the local constraints, and each flow corresponds to one set satisfying .
To prove the separation, we must rule out every sentence that might distinguish the two loads. We use the prime-field version of the Cai–Fürer–Immerman construction [5, 12]. Its automorphisms form a -group, a group whose order is a power of . When this group acts on the relations satisfying a formula, only relations fixed by the whole group contribute modulo . We match those fixed relations across the two structures and prove that the matching persists under further quantification and at each stage of a fixed point.
Kontinen and Szymanik (2014, Definition 2.7 and Corollary 3.6) separated coprime second-order divisibility quantifiers on a supplied family of sets. Here a single first-order formula defines the family on simple graphs, and the competing logic may count relations of any fixed arity. Affine systems have also supplied lower bounds for infinitary counting logic (Atserias et al., 2009) and for logics with linear-algebraic operators [13, 7]. In our examples Gaussian elimination over decides whether a solution exists, although the number of solutions is divisible by on both graphs.
Theorem (Canonisation). For any distinct primes , an formula defines the adjacency matrix of a canonical copy of every finite simple graph on its number sort. No formula defines such a copy on all finite simple graphs.
For the lower bound, a proposed one-prime formula would give the same adjacency bit at every numerical position on two nonisomorphic CFI graphs. For the upper bound, let be a Sylow -subgroup of the permutations of , so its order is the largest power of dividing . Group two labellings together if they differ by a permutation in . Each class, called a frame, has labellings, and the number of frames is prime to . Canonical placement under a permutation group [2] selects one adjacency string per frame. The inner quantifier recognises a frame with a given prefix because does not divide the number of compatible labellings. The outer quantifier counts each such frame once. Starting at the empty prefix, we can always extend by a bit whose count remains nonzero. The final string is a copy of the graph.
Our companion paper [11] uses the same count of cosets of a Sylow subgroup. Its algorithm guesses one representative per coset on a labelled input. Here we represent each coset by a relation on unordered vertices. The matrix can be computed in polynomial time with an oracle for modular circuit satisfiability. This oracle tests whether the number of satisfying assignments is nonzero modulo , a complete problem for . Evaluating ordered fixed-point sentences with this circuit test on the copy captures the isomorphism-invariant queries in .
When one prime suffices. A base for a permutation group is a tuple of points whose pointwise stabiliser contains only the identity. We now consider bases for the vertex action of a Sylow -subgroup of the automorphism group . For a positive integer-valued function , let .
Theorem (One-prime canonisation and capture). Fix a prime and an integer . On graphs where a Sylow -subgroup of has a base of at most vertices, defines a canonical ordered copy and captures the invariant Boolean queries.
On , each of these conclusions holds if and only if is bounded. One PTIME graph property witnesses failure of capture for every prime and every unbounded . Both equivalences also hold when bounds the Sylow -subgroup order or its minimum base size.
The entries of a base of bounded size allow a single relation of fixed arity to encode an entire orbit of labellings. For the converse, we read the field as well as the flow equations from the graph. Solubility is then one PTIME property for all primes. Taking the disjoint union of each graph in a CFI pair with the same long path preserves both answers and doubles each automorphism group order. We can therefore meet the bound at any sufficiently large size where exceeds these two orders.
We first encode the flow problem on simple graphs and prove that the one-prime logic preserves the resulting pairs. We then construct the ordered copy and show how to evaluate queries on it. The final sections treat graphs with bounded symmetry, the polynomial-time prefix test on circulants of bounded odd part, and the counts that can be computed on odd cycles.
Syntax and ordered output
Write for the vertex domain and for the number domain, where . Equality compares elements of the same sort. Adjacency is a relation on , and order is a relation on . For other input vocabularies, all input relations likewise have object arguments. If is the product of the argument sorts of , then
Each interpretation of gives one expansion of the input structure. Compton and Grädel [6] study the number of satisfying expansions as a counting function. On strings, Kontinen and Vollmer [20] study related second-order quantifiers over unary relations. Here may have arguments of either sort. The language is closed under Boolean operations and first-order quantification of either sort. We use the inflationary semantics of Gurevich and Shelah [16]. A fixed point with body starts at and successively sets . It returns the first stable relation. Parameters keep their values during iteration. This convention allows negation and modular tests in the body without a monotonicity assumption. Simultaneous tables can be represented by one relation with a numerical tag. Any finite list of exceptional domain sizes in such an encoding can be handled by first-order cases.
A canonising formula has two free number variables. Its output is the graph on with the edges it defines, equipped with the usual order. Its graph reduct must be isomorphic to the input, and isomorphic inputs must have identical outputs. The latter condition is automatic for formulas in our language because an input isomorphism acts as the identity on . The formula gives the edges on numbers directly and need never choose a bijection from to . We apply the Immerman–Vardi theorem only after defining the input to an ordered computation on the number sort.
A flow problem on graphs
Fix a prime and a connected ordered cubic graph , where is its set of undirected edges. The CFI structure over encodes a flow problem in a vocabulary independent of [12 Section 5]. For each orientation of an edge, its domain contains a fibre . The base order induces an order on the directed edges. A preorder on the domain compares elements by their edge and ties the elements of each fibre. A successor relation acts by in each fibre, and an inverse relation links to .
A load specifies the net outflows. At each vertex , list the three outgoing edges in base order. The ternary relation on their fibres contains exactly the triples whose coordinates sum to . Write for the resulting structure. Only the relations belong to the vocabulary. The field coordinates serve to describe the construction.
Write for equivalence in the fibre preorder, for the inverse relation, and for the CFI ternary relation. Define to hold if some , , satisfy . It records the ordered triples of fibres incident at a base vertex. A section is a set that selects exactly one element of each fibre. We write for the first-order condition that is a section satisfying both constraints. Selection of forces selection of its inverse whenever holds. For three selected elements , the incidence condition forces .
Lemma (Counting flows). On the number of sets satisfying is zero if and is otherwise.
Proof. Orient the undirected edges for the calculation. The selected point in each forward fibre specifies one field value. The inverse condition fixes the value in the reverse fibre as its negative. The ternary condition gives exactly the signed incidence equations prescribing divergence . Summing them gives the necessary zero-total condition. Conversely, choose a spanning tree and assign arbitrary values to the edges outside it. Each leaf equation fixes the remaining incident tree edge. Stripping leaves determines all tree edges, and the last equation holds by the zero-total condition. Each resulting flow gives a different set .
For example, take the complete graph on four vertices as the base over . Three of its six edges lie outside a spanning tree. Eight sets satisfy Sec at total load zero, and none do at total load one. Counting sections modulo three distinguishes the loads. To rule out every formula with modulus two we will need larger base graphs.
Encoding the witnesses as vertex sets
The graph encoding must preserve the number of witnesses. It must also let us recognise relations on graph tuples when proving the lower bound. We use a separate vertex for each tuple and give every auxiliary vertex a unique code over the original structure.
Lemma (An incidence encoding). For a fixed finite relational vocabulary of positive arities there is a faithful encoding as a simple graph. Its size depends only on . Each graph vertex has a unique representation by a finite tag and a bounded tuple of elements of . Adjacency on these codes is first-order definable. The object domain and its relations are first-order recoverable in the graph.
Proof. Start with an element vertex for each object. For each symbol of arity and each , add a tuple vertex, a marker, and position vertices. Join each position to the tuple and to its element . Join the marker to the tuple precisely when holds. Distinguish element, tuple, marker and position types, including the relation symbol and the position index, by attaching a different constant number of private leaves to each type, always at least two. The element, tuple, marker and position vertices now have degree at least two. The private leaves have degree one. The type of each nonleaf vertex is read from its number of leaf neighbours. Relations on element vertices are thus recovered by a fixed first-order formula following the position edges and testing the marker edge. Every structure isomorphism extends, and every graph isomorphism induces a structure isomorphism. A private leaf has the code of its parent and a fixed leaf index. All code domains depend only on , even when membership of tuples changes.
On simple graphs, define by interpreting on the decoded element vertices and requiring every member of to be an element vertex. Each flow then gives exactly one witness on the graph. Neither the decoder nor mentions the field size.
Preservation at one prime
The flow count shows why counting sections modulo loses the total load. To prove undefinability we compare the two CFI structures on arbitrary formulas. We first describe how a correspondence between tuple orbits extends to relations.
Fix and consider formulas that use at most variable symbols and allow arbitrary conjunctions and disjunctions. For each integer they also allow a quantifier asking whether at least elements satisfy a formula. The counting type is the set of these formulas true of in . We call two tuples matched if their types agree. Numeric parameters, when present, must agree coordinate by coordinate. The counting types are taken in the original object vocabulary. We use these types to compare structures in the proof.
Matching relations across two structures
Let be finite structures of the same vocabulary and cardinality, and let be -subgroups of their automorphism groups. Suppose that the empty tuples are matched. Up to a tuple length , suppose also that within either structure two tuples have the same -type exactly when they lie in the same orbit of its designated group. Call the tuple of assigned object parameters the context. Write for its pointwise stabiliser, the subgroup fixing each entry of , and define likewise. Suppose the contexts match. For , the correspondence
is a bijection between stabiliser orbits on -tuples. Indeed, among tuples realised in the two finite structures any one -type can be isolated by conjoining formulas that distinguish it from the other realised types. Existentially binding the new variables gives a test of realisation over the context, within the same slots. The tests agree on matched contexts. Within each side, equality of the extended types gives a group element sending one extension to the other and fixing the common prefix. For mixed-sort tuples we use the same bijection separately at each numerical tuple.
For matched contexts , write for the union of the orbits corresponding to those in , whenever is a union of -orbits. This transport is a bijection on invariant relations of each allowed sort and arity. It preserves unions and the empty relation. In a purely numerical argument domain the orbits are singletons and transport is the identity.
The formula determines how long a tuple we must match. Let be the number of object variables in the initial context, including all free object variables. Give distinct names to all bound variables. Let be the total number of object variables bound by individual quantifiers or introduced as arguments of fixed-point bodies. Let be the largest number of object arguments of any relation variable in the formula, taking if there are none. A bound then covers the context of every subformula together with one argument tuple for a relation. Repeated fixed-point stages use the same variables.
Lemma (Preservation under modular relation quantification). Let and let satisfy the orbit and counting-type hypotheses above through length . Evaluate at matched contexts . For each free relation let its value on be invariant under and give it value on . Then the two evaluations agree.
Proof. We argue by induction on the formula, retaining the outer context at each step.
Extending the context. If and match, every relation invariant at is invariant at . Moreover,
Corresponding orbits in the extended contexts have the same extended type. Forgetting the new coordinates sends them to corresponding orbits in the original contexts. Membership in is constant on each original orbit, which proves the equality. In particular, a relation bound by an outer modular quantifier keeps the same interpretation when an inner quantifier introduces a new parameter.
Atomic formulas agree by matched types, equality of numerical arguments, and the assumption on free relations. The Boolean steps follow immediately. For a first-order existential formula, extend the context by a witness. The orbit correspondence supplies a matched extension on the other side. For a numerical witness use the same number. The induction hypothesis applies, and the argument is symmetric.
Binding a relation. For in , the stabiliser of acts on the set of all assignments to that satisfy . This set is closed under the action because the other free relations are invariant and formula evaluation commutes with automorphisms for every assignment to . An automorphism carries the witnesses of each inner modular test bijectively to those for the transported parameters, and it carries each fixed-point stage to the corresponding stage. Each orbit with more than one assignment has size divisible by . It follows that the count modulo depends only on the satisfying assignments fixed by the stabiliser. Each fixed assignment to is a union of orbits on its argument tuples. The orbit correspondence pairs these unions bijectively across the two structures. Applying the induction hypothesis to with each corresponding pair of assignments shows that equal numbers of them satisfy . The two modular counts therefore agree.
Iterating a fixed point. Let be one inflationary update in the original context , and define likewise. Write . If the original stabiliser fixes , it also fixes , since formula evaluation commutes with automorphisms. At matched argument tuples , the refinement identity allows us to pass and all outer relations to the body. The induction hypothesis for the body gives the same decision about adding the tuple on both sides. Old membership also agrees. Hence the updates satisfy
Starting from the empty relations gives at every stage . Bijectivity of implies that a stage changes on one side exactly when it changes on the other. At their common stable stage, membership agrees at the argument of the fixed-point formula. This stage argument uses the induction hypothesis only for the update body, which may itself contain fixed points and modular quantifiers.
Applying the lemma to the encoded graphs
On a common connected base, two CFI structures are isomorphic exactly when their total loads agree. Their automorphisms act by translations on the edge fibres and form a -group [12 Section 5.2 and Theorem 5.2].
Two further results apply on the ordered cubic expander bases. For every fixed , structures with different total loads on a sufficiently large common base agree on all -variable counting sentences [12 Theorem 5.6]. Within either structure, the counting type in variables determines the automorphism orbit of an -tuple, for a constant independent of the base [12 Theorem 5.7]. Given the tuple bound , choose large enough to read the vocabulary and then choose the base. This gives both hypotheses of the preservation lemma on the CFI structures.
Proof (One-prime lower bound). Fix a proposed canonising formula. Multiply its tuple-length bound by the maximum number of object coordinates in a graph vertex code (the incidence encoding). Choose CFI structures , on the same base with total loads zero and one, using this enlarged bound. Let act on through the coordinates of the codes, fixing each tag, and use the corresponding action on . These designated groups are -groups even though private leaves with the same parent can also be permuted. The tags specify this action on the constructed graphs. No tag or leaf index is supplied to the proposed canonising formula.
Match two graph tuples when their tags agree and their concatenated object coordinates have the same counting type. For fixed tags, extending a graph tuple amounts to adjoining a bounded number of object coordinates. The uniqueness of each code therefore gives the orbit correspondence on graph tuples. Forgetting a graph parameter removes exactly its tag and object coordinates, so the refinement identity for invariant relations also holds. Atomic adjacency agrees because it is first-order definable on codes, with chosen large enough for the decoding formula. The graphs have the same size, so their numerical parameters match by equality.
The induction in the preservation lemma uses only agreement on atomic formulas and a bijection of extension orbits compatible with forgetting coordinates. The matching on graph codes supplies both, so the proposed formula gives the same answer on the two graphs at each numerical pair . A single matrix cannot be a copy of two nonisomorphic graphs.
Proof (Boolean separation). Fix and any prime . On graphs encoding CFI structures over , the flow count gives either zero witnesses or a power of . Consequently accepts exactly the zero-total loads on these encodings. If an sentence defined this graph query, the preceding argument with empty context would give it the same truth value on the two encoded structures. This contradicts the count. Exchanging the roles of and gives incomparability. Syntactic inclusion gives and the exhibited sentence makes this inclusion strict.
A canonical matrix with two primes
Fix distinct primes . A frame groups together the labellings that differ by a permutation in a fixed Sylow -subgroup of . To count frames with a relation quantifier, we need one relation per class of labellings. We construct that relation from the colours of ordered pairs of positions.
The frame and its labellings
Write in base . Divide into consecutive slots in decreasing order of size, with separately indexed slots of size . Identify the members of such a slot with the words of length over in digit order. For a pair of positions record both slot indices. For distinct words in the same slot record also the first position at which they differ and the difference between their digits there, taken in argument order (second minus first). Use separate tags for a diagonal pair and a pair in different slots, and fix every unused coordinate to zero. Regard this table as a relation whose unique value is a fixed-length numerical tuple. For fixed its entries are uniformly computable in polynomial time, so an ordered fixed-point formula defines . Write for the exponent of in .
Lemma (The group of a frame). The automorphism group of the table on its position domain, with colours fixed, has order .
Proof. Each slot is preserved. Within a slot the first differing position tells which pairs agree on any given prefix. A table automorphism therefore acts on the rooted tree of prefixes. If it sends a node to another node, the induced bijection of their child digits satisfies for all . It is a translation. Conversely, choosing a translation at each internal node defines a tree automorphism that preserves the table. A slot of size has internal nodes. Thus the exponent of in is
For a bijection let mean . Two maps give the same relation exactly when . Each frame occurs as the pullback of exactly maps. Consequently there are frames, a number nonzero modulo .
Reading a frame and choosing the prefix
The cyclic shifts of the children at individual nodes generate . Each shift leaves suffix digits unchanged, and there are only polynomially many nodes. Acting on unordered pairs of positions, these generators again give a -group, hence a solvable group. The canonical placement algorithm of Babai and Luks [2]}) therefore computes in polynomial time a string in the orbit of , with the same output for all strings in that orbit. We order pairs lexicographically, use for bits and follow their first-orbit and first-minimal-block-system rules (Section 3.2). For any labelling compatible with a frame , put
All compatible labellings give the same string because they differ by elements of .
Encode a prefix by its length or endpoint and its known bits in the lexicographic order on pairs . Define by requiring that be the graph of a bijection, that agree with on every argument, and that start with . The last test is a polynomial-time predicate on an ordered graph with numerical parameters encoding . Translate it to ordered fixed-point logic and substitute
for the transported edge relation. The resulting formula for uses only first-order quantifiers and fixed points.
Lemma (Counting frames with a given prefix). The formula
holds exactly when the number of frames for which begins with is nonzero modulo .
Proof. For an invalid table no bijection passes the pullback test. For a valid frame the number of maps passing all three tests is either zero or . Since is a power of , the inner quantifier accepts exactly the valid frames with the specified prefix. Each such frame contributes one assignment to the outer quantifier.
Take a graph consisting of two disjoint edges and let . The three frames are the three partitions into two pairs, each with eight compatible labellings. One frame pairs the endpoints of both edges and places a one first. The other two pair non-neighbours and place a zero first. With the inner test recognises each eligible frame since eight is nonzero modulo three. Two frames extend the empty prefix by zero and one frame extends it by one. The parity test therefore chooses one. Counting labellings by parity would give zero for both children.
Proof (Two-prime construction). Let count the frames whose placed string begins with . The count at the empty prefix is prime to . If the current count is nonzero modulo , then implies that at least one child count is nonzero modulo . Choose zero when the test in the prefix-counting lemma accepts , and one otherwise. An inflationary fixed point stores triples for the bits already decided. Its body adds the value for the first undecided pair using the current table and the prefix test. By induction every stage is a prefix with nonzero count. After steps some frame realises the entire string. That string is a labelled copy of the input. Relabelling the input transports frames bijectively and preserves their strings, so it preserves all the decisions. Read the stored bits symmetrically, with zero diagonal. For the output edge relation is empty.
Computing the same matrix with one oracle. On a labelled input, guess one membership bit for each entry of the frame table in a fixed order. Each table occurs on exactly one branch. The following procedure recovers a compatible map from every valid table. Read slot indices from diagonal entries. Within each slot group leaves by agreement through each prefix length, using the first-difference field. Check that these are nested partitions of the required sizes. At each internal node take the child containing the least input vertex for digit zero and use the recorded differences from it to place the others. Reject if any test fails. Once all digits have been assigned, compare the entire table with the pullback along the resulting bijection. This equality certifies that the table is a frame. On a valid frame, translation symmetry permits any choice of the zero child. Compute using this map and check the prefix. The accepting path count is exactly . A oracle answers the zero-child query at each of polynomially many positions.
Evaluation on the ordered copy
For any polynomial-time graph property , the Immerman–Vardi theorem gives an IFP sentence defining on ordered graphs. Run on the number sort, replacing each adjacency test by . By the canonisation theorem the graph on which runs is isomorphic to the input, so the resulting sentence defines . Once the matrix is known, evaluating takes ordinary polynomial time.
We can also characterise the queries computable with the same oracle that constructs the matrix. Keep fixed and allow ordered IFP sentences to test whether a definable Boolean circuit has a nonzero number of satisfying assignments modulo . Index the gates by fixed-length number tuples and reject circuit descriptions that are malformed or cyclic. To express this test, bind a relation of gate values by , check every gate and the output, and force unused tuple entries to be zero. Each satisfying assignment to the input gates has a unique extension to all gates.
Corollary (Evaluation on the ordered copy). Ordered fixed-point logic with modular circuit tests, evaluated on the copy defined by , captures the isomorphism-invariant Boolean graph queries in .
Proof. First compute the canonical copy with a oracle. For any fixed ordered sentence the relation tables and fixed-point iterations are polynomially bounded. Each circuit call has polynomial size and takes one oracle query after its description has been evaluated. Fixed nesting of subformulas preserves the polynomial bound.
For the converse, take modular circuit satisfiability as the complete oracle problem. A polynomial-time nondeterministic verifier can be represented by a circuit on its polynomially many choice bits with unused bits fixed, preserving the path count. Fix a deterministic polynomial-time oracle machine for the query. On the ordered copy, tuples index time, tape cells and query gates up to the machine’s polynomial bound. An inflationary table records the configuration at each time. Its successor row is given by the fixed transition rule, using the circuit test on the preceding query tape at an oracle instruction. The initial row and the decoding of the query tape are polynomial-time ordered predicates and hence are definable by ordered fixed points. The accepting state defines the desired sentence. Isomorphism invariance gives the correct answer on the canonical copy.
One prime under symmetry bounds
The two-prime construction counts a frame by testing its labellings with a second prime. Under the base hypothesis of the one-prime canonisation theorem, we can count orbits of labellings directly. Wielandt [23] showed that the orbits on -tuples determine a permutation group with a base of size . Köbler and Verbitsky [18] used bases for the full automorphism group to reduce parallel canonisation to a complete invariant for coloured graphs. Here the base bound applies to a Sylow subgroup. The input supplies neither the subgroup nor a base. We perform the group computations on the number sort once a candidate graph has been specified.
When , we have , and exactly bijections onto give any specified copy. On the number sort a one-prime formula can test whether that copy equals the canonical output, using the ordered simulation of the oracle machine. Counting the bijections that pass this test and give a one at recovers the canonical bit. For larger the same multiplicity can be zero modulo . We therefore count orbits of bijections under a suitable subgroup. A related result of Faben and Jerrum [9] says that two graphs without automorphisms of order are isomorphic if their homomorphism counts from every graph agree modulo .
Encoding an orbit of labellings by one relation
Keep the Sylow subgroup and the canonical placement function from the two-prime construction. For an ordered candidate graph on , put , where automorphisms here preserve the graph reduct of . We can compute generators of in polynomial time on the number sort by the Babai–Luks stabiliser algorithm for the solvable group acting on pair positions [2 Lemma 3.2 and Theorem 3.5]. For this action is faithful, and a permutation of vertices is recovered from its action on incident pairs. Smaller graphs can be handled directly.
Suppose satisfies the base bound of the one-prime canonisation theorem. If is a copy of , then lies in a Sylow -subgroup of . By Sylow conjugacy that subgroup has a base of size at most , which is also a base for . We need only a base for this last group. For example, on a triangle a single vertex can be a base for a Sylow -subgroup even though its stabiliser in the full group contains a transposition.
Call a candidate admissible if and admits a base in , allowing repetitions. For an admissible candidate take the lexicographically first such tuple . Compute from its generators [10]. For fixed each tuple orbit has size at most , so we can enumerate it in polynomial time and test whether its size equals . At the sole candidate base is the empty tuple, which passes precisely when is trivial. Orbit membership for -tuples is polynomial-time decidable by the same enumeration. Ordered fixed-point logic defines both tests.
For an isomorphism define the mixed-sort relation
Its slice at is empty unless some sends to . Such an is unique because is a base. The slice is then the graph of . Conversely, every occurs in the slice at . Thus the distinct nonempty slices are precisely the maps in the orbit .
Lemma (One relation per orbit of labellings). For each admissible , a formula with first-order quantifiers on the vertices and fixed points on the number sort recognises exactly the relations . There is one such relation per -orbit of isomorphisms from to .
Proof. For a proposed relation , existentially quantify a vertex tuple and read the slice as the graph of a map . Verify that it is a bijection carrying the edges and nonedges of to those of . Test the displayed equivalence defining on every argument, using that slice wherever occurs. If the test succeeds, . For the slice at gives , so the test succeeds. Postcomposition by preserves . Conversely, implies that the slice equal to also occurs in , so for some . The tuple is an ordinary existential witness inside the test, so choosing it introduces no multiplicity into the count of relations.
For a prefix , count pairs for which is an admissible -canonical graph extending and satisfies the orbit encoding conditions. A single binder counts these pairs. Reserve two numerical tags in one mixed-sort relation, one for and one for . For each tag, require membership to be independent of the unused coordinates. Forbid entries with any other tag. This encodes each pair exactly once on domains of size at least two. The candidate adjacency relation is required to be symmetric with empty diagonal.
Let . There are isomorphisms from to a specified copy . The free action of on these maps gives distinct relations for . The -orbit of , in turn, contains labelled graphs. Sum over the unique -canonical representative of each orbit of copies. All these representatives are admissible, so the count at the empty prefix is
This integer is prime to . The same pairs partition at each prefix according to the next bit of . We can therefore use the prefix fixed point to choose a full string. Relabelling transports and fixes , so every input labelling gives the same string.
On labelled inputs the data complexity of every fixed formula is in . To see this, induct on syntax with the current free relations supplied as explicit tables. A modular binder guesses one table and tests its body by an oracle call. Individual quantification and fixed-point iteration need only polynomially many such calls for a fixed formula. The induction closes by the prime-modulus lowness theorem [3 Theorem 6.7 and Corollary 6.8]. Conversely, on the promised class the matrix formula supplies an ordered copy. The ordered circuit test then expresses every invariant query with the same prime. Thus the sentences of define exactly the restrictions of those queries to the class. A polynomially clocked machine correct only on the promise gives the same conclusion. Its simulation on the definable matrix is invariant on all inputs and agrees with the query on the promised class, even when membership in the class is undecidable.
One polynomial-time witness for all primes
We define a Boolean query on all simple graphs. First apply the first-order decoder of the incidence encoding for the CFI signature. Require a nonempty decoded domain, a total preorder on it, and a successor relation consisting of one directed cycle on each equivalence class of the preorder. Require all cycles to have the same prime length . Reject if any of these tests fails.
Choose an origin in each cycle and follow its successor to give its elements coordinates in . Introduce one unknown in that field per class . For the decoded inverse and ternary relations, partition their tuples by their ordered lists of classes. Each nonempty block with list gives a table , where or . Require to be an affine subspace, and impose the constraint . Empty blocks contribute no constraint. Accept exactly when all tests pass and the resulting system is soluble.
This defines an invariant polynomial-time query even on malformed encodings. Gaussian elimination computes the affine hull of each nonempty block and equations for it. A block with hull of dimension equals its hull exactly when it has entries. Solve the combined system by elimination. The field size is at most the input size. Changing the origins translates each unknown and its occurrences in all tables by the same offset. Thus solubility and the tests for affine subspaces are independent of these choices. On an encoded the inverse blocks impose negation and the ternary blocks prescribe the sum at each vertex. The flow count gives
The field is read from the graph, so the query is common to all primes.
Blass et al. [4] used padded CFI structures to separate fixed-point logic with counting from choiceless polynomial time. Their padding by isolated vertices permits arbitrary permutations of those vertices. Here the size of the full automorphism group is part of the hypothesis, so we use a single path.
Fix , an unbounded , and a proposed formula. Choose its encoded CFI pair as in the one-prime lower bound. Let be their common order and . Every tail of is unbounded, so there exists with and . Add a disjoint path on vertices to each graph. It is larger than every old component and has two automorphisms. The new automorphism group order is therefore , and both padded graphs lie in . No path vertex has the two leaf neighbours required by the decoder, so still distinguishes the graphs.
Extend the designated -group on each core by the identity on the path. Match core coordinates as in the one-prime lower bound and match path vertices and numbers by equality. Once the path vertices and numbers of a tuple are specified, its stabiliser orbit is determined by its core coordinates. The orbit correspondence therefore extends to mixed tuples and still commutes with forgetting parameters. Adjacency is preserved, since the path and the core are disjoint.
These are the hypotheses used in the induction of the preservation lemma. Modular binders match unions of the extended orbits, and fixed-point updates preserve the matching at every stage. The formula’s tuple-length bound is independent of . Thus the two padded graphs agree on the proposed sentence, although distinguishes them. A proposed canoniser likewise assigns the same matrix to the two nonisomorphic graphs.
For the bounded case, suppose . Whenever the current pointwise stabiliser in a Sylow -subgroup is nontrivial, choose a vertex that it moves. Fixing that vertex decreases its order by a factor of at least . After at most choices the stabiliser is trivial, so the bounded-base result applies. The same argument works when bounds just the Sylow order, and a bound on the base size is the hypothesis itself. Conversely, the padded examples meet all three unbounded bounds because the full group order bounds both other parameters. The equivalences in the one-prime canonisation theorem concern classes specified by a numerical bound alone. Particular graph classes with unbounded automorphism groups, such as the complete graphs, can still admit a definable canonical copy.
What remains for polynomial-time evaluation
The construction expresses every PTIME graph property on the ordered copy. Its evaluation cost comes from the modular prefix test. Lichter and Schweitzer [21] obtain a different connection in choiceless polynomial time with witnessed symmetric choice. In their logic, definable isomorphism yields definable canonisation on classes closed under individualisation.
For the full language, modular circuit satisfiability already occurs on simple graphs. Encode the gate types and wires of a Boolean circuit by the incidence encoding. A first-order formula requires a vertex set to consist exactly of the gates assigned true in a consistent evaluation with true output. Each satisfying input has one such extension, so applied to this formula tests modular circuit satisfiability. The encoding takes polynomial time. A polynomial-time evaluator for every fixed sentence would therefore put both and in P.
The prefix test. Fix the primes and the canonical placement algorithm. Call reached if it occurs during the construction of the matrix on . Consider the promise problem with input and a reached, unfinished prefix . Is nonzero modulo ?
The test and the matrix are polynomial-time equivalent. Starting from the empty prefix, calls recover the matrix, and each call uses the prefix reached so far. Conversely, given the matrix, read the bit after . It is zero exactly when is nonzero modulo . A polynomial-time algorithm for the test would therefore give a logic capturing PTIME by evaluation on the copy. Comparing the matrices of two graphs would also decide isomorphism in polynomial time.
Circulant graphs of bounded odd part
A graph is circulant if it has an automorphism consisting of a single cycle through all its vertices. If the odd part of the cycle length is bounded, only polynomially many frames are fixed by the subgroup of rotations of power-of-two order.
Proposition (Circulants of bounded odd part). Fix . On circulant graphs of order , with odd and , every frame-prefix parity is computable in deterministic polynomial time from the graph alone. Consequently ordinary ordered IFP evaluated on the copy , for any odd prime , captures PTIME on this class.
Proof. Evdokimov and Ponomarenko [8] compute a cycle base in polynomial time. On a circulant graph this gives a full-cycle automorphism . Put . The permutation has cycles of length . The cyclic group generated by has power-of-two order and preserves the placed string of each frame it moves. Every prefix parity is therefore the parity of its matching -fixed frames.
When there is just one such frame. Number the vertices along in . Each level of a fixed binary tree is a partition invariant under translations. The block containing zero is a subgroup, and the other blocks are its cosets. At depth the cyclic group has a unique subgroup of index . Thus the levels are exactly the partitions into residue classes modulo . One placement of this explicit frame answers all prefix queries.
For bounded , the top slots have distinct sizes , with ranging over the powers of two occurring in . Assign whole cycles of to these slots in at most ways. Let count the balanced trees on one slot preserved by its cycles. We have , and counts all balanced trees on leaves. For ,
In the first term each root child receives half the cycles. In the second term exchanges the children, so their leaves alternate around each cycle. There are unordered choices of halves. One half carries cycles of of length . Choosing its tree determines the other by transport.
For fixed , induction on gives . Indeed the first summand is . Dividing by gives , where . The sum of the error terms over powers of two is bounded. The same splits enumerate the trees. Always process the child containing the least input vertex first to avoid duplicates. Every partial choice extends to an output, and the path to an output has at most splits. Thus the enumeration visits at most partial choices per output on average. Each choice takes polynomial time. The bound on makes the product of the slot counts polynomial in . Run placement on each resulting frame and count the requested prefix modulo two. The answer depends only on the original frame count, so any full cycle returned by the algorithm gives the same answers. The capture assertion follows by evaluating ordered IFP on this copy.
The parity test on odd cycles
Numbering an odd cycle consecutively gives it a canonical form. To compute the matrix defined by the two-prime construction, we must recover the bits chosen by the parity test. Each frame is a forest of full binary trees, one for each power of two in the binary expansion of . The singleton slot provides a distinguished leaf. Rotate the cycle until this leaf is at vertex 0. Each anchored frame then accounts for rotations, an odd number. Reflection about 0 pairs the remaining frames unless it preserves their trees. Let denote the anchored frames fixed by this reflection. For every prefix ,
For example, on there are nine anchored frames fixed by reflection. Seven place 00 first. Of those seven, three continue with zero and four with one, so the algorithm chooses 000. Counting all labelled copies of the cycle would assign a different multiplicity to the same strings.
For the counts below, fix and write . Let be the largest power of two at most . Write the cycle in the order , with singleton slot at 0. Reflection sends to . We use the placement algorithm and numerical pair order of the two-prime construction. On every placement gives the string 111.
Counting at the beginning and end of the matrix
The -orbit of the first output position consists of the sibling pairs in the largest slot. The Babai–Luks algorithm minimises the bit at the least position of its current domain. In an intransitive call it places the orbit of that position first. In a transitive call it keeps the least of the recursively placed strings. Induction on these two cases gives the claim. The first placed bit is therefore one exactly when all sibling pairs are cycle edges.
For a power of two , let count the balanced binary trees on specified leaves preserved by an involution with transpositions. This is in the count for circulant graphs. We have and, for ,
The factorial counts trees whose two halves are exchanged. The half containing the least leaf contains one leaf from each transposition, giving choices for that half. Its leaves admit trees, each of which determines the reflected tree in the other half. The second term counts the trees whose halves are preserved.
Write as a sum of distinct powers of two. There are
ways to distribute prescribed reflection pairs among the slots of sizes and choose a reflection-invariant tree in each slot. The empty product gives . There are anchored reflection-fixed frames in total. The number placing one first is
To see this, the sibling edges must form a reflection-invariant matching disjoint from the singleton. Since is even, the matching omits the unique edge fixed by reflection, . Choose disjoint edges on the path and take their mirrors. After the edges are contracted, the resulting leaves form reflection pairs in the upper tree. The unused pairs fill the remaining slots. The two first-bit counts are therefore and . All integers in this calculation have bits.
At the second position every frame places zero. Swaps within the pairs and preserve all sibling bits, so the next orbit contains all four cross pairs. At least one is a nonedge, since contains no four-cycle. On , fix the distance pair in the two-leaf slot. The four-leaf slot has three possible sibling partitions. Inspecting its cross pairs gives the prefixes 000, 000, 000 for and 100, 001, 001 for each of .
Completing the last rows. Let consist of all required edges of a prefix on the positions. If a vertex has degree above two or a cycle uses fewer than vertices, no completion is possible. A spanning cycle can be tested directly. Otherwise consists of paths, counting isolated vertices. Each completion arranges these paths in cyclic order and orients the nontrivial ones. Enumerate the distinct cycles obtained this way, discard those violating prescribed zeros, and keep only cycles for which .
By the orbit count under the Sylow base bound, a retained cycle occurs with multiplicity . Every element of fixes the singleton slot. Of the cycle automorphisms fixing that vertex, the only possibilities are the identity and its reflection. The multiplicity is therefore odd precisely when the reflection preserves the binary frame. A traversal identifies the vertices exchanged by reflection. We then check whether the reflection preserves each level of the binary forest. This gives both child parities in time by recording the next bit of each accepted cycle. With vertices left after the completed rows, all missing incidences belong to those vertices, so . In particular the last rows admit a polynomial test.
Initial prefixes and binary subtrees
Let be a power of two with . In each slot take the leaf sets of the subtrees of size , or the whole slot if it is smaller. Call these sets cells. The first positions are , all internal to a cell of the largest slot. The set of pairs internal to these largest-slot cells is -invariant. Until the initial positions have been placed, the orbit of the least remaining position lies in this set. Each call on such an orbit reads only its internal bits. Thus the induced graphs in the framed cells of the largest slot determine the first placed bits.
A polynomial test for each fixed initial length. A cell type records the binary tree on leaves and its induced graph up to tree-preserving isomorphism. For fixed the number of types is independent of . Enumerate their possible multiplicities summing to . To count the choices of disjoint framed cells of these types, take numbered copies of each type and count injections of their leaves into the cycle. Within a cell require its edges and forbid its nonedges. Between cells all pairs are unrestricted.
For type , add a subset of the forbidden edges to its required edges and give the term the inclusion–exclusion sign of that subset. A vertex of degree above two precludes an embedding. So does a cycle, since . In every other term the graph is a union of paths. Record with the corresponding sign, where counts all path components, including isolated vertices, and counts the nontrivial ones. Let be the resulting polynomial. In , multiply the coefficient of by
Choose a clockwise direction. A designated path starts at one of cycle positions. Order the others around the cycle, orient the nontrivial paths and distribute the unused vertices among the gaps. Summing gives the injection count. Divide this integer by . The factorials forget the ordering of cells of the same type. The automorphism factors forget the isomorphisms to their numbered representatives. The product has degree at most in each variable, and its coefficients have polynomial bit length.
It remains to sum over the trees joining the cells. Permuting equal-type cells preserves the test by locality. In each type, partition its cells into batches of the sizes in the binary expansion of . Put a fixed binary tree on each batch. The product of the automorphism groups of these trees is a 2-group, so only its fixed upper trees contribute to parity. Each batch must occur intact with its prescribed hierarchy. A transposition fixing all other leaves forces the two leaves it exchanges to be siblings. Inductively a swap of two already identified subtrees fixing everything outside them forces them to be siblings as well. Conversely, every balanced tree joining the intact batches is fixed.
If there are types, at most new batches enter at each size and at most trees arrive from the previous size. Pair these trees in all possible ways at each level. At most choices per level over levels give polynomially many trees for fixed . For each upper tree, set the edges outside the cells to zero and run placement. Multiply the parity of the number passing the prefix test by the number of choices of cells. The forest outside the largest slot has an odd number of choices, the index of its binary tree group in the symmetric group. Summing over the multiplicities gives the required parity. The degree of the running-time polynomial depends on .
A cancellation for growing cells. Suppose . Consider anchored frames fixed by reflection in which reflection exchanges the two children of the largest tree. For every prefix of length at most , an even number of these frames give that prefix. This holds also when grows with .
To prove this, group the distance labels according to the reflection orbit of the cell containing . The cell containing lies in the same orbit. Fix the resulting partition of distance labels. For each maximal consecutive interval in one part, interchange and on that interval. These permutations preserve the partition and commute with reflection. They preserve the anchored family under study, including the condition on the two children of the largest tree.
A flip can change adjacencies only across an interval boundary. There the two consecutive labels are in different cell orbits, so none of the changed pairs is internal to a cell. Each flip preserves the set of edges incident with and fixes the edge setwise. By locality, each prefix test is constant on orbits of the -group generated by the flips. It suffices to consider frames fixed by every flip. If reflection exchanges two cells in such a frame, their distance labels form a single interval. Otherwise a flip of one maximal interval would move only part of a cell to its mirror. Flipping the whole interval exchanges these two cells and fixes all other leaves. The cells must be siblings, since a swap at their least common ancestor moves every leaf below it. Hence reflection preserves every subtree of size at least setwise. When it cannot exchange the two root children, which proves the cancellation. For we may take .
On the cancellation fails at a later reached prefix. Removing the singleton leaves a path with a unique perfect matching. Contracting its edges to eight leaves reduces the check to the balanced trees on those leaves. Keep the preserved by path reversal and apply the canonical placement algorithm to each expanded tree. At the reached prefix , the zero and one counts are for exchanged halves and for preserved halves. Together these give , so the exchanged halves determine the next bit.
Width of a representation on adjacency bits
Let be the set of distinct placed cycles extending with odd frame multiplicity. A pointwise factorisation represents its indicator as over for every assignment of the adjacency bits , with auxiliary Boolean variables . Summing out all but the next adjacency bit then gives the two child parities.
In a tree decomposition each node carries a set of variables, or bag. Every factor has its variables together in a bag, and the bags containing each variable form a connected subtree. An elimination order of width yields bags of size at most .
Proposition (Width at the prefix 00). For , the prefix is reached on . Every pointwise factorisation of on its adjacency bits has bag size .
Proof. Size of the surviving family. Here . In the first-bit count, is a power of two. Writing , the binomial coefficient is . It is even because, over , the coefficient of in vanishes. The root count is odd, hence the algorithm chooses zero. The second bit always vanishes by the sibling-swap argument above.
There are at least distinct members of . Make every reflection pair a sibling pair and choose an arbitrary binary frame on the pairs. The number of choices is . Only one reflection pair is a cycle edge, so the largest slot contains a sibling nonedge and the placed prefix is 00. Two anchored frames have the same placed string precisely when a cycle automorphism fixing 0 transports one to the other. Both such automorphisms fix every constructed frame. The strings are therefore distinct, each represented once among anchored fixed frames.
A counting bound for fixed degrees. Let be any family on possible edges with a common degree vector and edges per graph. If its indicator has bag size , put . We claim that .
Attach a leaf for each visible bit to a bag containing it, using an equality to read that bit. Split high-degree bags into binary trees of identical bags, prune branches with no visible leaves, and suppress unary nodes. In the resulting binary tree the leaves are the possible edge positions. Across any cut, the matrix of the indicator with rows and columns indexed by assignments on opposite sides has rank at most . Fixing the shared bag variables separates the factors. Summing over their assignments gives at most outer products, also over . A leaf cut has rank at most two.
Each degree vector realised on the descendant side requires vector on the other, with degrees taken over the integers. Group rows and columns by these vectors. Distinct realised vectors give disjoint nonzero diagonal blocks, so there are at most of them per cut.
To encode a graph from the family, mark the leaves corresponding to its edges. Work upwards, detaching a nonroot subtree as soon as it contains at least still-attached marks. Each child passed up fewer than marks, so every resulting piece has at most marks. At most cuts were made. Record each cut and its degree vector for the entire original descendant subtree. Padding the list to entries with a blank symbol gives at most possible values.
Subtracting the vectors at the cuts immediately below a piece from its subtree vector (using at the root) gives the degrees inside the piece. If it has marked edges, those degrees specify labelled edge ends. At most pairings need be considered. A piece with no edges has one possible graph. Multiplication over the pieces gives at most graphs per record, proving the claim. Now take and . The two bounds give . Subtracting the logarithmic term gives the stated lower bound on .
The fixed-length algorithm computes both child parities at 00 in polynomial time. It does so without representing membership in on all adjacency bits. Whether both child parities can be computed in polynomial time at every reached prefix remains open even for odd cycles. A polynomial-time test for the zero child at every reached prefix on arbitrary graphs would give a logic capturing PTIME by evaluation on the canonical copy.
References
- [2]László Babai and Eugene M. Luks (1983). Canonical labeling of graphs. In 15th Annual ACM Symposium on Theory of Computing (STOC), 171–183.DOI
- [3]Richard Beigel and John Gill (1992). Counting classes: thresholds, parity, mods, and fewness. Theoretical Computer Science 103(1), 3–23.
- [4]Andreas Blass, Yuri Gurevich and Saharon Shelah (2002). On polynomial time computation over unordered structures. Journal of Symbolic Logic 67(3), 1093–1125.DOI
- [5]Jin-Yi Cai, Martin Fürer and Neil Immerman (1992). An optimal lower bound on the number of variables for graph identification. Combinatorica 12(4), 389–410.
- [6]Kevin J. Compton and Erich Grädel (1996). Logical definability of counting functions. Journal of Computer and System Sciences 53(2), 283–297.
- [7]Anuj Dawar, Erich Grädel and Wied Pakusa (2019). Approximations of isomorphism and logics with linear-algebraic operators. In 46th International Colloquium on Automata, Languages, and Programming (ICALP), LIPIcs 132, 112:1–112:14.
- [8]Sergei Evdokimov and Ilia Ponomarenko (2004). Circulant graphs: recognizing and isomorphism testing in polynomial time. St. Petersburg Mathematical Journal 15(6), 813–835.
- [9]John Faben and Mark Jerrum (2015). The complexity of parity graph homomorphism: an initial investigation. Theory of Computing 11(2), 35–57.
- [10]Merrick L. Furst, John E. Hopcroft and Eugene M. Luks (1980). Polynomial-time algorithms for permutation groups. In 21st Annual Symposium on Foundations of Computer Science (FOCS), 36–41.DOI
- [11]Vaani Goenka and Aalok Thakkar (2026). Graph and Tensor Canonisation by Modular Counting. Companion manuscript.
- [12]Erich Grädel, Martin Grohe, Benedikt Pago and Wied Pakusa (2019). A finite-model-theoretic view on propositional proof complexity. Logical Methods in Computer Science 15(1), 4:1–4:55. Corrected version, 2022.
- [13]Erich Grädel and Wied Pakusa (2019). Rank logic is dead, long live rank logic! Journal of Symbolic Logic 84(1), 54–87.DOI
- [14]Martin Grohe (2017). Descriptive Complexity, Canonisation, and Definable Graph Structure Theory. Lecture Notes in Logic 47. Cambridge University Press.DOI
- [15]Yuri Gurevich (1988). Logic and the challenge of computer science. In Egon Börger, editor, Current Trends in Theoretical Computer Science, 1–57. Computer Science Press.
- [16]Yuri Gurevich and Saharon Shelah (1986). Fixed-point extensions of first-order logic. Annals of Pure and Applied Logic 32, 265–280.
- [17]Neil Immerman (1986). Relational queries computable in polynomial time. Information and Control 68(1–3), 86–104.DOI
- [18]Johannes Köbler and Oleg Verbitsky (2008). From invariants to canonization in parallel. In Computer Science – Theory and Applications (CSR), 216–227.
- [20]Juha Kontinen and Heribert Vollmer (2010). On second-order monadic monoidal and groupoidal quantifiers. Logical Methods in Computer Science 6(3), article 25.DOI
- [21]Moritz Lichter and Pascal Schweitzer (2024). Choiceless polynomial time with witnessed symmetric choice. Journal of the ACM 71(2), article 7, 1–70.
- [22]Moshe Y. Vardi (1982). The complexity of relational query languages (extended abstract). In 14th Annual ACM Symposium on Theory of Computing (STOC), 137–146.DOI
- [23]Helmut Wielandt (1969). Permutation Groups through Invariant Relations and Invariant Functions. Lecture notes by Frank Demana, William McWorter and Surinder Sehgal. The Ohio State University, Columbus.