When a scheduling or planning problem with many-valued variables is handed to a SAT or QBF solver, each variable must be written in Boolean form. One convention, "one-hot" encoding, spends one Boolean per value and adds clauses forcing exactly one of them to be true. The other, logarithmic encoding, spends only $\lceil \log_2 d \rceil$ bits for a domain of size $d$ and gives each value its own bit string. Logarithmic encoding removes the huge space of illegal "several values at once" assignments. That can matter a great deal: in adversarial QBF games it turned a run of more than 2,000 seconds into 0.03 seconds (The Achilles' Heel of QBF). The standard complaint is that it also destroys useful structure. Fixing one bit only halves a domain, so unit propagation (the solver's cheap forced-deduction step) prunes weakly. Orderings on values that made some constraints easy to solve, such as "the allowed values of $y$ for each value of $x$ form a contiguous interval," appear to disappear once the values are scattered over the corners of a hypercube.
This note argues that most of that damage comes from an arbitrary choice rather than from logarithmic encoding itself: which bit string is assigned to which value. Suppose codes are assigned so that the sets of values each constraint allows fall on a few aligned sub-cubes of the bit space, that is, sets of codewords fixed on some bits and free on the rest. Then three things should follow. The clausal encoding stays small. Unit propagation removes whole blocks of values at once. The domain-shrinking steps from the constraint literature that preserve easy structure, in particular merging two interchangeable values, become simple bit-level operations instead of forcing a re-encoding. We propose to define this "code alignment" precisely, build encoders that optimize it, and test whether it measurably changes solver behavior. A clean negative result is also possible: modern clause-learning solvers may make the code choice irrelevant.
Core Claim
For a binary constraint $R$ between variables $x$ and $y$ with value-to-bit-string maps $c_x$ and $c_y$, define the cube cost
$$\kappa(R; c_x, c_y) = \sum_{a \in D_x} \mathrm{cov}\big(c_y(\{b : (a,b)\notin R\})\big).$$
Here $\mathrm{cov}(S)$ is the minimum number of sub-cubes of $\{0,1\}^k$ needed to cover a set $S$ of codewords, where $k = \lceil \log_2 |D_y| \rceil$ is the number of bits for $y$. Codewords assigned to no value may be used freely in a cover. $\kappa$ equals the number of clauses needed to write the forbidden pairs of $R$ in conflict form over $x$'s value literals and $y$'s bits. Each clause also detects a whole block of values for propagation, so lower $\kappa$ means both fewer clauses and coarser pruning.
The concrete, falsifiable claim has two parts. First, for constraint families known to be well structured, and in particular connected row convex constraints, whose allowed values in every row form one contiguous run (Fast Algorithm for Connected Row Convex Constraints), an order-respecting binary code bounds $\mathrm{cov}$ of each row by $2\lceil \log_2 d \rceil$. The bound comes from the standard fact that any integer interval splits into at most two dyadic blocks per bit level, and each dyadic block is a sub-cube. A random code gives no such bound. Second, this gap in cube cost produces measurable differences in encoding size, in root-level propagation strength, and in solver runtime between the structure-aware code and a random code, with everything else held fixed.
Relation to Prior Work
Three papers supply the motivating evidence that logarithmic encoding pays off in practice. The Achilles' Heel of QBF uses it to stop QBF solvers from refuting illegal universal moves one by one. Optimal Counterfactual Explanations in Tree Ensembles uses logarithmically many binaries to select tree vertices in an integer program, cutting non-zeros on Adult from about 163,000 to about 18,000. Optimal Decision Diagrams for Classification uses the same idea to get $O(n \log |V|)$ binaries for flow on a diagram skeleton. All three treat the value-to-code map as a fixed bookkeeping choice. None asks whether a different assignment would change solver behavior, and that question is what this proposal is about.
Four papers supply methods and constraints on the structural side. Fast Algorithm for Connected Row Convex Constraints shows that row convexity survives composition and elimination and exploits contiguous boundaries. We reuse its geometric view to argue that contiguity survives into dyadic sub-cubes. On Broken Triangles merges two values of a variable when no "broken triangle" pattern with other variables blocks it. We observe that if two mergeable values are given codewords differing in a single bit, the merge amounts to declaring that bit irrelevant in that value's context. The encoding then shrinks instead of being rebuilt. The satisfiability-preserving elimination rules of Variable Elimination in Binary CSPs and A BTP-Based Family of Variable Elimination Rules for Binary CSPs remove whole variables without adding constraints. Under logarithmic encoding, such a removal deletes a whole bit register. We check whether the remaining clauses stay as small as the multi-valued rule promises.
Two results constrain the design. Encoding Constraints as Binary Constraint Networks Satisfying BTP proves that networks with the broken-triangle property are limited to monotone circuits. Decoding a bit register needs negation, so we deliberately do not claim that broken-triangle tractability transfers to the bit level. We only claim that value-level merges and eliminations performed before encoding map cleanly onto the code. Separately, choosing a single value ordering that makes many constraints simultaneously convex inherits the hardness of ordering problems noted for directional broken-triangle orders in On Broken Triangles. Our code optimizer is therefore heuristic, and we say so.
The closest structural competitor is Encoding Multi-Valued Decision Diagram Constraints as Binary Constraint Trees. It compiles large constraints into tree-shaped binary networks where arc consistency equals full generalized arc consistency. Its bit-level work is word-parallel operations on one-bit-per-value domain masks, not logarithmic registers. It stays inside a constraint programming solver, whereas we target clausal and QBF solvers, where one-hot blow-up is the documented problem.
Research Program
The first component is analysis. For connected row convex, row convex, and tree convex constraints (Tractable Tree Convex Constraint Networks), we will prove upper bounds on $\kappa$ under order-respecting binary and reflected Gray codes, and lower bounds showing random codes need on the order of $d/2$ cubes per row on typical intervals. We will then characterize exactly what unit propagation on the resulting clauses achieves. Our conjecture, which we will prove or refute, is that it enforces "block consistency": a value is pruned only when its entire dyadic block has no support. This sits strictly between no pruning and arc consistency. Any refinement that recovers arc consistency on connected row convex networks, for example adding one auxiliary literal per dyadic block, would be reported with its size cost.
The second component handles the codewords left over when $d$ is not a power of two, the case the file flags as reintroducing awkward blocking clauses. We compare three treatments. The first blocks the unused codewords explicitly. The second places them at the end of the order and lets them act as free cover elements, as in the definition of $\kappa$. The third aliases each unused codeword to a duplicate of an existing value. Aliasing removes blocking clauses entirely but multiplies solutions, the same side effect the elimination literature reports for DE-snake (Variable Elimination in Binary CSPs). It is therefore acceptable for satisfiability but not for model counting, and we will measure its effect on both.
The third component is the encoder. It reads an XCSP instance and runs value merging and elimination from On Broken Triangles at the multi-valued level. It then computes a per-variable value order by consecutive-ones testing where a consistent order exists, falling back to spectral ordering of the constraint rows. It assigns codes that place merge candidates at Hamming distance one, refines the codes by local search over bit permutations and complements to minimize total $\kappa$, and emits CNF, or QCNF for game instances. The encoder's own running time is reported as part of total runtime.
Baselines
The naive reference point is the same pipeline with a uniformly random value-to-codeword map. It uses the same preprocessing, the same treatment of unused codewords, and the same SAT solver. This is the ablation that isolates the proposal's key ingredient: if structure-aware codes do not beat random codes, the claim fails regardless of any other comparison. We will run five random seeds per instance and report the median. No reported result found on Lacuna for random-code logarithmic encodings of CSPs.
The second baseline is one-hot (direct) encoding with a compact at-most-one encoding, given to the same clause-learning SAT solver on the same instances with the same timeout. This is the default most practitioners would reach for, and it has the strongest unit propagation per value. Beating it means solving more instances or achieving lower penalized average runtime on instance families where row-convex or tree-convex structure is prevalent. We do not expect to beat it everywhere, and we will report where we lose. No reported result found on Lacuna for SAT encodings of the XCSP table instances.
The strongest existing method on these instances is native constraint programming with the tree binary encoding of Encoding Multi-Valued Decision Diagram Constraints as Binary Constraint Trees. That paper reports it was "the fastest algorithm on 71% of the table instances tested" on more than 2,500 XCSP table instances, and up to 12x faster than the Compact Table algorithm. We will run the authors' propagator, or a faithful reimplementation if the code is unavailable, with the same machine, timeout, and search heuristics as reported in that paper. We will not claim to beat it overall. The claim is narrower: on families with strong convexity structure, a code-aligned SAT encoding closes a substantial part of the gap between one-hot SAT and this solver. The file gives no per-family numbers, so the comparison will be made on our reruns.
For the QBF setting, the baseline is Model B of The Achilles' Heel of QBF, which reported 0.03 seconds on the 4×4, 7-step Evader/Pursuer game against more than 2,000 seconds for the previous best solver. Model B's code is effectively arbitrary with respect to board geometry. Beating it means lower runtime or longer solvable horizons on 8×8 boards when positions are coded so that the sets of legal moves form aligned sub-cubes.
Why not just…?
Why not just use one-hot encoding and let clause learning recover the structure? This is the most serious threat. The random-code versus aligned-code ablation is designed to expose it. If a modern solver's learned clauses make the two codes indistinguishable in runtime, even though $\kappa$ differs by a large factor, then code choice is cosmetic. We would report that as the main finding. The existing evidence points the other way. The QBF gains in The Achilles' Heel of QBF and the counterfactual integer-programming gains in Optimal Counterfactual Explanations in Tree Ensembles show that representation matters even with strong solvers. The file's summary of work on clausal conversion (e.g. Meel et al., Sabharwal) says flattening hides structure that learning does not reliably rediscover.
Why not just stay in a native constraint solver with table or tree-binary propagators? For pure constraint satisfaction on table instances, that may simply be the better tool. Encoding Multi-Valued Decision Diagram Constraints as Binary Constraint Trees is fastest on most XCSP table instances. Our motivation is the settings where a Boolean backend is required or clearly preferable: quantified games, MaxSAT, QUBO hardware (Algorithmic QUBO Formulations for k-SAT and Hamiltonian Cycles). In those settings the choice is between Boolean encodings, not between Boolean and native constraint solving. The XCSP comparison is included so that readers can see how large the remaining gap is, not to claim superiority.
Why not just run broken-triangle merging and elimination on the multi-valued problem and encode however you like? We do run them, as the first stage of our encoder. On their own they are often inert: On Broken Triangles reports a reduction "as low as 0.02%" on general benchmarks, against 98% on marc. The question is whether the code adds value beyond what merging provides. The experiment compares merging followed by random codes with merging followed by aligned codes, so any gain from the code is measured on top of the gain from merging.
Proposed Experiments
The first check is purely structural. On all CPAI08 and XCSP instances (the 3,811 and more than 2,500 instance collections used in the cited papers), we compute total $\kappa$ and clause counts for random, order-respecting binary, Gray, and optimized codes, broken down by instance family. This tells us cheaply whether alignment exists in real instances before any solver is run.
The second check measures propagation strength. At the root and after each of the first 1,000 decisions, we record the fraction of values that arc consistency would prune which unit propagation on the encoding actually prunes, for each encoding. This tests the block-consistency conjecture directly.
The third check is end-to-end. We compare solved instances and penalized average runtime (unsolved runs charged at twice the timeout), at a fixed timeout, across one-hot, random-code logarithmic, aligned-code logarithmic, and native tree-binary constraint programming. Results are reported per family and correlated with the family's measured convexity.
The fourth check covers Evader/Pursuer games on 4×4 and 8×8 boards, comparing Model B against geometry-aligned codes over increasing horizons. It also compares the three treatments of unused codewords, measuring runtime for satisfiability and solution-count inflation for model counting.
The decisive outcome is the relationship between the reduction in $\kappa$ and the runtime gain of aligned over random codes within each family. A clear positive relationship supports the claim. A flat relationship means clause learning absorbs the code choice, and the proposal would then be reported as a negative result.
References
- The Achilles' Heel of QBF
- Fast Algorithm for Connected Row Convex Constraints
- Optimal Counterfactual Explanations in Tree Ensembles
- Optimal Decision Diagrams for Classification
- On Broken Triangles
- Variable Elimination in Binary CSPs (Extended Abstract)
- A BTP-Based Family of Variable Elimination Rules for Binary CSPs
- Encoding Constraints as Binary Constraint Networks Satisfying BTP
- Encoding Multi-Valued Decision Diagram Constraints as Binary Constraint Trees
- Tractable Tree Convex Constraint Networks
- Algorithmic QUBO Formulations for k-SAT and Hamiltonian Cycles