Published October 21, 2026 | Version v1

Model Counting as a Sum of Products: Verified Translation and Variable Elimination in Lean 4

Authors/Creators

Description

Weighted model counting is the sum, over all assignments of the variables, of a product of clause indicators and literal weights, that is, an einsum over Boolean indices. Tensor-network and project-join model counters build on this view, but the translation from a formula to a sum of products, and the elimination of variables that makes it efficient, are normally trusted. We formalize both in Lean 4, using only its core library, and prove three results. First, the plan of a weighted CNF evaluates to its weighted model count, which is defined independently by enumerating all 2^n assignments. Second, bucket elimination along any order of the variables computes the same count. Third, an eliminated (nested) plan can be flattened to a sum of monomials by a verified compiler that draws bound names from a counter, so that no variable is captured, also when names are reused; composed, these give an end-to-end theorem. The development is executable; on small instances the choice of order changes the number of table entries by up to a factor of six. We make no performance claim against solvers.

The record contains the manuscript (LaTeX sources in the format of the Journal on Satisfiability, Boolean Modeling and Computation, and PDF) and the Lean 4 artifact (tic_sat_lean.zip), which builds with "bash build.sh" using Lean 4.35.0.

Files

jsat.pdf

Files (2.0 MB)

Name Size
md5:87fba1382f677ec7de4d82be046a6d8f
2.0 MB Preview Download
md5:328b65bcaf5b0e9ea42060ca88db1113
21.6 kB Download
md5:e68fed453b8677c79f256bbf6beea8a2
43.6 kB Preview Download

Additional details

Software

Repository URL
https://zenodo.org/records/23539427
Programming language
Lean
Development Status
Active